Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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+

authored by

Ashok Raj and committed by
Bjorn Helgaas
3f9a7a13 1c026a18

+20 -1
+1 -1
drivers/iommu/intel/iommu.c
··· 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 }
+15
drivers/pci/ats.c
··· 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
+4
include/linux/pci-ats.h
··· 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