From 570829fbc17f57abd41571a7fb1ee3f1ad6218c3 Mon Sep 17 00:00:00 2001 From: Veerabhadrarao Badiganti Date: Wed, 24 Nov 2021 14:19:07 +0530 Subject: [PATCH] msm: mhi_dev: Don't process any other interrupts during M0 processing M0 (mhi resume) processing and doorbell interrupt processing are done in different contexts. And there can be a chance that DB processing can proceed even before the resume is completely done. Say while processing M0, MHI has issued M0-ack but not updated channel state to running state for *all* channels yet. The host can start ringing DB the moment it sees M0-ack and it's the channel is in running state. To avoid this race condition, ensure MHI doesn't process any CHDB interrupt until it's completely done with the resume. Change-Id: Ie8f7fec034be6b17c71e3b7437ab8e6effb63365 Signed-off-by: Veerabhadrarao Badiganti --- drivers/platform/msm/mhi_dev/mhi_sm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/platform/msm/mhi_dev/mhi_sm.c b/drivers/platform/msm/mhi_dev/mhi_sm.c index 6c826dbcea38..0d015e7a9127 100644 --- a/drivers/platform/msm/mhi_dev/mhi_sm.c +++ b/drivers/platform/msm/mhi_dev/mhi_sm.c @@ -1338,6 +1338,17 @@ int mhi_dev_notify_sm_event(enum mhi_dev_event event) INIT_WORK(&state_change_event->work, mhi_sm_dev_event_manager); atomic_inc(&mhi_sm_ctx->pending_device_events); queue_work(mhi_sm_ctx->mhi_sm_wq, &state_change_event->work); + + /* + * Wait until M0 processing is completely done. + * This ensures CHDB won't get processed while resume is in + * progress thus avoids race between M0 and CHDB processing. + */ + if (event == MHI_DEV_EVENT_M0_STATE) { + MHI_SM_DBG("Got M0, wait until resume is done\n"); + flush_workqueue(mhi_sm_ctx->mhi_sm_wq); + } + res = 0; exit: