Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp2552249rdg; Mon, 14 Aug 2023 06:19:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYg5JwWwFrG6pZ4AV1qJ0fXaV6wmzcgJKFHk+rYAEhx75VzLdwCjqx4mnmkGH1WOq6gSEH X-Received: by 2002:a17:902:f54e:b0:1bd:ca80:6fe6 with SMTP id h14-20020a170902f54e00b001bdca806fe6mr5637661plf.41.1692019171388; Mon, 14 Aug 2023 06:19:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692019171; cv=none; d=google.com; s=arc-20160816; b=QUz5xtPBboWW38EGWmUG/FpvV5Ykrm1mgnccS/N1emn/HgYEkyOsrB4u83Ycae0lqL TCl3QPyxdE0DJOWqJEQNV/N/dfRiqVwpc0imXlSUbl2RiXLKASMj/HRVOF/Dou3jh6+V ngsodFMByuOGzoL/UTTo0Zc5m93Zx1eEEjf9d3xryRNVbp8obWyaN0LgNJN25iBOFzOn 6xapAp74vAY1U01yKp2HtZWamrfzbrbF9CqrToheyhtDaX3NoAq4+aSICThcXu7Q7b2y z4dOjtkVrtcU3kRN3bhkIQ+kxgsH9qroNxaLpSwQsiD/7boNICUADxKQl/MO98er2WpR GimA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=rs/cBEo3rqYRMTWU2EFQmctZrTV/0YAHrVzSp8vUhOQ=; fh=0nxdnq2/b0/V87nRDabxOIgJIX1vI28EKSELwdGL/0o=; b=FfgKOUV6LPG/6jyab2W/iKostDMThbWARhvi9z5HQTkImkLMuwa426zzfNEf8Y/NEF blRBN0SrAzgq9d5/xT7C0JnjDpp6xLgs3+9Cy9fBzU3UgsIFt4qrN1Q/uyTP6OSZxOni 8r/fPKGVQ7J9V0xADj/9dOU6VhVJtXcmIqTzFTja3UbyogQ9aYi3+Bn1oaKSc9Tf0peS TF7vmHCUt3xjNo3qOE8llsx4rFKVnUwKp285hlpNt97xwJJeVJrgKC4X8NCJnfli0mgX OXmb4oApW3YmpO+OFabQIGZs36EW7un3itH6zteu66Viwh66rjLdCLlcX8YPgf6c1+Lf RXgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HSErfQ1a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k5-20020a170902c40500b001bb0ba81053si8566861plk.50.2023.08.14.06.19.18; Mon, 14 Aug 2023 06:19:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HSErfQ1a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229689AbjHNMeV (ORCPT + 99 others); Mon, 14 Aug 2023 08:34:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230160AbjHNMeL (ORCPT ); Mon, 14 Aug 2023 08:34:11 -0400 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D4EBE4A for ; Mon, 14 Aug 2023 05:34:10 -0700 (PDT) Received: by mail-yb1-xb2f.google.com with SMTP id 3f1490d57ef6-d66f105634eso1807610276.1 for ; Mon, 14 Aug 2023 05:34:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692016449; x=1692621249; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=rs/cBEo3rqYRMTWU2EFQmctZrTV/0YAHrVzSp8vUhOQ=; b=HSErfQ1aapjonTuHNv6obvYcqjB9/RdfTci3m3c4EyJ9nw+uVuz4QMJLnGEr/0I/uk q76jsFT/eIURBhvjaIBy+MdCn+QWvn30Nesdxr7Et0URwnHqystKUvRR5Tb/IYbYDtLF oeyQ2VKUKtCE7tz2vSsy4lIpooP9i3ynWpbtdAcDiWPAediDatubMiKQXM8Kgu47uoV9 AGl8LzezWlXW/DTuvvPJFHnvh4J5X4V4p0uzETppCNqKhB3VfI2DxlRhaWfQJnim4J78 nxRDZF2Cok2UPAvDrfpZnzDOht+tcp6X1CiDLeqbgG9H7sAxA+zbi8vgr3UZepLToWiA t9pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692016449; x=1692621249; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rs/cBEo3rqYRMTWU2EFQmctZrTV/0YAHrVzSp8vUhOQ=; b=WiXLuhKH65NZj9DVC6pFC+sOBL93BaTuAOKSonRtQoqHI8PBs1fpfEkvEHcwKQCB+Q 8rufyQLjG3nxRuf08orsV9VMz2lfqmISeYcb3/ukubqm1uu5CGjqKn14x1wZwIlOJiWF q16tJP1A5LyxU0uh9/jAgeth6VTBh9idxBmOpu3f7TWQPO7GiYWbU5u8FJx7CFDclxoy BhTvYKUiTDjruvSo/GZXsVppevYy6c8HaggVRlBtODLxynxM5Wa61h65fsOhwssVGu68 MrM88yAuKX92r4IezNMP5GxCsA60nYPnIMpWnCAIcXuCKpQ96WDZk0+0PYgPFlsF0LxT Uxkg== X-Gm-Message-State: AOJu0YwvxmsWn3dmG21DDUrB7jSlZtZ+KSDr4ghbo4P8x4oriWC0fbqn lJfah3sIk1XRy1F9HRGKV10wpsHFVhr6eUcHckdaoQ== X-Received: by 2002:a05:6902:529:b0:d09:2cba:bcac with SMTP id y9-20020a056902052900b00d092cbabcacmr6521672ybs.65.1692016449625; Mon, 14 Aug 2023 05:34:09 -0700 (PDT) MIME-Version: 1.0 References: <20230814104127.1929-1-peng.fan@oss.nxp.com> <20230814104127.1929-8-peng.fan@oss.nxp.com> In-Reply-To: From: Ulf Hansson Date: Mon, 14 Aug 2023 14:33:33 +0200 Message-ID: Subject: Re: [PATCH V4 7/8] genpd: imx: scu-pd: add multi states support To: Peng Fan Cc: "Peng Fan (OSS)" , "shawnguo@kernel.org" , "s.hauer@pengutronix.de" , "kernel@pengutronix.de" , "festevam@gmail.com" , dl-linux-imx , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "linux-pm@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" 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_NONE,SPF_PASS autolearn=unavailable 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: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 14 Aug 2023 at 14:23, Ulf Hansson wrote: > > On Mon, 14 Aug 2023 at 13:52, Peng Fan wrote: > > > > > Subject: Re: [PATCH V4 7/8] genpd: imx: scu-pd: add multi states support > > > > > > On Mon, 14 Aug 2023 at 12:37, Peng Fan (OSS) > > > wrote: > > > > > > > > From: Peng Fan > > > > > > > > Add multi states support, this is to support devices could run in LP > > > > mode when runtime suspend, and OFF mode when system suspend. > > > > > > For my understanding, is there a functional problem to support OFF at > > > runtime suspend too? > > > > In OFF mode, the HW state is lost, so the clks that exported by this(Subsystem) > > genpd is lost. While in LF mode, no need handle clks recover. > > > > > > Such as subsystem LSIO has clks output, has GPIO, has LPUART. > > > > The clks are in drivers/clk/imx/clk-imx8qxp*, which relies on the scu pd. > > > > If scu-pd is off, the clks will lose state. > > Thanks for clarifying, much appreciated! So it sounds like it's the > clock provider(s) that has these requirements then. Can we let the > clock provider set a QoS latency constraint for its device that is > attached to the genpd then? To prevent the deeper OFF state? > > Another option would be to enable runtime PM support for the clock > provider (to manage the save/restore from runtime PM callbacks), but > whether that's feasible sounds like a separate discussion. > > > > > > > > > > > > > > Signed-off-by: Peng Fan > > > > --- > > > > drivers/genpd/imx/scu-pd.c | 48 > > > > ++++++++++++++++++++++++++++++++++++-- > > > > 1 file changed, 46 insertions(+), 2 deletions(-) > > > > > > > > diff --git a/drivers/genpd/imx/scu-pd.c b/drivers/genpd/imx/scu-pd.c > > > > index 2f693b67ddb4..30da101119eb 100644 > > > > --- a/drivers/genpd/imx/scu-pd.c > > > > +++ b/drivers/genpd/imx/scu-pd.c > > > > @@ -65,6 +65,12 @@ > > > > #include > > > > #include > > > > > > > > +enum { > > > > + PD_STATE_LP, > > > > + PD_STATE_OFF, > > > > + PD_STATE_MAX > > > > +}; > > > > + > > > > /* SCU Power Mode Protocol definition */ struct > > > > imx_sc_msg_req_set_resource_power_mode { > > > > struct imx_sc_rpc_msg hdr; > > > > @@ -368,7 +374,8 @@ static int imx_sc_pd_power(struct > > > generic_pm_domain *domain, bool power_on) > > > > hdr->size = 2; > > > > > > > > msg.resource = pd->rsrc; > > > > - msg.mode = power_on ? IMX_SC_PM_PW_MODE_ON : > > > IMX_SC_PM_PW_MODE_LP; > > > > + msg.mode = power_on ? IMX_SC_PM_PW_MODE_ON : pd- > > > >pd.state_idx ? > > > > + IMX_SC_PM_PW_MODE_OFF : IMX_SC_PM_PW_MODE_LP; > > > > > > > > /* keep uart console power on for no_console_suspend */ > > > > if (imx_con_rsrc == pd->rsrc && !console_suspend_enabled && > > > > !power_on) @@ -412,11 +419,33 @@ static struct generic_pm_domain > > > *imx_scu_pd_xlate(struct of_phandle_args *spec, > > > > return domain; > > > > } > > > > > > > > +static bool imx_sc_pd_suspend_ok(struct device *dev) { > > > > + /* Always true */ > > > > + return true; > > > > +} > > > > + > > > > +static bool imx_sc_pd_power_down_ok(struct dev_pm_domain *pd) { > > > > + struct generic_pm_domain *genpd = pd_to_genpd(pd); > > > > + > > > > + /* For runtime suspend, choose LP mode */ > > > > + genpd->state_idx = 0; > > > > + > > > > + return true; > > > > +} > > > > > > I am wondering if we couldn't use the simple_qos_governor here instead. In > > > principle it looks like we want a QoS latency constraint to be set during > > > runtime, to prevent the OFF state. > > > > LP mode indeed could save resume time, but the major problem is to avoid > > save/restore clks. > > Okay. So it still sounds like a QoS latency constraint (for the clock > provider) sounds like the correct thing to do. > > If/when the clock provider gets runtime PM support, we can remove the > QoS latency constraints. That should work, right? > > > > > > > During system wide suspend, the deepest state is always selected by genpd. > > > > > > > + > > > > +struct dev_power_governor imx_sc_pd_qos_governor = { > > > > + .suspend_ok = imx_sc_pd_suspend_ok, > > > > + .power_down_ok = imx_sc_pd_power_down_ok, }; > > > > + > > > > static struct imx_sc_pm_domain * > > > > imx_scu_add_pm_domain(struct device *dev, int idx, > > > > const struct imx_sc_pd_range *pd_ranges) { > > > > struct imx_sc_pm_domain *sc_pd; > > > > + struct genpd_power_state *states; > > > > bool is_off; > > > > int mode, ret; > > > > > > > > @@ -427,9 +456,22 @@ imx_scu_add_pm_domain(struct device *dev, int > > > idx, > > > > if (!sc_pd) > > > > return ERR_PTR(-ENOMEM); > > > > > > > > + states = devm_kcalloc(dev, PD_STATE_MAX, sizeof(*states), > > > GFP_KERNEL); > > > > + if (!states) { > > > > + devm_kfree(dev, sc_pd); > > > > + return ERR_PTR(-ENOMEM); > > > > + } > > > > + > > > > sc_pd->rsrc = pd_ranges->rsrc + idx; > > > > sc_pd->pd.power_off = imx_sc_pd_power_off; > > > > sc_pd->pd.power_on = imx_sc_pd_power_on; > > > > + states[PD_STATE_LP].power_off_latency_ns = 25000; > > > > + states[PD_STATE_LP].power_on_latency_ns = 25000; > > > > + states[PD_STATE_OFF].power_off_latency_ns = 2500000; > > > > + states[PD_STATE_OFF].power_on_latency_ns = 2500000; > > > > > > We should probably describe these in DT instead? The domain-idle-states > > > bindings allows us to do this. See > > > Documentation/devicetree/bindings/power/domain-idle-state.yaml. > > > > The scu-pd is a firmware function node, there is no sub-genpd node inside it. > > > > Just like scmi pd, there is no sub-genpd in it. > > Not sure I got your point. We don't need a sub-genpd node to describe > this. This is how it could look like: > > domain-idle-states { > domain_retention: domain-retention { > compatible = "domain-idle-state"; > entry-latency-us = <25>; > exit-latency-us = <25>; > }; > domain_off: domain-off { > compatible = "domain-idle-state"; > entry-latency-us = <2500>; > exit-latency-us = <2500>; > }; > }; > > power-controller { > compatible = "fsl,imx8qxp-scu-pd", "fsl,scu-pd"; > #power-domain-cells = <1>; > domain-idle-states = <&domain_retention>, <&domain_off>; > }; Ahh, now I think I got your point. The domain-idle-states need a corresponding power-domain specifier too, right? Can we do something along the lines of the below: domain-idle-states = <&domain_retention domain-id>, <&domain_off domain-id>; Anyway, I don't have a strong opinion about moving this to the DT, if you want to keep the values in the code, that works too. Kind regards Uffe