Skip to content

Commit 80e0839

Browse files
js731cagregkh
authored andcommitted
usb: dwc3: gadget: Fix TRB reclaim logic for short transfers and ZLPs
Commit 96c7bf8f6b3e ("usb: dwc3: gadget: Cleanup SG handling") updated the TRB reclaim path to use the TRB CHN (Chain) bit to determine whether a TRB was part of a chain. However, this inadvertently changed the behavior of reclaiming the final TRB in some scatter-gather or short transfer cases. In particular, if the final TRB did not have the CHN bit set, the cleanup path could incorrectly skip clearing the HWO (Hardware Own) bit, leaving stale TRBs in the ring. This resulted in broken data transfer completions in userspace, notably for MTP over FunctionFS. Fix this by unconditionally clearing the HWO bit during TRB reclaim, regardless of the CHN bit state. This restores correct behavior especially for transfers that require ZLPs or end on non-CHN TRBs. Fixes: 6144062 ("usb: dwc3: gadget: Cleanup SG handling") Signed-off-by: Johannes Schneider <[email protected]> Acked-by: Thinh Nguyen <[email protected]> Cc: stable <[email protected]> Link: https://lore.kernel.org/r/AM8PR06MB7521A29A8863C838B54987B6BC7BA@AM8PR06MB7521.eurprd06.prod.outlook.com Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a49e1e2 commit 80e0839

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/usb/dwc3/gadget.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3516,7 +3516,7 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep,
35163516
* We're going to do that here to avoid problems of HW trying
35173517
* to use bogus TRBs for transfers.
35183518
*/
3519-
if (chain && (trb->ctrl & DWC3_TRB_CTRL_HWO))
3519+
if (trb->ctrl & DWC3_TRB_CTRL_HWO)
35203520
trb->ctrl &= ~DWC3_TRB_CTRL_HWO;
35213521

35223522
/*

0 commit comments

Comments
 (0)