From: Ulf Hansson <ulf.hansson@linaro.org>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Saravana Kannan <saravanak@google.com>,
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>,
Hiago De Franco <hiago.franco@toradex.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Linux-Renesas <linux-renesas-soc@vger.kernel.org>
Subject: Re: [PATCH v3 00/24] pmdomain: Add generic ->sync_state() support to genpd
Date: Thu, 14 Aug 2025 17:49:48 +0200 [thread overview]
Message-ID: <CAPDyKFr-mVbGo62Wp+othcs+cWR6Wn9bz==ZB5hSpyKgkGtqHg@mail.gmail.com> (raw)
In-Reply-To: <CAMuHMdU7W+f3nZ_ckHOFsmmK6V9HzK0-fNtcu8kgjTSeU89AqQ@mail.gmail.com>
On Wed, 13 Aug 2025 at 13:58, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Ulf,
>
> On Tue, 12 Aug 2025 at 12:01, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > On Thu, 7 Aug 2025 at 11:38, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > > On Wed, 30 Jul 2025 at 12:29, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > > > On Wed, 30 Jul 2025 at 11:56, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > > > > On Wed, 9 Jul 2025 at 13:31, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > > > > > On Tue, 1 Jul 2025 at 13:47, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > > > > > > Changes in v3:
> > > > > > > - Added a couple of patches to adress problems on some Renesas
> > > > > > > platforms. Thanks Geert and Tomi for helping out!
> > > > > > > - Adressed a few comments from Saravanna and Konrad.
> > > > > > > - Added some tested-by tags.
> > > > > >
> > > > > > I decided it was time to give this a try, so I have queued this up for
> > > > > > v6.17 via the next branch at my pmdomain tree.
> > > > > >
> > > > > > If you encounter any issues, please let me know so I can help to fix them.
> > > > >
> > > > > Thanks for your series! Due to holidays, I only managed to test
> > > > > this very recently.
> > > > >
> > > > > Unfortunately I have an issue with unused PM Domains no longer being
> > > > > disabled on R-Car:
> > > > > - On R-Car Gen1/2/3, using rcar-sysc.c, unused PM Domains are never
> > > > > disabled.
> > > > > - On R-Car Gen4, using rcar-gen4-sysc.c, unused PM Domains are
> > > > > sometimes not disabled.
> > > > > At first, I noticed the IOMMU driver was not enabled in my config,
> > > > > and enabling it did fix the issue. However, after that I still
> > > > > encountered the issue in a different config that does have the
> > > > > IOMMU driver enabled...
> > > > >
> > > > > FTR, unused PM Domains are still disabled correctly on R/SH-Mobile
> > > > > (using rmobile-sysc.c) and on BeagleBone Black. Note that these use
> > > > > of_genpd_add_provider_simple(), while all R-Car drivers use
> > > > > of_genpd_add_provider_onecell(). Perhaps there is an issue with
> > > > > the latter? If you don't have a clue, I plan to do some more
> > > > > investigation later...
> > >
> > > of_genpd_add_provider_onecell() has:
> > >
> > > if (!dev)
> > > sync_state = true;
> > > else
> > > dev_set_drv_sync_state(dev, genpd_sync_state);
> > >
> > > for (i = 0; i < data->num_domains; i++) {
> > > ...
> > > if (sync_state && !genpd_is_no_sync_state(genpd)) {
> > > genpd->sync_state = GENPD_SYNC_STATE_ONECELL;
> > > device_set_node(&genpd->dev, fwnode);
> > > sync_state = false;
> > > ^^^^^^^^^^^^^^^^^^^
> > > }
> > > ...
> > > }
> > >
> > > As the R-Car SYSC drivers are not platform drivers, dev is NULL, and
> > > genpd->sync_state is set to GENPD_SYNC_STATE_ONECELL for the first PM
> > > Domain only. All other domains have the default value of sync_state
> > > (0 = GENPD_SYNC_STATE_OFF). Hence when genpd_provider_sync_state()
> > > is called later, it ignores all but the first domain.
> > > Apparently this is intentional, as of_genpd_sync_state() tries to
> > > power off all domains handled by the same controller anyway (see below)?
> >
> > Right, this is intentional and mainly because of how fw_devlink works.
> >
> > fw_devlink is limited to use only the first device - if multiple
> > devices share the same fwnode. In principle, we could have picked any
> > of the devices in the array of genpds here - and reached the same
> > result.
>
> OK, just like I already assumed...
>
> > > > > BTW, the "pending due to"-messages look weird to me.
> > > > > On R-Car M2-W (r8a7791.dtsi) I see e.g.:
> > > > >
> > > > > genpd_provider ca15-cpu0: sync_state() pending due to e6020000.watchdog
> > > > > renesas-cpg-mssr e6150000.clock-controller: sync_state() pending
> > > > > due to e6020000.watchdog
> > > > >
> > > > > ca15-cpu0 is the PM Domain holding the first CPU core, while
> > > > > the watchdog resides in the always-on Clock Domain, and uses the
> > > > > clock-controller for PM_CLK handling.
> > >
> > > Unfortunately the first PM Domain is "ca15-cpu0", which is blocked on
> > > these bogus pending states, and no PM Domain is powered off.
> >
> > I see, thanks for the details. I am looking closer at this.
> >
> > In any case, this is the main issue, as it prevents the ->sync_state()
> > callback to be called. Hence the "genpd->stay_on" will also *not* be
> > cleared for any of the genpd's for the genpd-provider.
>
> I was under the impression there is a time-out, after which the
> .sync_state() callback would be called anyway, just like for probe
> deferral due to missing optional providers like DMACs and IOMMUs.
> Apparently that is not the case?
The behaviour is configurable, so it depends. The current default
behaviour does *not* enforce the ->sync_state() callbacks to be
called, even after a time-out.
You may set CONFIG_FW_DEVLINK_SYNC_STATE_TIMEOUT to achieve the above
behavior or use the fw_devlink command line parameters to change it.
Like setting "fw_devlink.sync_state=timeout".
I guess it can be debated what the default behaviour should be.
Perhaps we should even allow the default behaviour to be dynamically
tweaked on a per provider device/driver basis?
>
> > > If I remove the "sync_state = false" above, genpd_provider_sync_state()
> > > considers all domains, and does power down all unused domains (even
> > > multiple times, as expected).
> >
> > I think those are getting called because with the change above, there
> > is no device_link being tracked. As stated above, fw_devlink is
> > limited to use only one device - if multiple devices share the same
> > fwnode.
>
> Indeed.
>
> > In other words, the ->sync_state() callbacks are called even if the
> > corresponding consumer devices have not been probed yet.
>
> Hence shouldn't there be a timeout, as the kernel may not even have
> a driver for one or more consumer devices?
See above.
>
> > > Upon closer look, all "pending due to" messages I see claim that the
> > > first (index 0) PM Domain is pending on some devices, while all of
> > > these devices are part of a different domain (usually the always-on
> > > domain, which is always the last (32 or 64) on R-Car).
> > >
> > > So I think there are two issues:
> > > 1. Devices are not attributed to the correct PM Domain using
> > > fw_devlink sync_state,
> > > 2. One PM Domain of a multi-domain controller being blocked should
> > > not block all other domains handled by the same controller.
> >
> > Right, that's a current limitation with fw_devlink. To cope with this,
> > it's possible to enforce the ->sync_state() callback to be invoked
> > from user-space (timeout or explicitly) for a device.
> >
> > Another option would be to allow an opt-out behavior for some genpd's
> > that are powered-on at initialization. Something along the lines of
> > the below.
> >
> > From: Ulf Hansson <ulf.hansson@linaro.org>
> > Date: Tue, 29 Jul 2025 14:27:22 +0200
> > Subject: [PATCH] pmdomain: core: Allow powered-on PM domains to be powered-off
> > during boot
>
> [...]
>
> I gave this a try (i.e. "| GENPD_FLAG_NO_STAY_ON" in rcar-sysc.c), but
> this doesn't make any difference. I assume this would only work when
> actively calling genpd_power_off() (i.e. not from of_genpd_sync_state()
> or genpd_provider_sync_state())?
Right. Thanks for testing!
So, we may need to restore some part of the genpd_power_off_unused()
when CONFIG_PM_GENERIC_DOMAINS_OF is set. Without clearing
"genpd->stay_on".
I can extend the patch, if you think it would make sense for you?
Kind regards
Uffe
next prev parent reply other threads:[~2025-08-14 15:50 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-01 11:47 [PATCH v3 00/24] pmdomain: Add generic ->sync_state() support to genpd Ulf Hansson
2025-07-01 11:47 ` [PATCH v3 01/24] pmdomain: renesas: rcar-sysc: Add genpd OF provider at postcore_initcall Ulf Hansson
2025-07-01 11:47 ` [PATCH v3 02/24] pmdomain: renesas: rmobile-sysc: Move init to postcore_initcall Ulf Hansson
2025-07-01 11:47 ` [PATCH v3 03/24] pmdomain: renesas: rcar-gen4-sysc: " Ulf Hansson
2025-07-01 11:47 ` [PATCH v3 04/24] pmdomain: core: Prevent registering devices before the bus Ulf Hansson
2025-07-01 11:47 ` [PATCH v3 05/24] pmdomain: core: Add a bus and a driver for genpd providers Ulf Hansson
2025-07-01 11:47 ` [PATCH v3 06/24] pmdomain: core: Add the genpd->dev to the genpd provider bus Ulf Hansson
2025-07-01 11:47 ` [PATCH v3 07/24] pmdomain: core: Export a common ->sync_state() helper for genpd providers Ulf Hansson
2025-07-01 11:47 ` [PATCH v3 08/24] pmdomain: core: Prepare to add the common ->sync_state() support Ulf Hansson
2025-07-01 11:47 ` [PATCH v3 09/24] soc/tegra: pmc: Opt-out from genpd's " Ulf Hansson
2025-07-01 11:47 ` [PATCH v3 10/24] cpuidle: psci: " Ulf Hansson
2025-07-01 11:47 ` [PATCH v3 11/24] cpuidle: riscv-sbi: " Ulf Hansson
2025-07-04 10:14 ` Rahul Pathak
2025-07-07 9:36 ` Anup Patel
2025-08-10 21:12 ` patchwork-bot+linux-riscv
2025-07-01 11:47 ` [PATCH v3 12/24] pmdomain: qcom: rpmpd: Use of_genpd_sync_state() Ulf Hansson
2025-07-01 11:47 ` [PATCH v3 13/24] pmdomain: qcom: rpmhpd: " Ulf Hansson
2025-07-01 11:47 ` [PATCH v3 14/24] firmware/pmdomain: xilinx: Move ->sync_state() support to firmware driver Ulf Hansson
2025-07-01 11:47 ` [PATCH v3 15/24] firmware: xilinx: Don't share zynqmp_pm_init_finalize() Ulf Hansson
2025-07-01 11:47 ` [PATCH v3 16/24] firmware: xilinx: Use of_genpd_sync_state() Ulf Hansson
2025-07-01 11:47 ` [PATCH v3 17/24] driver core: Export get_dev_from_fwnode() Ulf Hansson
2025-07-02 7:34 ` Greg Kroah-Hartman
2025-07-02 19:26 ` Danilo Krummrich
2025-07-02 21:34 ` Saravana Kannan
2025-07-02 21:55 ` Danilo Krummrich
2025-07-01 11:47 ` [PATCH v3 18/24] pmdomain: core: Add common ->sync_state() support for genpd providers Ulf Hansson
2025-07-01 11:47 ` [PATCH v3 19/24] driver core: Add dev_set_drv_sync_state() Ulf Hansson
2025-07-01 11:47 ` [PATCH v3 20/24] pmdomain: core: Default to use of_genpd_sync_state() for genpd providers Ulf Hansson
2025-07-31 15:07 ` Jon Hunter
2025-08-11 12:11 ` Ulf Hansson
2025-09-03 12:33 ` Jon Hunter
2025-07-01 11:47 ` [PATCH v3 21/24] pmdomain: core: Leave powered-on genpds on until late_initcall_sync Ulf Hansson
[not found] ` <CGME20250710122654eucas1p20f1179a9ff22d562d89252f924d34dae@eucas1p2.samsung.com>
2025-07-10 12:26 ` Marek Szyprowski
2025-07-10 14:54 ` Ulf Hansson
2025-07-15 10:28 ` Jon Hunter
2025-07-15 11:32 ` Ulf Hansson
2025-07-15 11:34 ` Ulf Hansson
2025-07-31 12:53 ` Jon Hunter
2025-07-01 11:47 ` [PATCH v3 22/24] pmdomain: core: Leave powered-on genpds on until sync_state Ulf Hansson
2025-07-01 11:47 ` [PATCH v3 23/24] cpuidle: psci: Drop redundant sync_state support Ulf Hansson
2025-07-01 11:47 ` [PATCH v3 24/24] cpuidle: riscv-sbi: " Ulf Hansson
2025-07-04 10:39 ` Rahul Pathak
2025-07-07 9:38 ` Anup Patel
2025-07-09 11:30 ` [PATCH v3 00/24] pmdomain: Add generic ->sync_state() support to genpd Ulf Hansson
2025-07-15 8:50 ` Danilo Krummrich
2025-07-16 12:46 ` Ulf Hansson
2025-07-16 13:08 ` Danilo Krummrich
2025-07-30 9:56 ` Geert Uytterhoeven
2025-07-30 10:29 ` Ulf Hansson
2025-08-07 9:38 ` Geert Uytterhoeven
2025-08-12 10:00 ` Ulf Hansson
2025-08-13 11:58 ` Geert Uytterhoeven
2025-08-14 15:49 ` Ulf Hansson [this message]
2025-08-13 12:04 ` Geert Uytterhoeven
2025-09-03 7:39 ` Sebin Francis
2025-09-03 10:33 ` Ulf Hansson
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='CAPDyKFr-mVbGo62Wp+othcs+cWR6Wn9bz==ZB5hSpyKgkGtqHg@mail.gmail.com' \
--to=ulf.hansson@linaro.org \
--cc=abel.vesa@linaro.org \
--cc=andersson@kernel.org \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=hiago.franco@toradex.com \
--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=linux-renesas-soc@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=saravanak@google.com \
--cc=sboyd@kernel.org \
--cc=thierry.reding@gmail.com \
--cc=tomi.valkeinen@ideasonboard.com \
/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).