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

PCI/ATS: Handle sharing of PF PASID Capability with all 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.  VFs must not implement their
own PASID Capability.  Since VFs don't have a PASID Capability,
pci_enable_pasid() always failed, which caused IOMMU setup to fail.

Update the PASID interfaces so for VFs they reflect the state of the PF
PASID.

[bhelgaas: rebase without pasid_cap caching, commit log]
Suggested-by: default avatarAshok Raj <ashok.raj@intel.com>
Link: https://lore.kernel.org/r/8ba1ac192e4ac737508b6ac15002158e176bab91.1567029860.git.sathyanarayanan.kuppuswamy@linux.intel.com
Link: https://lore.kernel.org/r/20190905193146.90250-3-helgaas@kernel.orgSigned-off-by: default avatarKuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Cc: Ashok Raj <ashok.raj@intel.com>
Cc: Keith Busch <keith.busch@intel.com>
parent 9bf49e36
...@@ -346,6 +346,16 @@ int pci_enable_pasid(struct pci_dev *pdev, int features) ...@@ -346,6 +346,16 @@ int pci_enable_pasid(struct pci_dev *pdev, int features)
u16 control, supported; u16 control, supported;
int pos; int pos;
/*
* VFs must not implement the PASID Capability, but if a PF
* supports PASID, its VFs share the PF PASID configuration.
*/
if (pdev->is_virtfn) {
if (pci_physfn(pdev)->pasid_enabled)
return 0;
return -EINVAL;
}
if (WARN_ON(pdev->pasid_enabled)) if (WARN_ON(pdev->pasid_enabled))
return -EBUSY; return -EBUSY;
...@@ -383,6 +393,10 @@ void pci_disable_pasid(struct pci_dev *pdev) ...@@ -383,6 +393,10 @@ void pci_disable_pasid(struct pci_dev *pdev)
u16 control = 0; u16 control = 0;
int pos; int pos;
/* VFs share the PF PASID configuration */
if (pdev->is_virtfn)
return;
if (WARN_ON(!pdev->pasid_enabled)) if (WARN_ON(!pdev->pasid_enabled))
return; return;
...@@ -405,6 +419,9 @@ void pci_restore_pasid_state(struct pci_dev *pdev) ...@@ -405,6 +419,9 @@ void pci_restore_pasid_state(struct pci_dev *pdev)
u16 control; u16 control;
int pos; int pos;
if (pdev->is_virtfn)
return;
if (!pdev->pasid_enabled) if (!pdev->pasid_enabled)
return; return;
...@@ -432,6 +449,9 @@ int pci_pasid_features(struct pci_dev *pdev) ...@@ -432,6 +449,9 @@ int pci_pasid_features(struct pci_dev *pdev)
u16 supported; u16 supported;
int pos; int pos;
if (pdev->is_virtfn)
pdev = pci_physfn(pdev);
pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PASID); pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PASID);
if (!pos) if (!pos)
return -EINVAL; return -EINVAL;
...@@ -458,6 +478,9 @@ int pci_max_pasids(struct pci_dev *pdev) ...@@ -458,6 +478,9 @@ int pci_max_pasids(struct pci_dev *pdev)
u16 supported; u16 supported;
int pos; int pos;
if (pdev->is_virtfn)
pdev = pci_physfn(pdev);
pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PASID); pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PASID);
if (!pos) if (!pos)
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