Messages in this thread | | | Subject | Re: [RFC] xhci: clear port_remote_wakeup on device disconnection | From | Mathias Nyman <> | Date | Wed, 20 Mar 2019 15:55:02 +0200 |
| |
On 19.3.2019 16.54, Nicolas Saenz Julienne wrote: > Hi Oliver, thanks for the review! > > On Tue, 2019-03-19 at 12:01 +0100, Oliver Neukum wrote: >> On Mo, 2019-03-18 at 18:00 +0100, Nicolas Saenz Julienne wrote: >>> This patch clears "port_remote_wakeup" upon detecting a device >>> disconnection. Making sure the above mentioned situation doesn't trigger >>> a PM busyloop. >> >> Hi, >> >> that is an interesting race condition. >>
Turns out that port_remote_wakeup was only properly cleared in case of a successful resume where port stays in U0, or in case of an error where port goes to inactive state.
In all other cases port_remote_wakeup bit was left uncleared.
>>> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> >>> --- >>> drivers/usb/host/xhci-hub.c | 3 +++ >>> 1 file changed, 3 insertions(+) >>> >>> diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c >>> index e2eece693655..bea853f45aec 100644 >>> --- a/drivers/usb/host/xhci-hub.c >>> +++ b/drivers/usb/host/xhci-hub.c >>> @@ -942,6 +942,9 @@ static void xhci_get_usb3_port_status(struct xhci_port >>> *port, u32 *status, >>> bus_state->suspended_ports &= ~(1 << portnum); >>> } >>> >>> + if (!(portsc & PORT_CONNECT)) >>> + bus_state->port_remote_wakeup &= ~(1 << portnum); >>> +
A check like this should cover the failing resume cases, thanks
We also saw a case when a successful resume was missed as port went into U1 Link power save state (resume->U0->U1) before xhci driver read the port status.
A patch adding U1 and U2 to successful resume states is pending in my for-usb-linus branch for this.
>> >> Why are you putting that logic into xhci_get_usb3_port_status()? >> It looks to me like there is already something related in the caller > > You're right, xhci_get_usb3_port_status() is not the ideal spot I'll move the > code there. >
Sounds good, thanks
-Mathias
| |