Skip to content

Commit d7cdfc3

Browse files
matnymangregkh
authored andcommitted
xhci: track port suspend state correctly in unsuccessful resume cases
xhci-hub.c tracks suspended ports in a suspended_port bitfield. This is checked when responding to a Get_Status(PORT) request to see if a port in running U0 state was recently resumed, and adds the required USB_PORT_STAT_C_SUSPEND change bit in those cases. The suspended_port bit was left uncleared if a device is disconnected during suspend. The bit remained set even when a new device was connected and enumerated. The set bit resulted in a incorrect Get_Status(PORT) response with a bogus USB_PORT_STAT_C_SUSPEND change bit set once the new device reached U0 link state. USB_PORT_STAT_C_SUSPEND change bit is only used for USB2 ports, but xhci-hub keeps track of both USB2 and USB3 suspended ports. Cc: stable@vger.kernel.org Reported-by: Wesley Cheng <quic_wcheng@quicinc.com> Closes: https://lore.kernel.org/linux-usb/d68aa806-b26a-0e43-42fb-b8067325e967@quicinc.com/ Fixes: 1d5810b ("xhci: Rework port suspend structures for limited ports.") Tested-by: Wesley Cheng <quic_wcheng@quicinc.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://lore.kernel.org/r/20230915143108.1532163-3-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 41a4301 commit d7cdfc3

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

drivers/usb/host/xhci-hub.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,19 +1062,19 @@ static void xhci_get_usb3_port_status(struct xhci_port *port, u32 *status,
10621062
*status |= USB_PORT_STAT_C_CONFIG_ERROR << 16;
10631063

10641064
/* USB3 specific wPortStatus bits */
1065-
if (portsc & PORT_POWER) {
1065+
if (portsc & PORT_POWER)
10661066
*status |= USB_SS_PORT_STAT_POWER;
1067-
/* link state handling */
1068-
if (link_state == XDEV_U0)
1069-
bus_state->suspended_ports &= ~(1 << portnum);
1070-
}
10711067

1072-
/* remote wake resume signaling complete */
1073-
if (bus_state->port_remote_wakeup & (1 << portnum) &&
1068+
/* no longer suspended or resuming */
1069+
if (link_state != XDEV_U3 &&
10741070
link_state != XDEV_RESUME &&
10751071
link_state != XDEV_RECOVERY) {
1076-
bus_state->port_remote_wakeup &= ~(1 << portnum);
1077-
usb_hcd_end_port_resume(&hcd->self, portnum);
1072+
/* remote wake resume signaling complete */
1073+
if (bus_state->port_remote_wakeup & (1 << portnum)) {
1074+
bus_state->port_remote_wakeup &= ~(1 << portnum);
1075+
usb_hcd_end_port_resume(&hcd->self, portnum);
1076+
}
1077+
bus_state->suspended_ports &= ~(1 << portnum);
10781078
}
10791079

10801080
xhci_hub_report_usb3_link_state(xhci, status, portsc);
@@ -1131,6 +1131,7 @@ static void xhci_get_usb2_port_status(struct xhci_port *port, u32 *status,
11311131
usb_hcd_end_port_resume(&port->rhub->hcd->self, portnum);
11321132
}
11331133
port->rexit_active = 0;
1134+
bus_state->suspended_ports &= ~(1 << portnum);
11341135
}
11351136
}
11361137

0 commit comments

Comments
 (0)