From patchwork Wed Jan 23 09:39:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10776849 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 9D8816C2 for ; Wed, 23 Jan 2019 09:40:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C0D22A8EB for ; Wed, 23 Jan 2019 09:40:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D26B2A8CA; Wed, 23 Jan 2019 09:40:00 +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 3A8ED2A825 for ; Wed, 23 Jan 2019 09:40:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DD2376E4B2; Wed, 23 Jan 2019 09:39:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by gabe.freedesktop.org (Postfix) with ESMTPS id 458C66E081 for ; Wed, 23 Jan 2019 09:39:56 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id y139so1261391wmc.5 for ; Wed, 23 Jan 2019 01:39:56 -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:in-reply-to :references:mime-version:content-transfer-encoding; bh=IpG077bBS8wO4pLbl1c8VJYrVjm/XU2DdyZbsHoLosY=; b=MMAhmAAxEipsQ38JLwhl6+/ZrDjBpdOWxlbEnMurezBLchnqU5rvObJhD4jga6pot1 b0OBOBq2T3QiKg8b8hGh3nqykQmqwLec1grlQI36ZNcJgVpUgyLxQcSUmAqoPjw1Jt7v VFGkN1h76PAEuQyD2T56g4xzcaOqOfELWBF4gw0gVDW5kjNaM753cNCD2MnOUASRyotU zRQVcNHrmHJR37gp7dIoaxFprtGDnTgy1qL1IbvmaX1Y75I0jVpceqxm2NvWt9FofVcT yglaZEcJWM5Zp1jhzMN8eRKHy7M6A17ikX5Vi/kXxGanv0jk3jORKMJnYiiI3jwAPjZ8 loSw== X-Gm-Message-State: AJcUukeDsaHkLBkUvAbBuYxIwhnsnQK23Ut4QTp0ZQSThK9MlJeFUjq8 7jQNOsfKNS/Vp85rSSDyjDdSQIcy7k0= X-Google-Smtp-Source: ALg8bN5a59SS80sUiL0WB9Uw0iWJ24KEYW4fWWhhm9a54M/xDMb0GZk+gFgbC3z2WPrEbwzJoHE6RA== X-Received: by 2002:a1c:bbd6:: with SMTP id l205mr1844960wmf.97.1548236394816; Wed, 23 Jan 2019 01:39:54 -0800 (PST) Received: from localhost (pD9E51040.dip0.t-ipconnect.de. [217.229.16.64]) by smtp.gmail.com with ESMTPSA id k128sm74380785wmd.37.2019.01.23.01.39.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Jan 2019 01:39:54 -0800 (PST) From: Thierry Reding To: Thierry Reding Subject: [PATCH 1/5] drm/tegra: Store parent pointer in Tegra DRM clients Date: Wed, 23 Jan 2019 10:39:47 +0100 Message-Id: <20190123093951.24908-2-thierry.reding@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190123093951.24908-1-thierry.reding@gmail.com> References: <20190123093951.24908-1-thierry.reding@gmail.com> 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, Dmitry Osipenko , 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 Tegra DRM clients need access to their parent, so store a pointer to it upon registration. Signed-off-by: Thierry Reding --- drivers/gpu/drm/tegra/drm.c | 2 ++ drivers/gpu/drm/tegra/drm.h | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index 4b70ce664c41..61dcbd218ffc 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -1041,6 +1041,7 @@ int tegra_drm_register_client(struct tegra_drm *tegra, { mutex_lock(&tegra->clients_lock); list_add_tail(&client->list, &tegra->clients); + client->drm = tegra; mutex_unlock(&tegra->clients_lock); return 0; @@ -1051,6 +1052,7 @@ int tegra_drm_unregister_client(struct tegra_drm *tegra, { mutex_lock(&tegra->clients_lock); list_del_init(&client->list); + client->drm = NULL; mutex_unlock(&tegra->clients_lock); return 0; diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h index f1763b4d5b5f..2c809755bca7 100644 --- a/drivers/gpu/drm/tegra/drm.h +++ b/drivers/gpu/drm/tegra/drm.h @@ -88,6 +88,7 @@ int tegra_drm_submit(struct tegra_drm_context *context, struct tegra_drm_client { struct host1x_client base; struct list_head list; + struct tegra_drm *drm; unsigned int version; const struct tegra_drm_client_ops *ops; From patchwork Wed Jan 23 09:39:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10776851 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 3FF9591E for ; Wed, 23 Jan 2019 09:40:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DEC92A87D for ; Wed, 23 Jan 2019 09:40:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 220F82A8B5; Wed, 23 Jan 2019 09:40:03 +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 CE5B52A881 for ; Wed, 23 Jan 2019 09:40:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8D8946E4DD; Wed, 23 Jan 2019 09:39:59 +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 05A7D6E4DD for ; Wed, 23 Jan 2019 09:39:58 +0000 (UTC) Received: by mail-wr1-x442.google.com with SMTP id f7so1609270wrp.1 for ; Wed, 23 Jan 2019 01:39:57 -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:in-reply-to :references:mime-version:content-transfer-encoding; bh=+pwOb4E7QMv2s1mLGij/09z6WnnFIjoClRTuOR97cPc=; b=tXaDQINaFxIX0xqkz0mWyOPQ+O0Fwu8aJb+9WNZ6rd5iSaqPyumC/EkU6lfciYJViY p9fwElKRE/DlaXo80a+CJyuy7QkZmWY1Hn0vY+BTzYmWTpHLaxo7Ry41MBTs2ioYy79D a/M5SDnrRxqX0yBNG9Dr5juv3z50ZHCE0Mc+ZYLzxjtyAD4rrc64heNEAgZR2w9/gumt WrDPGpRimJLY9f+HWf9z4+C0hqKXslEOcL1hzUsL+ls4Cs7HdrYJUv3OQSz6NgkVq2nd kYiY+r15gR75FI+KwdeKtHpFZCR5EU47ggru5clYexfwyBJXWchXZmuGG3D7sTC2fYVn KMoA== X-Gm-Message-State: AJcUukf/mR851tTVU/+Sq+AWzAS0pdOjVFDATP3UT8VXLM2i/vJMV4gX YFhAZlalhfE41U1YCdgLTKM= X-Google-Smtp-Source: ALg8bN7FVGzjzh+eVUH90YgYrss3el0UIKGORmur2bIWzkl36h65/jebh15RwGGNzmBTE0SJsPeWUg== X-Received: by 2002:adf:ab51:: with SMTP id r17mr1879997wrc.62.1548236396536; Wed, 23 Jan 2019 01:39:56 -0800 (PST) Received: from localhost (pD9E51040.dip0.t-ipconnect.de. [217.229.16.64]) by smtp.gmail.com with ESMTPSA id p139sm113458172wmd.31.2019.01.23.01.39.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Jan 2019 01:39:55 -0800 (PST) From: Thierry Reding To: Thierry Reding Subject: [PATCH 2/5] drm/tegra: vic: Load firmware on demand Date: Wed, 23 Jan 2019 10:39:48 +0100 Message-Id: <20190123093951.24908-3-thierry.reding@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190123093951.24908-1-thierry.reding@gmail.com> References: <20190123093951.24908-1-thierry.reding@gmail.com> 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, Dmitry Osipenko , 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 Loading the firmware requires an allocation of IOVA space to make sure that the VIC's Falcon microcontroller can read the firmware if address translation via the SMMU is enabled. However, the allocation currently happens at a time where the geometry of an IOMMU domain may not have been initialized yet. This happens for example on Tegra186 and later where an ARM SMMU is used. Domains which are created by the ARM SMMU driver postpone the geometry setup until a device is attached to the domain. This is because IOMMU domains aren't attached to a specific IOMMU instance at allocation time and hence the input address space, which defines the geometry, is not known yet. Work around this by postponing the firmware load until it is needed at the time where a channel is opened to the VIC. At this time the shared IOMMU domain's geometry has been properly initialized. As a byproduct this allows the Tegra DRM to be created in the absence of VIC firmware, since the VIC initialization no longer fails if the firmware can't be found. Signed-off-by: Thierry Reding --- drivers/gpu/drm/tegra/vic.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/tegra/vic.c b/drivers/gpu/drm/tegra/vic.c index d47983deb1cf..afbdc33f49bc 100644 --- a/drivers/gpu/drm/tegra/vic.c +++ b/drivers/gpu/drm/tegra/vic.c @@ -181,13 +181,6 @@ static int vic_init(struct host1x_client *client) vic->domain = tegra->domain; } - if (!vic->falcon.data) { - vic->falcon.data = tegra; - err = falcon_load_firmware(&vic->falcon); - if (err < 0) - goto detach; - } - vic->channel = host1x_channel_request(client->dev); if (!vic->channel) { err = -ENOMEM; @@ -256,6 +249,16 @@ static int vic_open_channel(struct tegra_drm_client *client, if (err < 0) return err; + if (!vic->falcon.data) { + vic->falcon.data = client->drm; + + err = falcon_load_firmware(&vic->falcon); + if (err < 0) { + pm_runtime_put(vic->dev); + return err; + } + } + err = vic_boot(vic); if (err < 0) { pm_runtime_put(vic->dev); From patchwork Wed Jan 23 09:39:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10776853 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 2BC796C2 for ; Wed, 23 Jan 2019 09:40:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1AC952A81C for ; Wed, 23 Jan 2019 09:40:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F2FD2A891; Wed, 23 Jan 2019 09:40:06 +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 B1E042A825 for ; Wed, 23 Jan 2019 09:40:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BA77D6E472; Wed, 23 Jan 2019 09:40:00 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8F8AF6EEAC for ; Wed, 23 Jan 2019 09:39:59 +0000 (UTC) Received: by mail-wm1-x342.google.com with SMTP id b11so1288429wmj.1 for ; Wed, 23 Jan 2019 01:39:59 -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:in-reply-to :references:mime-version:content-transfer-encoding; bh=BvPmDgG4ulHqAQ+1bGKSPFPNzolLo9NaU9Nj+6RSRPw=; b=Zwlv67QFqzhHByoBua1sNZaIJ4qmTki9uod0JBIEjg5J39x3pTmGW+e3A3CT2gz49W OBE2DDtpFrP+bz1rw/RGro71x8oOv5F6W7KMt8j1h/f6OXfrluqvMXRpquW6hdbLmxQy km0MEfHZU3vUkbax8D3/BCyqjmS4yzKvri6N4DeimZAmxGtIt6+pRWHw0QeryQuR1e69 fx90kMklcsizXwYBwv8t0xIkxFrj+n6mI5P+g3FFT7HZIj1dzS2HiEHdiofBnlbzO3zq LKabZI6U7dKCCzUO/dr+huBAFupHaHSDDBovBzjJSh+6taTw6nVba1dpn4ZncxHj7Cbo Radw== X-Gm-Message-State: AJcUukeAENiKR5gTuhcUGmKD+Q3UPlvzeLgFJhmK8kbF3KEl+Kaq3pwx IZlJIQpTHienHqLUzsouUJM= X-Google-Smtp-Source: ALg8bN5dd0S89GxPjnP24X/L/oxhR3dlkFeIvwqOLvP56+O+POOEamWNxAtMvljc+6zZRSSs63LXvA== X-Received: by 2002:a1c:1688:: with SMTP id 130mr1891566wmw.86.1548236397934; Wed, 23 Jan 2019 01:39:57 -0800 (PST) Received: from localhost (pD9E51040.dip0.t-ipconnect.de. [217.229.16.64]) by smtp.gmail.com with ESMTPSA id y13sm80982074wrn.73.2019.01.23.01.39.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Jan 2019 01:39:57 -0800 (PST) From: Thierry Reding To: Thierry Reding Subject: [PATCH 3/5] drm/tegra: Setup shared IOMMU domain after initialization Date: Wed, 23 Jan 2019 10:39:49 +0100 Message-Id: <20190123093951.24908-4-thierry.reding@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190123093951.24908-1-thierry.reding@gmail.com> References: <20190123093951.24908-1-thierry.reding@gmail.com> 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, Dmitry Osipenko , 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 Move initialization of the shared IOMMU domain after the host1x device has been initialized. At this point all the Tegra DRM clients have been attached to the shared IOMMU domain. This is important because Tegra186 and later use an ARM SMMU, for which the driver defers setting up the geometry for a domain until a device is attached to it. This is to ensure that the domain is properly set up for a specific ARM SMMU instance, which is unknown at allocation time. Signed-off-by: Thierry Reding Reviewed-by: Dmitry Osipenko --- drivers/gpu/drm/tegra/drm.c | 54 ++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index 61dcbd218ffc..271c7a5fc954 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -92,10 +92,6 @@ static int tegra_drm_load(struct drm_device *drm, unsigned long flags) return -ENOMEM; if (iommu_present(&platform_bus_type)) { - u64 carveout_start, carveout_end, gem_start, gem_end; - struct iommu_domain_geometry *geometry; - unsigned long order; - tegra->domain = iommu_domain_alloc(&platform_bus_type); if (!tegra->domain) { err = -ENOMEM; @@ -105,27 +101,6 @@ static int tegra_drm_load(struct drm_device *drm, unsigned long flags) err = iova_cache_get(); if (err < 0) goto domain; - - geometry = &tegra->domain->geometry; - gem_start = geometry->aperture_start; - gem_end = geometry->aperture_end - CARVEOUT_SZ; - carveout_start = gem_end + 1; - carveout_end = geometry->aperture_end; - - order = __ffs(tegra->domain->pgsize_bitmap); - init_iova_domain(&tegra->carveout.domain, 1UL << order, - carveout_start >> order); - - tegra->carveout.shift = iova_shift(&tegra->carveout.domain); - tegra->carveout.limit = carveout_end >> tegra->carveout.shift; - - drm_mm_init(&tegra->mm, gem_start, gem_end - gem_start + 1); - mutex_init(&tegra->mm_lock); - - DRM_DEBUG("IOMMU apertures:\n"); - DRM_DEBUG(" GEM: %#llx-%#llx\n", gem_start, gem_end); - DRM_DEBUG(" Carveout: %#llx-%#llx\n", carveout_start, - carveout_end); } mutex_init(&tegra->clients_lock); @@ -159,6 +134,35 @@ static int tegra_drm_load(struct drm_device *drm, unsigned long flags) if (err < 0) goto fbdev; + if (tegra->domain) { + u64 carveout_start, carveout_end, gem_start, gem_end; + dma_addr_t start, end; + unsigned long order; + + start = tegra->domain->geometry.aperture_start; + end = tegra->domain->geometry.aperture_end; + + gem_start = start; + gem_end = end - CARVEOUT_SZ; + carveout_start = gem_end + 1; + carveout_end = end; + + order = __ffs(tegra->domain->pgsize_bitmap); + init_iova_domain(&tegra->carveout.domain, 1UL << order, + carveout_start >> order); + + tegra->carveout.shift = iova_shift(&tegra->carveout.domain); + tegra->carveout.limit = carveout_end >> tegra->carveout.shift; + + drm_mm_init(&tegra->mm, gem_start, gem_end - gem_start + 1); + mutex_init(&tegra->mm_lock); + + DRM_DEBUG("IOMMU apertures:\n"); + DRM_DEBUG(" GEM: %#llx-%#llx\n", gem_start, gem_end); + DRM_DEBUG(" Carveout: %#llx-%#llx\n", carveout_start, + carveout_end); + } + if (tegra->hub) { err = tegra_display_hub_prepare(tegra->hub); if (err < 0) From patchwork Wed Jan 23 09:39:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10776857 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 564F891E for ; Wed, 23 Jan 2019 09:40:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44A612A81C for ; Wed, 23 Jan 2019 09:40:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 390192A87D; Wed, 23 Jan 2019 09:40:14 +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 ED7DB2A825 for ; Wed, 23 Jan 2019 09:40:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3DC226EEAD; Wed, 23 Jan 2019 09:40:04 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3127D6EEAD for ; Wed, 23 Jan 2019 09:40:01 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id y8so1245342wmi.4 for ; Wed, 23 Jan 2019 01:40:01 -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:in-reply-to :references:mime-version:content-transfer-encoding; bh=cUH3hZoO0g/LZ+pZUMo8PX/7722b7rvBvBxyOPDoCcc=; b=rtsooA1+DYcNznaUsa6GOBjToEirC60y1lv5fCGA2za6Gl4A/SaT6/CuYMT0L5G0oH CUmaAsFdZtFeHrUmdfEtwQHKZRZByD+QLO+fl2v+KNO2RoL4JM13e2ZoFMIyQCl5H/Yd GAqiXZSYKrXbov/tCB2DNfYcfu1wS1aHpqMDT9/V7YzbF0Lzeh5lQb7/I8ovRbp+cDMn SqZRqDsbLM6kxghYAGWE2adb1ZRPO+jNgG7enyplobAfv3aeRo/gieTBZDC2DBHpDnhl EKBPcJpRqD/Tx5TiKz1s/yn7o+JwCdC9tNMqIsrOMLt0bkDcZ3A3itMoBQIrNoysiu9Z 3o6w== X-Gm-Message-State: AJcUukc5a+j2SOjaRbz1H/zrT2WBDqR652epOhsH2KLoAFZT7wRdxJfo EiuJNWPT7JiGyLZRAwDaOVPYbrBZbCU= X-Google-Smtp-Source: ALg8bN7yzEsHes0VDsRw07KZi9RcP9Vz+FDVPEv5AkJ3TLD9sYzAr9A67oX0STPfjCYHGdOHtHmNig== X-Received: by 2002:a1c:5a42:: with SMTP id o63mr1957199wmb.88.1548236399590; Wed, 23 Jan 2019 01:39:59 -0800 (PST) Received: from localhost (pD9E51040.dip0.t-ipconnect.de. [217.229.16.64]) by smtp.gmail.com with ESMTPSA id x20sm77813081wme.6.2019.01.23.01.39.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Jan 2019 01:39:58 -0800 (PST) From: Thierry Reding To: Thierry Reding Subject: [PATCH 4/5] drm/tegra: Restrict IOVA space to DMA mask Date: Wed, 23 Jan 2019 10:39:50 +0100 Message-Id: <20190123093951.24908-5-thierry.reding@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190123093951.24908-1-thierry.reding@gmail.com> References: <20190123093951.24908-1-thierry.reding@gmail.com> 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, Dmitry Osipenko , 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 On Tegra186 and later, the ARM SMMU provides an input address space that is 48 bits wide. However, memory clients can only address up to 40 bits. If the geometry is used as-is, allocations of IOVA space can end up in a region that cannot be addressed by the memory clients. To fix this, restrict the IOVA space to the DMA mask of the host1x device. Note that, technically, the IOVA space needs to be restricted to the intersection of the DMA masks for all clients that are attached to the IOMMU domain. In practice using the DMA mask of the host1x device is sufficient because all host1x clients share the same DMA mask. Signed-off-by: Thierry Reding --- drivers/gpu/drm/tegra/drm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index 271c7a5fc954..0c5f1e6a0446 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -136,11 +136,12 @@ static int tegra_drm_load(struct drm_device *drm, unsigned long flags) if (tegra->domain) { u64 carveout_start, carveout_end, gem_start, gem_end; + u64 dma_mask = dma_get_mask(&device->dev); dma_addr_t start, end; unsigned long order; - start = tegra->domain->geometry.aperture_start; - end = tegra->domain->geometry.aperture_end; + start = tegra->domain->geometry.aperture_start & dma_mask; + end = tegra->domain->geometry.aperture_end & dma_mask; gem_start = start; gem_end = end - CARVEOUT_SZ; From patchwork Wed Jan 23 09:39:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10776855 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 25CE06C2 for ; Wed, 23 Jan 2019 09:40:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15FC72A81C for ; Wed, 23 Jan 2019 09:40:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A90E2A87D; Wed, 23 Jan 2019 09:40:13 +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 C92252A81C for ; Wed, 23 Jan 2019 09:40:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2E0476EEAE; Wed, 23 Jan 2019 09:40:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by gabe.freedesktop.org (Postfix) with ESMTPS id 406416EEAF for ; Wed, 23 Jan 2019 09:40:03 +0000 (UTC) Received: by mail-wm1-x342.google.com with SMTP id a62so1269087wmh.4 for ; Wed, 23 Jan 2019 01:40:03 -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:in-reply-to :references:mime-version:content-transfer-encoding; bh=0S5b4a+9SaKfxqWDQqRsQruhZWip5+9qaZC2ybeTNek=; b=KT5oLdmhPOQyVI9j8j2gIzaBJiAYv9CoOVxCUXKkMomQoqj8LggsIbekzi0D1zao+4 FfM9HFjMhldd3p7850Yd0CNXLecvFRkTmk1oRBp7FInZaYXVF1u4YqvA8eHoHHnyF3zJ g2dS9UBbAmNkEXxZQoTb4xBgpOQLxBikKqykVAUZaTUuPqCvmH6Va2w5wb8lUx23Ou8h dsUVijMPEGgq7feYB9KchqyLMPIhRV/1ow9/AuZIsKzpvpnLNgv18y9vWp2ktamfIho7 5Xh9nWnbC6fjJLqhv64V19wLWIJohk03UwBUT8RG8HBZn+1vkz0bsQnU8kOLrngecx+p dZpg== X-Gm-Message-State: AJcUukdUhIbTqVC2Vwmz1bwyHMSbUKIoJijNsdCNZ71OQwuocbaANFKS ZuDu4zqvNHiuiRJpk8koHHU= X-Google-Smtp-Source: ALg8bN7d+AkVRcZ7PG7Wr7/OZIccRgeeq3vQbnyDFwJLw/d4IboUKr/KntlpkeKsUH7PWequbfh0HA== X-Received: by 2002:a1c:9a4c:: with SMTP id c73mr2044401wme.35.1548236400954; Wed, 23 Jan 2019 01:40:00 -0800 (PST) Received: from localhost (pD9E51040.dip0.t-ipconnect.de. [217.229.16.64]) by smtp.gmail.com with ESMTPSA id b18sm84356890wrw.83.2019.01.23.01.40.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Jan 2019 01:40:00 -0800 (PST) From: Thierry Reding To: Thierry Reding Subject: [PATCH 5/5] gpu: host1x: Supports 40-bit addressing on Tegra186 Date: Wed, 23 Jan 2019 10:39:51 +0100 Message-Id: <20190123093951.24908-6-thierry.reding@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190123093951.24908-1-thierry.reding@gmail.com> References: <20190123093951.24908-1-thierry.reding@gmail.com> 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, Dmitry Osipenko , 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 The host1x and clients instantiated on Tegra186 support addressing 40 bits of memory. Signed-off-by: Thierry Reding --- drivers/gpu/host1x/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c index 419d8929a98f..32fad4da7936 100644 --- a/drivers/gpu/host1x/dev.c +++ b/drivers/gpu/host1x/dev.c @@ -127,7 +127,7 @@ static const struct host1x_info host1x06_info = { .nb_bases = 16, .init = host1x06_init, .sync_offset = 0x0, - .dma_mask = DMA_BIT_MASK(34), + .dma_mask = DMA_BIT_MASK(40), .has_hypervisor = true, };