Skip to content

Commit cb83f4b

Browse files
jgunthorpethierryreding
authored andcommitted
gpu: host1x: Do not assume that a NULL domain means no DMA IOMMU
Previously with tegra-smmu, even with CONFIG_IOMMU_DMA, the default domain could have been left as NULL. The NULL domain is specially recognized by host1x_iommu_attach() as meaning it is not the DMA domain and should be replaced with the special shared domain. This happened prior to the below commit because tegra-smmu was using the NULL domain to mean IDENTITY. Now that the domain is properly labled the test in DRM doesn't see NULL. Check for IDENTITY as well to enable the special domains. This is the same issue and basic fix as seen in commit fae6e66 ("drm/tegra: Do not assume that a NULL domain means no DMA IOMMU"). Fixes: c8cc265 ("iommu/tegra-smmu: Implement an IDENTITY domain") Reported-by: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt> Closes: https://lore.kernel.org/all/c6a6f114-3acd-4d56-a13b-b88978e927dc@tecnico.ulisboa.pt/ Tested-by: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com> Link: https://patchwork.freedesktop.org/patch/msgid/0-v1-10dcc8ce3869+3a7-host1x_identity_jgg@nvidia.com
1 parent 67d15c7 commit cb83f4b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/gpu/host1x/dev.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,10 @@ static bool host1x_wants_iommu(struct host1x *host1x)
361361
return true;
362362
}
363363

364+
/*
365+
* Returns ERR_PTR on failure, NULL if the translation is IDENTITY, otherwise a
366+
* valid paging domain.
367+
*/
364368
static struct iommu_domain *host1x_iommu_attach(struct host1x *host)
365369
{
366370
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)
385389
* Similarly, if host1x is already attached to an IOMMU (via the DMA
386390
* API), don't try to attach again.
387391
*/
392+
if (domain && domain->type == IOMMU_DOMAIN_IDENTITY)
393+
domain = NULL;
388394
if (!host1x_wants_iommu(host) || domain)
389395
return domain;
390396

0 commit comments

Comments
 (0)