From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Johannes Schneider <johannes.schneider@leica-geosystems.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"bsp-development.geo@leica-geosystems.com"
<bsp-development.geo@leica-geosystems.com>
Subject: Re: [PATCH 1/3] usb: dwc3: gadget: Fix TRB reclaim logic for short transfers and ZLPs
Date: Mon, 23 Jun 2025 22:41:27 +0000 [thread overview]
Message-ID: <20250623224122.46m2hslqgllncjsi@synopsys.com> (raw)
In-Reply-To: <20250621-dwc3-fix-gadget-mtp-v1-1-a45e6def71bb@leica-geosystems.com>
On Sat, Jun 21, 2025, Johannes Schneider wrote:
> Commit 61440628a4ff ("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: 61440628a4ff ("usb: dwc3: gadget: Cleanup SG handling")
> Signed-off-by: Johannes Schneider <johannes.schneider@leica-geosystems.com>
> ---
> drivers/usb/dwc3/gadget.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 321361288935db4b773cd06235a16670a6adda1a..99fbd29d8f46d30df558ceb23d2afe7187b4244c 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -3516,7 +3516,7 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep,
> * We're going to do that here to avoid problems of HW trying
> * to use bogus TRBs for transfers.
> */
> - if (chain && (trb->ctrl & DWC3_TRB_CTRL_HWO))
> + if (trb->ctrl & DWC3_TRB_CTRL_HWO)
> trb->ctrl &= ~DWC3_TRB_CTRL_HWO;
>
> /*
>
> --
> 2.34.1
>
Thanks for the catch. Please also Cc stable.
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
BR,,
Thinh
next prev parent reply other threads:[~2025-06-23 22:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-21 19:07 [PATCH 0/3] usb: dwc3: Fix TRB reclaim regression and clean up reclaim logic Johannes Schneider
2025-06-21 19:07 ` [PATCH 1/3] usb: dwc3: gadget: Fix TRB reclaim logic for short transfers and ZLPs Johannes Schneider
2025-06-23 22:41 ` Thinh Nguyen [this message]
2025-06-25 7:49 ` [PATCH v3] " SCHNEIDER Johannes
2025-06-28 15:18 ` Greg Kroah-Hartman
2025-06-28 15:19 ` Greg Kroah-Hartman
2025-06-21 19:07 ` [PATCH 2/3] usb: dwc3: gadget: Simplify TRB reclaim logic by removing redundant 'chain' argument Johannes Schneider
2025-06-23 22:43 ` Thinh Nguyen
2025-06-25 7:53 ` [PATCH v3] " SCHNEIDER Johannes
2025-06-28 15:23 ` Greg Kroah-Hartman
2025-06-29 8:45 ` SCHNEIDER Johannes
2025-06-29 9:06 ` Greg Kroah-Hartman
2025-06-21 19:07 ` [PATCH 3/3] usb: dwc3: gadget: Simplify logic in dwc3_needs_extra_trb() Johannes Schneider
2025-06-23 22:31 ` Thinh Nguyen
2025-06-24 10:47 ` SCHNEIDER Johannes
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=20250623224122.46m2hslqgllncjsi@synopsys.com \
--to=thinh.nguyen@synopsys.com \
--cc=bsp-development.geo@leica-geosystems.com \
--cc=gregkh@linuxfoundation.org \
--cc=johannes.schneider@leica-geosystems.com \
--cc=kernel@pengutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/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