All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] usb: renesas_usbhs: fix the driver for v4.8
@ 2016-08-08 12:50 Yoshihiro Shimoda
  2016-08-08 12:50 ` [PATCH 1/3] usb: renesas_usbhs: Fix receiving data corrupt on R-Car Gen3 with dmac Yoshihiro Shimoda
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Yoshihiro Shimoda @ 2016-08-08 12:50 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, linux-usb, linux-renesas-soc, stable, Yoshihiro Shimoda

This patch set is based on the latest Felipe's usb.git / testing/fixes branch.
(The commit id = 10493a3c0718 ("usb: dwc3: gadget: increment request->actual once")

Yoshihiro Shimoda (3):
  usb: renesas_usbhs: Fix receiving data corrupt on R-Car Gen3 with dmac
  usb: renesas_usbhs: clear the BRDYSTS in usbhsg_ep_enable()
  usb: renesas_usbhs: Use dmac only if the pipe type is bulk

 drivers/usb/renesas_usbhs/common.c     | 3 ++-
 drivers/usb/renesas_usbhs/fifo.c       | 4 ++--
 drivers/usb/renesas_usbhs/mod_gadget.c | 7 +++++--
 3 files changed, 9 insertions(+), 5 deletions(-)

-- 
1.9.1


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

* [PATCH 1/3] usb: renesas_usbhs: Fix receiving data corrupt on R-Car Gen3 with dmac
  2016-08-08 12:50 [PATCH 0/3] usb: renesas_usbhs: fix the driver for v4.8 Yoshihiro Shimoda
@ 2016-08-08 12:50 ` Yoshihiro Shimoda
  2016-08-08 12:50 ` [PATCH 2/3] usb: renesas_usbhs: clear the BRDYSTS in usbhsg_ep_enable() Yoshihiro Shimoda
  2016-08-08 12:50 ` [PATCH 3/3] usb: renesas_usbhs: Use dmac only if the pipe type is bulk Yoshihiro Shimoda
  2 siblings, 0 replies; 4+ messages in thread
From: Yoshihiro Shimoda @ 2016-08-08 12:50 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, linux-usb, linux-renesas-soc, stable, Yoshihiro Shimoda

Since R-Car Gen3 SoC has the USB-DMAC, this driver should set
dparam->has_usb_dmac to 1. Otherwise, behavior of this driver and
the usb-dmac driver will be mismatch, then sometimes receiving data will
be corrupt.

Fixes: de18757e272d ("usb: renesas_usbhs: add R-Car Gen3 power control")
Cc: <stable@vger.kernel.org> # v4.5+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/usb/renesas_usbhs/common.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index 8fbbc2d..ac67bab 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -514,7 +514,8 @@ static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
 	if (gpio > 0)
 		dparam->enable_gpio = gpio;
 
-	if (dparam->type == USBHS_TYPE_RCAR_GEN2)
+	if (dparam->type == USBHS_TYPE_RCAR_GEN2 ||
+	    dparam->type == USBHS_TYPE_RCAR_GEN3)
 		dparam->has_usb_dmac = 1;
 
 	return info;
-- 
1.9.1


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

