From: Saravana Kannan <saravanak@google.com>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Stephen Boyd <sboyd@kernel.org>,
linux-pm@vger.kernel.org,
"Rafael J . Wysocki" <rafael@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Michael Grzeschik <m.grzeschik@pengutronix.de>,
Bjorn Andersson <andersson@kernel.org>,
Abel Vesa <abel.vesa@linaro.org>,
Peng Fan <peng.fan@oss.nxp.com>,
Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
Johan Hovold <johan@kernel.org>,
Maulik Shah <maulik.shah@oss.qualcomm.com>,
Michal Simek <michal.simek@amd.com>,
Konrad Dybcio <konradybcio@kernel.org>,
Thierry Reding <thierry.reding@gmail.com>,
Jonathan Hunter <jonathanh@nvidia.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 02/21] pmdomain: core: Add a bus and a driver for genpd providers
Date: Mon, 2 Jun 2025 17:23:19 -0700 [thread overview]
Message-ID: <CAGETcx-hsKb_BDPLuSM3A_ac0x6Z4NOq2pCmjKKJHTYbYZPwcA@mail.gmail.com> (raw)
In-Reply-To: <20250523134025.75130-3-ulf.hansson@linaro.org>
On Fri, May 23, 2025 at 6:40 AM Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> When we create a genpd via pm_genpd_init() we are initializing a
> corresponding struct device for it, but we don't add the device to any
> bus_type. It has not really been needed as the device is used as cookie to
> help us manage OPP tables.
>
> However, to prepare to make better use of the device let's add a new genpd
> provider bus_type and a corresponding genpd provider driver. Subsequent
> changes will make use of this.
>
> Suggested-by: Saravana Kannan <saravanak@google.com>
> Reviewed-by: Abel Vesa <abel.vesa@linaro.org>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
> drivers/pmdomain/core.c | 89 ++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 88 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
> index 9a66b728fbbf..da515350c65b 100644
> --- a/drivers/pmdomain/core.c
> +++ b/drivers/pmdomain/core.c
> @@ -27,6 +27,11 @@
> /* Provides a unique ID for each genpd device */
> static DEFINE_IDA(genpd_ida);
>
> +/* The parent for genpd_provider devices. */
> +static struct device genpd_provider_bus = {
> + .init_name = "genpd_provider",
> +};
> +
> #define GENPD_RETRY_MAX_MS 250 /* Approximate */
>
> #define GENPD_DEV_CALLBACK(genpd, type, callback, dev) \
> @@ -44,6 +49,14 @@ static DEFINE_IDA(genpd_ida);
> static LIST_HEAD(gpd_list);
> static DEFINE_MUTEX(gpd_list_lock);
>
> +#define to_genpd_provider_drv(d) container_of(d, struct genpd_provider_drv, drv)
> +
> +struct genpd_provider_drv {
> + struct device_driver drv;
> + int (*probe)(struct device *dev);
> + void (*remove)(struct device *dev);
> +};
> +
> struct genpd_lock_ops {
> void (*lock)(struct generic_pm_domain *genpd);
> void (*lock_nested)(struct generic_pm_domain *genpd, int depth);
> @@ -2225,6 +2238,26 @@ static int genpd_set_default_power_state(struct generic_pm_domain *genpd)
> return 0;
> }
>
> +static int genpd_provider_bus_probe(struct device *dev)
> +{
> + struct genpd_provider_drv *drv = to_genpd_provider_drv(dev->driver);
> +
> + return drv->probe(dev);
> +}
> +
> +static void genpd_provider_bus_remove(struct device *dev)
> +{
> + struct genpd_provider_drv *drv = to_genpd_provider_drv(dev->driver);
> +
> + drv->remove(dev);
> +}
Not sure if I'm missing some corner case you found out, but you don't
need these stubs just to call the drv ops. Driver core does it anyway
if the bus probe/remove functions are missing.
> +
> +static const struct bus_type genpd_provider_bus_type = {
> + .name = "genpd_provider",
> + .probe = genpd_provider_bus_probe,
> + .remove = genpd_provider_bus_remove,
> +};
> +
> static void genpd_provider_release(struct device *dev)
> {
> /* nothing to be done here */
> @@ -2262,6 +2295,8 @@ static int genpd_alloc_data(struct generic_pm_domain *genpd)
> genpd->gd = gd;
> device_initialize(&genpd->dev);
> genpd->dev.release = genpd_provider_release;
> + genpd->dev.bus = &genpd_provider_bus_type;
> + genpd->dev.parent = &genpd_provider_bus;
>
> if (!genpd_is_dev_name_fw(genpd)) {
> dev_set_name(&genpd->dev, "%s", genpd->name);
> @@ -3355,9 +3390,61 @@ int of_genpd_parse_idle_states(struct device_node *dn,
> }
> EXPORT_SYMBOL_GPL(of_genpd_parse_idle_states);
>
> +static int genpd_provider_probe(struct device *dev)
> +{
> + return 0;
> +}
> +
> +static void genpd_provider_remove(struct device *dev)
> +{
> +}
Same might apply here.
-Saravana
> +
> +static void genpd_provider_sync_state(struct device *dev)
> +{
> +}
> +
> +static struct genpd_provider_drv genpd_provider_drv = {
> + .drv = {
> + .name = "genpd_provider",
> + .bus = &genpd_provider_bus_type,
> + .sync_state = genpd_provider_sync_state,
> + .suppress_bind_attrs = true,
> + },
> + .probe = genpd_provider_probe,
> + .remove = genpd_provider_remove,
> +};
> +
> static int __init genpd_bus_init(void)
> {
> - return bus_register(&genpd_bus_type);
> + int ret;
> +
> + ret = device_register(&genpd_provider_bus);
> + if (ret) {
> + put_device(&genpd_provider_bus);
> + return ret;
> + }
> +
> + ret = bus_register(&genpd_provider_bus_type);
> + if (ret)
> + goto err_dev;
> +
> + ret = bus_register(&genpd_bus_type);
> + if (ret)
> + goto err_prov_bus;
> +
> + ret = driver_register(&genpd_provider_drv.drv);
> + if (ret)
> + goto err_bus;
> +
> + return 0;
> +
> +err_bus:
> + bus_unregister(&genpd_bus_type);
> +err_prov_bus:
> + bus_unregister(&genpd_provider_bus_type);
> +err_dev:
> + device_unregister(&genpd_provider_bus);
> + return ret;
> }
> core_initcall(genpd_bus_init);
>
> --
> 2.43.0
>
next prev parent reply other threads:[~2025-06-03 0:23 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-23 13:39 [PATCH v2 00/21] pmdomain: Add generic ->sync_state() support to genpd Ulf Hansson
2025-05-23 13:39 ` [PATCH v2 01/21] pmdomain: core: Use of_fwnode_handle() Ulf Hansson
2025-06-11 6:07 ` Dhruva Gole
2025-05-23 13:39 ` [PATCH v2 02/21] pmdomain: core: Add a bus and a driver for genpd providers Ulf Hansson
2025-06-03 0:23 ` Saravana Kannan [this message]
2025-06-03 10:28 ` Ulf Hansson
2025-05-23 13:40 ` [PATCH v2 03/21] pmdomain: core: Add the genpd->dev to the genpd provider bus Ulf Hansson
2025-05-23 13:40 ` [PATCH v2 04/21] pmdomain: core: Export a common ->sync_state() helper for genpd providers Ulf Hansson
2025-05-23 13:40 ` [PATCH v2 05/21] pmdomain: core: Prepare to add the common ->sync_state() support Ulf Hansson
2025-05-23 13:40 ` [PATCH v2 06/21] soc/tegra: pmc: Opt-out from genpd's " Ulf Hansson
2025-05-23 13:40 ` [PATCH v2 07/21] cpuidle: psci: " Ulf Hansson
2025-05-23 13:40 ` [PATCH v2 08/21] cpuidle: riscv-sbi: " Ulf Hansson
2025-08-10 21:12 ` patchwork-bot+linux-riscv
2025-05-23 13:40 ` [PATCH v2 09/21] pmdomain: qcom: rpmhpd: Use of_genpd_sync_state() Ulf Hansson
2025-05-23 19:42 ` Konrad Dybcio
2025-05-26 10:12 ` Ulf Hansson
2025-05-23 13:40 ` [PATCH v2 10/21] " Ulf Hansson
2025-05-23 13:40 ` [PATCH v2 11/21] firmware/pmdomain: xilinx: Move ->sync_state() support to firmware driver Ulf Hansson
2025-05-23 13:40 ` [PATCH v2 12/21] firmware: xilinx: Don't share zynqmp_pm_init_finalize() Ulf Hansson
2025-05-23 13:40 ` [PATCH v2 13/21] firmware: xilinx: Use of_genpd_sync_state() Ulf Hansson
2025-05-23 13:40 ` [PATCH v2 14/21] driver core: Export get_dev_from_fwnode() Ulf Hansson
2025-05-23 13:40 ` [PATCH v2 15/21] pmdomain: core: Add common ->sync_state() support for genpd providers Ulf Hansson
2025-05-23 13:40 ` [PATCH v2 16/21] driver core: Add dev_set_drv_sync_state() Ulf Hansson
2025-05-23 13:40 ` [PATCH v2 17/21] pmdomain: core: Default to use of_genpd_sync_state() for genpd providers Ulf Hansson
2025-05-23 13:40 ` [PATCH v2 18/21] pmdomain: core: Leave powered-on genpds on until late_initcall_sync Ulf Hansson
2025-05-23 13:40 ` [PATCH v2 19/21] pmdomain: core: Leave powered-on genpds on until sync_state Ulf Hansson
2025-05-23 13:40 ` [PATCH v2 20/21] cpuidle: psci: Drop redundant sync_state support Ulf Hansson
2025-05-23 13:40 ` [PATCH v2 21/21] cpuidle: riscv-sbi: " Ulf Hansson
2025-06-03 14:20 ` [PATCH v2 00/21] pmdomain: Add generic ->sync_state() support to genpd Hiago De Franco
2025-06-12 6:09 ` Tomi Valkeinen
2025-06-13 10:33 ` Tomi Valkeinen
2025-06-19 11:40 ` Ulf Hansson
2025-06-23 14:20 ` Ulf Hansson
2025-06-23 15:06 ` Geert Uytterhoeven
2025-06-24 12:10 ` Geert Uytterhoeven
2025-06-24 15:29 ` Ulf Hansson
2025-06-30 9:31 ` Geert Uytterhoeven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAGETcx-hsKb_BDPLuSM3A_ac0x6Z4NOq2pCmjKKJHTYbYZPwcA@mail.gmail.com \
--to=saravanak@google.com \
--cc=abel.vesa@linaro.org \
--cc=andersson@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=jonathanh@nvidia.com \
--cc=konradybcio@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=m.grzeschik@pengutronix.de \
--cc=maulik.shah@oss.qualcomm.com \
--cc=michal.simek@amd.com \
--cc=peng.fan@oss.nxp.com \
--cc=rafael@kernel.org \
--cc=sboyd@kernel.org \
--cc=thierry.reding@gmail.com \
--cc=tomi.valkeinen@ideasonboard.com \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).