Skip to content

Commit 3f9a7a1

Browse files
ashok-rajbjorn-helgaas
authored andcommitted
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: b16d0cb ("iommu/vt-d: Always enable PASID/PRI PCI capabilities before ATS") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ashok Raj <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Lu Baolu <[email protected]> Acked-by: Joerg Roedel <[email protected]> Cc: [email protected] # v4.4+
1 parent 1c026a1 commit 3f9a7a1

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

drivers/iommu/intel/iommu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2554,7 +2554,7 @@ static struct dmar_domain *dmar_insert_one_dev_info(struct intel_iommu *iommu,
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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,21 @@ int pci_prg_resp_pasid_required(struct pci_dev *pdev)
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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ int pci_enable_pri(struct pci_dev *pdev, u32 reqs);
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

0 commit comments

Comments
 (0)