* [PATCH 2/3] usb: renesas_usbhs: clear the BRDYSTS in usbhsg_ep_enable()
  2016-08-08 12:50 [PATCH 0/3] usb: renesas_usbhs: fix the driver for v4.8 Yoshihiro Shimoda
  2016-08-08 12:50 ` [PATCH 1/3] usb: renesas_usbhs: Fix receiving data corrupt on R-Car Gen3 with dmac Yoshihiro Shimoda
@ 2016-08-08 12:50 ` Yoshihiro Shimoda
  2016-08-08 12:50 ` [PATCH 3/3] usb: renesas_usbhs: Use dmac only if the pipe type is bulk Yoshihiro Shimoda
  2 siblings, 0 replies; 4+ messages in thread
From: Yoshihiro Shimoda @ 2016-08-08 12:50 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, linux-usb, linux-renesas-soc, stable, Yoshihiro Shimoda

This patch fixes an issue that unexpected BRDY interruption happens
when the usb_ep_{enable,disable}() are called with different direction.
In this case, the driver will cause the following message:

 renesas_usbhs e6590000.usb: irq_ready run_error 1 : -16

This issue causes the followings:
 1) A pipe is enabled as transmission
 2) The pipe sent a data
 3) The pipe is disabled and re-enabled as reception.
 4) The pipe got a queue

Since the driver doesn't clear the BRDYSTS flags after 2) above, the issue
happens. If we add such clearing the flags into the driver, the code will
become complicate. So, this patch clears the BRDYSTS flag of reception in
usbhsg_ep_enable() to avoid complicate.

Cc: <stable@vger.kernel.org> # v4.1+ (usbhs_xxxsts_clear() is needed)
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/usb/renesas_usbhs/mod_gadget.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c
index 50f3363..92bc83b 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -617,10 +617,13 @@ static int usbhsg_ep_enable(struct usb_ep *ep,
 		 * use dmaengine if possible.
 		 * It will use pio handler if impossible.
 		 */
-		if (usb_endpoint_dir_in(desc))
+		if (usb_endpoint_dir_in(desc)) {
 			pipe->handler = &usbhs_fifo_dma_push_handler;
-		else
+		} else {
 			pipe->handler = &usbhs_fifo_dma_pop_handler;
+			usbhs_xxxsts_clear(priv, BRDYSTS,
+					   usbhs_pipe_number(pipe));
+		}
 
 		ret = 0;
 	}
-- 
1.9.1


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

* [PATCH 3/3] usb: renesas_usbhs: Use dmac only if the pipe type is bulk
  2016-08-08 12:50 [PATCH 0/3] usb: renesas_usbhs: fix the driver for v4.8 Yoshihiro Shimoda
  2016-08-08 12:50 ` [PATCH 1/3] usb: renesas_usbhs: Fix receiving data corrupt on R-Car Gen3 with dmac Yoshihiro Shimoda
  2016-08-08 12:50 ` [PATCH 2/3] usb: renesas_usbhs: clear the BRDYSTS in usbhsg_ep_enable() Yoshihiro Shimoda
@ 2016-08-08 12:50 ` Yoshihiro Shimoda
  2 siblings, 0 replies; 4+ messages in thread
From: Yoshihiro Shimoda @ 2016-08-08 12:50 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, linux-usb, linux-renesas-soc, stable, Yoshihiro Shimoda

This patch fixes an issue that isochronous transfer's data is possible to
be lost as a workaround. Since this driver uses a workqueue to start
the dmac, the transfer is possible to be delayed when system load is high.

Fixes: 6e4b74e4690d ("usb: renesas: fix scheduling in atomic context bug")
Cc: <stable@vger.kernel.org> # v3.4+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/usb/renesas_usbhs/fifo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index 280ed5f..857e783 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -871,7 +871,7 @@ static int usbhsf_dma_prepare_push(struct usbhs_pkt *pkt, int *is_done)
 
 	/* use PIO if packet is less than pio_dma_border or pipe is DCP */
 	if ((len < usbhs_get_dparam(priv, pio_dma_border)) ||
-	    usbhs_pipe_is_dcp(pipe))
+	    usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_ISOC))
 		goto usbhsf_pio_prepare_push;
 
 	/* check data length if this driver don't use USB-DMAC */
@@ -976,7 +976,7 @@ static int usbhsf_dma_prepare_pop_with_usb_dmac(struct usbhs_pkt *pkt,
 
 	/* use PIO if packet is less than pio_dma_border or pipe is DCP */
 	if ((pkt->length < usbhs_get_dparam(priv, pio_dma_border)) ||
-	    usbhs_pipe_is_dcp(pipe))
+	    usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_ISOC))
 		goto usbhsf_pio_prepare_pop;
 
 	fifo = usbhsf_get_dma_fifo(priv, pkt);
-- 
1.9.1


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

end of thread, other threads:[~2016-08-08 12:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-08 12:50 [PATCH 0/3] usb: renesas_usbhs: fix the driver for v4.8 Yoshihiro Shimoda
2016-08-08 12:50 ` [PATCH 1/3] usb: renesas_usbhs: Fix receiving data corrupt on R-Car Gen3 with dmac Yoshihiro Shimoda
2016-08-08 12:50 ` [PATCH 2/3] usb: renesas_usbhs: clear the BRDYSTS in usbhsg_ep_enable() Yoshihiro Shimoda
2016-08-08 12:50 ` [PATCH 3/3] usb: renesas_usbhs: Use dmac only if the pipe type is bulk Yoshihiro Shimoda

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.