From patchwork Tue Jun 16 21:21:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 11609249 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3F6EA90 for ; Wed, 17 Jun 2020 07:27:20 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2858620786 for ; Wed, 17 Jun 2020 07:27:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2858620786 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=v3.sk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D54796EABE; Wed, 17 Jun 2020 07:26:09 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from v6.sk (v6.sk [167.172.42.174]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1D5186E99B; Tue, 16 Jun 2020 21:21:36 +0000 (UTC) Received: from localhost (v6.sk [IPv6:::1]) by v6.sk (Postfix) with ESMTP id E9F7C61636; Tue, 16 Jun 2020 21:21:33 +0000 (UTC) From: Lubomir Rintel To: Lucas Stach Subject: [RESEND PATCH v2 1/4] drm/etnaviv: Fix error path on failure to enable bus clk Date: Tue, 16 Jun 2020 23:21:24 +0200 Message-Id: <20200616212127.986410-2-lkundrak@v3.sk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200616212127.986410-1-lkundrak@v3.sk> References: <20200616212127.986410-1-lkundrak@v3.sk> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 17 Jun 2020 07:26:03 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Russell King , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, etnaviv@lists.freedesktop.org, Lubomir Rintel Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Since commit 65f037e8e908 ("drm/etnaviv: add support for slave interface clock") the reg clock is enabled before the bus clock and we need to undo its enablement on error. Fixes: 65f037e8e908 ("drm/etnaviv: add support for slave interface clock") Signed-off-by: Lubomir Rintel --- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c index a31eeff2b297a..c6dacfe3d321e 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c @@ -1496,7 +1496,7 @@ static int etnaviv_gpu_clk_enable(struct etnaviv_gpu *gpu) if (gpu->clk_bus) { ret = clk_prepare_enable(gpu->clk_bus); if (ret) - return ret; + goto disable_clk_reg; } if (gpu->clk_core) { @@ -1519,6 +1519,9 @@ static int etnaviv_gpu_clk_enable(struct etnaviv_gpu *gpu) disable_clk_bus: if (gpu->clk_bus) clk_disable_unprepare(gpu->clk_bus); +disable_clk_reg: + if (gpu->clk_reg) + clk_disable_unprepare(gpu->clk_reg); return ret; } From patchwork Tue Jun 16 21:21:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 11609235 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B085590 for ; Wed, 17 Jun 2020 07:26:59 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9993D20786 for ; Wed, 17 Jun 2020 07:26:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9993D20786 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=v3.sk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2F10C6EAA5; Wed, 17 Jun 2020 07:26:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from v6.sk (v6.sk [167.172.42.174]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6F3C76E99B; Tue, 16 Jun 2020 21:21:37 +0000 (UTC) Received: from localhost (v6.sk [IPv6:::1]) by v6.sk (Postfix) with ESMTP id 3DC5261638; Tue, 16 Jun 2020 21:21:36 +0000 (UTC) From: Lubomir Rintel To: Lucas Stach Subject: [RESEND PATCH v2 2/4] drm/etnaviv: Don't ignore errors on getting clocks Date: Tue, 16 Jun 2020 23:21:25 +0200 Message-Id: <20200616212127.986410-3-lkundrak@v3.sk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200616212127.986410-1-lkundrak@v3.sk> References: <20200616212127.986410-1-lkundrak@v3.sk> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 17 Jun 2020 07:26:02 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Russell King , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, etnaviv@lists.freedesktop.org, Lubomir Rintel Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" There might be good reasons why the getting a clock failed. To treat the clocks as optional we're specifically only interested in ignoring -ENOENT, and devm_clk_get_optional() does just that. Note that this preserves the original behavior of all clocks being optional. The binding document mandates the "bus" clock while the dove machine only specifies "core". Signed-off-by: Lubomir Rintel --- Changes since v1: - Fix the actual return value drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c index c6dacfe3d321e..f303172c091db 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c @@ -1786,26 +1786,26 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev) } /* Get Clocks: */ - gpu->clk_reg = devm_clk_get(&pdev->dev, "reg"); + gpu->clk_reg = devm_clk_get_optional(&pdev->dev, "reg"); DBG("clk_reg: %p", gpu->clk_reg); if (IS_ERR(gpu->clk_reg)) - gpu->clk_reg = NULL; + return PTR_ERR(gpu->clk_reg); - gpu->clk_bus = devm_clk_get(&pdev->dev, "bus"); + gpu->clk_bus = devm_clk_get_optional(&pdev->dev, "bus"); DBG("clk_bus: %p", gpu->clk_bus); if (IS_ERR(gpu->clk_bus)) - gpu->clk_bus = NULL; + return PTR_ERR(gpu->clk_bus); - gpu->clk_core = devm_clk_get(&pdev->dev, "core"); + gpu->clk_core = devm_clk_get_optional(&pdev->dev, "core"); DBG("clk_core: %p", gpu->clk_core); if (IS_ERR(gpu->clk_core)) - gpu->clk_core = NULL; + return PTR_ERR(gpu->clk_core); gpu->base_rate_core = clk_get_rate(gpu->clk_core); - gpu->clk_shader = devm_clk_get(&pdev->dev, "shader"); + gpu->clk_shader = devm_clk_get_optional(&pdev->dev, "shader"); DBG("clk_shader: %p", gpu->clk_shader); if (IS_ERR(gpu->clk_shader)) - gpu->clk_shader = NULL; + return PTR_ERR(gpu->clk_shader); gpu->base_rate_shader = clk_get_rate(gpu->clk_shader); /* TODO: figure out max mapped size */ From patchwork Tue Jun 16 21:21:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 11609247 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F30FB90 for ; Wed, 17 Jun 2020 07:27:12 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DC05820786 for ; Wed, 17 Jun 2020 07:27:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DC05820786 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=v3.sk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6E9EC6EA93; Wed, 17 Jun 2020 07:26:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from v6.sk (v6.sk [167.172.42.174]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8A3886E9A7; Tue, 16 Jun 2020 21:22:09 +0000 (UTC) Received: from localhost (v6.sk [IPv6:::1]) by v6.sk (Postfix) with ESMTP id 5C4C76163A; Tue, 16 Jun 2020 21:21:38 +0000 (UTC) From: Lubomir Rintel To: Lucas Stach Subject: [RESEND PATCH v2 3/4] drm/etnaviv: Make the "core" clock mandatory Date: Tue, 16 Jun 2020 23:21:26 +0200 Message-Id: <20200616212127.986410-4-lkundrak@v3.sk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200616212127.986410-1-lkundrak@v3.sk> References: <20200616212127.986410-1-lkundrak@v3.sk> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 17 Jun 2020 07:26:03 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Russell King , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, etnaviv@lists.freedesktop.org, Lubomir Rintel Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" It is always present. It was documented as mandatory prior to commit 90aeca875f8a ("dt-bindings: display: Convert etnaviv to json-schema"). Signed-off-by: Lubomir Rintel --- Changes since v1: - Add this patch drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c index f303172c091db..798fdbc8ecdb5 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c @@ -1796,7 +1796,7 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev) if (IS_ERR(gpu->clk_bus)) return PTR_ERR(gpu->clk_bus); - gpu->clk_core = devm_clk_get_optional(&pdev->dev, "core"); + gpu->clk_core = devm_clk_get(&pdev->dev, "core"); DBG("clk_core: %p", gpu->clk_core); if (IS_ERR(gpu->clk_core)) return PTR_ERR(gpu->clk_core); From patchwork Tue Jun 16 21:21:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 11609211 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CB954912 for ; Wed, 17 Jun 2020 07:26:32 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B2EA020786 for ; Wed, 17 Jun 2020 07:26:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B2EA020786 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=v3.sk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C23906EA45; Wed, 17 Jun 2020 07:26:04 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from v6.sk (v6.sk [167.172.42.174]) by gabe.freedesktop.org (Postfix) with ESMTPS id 738666E9A5; Tue, 16 Jun 2020 21:21:41 +0000 (UTC) Received: from localhost (v6.sk [IPv6:::1]) by v6.sk (Postfix) with ESMTP id 4D4586163C; Tue, 16 Jun 2020 21:21:40 +0000 (UTC) From: Lubomir Rintel To: Lucas Stach Subject: [RESEND PATCH v2 4/4] drm/etnaviv: Simplify clock enable/disable Date: Tue, 16 Jun 2020 23:21:27 +0200 Message-Id: <20200616212127.986410-5-lkundrak@v3.sk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200616212127.986410-1-lkundrak@v3.sk> References: <20200616212127.986410-1-lkundrak@v3.sk> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 17 Jun 2020 07:26:03 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Russell King , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, etnaviv@lists.freedesktop.org, Lubomir Rintel Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" All the NULL checks are pointless, clk_*() routines already deal with NULL just fine. Signed-off-by: Lubomir Rintel --- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 53 ++++++++++----------------- 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c index 798fdbc8ecdb5..fb37787449bb7 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c @@ -1487,55 +1487,40 @@ static int etnaviv_gpu_clk_enable(struct etnaviv_gpu *gpu) { int ret; - if (gpu->clk_reg) { - ret = clk_prepare_enable(gpu->clk_reg); - if (ret) - return ret; - } + ret = clk_prepare_enable(gpu->clk_reg); + if (ret) + return ret; - if (gpu->clk_bus) { - ret = clk_prepare_enable(gpu->clk_bus); - if (ret) - goto disable_clk_reg; - } + ret = clk_prepare_enable(gpu->clk_bus); + if (ret) + goto disable_clk_reg; - if (gpu->clk_core) { - ret = clk_prepare_enable(gpu->clk_core); - if (ret) - goto disable_clk_bus; - } + ret = clk_prepare_enable(gpu->clk_core); + if (ret) + goto disable_clk_bus; - if (gpu->clk_shader) { - ret = clk_prepare_enable(gpu->clk_shader); - if (ret) - goto disable_clk_core; - } + ret = clk_prepare_enable(gpu->clk_shader); + if (ret) + goto disable_clk_core; return 0; disable_clk_core: - if (gpu->clk_core) - clk_disable_unprepare(gpu->clk_core); + clk_disable_unprepare(gpu->clk_core); disable_clk_bus: - if (gpu->clk_bus) - clk_disable_unprepare(gpu->clk_bus); + clk_disable_unprepare(gpu->clk_bus); disable_clk_reg: - if (gpu->clk_reg) - clk_disable_unprepare(gpu->clk_reg); + clk_disable_unprepare(gpu->clk_reg); return ret; } static int etnaviv_gpu_clk_disable(struct etnaviv_gpu *gpu) { - if (gpu->clk_shader) - clk_disable_unprepare(gpu->clk_shader); - if (gpu->clk_core) - clk_disable_unprepare(gpu->clk_core); - if (gpu->clk_bus) - clk_disable_unprepare(gpu->clk_bus); - if (gpu->clk_reg) - clk_disable_unprepare(gpu->clk_reg); + clk_disable_unprepare(gpu->clk_shader); + clk_disable_unprepare(gpu->clk_core); + clk_disable_unprepare(gpu->clk_bus); + clk_disable_unprepare(gpu->clk_reg); return 0; }