aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/amd_iommu.c
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2009-11-23 10:14:57 -0500
committerJoerg Roedel <joerg.roedel@amd.com>2009-11-27 08:16:30 -0500
commit420aef8a3acfc3e75427107e23d5a9bafd17c477 (patch)
treed111ab861c9a98ff57388af31fa2cad49f596ed8 /arch/x86/kernel/amd_iommu.c
parent318afd41d2eca3224de3fd85a3b9a27a3010a98d (diff)
x86/amd-iommu: Use check_device for amd_iommu_dma_supported
The check_device logic needs to include the dma_supported checks to be really sure. Merge the dma_supported logic into check_device and use it to implement dma_supported. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'arch/x86/kernel/amd_iommu.c')
-rw-r--r--arch/x86/kernel/amd_iommu.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 5ebd24e4fc57..ac27b1d6bd12 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -1375,9 +1375,27 @@ static struct notifier_block device_nb = {
1375 */ 1375 */
1376static bool check_device(struct device *dev) 1376static bool check_device(struct device *dev)
1377{ 1377{
1378 u16 bdf;
1379 struct pci_dev *pcidev;
1380
1378 if (!dev || !dev->dma_mask) 1381 if (!dev || !dev->dma_mask)
1379 return false; 1382 return false;
1380 1383
1384 /* No device or no PCI device */
1385 if (!dev || dev->bus != &pci_bus_type)
1386 return false;
1387
1388 pcidev = to_pci_dev(dev);
1389
1390 bdf = calc_devid(pcidev->bus->number, pcidev->devfn);
1391
1392 /* Out of our scope? */
1393 if (bdf > amd_iommu_last_bdf)
1394 return false;
1395
1396 if (amd_iommu_rlookup_table[bdf] == NULL)
1397 return false;
1398
1381 return true; 1399 return true;
1382} 1400}
1383 1401
@@ -2065,22 +2083,7 @@ free_mem:
2065 */ 2083 */
2066static int amd_iommu_dma_supported(struct device *dev, u64 mask) 2084static int amd_iommu_dma_supported(struct device *dev, u64 mask)
2067{ 2085{
2068 u16 bdf; 2086 return check_device(dev);
2069 struct pci_dev *pcidev;
2070
2071 /* No device or no PCI device */
2072 if (!dev || dev->bus != &pci_bus_type)
2073 return 0;
2074
2075 pcidev = to_pci_dev(dev);
2076
2077 bdf = calc_devid(pcidev->bus->number, pcidev->devfn);
2078
2079 /* Out of our scope? */
2080 if (bdf > amd_iommu_last_bdf)
2081 return 0;
2082
2083 return 1;
2084} 2087}
2085 2088
2086/* 2089/*