diff mbox series

usb: Disable USB3 LPM at shutdown

Message ID 20240305065140.66801-1-kai.heng.feng@canonical.com (mailing list archive)
State Accepted
Commit d920a2ed8620be04a3301e1a9c2b7cc1de65f19d
Headers show
Series usb: Disable USB3 LPM at shutdown | expand

Commit Message

Kai-Heng Feng March 5, 2024, 6:51 a.m. UTC
SanDisks USB3 storage may disapper after system reboot:

usb usb2-port3: link state change
xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x2c0
usb usb2-port3: do warm reset, port only
xhci_hcd 0000:00:14.0: xhci_hub_status_data: stopping usb2 port polling
xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2b0, return 0x2b0
usb usb2-port3: not warm reset yet, waiting 50ms
xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2f0, return 0x2f0
usb usb2-port3: not warm reset yet, waiting 200ms
...
xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x6802c0, return 0x7002c0
usb usb2-port3: not warm reset yet, waiting 200ms
xhci_hcd 0000:00:14.0: clear port3 reset change, portsc: 0x4802c0
xhci_hcd 0000:00:14.0: clear port3 warm(BH) reset change, portsc: 0x4002c0
xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x2c0
xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2c0, return 0x2c0
usb usb2-port3: not enabled, trying warm reset again...

This is due to the USB device still cause port change event after xHCI is
shuted down:

xhci_hcd 0000:38:00.0: // Setting command ring address to 0xffffe001
xhci_hcd 0000:38:00.0: xhci_resume: starting usb3 port polling.
xhci_hcd 0000:38:00.0: xhci_hub_status_data: stopping usb4 port polling
xhci_hcd 0000:38:00.0: xhci_hub_status_data: stopping usb3 port polling
xhci_hcd 0000:38:00.0: hcd_pci_runtime_resume: 0
xhci_hcd 0000:38:00.0: xhci_shutdown: stopping usb3 port polling.
xhci_hcd 0000:38:00.0: // Halt the HC
xhci_hcd 0000:38:00.0: xhci_shutdown completed - status = 1
xhci_hcd 0000:00:14.0: xhci_shutdown: stopping usb1 port polling.
xhci_hcd 0000:00:14.0: // Halt the HC
xhci_hcd 0000:00:14.0: xhci_shutdown completed - status = 1
xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x1203, return 0x203
xhci_hcd 0000:00:14.0: set port reset, actual port 2-3 status  = 0x1311
xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x201203, return 0x100203
xhci_hcd 0000:00:14.0: clear port3 reset change, portsc: 0x1203
xhci_hcd 0000:00:14.0: clear port3 warm(BH) reset change, portsc: 0x1203
xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x1203
xhci_hcd 0000:00:14.0: clear port3 connect change, portsc: 0x1203
xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x1203, return 0x203
usb 2-3: device not accepting address 2, error -108
xhci_hcd 0000:00:14.0: xHCI dying or halted, can't queue_command
xhci_hcd 0000:00:14.0: Set port 2-3 link state, portsc: 0x1203, write 0x11261
xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x1263, return 0x263
xhci_hcd 0000:00:14.0: set port reset, actual port 2-3 status  = 0x1271
xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x12b1, return 0x2b1
usb usb2-port3: not reset yet, waiting 60ms
ACPI: PM: Preparing to enter system sleep state S5
xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x12f1, return 0x2f1
usb usb2-port3: not reset yet, waiting 200ms
reboot: Restarting system

