[PATCH v4 03/11] clk: sunxi-ng: nkm: Improve determine rate when setting parent

Maxime Ripard mripard at kernel.org
Mon Jul 17 07:10:10 PDT 2023


Hi,

On Mon, Jul 17, 2023 at 03:34:27PM +0200, Frank Oltmanns wrote:
> Make the SET_PARENT_RATE flag independent of the parents round_rate or
> determine_rate implementation.
> 
> Currently, the algorithm for ccu_nkm_find_best_with_parent_adj simply
> calculates the optimal parent rate as
>     (1) parent = rate * m / (n * k)
> 
> Due to integer division (1) might return a parent rate that is too low.
> So using this value for asking the parent for a rate it supports via
> clk_hw_round_rate causes problems on
>  a) parents that only support finding rates that are lower than the
>     requested rate - which is the default for sunxi-ng ccu's.
>  b) parents that incidentally also support the truncated rate.
> 
> In those cases ccu_nkm_determine_rate might return A' when A is
> requested and A'' when rate A' is requested.
> 
> Prevent this by trying to find a parent rate so that
>     (2) _rate = parent * n * k / m
> matches the requested rate exactly, if possible.
> 
> Background:
> ===========
> determine_rate may be called multiple times by the clk framework when
> setting a clock's rate. But the clk framework expects that the values
> determine_rate returns (i.e. the rate and parent_rate) are consistent
> with previous calls.
> 
> Specifically, clock's have to ensure that if determine_rate is called
> with requested rate A and the best rate it can find is A', it must also
> return A' when called with requested rate A'.
> 
> Signed-off-by: Frank Oltmanns <frank at oltmanns.dev>

As stated in my earlier mail, I still disagree with that patch.

Maxime
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20230717/57ecf00b/attachment-0001.sig>


More information about the linux-arm-kernel mailing list