diff --git a/drivers/platform/msm/mhi_dev/mhi_sm.c b/drivers/platform/msm/mhi_dev/mhi_sm.c index 7e3be7654729..655764d8664d 100644 --- a/drivers/platform/msm/mhi_dev/mhi_sm.c +++ b/drivers/platform/msm/mhi_dev/mhi_sm.c @@ -22,7 +22,10 @@ #define MHI_SM_FUNC_ENTRY() MHI_SM_DBG("ENTRY\n") #define MHI_SM_FUNC_EXIT() MHI_SM_DBG("EXIT\n") -#define PCIE_EP_TIMER_US 500000000 +#define PCIE_EP_TIMER_US 500000000 +#define MHI_IPA_DISABLE_DELAY_MS 10 +#define MHI_IPA_DISABLE_COUNTER 20 + static inline const char *mhi_sm_dev_event_str(enum mhi_dev_event state) { @@ -591,7 +594,7 @@ static int mhi_sm_prepare_suspend(enum mhi_dev_state new_state) { enum mhi_dev_state old_state; struct ep_pcie_inactivity inact_param; - int res = 0, rc; + int res = 0, rc, wait_timeout = 0; MHI_SM_DBG("Switching event:%d\n", new_state); @@ -668,11 +671,24 @@ static int mhi_sm_prepare_suspend(enum mhi_dev_state new_state) (new_state == MHI_DEV_M3_STATE))) { if (mhi_sm_ctx->mhi_dev->use_ipa) { MHI_SM_DBG("Disable IPA with ipa_dma_disable()\n"); - res = ipa_dma_disable(); - if (res) { - MHI_SM_ERR("IPA disable failed\n"); + while (wait_timeout < MHI_IPA_DISABLE_COUNTER) { + /* wait for the disable to finish */ + res = ipa_dma_disable(); + if (!res) + break; + MHI_SM_ERR + ("IPA disable fail cnt:%d\n", + wait_timeout); + msleep(MHI_IPA_DISABLE_DELAY_MS); + wait_timeout++; + } + + if (wait_timeout >= MHI_IPA_DISABLE_COUNTER) { + MHI_SM_ERR + ("Fail to disable IPA for M3\n"); goto exit; } + MHI_SM_ERR("IPA DMA successfully disabled\n"); } }