From patchwork Fri Nov 23 12:06:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10695711 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 0E1111750 for ; Fri, 23 Nov 2018 12:06:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1EC32AB8C for ; Fri, 23 Nov 2018 12:06:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E63B22B681; Fri, 23 Nov 2018 12:06:47 +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 A1FB62AB8C for ; Fri, 23 Nov 2018 12:06:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BB67C6E08E; Fri, 23 Nov 2018 12:06:46 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6BE9B6E082 for ; Fri, 23 Nov 2018 12:06:42 +0000 (UTC) Received: by mail-ed1-x542.google.com with SMTP id y56so10057073edd.11 for ; Fri, 23 Nov 2018 04:06:42 -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=4BOTl7jux4pQasSyxKIZHtohs1Rc7WDNsfhWL1lC7Ac=; b=N9fQ5ZfVGyhfyYig5872i678KRjxiE2QQLBM42syp7tz5NO80LiBxZWxkooU720YTc +ARAw1PgVNP5l9pZ8OFNT5XWHgrVjlbVO5yeNPBhlPObrnRzArUcVyrEZdzDXUha+b/M 1diL5OVoVcaD1zejjOZrilaLNDegx/uBrrC5lexe4if1Qt6AIsei3y260NMDXPCWdCbU fYO4ppmgvR6bBNR2xU/HLfunVhJL/1PXV4YQEVbatZqDKEu6K4TDtzcJrEyxVKv6ukVy 0MmQf5cqcTiBA/V20lyM0Zi31Sw1fWAslsThISrVm3+W20tG2z7UQgRlji42IZRtrYh/ PqWQ== X-Gm-Message-State: AA+aEWZd7PYrsHElS65sjZzNGiewmVT1AmA19bXTubL7yTIhWqbX8Rvv MKx73st6mrZGfp8NgdAPizU= X-Google-Smtp-Source: AFSGD/WlXGV59U5AHaA1bLfarEzaJ6oQziDbIrPEHwpH8hjwGErkY6G841n4tEbrk0+2gA3Sc/yLkg== X-Received: by 2002:a50:a5b8:: with SMTP id a53mr13367817edc.199.1542974801042; Fri, 23 Nov 2018 04:06:41 -0800 (PST) Received: from localhost (pD9E51040.dip0.t-ipconnect.de. [217.229.16.64]) by smtp.gmail.com with ESMTPSA id f19-v6sm4571896eje.28.2018.11.23.04.06.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 23 Nov 2018 04:06:40 -0800 (PST) From: Thierry Reding To: Thierry Reding Subject: [PATCH 1/3] drm/tegra: vic: Implement explicit reset support Date: Fri, 23 Nov 2018 13:06:37 +0100 Message-Id: <20181123120639.16706-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 Tegra supports generic PM domains on 64-bit ARM, and if that is enabled, the power domain code will make sure that resets are asserted and deasserted at appropriate points in time. If generic PM domains are not implemented, such as on 32-bit Tegra, the resets need to be asserted and deasserted explicitly by the driver. Signed-off-by: Thierry Reding --- drivers/gpu/drm/tegra/vic.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/tegra/vic.c b/drivers/gpu/drm/tegra/vic.c index 9fa77405db01..23f530db45ad 100644 --- a/drivers/gpu/drm/tegra/vic.c +++ b/drivers/gpu/drm/tegra/vic.c @@ -38,6 +38,7 @@ struct vic { struct iommu_domain *domain; struct device *dev; struct clk *clk; + struct reset_control *rst; /* Platform configuration */ const struct vic_config *config; @@ -56,13 +57,37 @@ static void vic_writel(struct vic *vic, u32 value, unsigned int offset) static int vic_runtime_resume(struct device *dev) { struct vic *vic = dev_get_drvdata(dev); + int err; + + err = clk_prepare_enable(vic->clk); + if (err < 0) + return err; + + usleep_range(2000, 4000); + + err = reset_control_deassert(vic->rst); + if (err < 0) + goto disable; + + usleep_range(2000, 4000); + + return 0; - return clk_prepare_enable(vic->clk); +disable: + clk_disable_unprepare(vic->clk); + return err; } static int vic_runtime_suspend(struct device *dev) { struct vic *vic = dev_get_drvdata(dev); + int err; + + err = reset_control_assert(vic->rst); + if (err < 0) + return err; + + usleep_range(2000, 4000); clk_disable_unprepare(vic->clk); @@ -324,6 +349,14 @@ static int vic_probe(struct platform_device *pdev) return PTR_ERR(vic->clk); } + if (!dev->pm_domain) { + vic->rst = devm_reset_control_get(dev, "vic"); + if (IS_ERR(vic->rst)) { + dev_err(&pdev->dev, "failed to get reset\n"); + return PTR_ERR(vic->rst); + } + } + vic->falcon.dev = dev; vic->falcon.regs = vic->regs; vic->falcon.ops = &vic_falcon_ops; From patchwork Fri Nov 23 12:06:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10695715 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 E0D5B1750 for ; Fri, 23 Nov 2018 12:06:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C78112AB8C for ; Fri, 23 Nov 2018 12:06:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B7C7A2B681; Fri, 23 Nov 2018 12:06:51 +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 5E5C82AB8C for ; Fri, 23 Nov 2018 12:06:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AE8F36E38C; Fri, 23 Nov 2018 12:06:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2A8D26E08E for ; Fri, 23 Nov 2018 12:06:44 +0000 (UTC) Received: by mail-ed1-x543.google.com with SMTP id f23so10098234edb.3 for ; Fri, 23 Nov 2018 04:06:44 -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=UlhLaZR7xR64FGSfaC1b+5i9naLiprMABQwSDDY64EY=; b=HBBdL/VLFzbpHAN9EiGbS3fqzSG3yFhv72PRz6vKfvy4LxwJSq/GpAltzkXrQTeMdJ tW/ru2BNkdByzyGtJkCz5/qQOjxsBaCofP9i4grgs/G0eGnY/iGlQAlKWhSWr8TlXQQr chmn7znic/0fYb5j+g7rv7xK20mEfQgokuGEOp/grVnAyIGGmSL9G40qItR04I+LGoyA Do+9ir0G/Abs99I11iAbhL9E36Q7sncW9lqmCWZukXo3aJpqH+2eg+M0hiMI48X3SbS+ ThRKxjJrqP6vD8FeD4+Ycq0IbS6l8zYeENJCBPm6+KnbfH9HqZG3jVXTU0Gxuv0dXBjP yfwQ== X-Gm-Message-State: AGRZ1gJZiRnVA62uoZRbUVFN14298I1jUlnr+xdWrb23Clh9symz5ih2 G6/6WTWMAeaiuMFqLVE3mac= X-Google-Smtp-Source: AJdET5dSkK8I9EuexY20dMKeCsbDYEMvCoNpqPdYIivFbl43QvhqMeasxj5BS9c5+8fXzlsugqKUrA== X-Received: by 2002:a17:906:f1c9:: with SMTP id gx9-v6mr11293339ejb.144.1542974802666; Fri, 23 Nov 2018 04:06:42 -0800 (PST) Received: from localhost (pD9E51040.dip0.t-ipconnect.de. [217.229.16.64]) by smtp.gmail.com with ESMTPSA id m13sm12690521edd.2.2018.11.23.04.06.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 23 Nov 2018 04:06:42 -0800 (PST) From: Thierry Reding To: Thierry Reding Subject: [PATCH 2/3] drm/tegra: falcon: Fix error handling Date: Fri, 23 Nov 2018 13:06:38 +0100 Message-Id: <20181123120639.16706-2-thierry.reding@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181123120639.16706-1-thierry.reding@gmail.com> References: <20181123120639.16706-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, 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 ->alloc() callback in struct falcon_ops returns an ERR_PTR()-encoded error code on failure, so it needs to be properly checked for, otherwise subsequent code may dereference an invalid pointer. Signed-off-by: Thierry Reding --- drivers/gpu/drm/tegra/falcon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/tegra/falcon.c b/drivers/gpu/drm/tegra/falcon.c index f685e72949d1..78c7a0156601 100644 --- a/drivers/gpu/drm/tegra/falcon.c +++ b/drivers/gpu/drm/tegra/falcon.c @@ -141,9 +141,9 @@ int falcon_load_firmware(struct falcon *falcon) /* allocate iova space for the firmware */ falcon->firmware.vaddr = falcon->ops->alloc(falcon, firmware->size, &falcon->firmware.paddr); - if (!falcon->firmware.vaddr) { - dev_err(falcon->dev, "dma memory mapping failed\n"); - return -ENOMEM; + if (IS_ERR(falcon->firmware.vaddr)) { + dev_err(falcon->dev, "DMA memory mapping failed\n"); + return PTR_ERR(falcon->firmware.vaddr); } /* copy firmware image into local area. this also ensures endianness */ From patchwork Fri Nov 23 12:06:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10695713 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 2561A15A7 for ; Fri, 23 Nov 2018 12:06:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1484B2AEF7 for ; Fri, 23 Nov 2018 12:06:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0887B2B9C8; Fri, 23 Nov 2018 12:06:50 +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 C33A32AEF7 for ; Fri, 23 Nov 2018 12:06:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3515E6E0A1; Fri, 23 Nov 2018 12:06:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by gabe.freedesktop.org (Postfix) with ESMTPS id A91B16E08E for ; Fri, 23 Nov 2018 12:06:45 +0000 (UTC) Received: by mail-ed1-x544.google.com with SMTP id d39so10043996edb.12 for ; Fri, 23 Nov 2018 04:06:45 -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=LmSfTSYiNHwRh/ulZS6uMw1khgT7uazWkLgcZFIFVFg=; b=lbFyp84hUlfSeUEXKs6dWs9J8azgmVZApfUbawUof2l7idV0EtV7AgeUUYtGNyKNUp TXMnEQ8wTcd4sk/bP2LwXPdJ7ZAHDKv1lQGU2WxTNUiL0rW+f3o+8PxIs2KO+DgkZKcO qsDB4KTQOyS7K3EM9YR3KAVCXr7qwhpRKO75iW1hs7PzpFHligfZN2VDvKWuvk5YoLPD izQDbiEoZrvWNImwJF4+K+ic5DcPerSY/M0Da1Ux93RYoZAzAgHh/nKmPoS8CSMgt1Dq J7393iaU0AnkOJX7GX01y3xGsGm+bBzhwEjSa+V0bp46eH4LHiqNIBnKxKv11jdwznjZ nY2Q== X-Gm-Message-State: AGRZ1gKoYRQ70hmAqDtwSKXUxZ1DvaKy0UbnyzHgKXxsXyLR9fJESbJA MaUhdhPOSBO3eUtKON55Amg= X-Google-Smtp-Source: AJdET5eaibA8wjMW2UgjSUmTwSJaEogOoFfHml1SxwkGmvjrXTiRhSRlTCpXfn1o1cgCZumZNrv9sQ== X-Received: by 2002:a17:906:4a4b:: with SMTP id a11-v6mr11341294ejv.68.1542974804266; Fri, 23 Nov 2018 04:06:44 -0800 (PST) Received: from localhost (pD9E51040.dip0.t-ipconnect.de. [217.229.16.64]) by smtp.gmail.com with ESMTPSA id w10sm11000141eda.77.2018.11.23.04.06.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 23 Nov 2018 04:06:43 -0800 (PST) From: Thierry Reding To: Thierry Reding Subject: [PATCH 3/3] drm/tegra: falcon: Wait for memory scrubbing to complete Date: Fri, 23 Nov 2018 13:06:39 +0100 Message-Id: <20181123120639.16706-3-thierry.reding@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181123120639.16706-1-thierry.reding@gmail.com> References: <20181123120639.16706-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, 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 Before booting the Falcon processor, make sure to wait for memory scrubbing to complete. Signed-off-by: Thierry Reding --- drivers/gpu/drm/tegra/falcon.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/tegra/falcon.c b/drivers/gpu/drm/tegra/falcon.c index 78c7a0156601..352d05feabb0 100644 --- a/drivers/gpu/drm/tegra/falcon.c +++ b/drivers/gpu/drm/tegra/falcon.c @@ -197,11 +197,19 @@ void falcon_exit(struct falcon *falcon) int falcon_boot(struct falcon *falcon) { unsigned long offset; + u32 value; int err; if (!falcon->firmware.vaddr) return -EINVAL; + err = readl_poll_timeout(falcon->regs + FALCON_DMACTL, value, + (value & (FALCON_DMACTL_IMEM_SCRUBBING | + FALCON_DMACTL_DMEM_SCRUBBING)) == 0, + 10, 10000); + if (err < 0) + return err; + falcon_writel(falcon, 0, FALCON_DMACTL); /* setup the address of the binary data so Falcon can access it later */