All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-renesas-soc@vger.kernel.org"
	<linux-renesas-soc@vger.kernel.org>
Subject: Re: How to resolve "Waited 2000ms for CONNECT" in system resuming?
Date: Wed, 8 Feb 2017 10:38:33 -0500 (EST)	[thread overview]
Message-ID: <Pine.LNX.4.44L0.1702081015570.2175-100000@iolanthe.rowland.org> (raw)
In-Reply-To: <HK2PR06MB0548FBFE65472F5899848A9BD8420@HK2PR06MB0548.apcprd06.prod.outlook.com>

On Wed, 8 Feb 2017, Yoshihiro Shimoda wrote:

> Hi,
> 
> In my environment, it causes the following message during system resume if debug messages are enabled:
> 
> 	usb 2-1: Waited 2000ms for CONNECT

This message indicates that the port was connected to a device when the 
system suspended, but when the system resumed the port was not 
connected.  (Or the device did not properly enable its terminating 
resistors, or some other problem of the same general sort.)

> < My environment >
>  - EHCI/OHCI controllers on R-Car H3 (arch/arm64/boot/dts/renesas/r8a7795-salvator-x.dts)
>  - Greg's usb.git / next branch (c95a9f83711bf53faeb4ed9bbb63a3f065613dfb) + some dts patches for R-Car H3
>  - A USB 1.1 (full speed) device (A USB1.1 hub is easy to reproduce)
> 
> < Details >
> - I investigated this issue and I found the issue is related the workqueue of drivers/usb/core/hub.c.
>   If I modified the flags from WQ_FREEZABLE to "0", the issue disappeared.
> 
> 	/*
> 	 * The workqueue needs to be freezable to avoid interfering with
> 	 * USB-PERSIST port handover. Otherwise it might see that a full-speed
> 	 * device was gone before the EHCI controller had handed its port
> 	 * over to the companion full-speed controller.
> 	 */
> 	hub_wq = alloc_workqueue("usb_hub_wq", WQ_FREEZABLE, 0);

That workqueue _must_ be freezable, as explained in the comment.

> - IIUC, an EHCI connects a full speed device first. After bus reset, an OHCI can connect the device.
>   However, if WQ_FREEZABLE is set, the hub driver cannot issue bus reset while system resuming,

That's not true at all.  The port _does_ get reset, by
ehci_handover_companion_ports() in drivers/usb/host/ehci-hub.c.  This 
code runs as part of the hub driver's resume routine, not in the hub_wq
workqueue.

>   and then the issue happened.
> 
> - I also found another option about "persist" feature on sysfs. If a USB1.1 device (exclude a hub) is connected,
>   we can disable the feature via sysfs and then the issue also disappeared.
> 
> < Question >
> How to resolve the issue?
>  - Can we modified the flags of the hub's workqueue?

Definitely not.

>  - Should we disable the persist feature if we need to avoid the wait in system resume?

You can disable it if you want, but you probably won't like the
results.  (See what happens if you suspend the system while a flash
drive is plugged into your USB-1.1 hub and is mounted.)

>  - Or, other ideas?

Do some additional debugging and figure out why 
ehci_handover_companion_ports() isn't working properly on your system.

Alan Stern

  reply	other threads:[~2017-02-08 16:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-08  6:24 How to resolve "Waited 2000ms for CONNECT" in system resuming? Yoshihiro Shimoda
2017-02-08 15:38 ` Alan Stern [this message]
2017-02-09  8:41   ` Yoshihiro Shimoda
2017-02-09 15:28     ` Alan Stern
2017-02-13  9:35       ` Yoshihiro Shimoda
2017-02-13 16:35         ` Alan Stern
2017-02-14 12:02           ` Yoshihiro Shimoda
2017-02-14 17:56             ` Alan Stern
2017-02-15  2:24               ` Yoshihiro Shimoda

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=Pine.LNX.4.44L0.1702081015570.2175-100000@iolanthe.rowland.org \
    --to=stern@rowland.harvard.edu \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=yoshihiro.shimoda.uh@renesas.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 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.