提交 570fda97 编写于 作者: S Shawn Lin 提交者: Heiko Stuebner

clk: rockchip: Correct the behaviour of restoring cached phase

We can't restore every phase, for instance the invalid phase and
the phase for coming rate which is out of the scope of boards'
ability. And this patch also corrects the error path to return
invalid pointer to clk if clk_notifier_register failed introduced
by the same offending commit.

Fixes: 60cf09e4 ("clk: rockchip: Restore the clock phase after the rate was changed")
Reported-by: Nwlq <wlq@rock-chips.com>
Signed-off-by: NShawn Lin <shawn.lin@rock-chips.com>
Tested-by: Nwlq <wlq@rock-chips.com>
Signed-off-by: NHeiko Stuebner <heiko@sntech.de>
上级 ce84eca9
...@@ -170,18 +170,30 @@ static int rockchip_mmc_clk_rate_notify(struct notifier_block *nb, ...@@ -170,18 +170,30 @@ static int rockchip_mmc_clk_rate_notify(struct notifier_block *nb,
unsigned long event, void *data) unsigned long event, void *data)
{ {
struct rockchip_mmc_clock *mmc_clock = to_rockchip_mmc_clock(nb); struct rockchip_mmc_clock *mmc_clock = to_rockchip_mmc_clock(nb);
struct clk_notifier_data *ndata = data;
/* /*
* rockchip_mmc_clk is mostly used by mmc controllers to sample * rockchip_mmc_clk is mostly used by mmc controllers to sample
* the intput data, which expects the fixed phase after the tuning * the intput data, which expects the fixed phase after the tuning
* process. However if the clock rate is changed, the phase is stale * process. However if the clock rate is changed, the phase is stale
* and may break the data sampling. So here we try to restore the phase * and may break the data sampling. So here we try to restore the phase
* for that case. * for that case, except that
* (1) cached_phase is invaild since we inevitably cached it when the
* clock provider be reparented from orphan to its real parent in the
* first place. Otherwise we may mess up the initialization of MMC cards
* since we only set the default sample phase and drive phase later on.
* (2) the new coming rate is higher than the older one since mmc driver
* set the max-frequency to match the boards' ability but we can't go
* over the heads of that, otherwise the tests smoke out the issue.
*/ */
if (ndata->old_rate <= ndata->new_rate)
return NOTIFY_DONE;
if (event == PRE_RATE_CHANGE) if (event == PRE_RATE_CHANGE)
mmc_clock->cached_phase = mmc_clock->cached_phase =
rockchip_mmc_get_phase(&mmc_clock->hw); rockchip_mmc_get_phase(&mmc_clock->hw);
else if (event == POST_RATE_CHANGE) else if (mmc_clock->cached_phase != -EINVAL &&
event == POST_RATE_CHANGE)
rockchip_mmc_set_phase(&mmc_clock->hw, mmc_clock->cached_phase); rockchip_mmc_set_phase(&mmc_clock->hw, mmc_clock->cached_phase);
return NOTIFY_DONE; return NOTIFY_DONE;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册