From: Vivek Pernamitta Date: Tue, 4 Apr 2023 09:44:16 +0000 (+0530) Subject: bus: mhi: host: Avoid ringing EV DB if there are no elements to process X-Git-Tag: v6.4-rc1~114^2~32^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4308c6878acfb58eda46483644b516abd732b6dd;p=thirdparty%2Fkernel%2Flinux.git bus: mhi: host: Avoid ringing EV DB if there are no elements to process Currently, mhi_process_data_event_ring()/mhi_process_ctrl_ev_ring() APIs are ringing DB even if there are no ring elements to process. This could cause the device to process the DB event in the absence of ring elements. So to avoid this unnecessary device processing, let's ring event DB only if there are any ring elements to process. Signed-off-by: Vivek Pernamitta Reviewed-by: Jeffrey Hugo Reviewed-by: Manivannan Sadhasivam Link: https://lore.kernel.org/r/1680601458-9105-1-git-send-email-quic_vpernami@quicinc.com [mani: massaged the commit message a bit] Signed-off-by: Manivannan Sadhasivam --- diff --git a/drivers/bus/mhi/host/main.c b/drivers/bus/mhi/host/main.c index 4fa0969472fcd..c7eb7b8be9d6b 100644 --- a/drivers/bus/mhi/host/main.c +++ b/drivers/bus/mhi/host/main.c @@ -961,7 +961,9 @@ int mhi_process_ctrl_ev_ring(struct mhi_controller *mhi_cntrl, } read_lock_bh(&mhi_cntrl->pm_lock); - if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl))) + + /* Ring EV DB only if there is any pending element to process */ + if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl)) && count) mhi_ring_er_db(mhi_event); read_unlock_bh(&mhi_cntrl->pm_lock); @@ -1031,7 +1033,9 @@ int mhi_process_data_event_ring(struct mhi_controller *mhi_cntrl, count++; } read_lock_bh(&mhi_cntrl->pm_lock); - if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl))) + + /* Ring EV DB only if there is any pending element to process */ + if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl)) && count) mhi_ring_er_db(mhi_event); read_unlock_bh(&mhi_cntrl->pm_lock);