Thread (22 messages) 22 messages, 2 authors, 2023-07-23

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

From: Maxime Ripard <mripard@kernel.org>
Date: 2023-07-17 14:10:18
Also in: linux-clk, linux-sunxi, lkml

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 <redacted>
As stated in my earlier mail, I still disagree with that patch.

Maxime
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help