All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Masney <bmasney@redhat.com>
To: Colin Foster <colin.foster@in-advantage.com>
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org,
	Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>,
	Michal Simek <michal.simek@amd.com>,
	Stephen Boyd <sboyd@kernel.org>,
	Michael Turquette <mturquette@baylibre.com>
Subject: Re: [PATCH v1 1/3] clk: clocking-wizard: fix clock difference detection
Date: Mon, 29 Jun 2026 16:12:50 -0400	[thread overview]
Message-ID: <akLRwsEQEd3JGcvz@redhat.com> (raw)
In-Reply-To: <20260506200555.2558434-2-colin.foster@in-advantage.com>

Hi Colin,

On Wed, May 06, 2026 at 03:05:53PM -0500, Colin Foster wrote:
> The diff calculation didn't take into account rollover. As such, a
> target clock frequency below the requested rate would not be considered.
> 
> Before this change, bogus diffs would be used to determine the closest
> possible clock:
> 
> 8<--------
> clk-wizard-test: requesting 133312500 Hz on output 0 (clock NOT enabled)
> *** Clock wizard - Matching for rate 133312500 parent rate 99999000
> m = 33, d = 1, o = 25, freq = 131998680, diff = 18446744073708237796
> m = 34, d = 1, o = 26, freq = 130767923, diff = 18446744073707007039
> m = 35, d = 1, o = 26, freq = 134614038, diff = 1301538
> m = 36, d = 1, o = 27, freq = 133332000, diff = 19500
> 8<--------
> 
> After this change:
> 
> 8<--------
> clk-wizard-test: requesting 133312500 Hz on output 0 (clock NOT enabled)
> *** Clock wizard - Matching for rate 133312500 parent rate 99999000
> m = 33, d = 1, o = 25, freq = 131998680, diff = 1313820
> m = 35, d = 1, o = 26, freq = 134614038, diff = 1301538
> m = 36, d = 1, o = 27, freq = 133332000, diff = 19500
> 8<--------
> 
> Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
> ---
>  drivers/clk/xilinx/clk-xlnx-clock-wizard.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
> index 032a688840d8..88b47b8cc387 100644
> --- a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
> +++ b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
> @@ -408,7 +408,7 @@ static int clk_wzrd_get_divisors(struct clk_hw *hw, unsigned long rate,
>  			if (o < omin || o > omax)
>  				continue;
>  			freq = DIV_ROUND_CLOSEST_ULL(vco_freq, o);
> -			diff = freq - rate;
> +			diff = abs(freq - rate);
>  
>  			if (diff < best_diff) {
>  				printk("m = %d, d = %d, o = %d, freq = %llu, diff = %llu", m, d, o, freq, diff);

Stephen didn't pick this up last development cycle and I'm assembling a
pull for him. This doesn't apply to upstream.  Please post a new
version that applies cleanly.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/clk/xilinx/clk-xlnx-clock-wizard.c#n341

Brian


  reply	other threads:[~2026-06-29 20:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-06 20:05 [PATCH v1 0/3] clock-wizard fixups Colin Foster
2026-05-06 20:05 ` [PATCH v1 1/3] clk: clocking-wizard: fix clock difference detection Colin Foster
2026-06-29 20:12   ` Brian Masney [this message]
2026-06-29 20:56     ` Colin Foster
2026-05-06 20:05 ` [PATCH v1 2/3] clk: clocking-wizard: optimize clock search Colin Foster
2026-05-06 20:05 ` [PATCH v1 3/3] clk: clocking-wizard: remove 20kHz restriction Colin Foster
2026-05-07 11:59 ` [PATCH v1 0/3] clock-wizard fixups Datta, Shubhrajyoti
2026-06-23 13:03   ` Colin Foster
2026-06-23 13:40     ` Brian Masney

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=akLRwsEQEd3JGcvz@redhat.com \
    --to=bmasney@redhat.com \
    --cc=colin.foster@in-advantage.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@amd.com \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@kernel.org \
    --cc=shubhrajyoti.datta@amd.com \
    /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.