All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Greg KH <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, stable@vger.kernel.org,
	Mike Murdoch <main.haarp@googlemail.com>
Subject: Re: [PATCH 3/7] xhci: Don't suspend a xhci usb bus if there is a pending event.
Date: Fri, 08 Apr 2016 13:16:21 +0300	[thread overview]
Message-ID: <570784F5.1080804@linux.intel.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1604071013470.2179-100000@iolanthe.rowland.org>

On 07.04.2016 17:23, Alan Stern wrote:
> On Thu, 7 Apr 2016, Mathias Nyman wrote:
>
>>> In this case there may be alternatives.  For example, you could just
>>> delay a few ms until the pending event has been handled.  Or, if you
>>> really just want to prevent runtime suspend, you should check to see if
>>> this was a runtime suspend and not a system suspend.  Or you could
>>> prevent the bus from being runtime suspended in the first place by
>>> doing a pm_runtime_get_sync().
>>
>> I just want to prevent runtime suspend.
>> The pm_message_t msg is lost when hcd_bus_suspend() calls hcd->driver->bus_suspend(hcd).
>> Maybe it could be added?
>
> It could.  You'd just have to update all the existing callback routines
> to accept the additional argument.
>
>> Or is there some other easy way to figure out if it is runtime suspend?
>
> There isn't.  But I still think you might be better off using the
> existing runtime PM facilities to prevent runtime suspend at bad times
> -- if possible.
>
> The commit message said something about waiting for a newly discovered
> hub to be probed.  Can you go into more detail?


A USB3 device connected to a runtime suspended host woke up the host, polled the roothub,
found nothing and immediately tried to suspend again.

Logs show:
Feb 16 20:03:33 xhci_hcd 0000:0e:00.0: // Setting command ring address to 0xffffe001
Feb 16 20:03:33 xhci_hcd 0000:0e:00.0: xhci_resume: starting port polling.
Feb 16 20:03:33 xhci_hcd 0000:0e:00.0: xhci_hub_status_data: stopping port polling.
Feb 16 20:03:33 xhci_hcd 0000:0e:00.0: xhci_suspend: stopping port polling.
Feb 16 20:03:33 xhci_hcd 0000:0e:00.0: Port Status Change Event for port 3
Feb 16 20:03:33 xhci_hcd 0000:0e:00.0: resume root hub
..other entries..
Feb 16 20:03:33 xhci_hcd 0000:0e:00.0: Port Status Change Event for port 1
Feb 16 20:03:33 xhci_hcd 0000:0e:00.0: resume root hub


So what probably happened here was that connecting the usb device caused a
PCI PME# event to wake up the xhci PCI controller, calling
   xhci_pci_resume(), calling
     xhci_resume(), calling
       usb_hcd_resume_root_hub(both usb2 and usb3 hcds) and
       usb_hcd_poll_rh_status(both usb2 and usb3 hcd). polling rh status calls
         hcd->driver->hub_status_data() -> xhci_hub_status_data()
         xhci_hub_status_data() reads PORTSCs -> no change -> stop polling -> return 0
     
In core/hub.c hub_probe() autosuspend is set to 0 for roothubs with a long explanation why.
I assume that as xhci_hub_status_data clears the HCD_FLAG_POLL_RH flag and returns 0 (no changes)
we immediately runtime suspend the hub -> runtime suspend host.

-Mathias

  reply	other threads:[~2016-04-08 10:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1459948088-27118-1-git-send-email-mathias.nyman@linux.intel.com>
2016-04-06 13:08 ` [PATCH 1/7] usb: xhci: applying XHCI_PME_STUCK_QUIRK to Intel BXT B0 host Mathias Nyman
2016-04-06 13:08 ` [PATCH 2/7] xhci: resume USB 3 roothub first Mathias Nyman
2016-04-06 13:08 ` [PATCH 3/7] xhci: Don't suspend a xhci usb bus if there is a pending event Mathias Nyman
2016-04-06 15:01   ` Alan Stern
2016-04-06 15:33     ` Bjørn Mork
2016-04-06 16:11       ` Alan Stern
2016-04-06 16:18         ` Bjørn Mork
2016-04-06 21:05   ` Greg KH
2016-04-06 21:25     ` Alan Stern
2016-04-07  8:10       ` Mathias Nyman
2016-04-07 14:23         ` Alan Stern
2016-04-08 10:16           ` Mathias Nyman [this message]
2016-04-06 13:08 ` [PATCH 4/7] usb: host: xhci: add a new quirk XHCI_NO_64BIT_SUPPORT Mathias Nyman
2016-04-06 13:08 ` [PATCH 5/7] usb: host: xhci-plat: fix cannot work if R-Car Gen2/3 run on above 4GB phys Mathias Nyman
2016-04-06 13:08 ` [PATCH 6/7] usb: xhci: fix wild pointers in xhci_mem_cleanup Mathias Nyman
2016-04-06 13:08 ` [PATCH 7/7] xhci: fix 10 second timeout on removal of PCI hotpluggable xhci controllers 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=570784F5.1080804@linux.intel.com \
    --to=mathias.nyman@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=main.haarp@googlemail.com \
    --cc=stable@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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.