On Wed, Feb 15, 2023 at 07:35:45PM -0500, Felix Kuehling wrote: > > If I understand this correctly, the HW or the BIOS is doing something wrong > about reporting ACS. I don't know what the GPU driver can do other than add > some quirk to stop using AMD IOMMUv2 on this HW/BIOS.
How about this: diff --git a/drivers/iommu/amd/iommu_v2.c b/drivers/iommu/amd/iommu_v2.c index 864e4ffb6aa94e..cc027ce9a6e86f 100644 --- a/drivers/iommu/amd/iommu_v2.c +++ b/drivers/iommu/amd/iommu_v2.c @@ -732,6 +732,7 @@ EXPORT_SYMBOL(amd_iommu_unbind_pasid); int amd_iommu_init_device(struct pci_dev *pdev, int pasids) { + struct iommu_dev_data *dev_data = dev_iommu_priv_get(&pdev->dev); struct device_state *dev_state; struct iommu_group *group; unsigned long flags; @@ -740,6 +741,9 @@ int amd_iommu_init_device(struct pci_dev *pdev, int pasids) might_sleep(); + if (!dev_data->ats.enabled) + return -EINVAL; + /* * When memory encryption is active the device is likely not in a * direct-mapped domain. Forbid using IOMMUv2 functionality for now.