[PATCH] USB: DWC3: Restart setup phase correctly if gadget halts the transfer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If a gadget halts control transfer stage, then that stage is stalled,
but core should be ready to receive next setup packet.

This patch restarts control transfer along with other software correct
flag settings.

Signed-off-by: Pratyush Anand <pratyush.anand@xxxxxx>
Signed-off-by: Michel Sanches <michel.sanches@xxxxxx>
---
 drivers/usb/dwc3/gadget.c |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 1b29b6a..c60cb48 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1234,15 +1234,6 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value)
 	memset(&params, 0x00, sizeof(params));
 
 	if (value) {
-		if (dep->number == 0 || dep->number == 1) {
-			/*
-			 * Whenever EP0 is stalled, we will restart
-			 * the state machine, thus moving back to
-			 * Setup Phase
-			 */
-			dwc->ep0state = EP0_SETUP_PHASE;
-		}
-
 		ret = dwc3_send_gadget_ep_cmd(dwc, dep->number,
 			DWC3_DEPCMD_SETSTALL, &params);
 		if (ret)
@@ -1251,6 +1242,19 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value)
 					dep->name);
 		else
 			dep->flags |= DWC3_EP_STALL;
+
+		if (dep->number == 0 || dep->number == 1) {
+			/*
+			 * Whenever EP0 is stalled, we will restart
+			 * the state machine, thus moving back to
+			 * Setup Phase
+			 * Also enable core to receive and generate
+			 * event for next setup packet.
+			 */
+			dwc->ep0state = EP0_SETUP_PHASE;
+			dep->flags = DWC3_EP_ENABLED;
+			dwc3_ep0_out_start(dwc);
+		}
 	} else {
 		if (dep->flags & DWC3_EP_WEDGE)
 			return 0;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux