Commit 2e34673b authored by Kuppuswamy Sathyanarayanan's avatar Kuppuswamy Sathyanarayanan Committed by Bjorn Helgaas

PCI/ATS: Use PF PASID for VFs

Per PCIe r5.0, sec 9.3.7.14, if a PF implements the PASID Capability, the
PF PASID configuration is shared by its VFs, and VFs must not implement
their own PASID Capability.  But commit 751035b8 ("PCI/ATS: Cache PASID
Capability offset") changed pci_max_pasids() and pci_pasid_features() to
use the PASID Capability of the VF device instead of the associated PF
device.  This leads to IOMMU bind failures when pci_max_pasids() and
pci_pasid_features() are called for VFs.

In pci_max_pasids() and pci_pasid_features(), always use the PF PASID
Capability.

Fixes: 751035b8 ("PCI/ATS: Cache PASID Capability offset")
Link: https://lore.kernel.org/r/fe891f9755cb18349389609e7fed9940fc5b081a.1580325170.git.sathyanarayanan.kuppuswamy@linux.intel.comSigned-off-by: default avatarKuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
CC: stable@vger.kernel.org	# v5.5+
parent b9303bb1
...@@ -424,11 +424,12 @@ void pci_restore_pasid_state(struct pci_dev *pdev) ...@@ -424,11 +424,12 @@ void pci_restore_pasid_state(struct pci_dev *pdev)
int pci_pasid_features(struct pci_dev *pdev) int pci_pasid_features(struct pci_dev *pdev)
{ {
u16 supported; u16 supported;
int pasid = pdev->pasid_cap; int pasid;
if (pdev->is_virtfn) if (pdev->is_virtfn)
pdev = pci_physfn(pdev); pdev = pci_physfn(pdev);
pasid = pdev->pasid_cap;
if (!pasid) if (!pasid)
return -EINVAL; return -EINVAL;
...@@ -451,11 +452,12 @@ int pci_pasid_features(struct pci_dev *pdev) ...@@ -451,11 +452,12 @@ int pci_pasid_features(struct pci_dev *pdev)
int pci_max_pasids(struct pci_dev *pdev) int pci_max_pasids(struct pci_dev *pdev)
{ {
u16 supported; u16 supported;
int pasid = pdev->pasid_cap; int pasid;
if (pdev->is_virtfn) if (pdev->is_virtfn)
pdev = pci_physfn(pdev); pdev = pci_physfn(pdev);
pasid = pdev->pasid_cap;
if (!pasid) if (!pasid)
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment