diff options
| -rw-r--r-- | drivers/iommu/dmar.c | 4 | ||||
| -rw-r--r-- | drivers/iommu/intel-iommu.c | 13 |
2 files changed, 16 insertions, 1 deletions
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c index 58470f5ced04..8c53748a769d 100644 --- a/drivers/iommu/dmar.c +++ b/drivers/iommu/dmar.c | |||
| @@ -338,7 +338,9 @@ static int dmar_pci_bus_notifier(struct notifier_block *nb, | |||
| 338 | struct pci_dev *pdev = to_pci_dev(data); | 338 | struct pci_dev *pdev = to_pci_dev(data); |
| 339 | struct dmar_pci_notify_info *info; | 339 | struct dmar_pci_notify_info *info; |
| 340 | 340 | ||
| 341 | /* Only care about add/remove events for physical functions */ | 341 | /* Only care about add/remove events for physical functions. |
| 342 | * For VFs we actually do the lookup based on the corresponding | ||
| 343 | * PF in device_to_iommu() anyway. */ | ||
| 342 | if (pdev->is_virtfn) | 344 | if (pdev->is_virtfn) |
| 343 | return NOTIFY_DONE; | 345 | return NOTIFY_DONE; |
| 344 | if (action != BUS_NOTIFY_ADD_DEVICE && | 346 | if (action != BUS_NOTIFY_ADD_DEVICE && |
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index a4407eabf0e6..2723090a0d54 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c | |||
| @@ -892,7 +892,13 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf | |||
| 892 | return NULL; | 892 | return NULL; |
| 893 | 893 | ||
| 894 | if (dev_is_pci(dev)) { | 894 | if (dev_is_pci(dev)) { |
| 895 | struct pci_dev *pf_pdev; | ||
| 896 | |||
| 895 | pdev = to_pci_dev(dev); | 897 | pdev = to_pci_dev(dev); |
| 898 | /* VFs aren't listed in scope tables; we need to look up | ||
| 899 | * the PF instead to find the IOMMU. */ | ||
| 900 | pf_pdev = pci_physfn(pdev); | ||
| 901 | dev = &pf_pdev->dev; | ||
| 896 | segment = pci_domain_nr(pdev->bus); | 902 | segment = pci_domain_nr(pdev->bus); |
| 897 | } else if (has_acpi_companion(dev)) | 903 | } else if (has_acpi_companion(dev)) |
| 898 | dev = &ACPI_COMPANION(dev)->dev; | 904 | dev = &ACPI_COMPANION(dev)->dev; |
| @@ -905,6 +911,13 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf | |||
| 905 | for_each_active_dev_scope(drhd->devices, | 911 | for_each_active_dev_scope(drhd->devices, |
| 906 | drhd->devices_cnt, i, tmp) { | 912 | drhd->devices_cnt, i, tmp) { |
| 907 | if (tmp == dev) { | 913 | if (tmp == dev) { |
| 914 | /* For a VF use its original BDF# not that of the PF | ||
| 915 | * which we used for the IOMMU lookup. Strictly speaking | ||
| 916 | * we could do this for all PCI devices; we only need to | ||
| 917 | * get the BDF# from the scope table for ACPI matches. */ | ||
| 918 | if (pdev->is_virtfn) | ||
| 919 | goto got_pdev; | ||
| 920 | |||
| 908 | *bus = drhd->devices[i].bus; | 921 | *bus = drhd->devices[i].bus; |
| 909 | *devfn = drhd->devices[i].devfn; | 922 | *devfn = drhd->devices[i].devfn; |
| 910 | goto out; | 923 | goto out; |
