All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/tegra: Provide fallback IOMMU domain geometry
@ 2019-01-22 14:36 Thierry Reding
  0 siblings, 0 replies; only message in thread
From: Thierry Reding @ 2019-01-22 14:36 UTC (permalink / raw)
  To: Thierry Reding; +Cc: linux-tegra, dri-devel, Mikko Perttunen

From: Thierry Reding <treding@nvidia.com>

Tegra186 and later use the ARM SMMU driver to provide IOMMU domains. The
driver sets the IOMMU domain's geometry only after a device has attached
to the domain. However, in order to properly set up the IOMMU domain
shared among all Tegra DRM clients, the domain's geometry is needed
before any devices attach to it.

Work around this by falling back to a 32-bit address space for the IOMMU
domain geometry. This is guaranteed to always work on all generations of
Tegra and no known use-cases require more IOVA space than that.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/tegra/drm.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index 4b70ce664c41..8af61559d662 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -93,7 +93,7 @@ static int tegra_drm_load(struct drm_device *drm, unsigned long flags)
 
 	if (iommu_present(&platform_bus_type)) {
 		u64 carveout_start, carveout_end, gem_start, gem_end;
-		struct iommu_domain_geometry *geometry;
+		dma_addr_t start, end;
 		unsigned long order;
 
 		tegra->domain = iommu_domain_alloc(&platform_bus_type);
@@ -106,11 +106,21 @@ static int tegra_drm_load(struct drm_device *drm, unsigned long flags)
 		if (err < 0)
 			goto domain;
 
-		geometry = &tegra->domain->geometry;
-		gem_start = geometry->aperture_start;
-		gem_end = geometry->aperture_end - CARVEOUT_SZ;
+		start = tegra->domain->geometry.aperture_start;
+		end = tegra->domain->geometry.aperture_end;
+
+		/*
+		 * The ARM SMMU driver only sets up the geometry after the
+		 * domain has been attached to a device. In that case, make
+		 * sure to fallback to a reasonable default.
+		 */
+		if (start == 0 && end == 0)
+			end = 0xffffffff;
+
+		gem_start = start;
+		gem_end = end - CARVEOUT_SZ;
 		carveout_start = gem_end + 1;
-		carveout_end = geometry->aperture_end;
+		carveout_end = end;
 
 		order = __ffs(tegra->domain->pgsize_bitmap);
 		init_iova_domain(&tegra->carveout.domain, 1UL << order,
-- 
2.19.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-01-22 14:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-22 14:36 [PATCH] drm/tegra: Provide fallback IOMMU domain geometry Thierry Reding

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.