mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
To: 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: Re: [RFC] xhci: clear port_remote_wakeup on device disconnection
Date: Tue, 19 Mar 2019 15:54:21 +0100	[thread overview]
Message-ID: <82718bec37e4e16e0a08b3b7a00452f99adc707b.camel@suse.de> (raw)
In-Reply-To: <1552993288.14757.23.camel@suse.com>

[-- Attachment #1: Type: text/plain, Size: 2420 bytes --]

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.
> 
> > 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);
>         }

You're right, xhci_get_usb3_port_status() is not the ideal spot I'll move the
code there.

> 
> Otherwise very good catch!
> 
> 	Regards
> 		Oliver
> 


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2019-03-19 14:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-18 17:00 Nicolas Saenz Julienne
2019-03-19 11:01 ` Oliver Neukum
2019-03-19 14:54   ` Nicolas Saenz Julienne [this message]
2019-03-20 13:55     ` Mathias Nyman

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=82718bec37e4e16e0a08b3b7a00452f99adc707b.camel@suse.de \
    --to=nsaenzjulienne@suse.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --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

all inboxes | Powered by JetHome®