linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>,
	Oliver Neukum <oneukum@suse.com>,
	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: Wed, 20 Mar 2019 15:55:02 +0200	[thread overview]
Message-ID: <cd27b6cf-805a-8051-23e4-3bd1de2ede4d@linux.intel.com> (raw)

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

             reply	other threads:[~2019-03-20 13:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-20 13:55 Mathias Nyman [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-03-19 14:54 [RFC] xhci: clear port_remote_wakeup on device disconnection Nicolas Saenz Julienne
2019-03-19 11:01 Oliver Neukum
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=cd27b6cf-805a-8051-23e4-3bd1de2ede4d@linux.intel.com \
    --to=mathias.nyman@linux.intel.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 \
    --cc=oneukum@suse.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).