From: Paul Zimmerman <pauldzim@gmail.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Peter Chen <peter.chen@nxp.com>, USB list <linux-usb@vger.kernel.org>
Subject: Re: No disconnection event for suspended device at v5.6
Date: Wed, 15 Apr 2020 16:22:47 -0700 [thread overview]
Message-ID: <20200415162247.04012028@EliteBook> (raw)
In-Reply-To: <Pine.LNX.4.44L0.2004151352250.6539-100000@netrider.rowland.org>
Hi Alan,
On Wed, 15 Apr 2020 15:40:31 -0400 (EDT) Alan Stern <stern@rowland.harvard.edu> wrote:
> On Wed, 15 Apr 2020, Peter Chen wrote:
>
> > Hi Alan,
> >
> > With commit e5d078af8e5f ("USB: hub: Don't record a connect-change event
> > during reset-resume"),
>
> For those who care, this is commit 8099f58f1ecd in the upstream kernel.
>
> > the disconnection event for the suspended device
> > (eg, removable hub with no device connected, auto-suspended mouse) at
> > roothub can't occur due to no hub->change_bits is set. Below is the
> > debug message:
> >
> > imx_usb 30b20000.usb: at imx_controller_resume
> > usbmisc_imx 30b20200.usbmisc: wakeup int
> > ci_hdrc ci_hdrc.1: at ci_controller_resume
> > usb usb1: usb wakeup-resume
> > usb usb1: usb auto-resume
> > ci_hdrc ci_hdrc.1: resume root hub
> > hub 1-0:1.0: hub_resume
> > ci_hdrc ci_hdrc.1: GetStatus port:1 status 1c00100a 14
> > e0 PEC CSC
> > usb usb1-port1: status 0100 change 0003
> > hub 1-0:1.0: state 7 ports 1 chg 0000 evt 0000
> > hub 1-0:1.0: hub_suspend
> > usb usb1: bus auto-suspend, wakeup 1
> > ci_hdrc ci_hdrc.1: suspend root hub
> > ci_hdrc ci_hdrc.1: at ci_runtime_suspend
> > imx_usb 30b20000.usb: at imx_controller_suspend
>
> You know, I had a nagging feeling when I wrote that patch that there
> was some scenario it didn't take into account. This is it -- a device
> getting disconnected while the its parent hub is in runtime suspend.
>
> Okay, clearly that commit needs to be reverted. Luckily, the commit's
> Changelog indicates that there is an alternate way of achieving the
> same goal. The patch below contains both the revert and the new fix.
> Please let me know if it works.
>
> Paul, I trust this new patch won't mess up your Bluetooth adapter. It
> should still clear the hub->change_bits entry before the hub workqueue
> thread wakes up.
>
> Alan Stern
>
> Index: usb-devel/drivers/usb/core/hub.c
> ===================================================================
> --- usb-devel.orig/drivers/usb/core/hub.c
> +++ usb-devel/drivers/usb/core/hub.c
> @@ -1219,6 +1219,11 @@ static void hub_activate(struct usb_hub
> #ifdef CONFIG_PM
> udev->reset_resume = 1;
> #endif
> + /* Don't set the change_bits when the device
> + * was powered off.
> + */
> + if (test_bit(port1, hub->power_bits))
> + set_bit(port1, hub->change_bits);
>
> } else {
> /* The power session is gone; tell hub_wq */
> @@ -3084,6 +3089,15 @@ static int check_port_resume_type(struct
> if (portchange & USB_PORT_STAT_C_ENABLE)
> usb_clear_port_feature(hub->hdev, port1,
> USB_PORT_FEAT_C_ENABLE);
> +
> + /*
> + * Whatever made this reset-resume necessary may have
> + * turned on the port1 bit in hub->change_bits. But after
> + * a successful reset-resume we want the bit to be clear;
> + * if it was on it would indicate that something happened
> + * following the reset-resume.
> + */
> + clear_bit(port1, hub->change_bits);
> }
>
> return status;
>
Unfortunately, my testing on this is somewhat inconclusive. I updated
to the latest Linus kernel, then did about a half-dozen suspend/resume
cycles to verify it was still working. Then I applied the patch and
rebooted into the new kernel. At first I thought it was OK, but after
about 5 or 6 suspend/resume cycles, the bluetooth stopped working (the
desktop bluetooth manager in Linux Mint froze when I opened it). Another
suspend/resume cycle brought it back to life, but after a couple more
cycles it froze again.
But looking at the dmesg log, there were no errors concerning the
bluetooth adapter. With the original failure, it would show errors
before or during the firmware update of the bluetooth adapter, but
now, the firmware update seemed to complete OK. And to top it off,
after a reboot, I am no longer able to make it fail. I did more than
a dozen suspend/resume cycles and have not seen any further failures.
So, make of that what you will :)
Thanks,
Paul
next prev parent reply other threads:[~2020-04-15 23:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-15 10:32 No disconnection event for suspended device at v5.6 Peter Chen
2020-04-15 19:40 ` Alan Stern
2020-04-15 23:22 ` Paul Zimmerman [this message]
2020-04-16 14:34 ` Alan Stern
2020-04-16 19:46 ` Paul Zimmerman
2020-04-16 20:20 ` Alan Stern
2020-04-17 2:42 ` Peter Chen
2020-04-16 1:18 ` Peter Chen
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=20200415162247.04012028@EliteBook \
--to=pauldzim@gmail.com \
--cc=linux-usb@vger.kernel.org \
--cc=peter.chen@nxp.com \
--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 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).