The port change event is caused by LPM transition, so disabling LPM at shutdown
to make sure the device is in U0 for warmboot.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/usb/core/port.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Kai-Heng Feng March 26, 2024, 3:38 a.m. UTC | #1
On Tue, Mar 5, 2024 at 2:52 PM Kai-Heng Feng
<kai.heng.feng@canonical.com> wrote:
>
> SanDisks USB3 storage may disapper after system reboot:
>
> usb usb2-port3: link state change
> xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x2c0
> usb usb2-port3: do warm reset, port only
> xhci_hcd 0000:00:14.0: xhci_hub_status_data: stopping usb2 port polling
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2b0, return 0x2b0
> usb usb2-port3: not warm reset yet, waiting 50ms
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2f0, return 0x2f0
> usb usb2-port3: not warm reset yet, waiting 200ms
> ...
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x6802c0, return 0x7002c0
> usb usb2-port3: not warm reset yet, waiting 200ms
> xhci_hcd 0000:00:14.0: clear port3 reset change, portsc: 0x4802c0
> xhci_hcd 0000:00:14.0: clear port3 warm(BH) reset change, portsc: 0x4002c0
> xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x2c0
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2c0, return 0x2c0
> usb usb2-port3: not enabled, trying warm reset again...
>
> This is due to the USB device still cause port change event after xHCI is
> shuted down:
>
> xhci_hcd 0000:38:00.0: // Setting command ring address to 0xffffe001
> xhci_hcd 0000:38:00.0: xhci_resume: starting usb3 port polling.
> xhci_hcd 0000:38:00.0: xhci_hub_status_data: stopping usb4 port polling
> xhci_hcd 0000:38:00.0: xhci_hub_status_data: stopping usb3 port polling
> xhci_hcd 0000:38:00.0: hcd_pci_runtime_resume: 0
> xhci_hcd 0000:38:00.0: xhci_shutdown: stopping usb3 port polling.
> xhci_hcd 0000:38:00.0: // Halt the HC
> xhci_hcd 0000:38:00.0: xhci_shutdown completed - status = 1
> xhci_hcd 0000:00:14.0: xhci_shutdown: stopping usb1 port polling.
> xhci_hcd 0000:00:14.0: // Halt the HC
> xhci_hcd 0000:00:14.0: xhci_shutdown completed - status = 1
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x1203, return 0x203
> xhci_hcd 0000:00:14.0: set port reset, actual port 2-3 status  = 0x1311
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x201203, return 0x100203
> xhci_hcd 0000:00:14.0: clear port3 reset change, portsc: 0x1203
> xhci_hcd 0000:00:14.0: clear port3 warm(BH) reset change, portsc: 0x1203
> xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x1203
> xhci_hcd 0000:00:14.0: clear port3 connect change, portsc: 0x1203
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x1203, return 0x203
> usb 2-3: device not accepting address 2, error -108
> xhci_hcd 0000:00:14.0: xHCI dying or halted, can't queue_command
> xhci_hcd 0000:00:14.0: Set port 2-3 link state, portsc: 0x1203, write 0x11261
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x1263, return 0x263
> xhci_hcd 0000:00:14.0: set port reset, actual port 2-3 status  = 0x1271
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x12b1, return 0x2b1
> usb usb2-port3: not reset yet, waiting 60ms
> ACPI: PM: Preparing to enter system sleep state S5
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x12f1, return 0x2f1
> usb usb2-port3: not reset yet, waiting 200ms
> reboot: Restarting system
>
> The port change event is caused by LPM transition, so disabling LPM at shutdown
> to make sure the device is in U0 for warmboot.
>
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>

A gentle ping...

