All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org,
	Mikko Perttunen <mperttunen@nvidia.com>
Subject: [PATCH] drm/tegra: Provide fallback IOMMU domain geometry
Date: Tue, 22 Jan 2019 15:36:13 +0100	[thread overview]
Message-ID: <20190122143613.16881-1-thierry.reding@gmail.com> (raw)

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

                 reply	other threads:[~2019-01-22 14:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190122143613.16881-1-thierry.reding@gmail.com \
    --to=thierry.reding@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mperttunen@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.