From patchwork Mon Apr 15 16:00:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13630243 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AF8E2C00A94 for ; Mon, 15 Apr 2024 16:01:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aPHAMpuIOmfh4slzf9aOmdXkWejpV+yD+h2eEvt2/RE=; b=zcY6dx9W7obEVI E8D2vhliVNZXIcPhqzxewpgVP7fnjskXaySpsSX2NbiFYGrr0E6SCV9GSyU+emKkJ/596AFOWOS8k CbSo7nmrzoN/tDBrk85ds/0vF6dWVKYO+qGBue8YDAm2e8403WSFX7DrBgKdUh6m6Mj66m4dfujXl /IsDy4m6c85siAK+oAjsXV5iFim/I7dDmIL2dCkQaE7gIcFORu5b6PVjWhpgNXBJicCwCmWhiKRAx YoLhYjbWmyILNlUDVLICGbuvC43gftgUwn09STmaQ3Wzm2nwh0xZ8wbIumyAJBrrzih6H+lrdiuS/ uDKbInufZrzE0NPEh+ew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwOlJ-00000008y8Q-0DNW; Mon, 15 Apr 2024 16:00:53 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwOlB-00000008y3e-2h50 for linux-arm-kernel@lists.infradead.org; Mon, 15 Apr 2024 16:00:51 +0000 Received: from [127.0.1.1] (91-154-34-181.elisa-laajakaista.fi [91.154.34.181]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 95B12720; Mon, 15 Apr 2024 17:59:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1713196797; bh=q5d8K34P4d8eJgHgXhElAdn8Ywho6XrfAYskz43O1Ow=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=pjcCXIxogHHjn9WYkB3L2LatIOWVFWC5Vk0NGyhmggt4DtryxMwPFe0JSCVQrTPZ4 G4IU3ZJJzdaGpET6ydeZrgBxdBuvJEk8qh4DWdU0oFUlEfy1XiO1nHOW2g6U8K24MT 0JY1BSD+r4xZSbkhjU47zbEZmPjM8YKZ870/FMEA= From: Tomi Valkeinen Date: Mon, 15 Apr 2024 19:00:23 +0300 Subject: [PATCH RFC 1/2] pmdomain: ti-sci: Fix duplicate PD referrals MIME-Version: 1.0 Message-Id: <20240415-ti-sci-pd-v1-1-a0e56b8ad897@ideasonboard.com> References: <20240415-ti-sci-pd-v1-0-a0e56b8ad897@ideasonboard.com> In-Reply-To: <20240415-ti-sci-pd-v1-0-a0e56b8ad897@ideasonboard.com> To: Nishanth Menon , Tero Kristo , Santosh Shilimkar , Dave Gerlach , J Keerthy Cc: Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Santosh Shilimkar , linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1903; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=q5d8K34P4d8eJgHgXhElAdn8Ywho6XrfAYskz43O1Ow=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBmHU8own3DVGbDDPyww4s5hSdGSKy5e80b+VNF6 Ndomlg9oKqJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZh1PKAAKCRD6PaqMvJYe 9QP1D/4x8fjg/suseu5F8fchpgjbsg7LM0RyS44ePFszB4DYYxMZczYq58Ek9bP07U/sC4/bKCT XAOFf0nxkuC3VlnJGdW7Hrg6twZnfsjMZRqB6oQGJrM8etmEWwEwLA7wpfTLeb1tXGep6yjnc9i Z+xAdIF9gpjoe74gKCgaYNi4JNmgTdZ5xqBnqxIiltqWXxXLi4aREdQikwnOX+nGzj8J3LFEgmL QzGDcSy9VV2L0JtRXka90NyuCjdtwCE3LNyRvZlbM9tz/QhDfKc3nWdRus8wXWKI2tmS69FjwLX gcK2IYld6hgdMAVmiiR6qaSadkkYrZsJOfEtFEJEG2gFtoiRAiKaU2KaSe/DZi2Rcut5Cbw/mLh jwAgnzBQ6t59mrjgdq/fTjMAF43PKF9CT3qj1j9+5JVrFuv/gW7/ef2LNtyOFrMUlZ/+c1vNml6 VU8yrskYhF2a8hW5Fdkl0lMKRfleRooJVz7KRxI9QF+TI/xgqeO+gj7gv9+sQb3kCqWub2PxAvF xN2tlNApeDG3ZPpbDBULXgU1LrZzPZrFz3Gb/lLs0zU86PFMwyTxK3F06Kxhy69l1xXFdFqpFNN b3dUsaAhoDTzWk8uLRuLWJEHrvYv0SOIRlTqRHLEahGybOP1q4AjQcFyuwQPe6HsQEP2naU4gEy uSEg4ZQ36OoOXxA== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_090045_898369_BFB1F087 X-CRM114-Status: GOOD ( 13.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When the dts file has multiple referrers to a single PD (e.g. simple-framebuffer and dss nodes both point to the DSS power-domain) the ti-sci driver will create two power domains, both with the same ID, and that will cause problems as one of the power domains will hide the other one. Fix this checking if a PD with the ID has already been created, and only create a PD for new IDs. Fixes: efa5c01cd7ee ("soc: ti: ti_sci_pm_domains: switch to use multiple genpds instead of one") Signed-off-by: Tomi Valkeinen --- drivers/pmdomain/ti/ti_sci_pm_domains.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/pmdomain/ti/ti_sci_pm_domains.c b/drivers/pmdomain/ti/ti_sci_pm_domains.c index 9dddf227a3a6..1510d5ddae3d 100644 --- a/drivers/pmdomain/ti/ti_sci_pm_domains.c +++ b/drivers/pmdomain/ti/ti_sci_pm_domains.c @@ -114,6 +114,18 @@ static const struct of_device_id ti_sci_pm_domain_matches[] = { }; MODULE_DEVICE_TABLE(of, ti_sci_pm_domain_matches); +static bool ti_sci_pm_idx_exists(struct ti_sci_genpd_provider *pd_provider, u32 idx) +{ + struct ti_sci_pm_domain *pd; + + list_for_each_entry(pd, &pd_provider->pd_list, node) { + if (pd->idx == idx) + return true; + } + + return false; +} + static int ti_sci_pm_domain_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -149,8 +161,14 @@ static int ti_sci_pm_domain_probe(struct platform_device *pdev) break; if (args.args_count >= 1 && args.np == dev->of_node) { - if (args.args[0] > max_id) + if (args.args[0] > max_id) { max_id = args.args[0]; + } else { + if (ti_sci_pm_idx_exists(pd_provider, args.args[0])) { + index++; + continue; + } + } pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); if (!pd) { From patchwork Mon Apr 15 16:00:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13630244 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 64863C4345F for ; Mon, 15 Apr 2024 16:01:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=j389TzL5rx7y4jjFCbOzP4lAePyoi4C6fR9tmtD0GU8=; b=qgl7OewkP3JeHK Z1a2Sh1fwhLu+ORf4F5eu4KiEE4IkEt8qWTxTVnZk6Pfq56YArcjSaLWNyBVa+1VUlk8AoqdVMPX8 0TT8URC+mFL/hquIGGa2KR0918gnklT85go8BS7ZXZOD4QQYBUBY16S8bkQMg9L/ioNM8lRKRmeXY shIjtQg6jDfIgQmjs0HHeXlVcttnCf8uY1GNgO/Gb8v7wWdEIjOZMdIZgP+/DVUJUoo/YYm4+mBKf xgMGuaNoI+JtN6sO6v/7L3QeVkXkHbdWVTpuU+9Nk+uexGck1Vv4teDWhujAtjlRLIWeTTNuKeBTx 65Gq/NB+DuY2S2b5rysQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwOlW-00000008yFz-1Sar; Mon, 15 Apr 2024 16:01:06 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwOlC-00000008y3f-1ngZ for linux-arm-kernel@lists.infradead.org; Mon, 15 Apr 2024 16:00:54 +0000 Received: from [127.0.1.1] (91-154-34-181.elisa-laajakaista.fi [91.154.34.181]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7FBE47E4; Mon, 15 Apr 2024 17:59:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1713196798; bh=aHZGJy27O3UQ6ClAkPEPt8qvWQjPk8Laos6wipFyuwQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=b3c1sheswxT8ikKUTQ8Pt3VoSPGellzjUiMwcpuLIaFondbj1fOPgdwVO4HLqRbTM STb1eSDtoyF2ldLIzTI8/0v68iRRRVV5uhwIMX+jiqMNQLXbTEkMJNoTtsw8fuWjQ3 qQ3vJPwqPg5ql6Yu6RnUf03vgms3ruY6gDWI39ng= From: Tomi Valkeinen Date: Mon, 15 Apr 2024 19:00:24 +0300 Subject: [PATCH RFC 2/2] pmdomain: ti-sci: Support retaining PD boot time state MIME-Version: 1.0 Message-Id: <20240415-ti-sci-pd-v1-2-a0e56b8ad897@ideasonboard.com> References: <20240415-ti-sci-pd-v1-0-a0e56b8ad897@ideasonboard.com> In-Reply-To: <20240415-ti-sci-pd-v1-0-a0e56b8ad897@ideasonboard.com> To: Nishanth Menon , Tero Kristo , Santosh Shilimkar , Dave Gerlach , J Keerthy Cc: Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Santosh Shilimkar , linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4969; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=aHZGJy27O3UQ6ClAkPEPt8qvWQjPk8Laos6wipFyuwQ=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBmHU8o1BLaDv0NeuzDEaSDr1lMCCxM+xTAexGI4 03BPSBl+9aJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZh1PKAAKCRD6PaqMvJYe 9V50EACQR5lMfH0sU8J1ckdRURsik2Oe516ogzaF77WK53RcpQSizwEC4rmMXtr7c+EH0R99Fv0 qq5SWYcF/b/A/NNoFFFZUx7Nn3x2A3MkEBfz/3QxvXBtykhELggAT5S711Jc9nh7pFX7GAIow8A 57tB8EFNAbqANxYRSgrmJPk0wIEucMd3NRwQIsmc8RejszxiZM2wvZ2uGXOnRRprO0AGyujN64m 0mZE5JK6tTTf41uNH36KqO6qEHuV1V0Jm6Mb+awZKvIk2Xl5ZigAe8H5pmDeh91I4piH4AXKM3m 7MU+HEdDgjLuxrDdfJks4NmAQFQrDyvWO+3m1pH9G0PJY20ONJJ+O1BSThlpwmYf9uX+RseYb4w +XWJhLsb4B4qJohUzJDTUb3v9s//HyxOOUsFQ192QDU8hUBQUw2MAFThqD/kUf4WPoGTWHMHfLO mWfDc2kUScL1qhruStp7kkQUZC+EZr33mqPnchZXXsNdMPBjt4gwvROt/T1YBOIxv4ApVjTy87l QJs4mo0aMGMM/B2UMO8hZS+gTJoYC6DWzpHS1lntXvV2qKi0aXBkZn2ho//yOC6/zUItS9uN6J8 KI+P1Npv32mYqomT4gm0f0jJzOx85HociK9SHo2d41c0jw16CFJuFaHtI+P6eLaABRDM6OwUBDa r3XMNW7U5/A1Uuw== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_090046_661062_D67CD09B X-CRM114-Status: GOOD ( 28.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add a new flag, TI_SCI_PD_KEEP_BOOT_STATE, which can be set in the dts when referring to power domains. When this flag is set, the ti-sci driver will check if the PD is currently enabled in the HW, and if so, set the GENPD_FLAG_ALWAYS_ON flag so that the PD will stay enabled. The main issue I'm trying to solve here is this: If the Display Subsystem (DSS) has been enabled by the bootloader, the related PD has also been enabled in the HW. When the tidss driver probes, the driver framework will automatically enable the PD. While executing the probe function it is very common for the probe to return EPROBE_DEFER, and, in rarer cases, an actual error. When this happens (probe() returns an error), the driver framework will automatically disable the related PD. Powering off the PD while the DSS is enabled and displaying a picture will cause the DSS HW to enter a bad state, from which (afaik) it can't be woken up except with full power-cycle. Trying to access the DSS in this state (e.g. when retrying the probe) will usually cause the board to hang sooner or later. Even if we wouldn't have this board-hangs issue, it's nice to be able to keep the DSS PD enabled: we want to keep the DSS enabled when the bootloader has enabled the screen. If, instead, we disable the PD at the first EPROBE_DEFER, the screen will (probably) go black. Another option here would perhaps be to change the driver framework (drivers/base/platform.c) which attaches and detaches the PD, and make it somehow optional, allowing the driver the manage the PD. That option has two downsides: 1) the driver _has_ to manage the PD, which would rule out the use of simplefb and simpledrm, and 2) it would leave the PD in off state from Linux's perspective until a driver enables the PD, and that might mean that the PD gets actually disabled as part of normal system wide power management (disabling unused resources). Yet another option would be to do this outside the ti_sci_pm_domains driver: a piece of code that would somehow be ran after the ti_sci_pm_domains driver has probed (so that we have the PDs), but before tidss/simplefb/simpledrm probes. The problem here is the "somehow" part. Also, this would partly have the same issue 2) as mentioned above. TODO: If this approach is ok, sci-pm-domain.yaml needs to be extended. Also, it sounds a bit like the cell value is not a bit-mask, so maybe adding TI_SCI_PD_KEEP_BOOT_STATE flag this way is not fine. Signed-off-by: Tomi Valkeinen --- drivers/pmdomain/ti/ti_sci_pm_domains.c | 27 +++++++++++++++++++++++++-- include/dt-bindings/soc/ti,sci_pm_domain.h | 1 + 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/pmdomain/ti/ti_sci_pm_domains.c b/drivers/pmdomain/ti/ti_sci_pm_domains.c index 1510d5ddae3d..b71b390aaa39 100644 --- a/drivers/pmdomain/ti/ti_sci_pm_domains.c +++ b/drivers/pmdomain/ti/ti_sci_pm_domains.c @@ -103,7 +103,7 @@ static struct generic_pm_domain *ti_sci_pd_xlate( return ERR_PTR(-ENOENT); genpd_to_ti_sci_pd(genpd_data->domains[idx])->exclusive = - genpdspec->args[1]; + genpdspec->args[1] & TI_SCI_PD_EXCLUSIVE; return genpd_data->domains[idx]; } @@ -161,6 +161,8 @@ static int ti_sci_pm_domain_probe(struct platform_device *pdev) break; if (args.args_count >= 1 && args.np == dev->of_node) { + bool is_on = false; + if (args.args[0] > max_id) { max_id = args.args[0]; } else { @@ -189,7 +191,28 @@ static int ti_sci_pm_domain_probe(struct platform_device *pdev) pd->idx = args.args[0]; pd->parent = pd_provider; - pm_genpd_init(&pd->pd, NULL, true); + /* + * If TI_SCI_PD_KEEP_BOOT_STATE is set and the + * PD has been enabled by the bootloader, set + * the PD to GENPD_FLAG_ALWAYS_ON. This will + * make sure the PD stays enabled until a driver + * takes over and clears the GENPD_FLAG_ALWAYS_ON + * flag. + */ + if (args.args_count > 1 && + args.args[1] & TI_SCI_PD_KEEP_BOOT_STATE) { + /* + * We ignore any error here, and in case + * of error just assume the PD is off. + */ + pd_provider->ti_sci->ops.dev_ops.is_on(pd_provider->ti_sci, + pd->idx, NULL, &is_on); + + if (is_on) + pd->pd.flags |= GENPD_FLAG_ALWAYS_ON; + } + + pm_genpd_init(&pd->pd, NULL, !is_on); list_add(&pd->node, &pd_provider->pd_list); } diff --git a/include/dt-bindings/soc/ti,sci_pm_domain.h b/include/dt-bindings/soc/ti,sci_pm_domain.h index 8f2a7360b65e..af610208e3a3 100644 --- a/include/dt-bindings/soc/ti,sci_pm_domain.h +++ b/include/dt-bindings/soc/ti,sci_pm_domain.h @@ -3,6 +3,7 @@ #ifndef __DT_BINDINGS_TI_SCI_PM_DOMAIN_H #define __DT_BINDINGS_TI_SCI_PM_DOMAIN_H +#define TI_SCI_PD_KEEP_BOOT_STATE 2 #define TI_SCI_PD_EXCLUSIVE 1 #define TI_SCI_PD_SHARED 0