[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YPVrkAarqSBMY1tV@smile.fi.intel.com>
Date: Mon, 19 Jul 2021 15:09:52 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Liu Ying <victor.liu@....com>
Cc: Heiko Stuebner <heiko@...ech.de>,
Elaine Zhang <zhangqing@...k-chips.com>,
Stephen Boyd <sboyd@...nel.org>, linux-kernel@...r.kernel.org,
linux-clk@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-rockchip@...ts.infradead.org,
Michael Turquette <mturquette@...libre.com>,
NXP Linux Team <linux-imx@....com>,
Jacky Bai <ping.bai@....com>
Subject: Re: [PATCH v1 2/3] clk: fractional-divider: Introduce NO_PRESCALER
flag
On Mon, Jul 19, 2021 at 11:16:07AM +0800, Liu Ying wrote:
> On Fri, 2021-07-16 at 16:19 +0300, Andy Shevchenko wrote:
> > On Fri, Jul 16, 2021 at 10:43:57AM +0800, Liu Ying wrote:
> > > On Thu, 2021-07-15 at 15:07 +0300, Andy Shevchenko wrote:
...
> > > Second and more important, it seems that it would be good to decouple
> > > the prescaler knowledge from this fractional divider clk driver so as
> > > to make it simple(Output rate = (m / n) * parent_rate). This way, the
> > > CLK_FRAC_DIVIDER_NO_PRESCALER flag is not even needed at the first
> > > place, which means rational_best_approximation() just _directly_
> > > offer best_{numerator,denominator} for all cases.
> >
> > Feel free to submit a patch, just give a good test to avoid breakage of almost
> > all users of this driver.
>
> Maybe someone may do that.
Perhaps. The idea per se is good I think, but I doubt that the implementation
will be plausible.
> I just shared my thought that it sounds
> like a good idea
Thanks!
> to decouple the prescaler knowledge from this
> fractional divider clk driver.
Are you suggesting that each of the device that has _private_ pre-scaler has to
be a clock provider at the same time?
OTOH you will probably need irrespresentable hierarchy to avoid saturated values.
At least those two issues I believe makes the idea fade in complications of the
actual implementation. But again, send the code (you or anybody else) and we will
see how it looks like.
...
> > > Further more, is it
> > > possilbe for rational_best_approximation() to make sure there is no
> > > risk of overflow for best_{numerator,denominator}, since
> > > max_{numerator,denominator} are already handed over to
> > > rational_best_approximation()?
> >
> > How? It can not be satisfied for all possible inputs.
>
> Just have rational_best_approximation() make sure
> best_{numerator,denominator} are in the range of
> [1, max_{numerator,denominator}] for all given_{numerator,denominator}.
> At the same time, best_numerator/best_denominator should be as close
> to given_numerator/given_denominator as possible. For this particular
> fractional divider clk use case, clk_round_rate() can be called
> multiple times until users find rounded rate is ok.
How is it supposed to work IRL? E.g. this driver is being used for UART. Serial
core (or even TTY) has a specific function to approximate the baud rate and it
tries it 2 or 3 times. In case of *saturated* values it won't progress anyhow
because from best rational approximation algorithm the very first attempt would
be done against the best possible clock rate.
Can you provide some code skeleton to see?
...
> > > Overflowed/unreasonable
> > > best_{numerator,denominator} don't sound like the "best" offered value.
> >
> > I don't follow here. If you got saturated values it means that your input is
> > not convergent. In practice it means that we will supply quite a bad value to
> > the caller.
>
> Just like I mentioned above, if given_{numerator,denominator} are not
> convergent, best_numerator/best_denominator should be as close
> to given_numerator/given_denominator as possible and at the same time
> best_{numerator,denominator} are in the range of
> [1, max_{numerator,denominator}]. This way, caller may have chance to
> propose convergent inputs.
How? Again, provide some code to understand this better.
(Spoiler: arithmetics won't allow you to do this. Or maybe
I'm badly missing something very simple and obvious...)
And, if it's possible to achieve, are you suggesting that part of
what CCF driver should do the users will have been doing by their
own?
TL;DR: please send a code to discuss.
Thanks for review and you review of v2 is warmly welcomed!
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists