From: Zhangfei Gao Date: Thu, 7 Nov 2024 04:37:11 +0000 (+0000) Subject: iommufd: Allow fault reporting for non-PRI PCI devices X-Git-Tag: v6.13-rc1~125^2~34 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c9d6ee6699fd6626b0974143a72c3406276e1c65;p=thirdparty%2Fkernel%2Flinux.git iommufd: Allow fault reporting for non-PRI PCI devices iommufd_fault_iopf_enable has limitation to PRI on PCI/SRIOV VFs because the PRI might be a shared resource and current iommu subsystem is not ready to support enabling/disabling PRI on a VF without any impact on others. However, we have devices that appear as PCI but are actually on the AMBA bus. These fake PCI devices have PASID capability, support stall as well as SRIOV, so remove the limitation for these devices. Link: https://patch.msgid.link/r/20241107043711.116-1-zhangfei.gao@linaro.org Co-developed-by: Lu Baolu Signed-off-by: Lu Baolu Reviewed-by: Lu Baolu Signed-off-by: Zhangfei Gao Signed-off-by: Jason Gunthorpe --- diff --git a/drivers/iommu/iommufd/fault.c b/drivers/iommu/iommufd/fault.c index e590973ce5cfa..053b0e30f55a9 100644 --- a/drivers/iommu/iommufd/fault.c +++ b/drivers/iommu/iommufd/fault.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -27,8 +28,12 @@ static int iommufd_fault_iopf_enable(struct iommufd_device *idev) * resource between PF and VFs. There is no coordination for this * shared capability. This waits for a vPRI reset to recover. */ - if (dev_is_pci(dev) && to_pci_dev(dev)->is_virtfn) - return -EINVAL; + if (dev_is_pci(dev)) { + struct pci_dev *pdev = to_pci_dev(dev); + + if (pdev->is_virtfn && pci_pri_supported(pdev)) + return -EINVAL; + } mutex_lock(&idev->iopf_lock); /* Device iopf has already been on. */