> ---
>  drivers/usb/core/port.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
> index c628c1abc907..c50266d7ce9d 100644
> --- a/drivers/usb/core/port.c
> +++ b/drivers/usb/core/port.c
> @@ -418,8 +418,10 @@ static void usb_port_shutdown(struct device *dev)
>  {
>         struct usb_port *port_dev = to_usb_port(dev);
>
> -       if (port_dev->child)
> +       if (port_dev->child) {
>                 usb_disable_usb2_hardware_lpm(port_dev->child);
> +               usb_unlocked_disable_lpm(port_dev->child);
> +       }
>  }
>
>  static const struct dev_pm_ops usb_port_pm_ops = {
> --
> 2.34.1
>
Greg KH March 26, 2024, 5:56 a.m. UTC | #2
On Tue, Mar 26, 2024 at 11:38:48AM +0800, Kai-Heng Feng wrote:
> On Tue, Mar 5, 2024 at 2:52 PM Kai-Heng Feng
> <kai.heng.feng@canonical.com> wrote:
> >
> > SanDisks USB3 storage may disapper after system reboot:
> >
> > usb usb2-port3: link state change
> > xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x2c0
> > usb usb2-port3: do warm reset, port only
> > xhci_hcd 0000:00:14.0: xhci_hub_status_data: stopping usb2 port polling
> > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2b0, return 0x2b0
> > usb usb2-port3: not warm reset yet, waiting 50ms
> > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2f0, return 0x2f0
> > usb usb2-port3: not warm reset yet, waiting 200ms
> > ...
> > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x6802c0, return 0x7002c0
> > usb usb2-port3: not warm reset yet, waiting 200ms
> > xhci_hcd 0000:00:14.0: clear port3 reset change, portsc: 0x4802c0
> > xhci_hcd 0000:00:14.0: clear port3 warm(BH) reset change, portsc: 0x4002c0
> > xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x2c0
> > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2c0, return 0x2c0
> > usb usb2-port3: not enabled, trying warm reset again...
> >
> > This is due to the USB device still cause port change event after xHCI is
> > shuted down:
> >
> > xhci_hcd 0000:38:00.0: // Setting command ring address to 0xffffe001
> > xhci_hcd 0000:38:00.0: xhci_resume: starting usb3 port polling.
> > xhci_hcd 0000:38:00.0: xhci_hub_status_data: stopping usb4 port polling
> > xhci_hcd 0000:38:00.0: xhci_hub_status_data: stopping usb3 port polling
> > xhci_hcd 0000:38:00.0: hcd_pci_runtime_resume: 0
> > xhci_hcd 0000:38:00.0: xhci_shutdown: stopping usb3 port polling.
> > xhci_hcd 0000:38:00.0: // Halt the HC
> > xhci_hcd 0000:38:00.0: xhci_shutdown completed - status = 1
> > xhci_hcd 0000:00:14.0: xhci_shutdown: stopping usb1 port polling.
> > xhci_hcd 0000:00:14.0: // Halt the HC
> > xhci_hcd 0000:00:14.0: xhci_shutdown completed - status = 1
> > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x1203, return 0x203
> > xhci_hcd 0000:00:14.0: set port reset, actual port 2-3 status  = 0x1311
> > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x201203, return 0x100203
> > xhci_hcd 0000:00:14.0: clear port3 reset change, portsc: 0x1203
> > xhci_hcd 0000:00:14.0: clear port3 warm(BH) reset change, portsc: 0x1203
> > xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x1203
> > xhci_hcd 0000:00:14.0: clear port3 connect change, portsc: 0x1203
> > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x1203, return 0x203
> > usb 2-3: device not accepting address 2, error -108
> > xhci_hcd 0000:00:14.0: xHCI dying or halted, can't queue_command
> > xhci_hcd 0000:00:14.0: Set port 2-3 link state, portsc: 0x1203, write 0x11261
> > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x1263, return 0x263
> > xhci_hcd 0000:00:14.0: set port reset, actual port 2-3 status  = 0x1271
> > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x12b1, return 0x2b1
> > usb usb2-port3: not reset yet, waiting 60ms
> > ACPI: PM: Preparing to enter system sleep state S5
> > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x12f1, return 0x2f1
> > usb usb2-port3: not reset yet, waiting 200ms
> > reboot: Restarting system
> >
> > The port change event is caused by LPM transition, so disabling LPM at shutdown
> > to make sure the device is in U0 for warmboot.
> >
> > Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> 
> A gentle ping...

It was the middle of the merge window, we couldn't do anything with new
changes, right?

And if you wish to see patches get merged quicker, please help review
other patches on the list, that will reduce the workload of the
maintainers.  Why haven't you done that while waiting?

thanks,

greg k-h
Greg KH March 26, 2024, 5:56 a.m. UTC | #3
On Tue, Mar 05, 2024 at 02:51:38PM +0800, Kai-Heng Feng wrote:
> SanDisks USB3 storage may disapper after system reboot:
> 
> usb usb2-port3: link state change
> xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x2c0
> usb usb2-port3: do warm reset, port only
> xhci_hcd 0000:00:14.0: xhci_hub_status_data: stopping usb2 port polling
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2b0, return 0x2b0
> usb usb2-port3: not warm reset yet, waiting 50ms
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2f0, return 0x2f0
> usb usb2-port3: not warm reset yet, waiting 200ms
> ...
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x6802c0, return 0x7002c0
> usb usb2-port3: not warm reset yet, waiting 200ms
> xhci_hcd 0000:00:14.0: clear port3 reset change, portsc: 0x4802c0
> xhci_hcd 0000:00:14.0: clear port3 warm(BH) reset change, portsc: 0x4002c0
> xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x2c0
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2c0, return 0x2c0
> usb usb2-port3: not enabled, trying warm reset again...
> 
> This is due to the USB device still cause port change event after xHCI is
> shuted down:
> 
> xhci_hcd 0000:38:00.0: // Setting command ring address to 0xffffe001
> xhci_hcd 0000:38:00.0: xhci_resume: starting usb3 port polling.
> xhci_hcd 0000:38:00.0: xhci_hub_status_data: stopping usb4 port polling
> xhci_hcd 0000:38:00.0: xhci_hub_status_data: stopping usb3 port polling
> xhci_hcd 0000:38:00.0: hcd_pci_runtime_resume: 0
> xhci_hcd 0000:38:00.0: xhci_shutdown: stopping usb3 port polling.
> xhci_hcd 0000:38:00.0: // Halt the HC
> xhci_hcd 0000:38:00.0: xhci_shutdown completed - status = 1
> xhci_hcd 0000:00:14.0: xhci_shutdown: stopping usb1 port polling.
> xhci_hcd 0000:00:14.0: // Halt the HC
> xhci_hcd 0000:00:14.0: xhci_shutdown completed - status = 1
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x1203, return 0x203
> xhci_hcd 0000:00:14.0: set port reset, actual port 2-3 status  = 0x1311
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x201203, return 0x100203
> xhci_hcd 0000:00:14.0: clear port3 reset change, portsc: 0x1203
> xhci_hcd 0000:00:14.0: clear port3 warm(BH) reset change, portsc: 0x1203
> xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x1203
> xhci_hcd 0000:00:14.0: clear port3 connect change, portsc: 0x1203
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x1203, return 0x203
> usb 2-3: device not accepting address 2, error -108
> xhci_hcd 0000:00:14.0: xHCI dying or halted, can't queue_command
> xhci_hcd 0000:00:14.0: Set port 2-3 link state, portsc: 0x1203, write 0x11261
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x1263, return 0x263
> xhci_hcd 0000:00:14.0: set port reset, actual port 2-3 status  = 0x1271
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x12b1, return 0x2b1
> usb usb2-port3: not reset yet, waiting 60ms
> ACPI: PM: Preparing to enter system sleep state S5
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x12f1, return 0x2f1
> usb usb2-port3: not reset yet, waiting 200ms
> reboot: Restarting system
> 
> The port change event is caused by LPM transition, so disabling LPM at shutdown
> to make sure the device is in U0 for warmboot.
> 
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> ---
>  drivers/usb/core/port.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

What commit id does this fix?
Kai-Heng Feng March 26, 2024, 9:29 a.m. UTC | #4
On Tue, Mar 26, 2024 at 1:56 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Tue, Mar 26, 2024 at 11:38:48AM +0800, Kai-Heng Feng wrote:
> > On Tue, Mar 5, 2024 at 2:52 PM Kai-Heng Feng
> > <kai.heng.feng@canonical.com> wrote:
> > >
> > > SanDisks USB3 storage may disapper after system reboot:
> > >
> > > usb usb2-port3: link state change
> > > xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x2c0
> > > usb usb2-port3: do warm reset, port only
> > > xhci_hcd 0000:00:14.0: xhci_hub_status_data: stopping usb2 port polling
> > > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2b0, return 0x2b0
> > > usb usb2-port3: not warm reset yet, waiting 50ms
> > > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2f0, return 0x2f0
> > > usb usb2-port3: not warm reset yet, waiting 200ms
> > > ...
> > > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x6802c0, return 0x7002c0
> > > usb usb2-port3: not warm reset yet, waiting 200ms
> > > xhci_hcd 0000:00:14.0: clear port3 reset change, portsc: 0x4802c0
> > > xhci_hcd 0000:00:14.0: clear port3 warm(BH) reset change, portsc: 0x4002c0
> > > xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x2c0
> > > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2c0, return 0x2c0
> > > usb usb2-port3: not enabled, trying warm reset again...
> > >
> > > This is due to the USB device still cause port change event after xHCI is
> > > shuted down:
> > >
> > > xhci_hcd 0000:38:00.0: // Setting command ring address to 0xffffe001
> > > xhci_hcd 0000:38:00.0: xhci_resume: starting usb3 port polling.
> > > xhci_hcd 0000:38:00.0: xhci_hub_status_data: stopping usb4 port polling
> > > xhci_hcd 0000:38:00.0: xhci_hub_status_data: stopping usb3 port polling
> > > xhci_hcd 0000:38:00.0: hcd_pci_runtime_resume: 0
> > > xhci_hcd 0000:38:00.0: xhci_shutdown: stopping usb3 port polling.
> > > xhci_hcd 0000:38:00.0: // Halt the HC
> > > xhci_hcd 0000:38:00.0: xhci_shutdown completed - status = 1
> > > xhci_hcd 0000:00:14.0: xhci_shutdown: stopping usb1 port polling.
> > > xhci_hcd 0000:00:14.0: // Halt the HC
> > > xhci_hcd 0000:00:14.0: xhci_shutdown completed - status = 1
> > > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x1203, return 0x203
> > > xhci_hcd 0000:00:14.0: set port reset, actual port 2-3 status  = 0x1311
> > > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x201203, return 0x100203
> > > xhci_hcd 0000:00:14.0: clear port3 reset change, portsc: 0x1203
> > > xhci_hcd 0000:00:14.0: clear port3 warm(BH) reset change, portsc: 0x1203
> > > xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x1203
> > > xhci_hcd 0000:00:14.0: clear port3 connect change, portsc: 0x1203
> > > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x1203, return 0x203
> > > usb 2-3: device not accepting address 2, error -108
> > > xhci_hcd 0000:00:14.0: xHCI dying or halted, can't queue_command
> > > xhci_hcd 0000:00:14.0: Set port 2-3 link state, portsc: 0x1203, write 0x11261
> > > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x1263, return 0x263
> > > xhci_hcd 0000:00:14.0: set port reset, actual port 2-3 status  = 0x1271
> > > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x12b1, return 0x2b1
> > > usb usb2-port3: not reset yet, waiting 60ms
> > > ACPI: PM: Preparing to enter system sleep state S5
> > > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x12f1, return 0x2f1
> > > usb usb2-port3: not reset yet, waiting 200ms
> > > reboot: Restarting system
> > >
> > > The port change event is caused by LPM transition, so disabling LPM at shutdown
> > > to make sure the device is in U0 for warmboot.
> > >
> > > Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> >
> > A gentle ping...
>
> It was the middle of the merge window, we couldn't do anything with new
> changes, right?
>
> And if you wish to see patches get merged quicker, please help review
> other patches on the list, that will reduce the workload of the
> maintainers.  Why haven't you done that while waiting?

Good suggestion. I'll start to review the patches on the list.

>
> thanks,
>
> greg k-h
Kai-Heng Feng March 26, 2024, 9:30 a.m. UTC | #5
On Tue, Mar 26, 2024 at 1:56 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Tue, Mar 05, 2024 at 02:51:38PM +0800, Kai-Heng Feng wrote:
> > SanDisks USB3 storage may disapper after system reboot:
> >
> > usb usb2-port3: link state change
> > xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x2c0
> > usb usb2-port3: do warm reset, port only
> > xhci_hcd 0000:00:14.0: xhci_hub_status_data: stopping usb2 port polling
> > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2b0, return 0x2b0
> > usb usb2-port3: not warm reset yet, waiting 50ms
> > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2f0, return 0x2f0
> > usb usb2-port3: not warm reset yet, waiting 200ms
> > ...
> > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x6802c0, return 0x7002c0
> > usb usb2-port3: not warm reset yet, waiting 200ms
> > xhci_hcd 0000:00:14.0: clear port3 reset change, portsc: 0x4802c0
> > xhci_hcd 0000:00:14.0: clear port3 warm(BH) reset change, portsc: 0x4002c0
> > xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x2c0
> > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2c0, return 0x2c0
> > usb usb2-port3: not enabled, trying warm reset again...
> >
> > This is due to the USB device still cause port change event after xHCI is
> > shuted down:
> >
> > xhci_hcd 0000:38:00.0: // Setting command ring address to 0xffffe001
> > xhci_hcd 0000:38:00.0: xhci_resume: starting usb3 port polling.
> > xhci_hcd 0000:38:00.0: xhci_hub_status_data: stopping usb4 port polling
> > xhci_hcd 0000:38:00.0: xhci_hub_status_data: stopping usb3 port polling
> > xhci_hcd 0000:38:00.0: hcd_pci_runtime_resume: 0
> > xhci_hcd 0000:38:00.0: xhci_shutdown: stopping usb3 port polling.
> > xhci_hcd 0000:38:00.0: // Halt the HC
> > xhci_hcd 0000:38:00.0: xhci_shutdown completed - status = 1
> > xhci_hcd 0000:00:14.0: xhci_shutdown: stopping usb1 port polling.
> > xhci_hcd 0000:00:14.0: // Halt the HC
> > xhci_hcd 0000:00:14.0: xhci_shutdown completed - status = 1
> > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x1203, return 0x203
> > xhci_hcd 0000:00:14.0: set port reset, actual port 2-3 status  = 0x1311
> > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x201203, return 0x100203
> > xhci_hcd 0000:00:14.0: clear port3 reset change, portsc: 0x1203
> > xhci_hcd 0000:00:14.0: clear port3 warm(BH) reset change, portsc: 0x1203
> > xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x1203
> > xhci_hcd 0000:00:14.0: clear port3 connect change, portsc: 0x1203
> > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x1203, return 0x203
> > usb 2-3: device not accepting address 2, error -108
> > xhci_hcd 0000:00:14.0: xHCI dying or halted, can't queue_command
> > xhci_hcd 0000:00:14.0: Set port 2-3 link state, portsc: 0x1203, write 0x11261
> > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x1263, return 0x263
> > xhci_hcd 0000:00:14.0: set port reset, actual port 2-3 status  = 0x1271
> > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x12b1, return 0x2b1
> > usb usb2-port3: not reset yet, waiting 60ms
> > ACPI: PM: Preparing to enter system sleep state S5
> > xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x12f1, return 0x2f1
> > usb usb2-port3: not reset yet, waiting 200ms
> > reboot: Restarting system
> >
> > The port change event is caused by LPM transition, so disabling LPM at shutdown
> > to make sure the device is in U0 for warmboot.
> >
> > Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> > ---
> >  drivers/usb/core/port.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
>
> What commit id does this fix?

This isn't a regression, so if this question is for stable kernel, I
think all supported kernel should get the fix.

Kai-Heng
Jon Hunter Oct. 10, 2024, 2:45 p.m. UTC | #6
Hi Kai-Heng,

On 05/03/2024 06:51, Kai-Heng Feng wrote:
> SanDisks USB3 storage may disapper after system reboot:
> 
> usb usb2-port3: link state change
> xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x2c0
> usb usb2-port3: do warm reset, port only
> xhci_hcd 0000:00:14.0: xhci_hub_status_data: stopping usb2 port polling
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2b0, return 0x2b0
> usb usb2-port3: not warm reset yet, waiting 50ms
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2f0, return 0x2f0
> usb usb2-port3: not warm reset yet, waiting 200ms
> ...
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x6802c0, return 0x7002c0
> usb usb2-port3: not warm reset yet, waiting 200ms
> xhci_hcd 0000:00:14.0: clear port3 reset change, portsc: 0x4802c0
> xhci_hcd 0000:00:14.0: clear port3 warm(BH) reset change, portsc: 0x4002c0
> xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x2c0
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2c0, return 0x2c0
> usb usb2-port3: not enabled, trying warm reset again...
> 
> This is due to the USB device still cause port change event after xHCI is
> shuted down:
> 
> xhci_hcd 0000:38:00.0: // Setting command ring address to 0xffffe001
> xhci_hcd 0000:38:00.0: xhci_resume: starting usb3 port polling.
> xhci_hcd 0000:38:00.0: xhci_hub_status_data: stopping usb4 port polling
> xhci_hcd 0000:38:00.0: xhci_hub_status_data: stopping usb3 port polling
> xhci_hcd 0000:38:00.0: hcd_pci_runtime_resume: 0
> xhci_hcd 0000:38:00.0: xhci_shutdown: stopping usb3 port polling.
> xhci_hcd 0000:38:00.0: // Halt the HC
> xhci_hcd 0000:38:00.0: xhci_shutdown completed - status = 1
> xhci_hcd 0000:00:14.0: xhci_shutdown: stopping usb1 port polling.
> xhci_hcd 0000:00:14.0: // Halt the HC
> xhci_hcd 0000:00:14.0: xhci_shutdown completed - status = 1
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x1203, return 0x203
> xhci_hcd 0000:00:14.0: set port reset, actual port 2-3 status  = 0x1311
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x201203, return 0x100203
> xhci_hcd 0000:00:14.0: clear port3 reset change, portsc: 0x1203
> xhci_hcd 0000:00:14.0: clear port3 warm(BH) reset change, portsc: 0x1203
> xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x1203
> xhci_hcd 0000:00:14.0: clear port3 connect change, portsc: 0x1203
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x1203, return 0x203
> usb 2-3: device not accepting address 2, error -108
> xhci_hcd 0000:00:14.0: xHCI dying or halted, can't queue_command
> xhci_hcd 0000:00:14.0: Set port 2-3 link state, portsc: 0x1203, write 0x11261
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x1263, return 0x263
> xhci_hcd 0000:00:14.0: set port reset, actual port 2-3 status  = 0x1271
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x12b1, return 0x2b1
> usb usb2-port3: not reset yet, waiting 60ms
> ACPI: PM: Preparing to enter system sleep state S5
> xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x12f1, return 0x2f1
> usb usb2-port3: not reset yet, waiting 200ms
> reboot: Restarting system
> 
> The port change event is caused by LPM transition, so disabling LPM at shutdown
> to make sure the device is in U0 for warmboot.
> 
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> ---
>   drivers/usb/core/port.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
> index c628c1abc907..c50266d7ce9d 100644
> --- a/drivers/usb/core/port.c
> +++ b/drivers/usb/core/port.c
> @@ -418,8 +418,10 @@ static void usb_port_shutdown(struct device *dev)
>   {
>   	struct usb_port *port_dev = to_usb_port(dev);
>   
> -	if (port_dev->child)
> +	if (port_dev->child) {
>   		usb_disable_usb2_hardware_lpm(port_dev->child);
> +		usb_unlocked_disable_lpm(port_dev->child);
> +	}
>   }
>   
>   static const struct dev_pm_ops usb_port_pm_ops = {


Since this commit landed we have noticed that when rebooting our Jetson 
AGX Orin platform we see the following error messages if there are no 
USB devices connected ...

[   59.503154] usb 2-3: Failed to set U1 timeout to 0x0,error code -113 
 
 

[   59.509768] usb 2-3: Failed to set U1 timeout to 0xa,error code -113 
 
 

[   59.516381] usb 2-3: Failed to set U2 timeout to 0x4,error code -113

Now if there is no USB device we do not see the above. If I revert this 
change then I don't see any errors.

The board has a realtek hub ...

$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 13d3:3549 IMC Networks Bluetooth Radio
Bus 001 Device 003: ID 0bda:5420 Realtek Semiconductor Corp. 4-Port USB 
2.0 Hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 002: ID 0bda:0420 Realtek Semiconductor Corp. 4-Port USB 
3.0 Hub

This uses the generic USB hub driver. AFAICT the host is not shutdown 
before the hub, but the hub is failing to set this timeout. If you have 
any thoughts, let me know.

Jon
diff mbox series

Patch

diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index c628c1abc907..c50266d7ce9d 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -418,8 +418,10 @@  static void usb_port_shutdown(struct device *dev)
 {
 	struct usb_port *port_dev = to_usb_port(dev);
 
-	if (port_dev->child)
+	if (port_dev->child) {
 		usb_disable_usb2_hardware_lpm(port_dev->child);
+		usb_unlocked_disable_lpm(port_dev->child);
+	}
 }
 
 static const struct dev_pm_ops usb_port_pm_ops = {