diff options
author | Mian Yousaf Kaukab <yousaf.kaukab@intel.com> | 2015-09-29 06:08:25 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2015-10-01 13:40:26 -0400 |
commit | 5390d438e6f4aaf3555acc72aff155660a48cd28 (patch) | |
tree | 87ac6d976987dc637bce73b3f3968d7207b7039d | |
parent | c524dd5f432a0690710b62e729a3673c557d8b58 (diff) |
usb: dwc2: gadget: kill ep0 requests before reinitializing core
Make sure there are no requests pending on ep0 before reinitializing
core. Otherwise, dwc2_hsotg_enqueue_setup will fail afterwards.
Also, take hsotg->lock before calling
dwc2_hsotg_core_init_disconnected() from dwc2_conn_id_status_change()
as dwc2_hsotg_complete_request() expect lock to be held.
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/usb/dwc2/gadget.c | 8 | ||||
-rw-r--r-- | drivers/usb/dwc2/hcd.c | 3 |
2 files changed, 6 insertions, 5 deletions
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 38c29a8bdd11..2d81fc5f39e9 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c | |||
@@ -2287,6 +2287,9 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg, | |||
2287 | { | 2287 | { |
2288 | u32 val; | 2288 | u32 val; |
2289 | 2289 | ||
2290 | /* Kill any ep0 requests as controller will be reinitialized */ | ||
2291 | kill_all_requests(hsotg, hsotg->eps_out[0], -ECONNRESET); | ||
2292 | |||
2290 | if (!is_usb_reset) | 2293 | if (!is_usb_reset) |
2291 | if (dwc2_hsotg_corereset(hsotg)) | 2294 | if (dwc2_hsotg_corereset(hsotg)) |
2292 | return; | 2295 | return; |
@@ -2515,9 +2518,6 @@ irq_retry: | |||
2515 | if (time_after(jiffies, hsotg->last_rst + | 2518 | if (time_after(jiffies, hsotg->last_rst + |
2516 | msecs_to_jiffies(200))) { | 2519 | msecs_to_jiffies(200))) { |
2517 | 2520 | ||
2518 | kill_all_requests(hsotg, hsotg->eps_out[0], | ||
2519 | -ECONNRESET); | ||
2520 | |||
2521 | dwc2_hsotg_core_init_disconnected(hsotg, true); | 2521 | dwc2_hsotg_core_init_disconnected(hsotg, true); |
2522 | } | 2522 | } |
2523 | } | 2523 | } |
@@ -3296,8 +3296,6 @@ static int dwc2_hsotg_vbus_session(struct usb_gadget *gadget, int is_active) | |||
3296 | if (hsotg->lx_state == DWC2_L2) | 3296 | if (hsotg->lx_state == DWC2_L2) |
3297 | dwc2_exit_hibernation(hsotg, false); | 3297 | dwc2_exit_hibernation(hsotg, false); |
3298 | 3298 | ||
3299 | /* Kill any ep0 requests as controller will be reinitialized */ | ||
3300 | kill_all_requests(hsotg, hsotg->eps_out[0], -ECONNRESET); | ||
3301 | dwc2_hsotg_core_init_disconnected(hsotg, false); | 3299 | dwc2_hsotg_core_init_disconnected(hsotg, false); |
3302 | if (hsotg->enabled) | 3300 | if (hsotg->enabled) |
3303 | dwc2_hsotg_core_connect(hsotg); | 3301 | dwc2_hsotg_core_connect(hsotg); |
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 15a1e62ac902..af4e4a27126f 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c | |||
@@ -1355,6 +1355,7 @@ static void dwc2_conn_id_status_change(struct work_struct *work) | |||
1355 | wf_otg); | 1355 | wf_otg); |
1356 | u32 count = 0; | 1356 | u32 count = 0; |
1357 | u32 gotgctl; | 1357 | u32 gotgctl; |
1358 | unsigned long flags; | ||
1358 | 1359 | ||
1359 | dev_dbg(hsotg->dev, "%s()\n", __func__); | 1360 | dev_dbg(hsotg->dev, "%s()\n", __func__); |
1360 | 1361 | ||
@@ -1382,7 +1383,9 @@ static void dwc2_conn_id_status_change(struct work_struct *work) | |||
1382 | hsotg->op_state = OTG_STATE_B_PERIPHERAL; | 1383 | hsotg->op_state = OTG_STATE_B_PERIPHERAL; |
1383 | dwc2_core_init(hsotg, false, -1); | 1384 | dwc2_core_init(hsotg, false, -1); |
1384 | dwc2_enable_global_interrupts(hsotg); | 1385 | dwc2_enable_global_interrupts(hsotg); |
1386 | spin_lock_irqsave(&hsotg->lock, flags); | ||
1385 | dwc2_hsotg_core_init_disconnected(hsotg, false); | 1387 | dwc2_hsotg_core_init_disconnected(hsotg, false); |
1388 | spin_unlock_irqrestore(&hsotg->lock, flags); | ||
1386 | dwc2_hsotg_core_connect(hsotg); | 1389 | dwc2_hsotg_core_connect(hsotg); |
1387 | } else { | 1390 | } else { |
1388 | /* A-Device connector (Host Mode) */ | 1391 | /* A-Device connector (Host Mode) */ |