($INBOX_DIR/description missing)
 help / color / mirror / Atom feed
From: Vivek Pernamitta <quic_vpernami@quicinc.com>
To: mhi@lists.linux.dev
Cc: quic_qianyu@quicinc.com, manivannan.sadhasivam@linaro.org,
	quic_vbadigan@quicinc.com, quic_krichai@quicinc.com,
	quic_skananth@quicinc.com, mrana@quicinc.com,
	Vivek Pernamitta <quic_vpernami@quicinc.com>,
	Manivannan Sadhasivam <mani@kernel.org>,
	Alex Elder <elder@linaro.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jeffrey Hugo <quic_jhugo@quicinc.com>,
	Hemant Kumar <hemantk@codeaurora.org>,
	Bhaumik Bhatt <bbhatt@codeaurora.org>,
	linux-arm-msm@vger.kernel.org (open list:MHI BUS),
	linux-kernel@vger.kernel.org (open list)
Subject: [PATCH v5] bus: mhi: host: Avoid ringing EV DB if there is no elements to process
Date: Wed, 22 Feb 2023 23:07:48 +0530	[thread overview]
Message-ID: <1677087470-7004-1-git-send-email-quic_vpernami@quicinc.com> (raw)

As mhi_poll function can be called by mhi client drivers
which will call process_event, which will ring DB even if
there no ring elements to process. This could cause
doorbell event to be processed by MHI device to check for
any ring elements even it is none and also it will occupy
lot of bandwidth on peripheral when mhi_poll() is called in
aggressive loop.

Signed-off-by: Vivek Pernamitta <quic_vpernami@quicinc.com>
Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>

---
changes since v4:
	updating the commit text with more information.
changes since v3:
	- Updating commit text for multiple versions of patches.
changes since v2:
	- Updated comments in code.
changes since v1:
	- Add an check to avoid ringing EV DB in mhi_process_ctrl_ev_ring().
---
 drivers/bus/mhi/host/main.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/mhi/host/main.c b/drivers/bus/mhi/host/main.c
index df0fbfe..1bbdb75 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);
 
-- 
2.7.4


             reply	other threads:[~2023-02-22 17:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-22 17:37 Vivek Pernamitta [this message]
2023-02-23 15:48 ` [PATCH v5] bus: mhi: host: Avoid ringing EV DB if there is no elements to process Manivannan Sadhasivam
2023-03-07 16:41   ` Manivannan Sadhasivam
  -- strict thread matches above, loose matches on Subject: below --
2023-04-04  9:41 [PATCH V5] " Vivek Pernamitta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1677087470-7004-1-git-send-email-quic_vpernami@quicinc.com \
    --to=quic_vpernami@quicinc.com \
    --cc=bbhatt@codeaurora.org \
    --cc=elder@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hemantk@codeaurora.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mani@kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=mhi@lists.linux.dev \
    --cc=mrana@quicinc.com \
    --cc=quic_jhugo@quicinc.com \
    --cc=quic_krichai@quicinc.com \
    --cc=quic_qianyu@quicinc.com \
    --cc=quic_skananth@quicinc.com \
    --cc=quic_vbadigan@quicinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).