Skip to content

Commit c8cd1cf

Browse files
marcanjannau
authored andcommitted
iommu: Only allocate FQ domains for IOMMUs that support them
Commit a4fdd97 ("iommu: Use flush queue capability") hid the IOMMU_DOMAIN_DMA_FQ domain type from domain allocation. A check was introduced in iommu_dma_init_domain() to fall back if not supported, but this check runs too late: by that point, devices have been attached to the IOMMU, and the IOMMU driver might not expect FQ domains at ops->attach_dev() time. Ensure that we immediately clamp FQ domains to plain DMA if not supported by the driver at device attach time, not later. This regressed apple-dart in v6.5. Cc: regressions@lists.linux.dev Cc: stable@vger.kernel.org Fixes: a4fdd97 ("iommu: Use flush queue capability") Signed-off-by: Hector Martin <marcan@marcan.st>
1 parent b694eaf commit c8cd1cf

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

drivers/iommu/iommu.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2063,6 +2063,15 @@ static int __iommu_attach_device(struct iommu_domain *domain,
20632063
if (unlikely(domain->ops->attach_dev == NULL))
20642064
return -ENODEV;
20652065

2066+
/*
2067+
* Ensure we do not try to attach devices to FQ domains if the
2068+
* IOMMU does not support them. We can safely fall back to
2069+
* non-FQ.
2070+
*/
2071+
if (domain->type == IOMMU_DOMAIN_DMA_FQ &&
2072+
!device_iommu_capable(dev, IOMMU_CAP_DEFERRED_FLUSH))
2073+
domain->type = IOMMU_DOMAIN_DMA;
2074+
20662075
ret = domain->ops->attach_dev(domain, dev);
20672076
if (ret)
20682077
return ret;

0 commit comments

Comments
 (0)