mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-14 00:24:41 -04:00
mhi: core: block low power modes only in mission mode
While attempting to block low power modes before sending commands to modify channel state, make sure that execution environment is in mission mode as we may run into a race condition where a forced suspend/resume cycle does not get a chance to run. Change-Id: Ibc7ca5a52036e18677bb597dc0cd95be96d6698a Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
This commit is contained in:
parent
aa01212fe5
commit
c234a26803
1 changed files with 27 additions and 6 deletions
|
|
@ -1843,6 +1843,7 @@ int mhi_prepare_channel(struct mhi_controller *mhi_cntrl,
|
|||
struct mhi_chan *mhi_chan)
|
||||
{
|
||||
int ret = 0;
|
||||
bool in_mission_mode = false;
|
||||
|
||||
MHI_LOG("Entered: preparing channel:%d\n", mhi_chan->chan);
|
||||
|
||||
|
|
@ -1881,7 +1882,12 @@ int mhi_prepare_channel(struct mhi_controller *mhi_cntrl,
|
|||
goto error_pm_state;
|
||||
}
|
||||
|
||||
atomic_inc(&mhi_cntrl->pending_pkts);
|
||||
/* block host low power modes */
|
||||
if (MHI_IN_MISSION_MODE(mhi_cntrl->ee)) {
|
||||
atomic_inc(&mhi_cntrl->pending_pkts);
|
||||
in_mission_mode = true;
|
||||
}
|
||||
|
||||
mhi_cntrl->wake_toggle(mhi_cntrl);
|
||||
if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state))
|
||||
mhi_trigger_resume(mhi_cntrl);
|
||||
|
|
@ -1902,7 +1908,8 @@ int mhi_prepare_channel(struct mhi_controller *mhi_cntrl,
|
|||
goto error_dec_pendpkt;
|
||||
}
|
||||
|
||||
atomic_dec(&mhi_cntrl->pending_pkts);
|
||||
if (in_mission_mode)
|
||||
atomic_dec(&mhi_cntrl->pending_pkts);
|
||||
|
||||
write_lock_irq(&mhi_chan->lock);
|
||||
mhi_chan->ch_state = MHI_CH_STATE_ENABLED;
|
||||
|
|
@ -2086,6 +2093,7 @@ static void __mhi_unprepare_channel(struct mhi_controller *mhi_cntrl,
|
|||
struct mhi_chan *mhi_chan)
|
||||
{
|
||||
int ret;
|
||||
bool in_mission_mode = false;
|
||||
|
||||
MHI_LOG("Entered: unprepare channel:%d\n", mhi_chan->chan);
|
||||
|
||||
|
|
@ -2109,7 +2117,12 @@ static void __mhi_unprepare_channel(struct mhi_controller *mhi_cntrl,
|
|||
goto error_invalid_state;
|
||||
}
|
||||
|
||||
atomic_inc(&mhi_cntrl->pending_pkts);
|
||||
/* block host low power modes */
|
||||
if (MHI_IN_MISSION_MODE(mhi_cntrl->ee)) {
|
||||
atomic_inc(&mhi_cntrl->pending_pkts);
|
||||
in_mission_mode = true;
|
||||
}
|
||||
|
||||
mhi_cntrl->wake_toggle(mhi_cntrl);
|
||||
if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state))
|
||||
mhi_trigger_resume(mhi_cntrl);
|
||||
|
|
@ -2128,7 +2141,8 @@ static void __mhi_unprepare_channel(struct mhi_controller *mhi_cntrl,
|
|||
MHI_ERR("Failed to receive cmd completion, still resetting\n");
|
||||
|
||||
error_dec_pendpkt:
|
||||
atomic_dec(&mhi_cntrl->pending_pkts);
|
||||
if (in_mission_mode)
|
||||
atomic_dec(&mhi_cntrl->pending_pkts);
|
||||
error_invalid_state:
|
||||
if (!mhi_chan->offload_ch) {
|
||||
mhi_reset_chan(mhi_cntrl, mhi_chan);
|
||||
|
|
@ -2337,6 +2351,7 @@ static int mhi_update_channel_state(struct mhi_controller *mhi_cntrl,
|
|||
enum MHI_CMD cmd)
|
||||
{
|
||||
int ret = -EIO;
|
||||
bool in_mission_mode = false;
|
||||
|
||||
mutex_lock(&mhi_chan->mutex);
|
||||
|
||||
|
|
@ -2359,7 +2374,12 @@ static int mhi_update_channel_state(struct mhi_controller *mhi_cntrl,
|
|||
goto error_chan_state;
|
||||
}
|
||||
|
||||
atomic_inc(&mhi_cntrl->pending_pkts);
|
||||
/* block host low power modes */
|
||||
if (MHI_IN_MISSION_MODE(mhi_cntrl->ee)) {
|
||||
atomic_inc(&mhi_cntrl->pending_pkts);
|
||||
in_mission_mode = true;
|
||||
}
|
||||
|
||||
mhi_cntrl->wake_toggle(mhi_cntrl);
|
||||
if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state))
|
||||
mhi_trigger_resume(mhi_cntrl);
|
||||
|
|
@ -2386,7 +2406,8 @@ static int mhi_update_channel_state(struct mhi_controller *mhi_cntrl,
|
|||
mhi_chan->chan, cmd == MHI_CMD_START_CHAN ? "START" : "STOP");
|
||||
|
||||
error_dec_pendpkt:
|
||||
atomic_dec(&mhi_cntrl->pending_pkts);
|
||||
if (in_mission_mode)
|
||||
atomic_dec(&mhi_cntrl->pending_pkts);
|
||||
error_chan_state:
|
||||
mutex_unlock(&mhi_chan->mutex);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue