Skip to content

Commit 31f42da

Browse files
Minas Harutyunyangregkh
authored andcommitted
usb: dwc2: gadget: Fix exiting from clock gating
Added exiting from the clock gating mode on USB Reset Detect interrupt if core in the clock gating mode. Added new condition to check core in clock gating mode or no. Fixes: 9b4965d ("usb: dwc2: Add exit clock gating from session request interrupt") Fixes: 5d240ef ("usb: dwc2: Add exit clock gating from wakeup interrupt") Fixes: 16c729f ("usb: dwc2: Allow exit clock gating in urb enqueue") Fixes: 401411b ("usb: dwc2: Add exit clock gating before removing driver") CC: stable@vger.kernel.org Signed-off-by: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com> Link: https://lore.kernel.org/r/cbcc2ccd37e89e339130797ed68ae4597db773ac.1708938774.git.Minas.Harutyunyan@synopsys.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b258e42 commit 31f42da

4 files changed

Lines changed: 14 additions & 5 deletions

File tree

drivers/usb/dwc2/core_intr.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ static void dwc2_handle_session_req_intr(struct dwc2_hsotg *hsotg)
297297

298298
/* Exit gadget mode clock gating. */
299299
if (hsotg->params.power_down ==
300-
DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended)
300+
DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended &&
301+
!hsotg->params.no_clock_gating)
301302
dwc2_gadget_exit_clock_gating(hsotg, 0);
302303
}
303304

@@ -408,7 +409,8 @@ static void dwc2_handle_wakeup_detected_intr(struct dwc2_hsotg *hsotg)
408409

409410
/* Exit gadget mode clock gating. */
410411
if (hsotg->params.power_down ==
411-
DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended)
412+
DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended &&
413+
!hsotg->params.no_clock_gating)
412414
dwc2_gadget_exit_clock_gating(hsotg, 0);
413415
} else {
414416
/* Change to L0 state */
@@ -425,7 +427,8 @@ static void dwc2_handle_wakeup_detected_intr(struct dwc2_hsotg *hsotg)
425427
}
426428

427429
if (hsotg->params.power_down ==
428-
DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended)
430+
DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended &&
431+
!hsotg->params.no_clock_gating)
429432
dwc2_host_exit_clock_gating(hsotg, 1);
430433

431434
/*

drivers/usb/dwc2/gadget.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3727,6 +3727,12 @@ static irqreturn_t dwc2_hsotg_irq(int irq, void *pw)
37273727
if (hsotg->in_ppd && hsotg->lx_state == DWC2_L2)
37283728
dwc2_exit_partial_power_down(hsotg, 0, true);
37293729

3730+
/* Exit gadget mode clock gating. */
3731+
if (hsotg->params.power_down ==
3732+
DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended &&
3733+
!hsotg->params.no_clock_gating)
3734+
dwc2_gadget_exit_clock_gating(hsotg, 0);
3735+
37303736
hsotg->lx_state = DWC2_L0;
37313737
}
37323738

drivers/usb/dwc2/hcd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4657,7 +4657,7 @@ static int _dwc2_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
46574657
}
46584658

46594659
if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_NONE &&
4660-
hsotg->bus_suspended) {
4660+
hsotg->bus_suspended && !hsotg->params.no_clock_gating) {
46614661
if (dwc2_is_device_mode(hsotg))
46624662
dwc2_gadget_exit_clock_gating(hsotg, 0);
46634663
else

drivers/usb/dwc2/platform.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ static void dwc2_driver_remove(struct platform_device *dev)
331331

332332
/* Exit clock gating when driver is removed. */
333333
if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_NONE &&
334-
hsotg->bus_suspended) {
334+
hsotg->bus_suspended && !hsotg->params.no_clock_gating) {
335335
if (dwc2_is_device_mode(hsotg))
336336
dwc2_gadget_exit_clock_gating(hsotg, 0);
337337
else

0 commit comments

Comments
 (0)