From: Stephen Boyd <sboyd@kernel.org>
To: Jay Buddhabhatti <jay.buddhabhatti@amd.com>,
michal.simek@amd.com, mturquette@baylibre.com
Cc: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Jay Buddhabhatti <jay.buddhabhatti@amd.com>
Subject: Re: [PATCH RESEND 2/2] drivers: clk: zynqmp: update divider round rate logic
Date: Mon, 23 Oct 2023 20:37:49 -0700 [thread overview]
Message-ID: <3ff911fa4c417a81462813f975ac757f.sboyd@kernel.org> (raw)
In-Reply-To: <20231016113002.15929-3-jay.buddhabhatti@amd.com>
Quoting Jay Buddhabhatti (2023-10-16 04:30:02)
> Currently zynqmp divider round rate is considering single parent and
> calculating rate and parent rate accordingly. But if divider clock flag
> is set to SET_RATE_PARENT then its not trying to traverse through all
> parent rate and not selecting best parent rate from that. So use common
> divider_round_rate() which is traversing through all clock parents and
> its rate and calculating proper parent rate.
>
> Signed-off-by: Jay Buddhabhatti <jay.buddhabhatti@amd.com>
> ---
> drivers/clk/zynqmp/divider.c | 70 ++++++------------------------------
> 1 file changed, 10 insertions(+), 60 deletions(-)
Can't argue against removing that many lines!
>
> diff --git a/drivers/clk/zynqmp/divider.c b/drivers/clk/zynqmp/divider.c
> index 33a3b2a22659..a42c183d7e5d 100644
> --- a/drivers/clk/zynqmp/divider.c
> +++ b/drivers/clk/zynqmp/divider.c
> @@ -193,23 +149,17 @@ static long zynqmp_clk_divider_round_rate(struct clk_hw *hw,
> return DIV_ROUND_UP_ULL((u64)*prate, bestdiv);
> }
>
> - bestdiv = zynqmp_divider_get_val(*prate, rate, divider->flags);
> -
> - /*
> - * In case of two divisors, compute best divider values and return
> - * divider2 value based on compute value. div1 will be automatically
> - * set to optimum based on required total divider value.
> - */
> - if (div_type == TYPE_DIV2 &&
> - (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT)) {
> - zynqmp_get_divider2_val(hw, rate, divider, &bestdiv);
> + max = divider->max_div;
> + while (max != 0) {
> + if ((max & 1) == 1)
> + width++;
> + max = max >> 1;
Is this ffs()?
> }
>
> - if ((clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) && divider->is_frac)
> - bestdiv = rate % *prate ? 1 : bestdiv;
> + rate = divider_round_rate(hw, rate, prate, NULL, width, divider->flags);
>
> - bestdiv = min_t(u32, bestdiv, divider->max_div);
> - *prate = rate * bestdiv;
> + if (divider->is_frac && (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) && (rate % *prate))
> + *prate = rate;
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-10-24 3:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-16 11:30 [PATCH RESEND 0/2] update for versal net platform Jay Buddhabhatti
2023-10-16 11:30 ` [PATCH RESEND 1/2] drivers: clk: zynqmp: calculate closest mux rate Jay Buddhabhatti
2023-10-24 3:38 ` Stephen Boyd
2023-10-25 12:24 ` Buddhabhatti, Jay
2023-10-16 11:30 ` [PATCH RESEND 2/2] drivers: clk: zynqmp: update divider round rate logic Jay Buddhabhatti
2023-10-24 3:37 ` Stephen Boyd [this message]
2023-10-25 12:21 ` Buddhabhatti, Jay
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=3ff911fa4c417a81462813f975ac757f.sboyd@kernel.org \
--to=sboyd@kernel.org \
--cc=jay.buddhabhatti@amd.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 \
/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;
as well as URLs for NNTP newsgroup(s).