All of lore.kernel.org
 help / color / mirror / Atom feed
From: Neha Malcom Francis <n-francis@ti.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>,
	Simon Glass <sjg@chromium.org>,  Tom Rini <trini@konsulko.com>,
	Jaehoon Chung <jh80.chung@samsung.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	<u-boot@lists.denx.de>,
	Samuel Holland <samuel.holland@sifive.com>,
	Wadim Egorov <w.egorov@phytec.de>, Heiko Schocher <hs@denx.de>,
	Fabio Estevam <festevam@denx.de>
Subject: Re: [PATCH 1/2] power-domain: Add support for refcounting (again)
Date: Fri, 25 Apr 2025 15:19:39 +0530	[thread overview]
Message-ID: <e6857778-a543-4aff-83d2-1b91eb21bdf2@ti.com> (raw)
In-Reply-To: <20250425-ge-ian-display-support-v1-1-8a7a0fe75023@bootlin.com>

Hi Miquel

On 25/04/25 12:19, Miquel Raynal 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 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.
> 
> Some drivers implement their own mechanism for that, but it is probably
> best to add this feature in the uclass and share the common code across
> drivers. In order to avoid breaking existing drivers, refcounting is
> only enabled if the number of subdomains a device node supports is
> explicitly set in the probe function. ->xlate() callbacks will return
> the power domain ID which is then being used as the array index to reach
> the correct refcounter.
> 
> As we do not want to break existing users while stile getting
> interesting error codes, the implementation is split between:
> - a low-level helper reporting error codes if the requested transition
>   could not be operated,
> - a higher-level helper ignoring the "non error" codes, like EALREADY and
>   EBUSY.
> 
> CI tests using power domains are slightly updated to make sure the count
> of on/off calls is even and the results match what we *now* expect. They
> are also extended to test the low-level functions.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
>  arch/sandbox/include/asm/power-domain.h          |  2 +
>  drivers/firmware/scmi/sandbox-scmi_devices.c     |  1 +
>  drivers/power/domain/power-domain-uclass.c       | 90 ++++++++++++++++++++++--
>  drivers/power/domain/sandbox-power-domain-test.c | 15 ++++
>  drivers/power/domain/sandbox-power-domain.c      |  4 ++
>  include/power-domain.h                           | 69 +++++++++++++++---
>  test/dm/power-domain.c                           | 11 ++-
>  7 files changed, 177 insertions(+), 15 deletions(-)
> 
> diff --git a/arch/sandbox/include/asm/power-domain.h b/arch/sandbox/include/asm/power-domain.h
> index 4d5e861dbce2b6434ac9bcffe5fc8f704d32e62d..3b0717f8fa06f1c0493fe6ee758e2e72ff77141e 100644
> --- a/arch/sandbox/include/asm/power-domain.h
> +++ b/arch/sandbox/include/asm/power-domain.h
> @@ -13,6 +13,8 @@ int sandbox_power_domain_query(struct udevice *dev, unsigned long id);
>  int sandbox_power_domain_test_get(struct udevice *dev);
>  int sandbox_power_domain_test_on(struct udevice *dev);
>  int sandbox_power_domain_test_off(struct udevice *dev);
> +int sandbox_power_domain_test_on_ll(struct udevice *dev);
> +int sandbox_power_domain_test_off_ll(struct udevice *dev);
>  int sandbox_power_domain_test_free(struct udevice *dev);
>  
>  #endif
> diff --git a/drivers/firmware/scmi/sandbox-scmi_devices.c b/drivers/firmware/scmi/sandbox-scmi_devices.c
> index 96c2922b067e2886b3fa963bcd7e396f4569a569..9f253b0fd40f703a5ec11d34c197423d27ad8b01 100644
> --- a/drivers/firmware/scmi/sandbox-scmi_devices.c
> +++ b/drivers/firmware/scmi/sandbox-scmi_devices.c
> @@ -163,4 +163,5 @@ U_BOOT_DRIVER(sandbox_scmi_devices) = {
>  	.priv_auto = sizeof(struct sandbox_scmi_device_priv),
>  	.remove = sandbox_scmi_devices_remove,
>  	.probe = sandbox_scmi_devices_probe,
> +	.flags = DM_FLAG_DEFAULT_PD_CTRL_OFF,
>  };
[...]

Thanks for working on this quickly, I've booted it on j784s4-evm and
works fine! And I am good with this approach using subdomains.

Tested-by: Neha Malcom Francis <n-francis@ti.com>
(on j784s4-evm)

-- 
Thanking You
Neha Malcom Francis

  parent reply	other threads:[~2025-04-25  9:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-25  6:49 [PATCH 0/2] power-domain: Enable uclass refcounting Miquel Raynal
2025-04-25  6:49 ` [PATCH 1/2] power-domain: Add support for refcounting (again) Miquel Raynal
2025-04-25  8:57   ` Wadim Egorov
2025-04-25  9:49   ` Neha Malcom Francis [this message]
2025-04-25 11:12   ` Heiko Schocher
2025-04-25  6:49 ` [PATCH 2/2] imx: power-domain: Enable refcounting on imx8mp Miquel Raynal
2025-04-25 11:13   ` Heiko Schocher
2025-07-21 16:01   ` Frieder Schrempf
2025-07-22  4:43     ` Neha Malcom Francis
2025-07-22  7:26     ` Frieder Schrempf
2025-07-22  8:32       ` Frieder Schrempf
2025-04-25  8:56 ` [PATCH 0/2] power-domain: Enable uclass refcounting Wadim Egorov
2025-04-28 16: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=e6857778-a543-4aff-83d2-1b91eb21bdf2@ti.com \
    --to=n-francis@ti.com \
    --cc=festevam@denx.de \
    --cc=hs@denx.de \
    --cc=jh80.chung@samsung.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=samuel.holland@sifive.com \
    --cc=sjg@chromium.org \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=w.egorov@phytec.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.