From: Oliver Neukum <oneukum@suse.com>
To: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>,
Mathias Nyman <mathias.nyman@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org
Subject: [RFC] xhci: clear port_remote_wakeup on device disconnection
Date: Tue, 19 Mar 2019 12:01:28 +0100 [thread overview]
Message-ID: <1552993288.14757.23.camel@suse.com> (raw)
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.
>
> 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);
> +
> xhci_hub_report_usb3_link_state(xhci, status, portsc);
> xhci_del_comp_mod_timer(xhci, portsc, portnum);
> }
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
/* USB2 and USB3 specific bits, including Port Link State */
if (hcd->speed >= HCD_USB3)
xhci_get_usb3_port_status(port, &status, raw_port_status);
else
xhci_get_usb2_port_status(port, &status, raw_port_status,
flags);
/*
* Clear stale usb2 resume signalling variables in case port changed
* state during resume signalling. For example on error
*/
if ((bus_state->resume_done[wIndex] ||
test_bit(wIndex, &bus_state->resuming_ports)) &&
(raw_port_status & PORT_PLS_MASK) != XDEV_U3 &&
(raw_port_status & PORT_PLS_MASK) != XDEV_RESUME) {
bus_state->resume_done[wIndex] = 0;
clear_bit(wIndex, &bus_state->resuming_ports);
usb_hcd_end_port_resume(&hcd->self, wIndex);
}
Otherwise very good catch!
Regards
Oliver
WARNING: multiple messages have this Message-ID (diff)
From: Oliver Neukum <oneukum@suse.com>
To: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>,
Mathias Nyman <mathias.nyman@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org
Subject: Re: [RFC] xhci: clear port_remote_wakeup on device disconnection
Date: Tue, 19 Mar 2019 12:01:28 +0100 [thread overview]
Message-ID: <1552993288.14757.23.camel@suse.com> (raw)
In-Reply-To: <20190318170038.23914-1-nsaenzjulienne@suse.de>
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.
>
> 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);
> +
> xhci_hub_report_usb3_link_state(xhci, status, portsc);
> xhci_del_comp_mod_timer(xhci, portsc, portnum);
> }
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
/* USB2 and USB3 specific bits, including Port Link State */
if (hcd->speed >= HCD_USB3)
xhci_get_usb3_port_status(port, &status, raw_port_status);
else
xhci_get_usb2_port_status(port, &status, raw_port_status,
flags);
/*
* Clear stale usb2 resume signalling variables in case port changed
* state during resume signalling. For example on error
*/
if ((bus_state->resume_done[wIndex] ||
test_bit(wIndex, &bus_state->resuming_ports)) &&
(raw_port_status & PORT_PLS_MASK) != XDEV_U3 &&
(raw_port_status & PORT_PLS_MASK) != XDEV_RESUME) {
bus_state->resume_done[wIndex] = 0;
clear_bit(wIndex, &bus_state->resuming_ports);
usb_hcd_end_port_resume(&hcd->self, wIndex);
}
Otherwise very good catch!
Regards
Oliver
next reply other threads:[~2019-03-19 11:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-19 11:01 Oliver Neukum [this message]
2019-03-19 11:01 ` [RFC] xhci: clear port_remote_wakeup on device disconnection Oliver Neukum
-- strict thread matches above, loose matches on Subject: below --
2019-03-20 13:55 Mathias Nyman
2019-03-20 13:55 ` Mathias Nyman
2019-03-19 14:54 Nicolas Saenz Julienne
2019-03-19 14:54 ` Nicolas Saenz Julienne
2019-03-18 17:00 Nicolas Saenz Julienne
2019-03-18 17:00 ` Nicolas Saenz Julienne
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1552993288.14757.23.camel@suse.com \
--to=oneukum@suse.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
--cc=nsaenzjulienne@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.