mhi.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH V5] bus: mhi: host: Avoid ringing EV DB if there is no elements to process
@ 2023-04-04  9:41 Vivek Pernamitta
  0 siblings, 0 replies; 4+ messages in thread
From: Vivek Pernamitta @ 2023-04-04  9:41 UTC (permalink / raw)
  To: mhi
  Cc: quic_qianyu, manivannan.sadhasivam, quic_vbadigan, quic_krichai,
	quic_skananth, Vivek Pernamitta, Manivannan Sadhasivam,
	Jeffrey Hugo, Bhaumik Bhatt, Hemant Kumar, open list:MHI BUS,
	open list

curenlty mhi_process_data_event_ring()/mhi_process_ctrl_ev_ring()
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.
So ring event DB only if any event ring elements are processed.

Signed-off-by: Vivek Pernamitta <quic_vpernami@quicinc.com>
Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
changes since v5:
	updating the commit text.
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


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

* Re: [PATCH v5] bus: mhi: host: Avoid ringing EV DB if there is no elements to process
  2023-02-23 15:48 ` Manivannan Sadhasivam
@ 2023-03-07 16:41   ` Manivannan Sadhasivam
  0 siblings, 0 replies; 4+ messages in thread
From: Manivannan Sadhasivam @ 2023-03-07 16:41 UTC (permalink / raw)
  To: Vivek Pernamitta
  Cc: mhi, quic_qianyu, quic_vbadigan, quic_krichai, quic_skananth,
	mrana, Alex Elder, Greg Kroah-Hartman, Jeffrey Hugo,
	Hemant Kumar, Bhaumik Bhatt, open list:MHI BUS, open list

On Thu, Feb 23, 2023 at 09:18:36PM +0530, Manivannan Sadhasivam wrote:
> On Wed, Feb 22, 2023 at 11:07:48PM +0530, Vivek Pernamitta wrote:
> > 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.
> > 
> 
> The change looks good to me but who is the actual in-kernel user of
> mhi_poll() API? It is being exported and if there is no upstream client
> driver making use of it, then it shouldn't be.
> 
> I'm gonna submit a patch to remove this API altogether.
> 

The patch removing mhi_poll() API is now merged. Can you please respin this
patch removing the note to the API?

I still think this patch is relevant without that API.

Thanks,
Mani

> > Signed-off-by: Vivek Pernamitta <quic_vpernami@quicinc.com>
> > Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
> 
> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> 
> Thanks,
> Mani
> 
> > 
> > ---
> > 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
> > 
> 

-- 
மணிவண்ணன் சதாசிவம்

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

* Re: [PATCH v5] bus: mhi: host: Avoid ringing EV DB if there is no elements to process
  2023-02-22 17:37 [PATCH v5] " Vivek Pernamitta
@ 2023-02-23 15:48 ` Manivannan Sadhasivam
  2023-03-07 16:41   ` Manivannan Sadhasivam
  0 siblings, 1 reply; 4+ messages in thread
From: Manivannan Sadhasivam @ 2023-02-23 15:48 UTC (permalink / raw)
  To: Vivek Pernamitta
  Cc: mhi, quic_qianyu, quic_vbadigan, quic_krichai, quic_skananth,
	mrana, Alex Elder, Greg Kroah-Hartman, Jeffrey Hugo,
	Hemant Kumar, Bhaumik Bhatt, open list:MHI BUS, open list

On Wed, Feb 22, 2023 at 11:07:48PM +0530, Vivek Pernamitta wrote:
> 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.
> 

The change looks good to me but who is the actual in-kernel user of
mhi_poll() API? It is being exported and if there is no upstream client
driver making use of it, then it shouldn't be.

I'm gonna submit a patch to remove this API altogether.

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

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Thanks,
Mani

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

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

* [PATCH v5] bus: mhi: host: Avoid ringing EV DB if there is no elements to process
@ 2023-02-22 17:37 Vivek Pernamitta
  2023-02-23 15:48 ` Manivannan Sadhasivam
  0 siblings, 1 reply; 4+ messages in thread
From: Vivek Pernamitta @ 2023-02-22 17:37 UTC (permalink / raw)
  To: mhi
  Cc: quic_qianyu, manivannan.sadhasivam, quic_vbadigan, quic_krichai,
	quic_skananth, mrana, Vivek Pernamitta, Manivannan Sadhasivam,
	Alex Elder, Greg Kroah-Hartman, Jeffrey Hugo, Hemant Kumar,
	Bhaumik Bhatt, open list:MHI BUS, open list

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


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

end of thread, other threads:[~2023-04-04 10:17 UTC | newest]

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

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