On 2025-02-03 5:43 pm, Jason Gunthorpe wrote:
How about this:
diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c
index be2ad7203d7b96..090b1fc97a7309 100644
--- a/drivers/gpu/host1x/dev.c
+++ b/drivers/gpu/host1x/dev.c
@@ -361,6 +361,10 @@ static bool host1x_wants_iommu(struct host1x *host1x)
return true;
}
+/*
+ * Returns ERR_PTR on failure, NULL if the translation is IDENTITY, otherwise a
+ * valid paging domain.
+ */
static struct iommu_domain *host1x_iommu_attach(struct host1x *host)
{
struct iommu_domain *domain = iommu_get_domain_for_dev(host->dev);
@@ -385,6 +389,8 @@ static struct iommu_domain *host1x_iommu_attach(struct host1x *host)
* Similarly, if host1x is already attached to an IOMMU (via the DMA
* API), don't try to attach again.
*/
+ if (domain && domain->type == IOMMU_DOMAIN_IDENTITY)
+ domain = NULL;
if (!host1x_wants_iommu(host) || domain)
return domain;
(if not can you investigate this function's flow compared to a good
kernel?)
Yes, this worked! Does this mean that with this change we go through the
path of using the shared Tegra domain (for example in the driver I
attached client->group == true), and if that is the case would it be
beneficial for us to try and change tegra_smmu_def_domain_type() from
returning IOMMU_DOMAIN_IDENTITY into IOMMU_DOMAIN_DMA so that the
dma_alloc_* functions are called directly?
FWIW that would be better thought of as simply making the entire
existence of tegra_smmu_def_domain_type() conditional on CONFIG_ARM.
Definitely worth trying, at least.
I do not know the answer those questions.. The whole rational around
this host 1x domain stuff is mysterious to me.
This change (i.e. ignoring identity domains) should indeed lead to
host1x allocating and using its own paging domain, which is indeed what
you want in that case because otherwise the non-IOMMU DMA ops aren't
going to be much use on their own for allocating/importing great big
media buffers.
It does sound quite appealing for the implementation to use the dma
api instead of attaching its own special domain.
I'd hope the historical reasons for not supporting IOMMU_DOMAIN_DMA in
tegra-smmu no longer apply, given that all the default domain stuff has
now been integrated into host1x for the newer arm-smmu based Tegras. And
I guess it also shows that nobody's been running those newer SoCs with
IOMMU_DEFAULT_PASSTHROUGH either, or they presumably would have run in
to this same issue...
Thanks,
Robin.