diff options
-rw-r--r-- | arch/x86/kernel/amd_iommu.c | 2 | ||||
-rw-r--r-- | arch/x86/kernel/amd_iommu_init.c | 9 | ||||
-rw-r--r-- | include/asm-x86/amd_iommu_types.h | 7 |
3 files changed, 13 insertions, 5 deletions
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c index dec10e1a397c..8c3deb027d3a 100644 --- a/arch/x86/kernel/amd_iommu.c +++ b/arch/x86/kernel/amd_iommu.c | |||
@@ -664,7 +664,7 @@ static int get_device_resources(struct device *dev, | |||
664 | BUG_ON(!dev || dev->bus != &pci_bus_type || !dev->dma_mask); | 664 | BUG_ON(!dev || dev->bus != &pci_bus_type || !dev->dma_mask); |
665 | 665 | ||
666 | pcidev = to_pci_dev(dev); | 666 | pcidev = to_pci_dev(dev); |
667 | _bdf = (pcidev->bus->number << 8) | pcidev->devfn; | 667 | _bdf = calc_devid(pcidev->bus->number, pcidev->devfn); |
668 | 668 | ||
669 | /* device not translated by any IOMMU in the system? */ | 669 | /* device not translated by any IOMMU in the system? */ |
670 | if (_bdf >= amd_iommu_last_bdf) { | 670 | if (_bdf >= amd_iommu_last_bdf) { |
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c index e0ff9404e6c9..9bf1b8111b08 100644 --- a/arch/x86/kernel/amd_iommu_init.c +++ b/arch/x86/kernel/amd_iommu_init.c | |||
@@ -30,7 +30,6 @@ | |||
30 | /* | 30 | /* |
31 | * definitions for the ACPI scanning code | 31 | * definitions for the ACPI scanning code |
32 | */ | 32 | */ |
33 | #define DEVID(bus, devfn) (((bus) << 8) | (devfn)) | ||
34 | #define PCI_BUS(x) (((x) >> 8) & 0xff) | 33 | #define PCI_BUS(x) (((x) >> 8) & 0xff) |
35 | #define IVRS_HEADER_LENGTH 48 | 34 | #define IVRS_HEADER_LENGTH 48 |
36 | 35 | ||
@@ -295,7 +294,7 @@ static int __init find_last_devid_on_pci(int bus, int dev, int fn, int cap_ptr) | |||
295 | u32 cap; | 294 | u32 cap; |
296 | 295 | ||
297 | cap = read_pci_config(bus, dev, fn, cap_ptr+MMIO_RANGE_OFFSET); | 296 | cap = read_pci_config(bus, dev, fn, cap_ptr+MMIO_RANGE_OFFSET); |
298 | update_last_devid(DEVID(MMIO_GET_BUS(cap), MMIO_GET_LD(cap))); | 297 | update_last_devid(calc_devid(MMIO_GET_BUS(cap), MMIO_GET_LD(cap))); |
299 | 298 | ||
300 | return 0; | 299 | return 0; |
301 | } | 300 | } |
@@ -494,8 +493,10 @@ static void __init init_iommu_from_pci(struct amd_iommu *iommu) | |||
494 | iommu->cap = read_pci_config(bus, dev, fn, cap_ptr+MMIO_CAP_HDR_OFFSET); | 493 | iommu->cap = read_pci_config(bus, dev, fn, cap_ptr+MMIO_CAP_HDR_OFFSET); |
495 | 494 | ||
496 | range = read_pci_config(bus, dev, fn, cap_ptr+MMIO_RANGE_OFFSET); | 495 | range = read_pci_config(bus, dev, fn, cap_ptr+MMIO_RANGE_OFFSET); |
497 | iommu->first_device = DEVID(MMIO_GET_BUS(range), MMIO_GET_FD(range)); | 496 | iommu->first_device = calc_devid(MMIO_GET_BUS(range), |
498 | iommu->last_device = DEVID(MMIO_GET_BUS(range), MMIO_GET_LD(range)); | 497 | MMIO_GET_FD(range)); |
498 | iommu->last_device = calc_devid(MMIO_GET_BUS(range), | ||
499 | MMIO_GET_LD(range)); | ||
499 | } | 500 | } |
500 | 501 | ||
501 | /* | 502 | /* |
diff --git a/include/asm-x86/amd_iommu_types.h b/include/asm-x86/amd_iommu_types.h index 2e8601b0f006..22aa58ca1991 100644 --- a/include/asm-x86/amd_iommu_types.h +++ b/include/asm-x86/amd_iommu_types.h | |||
@@ -332,4 +332,11 @@ static inline void print_devid(u16 devid, int nl) | |||
332 | printk("\n"); | 332 | printk("\n"); |
333 | } | 333 | } |
334 | 334 | ||
335 | /* takes bus and device/function and returns the device id | ||
336 | * FIXME: should that be in generic PCI code? */ | ||
337 | static inline u16 calc_devid(u8 bus, u8 devfn) | ||
338 | { | ||
339 | return (((u16)bus) << 8) | devfn; | ||
340 | } | ||
341 | |||
335 | #endif | 342 | #endif |