mhi.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] bus: mhi: host: Avoid ringing EV DB if there is no elements to process
@ 2023-02-22 11:43 Vivek Pernamitta
  2023-02-22 15:43 ` Jeffrey Hugo
  0 siblings, 1 reply; 2+ messages in thread
From: Vivek Pernamitta @ 2023-02-22 11:43 UTC (permalink / raw)
  To: mhi
  Cc: quic_qianyu, manivannan.sadhasivam, quic_vbadigan, quic_krichai,
	quic_skananth, Vivek Pernamitta, Manivannan Sadhasivam,
	Alex Elder, Greg Kroah-Hartman, Hemant Kumar, Jeffrey Hugo,
	Paul Davey, open list:MHI BUS, open list

Avoid ringing Event DB if there is no elements to process.
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.

Signed-off-by: Vivek Pernamitta <quic_vpernami@quicinc.com>

---
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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v4] bus: mhi: host: Avoid ringing EV DB if there is no elements to process
  2023-02-22 11:43 [PATCH v4] bus: mhi: host: Avoid ringing EV DB if there is no elements to process Vivek Pernamitta
@ 2023-02-22 15:43 ` Jeffrey Hugo
  0 siblings, 0 replies; 2+ messages in thread
From: Jeffrey Hugo @ 2023-02-22 15:43 UTC (permalink / raw)
  To: Vivek Pernamitta, mhi
  Cc: quic_qianyu, manivannan.sadhasivam, quic_vbadigan, quic_krichai,
	quic_skananth, Manivannan Sadhasivam, Alex Elder,
	Greg Kroah-Hartman, Paul Davey, open list:MHI BUS, open list

On 2/22/2023 4:43 AM, Vivek Pernamitta wrote:
> Avoid ringing Event DB if there is no elements to process.

This is almost exactly identical to $SUBJECT and therefore redundant.

> 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.

I think that you could be more clear on why this is a problem that 
should be addressed.  Perhaps add a sentence like "These doorbell events 
needlessly interrupt the MHI device to checked for ring elements when 
there are none."

With the commit text updated, you can add
Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>

> 
> Signed-off-by: Vivek Pernamitta <quic_vpernami@quicinc.com>
> 
> ---
> 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);
>   


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-22 15:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-22 11:43 [PATCH v4] bus: mhi: host: Avoid ringing EV DB if there is no elements to process Vivek Pernamitta
2023-02-22 15:43 ` Jeffrey Hugo

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 NNTP newsgroup(s).