For SR-IOV, the PF PRI is shared between the PF and any associated VFs, and the PRI Capability is allowed for PFs but not for VFs. Searching for the PRI Capability on a VF always fails, even if its associated PF supports PRI. Add pci_pri_supported() to check whether device or its associated PF supports PRI. [bhelgaas: commit log, avoid "!!"] Fixes: b16d0cb9e2fc ("iommu/vt-d: Always enable PASID/PRI PCI capabilities before ATS") Link: https://lore.kernel.org/r/1595543849-19692-1-git-send-email-ashok.raj@intel.com Signed-off-by: Ashok Raj <ashok.raj@intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Acked-by: Joerg Roedel <jroedel@suse.de> Cc: stable@vger.kernel.org # v4.4+
Unified · Split
| @@ -2554,7 +2554,7 @@ static struct dmar_domain *dmar_insert_one_dev_info(struct intel_iommu *iommu, · 2553 unmodified lines | ||
| 2554 | 2554 | } |
| 2555 | 2555 | |
| 2556 | 2556 | if (info->ats_supported && ecap_prs(iommu->ecap) && |
| 2557 | − pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PRI)) | |
| 2557 | + pci_pri_supported(pdev)) | |
| 2558 | 2558 | info->pri_supported = 1; |
| 2559 | 2559 | } |
| 2560 | 2560 | } |
| @@ -325,6 +325,21 @@ int pci_prg_resp_pasid_required(struct pci_dev *pdev) · 324 unmodified lines | ||
| 325 | 325 | |
| 326 | 326 | return pdev->pasid_required; |
| 327 | 327 | } |
| 328 | + | |
| 329 | +/** | |
| 330 | + * pci_pri_supported - Check if PRI is supported. | |
| 331 | + * @pdev: PCI device structure | |
| 332 | + * | |
| 333 | + * Returns true if PRI capability is present, false otherwise. | |
| 334 | + */ | |
| 335 | +bool pci_pri_supported(struct pci_dev *pdev) | |
| 336 | +{ | |
| 337 | + /* VFs share the PF PRI */ | |
| 338 | + if (pci_physfn(pdev)->pri_cap) | |
| 339 | + return true; | |
| 340 | + return false; | |
| 341 | +} | |
| 342 | +EXPORT_SYMBOL_GPL(pci_pri_supported); | |
| 328 | 343 | #endif /* CONFIG_PCI_PRI */ |
| 329 | 344 | |
| 330 | 345 | #ifdef CONFIG_PCI_PASID |
| @@ -28,6 +28,10 @@ int pci_enable_pri(struct pci_dev *pdev, u32 reqs); · 27 unmodified lines | ||
| 28 | 28 | void pci_disable_pri(struct pci_dev *pdev); |
| 29 | 29 | int pci_reset_pri(struct pci_dev *pdev); |
| 30 | 30 | int pci_prg_resp_pasid_required(struct pci_dev *pdev); |
| 31 | +bool pci_pri_supported(struct pci_dev *pdev); | |
| 32 | +#else | |
| 33 | +static inline bool pci_pri_supported(struct pci_dev *pdev) | |
| 34 | +{ return false; } | |
| 31 | 35 | #endif /* CONFIG_PCI_PRI */ |
| 32 | 36 | |
| 33 | 37 | #ifdef CONFIG_PCI_PASID |