diff mbox

usb: renesas_usbhs: fix usbhsf_fifo_clear() behavior

Message ID 1506499445-14826-1-git-send-email-yoshihiro.shimoda.uh@renesas.com (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show

Commit Message

Yoshihiro Shimoda Sept. 27, 2017, 8:04 a.m. UTC
This patch fixes two issues:
 - the usbhsf_fifo_clear() is possible to cause 10 msec delay if
   the pipe is RX direction and empty because the FRDY bit will never
   be set to 1 in such case.
 - sets the BCLR of {C,Dn}FIFOCTR to 1 even when it's non-DCP pipe and
   the FRDY bit sets to 0.

Fixes: e8d548d54968 ("usb: renesas_usbhs: fifo became independent from pipe.")
Cc: <stable@vger.kernel.org> # v3.1+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 This patch set is based on the Felipe's usb.git / testing/fixes branch
 (The commit is 7661ca09b2ff98f48693f431bb01fed62830e433).

 drivers/usb/renesas_usbhs/fifo.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

Comments

Greg KH Sept. 27, 2017, 8:36 a.m. UTC | #1
On Wed, Sep 27, 2017 at 05:04:05PM +0900, Yoshihiro Shimoda wrote:
> This patch fixes two issues:
>  - the usbhsf_fifo_clear() is possible to cause 10 msec delay if
>    the pipe is RX direction and empty because the FRDY bit will never
>    be set to 1 in such case.
>  - sets the BCLR of {C,Dn}FIFOCTR to 1 even when it's non-DCP pipe and
>    the FRDY bit sets to 0.

Should this be two different patches because of this?

thanks,

greg k-h
Yoshihiro Shimoda Sept. 27, 2017, 8:40 a.m. UTC | #2
Hi Greg,

> -----Original Message-----
> From: Greg KH
> Sent: Wednesday, September 27, 2017 5:37 PM
> 
> On Wed, Sep 27, 2017 at 05:04:05PM +0900, Yoshihiro Shimoda wrote:
> > This patch fixes two issues:
> >  - the usbhsf_fifo_clear() is possible to cause 10 msec delay if
> >    the pipe is RX direction and empty because the FRDY bit will never
> >    be set to 1 in such case.
> >  - sets the BCLR of {C,Dn}FIFOCTR to 1 even when it's non-DCP pipe and
> >    the FRDY bit sets to 0.
> 
> Should this be two different patches because of this?

I got it. I will make two patches from this patch.

Best regards,
Yoshihiro Shimoda

> thanks,
> 
> greg k-h
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index d1af831..68f2690 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -282,11 +282,26 @@  static void usbhsf_fifo_clear(struct usbhs_pipe *pipe,
 			      struct usbhs_fifo *fifo)
 {
 	struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
+	int ret = 0;
 
-	if (!usbhs_pipe_is_dcp(pipe))
-		usbhsf_fifo_barrier(priv, fifo);
+	if (!usbhs_pipe_is_dcp(pipe)) {
+		/*
+		 * This driver checks the pipe condition first to avoid -EBUSY
+		 * from usbhsf_fifo_barrier() with about 10 msec delay in
+		 * the interrupt handler if the pipe is RX direction and empty.
+		 */
+		if (usbhs_pipe_is_dir_in(pipe))
+			ret = usbhs_pipe_is_accessible(pipe);
+		if (!ret)
+			ret = usbhsf_fifo_barrier(priv, fifo);
+	}
 
-	usbhs_write(priv, fifo->ctr, BCLR);
+	/*
+	 * if non-DCP pipe, this driver should set BCLR when
+	 * usbhsf_fifo_barrier() returns 0.
+	 */
+	if (!ret)
+		usbhs_write(priv, fifo->ctr, BCLR);
 }
 
 static int usbhsf_fifo_rcv_len(struct usbhs_priv *priv,