mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-12 15:49:17 -04:00
clk: qcom: clk-rpmh: Wait for completion when enabling clocks
The current implementation always uses rpmh_write_async, which doesn't wait for completion. That's fine for disable requests since there's no immediate need for the clocks and they can be disabled in the background. However, for enable requests we need to ensure the clocks are actually enabled before returning to the client. Otherwise, clients can end up accessing their HW before the necessary clocks are enabled, which can lead to bus errors. Use the synchronous version of this API (rpmh_write) for enable requests in the active set to ensure completion. Completion isn't required for sleep/wake sets, since they don't take effect until after we enter sleep. All rpmh requests are automatically flushed prior to entering sleep. Change-Id: I3d3261159bb30e4e149f4cb6b3e9d60b018a5d5e Signed-off-by: Mike Tipton <mdtipton@codeaurora.org>
This commit is contained in:
parent
3bdb50e53a
commit
6621c8dad5
1 changed files with 16 additions and 2 deletions
|
|
@ -153,6 +153,19 @@ static inline bool has_state_changed(struct clk_rpmh *c, u32 state)
|
|||
!= (c->aggr_state & BIT(state));
|
||||
}
|
||||
|
||||
static int clk_rpmh_send(struct clk_rpmh *c, enum rpmh_state state,
|
||||
struct tcs_cmd *cmd, bool wait_for_completion)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (wait_for_completion)
|
||||
ret = rpmh_write(c->dev, state, cmd, 1);
|
||||
else
|
||||
ret = rpmh_write_async(c->dev, state, cmd, 1);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int clk_rpmh_send_aggregate_command(struct clk_rpmh *c)
|
||||
{
|
||||
struct tcs_cmd cmd = { 0 };
|
||||
|
|
@ -169,7 +182,8 @@ static int clk_rpmh_send_aggregate_command(struct clk_rpmh *c)
|
|||
if (cmd_state & BIT(state))
|
||||
cmd.data = on_val;
|
||||
|
||||
ret = rpmh_write_async(c->dev, state, &cmd, 1);
|
||||
ret = clk_rpmh_send(c, state, &cmd,
|
||||
cmd_state && state == RPMH_ACTIVE_ONLY_STATE);
|
||||
if (ret) {
|
||||
dev_err(c->dev, "set %s state of %s failed: (%d)\n",
|
||||
!state ? "sleep" :
|
||||
|
|
@ -277,7 +291,7 @@ static int clk_rpmh_bcm_send_cmd(struct clk_rpmh *c, bool enable)
|
|||
cmd.addr = c->res_addr;
|
||||
cmd.data = BCM_TCS_CMD(1, enable, 0, cmd_state);
|
||||
|
||||
ret = rpmh_write_async(c->dev, RPMH_ACTIVE_ONLY_STATE, &cmd, 1);
|
||||
ret = clk_rpmh_send(c, RPMH_ACTIVE_ONLY_STATE, &cmd, enable);
|
||||
if (ret) {
|
||||
dev_err(c->dev, "set active state of %s failed: (%d)\n",
|
||||
c->res_name, ret);
|
||||
|
|
|
|||
Loading…
Reference in a new issue