mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
usb: dwc2: gadget: Exit partial power down state when changing USB pull-up
When a USB host suspends a connected device, the DWC2 USB device controller
enters a partial power down state where controller registers are not
accessible. If the USB gadget is then disconnected or deactivated
(e.g. when a gadget function is unbound from the controller), the `pullup`
callback in struct usb_gadget_ops is invoked; if the controller is kept in
partial power down, the register write in dwc2_hsotg_core_disconnect() does
not take effect; as a result, the USB host keeps seeing the device as
connected, even though the device is disabled.
Properly exit partial power down state in the pullup callback, so that the
USB host detects a device disconnection as intended.
Fixes: 97861781da ("usb: dwc2: Allow entering hibernation from USB_SUSPEND interrupt")
Cc: stable@vger.kernel.org
Signed-off-by: Francesco Lavra <flavra@baylibre.com>
Link: https://patch.msgid.link/20260728154420.2021519-1-flavra@baylibre.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
e78dcb1f7e
commit
bf1e90189a
|
|
@ -4680,6 +4680,7 @@ static int dwc2_hsotg_pullup(struct usb_gadget *gadget, int is_on)
|
|||
{
|
||||
struct dwc2_hsotg *hsotg = to_hsotg(gadget);
|
||||
unsigned long flags;
|
||||
int ret = 0;
|
||||
|
||||
dev_dbg(hsotg->dev, "%s: is_on: %d op_state: %d\n", __func__, is_on,
|
||||
hsotg->op_state);
|
||||
|
|
@ -4691,6 +4692,13 @@ static int dwc2_hsotg_pullup(struct usb_gadget *gadget, int is_on)
|
|||
}
|
||||
|
||||
spin_lock_irqsave(&hsotg->lock, flags);
|
||||
if (hsotg->in_ppd) {
|
||||
ret = dwc2_exit_partial_power_down(hsotg, 0, true);
|
||||
if (ret) {
|
||||
dev_err(hsotg->dev, "exit partial_power_down failed\n");
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
if (is_on) {
|
||||
hsotg->enabled = 1;
|
||||
dwc2_hsotg_core_init_disconnected(hsotg, false);
|
||||
|
|
@ -4704,9 +4712,10 @@ static int dwc2_hsotg_pullup(struct usb_gadget *gadget, int is_on)
|
|||
}
|
||||
|
||||
hsotg->gadget.speed = USB_SPEED_UNKNOWN;
|
||||
exit:
|
||||
spin_unlock_irqrestore(&hsotg->lock, flags);
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int dwc2_hsotg_vbus_session(struct usb_gadget *gadget, int is_active)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user