diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2009-12-10 05:03:39 -0500 |
---|---|---|
committer | Joerg Roedel <joerg.roedel@amd.com> | 2009-12-10 06:21:31 -0500 |
commit | b7cc9554bc73641c9ed4d7eb74b2d6e78f20abea (patch) | |
tree | 42a90d0bcef2932b3aca414bf6620fb13685e9b7 /arch/x86/kernel/amd_iommu.c | |
parent | 4528752f49c1f4025473d12bc5fa9181085c3f22 (diff) |
x86/amd-iommu: Fix passthrough mode
The data structure changes to use dev->archdata.iommu field
broke the iommu=pt mode because in this case the
dev->archdata.iommu was left uninitialized. This moves the
inititalization of the devices into the main init function
and fixes the problem.
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.c | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c index 32fb09102a13..450dd6ac03d3 100644 --- a/arch/x86/kernel/amd_iommu.c +++ b/arch/x86/kernel/amd_iommu.c | |||
@@ -166,6 +166,43 @@ static void iommu_uninit_device(struct device *dev) | |||
166 | { | 166 | { |
167 | kfree(dev->archdata.iommu); | 167 | kfree(dev->archdata.iommu); |
168 | } | 168 | } |
169 | |||
170 | void __init amd_iommu_uninit_devices(void) | ||
171 | { | ||
172 | struct pci_dev *pdev = NULL; | ||
173 | |||
174 | for_each_pci_dev(pdev) { | ||
175 | |||
176 | if (!check_device(&pdev->dev)) | ||
177 | continue; | ||
178 | |||
179 | iommu_uninit_device(&pdev->dev); | ||
180 | } | ||
181 | } | ||
182 | |||
183 | int __init amd_iommu_init_devices(void) | ||
184 | { | ||
185 | struct pci_dev *pdev = NULL; | ||
186 | int ret = 0; | ||
187 | |||
188 | for_each_pci_dev(pdev) { | ||
189 | |||
190 | if (!check_device(&pdev->dev)) | ||
191 | continue; | ||
192 | |||
193 | ret = iommu_init_device(&pdev->dev); | ||
194 | if (ret) | ||
195 | goto out_free; | ||
196 | } | ||
197 | |||
198 | return 0; | ||
199 | |||
200 | out_free: | ||
201 | |||
202 | amd_iommu_uninit_devices(); | ||
203 | |||
204 | return ret; | ||
205 | } | ||
169 | #ifdef CONFIG_AMD_IOMMU_STATS | 206 | #ifdef CONFIG_AMD_IOMMU_STATS |
170 | 207 | ||
171 | /* | 208 | /* |
@@ -2145,8 +2182,6 @@ static void prealloc_protection_domains(void) | |||
2145 | if (!check_device(&dev->dev)) | 2182 | if (!check_device(&dev->dev)) |
2146 | continue; | 2183 | continue; |
2147 | 2184 | ||
2148 | iommu_init_device(&dev->dev); | ||
2149 | |||
2150 | /* Is there already any domain for it? */ | 2185 | /* Is there already any domain for it? */ |
2151 | if (domain_for_device(&dev->dev)) | 2186 | if (domain_for_device(&dev->dev)) |
2152 | continue; | 2187 | continue; |