Re: [PATCH 4/4] clk: Warn if we register a mux without determine_rate

From: Maxime Ripard
Date: Thu Nov 03 2022 - 08:33:38 EST


Going back to this mail.

On Tue, Oct 25, 2022 at 07:07:58PM -0700, Stephen Boyd wrote:
> Quoting Maxime Ripard (2022-10-18 06:52:59)
> > The determine_rate hook allows to select the proper parent and its rate
> > for a given clock configuration. On another hand, set_parent is there to
> > change the parent of a mux.
> >
> > Some clocks provide a set_parent hook but don't implement
> > determine_rate. In such a case, set_parent is pretty much useless since
> > the clock framework will always assume the current parent is to be used,
> > and we will thus never change it.
> >
> > This situation can be solved in two ways:
> > - either we don't need to change the parent, and we thus shouldn't
> > implement set_parent;
> > - or we don't want to change the parent, in this case we should set
> > CLK_SET_RATE_NO_REPARENT;
> > - or we're missing a determine_rate implementation.
> >
> > The latter is probably just an oversight from the driver's author, and
> > we should thus raise their awareness about the fact that the current
> > state of the driver is confusing.
>
> There is another case which is a leaf clk that is a mux where you only
> expect clk_set_parent() to be used, and not clk_set_rate(). This use
> case is odd though, so I'm not sure how much we care.

It looks like there's a good number of clocks that do indeed only
provide get_parent / set_parent. It's hard to tell if it's an oversight
or a choice.

I think we can make that decision explicit by providing a determine_rate
helper that always returns the current parent and its rate. It shouldn't
change anything from a CCF behavior point of view, and it makes it clear
what the behavior is. And if someone wants something else, then they can
change it to whatever they want.

Maxime