Re: [PATCH] xhci: Disable connect, disconnect and over-current wakeup on system suspend

From: Kai-Heng Feng
Date: Thu Aug 17 2023 - 20:03:18 EST


On Thu, Aug 17, 2023 at 10:07 PM Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:
>
> On Thu, Aug 17, 2023 at 05:33:05PM +0800, Kai-Heng Feng wrote:
> > HP ProOne 440 G10 AIO sometimes cannot suspend as xHCI wakes up the
> > system:
> > [ 445.814574] hub 2-0:1.0: hub_suspend
> > [ 445.814652] usb usb2: bus suspend, wakeup 0
> > [ 445.824629] xhci_hcd 0000:00:14.0: Port change event, 1-11, id 11, portsc: 0x202a0
>
> What is the meaning of the 0x202a0 bits? What caused this wakeup?

The USB touchpanel is disconnecting from the USB bus. CCS is 0.

>
> > [ 445.824639] xhci_hcd 0000:00:14.0: resume root hub
> > [ 445.824651] xhci_hcd 0000:00:14.0: handle_port_status: starting usb1 port polling.
> > [ 445.844039] xhci_hcd 0000:00:14.0: PM: pci_pm_suspend(): hcd_pci_suspend+0x0/0x20 returns -16
> > [ 445.844058] xhci_hcd 0000:00:14.0: PM: dpm_run_callback(): pci_pm_suspend+0x0/0x1c0 returns -16
> > [ 445.844072] xhci_hcd 0000:00:14.0: PM: failed to suspend async: error -16
> > [ 446.276101] PM: Some devices failed to suspend, or early wake event detected
> >
> > The system is designed to let display and touchpanel share the same
> > power source, so when the display becomes off, the USB touchpanel also
> > lost its power and disconnect itself from USB bus. That doesn't play
> > well when most Desktop Environment lock and turnoff the display right
> > before entering system suspend.
>
> I don't see why that should cause any trouble. The display gets locked
> and turned off, the touchpanel disconnects from the USB bus, and then
> the system goes into suspend. Why would there be a wakeup signal at
> this point?

The disconnecting can happens during the system suspend process, so
the suspend process is aborted.


>
> > So for system-wide suspend, also disable connect, disconnect and
> > over-current wakeup to prevent spurious wakeup.
>
> Whether to disable these things is part of the userspace policy. The
> kernel should not make the decision; the user does by enabling or
> disabling wakeups.

The power/wakeup is already disabled.

The disconnecting event is from roothub and if roothub wakeup is
disabled, other USB devices lose the ability to wake the system up
from system suspend.

Kai-Heng

>
> Alan Stern
>
> > Signed-off-by: Kai-Heng Feng <kai.heng.feng@xxxxxxxxxxxxx>
> > ---
> > drivers/usb/host/xhci.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> > index fae994f679d4..dc499100efa6 100644
> > --- a/drivers/usb/host/xhci.c
> > +++ b/drivers/usb/host/xhci.c
> > @@ -16,6 +16,7 @@
> > #include <linux/module.h>
> > #include <linux/moduleparam.h>
> > #include <linux/slab.h>
> > +#include <linux/suspend.h>
> > #include <linux/dmi.h>
> > #include <linux/dma-mapping.h>
> >
> > @@ -789,7 +790,7 @@ static void xhci_disable_hub_port_wake(struct xhci_hcd *xhci,
> > t2 = t1;
> >
> > /* clear wake bits if do_wake is not set */
> > - if (!do_wakeup)
> > + if (!do_wakeup || pm_suspend_target_state != PM_SUSPEND_ON)
> > t2 &= ~PORT_WAKE_BITS;
> >
> > /* Don't touch csc bit if connected or connect change is set */
> > --
> > 2.34.1
> >