History

PCI/ATS: Add pci_pri_supported() to check device or associated PF

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+

Ashok Raj committed 6 years ago

Commit 3f9a7a11 parent 1c026a13 files · +20 −1Browse files

Unified · Split

3 files
  1. drivers/iommu/intel/iommu.c +1 −1
  2. drivers/pci/ats.c +15 −0
  3. include/linux/pci-ats.h +4 −0
drivers/iommu/intel/iommu.c+1−1
@@ -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 if (info->ats_supported && ecap_prs(iommu->ecap) &&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 info->pri_supported = 1;2558 info->pri_supported = 1;
2559 }2559 }
2560 }2560 }
drivers/pci/ats.c+15−0
@@ -325,6 +325,21 @@ int pci_prg_resp_pasid_required(struct pci_dev *pdev) · 324 unmodified lines
325 325
326 return pdev->pasid_required;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 */
335bool 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}
342EXPORT_SYMBOL_GPL(pci_pri_supported);
328#endif /* CONFIG_PCI_PRI */343#endif /* CONFIG_PCI_PRI */
329 344
330#ifdef CONFIG_PCI_PASID345#ifdef CONFIG_PCI_PASID
include/linux/pci-ats.h+4−0
@@ -28,6 +28,10 @@ int pci_enable_pri(struct pci_dev *pdev, u32 reqs); · 27 unmodified lines
28void pci_disable_pri(struct pci_dev *pdev);28void pci_disable_pri(struct pci_dev *pdev);
29int pci_reset_pri(struct pci_dev *pdev);29int pci_reset_pri(struct pci_dev *pdev);
30int pci_prg_resp_pasid_required(struct pci_dev *pdev);30int pci_prg_resp_pasid_required(struct pci_dev *pdev);
31bool pci_pri_supported(struct pci_dev *pdev);
32#else
33static inline bool pci_pri_supported(struct pci_dev *pdev)
34{ return false; }
31#endif /* CONFIG_PCI_PRI */35#endif /* CONFIG_PCI_PRI */
32 36
33#ifdef CONFIG_PCI_PASID37#ifdef CONFIG_PCI_PASID