Skip to content

Commit

Permalink
x86/amd-iommu: Fix boot crash with hidden PCI devices
Browse files Browse the repository at this point in the history
Some PCIe cards ship with a PCI-PCIe bridge which is not
visible as a PCI device in Linux. But the device-id of the
bridge is present in the IOMMU tables which causes a boot
crash in the IOMMU driver.
This patch fixes by removing these cards from the IOMMU
handling. This is a pure -stable fix, a real fix to handle
this situation appriatly will follow for the next merge
window.

Cc: stable@kernel.org	# > 2.6.32
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
  • Loading branch information
Joerg Roedel committed Jun 7, 2011
1 parent 27c2127 commit 2601887
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion arch/x86/kernel/amd_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ static int iommu_init_device(struct device *dev)
pdev = pci_get_bus_and_slot(PCI_BUS(alias), alias & 0xff);
if (pdev)
dev_data->alias = &pdev->dev;
else {
kfree(dev_data);
return -ENOTSUPP;
}

atomic_set(&dev_data->bind, 0);

Expand All @@ -164,6 +168,20 @@ static int iommu_init_device(struct device *dev)
return 0;
}

static void iommu_ignore_device(struct device *dev)
{
u16 devid, alias;

devid = get_device_id(dev);
alias = amd_iommu_alias_table[devid];

memset(&amd_iommu_dev_table[devid], 0, sizeof(struct dev_table_entry));
memset(&amd_iommu_dev_table[alias], 0, sizeof(struct dev_table_entry));

amd_iommu_rlookup_table[devid] = NULL;
amd_iommu_rlookup_table[alias] = NULL;
}

static void iommu_uninit_device(struct device *dev)
{
kfree(dev->archdata.iommu);
Expand Down Expand Up @@ -193,7 +211,9 @@ int __init amd_iommu_init_devices(void)
continue;

ret = iommu_init_device(&pdev->dev);
if (ret)
if (ret == -ENOTSUPP)
iommu_ignore_device(&pdev->dev);
else if (ret)
goto out_free;
}

Expand Down

0 comments on commit 2601887

Please sign in to comment.