U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Nuno Sá" <nuno.sa@analog.com>
To: Qasim Ijaz <Qasim.Ijaz@analog.com>
Cc: u-boot@lists.u-boot-project.org, Tom Rini <trini@konsulko.com>,
	Peng Fan <peng.fan@nxp.com>
Subject: Re: [PATCH] cmd: clk: Don't truncate "clk dump" clock rates to u32
Date: Thu, 15 Oct 2026 14:28:54 +0100	[thread overview]
Message-ID: <atDVBKlKfTWKlT01@nsa> (raw)
In-Reply-To: <dcc2d705-eef9-4346-a2da-ad42e53e973e@analog.com>

On Sat, Oct 03, 2026 at 05:55:07PM +0100, Qasim Ijaz wrote:
> show_clks() prints information about the clock tree such as the rates of
> various clocks. While doing this it gets the rate via clk_get_rate() and
> stores it in an unsigned 32 bit integer variable. This limits the clock
> rate to 4294967295 (or around 4.2GHz). If a clock rate exceeds this then
> "clk dump" will print a rate which has wrapped around the unsigned 32
> bit integer.
> 
> This was observed in the clock tree of an SoC ADI is currently bringing
> up (the ADSP-SC846):
> 
> 	=> clk dump
> 		...
> 		cgu1_vco       505032704
> 		cgu1_pllclk   2400000000
> 		cclk2_1       1600000000
> 		dclk1_1        960000000
> 		...
> 
> In the above the VCO clock should have a rate of 4.8GHz via:
> VCO = SYS_CLKIN * MSEL * 2 = 25MHz * 96 * 2 = 4,800,000,000 Hz. However,
> 4,800,000,000 truncated to 32 bits is 505032704, which is the value
> reported above.
> 
> To fix this issue change the type of "rate" to ulong to match the
> return value of clk_get_rate() also change the format specifier to
> %lu to accommodate the type change.
> 
> Fixes: aeeb2e6d9c67 ("clk: support clk tree dump")
> Signed-off-by: Qasim Ijaz <Qasim.Ijaz@analog.com>
> ---

Acked-by: Nuno Sá <nuno.sa@analog.com>

>  cmd/clk.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/cmd/clk.c b/cmd/clk.c
> index 2fc834e5549..3c816a41730 100644
> --- a/cmd/clk.c
> +++ b/cmd/clk.c
> @@ -15,7 +15,7 @@ static void show_clks(struct udevice *dev, int depth, int last_flag)
>  	int i, is_last;
>  	struct udevice *child;
>  	struct clk *clkp, *parent;
> -	u32 rate;
> +	ulong rate;
>  
>  	clkp = dev_get_clk_ptr(dev);
>  	if (clkp) {
> @@ -25,7 +25,7 @@ static void show_clks(struct udevice *dev, int depth, int last_flag)
>  		depth++;
>  		rate = clk_get_rate(clkp);
>  
> -		printf(" %-12u  %8d        ", rate, clkp->enable_count);
> +		printf(" %-12lu  %8d        ", rate, clkp->enable_count);
>  
>  		for (i = depth; i >= 0; i--) {
>  			is_last = (last_flag >> i) & 1;
> -- 
> 2.43.0

  reply	other threads:[~2026-10-15 14:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-03 16:55 [PATCH] cmd: clk: Don't truncate "clk dump" clock rates to u32 Qasim Ijaz
2026-10-15 13:28 ` Nuno Sá [this message]
2026-10-20  1:06 ` Tom Rini

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=atDVBKlKfTWKlT01@nsa \
    --to=nuno.sa@analog.com \
    --cc=Qasim.Ijaz@analog.com \
    --cc=peng.fan@nxp.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.org \
    /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