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
25542554 }
25552555
25562556 if (info->ats_supported && ecap_prs(iommu->ecap) &&
2557− pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PRI))
2557+ pci_pri_supported(pdev))
25582558 info->pri_supported = 1;
25592559 }
25602560 }
drivers/pci/ats.c+15−0
@@ -325,6 +325,21 @@ int pci_prg_resp_pasid_required(struct pci_dev *pdev) · 324 unmodified lines
325325
326326 return pdev->pasid_required;
327327 }
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);
328343 #endif /* CONFIG_PCI_PRI */
329344
330345 #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
2828 void pci_disable_pri(struct pci_dev *pdev);
2929 int pci_reset_pri(struct pci_dev *pdev);
3030 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; }
3135 #endif /* CONFIG_PCI_PRI */
3236
3337 #ifdef CONFIG_PCI_PASID