From: Sascha Hauer <s.hauer@pengutronix.de>
To: BAREBOX <barebox@lists.infradead.org>
Cc: Sascha Hauer <sascha@saschahauer.de>,
"Claude Sonnet 4.6" <noreply@anthropic.com>
Subject: [PATCH 2/2] usb: dwc2: fix data toggle reset direction on ClearFeature(ENDPOINT_HALT)
Date: Mon, 20 Apr 2026 13:20:54 +0200 [thread overview]
Message-ID: <20260420-usb-dwc2-usb-c-stick-v1-2-c86f733f24f8@pengutronix.de> (raw)
In-Reply-To: <20260420-usb-dwc2-usb-c-stick-v1-0-c86f733f24f8@pengutronix.de>
From: Sascha Hauer <sascha@saschahauer.de>
dwc2_submit_control_msg() resets the data toggle after a successful
ClearFeature(ENDPOINT_HALT) request. It passes usb_pipein(pipe) as the
direction to dwc2_endpoint_reset(), but pipe is always the control-out
pipe used to send the request, so usb_pipein() always returns 0 (OUT).
As a result, clearing an IN endpoint halt resets the OUT toggle instead
of the IN toggle, leaving the IN data toggle in an incorrect state for
subsequent transfers.
Fix by extracting the direction from the endpoint address in setup->index
(wIndex), where bit 7 is the direction flag per USB 2.0 section 9.3.4.
Fixes: 446bcf875395 ("usb: dwc2: host: Fix toggle reset")
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Sascha Hauer <sascha@saschahauer.de>
---
drivers/usb/dwc2/host.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/dwc2/host.c b/drivers/usb/dwc2/host.c
index ddad51c882..2be2666574 100644
--- a/drivers/usb/dwc2/host.c
+++ b/drivers/usb/dwc2/host.c
@@ -401,8 +401,8 @@ static int dwc2_submit_control_msg(struct usb_device *udev,
* ClearFeature(ENDPOINT_HALT) request always results
* in the data toggle being reinitialized to DATA0.
*/
- int ep = le16_to_cpu(setup->index) & 0xf;
- dwc2_endpoint_reset(dwc2, usb_pipein(pipe), devnum, ep);
+ int ep_addr = le16_to_cpu(setup->index);
+ dwc2_endpoint_reset(dwc2, ep_addr >> 7, devnum, ep_addr & 0xf);
}
udev->act_len = act_len;
--
2.47.3
prev parent reply other threads:[~2026-04-20 11:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-20 11:20 [PATCH 0/2] USB: dwc2: Fix handling NAK Sascha Hauer
2026-04-20 11:20 ` [PATCH 1/2] usb: dwc2: handle NAK when CHHLTD does not fire Sascha Hauer
2026-04-20 11:32 ` Ahmad Fatoum
2026-04-20 12:18 ` Sascha Hauer
2026-04-20 14:11 ` Ahmad Fatoum
2026-04-20 15:40 ` anis chali
2026-04-21 2:28 ` anis chali
2026-04-21 7:54 ` Sascha Hauer
2026-04-21 13:48 ` anis chali
2026-04-20 11:20 ` Sascha Hauer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260420-usb-dwc2-usb-c-stick-v1-2-c86f733f24f8@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=noreply@anthropic.com \
--cc=sascha@saschahauer.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox