Skip to contentSkip to conversation

drm/tegra: Provide fallback IOMMU domain geometry

PATCH New Thierry Reding 1 participant 1 message Jan 22, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/tegra: Provide fallback IOMMU domain geometry

From: Thierry Reding <[email protected]>

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.

---
 drivers/gpu/drm/tegra/drm.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/gpu/drm/tegra/drm.c +15 -5
index 4b70ce664c41..8af61559d662 100644
@@ -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,
Signature · 6 lines
2.19.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel