From patchwork Tue Jan 22 14:36:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10775579 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3C7A913B5 for ; Tue, 22 Jan 2019 14:36:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2BA6A2A8FD for ; Tue, 22 Jan 2019 14:36:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F9B72A981; Tue, 22 Jan 2019 14:36:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CC79A2A8FD for ; Tue, 22 Jan 2019 14:36:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 013F96ECE8; Tue, 22 Jan 2019 14:36:22 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id 898CF6ECE8 for ; Tue, 22 Jan 2019 14:36:20 +0000 (UTC) Received: by mail-wr1-x442.google.com with SMTP id v13so27625496wrw.5 for ; Tue, 22 Jan 2019 06:36:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=q1HYI8Hg3f5S0MpkQ1QJEcaC8Na3Z0xe/Wt46H2OdrA=; b=tWU+XzZVsOHGXOcaH8QgJ/itqAh9RC2CRdmmolrnuVHLJ0DygWbq/eqTlaol8SIQMg d0VCljW1RhxUscJ65zBA2+32bwcHzhcCzGc7cvk8L/mmKtc+tu7O3JlW25BPJiCfpMYY dfpyim5tnlbkB49mlSVf4R/R68ahU1GKsHS3XozADqJzS8Ly2iU0stMeCdBOtT93PvKA OfpipWmMABIFQwWIyMxwJKSVgF+LFhA2hAj0gRmKcIjzv1tcQevBwQRruEEJ80pnpdjM hhZMcdsZbp0ON4ettckYAIElLz9th3FyRMmyr6ljHmN08HiyJ7MptXBMc6cotzSK6pZ2 J0Ag== X-Gm-Message-State: AJcUukdBTKlAhb7EiEA3HE3Ts1Abe8jfkdymKep2AXRmmNwUgTB2fG+6 xEx7dcVMGcltm5zlEsLC2yvZqS5nNG8= X-Google-Smtp-Source: ALg8bN5eq988vQ+A3fDgaURNkpLG+EZQ2CkJlLPvdTQKjGTHWDevNQy7RL4KN/Lctj0PM/mF9fw3oQ== X-Received: by 2002:adf:9422:: with SMTP id 31mr35078766wrq.106.1548167778950; Tue, 22 Jan 2019 06:36:18 -0800 (PST) Received: from localhost (pD9E51040.dip0.t-ipconnect.de. [217.229.16.64]) by smtp.gmail.com with ESMTPSA id t66sm16799089wme.15.2019.01.22.06.36.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 Jan 2019 06:36:18 -0800 (PST) From: Thierry Reding To: Thierry Reding Subject: [PATCH] drm/tegra: Provide fallback IOMMU domain geometry Date: Tue, 22 Jan 2019 15:36:13 +0100 Message-Id: <20190122143613.16881-1-thierry.reding@gmail.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, Mikko Perttunen Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding 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 --- 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,