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);