[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAAhSdy3jKY_48bFCSyzCcJ8kW=aERNEjBRz=5GEasefuN3Bydw@mail.gmail.com>
Date: Wed, 9 Jun 2021 16:06:51 +0530
From: Anup Patel <anup@...infault.org>
To: Samuel Holland <samuel@...lland.org>
Cc: Anup Patel <anup.patel@....com>,
Sandeep Tripathy <milun.tripathy@...il.com>,
Atish Patra <atish.patra@....com>,
Alistair Francis <Alistair.Francis@....com>,
Liush <liush@...winnertech.com>,
DTML <devicetree@...r.kernel.org>,
linux-riscv <linux-riscv@...ts.infradead.org>,
"linux-kernel@...r.kernel.org List" <linux-kernel@...r.kernel.org>,
"open list:THERMAL" <linux-pm@...r.kernel.org>,
linux-arm-kernel <linux-arm-kernel@...ts.infradead.org>,
Palmer Dabbelt <palmer@...belt.com>,
Palmer Dabbelt <palmerdabbelt@...gle.com>,
Ulf Hansson <ulf.hansson@...aro.org>,
Rob Herring <robh+dt@...nel.org>,
Albert Ou <aou@...s.berkeley.edu>,
"Rafael J . Wysocki" <rjw@...ysocki.net>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
Paul Walmsley <paul.walmsley@...ive.com>,
Pavel Machek <pavel@....cz>
Subject: Re: [PATCH v5 6/8] cpuidle: Add RISC-V SBI CPU idle driver
On Mon, Jun 7, 2021 at 12:09 AM Samuel Holland <samuel@...lland.org> wrote:
>
> On 6/2/21 6:23 AM, Anup Patel wrote:
> > The RISC-V SBI HSM extension provides HSM suspend call which can
> > be used by Linux RISC-V to enter platform specific low-power state.
> >
> > This patch adds a CPU idle driver based on RISC-V SBI calls which
> > will populate idle states from device tree and use SBI calls to
> > entry these idle states.
> >
> > Signed-off-by: Anup Patel <anup.patel@....com>
> > ---
> > MAINTAINERS | 7 +
> > drivers/cpuidle/Kconfig | 5 +
> > drivers/cpuidle/Kconfig.riscv | 15 +
> > drivers/cpuidle/Makefile | 4 +
> > drivers/cpuidle/cpuidle-sbi.c | 626 ++++++++++++++++++++++++++++++++++
> > 5 files changed, 657 insertions(+)
> > create mode 100644 drivers/cpuidle/Kconfig.riscv
> > create mode 100644 drivers/cpuidle/cpuidle-sbi.c
> >
> > ...
> > diff --git a/drivers/cpuidle/cpuidle-sbi.c b/drivers/cpuidle/cpuidle-sbi.c
> > new file mode 100644
> > index 000000000000..f743684d07de
> > --- /dev/null
> > +++ b/drivers/cpuidle/cpuidle-sbi.c
> > @@ -0,0 +1,626 @@
> > ...
> > + /* Initialize idle states from DT. */
> > + ret = sbi_cpuidle_dt_init_states(dev, drv, cpu, state_count);
> > + if (ret) {
> > + pr_err("HART%ld: failed to init idle states\n",
> > + cpuid_to_hartid_map(cpu));
> > + return ret;
> > + }
> > +
> > + ret = cpuidle_register(drv, NULL);
> > + if (ret)
> > + goto deinit;
> > +
> > + cpuidle_cooling_register(drv);
> > +
> > + return 0;
> > +deinit:
> > + sbi_cpuidle_deinit_cpu(cpu);
> > + return ret;
> > +}
> > +
> > +static int sbi_cpuidle_pd_power_off(struct generic_pm_domain *pd)
>
> This function should be moved inside the CONFIG_DT_IDLE_GENPD block
> below. Otherwise it is defined but unused.
Indeed, sbi_cpuidle_pd_power_off() should be under
"#ifdef CONFIG_DT_IDLE_GENPD". I will update in the
next patch revision.
>
> > +{
> > + struct genpd_power_state *state = &pd->states[pd->state_idx];
> > + u32 *pd_state;
> > +
> > + if (!state->data)
> > + return 0;
> > +
> > + if (!sbi_cpuidle_pd_allow_domain_state)
> > + return -EBUSY;
> > +
> > + /* OSI mode is enabled, set the corresponding domain state. */
> > + pd_state = state->data;
> > + sbi_set_domain_state(*pd_state);
> > +
> > + return 0;
> > +}
> > +
> > +static void sbi_cpuidle_domain_sync_state(struct device *dev)
> > +{
> > + /*
> > + * All devices have now been attached/probed to the PM domain
> > + * topology, hence it's fine to allow domain states to be picked.
> > + */
> > + sbi_cpuidle_pd_allow_domain_state = true;
> > +}
> > +
> > +#ifdef CONFIG_DT_IDLE_GENPD
> > +
> > +struct sbi_pd_provider {
> > + struct list_head link;
> > + struct device_node *node;
> > +};
> > +
> > +static LIST_HEAD(sbi_pd_providers);
> > +
> > +static int sbi_pd_init(struct device_node *np)
> > +{
> > + struct generic_pm_domain *pd;
> > + struct sbi_pd_provider *pd_provider;
> > + struct dev_power_governor *pd_gov;
> > + int ret = -ENOMEM, state_count = 0;
> > +
> > + pd = dt_idle_pd_alloc(np, sbi_dt_parse_state_node);
> > + if (!pd)
> > + goto out;
> > ...
Regards,
Anup
Powered by blists - more mailing lists