From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Simon Glass <sjg@chromium.org>
Cc: Fabio Estevam <festevam@gmail.com>,
Tom Rini <trini@konsulko.com>, Lukasz Majewski <lukma@denx.de>,
Sean Anderson <seanga2@gmail.com>,
Jaehoon Chung <jh80.chung@samsung.com>,
Anatolij Gustschin <agust@denx.de>,
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 v2 05/13] power-domain: Add refcounting
Date: Fri, 06 Dec 2024 15:38:05 +0100 [thread overview]
Message-ID: <871pykop0y.fsf@bootlin.com> (raw)
In-Reply-To: <CAFLszTjaqOYJnoJ+DZh+BrREKsyenAT-mwkp=+9k4wyc6zHYUw@mail.gmail.com> (Simon Glass's message of "Thu, 5 Dec 2024 10:56:44 -0700")
Hello Simon,
On 05/12/2024 at 10:56:44 -07, Simon Glass <sjg@chromium.org> wrote:
> Hi Miquel,
>
> On Thu, 5 Dec 2024 at 06:54, Miquel Raynal <miquel.raynal@bootlin.com> wrote:
>>
>> It is very surprising that such an uclass, specifically designed to
>> handle resources that may be shared by different devices, is not keeping
>> the count of the number of times a power domain has been
>> enabled/disabled to avoid shutting it down unexpectedly or disabling it
>> several times.
>>
>> Doing this causes troubles on eg. i.MX8MP because disabling power
>> domains can be done in a recursive loops were the same power domain
>> disabled up to 4 times in a row. PGCs seem to have tight FSM internal
>> timings to respect and it is easy to produce a race condition that puts
>> the power domains in an unstable state, leading to ADB400 errors and
>> later crashes in Linux.
>>
>> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
>> ---
>> drivers/power/domain/power-domain-uclass.c | 37 ++++++++++++++++++++++++++++--
>> include/power-domain.h | 4 ++--
>> 2 files changed, 37 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/power/domain/power-domain-uclass.c b/drivers/power/domain/power-domain-uclass.c
>> index 938bd8cbc9ffd1ba2109d702f886b6a99288d063..55a3d95d83c5aaac31acbd877199c87f8f6fb880 100644
>> --- a/drivers/power/domain/power-domain-uclass.c
>> +++ b/drivers/power/domain/power-domain-uclass.c
>> @@ -12,6 +12,10 @@
>> #include <power-domain-uclass.h>
>> #include <dm/device-internal.h>
>>
>> +struct power_domain_priv {
>> + int on_count;
>> +};
>> +
>> static inline struct power_domain_ops *power_domain_dev_ops(struct udevice *dev)
>> {
>> return (struct power_domain_ops *)dev->driver->ops;
>> @@ -110,19 +114,47 @@ int power_domain_free(struct power_domain *power_domain)
>> int power_domain_on(struct power_domain *power_domain)
>> {
>> struct power_domain_ops *ops = power_domain_dev_ops(power_domain->dev);
>> + struct power_domain_priv *priv = dev_get_uclass_priv(power_domain->dev);
>> + int ret;
>>
>> debug("%s(power_domain=%p)\n", __func__, power_domain);
>>
>> - return ops->on ? ops->on(power_domain) : 0;
>> + if (priv->on_count++ > 0)
>> + return 0;
>
> -EALREADY - see drivers/power/regulator/regulator-uclass.c
Actually I don't see the point in returning this? What is the purpose?
Users should not care nor know about this, it is all internal to the
uclass, we do _not_ want users to mess with this.
If someone ever needs it, they can add a layer of "hiding" for all users
but them, but as said just above, I really think it is a bad idea to
propagate this outside of the uclass.
(same in the _off path).
Thanks,
Miquèl
next prev parent reply other threads:[~2024-12-06 14:38 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-05 13:54 [PATCH v2 00/13] Add imx8mp video support Miquel Raynal
2024-12-05 13:54 ` [PATCH v2 01/13] dm: doc: Fix example Miquel Raynal
2024-12-05 17:56 ` Simon Glass
2024-12-05 13:54 ` [PATCH v2 02/13] dm: core: Add a helper to retrieve devices through graph endpoints Miquel Raynal
2024-12-05 17:57 ` Simon Glass
2024-12-05 13:54 ` [PATCH v2 03/13] sandbox: Add a fake display controller and link it to the panel Miquel Raynal
2024-12-05 17:56 ` Simon Glass
2024-12-05 13:54 ` [PATCH v2 04/13] test: dm: test-fdt: Add checks for uclass_get_device_by_endpoint() Miquel Raynal
2024-12-05 17:57 ` Simon Glass
2024-12-05 13:54 ` [PATCH v2 05/13] power-domain: Add refcounting Miquel Raynal
2024-12-05 17:56 ` Simon Glass
2024-12-06 14:38 ` Miquel Raynal [this message]
2024-12-05 13:54 ` [PATCH v2 06/13] clk: Ensure the parent clocks are enabled while reparenting Miquel Raynal
2024-12-05 13:54 ` [PATCH v2 07/13] clk: imx8mp: Add media related clocks Miquel Raynal
2024-12-05 13:54 ` [PATCH v2 08/13] imx: power-domain: Describe the i.MX8 MEDIAMIX domain Miquel Raynal
2024-12-05 13:54 ` [PATCH v2 09/13] imx: power-domain: Add support for the MEDIAMIX control block Miquel Raynal
2024-12-05 13:54 ` [PATCH v2 10/13] video: imx: Fix Makefile in order to be able to add other imx drivers Miquel Raynal
2024-12-05 13:54 ` [PATCH v2 11/13] video: imx: Add LDB driver Miquel Raynal
2024-12-05 13:54 ` [PATCH v2 12/13] video: imx: Add LCDIF driver Miquel Raynal
2024-12-05 13:54 ` [PATCH v2 13/13] imx8mp_evk: Enable display support Miquel Raynal
2024-12-09 12:12 ` [PATCH v2 00/13] Add imx8mp video support Fabio Estevam
2024-12-20 9:16 ` Miquel Raynal
2024-12-20 12:19 ` 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=871pykop0y.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=michael@amarulasolutions.com \
--cc=seanga2@gmail.com \
--cc=sjg@chromium.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.