From 9d1744bde80487feec2b4a99412a81c1b6cb39a7 Mon Sep 17 00:00:00 2001 From: Veerabhadrarao Badiganti Date: Mon, 12 Apr 2021 12:37:04 +0530 Subject: [PATCH] msm: mhi_dev: Defer mhi resume till M0 ack is sent Defer mhi resume till M0 ack is notified to host. This is to ensure no outstanding transfer completion events are send to host before M0 ack. Change-Id: Ia10fabc554b1cdef14a0771012b9ffea68851e25 Signed-off-by: Veerabhadrarao Badiganti --- drivers/platform/msm/mhi_dev/mhi_sm.c | 30 ++++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/platform/msm/mhi_dev/mhi_sm.c b/drivers/platform/msm/mhi_dev/mhi_sm.c index 655764d8664d..15b518645b65 100644 --- a/drivers/platform/msm/mhi_dev/mhi_sm.c +++ b/drivers/platform/msm/mhi_dev/mhi_sm.c @@ -519,12 +519,6 @@ static int mhi_sm_prepare_resume(void) } } - res = mhi_dev_resume(mhi_sm_ctx->mhi_dev); - if (res) { - MHI_SM_ERR("Failed resuming mhi core: %d", res); - goto exit; - } - res = ipa_mhi_resume(); if (res) { MHI_SM_ERR("Failed resuming ipa_mhi:%d", res); @@ -544,11 +538,27 @@ static int mhi_sm_prepare_resume(void) /* Send state change notification only if we were in M3 state */ res = mhi_dev_send_state_change_event(mhi_sm_ctx->mhi_dev, MHI_DEV_M0_STATE); - if (res) { - MHI_SM_ERR("Failed to send event %s to host, returned %d\n", - mhi_sm_dev_event_str(MHI_DEV_EVENT_M0_STATE), res); - goto exit; + if (res) { + MHI_SM_ERR("Failed to send event %s to host, ret =%d\n", + mhi_sm_dev_event_str(MHI_DEV_EVENT_M0_STATE), + res); + goto exit; + } } + + /* + * Defer mhi resume till M0 ack is notified to host. + * This is to ensure no outstanding transfer completion events are send + * to host before M0 ack. + */ + if ((old_state == MHI_DEV_M3_STATE) || + (old_state == MHI_DEV_M2_STATE)) { + res = mhi_dev_resume(mhi_sm_ctx->mhi_dev); + if (res) { + MHI_SM_ERR("Failed resuming mhi core, returned %d", + res); + goto exit; + } } if (old_state == MHI_DEV_READY_STATE) {