Re: [PATCH 2/5] clk: spacemit: make MIX rate selection consistent

From: Troy Mitchell

Date: Thu Sep 10 2026 - 10:36:14 EST


On Thu, Sep 10, 2026 at 01:01:30PM +0000, Yao Zi wrote:
> [...]
>
> > @@ -107,22 +107,27 @@ ccu_mix_calc_best_rate(struct clk_hw *hw, unsigned long rate,
> > struct ccu_mix *mix = hw_to_ccu_mix(hw);
> > unsigned int parent_num = clk_hw_get_num_parents(hw);
> > struct ccu_div_config *div = &mix->div;
> > - u32 div_max = 1 << div->width;
> > unsigned long best_rate = 0;
> > + unsigned long best_delta = ULONG_MAX;
> >
> > for (int i = 0; i < parent_num; i++) {
> > struct clk_hw *parent = clk_hw_get_parent_by_index(hw, i);
> > unsigned long parent_rate;
> > + u32 div_max = 1 << div->width;
>
> div_max should be invariant across iterations. Is there a reason moving
> it inside the loop?

It is invariant in this patch. Moving the declaration was preparation
for patch 3, which makes the limit depend on the parent being considered:

u32 div_max = div->bypass & BIT(i) ? 1 : 1 << div->width;

K3 bypasses the divider for some parents, so those parents must only be
considered with a divisor of one.

I will keep the declaration outside the loop in patch 2 and move it
inside when introducing the bypass handling in patch 3. This does not
change the final code.

- Troy

Attachment: signature.asc
Description: PGP signature