FAILED: patch "[PATCH] usb: dwc3: clear forceRM when issuing EndTransfer" failed to apply to 6.12-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x b58e6200450d350314db0ecda7d6d1bde3281e80
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090819-kilometer-itunes-d755@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From b58e6200450d350314db0ecda7d6d1bde3281e80 Mon Sep 17 00:00:00 2001
From: Elson Serrao <[email protected]>
Date: Thu, 13 Aug 2026 08:14:56 -0700
Subject: [PATCH] usb: dwc3: clear forceRM when issuing EndTransfer
The forceRM bit of the DEPCMD register controls the behavior of the EndTransfer command used to stop an active transfer. Older DWC3 programming guide revisions recommended setting forceRM=1 when issuing EndTransfer. Newer programming guide revisions recommend issuing EndTransfer with forceRM cleared.
With forceRM=1 on DWC_usb31 v2.00a and v2.10a controllers, a transfer aborted through the ep_dequeue path was observed to remain active after EndTransfer completion. A subsequent StartTransfer issued on the same endpoint triggered writes associated with the aborted transfer. This resulted in an SMMU fault because the transfer buffer had already been unmapped during EndTransfer command-completion cleanup.
Using forceRM=0 eliminates the issue. Although older DWC3 programming guide revisions recommended setting forceRM=1, no issues are known from using forceRM=0. Clear forceRM when issuing EndTransfer to provide consistent EndTransfer behavior and align with newer programming guide recommendations.
drivers/usb/dwc3/ep0.c +1 -1
@@ -304,7 +304,7 @@ void dwc3_ep0_out_start(struct dwc3 *dwc) dwc3_ep->flags &= ~DWC3_EP_DELAY_STOP ;if (dwc->connected) -dwc3_stop_active_transfer (dwc3_ep, true, true); +dwc3_stop_active_transfer (dwc3_ep, false, true);else dwc3_remove_requests (dwc, dwc3_ep, -ESHUTDOWN ); }
drivers/usb/dwc3/gadget.c +13 -8
@@ -1004,7 +1004,7 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, unsigned int action)* controller to generate an ERDY to initiate the * stream. */ -dwc3_stop_active_transfer (dep, true, true); +dwc3_stop_active_transfer (dep, false, true);/* * All stream eps will reinitiate stream on NoStream
@@ -1032,7 +1032,7 @@ void dwc3_remove_requests(struct dwc3 *dwc, struct dwc3_ep *dep, int status) {struct dwc3_request *req; -dwc3_stop_active_transfer (dep, true, false); +dwc3_stop_active_transfer (dep, false, false);/* If endxfer is delayed, avoid unmapping requests */ if (dep->flags &DWC3_EP_DELAY_STOP )
@@ -1720,7 +1720,7 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep)if (ret == -EAGAIN )return ret; -dwc3_stop_active_transfer (dep, true, true); +dwc3_stop_active_transfer (dep, false, true);list_for_each_entry_safe (req, tmp, &dep->started_list, list)dwc3_gadget_move_cancelled_request (req,DWC3_REQUEST_STATUS_DEQUEUED );
@@ -1757,6 +1757,11 @@ static int __dwc3_gadget_get_frame(struct dwc3 *dwc)* the controller won't update the TRB progress on command * completion. It also won't clear the HWO bit in the TRB. * The command will also not complete immediately in that case. +* +* Older programming guide revisions recommended setting ForceRM to 1 +* when ending a transfer. Newer programming guide revisions now +* recommend keeping ForceRM cleared, and TRBs are properly updated +* on command completion. */ static int __dwc3_stop_active_transfer (struct dwc3_ep *dep,bool force,bool interrupt) {
@@ -1882,7 +1887,7 @@ static int dwc3_gadget_start_isoc_quirk(struct dwc3_ep *dep)* to wait for the next XferNotReady to test the command again */ if (cmd_status ==0 ) { -dwc3_stop_active_transfer (dep, true, true); +dwc3_stop_active_transfer (dep, false, true);return 0 ; } }
@@ -2165,7 +2170,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,struct dwc3_request *t;/* wait until it is processed */ -dwc3_stop_active_transfer (dep, true, true); +dwc3_stop_active_transfer (dep, false, true);/* * Remove any started request if the transfer is
@@ -2242,7 +2247,7 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol)return 0 ; } -dwc3_stop_active_transfer (dep, true, true); +dwc3_stop_active_transfer (dep, false, true);list_for_each_entry_safe (req, tmp, &dep->started_list, list)dwc3_gadget_move_cancelled_request (req,DWC3_REQUEST_STATUS_STALLED );
@@ -3368,7 +3373,7 @@ static void dwc3_nostream_work(struct work_struct *work)dwc3_send_gadget_generic_command (dwc, cmd, dep->number); }else { dep->flags |=DWC3_EP_DELAY_START ; -dwc3_stop_active_transfer (dep, true, true); +dwc3_stop_active_transfer (dep, false, true);spin_unlock_irqrestore (&dwc->lock, flags);return ; }
@@ -3726,7 +3731,7 @@ static bool dwc3_gadget_endpoint_trbs_complete(struct dwc3_ep *dep,if (usb_endpoint_xfer_isoc (dep->endpoint.desc) &&list_empty (&dep->started_list) && (list_empty (&dep->pending_list) || status == -EXDEV )) -dwc3_stop_active_transfer (dep, true, true); +dwc3_stop_active_transfer (dep, false, true);else if (dwc3_gadget_ep_should_continue (dep))if (__dwc3_gadget_kick_transfer (dep) ==0 ) no_started_trb = false;
Sasha Levin
maintainerPATCH 1/2 usb: dwc3: gadget: Reinitiate stream for all host NoStream behavior
From: Thinh Nguyen <[email protected]>
[ Upstream commit dcfe437492e27d54f3ac491aed024da760f5c43c ]
There are too many different host behaviors when it comes to NoStream handling, and not everyone follows the USB and xHCI spec. The DWC3 driver attempts to do some guess work to interop with different hosts, but it can't cover everything. Let's keep it simple and treat every host the same: just retry on NoStream after a 100ms of no response delay. Note that some hosts cannot handle frequent retries. This may affect performance on certain defective hosts, but NoStream is a rare occurrence and interoperability is more important.
Stable-dep-of: b58e6200450d ("usb: dwc3: clear forceRM when issuing EndTransfer")
--- drivers/usb/dwc3/core.h | 3 +- drivers/usb/dwc3/gadget.c | 109 ++++++++++++++++++++------------------ 2 files changed, 59 insertions(+), 53 deletions(-)
drivers/usb/dwc3/core.h +2 -1
@@ -742,6 +742,7 @@ struct dwc3_event_buffer {*/ struct dwc3_ep {struct usb_ep endpoint; +struct delayed_work nostream_work;struct list_head cancelled_list;struct list_head pending_list;struct list_head started_list;
@@ -764,7 +765,7 @@ struct dwc3_ep {#define DWC3_EP_WAIT_TRANSFER_COMPLETE BIT(7)#define DWC3_EP_IGNORE_NEXT_NOSTREAM BIT(8)#define DWC3_EP_FORCE_RESTART_STREAM BIT(9) -#define DWC3_EP_FIRST_STREAM_PRIMED BIT(10) +#define DWC3_EP_STREAM_PRIMED BIT(10)#define DWC3_EP_PENDING_CLEAR_STALL BIT(11)#define DWC3_EP_TXFIFO_RESIZED BIT(12)#define DWC3_EP_DELAY_STOP BIT(13)
drivers/usb/dwc3/gadget.c +57 -52
143 lines not on this page · raw message
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/2 usb: dwc3: clear forceRM when issuing EndTransfer
From: Elson Serrao <[email protected]>
[ Upstream commit b58e6200450d350314db0ecda7d6d1bde3281e80 ]
The forceRM bit of the DEPCMD register controls the behavior of the EndTransfer command used to stop an active transfer. Older DWC3 programming guide revisions recommended setting forceRM=1 when issuing EndTransfer. Newer programming guide revisions recommend issuing EndTransfer with forceRM cleared.
With forceRM=1 on DWC_usb31 v2.00a and v2.10a controllers, a transfer aborted through the ep_dequeue path was observed to remain active after EndTransfer completion. A subsequent StartTransfer issued on the same endpoint triggered writes associated with the aborted transfer. This resulted in an SMMU fault because the transfer buffer had already been unmapped during EndTransfer command-completion cleanup.
Using forceRM=0 eliminates the issue. Although older DWC3 programming guide revisions recommended setting forceRM=1, no issues are known from using forceRM=0. Clear forceRM when issuing EndTransfer to provide consistent EndTransfer behavior and align with newer programming guide recommendations.
--- drivers/usb/dwc3/ep0.c | 2 +- drivers/usb/dwc3/gadget.c | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-)
drivers/usb/dwc3/ep0.c +1 -1
@@ -304,7 +304,7 @@ void dwc3_ep0_out_start(struct dwc3 *dwc) dwc3_ep->flags &= ~DWC3_EP_DELAY_STOP ;if (dwc->connected) -dwc3_stop_active_transfer (dwc3_ep, true, true); +dwc3_stop_active_transfer (dwc3_ep, false, true);else dwc3_remove_requests (dwc, dwc3_ep, -ESHUTDOWN ); }
drivers/usb/dwc3/gadget.c +13 -8
@@ -991,7 +991,7 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, unsigned int action)* controller to generate an ERDY to initiate the * stream. */ -dwc3_stop_active_transfer (dep, true, true); +dwc3_stop_active_transfer (dep, false, true);/* * All stream eps will reinitiate stream on NoStream
@@ -1019,7 +1019,7 @@ void dwc3_remove_requests(struct dwc3 *dwc, struct dwc3_ep *dep, int status) {struct dwc3_request *req; -dwc3_stop_active_transfer (dep, true, false); +dwc3_stop_active_transfer (dep, false, false);/* If endxfer is delayed, avoid unmapping requests */ if (dep->flags &DWC3_EP_DELAY_STOP )
@@ -1709,7 +1709,7 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep)if (ret == -EAGAIN )return ret; -dwc3_stop_active_transfer (dep, true, true); +dwc3_stop_active_transfer (dep, false, true);list_for_each_entry_safe (req, tmp, &dep->started_list, list)dwc3_gadget_move_cancelled_request (req,DWC3_REQUEST_STATUS_DEQUEUED );
@@ -1746,6 +1746,11 @@ static int __dwc3_gadget_get_frame(struct dwc3 *dwc)* the controller won't update the TRB progress on command * completion. It also won't clear the HWO bit in the TRB. * The command will also not complete immediately in that case. +* +* Older programming guide revisions recommended setting ForceRM to 1 +* when ending a transfer. Newer programming guide revisions now +* recommend keeping ForceRM cleared, and TRBs are properly updated +* on command completion. */ static int __dwc3_stop_active_transfer (struct dwc3_ep *dep,bool force,bool interrupt) {
@@ -1871,7 +1876,7 @@ static int dwc3_gadget_start_isoc_quirk(struct dwc3_ep *dep)* to wait for the next XferNotReady to test the command again */ if (cmd_status ==0 ) { -dwc3_stop_active_transfer (dep, true, true); +dwc3_stop_active_transfer (dep, false, true);return 0 ; } }
@@ -2154,7 +2159,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,struct dwc3_request *t;/* wait until it is processed */ -dwc3_stop_active_transfer (dep, true, true); +dwc3_stop_active_transfer (dep, false, true);/* * Remove any started request if the transfer is
@@ -2231,7 +2236,7 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol)return 0 ; } -dwc3_stop_active_transfer (dep, true, true); +dwc3_stop_active_transfer (dep, false, true);list_for_each_entry_safe (req, tmp, &dep->started_list, list)dwc3_gadget_move_cancelled_request (req,DWC3_REQUEST_STATUS_STALLED );
@@ -3343,7 +3348,7 @@ static void dwc3_nostream_work(struct work_struct *work)dwc3_send_gadget_generic_command (dwc, cmd, dep->number); }else { dep->flags |=DWC3_EP_DELAY_START ; -dwc3_stop_active_transfer (dep, true, true); +dwc3_stop_active_transfer (dep, false, true);spin_unlock_irqrestore (&dwc->lock, flags);return ; }
@@ -3687,7 +3692,7 @@ static bool dwc3_gadget_endpoint_trbs_complete(struct dwc3_ep *dep,if (usb_endpoint_xfer_isoc (dep->endpoint.desc) &&list_empty (&dep->started_list) && (list_empty (&dep->pending_list) || status == -EXDEV )) -dwc3_stop_active_transfer (dep, true, true); +dwc3_stop_active_transfer (dep, false, true);else if (dwc3_gadget_ep_should_continue (dep))if (__dwc3_gadget_kick_transfer (dep) ==0 ) no_started_trb = false;
Signature · 1 line
2.53.0