Re: [PATCH 1/2] clk: Update req_rate on __clk_recalc_rates()

From: Stephen Boyd
Date: Mon Oct 10 2022 - 23:43:57 EST


Quoting Maxime Ripard (2022-10-10 07:47:38)
> Commit cb1b1dd96241 ("clk: Set req_rate on reparenting") introduced a
> new function, clk_core_update_orphan_child_rates(), that updates the
> req_rate field on reparenting.
>
> It turns out that that function will interfere with the clock notifying
> done by __clk_recalc_rates(). This ends up reporting the new rate in
> both the old_rate and new_rate fields of struct clk_notifier_data.
>
> Since clk_core_update_orphan_child_rates() is basically
> __clk_recalc_rates() without the notifiers, and with the req_rate field
> update, we can drop clk_core_update_orphan_child_rates() entirely, and
> make __clk_recalc_rates() update req_rate.
>
> However, __clk_recalc_rates() is being called in several code paths:
> when retrieving a rate (most likely through clk_get_rate()), when changing
> parents (through clk_set_rate() or clk_hw_reparent()), or when updating
> the orphan status (through clk_core_reparent_orphans_nolock(), called at
> registration).
>
> Updating req_rate on reparenting or initialisation makes sense, but we
> shouldn't do it on clk_get_rate(). Thus an extra flag has been added to
> update or not req_rate depending on the context.
>
> Fixes: cb1b1dd96241 ("clk: Set req_rate on reparenting")
> Link: https://lore.kernel.org/linux-clk/0acc7217-762c-7c0d-45a0-55c384824ce4@xxxxxxxxxxx/
> Link: https://lore.kernel.org/linux-clk/Y0QNSx+ZgqKSvPOC@xxxxxxxxxxxxx/
> Reported-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
> Reported-by: Mark Brown <broonie@xxxxxxxxxx>
> Suggested-by: Stephen Boyd <sboyd@xxxxxxxxxx>
> Signed-off-by: Maxime Ripard <maxime@xxxxxxxxxx>
> ---

Applied to clk-next