]> git.baikalelectronics.ru Git - kernel.git/commit
clk: Initialize orphan req_rate
authorMaxime Ripard <maxime@cerno.tech>
Fri, 25 Mar 2022 16:11:42 +0000 (17:11 +0100)
committerStephen Boyd <sboyd@kernel.org>
Fri, 25 Mar 2022 18:29:34 +0000 (11:29 -0700)
commitf9d60aa187809d15a1e5935f55020e207926a50f
treee1ffcba42beff8bc8da2545f49b81741269d9500
parentb5413914b0b6b192ef228f400f0f5f3adf26dbea
clk: Initialize orphan req_rate

When registering a clock that doesn't have a recalc_rate implementation,
and doesn't have its parent registered yet, we initialize the clk_core
rate and 'req_rate' fields to 0.

The rate field is later updated when the parent is registered in
clk_core_reparent_orphans_nolock() using __clk_recalc_rates(), but the
'req_rate' field is never updated.

This leads to an issue in clk_set_rate_range() and clk_put(), since
those functions will call clk_set_rate() with the content of 'req_rate'
to provide drivers with the opportunity to change the rate based on the
new boundaries. In this case, we would call clk_set_rate() with a rate
of 0, effectively enforcing the minimum allowed for this clock whenever
we would call one of those two functions, even though the actual rate
might be within range.

Let's fix this by setting 'req_rate' in
clk_core_reparent_orphans_nolock() with the rate field content just
updated by the call to __clk_recalc_rates().

Fixes: 077bc622e095 ("clk: Add rate constraints to clocks")
Reported-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> # T30 Nexus7
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://lore.kernel.org/r/20220325161144.1901695-2-maxime@cerno.tech
[sboyd@kernel.org: Reword comment]
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
drivers/clk/clk.c