drivers/usb/dwc3/ep0.c | 20 ++++++++++++++++---- drivers/usb/dwc3/gadget.c | 10 ++++++++-- 2 files changed, 24 insertions(+), 6 deletions(-)
This commit addresses a rarely observed endpoint command timeout
which causes kernel panic due to warn when 'panic_on_warn' is enabled
and unnecessary call trace prints when 'panic_on_warn' is disabled.
It is seen during fast software-controlled connect/disconnect testcases.
The following is one such endpoint command timeout that we observed:
1. Connect
=======
->dwc3_thread_interrupt
->dwc3_ep0_interrupt
->configfs_composite_setup
->composite_setup
->usb_ep_queue
->dwc3_gadget_ep0_queue
->__dwc3_gadget_ep0_queue
->__dwc3_ep0_do_control_data
->dwc3_send_gadget_ep_cmd
2. Disconnect
==========
->dwc3_thread_interrupt
->dwc3_gadget_disconnect_interrupt
->dwc3_ep0_reset_state
->dwc3_ep0_end_control_data
->dwc3_send_gadget_ep_cmd
In the issue scenario, in Exynos platforms, we observed that control
transfers for the previous connect have not yet been completed and end
transfer command sent as a part of the disconnect sequence and
processing of USB_ENDPOINT_HALT feature request from the host timeout.
This maybe an expected scenario since the controller is processing EP
commands sent as a part of the previous connect. It maybe better to
remove WARN_ON in all places where device endpoint commands are sent to
avoid unnecessary kernel panic due to warn.
Cc: stable@vger.kernel.org
Signed-off-by: Akash M <akash.m5@samsung.com>
Signed-off-by: Selvarasu Ganesan <selvarasu.g@samsung.com>
---
Changes in v2:
- Removed the 'Fixes' tag from the commit message, as this patch does
not contain a fix.
- And Retained the 'stable' tag, as these changes are intended to be
applied across all stable kernels.
- Additionally, replaced 'dev_warn*' with 'dev_err*'."
Link to v1: https://lore.kernel.org/all/20250807005638.thhsgjn73aaov2af@synopsys.com/
---
drivers/usb/dwc3/ep0.c | 20 ++++++++++++++++----
drivers/usb/dwc3/gadget.c | 10 ++++++++--
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 666ac432f52d..b4229aa13f37 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -288,7 +288,9 @@ void dwc3_ep0_out_start(struct dwc3 *dwc)
dwc3_ep0_prepare_one_trb(dep, dwc->ep0_trb_addr, 8,
DWC3_TRBCTL_CONTROL_SETUP, false);
ret = dwc3_ep0_start_trans(dep);
- WARN_ON(ret < 0);
+ if (ret < 0)
+ dev_err(dwc->dev, "ep0 out start transfer failed: %d\n", ret);
+
for (i = 2; i < DWC3_ENDPOINTS_NUM; i++) {
struct dwc3_ep *dwc3_ep;
@@ -1061,7 +1063,9 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
ret = dwc3_ep0_start_trans(dep);
}
- WARN_ON(ret < 0);
+ if (ret < 0)
+ dev_err(dwc->dev,
+ "ep0 data phase start transfer failed: %d\n", ret);
}
static int dwc3_ep0_start_control_status(struct dwc3_ep *dep)
@@ -1078,7 +1082,12 @@ static int dwc3_ep0_start_control_status(struct dwc3_ep *dep)
static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep)
{
- WARN_ON(dwc3_ep0_start_control_status(dep));
+ int ret;
+
+ ret = dwc3_ep0_start_control_status(dep);
+ if (ret)
+ dev_err(dwc->dev,
+ "ep0 status phase start transfer failed: %d\n", ret);
}
static void dwc3_ep0_do_control_status(struct dwc3 *dwc,
@@ -1121,7 +1130,10 @@ void dwc3_ep0_end_control_data(struct dwc3 *dwc, struct dwc3_ep *dep)
cmd |= DWC3_DEPCMD_PARAM(dep->resource_index);
memset(¶ms, 0, sizeof(params));
ret = dwc3_send_gadget_ep_cmd(dep, cmd, ¶ms);
- WARN_ON_ONCE(ret);
+ if (ret)
+ dev_err_ratelimited(dwc->dev,
+ "ep0 data phase end transfer failed: %d\n", ret);
+
dep->resource_index = 0;
}
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 4a3e97e606d1..4a3d076c1015 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1772,7 +1772,11 @@ static int __dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, bool int
dep->flags |= DWC3_EP_DELAY_STOP;
return 0;
}
- WARN_ON_ONCE(ret);
+
+ if (ret)
+ dev_err_ratelimited(dep->dwc->dev,
+ "end transfer failed: %d\n", ret);
+
dep->resource_index = 0;
if (!interrupt)
@@ -4039,7 +4043,9 @@ static void dwc3_clear_stall_all_ep(struct dwc3 *dwc)
dep->flags &= ~DWC3_EP_STALL;
ret = dwc3_send_clear_stall_ep_cmd(dep);
- WARN_ON_ONCE(ret);
+ if (ret)
+ dev_err_ratelimited(dwc->dev,
+ "failed to clear STALL on %s\n", dep->name);
}
}
--
2.17.1
On 2025-08-07 07:16:31 [+0530], Selvarasu Ganesan wrote: > This commit addresses a rarely observed endpoint command timeout … > > Cc: stable@vger.kernel.org > Signed-off-by: Akash M <akash.m5@samsung.com> > Signed-off-by: Selvarasu Ganesan <selvarasu.g@samsung.com> The Author is Selvarasu Ganesan <selvarasu.g@samsung.com> while the first sign-off is Akash M <akash.m5@samsung.com>. If Akash is the Author and you are sending it then the patch body has to start with From: line to credit this. Please see https://origin.kernel.org/doc/html/latest/process/submitting-patches.html#when-to-use-acked-by-cc-and-co-developed-by and https://origin.kernel.org/doc/html/latest/process/submitting-patches.html#from-line Sebastian
On 8/8/2025 2:31 PM, Sebastian Andrzej Siewior wrote: > On 2025-08-07 07:16:31 [+0530], Selvarasu Ganesan wrote: >> This commit addresses a rarely observed endpoint command timeout > … >> Cc: stable@vger.kernel.org >> Signed-off-by: Akash M <akash.m5@samsung.com> >> Signed-off-by: Selvarasu Ganesan <selvarasu.g@samsung.com> > The Author is Selvarasu Ganesan <selvarasu.g@samsung.com> while the > first sign-off is Akash M <akash.m5@samsung.com>. If Akash is the Author > and you are sending it then the patch body has to start with From: line > to credit this. > > Please see > https://origin.kernel.org/doc/html/latest/process/submitting-patches.html#when-to-use-acked-by-cc-and-co-developed-by > and https://origin.kernel.org/doc/html/latest/process/submitting-patches.html#from-line > > Sebastian Hi Sebastian, Thank you for pointing out the discrepancy. We will ensure that the patch submission accurately reflects the authorship. Since I, "Selvarasu Ganesan" am the author, I will reorder the sign-offs to reflect the correct authorship. Here is the corrected patch submission: Cc: stable@vger.kernel.org Signed-off-by: Selvarasu Ganesan <selvarasu.g@samsung.com> Signed-off-by: Akash M <akash.m5@samsung.com> Regarding the next steps, I will post a new patchset with the reordered sign-offs. Thanks, Selva
On 2025-08-08 16:07:25 [+0530], Selvarasu Ganesan wrote: > Thank you for pointing out the discrepancy. We will ensure that the > patch submission accurately reflects the authorship. > > Since I, "Selvarasu Ganesan" am the author, I will reorder the sign-offs > to reflect the correct authorship. > > Here is the corrected patch submission: > > Cc: stable@vger.kernel.org > Signed-off-by: Selvarasu Ganesan <selvarasu.g@samsung.com> > Signed-off-by: Akash M <akash.m5@samsung.com> > > Regarding the next steps, I will post a new patchset with the reordered > sign-offs. Your sign-off (as the poster) should come last. What is Akash' role in this? > Thanks, > Selva Sebastian
On 8/8/2025 4:22 PM, Sebastian Andrzej Siewior wrote: > On 2025-08-08 16:07:25 [+0530], Selvarasu Ganesan wrote: >> Thank you for pointing out the discrepancy. We will ensure that the >> patch submission accurately reflects the authorship. >> >> Since I, "Selvarasu Ganesan" am the author, I will reorder the sign-offs >> to reflect the correct authorship. >> >> Here is the corrected patch submission: >> >> Cc: stable@vger.kernel.org >> Signed-off-by: Selvarasu Ganesan <selvarasu.g@samsung.com> >> Signed-off-by: Akash M <akash.m5@samsung.com> >> >> Regarding the next steps, I will post a new patchset with the reordered >> sign-offs. > Your sign-off (as the poster) should come last. > What is Akash' role in this? Akash M's role in the patch as a co-contributor. Shall i add tag as Co-developed-by: Akash M <akash.m5@samsung.com>? Cc: stable@vger.kernel.org Co-developed-by: Akash M <akash.m5@samsung.com> Signed-off-by: Akash M <akash.m5@samsung.com> Signed-off-by: Selvarasu Ganesan <selvarasu.g@samsung.com> >> Thanks, >> Selva > Sebastian > >
On 2025-08-08 16:59:08 [+0530], Selvarasu Ganesan wrote: > >> Here is the corrected patch submission: > >> > >> Cc: stable@vger.kernel.org > >> Signed-off-by: Selvarasu Ganesan <selvarasu.g@samsung.com> > >> Signed-off-by: Akash M <akash.m5@samsung.com> > >> > >> Regarding the next steps, I will post a new patchset with the reordered > >> sign-offs. > > Your sign-off (as the poster) should come last. > > What is Akash' role in this? > > > Akash M's role in the patch as a co-contributor. > Shall i add tag as Co-developed-by: Akash M <akash.m5@samsung.com>? > > Cc: stable@vger.kernel.org > Co-developed-by: Akash M <akash.m5@samsung.com> > Signed-off-by: Akash M <akash.m5@samsung.com> > Signed-off-by: Selvarasu Ganesan <selvarasu.g@samsung.com> Yes. This looks good now. > >> Thanks, > >> Selva Sebastian
On 8/8/2025 6:13 PM, Sebastian Andrzej Siewior wrote: > On 2025-08-08 16:59:08 [+0530], Selvarasu Ganesan wrote: >>>> Here is the corrected patch submission: >>>> >>>> Cc: stable@vger.kernel.org >>>> Signed-off-by: Selvarasu Ganesan <selvarasu.g@samsung.com> >>>> Signed-off-by: Akash M <akash.m5@samsung.com> >>>> >>>> Regarding the next steps, I will post a new patchset with the reordered >>>> sign-offs. >>> Your sign-off (as the poster) should come last. >>> What is Akash' role in this? >> >> Akash M's role in the patch as a co-contributor. >> Shall i add tag as Co-developed-by: Akash M <akash.m5@samsung.com>? >> >> Cc: stable@vger.kernel.org >> Co-developed-by: Akash M <akash.m5@samsung.com> >> Signed-off-by: Akash M <akash.m5@samsung.com> >> Signed-off-by: Selvarasu Ganesan <selvarasu.g@samsung.com> > Yes. This looks good now. Ok. Thanks for the confirmation. > >>>> Thanks, >>>> Selva > Sebastian > >
On Thu, Aug 07, 2025, Selvarasu Ganesan wrote: > This commit addresses a rarely observed endpoint command timeout > which causes kernel panic due to warn when 'panic_on_warn' is enabled > and unnecessary call trace prints when 'panic_on_warn' is disabled. > It is seen during fast software-controlled connect/disconnect testcases. > The following is one such endpoint command timeout that we observed: > > 1. Connect > ======= > ->dwc3_thread_interrupt > ->dwc3_ep0_interrupt > ->configfs_composite_setup > ->composite_setup > ->usb_ep_queue > ->dwc3_gadget_ep0_queue > ->__dwc3_gadget_ep0_queue > ->__dwc3_ep0_do_control_data > ->dwc3_send_gadget_ep_cmd > > 2. Disconnect > ========== > ->dwc3_thread_interrupt > ->dwc3_gadget_disconnect_interrupt > ->dwc3_ep0_reset_state > ->dwc3_ep0_end_control_data > ->dwc3_send_gadget_ep_cmd > > In the issue scenario, in Exynos platforms, we observed that control > transfers for the previous connect have not yet been completed and end > transfer command sent as a part of the disconnect sequence and > processing of USB_ENDPOINT_HALT feature request from the host timeout. > This maybe an expected scenario since the controller is processing EP > commands sent as a part of the previous connect. It maybe better to > remove WARN_ON in all places where device endpoint commands are sent to > avoid unnecessary kernel panic due to warn. > > Cc: stable@vger.kernel.org > Signed-off-by: Akash M <akash.m5@samsung.com> > Signed-off-by: Selvarasu Ganesan <selvarasu.g@samsung.com> > --- > > Changes in v2: > - Removed the 'Fixes' tag from the commit message, as this patch does > not contain a fix. > - And Retained the 'stable' tag, as these changes are intended to be > applied across all stable kernels. > - Additionally, replaced 'dev_warn*' with 'dev_err*'." > Link to v1: https://urldefense.com/v3/__https://lore.kernel.org/all/20250807005638.thhsgjn73aaov2af@synopsys.com/__;!!A4F2R9G_pg!fGholZu_giqPUY40LREan9c7A05ec6mbjlIxrsuzsMKfOiEk8u8GsPxRlXTCaxoWM4nLboHcmzblqgQP2eSzvOqEuAY$ > --- > drivers/usb/dwc3/ep0.c | 20 ++++++++++++++++---- > drivers/usb/dwc3/gadget.c | 10 ++++++++-- > 2 files changed, 24 insertions(+), 6 deletions(-) > > diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c > index 666ac432f52d..b4229aa13f37 100644 > --- a/drivers/usb/dwc3/ep0.c > +++ b/drivers/usb/dwc3/ep0.c > @@ -288,7 +288,9 @@ void dwc3_ep0_out_start(struct dwc3 *dwc) > dwc3_ep0_prepare_one_trb(dep, dwc->ep0_trb_addr, 8, > DWC3_TRBCTL_CONTROL_SETUP, false); > ret = dwc3_ep0_start_trans(dep); > - WARN_ON(ret < 0); > + if (ret < 0) > + dev_err(dwc->dev, "ep0 out start transfer failed: %d\n", ret); > + > for (i = 2; i < DWC3_ENDPOINTS_NUM; i++) { > struct dwc3_ep *dwc3_ep; > > @@ -1061,7 +1063,9 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, > ret = dwc3_ep0_start_trans(dep); > } > > - WARN_ON(ret < 0); > + if (ret < 0) > + dev_err(dwc->dev, > + "ep0 data phase start transfer failed: %d\n", ret); > } > > static int dwc3_ep0_start_control_status(struct dwc3_ep *dep) > @@ -1078,7 +1082,12 @@ static int dwc3_ep0_start_control_status(struct dwc3_ep *dep) > > static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep) > { > - WARN_ON(dwc3_ep0_start_control_status(dep)); > + int ret; > + > + ret = dwc3_ep0_start_control_status(dep); > + if (ret) > + dev_err(dwc->dev, > + "ep0 status phase start transfer failed: %d\n", ret); > } > > static void dwc3_ep0_do_control_status(struct dwc3 *dwc, > @@ -1121,7 +1130,10 @@ void dwc3_ep0_end_control_data(struct dwc3 *dwc, struct dwc3_ep *dep) > cmd |= DWC3_DEPCMD_PARAM(dep->resource_index); > memset(¶ms, 0, sizeof(params)); > ret = dwc3_send_gadget_ep_cmd(dep, cmd, ¶ms); > - WARN_ON_ONCE(ret); > + if (ret) > + dev_err_ratelimited(dwc->dev, > + "ep0 data phase end transfer failed: %d\n", ret); > + > dep->resource_index = 0; > } > > diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c > index 4a3e97e606d1..4a3d076c1015 100644 > --- a/drivers/usb/dwc3/gadget.c > +++ b/drivers/usb/dwc3/gadget.c > @@ -1772,7 +1772,11 @@ static int __dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, bool int > dep->flags |= DWC3_EP_DELAY_STOP; > return 0; > } > - WARN_ON_ONCE(ret); > + > + if (ret) > + dev_err_ratelimited(dep->dwc->dev, > + "end transfer failed: %d\n", ret); > + > dep->resource_index = 0; > > if (!interrupt) > @@ -4039,7 +4043,9 @@ static void dwc3_clear_stall_all_ep(struct dwc3 *dwc) > dep->flags &= ~DWC3_EP_STALL; > > ret = dwc3_send_clear_stall_ep_cmd(dep); > - WARN_ON_ONCE(ret); > + if (ret) > + dev_err_ratelimited(dwc->dev, > + "failed to clear STALL on %s\n", dep->name); > } > } > > -- > 2.17.1 > Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> BR, Thinh
© 2016 - 2025 Red Hat, Inc.