Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/2] usb: dwc3: gadget: Fix END_TRANSFER handling
@ 2019-11-27 21:10 Thinh Nguyen
  2019-11-27 21:10 ` [PATCH 1/2] usb: dwc3: gadget: Clear started flag for non-IOC Thinh Nguyen
  2019-11-27 21:10 ` [PATCH 2/2] usb: dwc3: ep0: Clear started flag on completion Thinh Nguyen
  0 siblings, 2 replies; 3+ messages in thread
From: Thinh Nguyen @ 2019-11-27 21:10 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Thinh Nguyen, linux-usb
  Cc: John Youn, stable

This patch series adds a couple of fixes related to handling
END_TRANSFER command.



Thinh Nguyen (2):
  usb: dwc3: gadget: Clear started flag for non-IOC
  usb: dwc3: ep0: Clear started flag on completion

 drivers/usb/dwc3/ep0.c    | 8 ++++++++
 drivers/usb/dwc3/gadget.c | 3 +++
 2 files changed, 11 insertions(+)

-- 
2.11.0


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

* [PATCH 1/2] usb: dwc3: gadget: Clear started flag for non-IOC
  2019-11-27 21:10 [PATCH 0/2] usb: dwc3: gadget: Fix END_TRANSFER handling Thinh Nguyen
@ 2019-11-27 21:10 ` Thinh Nguyen
  2019-11-27 21:10 ` [PATCH 2/2] usb: dwc3: ep0: Clear started flag on completion Thinh Nguyen
  1 sibling, 0 replies; 3+ messages in thread
From: Thinh Nguyen @ 2019-11-27 21:10 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Thinh Nguyen, linux-usb
  Cc: John Youn, stable

Normally the END_TRANSFER command completion handler will clear the
DWC3_EP_TRANSFER_STARTED flag. However, if the command was sent without
interrupt on completion, then the flag will not be cleared. Make sure to
clear the flag in this case.

Cc: stable@vger.kernel.org
Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
---
 drivers/usb/dwc3/gadget.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 7f97856e6b20..95a0b2e7ecea 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2716,6 +2716,9 @@ static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force,
 	WARN_ON_ONCE(ret);
 	dep->resource_index = 0;
 
+	if (!interrupt)
+		dep->flags &= ~DWC3_EP_TRANSFER_STARTED;
+
 	if (dwc3_is_usb31(dwc) || dwc->revision < DWC3_REVISION_310A)
 		udelay(100);
 }
-- 
2.11.0


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

* [PATCH 2/2] usb: dwc3: ep0: Clear started flag on completion
  2019-11-27 21:10 [PATCH 0/2] usb: dwc3: gadget: Fix END_TRANSFER handling Thinh Nguyen
  2019-11-27 21:10 ` [PATCH 1/2] usb: dwc3: gadget: Clear started flag for non-IOC Thinh Nguyen
@ 2019-11-27 21:10 ` Thinh Nguyen
  1 sibling, 0 replies; 3+ messages in thread
From: Thinh Nguyen @ 2019-11-27 21:10 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Thinh Nguyen, linux-usb
  Cc: John Youn, stable

Clear ep0's DWC3_EP_TRANSFER_STARTED flag if the END_TRANSFER command is
completed. Otherwise, we can't start control transfer again after
END_TRANSFER.

Cc: stable@vger.kernel.org
Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
---
 drivers/usb/dwc3/ep0.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 3996b9c4ff8d..fd1b100d2927 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -1117,6 +1117,9 @@ static void dwc3_ep0_xfernotready(struct dwc3 *dwc,
 void dwc3_ep0_interrupt(struct dwc3 *dwc,
 		const struct dwc3_event_depevt *event)
 {
+	struct dwc3_ep	*dep = dwc->eps[event->endpoint_number];
+	u8		cmd;
+
 	switch (event->endpoint_event) {
 	case DWC3_DEPEVT_XFERCOMPLETE:
 		dwc3_ep0_xfer_complete(dwc, event);
@@ -1129,7 +1132,12 @@ void dwc3_ep0_interrupt(struct dwc3 *dwc,
 	case DWC3_DEPEVT_XFERINPROGRESS:
 	case DWC3_DEPEVT_RXTXFIFOEVT:
 	case DWC3_DEPEVT_STREAMEVT:
+		break;
 	case DWC3_DEPEVT_EPCMDCMPLT:
+		cmd = DEPEVT_PARAMETER_CMD(event->parameters);
+
+		if (cmd == DWC3_DEPCMD_ENDTRANSFER)
+			dep->flags &= ~DWC3_EP_TRANSFER_STARTED;
 		break;
 	}
 }
-- 
2.11.0


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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-27 21:10 [PATCH 0/2] usb: dwc3: gadget: Fix END_TRANSFER handling Thinh Nguyen
2019-11-27 21:10 ` [PATCH 1/2] usb: dwc3: gadget: Clear started flag for non-IOC Thinh Nguyen
2019-11-27 21:10 ` [PATCH 2/2] usb: dwc3: ep0: Clear started flag on completion Thinh Nguyen

Linux-USB Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \
		linux-usb@vger.kernel.org
	public-inbox-index linux-usb

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git