Re: [PATCH 2/3] usb: dwc3: gadget: Simplify TRB reclaim logic by removing redundant 'chain' argument
From: Thinh Nguyen
Date: Mon Jun 23 2025 - 18:44:45 EST
On Sat, Jun 21, 2025, Johannes Schneider wrote:
> Now that the TRB reclaim logic always inspects the TRB's CHN (Chain) bit
> directly to determine whether a TRB is part of a chain, the explicit
> 'chain' parameter passed into dwc3_gadget_ep_reclaim_completed_trb()
> is no longer necessary.
>
> This cleanup simplifies the reclaim code by avoiding duplication of
> chain state tracking, and makes the reclaim logic rely entirely on the
> hardware descriptor flags — which are already present and accurate at
> this stage.
>
> No functional changes intended.
>
> Signed-off-by: Johannes Schneider <johannes.schneider@xxxxxxxxxxxxxxxxxxxx>
> ---
> drivers/usb/dwc3/gadget.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 99fbd29d8f46d30df558ceb23d2afe7187b4244c..a4a2bf273f943fa112f49979297023a732e0af2e 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -3497,7 +3497,7 @@ static void dwc3_gadget_free_endpoints(struct dwc3 *dwc)
>
> static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep,
> struct dwc3_request *req, struct dwc3_trb *trb,
> - const struct dwc3_event_depevt *event, int status, int chain)
> + const struct dwc3_event_depevt *event, int status)
> {
> unsigned int count;
>
> @@ -3549,7 +3549,8 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep,
> if ((trb->ctrl & DWC3_TRB_CTRL_HWO) && status != -ESHUTDOWN)
> return 1;
>
> - if (event->status & DEPEVT_STATUS_SHORT && !chain)
> + if (event->status & DEPEVT_STATUS_SHORT &&
> + !(trb->ctrl & DWC3_TRB_CTRL_CHN))
> return 1;
>
> if ((trb->ctrl & DWC3_TRB_CTRL_ISP_IMI) &&
> @@ -3576,8 +3577,7 @@ static int dwc3_gadget_ep_reclaim_trb_sg(struct dwc3_ep *dep,
> trb = &dep->trb_pool[dep->trb_dequeue];
>
> ret = dwc3_gadget_ep_reclaim_completed_trb(dep, req,
> - trb, event, status,
> - !!(trb->ctrl & DWC3_TRB_CTRL_CHN));
> + trb, event, status);
> if (ret)
> break;
> }
>
> --
> 2.34.1
>
Acked-by: Thinh Nguyen <Thinh.Nguyen@xxxxxxxxxxxx>
Note: if you want the fix [Patch 1/3] to be picked up early, then it needs to
be separated from this series. Otherwise this series won't be picked up
until the next rc1 release.
Thanks,
Thinh