Skip to content

Commit a8d3e4a

Browse files
lategoodbyegregkh
authored andcommitted
usb: dwc2: hcd: Fix GetPortStatus & SetPortFeature
On Rasperry Pis without onboard USB hub the power cycle during power connect init only disable the port but never enabled it again: usb usb1-port1: attempt power cycle The port relevant part in dwc2_hcd_hub_control() is skipped in case port_connect_status = 0 under the assumption the core is or will be soon in device mode. But this assumption is wrong, because after ClearPortFeature USB_PORT_FEAT_POWER the port_connect_status will also be 0 and SetPortFeature (incl. USB_PORT_FEAT_POWER) will be a no-op. Fix the behavior of dwc2_hcd_hub_control() by replacing the port_connect_status check with dwc2_is_device_mode(). Link: raspberrypi/linux#6247 Fixes: 7359d48 ("staging: HCD files for the DWC2 driver") Signed-off-by: Stefan Wahren <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 336f72d commit a8d3e4a

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

drivers/usb/dwc2/hcd.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3546,11 +3546,9 @@ static int dwc2_hcd_hub_control(struct dwc2_hsotg *hsotg, u16 typereq,
35463546
port_status |= USB_PORT_STAT_C_OVERCURRENT << 16;
35473547
}
35483548

3549-
if (!hsotg->flags.b.port_connect_status) {
3549+
if (dwc2_is_device_mode(hsotg)) {
35503550
/*
3551-
* The port is disconnected, which means the core is
3552-
* either in device mode or it soon will be. Just
3553-
* return 0's for the remainder of the port status
3551+
* Just return 0's for the remainder of the port status
35543552
* since the port register can't be read if the core
35553553
* is in device mode.
35563554
*/
@@ -3620,13 +3618,11 @@ static int dwc2_hcd_hub_control(struct dwc2_hsotg *hsotg, u16 typereq,
36203618
if (wvalue != USB_PORT_FEAT_TEST && (!windex || windex > 1))
36213619
goto error;
36223620

3623-
if (!hsotg->flags.b.port_connect_status) {
3621+
if (dwc2_is_device_mode(hsotg)) {
36243622
/*
3625-
* The port is disconnected, which means the core is
3626-
* either in device mode or it soon will be. Just
3627-
* return without doing anything since the port
3628-
* register can't be written if the core is in device
3629-
* mode.
3623+
* Just return 0's for the remainder of the port status
3624+
* since the port register can't be read if the core
3625+
* is in device mode.
36303626
*/
36313627
break;
36323628
}

0 commit comments

Comments
 (0)