diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2009-11-20 08:31:51 -0500 |
---|---|---|
committer | Joerg Roedel <joerg.roedel@amd.com> | 2009-11-27 05:45:49 -0500 |
commit | bb52777ec4d736c2d7c4f037b32d4eeeb172ed89 (patch) | |
tree | dfeed02c76169a92fd04e12145c72f9a0cbaf6f7 /arch/x86/kernel/amd_iommu_init.c | |
parent | bf3118c1276d27fe9e84aa42382da25ee0750777 (diff) |
x86/amd-iommu: Add an index field to struct amd_iommu
This patch adds an index field to struct amd_iommu which can
be used to lookup it up in an array. This index will be used
in struct protection_domain to keep track which protection
domain has devices behind which IOMMU.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'arch/x86/kernel/amd_iommu_init.c')
-rw-r--r-- | arch/x86/kernel/amd_iommu_init.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c index cee11424d412..8567d1698027 100644 --- a/arch/x86/kernel/amd_iommu_init.c +++ b/arch/x86/kernel/amd_iommu_init.c | |||
@@ -137,6 +137,10 @@ bool amd_iommu_unmap_flush; /* if true, flush on every unmap */ | |||
137 | LIST_HEAD(amd_iommu_list); /* list of all AMD IOMMUs in the | 137 | LIST_HEAD(amd_iommu_list); /* list of all AMD IOMMUs in the |
138 | system */ | 138 | system */ |
139 | 139 | ||
140 | /* Array to assign indices to IOMMUs*/ | ||
141 | struct amd_iommu *amd_iommus[MAX_IOMMUS]; | ||
142 | int amd_iommus_present; | ||
143 | |||
140 | /* | 144 | /* |
141 | * Pointer to the device table which is shared by all AMD IOMMUs | 145 | * Pointer to the device table which is shared by all AMD IOMMUs |
142 | * it is indexed by the PCI device id or the HT unit id and contains | 146 | * it is indexed by the PCI device id or the HT unit id and contains |
@@ -840,7 +844,18 @@ static void __init free_iommu_all(void) | |||
840 | static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h) | 844 | static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h) |
841 | { | 845 | { |
842 | spin_lock_init(&iommu->lock); | 846 | spin_lock_init(&iommu->lock); |
847 | |||
848 | /* Add IOMMU to internal data structures */ | ||
843 | list_add_tail(&iommu->list, &amd_iommu_list); | 849 | list_add_tail(&iommu->list, &amd_iommu_list); |
850 | iommu->index = amd_iommus_present++; | ||
851 | |||
852 | if (unlikely(iommu->index >= MAX_IOMMUS)) { | ||
853 | WARN(1, "AMD-Vi: System has more IOMMUs than supported by this driver\n"); | ||
854 | return -ENOSYS; | ||
855 | } | ||
856 | |||
857 | /* Index is fine - add IOMMU to the array */ | ||
858 | amd_iommus[iommu->index] = iommu; | ||
844 | 859 | ||
845 | /* | 860 | /* |
846 | * Copy data from ACPI table entry to the iommu struct | 861 | * Copy data from ACPI table entry to the iommu struct |