Re: [PATCH v3 20/24] pmdomain: core: Default to use of_genpd_sync_state() for genpd providers
From: Ulf Hansson <hidden>
Date: 2025-08-11 12:11:39
Also in:
linux-pm, linux-tegra, lkml
On Thu, 31 Jul 2025 at 17:07, Jon Hunter [off-list ref] wrote:
Hi Ulf, On 01/07/2025 12:47, Ulf Hansson wrote:quoted
Unless the typical platform driver that act as genpd provider, has its own ->sync_state() callback implemented let's default to use of_genpd_sync_state(). More precisely, while adding a genpd OF provider let's assign the ->sync_state() callback, in case the fwnode has a device and its driver doesn't have the ->sync_state() set already. In this way the typical platform driver doesn't need to assign ->sync_state(), unless it has some additional things to manage beyond genpds. Suggested-by: Saravana Kannan <redacted> Tested-by: Hiago De Franco <redacted> # Colibri iMX8X Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> # TI AM62A,Xilinx ZynqMP ZCU106 Signed-off-by: Ulf Hansson <redacted> --- drivers/pmdomain/core.c | 9 +++++++++ 1 file changed, 9 insertions(+)diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c index ca47f91b9e91..5cef6de60c72 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c@@ -2600,6 +2600,11 @@ static bool genpd_present(const struct generic_pm_domain *genpd) return ret; } +static void genpd_sync_state(struct device *dev) +{ + return of_genpd_sync_state(dev->of_node); +} + /** * of_genpd_add_provider_simple() - Register a simple PM domain provider * @np: Device node pointer associated with the PM domain provider.@@ -2628,6 +2633,8 @@ int of_genpd_add_provider_simple(struct device_node *np, if (!dev && !genpd_is_no_sync_state(genpd)) { genpd->sync_state = GENPD_SYNC_STATE_SIMPLE; device_set_node(&genpd->dev, fwnode); + } else { + dev_set_drv_sync_state(dev, genpd_sync_state); } put_device(dev);@@ -2700,6 +2707,8 @@ int of_genpd_add_provider_onecell(struct device_node *np, dev = get_dev_from_fwnode(fwnode); if (!dev) sync_state = true; + else + dev_set_drv_sync_state(dev, genpd_sync_state); put_device(dev);Following this change I am seeing the following warning on our Tegra194 devices ... WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 17000000.gpu WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 3960000.cec WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 15380000.nvjpg WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 154c0000.nvenc WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 15a80000.nvenc Per your change [0], the 'GENPD_FLAG_NO_SYNC_STATE' is set for Tegra and so should Tegra be using of_genpd_sync_state() by default?
This is a different power-domain provider (bpmp) in drivers/firmware/tegra/bpmp.c and drivers/pmdomain/tegra/powergate-bpmp.c. For the bpmp we don't need GENPD_FLAG_NO_SYNC_STATE, as the power-domain provider is described along with the "nvidia,tegra186-bpmp" compatible string. In the other case (drivers/soc/tegra/pmc.c) the "core-domain" and "powergates" are described through child-nodes, while ->sync_state() is managed by the parent-device-node. In the bpmp case there is no ->sync_state() callback assigned, which means genpd decides to assign a default one. The reason for the warnings above is because we are still waiting for those devices to be probed, hence the ->sync_state() callback is still waiting to be invoked. Enforcing ->sync_state() callback to be invoked can be done via user-space if that is needed. Did that make sense?
Thanks Jon [0] https://lore.kernel.org/all/20250701114733.636510-10-ulf.hansson@linaro.org/ (local) -- nvpublic
Kind regards Uffe