Message ID | 20231101-tidss-probe-v1-7-45149e0f9415@ideasonboard.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:abcd:0:b0:403:3b70:6f57 with SMTP id f13csp282547vqx; Wed, 1 Nov 2023 02:19:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEb3BySUFonenRqJGyKrGxJhkiPbeANTVkcZu/3AD9ua0wZc0pmm4TiLtoomQOfT//VLVfu X-Received: by 2002:a05:6358:7212:b0:168:e7fc:1209 with SMTP id h18-20020a056358721200b00168e7fc1209mr14701320rwa.22.1698830368233; Wed, 01 Nov 2023 02:19:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698830368; cv=none; d=google.com; s=arc-20160816; b=AcqJ9FfKKK99VRuZeSMkoxUvvpRAw6gBh5e8Zu0M+f2AQq/CIhhzP2Zii1fpDCJGUo KrmFnSs79ISyb9O6ty6cRW/lsBlRO0hIe5wEWz8MRIk1CZ/Ekq/sRzrfdO4xFrpWXNuL VAp+6vDFfKaTX1B2jrd8cL4dIvY6CIVFwD6xqjd7FEG64XUYsyU6pUGaLcTCRKHnE+ra 3Koo4f376sLnAG0J58b5yhkh19gN614BuSYGu41V3xZR3T2ShUPLHQzQwQ27MAWei4WK GnOAG1gpbAb6y0p6UB/nJttoamVe/p5/nT3JaD5fW2Ve9J7i8HWb8i7HZEIk15EDlAoS yF5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=QTE05KeiuezyEKTX9mkuL9VK77vBOJIH+1LpvM0ag34=; fh=IpenHstmzluQ2qG4rgZds4W72uLPbZNMEjQq5GLr0+k=; b=R/sGsPGfQ+A9kglI1PTnZgNY4PPDXREzAOwRrPpOKBKCEZwUSmwP+oHpncvzFjo3YZ r6rVrORHC4xO418GhTzZYok1XbaVNRSvKTyHbKASX681wY1yJUvtwcHu9uRukPr6jboS qyRxODIgcYhOtSJCXl4BEmYM+JxAfYwP3u9QLaJpxM9ixxmW2azd2FCHCSooBAVqUjvJ O+9oX/Maa1NHJhzi9dDOebYmMiqXn52dX3Z72YSxqO6v5liUV7RkSh7F9UgAMZXScUAF uvNimdFF+d26nzyZymfykR2tvTgHpK0BhOAPMtmqZU7HQMeBZAt1UhyRpean4wD4AyKi lhWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=X28UD5Bs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id e62-20020a636941000000b00585a6bdce46si2603299pgc.308.2023.11.01.02.19.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 02:19:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=X28UD5Bs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 60C3B80D44FC; Wed, 1 Nov 2023 02:19:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234999AbjKAJTR (ORCPT <rfc822;rbbytesnap@gmail.com> + 35 others); Wed, 1 Nov 2023 05:19:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234894AbjKAJTH (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 1 Nov 2023 05:19:07 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF9F910F for <linux-kernel@vger.kernel.org>; Wed, 1 Nov 2023 02:18:56 -0700 (PDT) Received: from [127.0.1.1] (91-158-149-209.elisa-laajakaista.fi [91.158.149.209]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A4C6F1BAE; Wed, 1 Nov 2023 10:18:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1698830303; bh=dkl3jtDooC1JFtaD0YoyJ131w9qjC5vo5eQl2h7Sweo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=X28UD5BsxO8OYz1iBNC/hEargVmbvL7kBwjtoMi4DnBqAbZdZszrGVIWyp4s7IAbd 1AVMmwshLM8JHaJF9zrLfFeCQiw9mP3h8QvHnB7ZqeYqMGPxhnBQd1qdX8h6NcqhVh dXK95kbx1eUUPcBu2f0noTr9DHcB7CGyqUs9AbLc= From: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Date: Wed, 01 Nov 2023 11:17:44 +0200 Subject: [PATCH 07/10] drm/tidss: Fix dss reset MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231101-tidss-probe-v1-7-45149e0f9415@ideasonboard.com> References: <20231101-tidss-probe-v1-0-45149e0f9415@ideasonboard.com> In-Reply-To: <20231101-tidss-probe-v1-0-45149e0f9415@ideasonboard.com> To: Aradhya Bhatia <a-bhatia1@ti.com>, Devarsh Thakkar <devarsht@ti.com>, Jyri Sarha <jyri.sarha@iki.fi>, Maarten Lankhorst <maarten.lankhorst@linux.intel.com>, Maxime Ripard <mripard@kernel.org>, Thomas Zimmermann <tzimmermann@suse.de>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch> Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Laurent Pinchart <laurent.pinchart@ideasonboard.com>, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=2654; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=dkl3jtDooC1JFtaD0YoyJ131w9qjC5vo5eQl2h7Sweo=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBlQhfnclbJel7gQ5GXPPWj5UOUtsFOinZZ0pugH /NxyVI+gV+JAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZUIX5wAKCRD6PaqMvJYe 9XdDD/9FXC7yP4L2ixb760gH7/wVpJyGAsTsAlYaoBTFTw5xeGwhs8RjwMtFnhLBbF5zmmMqyNF OxZnojctXWY/mBYxSHUjx/a9PELtelP094ZjhLD9EG4Ng4GiPRst8TMeE8DhioLT+b0E66EevUf /FObJE4gO2GA1AXutg7+AHqAXIoFXS5E67u4rJuRbOzbfTyOW5R/NhVp2IcCQGxMAMFcINI1/gW kKlX7uos1wVdGxsWnQkezqPjrLodBtph11X+URZvvnUlKtJDXc8+UwtJHx06axtrPHZd88NL6U/ EMmY6NQ5GHscG/6GmskW2ojmPIF1M1VyfFzFwkxt5pi95dhfOn02C8IOmyGY/tOBPWDZa237Yk7 G9xRRjuJ6jJTO/Cu6WKL0fW5HDkIA0kg3i93lvSOBHleAcvqBTo9FnvviNEPdlw+BJMbsMErdPH RFnvCGWdgEk/6F/JulnQ1UW5E9ObYsQ0RjmbmC1mO68zShNkdQ34cE+gJ9SRBRAr9QSBfF5XKHZ IbEr5z0JPIapFTgVYGFCxjXDS2rWq974WtIk/f1KBKKr7i10KU+cp/lY1omCsH1hjeGpMwWYVuL j01zWpoSgc3ciZJVzOOM3aNlZo3gABubkDqOPk2VKmhXhDJ9sC8pyCNZIvHRWWnJfHRayHKAQ2y 3uSypv0sboLvj8Q== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 01 Nov 2023 02:19:27 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781352752062398678 X-GMAIL-MSGID: 1781352752062398678 |
Series |
drm/tidss: Probe related fixes and cleanups
|
|
Commit Message
Tomi Valkeinen
Nov. 1, 2023, 9:17 a.m. UTC
The probe function calls dispc_softreset() before runtime PM is enabled
and without enabling any of the DSS clocks. This happens to work by
luck, and we need to make sure the DSS HW is active and the fclk is
enabled.
To fix the above, add a new function, dispc_init_hw(), which does:
- pm_runtime_set_active()
- clk_prepare_enable(fclk)
- dispc_softreset().
This ensures that the reset can be successfully accomplished.
Note that we use pm_runtime_set_active(), not the normal
pm_runtime_get(). The reason for this is that at this point we haven't
enabled the runtime PM yet and also we don't want the normal resume
callback to be called: the dispc resume callback does some initial HW
setup, and it expects that the HW was off (no video ports are
streaming). If the bootloader has enabled the DSS and has set up a
boot time splash-screen, the DSS would be enabled and streaming which
might lead to issues with the normal resume callback.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
drivers/gpu/drm/tidss/tidss_dispc.c | 45 ++++++++++++++++++++++++++++++++++++-
1 file changed, 44 insertions(+), 1 deletion(-)
Comments
Hi Tomi, Thank you for the patch. On Wed, Nov 01, 2023 at 11:17:44AM +0200, Tomi Valkeinen wrote: > The probe function calls dispc_softreset() before runtime PM is enabled > and without enabling any of the DSS clocks. This happens to work by > luck, and we need to make sure the DSS HW is active and the fclk is > enabled. > > To fix the above, add a new function, dispc_init_hw(), which does: > > - pm_runtime_set_active() > - clk_prepare_enable(fclk) > - dispc_softreset(). > > This ensures that the reset can be successfully accomplished. > > Note that we use pm_runtime_set_active(), not the normal > pm_runtime_get(). The reason for this is that at this point we haven't > enabled the runtime PM yet and also we don't want the normal resume > callback to be called: the dispc resume callback does some initial HW > setup, and it expects that the HW was off (no video ports are > streaming). If the bootloader has enabled the DSS and has set up a > boot time splash-screen, the DSS would be enabled and streaming which > might lead to issues with the normal resume callback. I think the right way to do this would be, in probe(), to - power on the device - enable runtime PM, masking the device as active - at end of probe, calling pm_runtime_put_autosuspend() Please also see my review of patch 02/10. > Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> > --- > drivers/gpu/drm/tidss/tidss_dispc.c | 45 ++++++++++++++++++++++++++++++++++++- > 1 file changed, 44 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/tidss/tidss_dispc.c b/drivers/gpu/drm/tidss/tidss_dispc.c > index f204a0701e9f..13db062892e3 100644 > --- a/drivers/gpu/drm/tidss/tidss_dispc.c > +++ b/drivers/gpu/drm/tidss/tidss_dispc.c > @@ -2724,6 +2724,49 @@ static int dispc_softreset(struct dispc_device *dispc) > return 0; > } > > +static int dispc_init_hw(struct dispc_device *dispc) > +{ > + struct device *dev = dispc->dev; > + int ret; > + > + ret = pm_runtime_set_active(dev); > + if (ret) { > + dev_err(dev, "Failed to set DSS PM to active\n"); > + return ret; > + } > + > + ret = clk_prepare_enable(dispc->fclk); > + if (ret) { > + dev_err(dev, "Failed to enable DSS fclk\n"); > + goto err_runtime_suspend; > + } > + > + ret = dispc_softreset(dispc); > + if (ret) > + goto err_clk_disable; > + > + clk_disable_unprepare(dispc->fclk); > + ret = pm_runtime_set_suspended(dev); > + if (ret) { > + dev_err(dev, "Failed to set DSS PM to suspended\n"); > + return ret; > + } > + > + return 0; > + > +err_clk_disable: > + clk_disable_unprepare(dispc->fclk); > + > +err_runtime_suspend: > + ret = pm_runtime_set_suspended(dev); > + if (ret) { > + dev_err(dev, "Failed to set DSS PM to suspended\n"); > + return ret; > + } > + > + return ret; > +} > + > int dispc_init(struct tidss_device *tidss) > { > struct device *dev = tidss->dev; > @@ -2835,7 +2878,7 @@ int dispc_init(struct tidss_device *tidss) > > tidss->dispc = dispc; > > - r = dispc_softreset(dispc); > + r = dispc_init_hw(dispc); > if (r) > return r; >
On 01/11/2023 16:30, Laurent Pinchart wrote: > Hi Tomi, > > Thank you for the patch. > > On Wed, Nov 01, 2023 at 11:17:44AM +0200, Tomi Valkeinen wrote: >> The probe function calls dispc_softreset() before runtime PM is enabled >> and without enabling any of the DSS clocks. This happens to work by >> luck, and we need to make sure the DSS HW is active and the fclk is >> enabled. >> >> To fix the above, add a new function, dispc_init_hw(), which does: >> >> - pm_runtime_set_active() >> - clk_prepare_enable(fclk) >> - dispc_softreset(). >> >> This ensures that the reset can be successfully accomplished. >> >> Note that we use pm_runtime_set_active(), not the normal >> pm_runtime_get(). The reason for this is that at this point we haven't >> enabled the runtime PM yet and also we don't want the normal resume >> callback to be called: the dispc resume callback does some initial HW >> setup, and it expects that the HW was off (no video ports are >> streaming). If the bootloader has enabled the DSS and has set up a >> boot time splash-screen, the DSS would be enabled and streaming which >> might lead to issues with the normal resume callback. > > I think the right way to do this would be, in probe(), to > > - power on the device > - enable runtime PM, masking the device as active > - at end of probe, calling pm_runtime_put_autosuspend() Can you explain what that would accomplish, or why the code in this patch is wrong? If I understand it right, you're suggesting a more "normal" power up at the probe time, and then leaving the DSS enabled, but with autosuspend. That would require powering up, doing a reset, and calling dispc_runtime_resume. Which can be done, but I'm not sure why it's better, as we're not interested in "normal" power up at probe time. But I can see that my approach looks perhaps a bit odd just by looking at these patches. This work was related to keeping the bootloader's splash screen on the screen for a longer time, i.e. delaying reset. For that, I wanted an early function (dispc_init_hw) which would, instead of always resetting the DSS as it does in this version, peek at the DSS hardware, and see if the DSS is already streaming. If no, do a reset and proceed normally. If yes, skip the reset, leave the clocks enabled, and keep DSS PM active. Later, when we'd be doing the first modeset, the driver would do the initial reset. So, that's why I wanted an independent function for the HW probing/init, which is called before runtime PM is enabled, and I did not want normal runtime resume to be called as dispc_runtime_resume() would break the display. I think a better solution would be to set up the fb of tidss's fbdev to use the reserved memory, used for the boot splash screen. But I didn't figure out a way to do this. But even there we'd like to delay the reset until the first modeset (when the fbdev display is getting enabled). Tomi
On Wed, Nov 01, 2023 at 11:17:44AM +0200, Tomi Valkeinen wrote: > The probe function calls dispc_softreset() before runtime PM is enabled > and without enabling any of the DSS clocks. This happens to work by > luck, and we need to make sure the DSS HW is active and the fclk is > enabled. Not sure on the exact implication here, however from the description this seems a candidate for stable and would need a Fixes tag. Francesco
diff --git a/drivers/gpu/drm/tidss/tidss_dispc.c b/drivers/gpu/drm/tidss/tidss_dispc.c index f204a0701e9f..13db062892e3 100644 --- a/drivers/gpu/drm/tidss/tidss_dispc.c +++ b/drivers/gpu/drm/tidss/tidss_dispc.c @@ -2724,6 +2724,49 @@ static int dispc_softreset(struct dispc_device *dispc) return 0; } +static int dispc_init_hw(struct dispc_device *dispc) +{ + struct device *dev = dispc->dev; + int ret; + + ret = pm_runtime_set_active(dev); + if (ret) { + dev_err(dev, "Failed to set DSS PM to active\n"); + return ret; + } + + ret = clk_prepare_enable(dispc->fclk); + if (ret) { + dev_err(dev, "Failed to enable DSS fclk\n"); + goto err_runtime_suspend; + } + + ret = dispc_softreset(dispc); + if (ret) + goto err_clk_disable; + + clk_disable_unprepare(dispc->fclk); + ret = pm_runtime_set_suspended(dev); + if (ret) { + dev_err(dev, "Failed to set DSS PM to suspended\n"); + return ret; + } + + return 0; + +err_clk_disable: + clk_disable_unprepare(dispc->fclk); + +err_runtime_suspend: + ret = pm_runtime_set_suspended(dev); + if (ret) { + dev_err(dev, "Failed to set DSS PM to suspended\n"); + return ret; + } + + return ret; +} + int dispc_init(struct tidss_device *tidss) { struct device *dev = tidss->dev; @@ -2835,7 +2878,7 @@ int dispc_init(struct tidss_device *tidss) tidss->dispc = dispc; - r = dispc_softreset(dispc); + r = dispc_init_hw(dispc); if (r) return r;