Skip to content

Commit 45eae11

Browse files
Selvarasu Ganesangregkh
authored andcommitted
usb: dwc3: Remove WARN_ON for device endpoint command timeouts
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 <[email protected]> Co-developed-by: Akash M <[email protected]> Signed-off-by: Akash M <[email protected]> Signed-off-by: Selvarasu Ganesan <[email protected]> Acked-by: Thinh Nguyen <[email protected]> Reviewed-by: Sebastian Andrzej Siewior <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a3dc32c commit 45eae11

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

drivers/usb/dwc3/ep0.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,9 @@ void dwc3_ep0_out_start(struct dwc3 *dwc)
288288
dwc3_ep0_prepare_one_trb(dep, dwc->ep0_trb_addr, 8,
289289
DWC3_TRBCTL_CONTROL_SETUP, false);
290290
ret = dwc3_ep0_start_trans(dep);
291-
WARN_ON(ret < 0);
291+
if (ret < 0)
292+
dev_err(dwc->dev, "ep0 out start transfer failed: %d\n", ret);
293+
292294
for (i = 2; i < DWC3_ENDPOINTS_NUM; i++) {
293295
struct dwc3_ep *dwc3_ep;
294296

@@ -1061,7 +1063,9 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
10611063
ret = dwc3_ep0_start_trans(dep);
10621064
}
10631065

1064-
WARN_ON(ret < 0);
1066+
if (ret < 0)
1067+
dev_err(dwc->dev,
1068+
"ep0 data phase start transfer failed: %d\n", ret);
10651069
}
10661070

10671071
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)
10781082

10791083
static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep)
10801084
{
1081-
WARN_ON(dwc3_ep0_start_control_status(dep));
1085+
int ret;
1086+
1087+
ret = dwc3_ep0_start_control_status(dep);
1088+
if (ret)
1089+
dev_err(dwc->dev,
1090+
"ep0 status phase start transfer failed: %d\n", ret);
10821091
}
10831092

10841093
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)
11211130
cmd |= DWC3_DEPCMD_PARAM(dep->resource_index);
11221131
memset(&params, 0, sizeof(params));
11231132
ret = dwc3_send_gadget_ep_cmd(dep, cmd, &params);
1124-
WARN_ON_ONCE(ret);
1133+
if (ret)
1134+
dev_err_ratelimited(dwc->dev,
1135+
"ep0 data phase end transfer failed: %d\n", ret);
1136+
11251137
dep->resource_index = 0;
11261138
}
11271139

drivers/usb/dwc3/gadget.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,7 +1772,11 @@ static int __dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, bool int
17721772
dep->flags |= DWC3_EP_DELAY_STOP;
17731773
return 0;
17741774
}
1775-
WARN_ON_ONCE(ret);
1775+
1776+
if (ret)
1777+
dev_err_ratelimited(dep->dwc->dev,
1778+
"end transfer failed: %d\n", ret);
1779+
17761780
dep->resource_index = 0;
17771781

17781782
if (!interrupt)
@@ -4048,7 +4052,9 @@ static void dwc3_clear_stall_all_ep(struct dwc3 *dwc)
40484052
dep->flags &= ~DWC3_EP_STALL;
40494053

40504054
ret = dwc3_send_clear_stall_ep_cmd(dep);
4051-
WARN_ON_ONCE(ret);
4055+
if (ret)
4056+
dev_err_ratelimited(dwc->dev,
4057+
"failed to clear STALL on %s\n", dep->name);
40524058
}
40534059
}
40544060

0 commit comments

Comments
 (0)