All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Heiko Stübner" <heiko@sntech.de>
To: u-boot@lists.denx.de
Cc: Tom Rini <trini@konsulko.com>, Lukasz Majewski <lukma@denx.de>,
	David Lechner <dlechner@baylibre.com>,
	Julien Stephan <jstephan@baylibre.com>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Peng Fan <peng.fan@nxp.com>,
	Quentin Schulz <quentin.schulz@cherry.de>,
	Philip Molloy <philip.molloy@analog.com>,
	Sean Anderson <sean.anderson@linux.dev>,
	Richard Genoud <richard.genoud@bootlin.com>,
	Simon Glass <sjg@chromium.org>,
	Peter Korsgaard <peter@korsgaard.com>,
	Philipp Tomsich <philipp.tomsich@vrull.eu>,
	Kever Yang <kever.yang@rock-chips.com>,
	Daniele Briguglio <hello@superkali.me>,
	Jonas Karlman <jonas@kwiboo.se>,
	Daniele Briguglio <hello@superkali.me>
Subject: Re: [PATCH v3 3/4] pci: pcie_dw_rockchip: drop clk_release_bulk calls
Date: Tue, 09 Jun 2026 21:04:27 +0200	[thread overview]
Message-ID: <1963052.CQOukoFCf9@diego> (raw)
In-Reply-To: <20260520-rock-5-itx-pcie-refclk-dtsi-v3-3-58f2cea72030@superkali.me>

Am Mittwoch, 20. Mai 2026, 08:05:29 Mitteleuropäische Sommerzeit schrieb Daniele Briguglio:
> clk_release_bulk() loops clk_disable() over the bulk; the bulk
> array itself is devm_kcalloc()-allocated and freed at device
> detach, so the function does not actually release memory.
> 
> In parse_dt() the clocks are acquired but never enabled, so the
> existing call disables clocks that are off.  In probe() after
> init_port() failure, the inner err_disable_clks: path added in
> the previous patch has already balanced clk_enable_bulk() with
> clk_disable_bulk(), so the outer call is a double-disable.
> 
> With the new gated-fixed-clock driver both cases trigger
> regulator_set_enable_if_allowed(false) on regulators that were
> either never enabled or just disabled, desynchronising the
> regulator enable_count.  On rk3588-rock-5-itx with only one M.2
> slot populated, the failing empty slot would decrement the
> enable_count of the still-needed regulator twice and pull power
> from the populated slot.
> 
> Suggested-by: Jonas Karlman <jonas@kwiboo.se>
> Signed-off-by: Daniele Briguglio <hello@superkali.me>

Acked-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Heiko Stuebner <heiko@sntech.de> # rock-5-itx


Though the whole clk handling is quite strange.
I would assume that it's always a
  - clk-request
      - clk-enable
          something
      - clk-disable
  - clk-release


That a clk-disable also hides in the clk-release is really surprising,
and I guess a lot of places in u-boot will encounter the same
imbalance - just mitigated by the fact that the double-disable
won't matter.

Directly in clk_get_bulk the problem is apparent ...
The function tries to get all the clocks, and on error calls
clk_release_all on the already gotten clocks.

All of these clocks never got enabled, but are getting double-disabled
by the clk_release_all() call.

Very very strange ;-)


Heiko

> ---
>  drivers/pci/pcie_dw_rockchip.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/pcie_dw_rockchip.c b/drivers/pci/pcie_dw_rockchip.c
> index 8ea51e642..c1e34df53 100644
> --- a/drivers/pci/pcie_dw_rockchip.c
> +++ b/drivers/pci/pcie_dw_rockchip.c
> @@ -425,7 +425,7 @@ static int rockchip_pcie_parse_dt(struct udevice *dev)
>  rockchip_pcie_parse_dt_err_phy_get_by_index:
>  	/* regulators don't need release */
>  rockchip_pcie_parse_dt_err_supply_regulator:
> -	clk_release_bulk(&priv->clks);
> +	/* clocks don't need release */
>  rockchip_pcie_parse_dt_err_clk_get_bulk:
>  	reset_release_bulk(&priv->rsts);
>  rockchip_pcie_parse_dt_err_reset_get_bulk:
> @@ -476,7 +476,6 @@ static int rockchip_pcie_probe(struct udevice *dev)
>  		return ret;
>  
>  rockchip_pcie_probe_err_init_port:
> -	clk_release_bulk(&priv->clks);
>  	reset_release_bulk(&priv->rsts);
>  	dm_gpio_free(dev, &priv->rst_gpio);
>  
> 
> 





  reply	other threads:[~2026-06-09 19:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-20  6:05 [PATCH v3 0/4] rockchip: PCIe gated reference clock support Daniele Briguglio
2026-05-20  6:05 ` [PATCH v3 1/4] clk: add gated-fixed-clock driver Daniele Briguglio
2026-06-09 18:49   ` Heiko Stübner
2026-05-20  6:05 ` [PATCH v3 2/4] pci: pcie_dw_rockchip: enable clocks before PHY init Daniele Briguglio
2026-06-09 18:50   ` Heiko Stübner
2026-05-20  6:05 ` [PATCH v3 3/4] pci: pcie_dw_rockchip: drop clk_release_bulk calls Daniele Briguglio
2026-06-09 19:04   ` Heiko Stübner [this message]
2026-06-09 20:06     ` Daniele Briguglio
2026-05-20  6:05 ` [PATCH v3 4/4] pci: pcie_dw_rockchip: imply CLK_GATED_FIXED and switch PHY to imply Daniele Briguglio
2026-06-09 19:04   ` Heiko Stübner

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=1963052.CQOukoFCf9@diego \
    --to=heiko@sntech.de \
    --cc=dlechner@baylibre.com \
    --cc=hello@superkali.me \
    --cc=jonas@kwiboo.se \
    --cc=jstephan@baylibre.com \
    --cc=kever.yang@rock-chips.com \
    --cc=lukma@denx.de \
    --cc=peng.fan@nxp.com \
    --cc=peter@korsgaard.com \
    --cc=philip.molloy@analog.com \
    --cc=philipp.tomsich@vrull.eu \
    --cc=quentin.schulz@cherry.de \
    --cc=richard.genoud@bootlin.com \
    --cc=sean.anderson@linux.dev \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.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.