* [PATCH 3/4] usb: renesas_usbhs: fix the condition of is_done in usbhsf_dma_push_done
@ 2014-08-22 11:14 Yoshihiro Shimoda
2014-09-10 10:34 ` [PATCH 3/4] usb: renesas_usbhs: fix the timing of dcp_control_transfer_done Yoshihiro Shimoda
2014-09-10 13:50 ` Felipe Balbi
0 siblings, 2 replies; 3+ messages in thread
From: Yoshihiro Shimoda @ 2014-08-22 11:14 UTC (permalink / raw)
To: linux-sh
This patch fixes the condition of is_done in usbhsf_dma_push_done().
This function will be called after a transmission finished by DMAC.
So, the function should check if the transmission packet is short packet
or not. Also the function should call try_run to send the zero packet
by the pio handler if the "*is_done" is not set. Otherwize, the
transaction will not finish if a gadget driver sets the "zero" flag
in a transmission.
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
drivers/usb/renesas_usbhs/fifo.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index 3efece3..1564829 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -889,16 +889,29 @@ usbhsf_pio_prepare_push:
static int usbhsf_dma_push_done(struct usbhs_pkt *pkt, int *is_done)
{
struct usbhs_pipe *pipe = pkt->pipe;
+ int is_short = pkt->trans % usbhs_pipe_get_maxpacket(pipe);
- pkt->actual = pkt->trans;
+ pkt->actual += pkt->trans;
+
+ if (pkt->actual < pkt->length)
+ *is_done = 0; /* there are remainder data */
+ else if (is_short)
+ *is_done = 1; /* short packet */
+ else
+ *is_done = !pkt->zero; /* send zero packet? */
- *is_done = !pkt->zero; /* send zero packet ? */
usbhs_pipe_running(pipe, !*is_done);
usbhsf_dma_stop(pipe, pipe->fifo);
usbhsf_dma_unmap(pkt);
usbhsf_fifo_unselect(pipe, pipe->fifo);
+ if (!*is_done) {
+ /* change handler to PIO */
+ pkt->handler = &usbhs_fifo_pio_push_handler;
+ return pkt->handler->try_run(pkt, is_done);
+ }
+
return 0;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 3/4] usb: renesas_usbhs: fix the timing of dcp_control_transfer_done
2014-08-22 11:14 [PATCH 3/4] usb: renesas_usbhs: fix the condition of is_done in usbhsf_dma_push_done Yoshihiro Shimoda
@ 2014-09-10 10:34 ` Yoshihiro Shimoda
2014-09-10 13:50 ` Felipe Balbi
1 sibling, 0 replies; 3+ messages in thread
From: Yoshihiro Shimoda @ 2014-09-10 10:34 UTC (permalink / raw)
To: linux-sh
According to the datasheet, this driver should clear the INTSTS0.CTRT
bit before this controller detects the next stage transition. Otherwise,
the driver may not be able to clear the bit after the controller went to
the next stage transition. After that, the driver will not be able to
clear the INTSTS0.VALID, and a usb control transfer will not finish
finally.
If we use the testusb tool, it is easy to reproduce this issue:
# testusb -a -t 10
Since the previous code handled a data stage and a status stage in
the usbhsf_pio_try_push(), it may not clear the INTSTS0.CTRT at the
right timing.
So, this patch changes the timing of usbhs_dcp_control_transfer_done()
to the usbhsg_irq_ctrl_stage().
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
drivers/usb/renesas_usbhs/fifo.c | 16 ----------------
drivers/usb/renesas_usbhs/mod_gadget.c | 3 +++
2 files changed, 3 insertions(+), 16 deletions(-)
diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index b0c97a3..0e07925 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -577,14 +577,6 @@ static int usbhsf_pio_try_push(struct usbhs_pkt *pkt, int *is_done)
usbhs_pipe_number(pipe),
pkt->length, pkt->actual, *is_done, pkt->zero);
- /*
- * Transmission end
- */
- if (*is_done) {
- if (usbhs_pipe_is_dcp(pipe))
- usbhs_dcp_control_transfer_done(pipe);
- }
-
usbhsf_fifo_unselect(pipe, fifo);
return 0;
@@ -722,14 +714,6 @@ usbhs_fifo_read_end:
usbhs_pipe_number(pipe),
pkt->length, pkt->actual, *is_done, pkt->zero);
- /*
- * Transmission end
- */
- if (*is_done) {
- if (usbhs_pipe_is_dcp(pipe))
- usbhs_dcp_control_transfer_done(pipe);
- }
-
usbhs_fifo_read_busy:
usbhsf_fifo_unselect(pipe, fifo);
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c
index b80c802..ba890c1 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -486,6 +486,9 @@ static int usbhsg_irq_ctrl_stage(struct usbhs_priv *priv,
case NODATA_STATUS_STAGE:
pipe->handler = &usbhs_ctrl_stage_end_handler;
break;
+ case READ_STATUS_STAGE:
+ case WRITE_STATUS_STAGE:
+ usbhs_dcp_control_transfer_done(pipe);
default:
return ret;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 3/4] usb: renesas_usbhs: fix the timing of dcp_control_transfer_done
2014-08-22 11:14 [PATCH 3/4] usb: renesas_usbhs: fix the condition of is_done in usbhsf_dma_push_done Yoshihiro Shimoda
2014-09-10 10:34 ` [PATCH 3/4] usb: renesas_usbhs: fix the timing of dcp_control_transfer_done Yoshihiro Shimoda
@ 2014-09-10 13:50 ` Felipe Balbi
1 sibling, 0 replies; 3+ messages in thread
From: Felipe Balbi @ 2014-09-10 13:50 UTC (permalink / raw)
To: linux-sh
[-- Attachment #1: Type: text/plain, Size: 965 bytes --]
On Wed, Sep 10, 2014 at 07:34:05PM +0900, Yoshihiro Shimoda wrote:
> According to the datasheet, this driver should clear the INTSTS0.CTRT
> bit before this controller detects the next stage transition. Otherwise,
> the driver may not be able to clear the bit after the controller went to
> the next stage transition. After that, the driver will not be able to
> clear the INTSTS0.VALID, and a usb control transfer will not finish
> finally.
>
> If we use the testusb tool, it is easy to reproduce this issue:
>
> # testusb -a -t 10
>
> Since the previous code handled a data stage and a status stage in
> the usbhsf_pio_try_push(), it may not clear the INTSTS0.CTRT at the
> right timing.
> So, this patch changes the timing of usbhs_dcp_control_transfer_done()
> to the usbhsg_irq_ctrl_stage().
>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
which commit does this fix ? Do we need to Cc stable ?
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-09-10 13:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-22 11:14 [PATCH 3/4] usb: renesas_usbhs: fix the condition of is_done in usbhsf_dma_push_done Yoshihiro Shimoda
2014-09-10 10:34 ` [PATCH 3/4] usb: renesas_usbhs: fix the timing of dcp_control_transfer_done Yoshihiro Shimoda
2014-09-10 13:50 ` Felipe Balbi
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).