clk: fix determine rate error with pass-through clock
authorJerome Brunet <jbrunet@baylibre.com>
Wed, 14 Feb 2018 13:43:35 +0000 (14:43 +0100)
committerStephen Boyd <sboyd@kernel.org>
Mon, 12 Mar 2018 22:10:22 +0000 (15:10 -0700)
commit04bf9ab3359ff89059509ee5c35446c45b9cdaaa
tree4c72bf3dd197f468b1fd657b3e43e40dc34d60e0
parent99652a469df19086d594e8e89757d4081a812789
clk: fix determine rate error with pass-through clock

If we try to determine the rate of a pass-through clock (a clock which
does not implement .round_rate() nor .determine_rate()),
clk_core_round_rate_nolock() will directly forward the call to the
parent clock. In the particular case where the pass-through actually
does not have a parent, clk_core_round_rate_nolock() will directly
return 0 with the requested rate still set to the initial request
structure. This is interpreted as if the rate could be exactly achieved
while it actually cannot be adjusted.

This become a real problem when this particular pass-through clock is
the parent of a mux with the flag CLK_SET_RATE_PARENT set. The
pass-through clock will always report an exact match, get picked and
finally error when the rate is actually getting set.

This is fixed by setting the rate inside the req to 0 when core is NULL
in clk_core_round_rate_nolock() (same as in __clk_determine_rate() when
hw is NULL)

Fixes: 0f6cc2b8e94d ("clk: rework calls to round and determine rate callbacks")
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Michael Turquette <mturquette@baylibre.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
drivers/clk/clk.c