diff options
| -rw-r--r-- | arch/x86/kernel/amd_iommu_init.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c index 6e1c8ffc0c5b..1f148393cf7a 100644 --- a/arch/x86/kernel/amd_iommu_init.c +++ b/arch/x86/kernel/amd_iommu_init.c | |||
| @@ -33,7 +33,6 @@ | |||
| 33 | #define DEVID(bus, devfn) (((bus) << 8) | (devfn)) | 33 | #define DEVID(bus, devfn) (((bus) << 8) | (devfn)) |
| 34 | #define PCI_BUS(x) (((x) >> 8) & 0xff) | 34 | #define PCI_BUS(x) (((x) >> 8) & 0xff) |
| 35 | #define IVRS_HEADER_LENGTH 48 | 35 | #define IVRS_HEADER_LENGTH 48 |
| 36 | #define TBL_SIZE(x) (1 << (PAGE_SHIFT + get_order(amd_iommu_last_bdf * (x)))) | ||
| 37 | 36 | ||
| 38 | #define ACPI_IVHD_TYPE 0x10 | 37 | #define ACPI_IVHD_TYPE 0x10 |
| 39 | #define ACPI_IVMD_TYPE_ALL 0x20 | 38 | #define ACPI_IVMD_TYPE_ALL 0x20 |
| @@ -170,6 +169,14 @@ static inline void update_last_devid(u16 devid) | |||
| 170 | amd_iommu_last_bdf = devid; | 169 | amd_iommu_last_bdf = devid; |
| 171 | } | 170 | } |
| 172 | 171 | ||
| 172 | static inline unsigned long tbl_size(int entry_size) | ||
| 173 | { | ||
| 174 | unsigned shift = PAGE_SHIFT + | ||
| 175 | get_order(amd_iommu_last_bdf * entry_size); | ||
| 176 | |||
| 177 | return 1UL << shift; | ||
| 178 | } | ||
| 179 | |||
| 173 | /**************************************************************************** | 180 | /**************************************************************************** |
| 174 | * | 181 | * |
| 175 | * AMD IOMMU MMIO register space handling functions | 182 | * AMD IOMMU MMIO register space handling functions |
| @@ -884,9 +891,9 @@ int __init amd_iommu_init(void) | |||
| 884 | if (acpi_table_parse("IVRS", find_last_devid_acpi) != 0) | 891 | if (acpi_table_parse("IVRS", find_last_devid_acpi) != 0) |
| 885 | return -ENODEV; | 892 | return -ENODEV; |
| 886 | 893 | ||
| 887 | dev_table_size = TBL_SIZE(DEV_TABLE_ENTRY_SIZE); | 894 | dev_table_size = tbl_size(DEV_TABLE_ENTRY_SIZE); |
| 888 | alias_table_size = TBL_SIZE(ALIAS_TABLE_ENTRY_SIZE); | 895 | alias_table_size = tbl_size(ALIAS_TABLE_ENTRY_SIZE); |
| 889 | rlookup_table_size = TBL_SIZE(RLOOKUP_TABLE_ENTRY_SIZE); | 896 | rlookup_table_size = tbl_size(RLOOKUP_TABLE_ENTRY_SIZE); |
| 890 | 897 | ||
| 891 | ret = -ENOMEM; | 898 | ret = -ENOMEM; |
| 892 | 899 | ||
