From 6c5c3f023db568233ffacb81f8374080710a1402 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Tue, 18 Oct 2011 18:00:26 +0300 Subject: [PATCH] --- yaml --- r: 280815 b: refs/heads/master c: 9cc9bcd5b3e8efa45accf2ccb59f13c8de85a0ce h: refs/heads/master i: 280813: ec77bde6466da10eaaa1a314bdafdd445c2d9f8d 280811: 10a6349a40fbd231a1a8c5103521e3ae59bffbb0 280807: 7ca663b0607724746d886524033b6fc7807636dd 280799: fbecc98576ddff37d40fcae96f32ce4d87da4bad v: v3 --- [refs] | 2 +- trunk/drivers/usb/dwc3/ep0.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index a287f65d9572..e5a605093f97 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 0b9fe32deece53c9bc6d1e6d17a85ef1eb2e294b +refs/heads/master: 9cc9bcd5b3e8efa45accf2ccb59f13c8de85a0ce diff --git a/trunk/drivers/usb/dwc3/ep0.c b/trunk/drivers/usb/dwc3/ep0.c index 24b447e40bc7..36482f45b3b1 100644 --- a/trunk/drivers/usb/dwc3/ep0.c +++ b/trunk/drivers/usb/dwc3/ep0.c @@ -733,6 +733,41 @@ static void dwc3_ep0_do_control_status(struct dwc3 *dwc, static void dwc3_ep0_xfernotready(struct dwc3 *dwc, const struct dwc3_event_depevt *event) { + /* + * This part is very tricky: If we has just handled + * XferNotReady(Setup) and we're now expecting a + * XferComplete but, instead, we receive another + * XferNotReady(Setup), we should STALL and restart + * the state machine. + * + * In all other cases, we just continue waiting + * for the XferComplete event. + * + * We are a little bit unsafe here because we're + * not trying to ensure that last event was, indeed, + * XferNotReady(Setup). + * + * Still, we don't expect any condition where that + * should happen and, even if it does, it would be + * another error condition. + */ + if (dwc->ep0_next_event == DWC3_EP0_COMPLETE) { + switch (event->status) { + case DEPEVT_STATUS_CONTROL_SETUP: + dev_vdbg(dwc->dev, "Unexpected XferNotReady(Setup)\n"); + dwc3_ep0_stall_and_restart(dwc); + break; + case DEPEVT_STATUS_CONTROL_DATA: + /* FALLTHROUGH */ + case DEPEVT_STATUS_CONTROL_STATUS: + /* FALLTHROUGH */ + default: + dev_vdbg(dwc->dev, "waiting for XferComplete\n"); + } + + return; + } + switch (event->status) { case DEPEVT_STATUS_CONTROL_SETUP: dev_vdbg(dwc->dev, "Control Setup\n");