From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>,
Jaehoon Chung <jh80.chung@samsung.com>,
Lukasz Majewski <lukma@denx.de>,
Sean Anderson <seanga2@gmail.com>,
Anatolij Gustschin <agust@denx.de>,
Fabio Estevm <festevam@gmail.com>, Peng Fan <peng.fan@nxp.com>,
Mario Six <mario.six@gdsys.cc>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
u-boot@lists.denx.de, Ian Ray <ian.ray@gehealthcare.com>,
Michael Nazzareno Trimarchi <michael@amarulasolutions.com>,
Dario Binacchi <dario.binacchi@amarulasolutions.com>,
Adam Ford <aford173@gmail.com>, Marek Vasut <marex@denx.de>
Subject: Re: [PATCH v3 05/13] power-domain: Add refcounting
Date: Tue, 21 Jan 2025 09:34:54 +0100 [thread overview]
Message-ID: <87frlcr2dt.fsf@bootlin.com> (raw)
In-Reply-To: <CAFLszThX2ULHHA1DOA-essfVJ_Fw=BgsR391iDT=bO+6j=UGwg@mail.gmail.com> (Simon Glass's message of "Mon, 20 Jan 2025 12:21:04 -0700")
Hi Simon,
On 20/01/2025 at 12:21:04 -07, Simon Glass <sjg@chromium.org> wrote:
> Hi Miquel,
>
> On Mon, 20 Jan 2025 at 03:34, Miquel Raynal <miquel.raynal@bootlin.com> wrote:
>>
>> Hello Simon,
>>
>> >> int power_domain_on(struct power_domain *power_domain)
>> >> {
>>
>> ...
>>
>> >> + if (priv->on_count++ > 0)
>> >> + return 0;
>> >
>> > -EALREADY
>>
>> ...
>>
>> >> int power_domain_off(struct power_domain *power_domain)
>> >> {
>>
>> ...
>>
>> >> + if (priv->on_count-- > 1)
>> >> + return 0;
>> >
>> > -EBUSY
>> >
>> > See how the regulator uclass does it.
>>
>> I really does not understand why we would like to do that.
>>
>> It is perfectly normal operation to call power_domain_on/off() on the
>> same power domain several times in a row and there is no reason to
>> return an error code. It is quite the opposite, the main reason for
>> power domains is to act like shared regulators. Se while a regulator has
>> one user and doing the same action on it several times does not make
>> much sense and can be reported, that is not how power domains have been
>> thought about in the first place.
>
> I am not aware of any difference between these two subsystems.
Actually you're right on this point, the regulator API works like the
pmdomain one. I had a look: it always returns 0, no matter the state of
the regulator after the operation (as long as there is no error of
course).
> If we
> want a power domain to actually turn off, how many times do we need to
> call power_domain_off()?
We do not? It is why I add refcounting, if a power domain has 2
consumers, each consumer says whether it needs the power domain to be on
or off and the core will handle, but in no case they should force it's
state.
> The function silently does nothing in many
> cases, so it is not deterministic.
It is fully deterministic, as long as consumers call power_on/off
evenly (and this is already what we request in U-Boot).
> In the case where we *actually*
> want to turn the power domain off, we are at a loss as to what code to
> write.
>
>> Hence, I do not agree with returning error codes in these situations,
>> they are misleading and they would have to be ignored anyway.
>>
>
> How about creating a power_domain_off_if_allowed() or
> power_domain_soft_off/on() or power_domain_req_off (for request)?
The power domain logic has a hardware reality in many SoCs but is also a
software concept that is shared with Linux. Changing the semantics in
U-Boot would be very misleading and if my understanding is correct, this
approach would be new.
If you really want a way to track the state of the power domain,
however, I can maybe add a helper returning its state, ie:
bool power_domain_is_on(domain)
Would that work?
Thanks,
Miquèl
next prev parent reply other threads:[~2025-01-21 8:35 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-10 18:42 [PATCH v3 00/13] Add imx8mp video support Miquel Raynal
2025-01-10 18:42 ` [PATCH v3 01/13] dm: doc: Fix example Miquel Raynal
2025-01-10 18:42 ` [PATCH v3 02/13] dm: core: Add a helper to retrieve devices through graph endpoints Miquel Raynal
2025-01-10 18:43 ` [PATCH v3 03/13] sandbox: Add a fake DSI controller and link it to the panel Miquel Raynal
2025-01-10 18:43 ` [PATCH v3 04/13] test: dm: test-fdt: Add checks for uclass_get_device_by_endpoint() Miquel Raynal
2025-01-10 18:43 ` [PATCH v3 05/13] power-domain: Add refcounting Miquel Raynal
2025-01-15 13:19 ` Simon Glass
2025-01-20 10:34 ` Miquel Raynal
2025-01-20 19:21 ` Simon Glass
2025-01-21 8:34 ` Miquel Raynal [this message]
2025-01-23 14:38 ` Simon Glass
2025-01-24 15:20 ` Miquel Raynal
2025-01-25 17:11 ` Simon Glass
2025-01-27 17:11 ` Miquel Raynal
2025-01-27 17:42 ` Simon Glass
2025-01-28 8:56 ` Miquel Raynal
2025-01-10 18:43 ` [PATCH v3 06/13] clk: Ensure the parent clocks are enabled while reparenting Miquel Raynal
2025-01-10 18:43 ` [PATCH v3 07/13] clk: imx8mp: Add media related clocks Miquel Raynal
2025-01-10 18:43 ` [PATCH v3 08/13] imx: power-domain: Describe the i.MX8 MEDIAMIX domain Miquel Raynal
2025-01-10 18:43 ` [PATCH v3 09/13] imx: power-domain: Add support for the MEDIAMIX control block Miquel Raynal
2025-01-10 18:43 ` [PATCH v3 10/13] video: imx: Fix Makefile in order to be able to add other imx drivers Miquel Raynal
2025-01-10 18:43 ` [PATCH v3 11/13] video: imx: Add LDB driver Miquel Raynal
2025-01-10 18:43 ` [PATCH v3 12/13] video: imx: Add LCDIF driver Miquel Raynal
2025-01-10 18:43 ` [PATCH v3 13/13] imx8mp_evk: Enable display support Miquel Raynal
2025-01-10 18:53 ` Fabio Estevam
2025-01-11 9:51 ` Miquel Raynal
2025-01-16 16:13 ` Fabio Estevam
2025-01-16 17:09 ` Miquel Raynal
2025-01-10 19:11 ` Fabio Estevam
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=87frlcr2dt.fsf@bootlin.com \
--to=miquel.raynal@bootlin.com \
--cc=aford173@gmail.com \
--cc=agust@denx.de \
--cc=dario.binacchi@amarulasolutions.com \
--cc=festevam@gmail.com \
--cc=ian.ray@gehealthcare.com \
--cc=jh80.chung@samsung.com \
--cc=lukma@denx.de \
--cc=marex@denx.de \
--cc=mario.six@gdsys.cc \
--cc=michael@amarulasolutions.com \
--cc=peng.fan@nxp.com \
--cc=seanga2@gmail.com \
--cc=sjg@chromium.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/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