From: Maxime Ripard <mripard@kernel.org>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Michal Wilczynski <m.wilczynski@samsung.com>,
Stephen Boyd <sboyd@kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
Pavel Machek <pavel@kernel.org>, Drew Fustini <drew@pdp7.com>,
Guo Ren <guoren@kernel.org>, Fu Wei <wefu@redhat.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
Frank Binns <frank.binns@imgtec.com>,
Matt Coster <matt.coster@imgtec.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>,
m.szyprowski@samsung.com, linux-kernel@vger.kernel.org,
linux-pm@vger.kernel.org, linux-riscv@lists.infradead.org,
devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 1/4] PM: device: Introduce platform_resources_managed flag
Date: Fri, 25 Apr 2025 09:09:15 +0200 [thread overview]
Message-ID: <20250425-lumpy-marmot-of-popularity-cdbbcd@houat> (raw)
In-Reply-To: <CAPDyKFqND2JrH8nLUzAqwWgHkwia6M9XOJoY6AqxtR0t120JUA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 6057 bytes --]
Hi,
On Thu, Apr 24, 2025 at 06:51:00PM +0200, Ulf Hansson wrote:
> On Thu, 17 Apr 2025 at 18:19, Michal Wilczynski
> <m.wilczynski@samsung.com> wrote:
> > On 4/16/25 16:48, Rafael J. Wysocki wrote:
> > > On Wed, Apr 16, 2025 at 3:32 PM Michal Wilczynski
> > > <m.wilczynski@samsung.com> wrote:
> > >>
> > >> On 4/15/25 18:42, Rafael J. Wysocki wrote:
> > >>> On Mon, Apr 14, 2025 at 8:53 PM Michal Wilczynski
> > >>> <m.wilczynski@samsung.com> wrote:
> > >>>>
> > >>>> Introduce a new dev_pm_info flag - platform_resources_managed, to
> > >>>> indicate whether platform PM resources such as clocks or resets are
> > >>>> managed externally (e.g. by a generic power domain driver) instead of
> > >>>> directly by the consumer device driver.
> > >>>
> > >>> I think that this is genpd-specific and so I don't think it belongs in
> > >>> struct dev_pm_info.
> > >>>
> > >>> There is dev->power.subsys_data->domain_data, why not use it for this?
> > >>
> > >> Hi Rafael,
> > >>
> > >> Thanks for the feedback.
> > >>
> > >> You're right — this behavior is specific to genpd, so embedding the flag
> > >> directly in struct dev_pm_info may not be the best choice. Using
> > >> dev->power.subsys_data->domain_data makes more sense and avoids bloating
> > >> the core PM structure.
> > >>
> > >>>
> > >>> Also, it should be documented way more comprehensively IMV.
> > >>>
> > >>> Who is supposed to set it and when? What does it mean when it is set?
> > >>
> > >> To clarify the intended usage, I would propose adding the following
> > >> explanation to the commit message:
> > >>
> > >> "This flag is intended to be set by a generic PM domain driver (e.g.,
> > >> from within its attach_dev callback) to indicate that it will manage
> > >> platform specific runtime power management resources — such as clocks
> > >> and resets — on behalf of the consumer device. This implies a delegation
> > >> of runtime PM control to the PM domain, typically implemented through
> > >> its start and stop callbacks.
> > >>
> > >> When this flag is set, the consumer driver (e.g., drm/imagination) can
> > >> check it and skip managing such resources in its runtime PM callbacks
> > >> (runtime_suspend, runtime_resume), avoiding conflicts or redundant
> > >> operations."
> > >
> > > This sounds good and I would also put it into a code comment somewhere.
> > >
> > > I guess you'll need helpers for setting and testing this flag, so
> > > their kerneldoc comments can be used for that.
> > >
> > >> This could also be included as a code comment near the flag definition
> > >> if you think that’s appropriate.
> > >>
> > >> Also, as discussed earlier with Maxime and Matt [1], this is not about
> > >> full "resource ownership," but more about delegating runtime control of
> > >> PM resources like clocks/resets to the genpd. That nuance may be worth
> > >> reflecting in the flag name as well, I would rename it to let's say
> > >> 'runtime_pm_platform_res_delegated', or more concise
> > >> 'runtime_pm_delegated'.
> > >
> > > Or just "rpm_delegated" I suppose.
> > >
> > > But if the genpd driver is going to set that flag, it will rather mean
> > > that this driver will now control the resources in question, so the
> > > driver should not attempt to manipulate them directly. Is my
> > > understanding correct?
> >
> > Yes, your understanding is correct — with one minor clarification.
> >
> > When the genpd driver sets the flag, it indicates that it will take over
> > control of the relevant PM resources in the context of runtime PM, i.e.,
> > via its start() and stop() callbacks. As a result, the device driver
> > should not manipulate those resources from within its RUNTIME_PM_OPS
> > (e.g., runtime_suspend, runtime_resume) to avoid conflicts.
> >
> > However, outside of the runtime PM callbacks, the consumer device driver
> > may still access or use those resources if needed e.g for devfreq.
> >
> > >
> > > Assuming that it is correct, how is the device driver going to know
> > > which resources in particular are now controlled by the genpd driver?
> >
> > Good question — to allow finer-grained control, we could replace the
> > current single boolean flag with a u32 bitmask field. Each bit would
> > correspond to a specific category of platform managed resources. For
> > example:
> >
> > #define RPM_TAKEOVER_CLK BIT(0)
> > #define RPM_TAKEOVER_RESET BIT(1)
> >
> > This would allow a PM domain driver to selectively declare which
> > resources it is taking over and let the consumer driver query only the
> > relevant parts.
>
> Assuming we are targeting device specific resources for runtime PM;
> why would we want the driver to be responsible for some resources and
> the genpd provider for some others? I would assume we want to handle
> all these RPM-resources from the genpd provider, if/when possible,
> right?
>
> The tricky part though (maybe Stephen had some ideas in his talk [a]
> at OSS), is to teach the genpd provider about what resources it should
> handle. In principle the genpd provider will need some kind of device
> specific knowledge, perhaps based on the device's compatible-string
> and description in DT.
>
> My point is, using a bitmask doesn't scale as it would end up having
> one bit for each clock (a device may have multiple clocks), regulator,
> pinctrl, phy, etc. In principle, reflecting the description in DT.
My understanding is that it's to address a situation where a "generic"
driver interacts with some platform specific code. I think it's tied to
the discussion with the imagination GPU driver handling his clocks, and
the platform genpd clocks overlapping a bit.
But then, my question is: does it matter? clocks are refcounted, and
resets are as well iirc, so why do we need a transition at all? Can't we
just let the platform genpd code take a reference on the clock, the GPU
driver take one as well, and it's all good, right?
Maxime
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]
next prev parent reply other threads:[~2025-04-25 7:09 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20250414185313eucas1p1c4d13c657f3a3c3e47810955db645ca2@eucas1p1.samsung.com>
2025-04-14 18:52 ` [PATCH v2 0/4] Add GPU clock/reset management for TH1520 in genpd Michal Wilczynski
[not found] ` <CGME20250414185314eucas1p1ae57b937773a2ed4ce8d52d5598eb028@eucas1p1.samsung.com>
2025-04-14 18:52 ` [PATCH v2 1/4] PM: device: Introduce platform_resources_managed flag Michal Wilczynski
2025-04-15 16:42 ` Rafael J. Wysocki
2025-04-16 13:32 ` Michal Wilczynski
2025-04-16 14:48 ` Rafael J. Wysocki
2025-04-17 16:19 ` Michal Wilczynski
2025-04-24 16:51 ` Ulf Hansson
2025-04-25 7:09 ` Maxime Ripard [this message]
2025-04-25 10:10 ` Ulf Hansson
[not found] ` <CGME20250414185315eucas1p1fae2d6250bfd30b12bb084e197c02948@eucas1p1.samsung.com>
2025-04-14 18:52 ` [PATCH v2 2/4] dt-bindings: firmware: thead,th1520: Add resets for GPU clkgen Michal Wilczynski
2025-04-15 16:38 ` Conor Dooley
2025-04-16 11:40 ` Michal Wilczynski
2025-04-16 17:10 ` Conor Dooley
[not found] ` <CGME20250414185316eucas1p2c2dbd33788d9141773546f7a479ac288@eucas1p2.samsung.com>
2025-04-14 18:52 ` [PATCH v2 3/4] pmdomain: thead: Add GPU-specific clock and reset handling for TH1520 Michal Wilczynski
2025-04-25 8:50 ` Ulf Hansson
2025-04-30 12:17 ` Michal Wilczynski
2025-05-08 11:13 ` Ulf Hansson
[not found] ` <CGME20250414185317eucas1p139284a38dc4418ac90bd081c2825142a@eucas1p1.samsung.com>
2025-04-14 18:52 ` [PATCH v2 4/4] drm/imagination: Skip clocks if platform PM manages resources Michal Wilczynski
2025-04-15 8:55 ` Maxime Ripard
2025-04-15 9:15 ` Matt Coster
2025-04-15 11:05 ` Michal Wilczynski
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=20250425-lumpy-marmot-of-popularity-cdbbcd@houat \
--to=mripard@kernel.org \
--cc=airlied@gmail.com \
--cc=conor+dt@kernel.org \
--cc=dakr@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=drew@pdp7.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=frank.binns@imgtec.com \
--cc=guoren@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=m.szyprowski@samsung.com \
--cc=m.wilczynski@samsung.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matt.coster@imgtec.com \
--cc=p.zabel@pengutronix.de \
--cc=pavel@kernel.org \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
--cc=ulf.hansson@linaro.org \
--cc=wefu@redhat.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).