[PATCH 3.2 020/101] usb: dwc3: gadget: skip Set/Clear Halt when invalid

From: Ben Hutchings
Date: Thu Jun 01 2017 - 13:03:15 EST


3.2.89-rc1 review patch. If anyone has any objections, please let me know.

------------------

From: Felipe Balbi <felipe.balbi@xxxxxxxxxxxxxxx>

commit ffb80fc672c3a7b6afd0cefcb1524fb99917b2f3 upstream.

At least macOS seems to be sending
ClearFeature(ENDPOINT_HALT) to endpoints which
aren't Halted. This makes DWC3's CLEARSTALL command
time out which causes several issues for the driver.

Instead, let's just return 0 and bail out early.

Signed-off-by: Felipe Balbi <felipe.balbi@xxxxxxxxxxxxxxx>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@xxxxxxxxxxxxxxx>
---
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -925,6 +925,9 @@ int __dwc3_gadget_ep_set_halt(struct dwc
memset(&params, 0x00, sizeof(params));

if (value) {
+ if (dep->flags & DWC3_EP_STALL)
+ return 0;
+
if (dep->number == 0 || dep->number == 1) {
/*
* Whenever EP0 is stalled, we will restart
@@ -943,6 +946,9 @@ int __dwc3_gadget_ep_set_halt(struct dwc
else
dep->flags |= DWC3_EP_STALL;
} else {
+ if (!(dep->flags & DWC3_EP_STALL))
+ return 0;
+
ret = dwc3_send_gadget_ep_cmd(dwc, dep->number,
DWC3_DEPCMD_CLEARSTALL, &params);
if (ret)