All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] usb: dwc3: Fix TRB reclaim regression and clean up reclaim logic
@ 2025-06-24 10:53 Johannes Schneider
  2025-06-24 10:53 ` [PATCH v2 1/2] usb: dwc3: gadget: Fix TRB reclaim logic for short transfers and ZLPs Johannes Schneider
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Johannes Schneider @ 2025-06-24 10:53 UTC (permalink / raw)
  To: Thinh Nguyen, Greg Kroah-Hartman
  Cc: Pengutronix Kernel Team, linux-usb, linux-kernel, stable,
	bsp-development.geo, Johannes Schneider

Hoi,

This patch series fixes a subtle regression introduced in the recent
scatter-gather cleanup for the DWC3 USB gadget driver, and follows up
with two clean-up patches to simplify and clarify related logic.

Background:

Commit 61440628a4ff ("usb: dwc3: gadget: Cleanup SG handling") removed
some redundant state tracking in the DWC3 gadget driver, including how
scatter-gather TRBs are reclaimed after use. However, the reclaim logic
began relying on the TRB CHN (chain) bit to determine whether TRBs
belonged to a chain — which led to missed TRB reclamation in some
cases.

This broke userspace-facing protocols like MTP (Media Transfer Protocol)
when used via FunctionFS, causing incomplete transfers due to skipped
zero-length packets (ZLPs) or improperly reclaimed short TRBs.

The "offending" chunk from 61440628a4ff:
80                 ret = dwc3_gadget_ep_reclaim_completed_trb(dep, req,
81 -                               trb, event, status, true);
82 +                               trb, event, status,
83 +                               !!(trb->ctrl & DWC3_TRB_CTRL_CHN));

Patch 1 fixes the issue by ensuring the HWO bit is always cleared
on reclaimed TRBs, regardless of the CHN bit.

Patches 2 and 3 follow up with simplifications:
- Patch 2 removes the now-redundant `chain` argument to the reclaim function
- Patch 3 simplifies the logic in `dwc3_needs_extra_trb()` to make the conditions easier to read and maintain

All three patches have been tested on a imx8mp based hardware, with
userspace MTP (viveris/uMTP-Responder) over FunctionFS and resolve the
regression while preserving the recent cleanup work.

Signed-off-by: Johannes Schneider <johannes.schneider@leica-geosystems.com>
---
Changes in v2:
- dropped Patch 3, as it did change the logic
- CC to stable
- Link to v1: https://lore.kernel.org/r/20250621-dwc3-fix-gadget-mtp-v1-0-a45e6def71bb@leica-geosystems.com

---
Johannes Schneider (2):
      usb: dwc3: gadget: Fix TRB reclaim logic for short transfers and ZLPs
      usb: dwc3: gadget: Simplify TRB reclaim logic by removing redundant 'chain' argument

 drivers/usb/dwc3/gadget.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
---
base-commit: d0c22de9995b624f563bc5004d44ac2655712a56
change-id: 20250621-dwc3-fix-gadget-mtp-3c09a6ab84c6

Best regards,
-- 
Johannes Schneider <johannes.schneider@leica-geosystems.com>


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

end of thread, other threads:[~2025-06-24 11:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-24 10:53 [PATCH v2 0/2] usb: dwc3: Fix TRB reclaim regression and clean up reclaim logic Johannes Schneider
2025-06-24 10:53 ` [PATCH v2 1/2] usb: dwc3: gadget: Fix TRB reclaim logic for short transfers and ZLPs Johannes Schneider
2025-06-24 10:55   ` kernel test robot
2025-06-24 10:53 ` [PATCH v2 2/2] usb: dwc3: gadget: Simplify TRB reclaim logic by removing redundant 'chain' argument Johannes Schneider
2025-06-24 11:12 ` [PATCH v2 0/2] usb: dwc3: Fix TRB reclaim regression and clean up reclaim logic SCHNEIDER Johannes

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.