The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 1/1] usb: dwc3: ep0: skip CLEAR_HALT on non-stalled endpoints
@ 2026-07-27  9:58 Jiazi Liu
  2026-08-04 23:17 ` Thinh Nguyen
  0 siblings, 1 reply; 2+ messages in thread
From: Jiazi Liu @ 2026-07-27  9:58 UTC (permalink / raw)
  To: Thinh.Nguyen; +Cc: gregkh, linux-usb, linux-kernel, Jiazi Liu

Mac hosts send CLEAR_FEATURE(HALT) to all endpoints immediately after
SET_CONFIGURATION, even when no endpoint is actually stalled. This
causes __dwc3_gadget_ep_set_halt() to be called unnecessarily, which
can disrupt ongoing transfers on active endpoints.

Fix this by checking the DWC3_EP_STALL flag before processing
CLEAR_FEATURE(HALT). If the endpoint is not stalled, simply acknowledge
the host request without calling into the endpoint halt path.

Signed-off-by: Jiazi Liu <liujiazi@amazon.com>
---
 drivers/usb/dwc3/ep0.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index bfe616194dfa..b577a1b764fc 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -554,6 +554,9 @@ static int dwc3_ep0_handle_endpoint(struct dwc3 *dwc,
 		if (set == 0 && (dep->flags & DWC3_EP_WEDGE))
 			break;
 
+		if (set == 0 && !(dep->flags & DWC3_EP_STALL))
+			break;
+
 		ret = __dwc3_gadget_ep_set_halt(dep, set, true);
 		if (ret)
 			return -EINVAL;
-- 
2.50.1 (Apple Git-155)


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

* Re: [PATCH 1/1] usb: dwc3: ep0: skip CLEAR_HALT on non-stalled endpoints
  2026-07-27  9:58 [PATCH 1/1] usb: dwc3: ep0: skip CLEAR_HALT on non-stalled endpoints Jiazi Liu
@ 2026-08-04 23:17 ` Thinh Nguyen
  0 siblings, 0 replies; 2+ messages in thread
From: Thinh Nguyen @ 2026-08-04 23:17 UTC (permalink / raw)
  To: Jiazi Liu
  Cc: Thinh Nguyen, gregkh@linuxfoundation.org,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jiazi Liu

On Mon, Jul 27, 2026, Jiazi Liu wrote:
> Mac hosts send CLEAR_FEATURE(HALT) to all endpoints immediately after
> SET_CONFIGURATION, even when no endpoint is actually stalled. This
> causes __dwc3_gadget_ep_set_halt() to be called unnecessarily, which
> can disrupt ongoing transfers on active endpoints.

Can you provide more details on what disruptions you saw and on what
endpoints (e.g. transfers on endpoints not targeted by this request?)

> 
> Fix this by checking the DWC3_EP_STALL flag before processing
> CLEAR_FEATURE(HALT). If the endpoint is not stalled, simply acknowledge
> the host request without calling into the endpoint halt path.

No. We should not do this. Host does ClEAR_FEATURE(HALT) sometime to
reset the packet sequence number for various reasons such as error
recovery. If we don't also perform set_halt from gadget side, then the
data sequence will potentially be out of sync.

BR,
Thinh

> 
> Signed-off-by: Jiazi Liu <liujiazi@amazon.com>
> ---
>  drivers/usb/dwc3/ep0.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
> index bfe616194dfa..b577a1b764fc 100644
> --- a/drivers/usb/dwc3/ep0.c
> +++ b/drivers/usb/dwc3/ep0.c
> @@ -554,6 +554,9 @@ static int dwc3_ep0_handle_endpoint(struct dwc3 *dwc,
>  		if (set == 0 && (dep->flags & DWC3_EP_WEDGE))
>  			break;
>  
> +		if (set == 0 && !(dep->flags & DWC3_EP_STALL))
> +			break;
> +
>  		ret = __dwc3_gadget_ep_set_halt(dep, set, true);
>  		if (ret)
>  			return -EINVAL;
> -- 
> 2.50.1 (Apple Git-155)
> 

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

end of thread, other threads:[~2026-08-04 23:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-27  9:58 [PATCH 1/1] usb: dwc3: ep0: skip CLEAR_HALT on non-stalled endpoints Jiazi Liu
2026-08-04 23:17 ` Thinh Nguyen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox