BACKPORT: 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: 1d5810b692 ("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>
Bug: 200589374
(cherry picked from commit d7cdfc319b2bcf6899ab0a05eec0958bc802a9a1 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
[wcheng: modified change to remove dependency on updated resume timestamp tracking]
Change-Id: Icccc1778a1f193b4b4c03532d291db88772bd454
Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
This commit is contained in:
parent
ac90f08292
commit
98b0e4cf09
1 changed files with 24 additions and 9 deletions
|
|
@ -1053,19 +1053,19 @@ static void xhci_get_usb3_port_status(struct xhci_port *port, u32 *status,
|
|||
*status |= USB_PORT_STAT_C_CONFIG_ERROR << 16;
|
||||
|
||||
/* USB3 specific wPortStatus bits */
|
||||
if (portsc & PORT_POWER) {
|
||||
if (portsc & PORT_POWER)
|
||||
*status |= USB_SS_PORT_STAT_POWER;
|
||||
/* link state handling */
|
||||
if (link_state == XDEV_U0)
|
||||
bus_state->suspended_ports &= ~(1 << portnum);
|
||||
}
|
||||
|
||||
/* remote wake resume signaling complete */
|
||||
if (bus_state->port_remote_wakeup & (1 << portnum) &&
|
||||
/* no longer suspended or resuming */
|
||||
if (link_state != XDEV_U3 &&
|
||||
link_state != XDEV_RESUME &&
|
||||
link_state != XDEV_RECOVERY) {
|
||||
bus_state->port_remote_wakeup &= ~(1 << portnum);
|
||||
usb_hcd_end_port_resume(&hcd->self, portnum);
|
||||
/* remote wake resume signaling complete */
|
||||
if (bus_state->port_remote_wakeup & (1 << portnum)) {
|
||||
bus_state->port_remote_wakeup &= ~(1 << portnum);
|
||||
usb_hcd_end_port_resume(&hcd->self, portnum);
|
||||
}
|
||||
bus_state->suspended_ports &= ~(1 << portnum);
|
||||
}
|
||||
|
||||
xhci_hub_report_usb3_link_state(xhci, status, portsc);
|
||||
|
|
@ -1111,6 +1111,21 @@ static void xhci_get_usb2_port_status(struct xhci_port *port, u32 *status,
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Clear usb2 resume signalling variables if port is no longer suspended
|
||||
* or resuming. Port either resumed to U0/U1/U2, disconnected, or in a
|
||||
* error state. Resume related variables should be cleared in all those cases.
|
||||
*/
|
||||
if (link_state != XDEV_U3 && link_state != XDEV_RESUME) {
|
||||
if (bus_state->resume_done[portnum] ||
|
||||
test_bit(portnum, &bus_state->resuming_ports)) {
|
||||
bus_state->resume_done[portnum] = 0;
|
||||
clear_bit(portnum, &bus_state->resuming_ports);
|
||||
usb_hcd_end_port_resume(&port->rhub->hcd->self, portnum);
|
||||
}
|
||||
bus_state->suspended_ports &= ~(1 << portnum);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue