diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/iommu/amd_iommu.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 7de92768871d..8c5216633987 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c | |||
@@ -260,17 +260,13 @@ static bool check_device(struct device *dev) | |||
260 | return true; | 260 | return true; |
261 | } | 261 | } |
262 | 262 | ||
263 | static int init_iommu_group(struct device *dev) | 263 | static void init_iommu_group(struct device *dev) |
264 | { | 264 | { |
265 | struct iommu_group *group; | 265 | struct iommu_group *group; |
266 | 266 | ||
267 | group = iommu_group_get_for_dev(dev); | 267 | group = iommu_group_get_for_dev(dev); |
268 | 268 | if (!IS_ERR(group)) | |
269 | if (IS_ERR(group)) | 269 | iommu_group_put(group); |
270 | return PTR_ERR(group); | ||
271 | |||
272 | iommu_group_put(group); | ||
273 | return 0; | ||
274 | } | 270 | } |
275 | 271 | ||
276 | static int __last_alias(struct pci_dev *pdev, u16 alias, void *data) | 272 | static int __last_alias(struct pci_dev *pdev, u16 alias, void *data) |
@@ -340,7 +336,6 @@ static int iommu_init_device(struct device *dev) | |||
340 | struct pci_dev *pdev = to_pci_dev(dev); | 336 | struct pci_dev *pdev = to_pci_dev(dev); |
341 | struct iommu_dev_data *dev_data; | 337 | struct iommu_dev_data *dev_data; |
342 | u16 alias; | 338 | u16 alias; |
343 | int ret; | ||
344 | 339 | ||
345 | if (dev->archdata.iommu) | 340 | if (dev->archdata.iommu) |
346 | return 0; | 341 | return 0; |
@@ -364,12 +359,6 @@ static int iommu_init_device(struct device *dev) | |||
364 | dev_data->alias_data = alias_data; | 359 | dev_data->alias_data = alias_data; |
365 | } | 360 | } |
366 | 361 | ||
367 | ret = init_iommu_group(dev); | ||
368 | if (ret) { | ||
369 | free_dev_data(dev_data); | ||
370 | return ret; | ||
371 | } | ||
372 | |||
373 | if (pci_iommuv2_capable(pdev)) { | 362 | if (pci_iommuv2_capable(pdev)) { |
374 | struct amd_iommu *iommu; | 363 | struct amd_iommu *iommu; |
375 | 364 | ||
@@ -455,6 +444,15 @@ int __init amd_iommu_init_devices(void) | |||
455 | goto out_free; | 444 | goto out_free; |
456 | } | 445 | } |
457 | 446 | ||
447 | /* | ||
448 | * Initialize IOMMU groups only after iommu_init_device() has | ||
449 | * had a chance to populate any IVRS defined aliases. | ||
450 | */ | ||
451 | for_each_pci_dev(pdev) { | ||
452 | if (check_device(&pdev->dev)) | ||
453 | init_iommu_group(&pdev->dev); | ||
454 | } | ||
455 | |||
458 | return 0; | 456 | return 0; |
459 | 457 | ||
460 | out_free: | 458 | out_free: |
@@ -2415,6 +2413,7 @@ static int device_change_notifier(struct notifier_block *nb, | |||
2415 | case BUS_NOTIFY_ADD_DEVICE: | 2413 | case BUS_NOTIFY_ADD_DEVICE: |
2416 | 2414 | ||
2417 | iommu_init_device(dev); | 2415 | iommu_init_device(dev); |
2416 | init_iommu_group(dev); | ||
2418 | 2417 | ||
2419 | /* | 2418 | /* |
2420 | * dev_data is still NULL and | 2419 | * dev_data is still NULL and |