public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: Forest <forestix@nom.one>
Cc: linux-usb@vger.kernel.org, regressions@lists.linux.dev,
	stable@vger.kernel.org
Subject: Re: [REGRESSION] usb: xhci port capability storage change broke fastboot android bootloader utility
Date: Mon, 13 Jan 2025 17:05:09 +0200	[thread overview]
Message-ID: <8a5bef2e-7cf9-4f5c-8281-c8043a090feb@linux.intel.com> (raw)
In-Reply-To: <4kb3ojp4t59rm79ui8kj3t8irsp6shlinq@sonic.net>

On 11.1.2025 2.00, Forest wrote:
> On Tue, 7 Jan 2025 14:29:35 +0200, Mathias Nyman wrote:
> 
>> Does disabling USB2 hardware LPM for the device make it work again?
>>
>> Adding USB_QUIRK_NO_LPM quirk "k" for your device vid:pid should do it.
>> i.e. add "usbcore.quirks=0fce:0dde:k" parameter to your kernel cmdline.
> 
> That fixed my test case on Debian kernel 6.12.8-amd64, which is among those
> that have been failing.
> 
> # grep EXTCAP_PORTINFO reg-ext-protocol:*
> reg-ext-protocol:00:EXTCAP_PORTINFO = 0x40000101
> reg-ext-protocol:01:EXTCAP_PORTINFO = 0x20000402
> reg-ext-protocol:02:EXTCAP_PORTINFO = 0x00190c06
> 
>>>> bool(0x40000101 & 1 << 19)
> False
>>>> bool(0x20000402 & 1 << 19)
> False
>>>> bool(0x00190c06 & 1 << 19)
> True
> 
>> Device USB2 LPM capability can be checked from the devices BOS descriptor,
>> visible (as sudo/root) with lsusb -v -d 0fce:0dde
> 
> # lsusb -v -d 0fce:0dde |grep -B 5 LPM
>    USB 2.0 Extension Device Capability:
>      bLength                 7
>      bDescriptorType        16
>      bDevCapabilityType      2
>      bmAttributes   0x00000006
>        BESL Link Power Management (LPM) Supported
> 
> I think that says the device claims support for LPM, yes?

Yes. Looks like both the device and host support USB2 LPM

I think I see what is going on.

Before commit 63a1f8454962a64746a59441687 the xhci driver apparently failed
to detect xHC USB2 LPM support if USB 3 ports were listed before USB 2 ports
in the "supported protocol capabilities.

Now that we correctly detect LPM support and enable it, it turns out the
device does not work well with USB 2 LPM enabled.

I'd recommend a patch that permanently adds USB_QUIRK_NO_LPM for this device.
Let me know if you want to submit it yourself, otherwise I can do it.

Thanks
Mathias

Additional debugging details:

We incorrectly compared usb device port numbers with xHC hardware port
numbers when checking for USB2 port capabilities.

xHC hardware has one long array of ports, including all USB 2 and USB 3 ports.
In your case host lists three sets of supported protocol capabilities:

One USB 3.2 port as the fist port at offset 1:
   reg-ext-protocol:00:EXTCAP_REVISION = 0x03200802
   reg-ext-protocol:00:EXTCAP_PORTINFO = 0x40000101

Four USB 3.1 ports starting at offset 2
   reg-ext-protocol:01:EXTCAP_REVISION = 0x03100802
   reg-ext-protocol:01:EXTCAP_PORTINFO = 0x20000402

Ten USB 2.0 ports stating at offset 6, supporting LPM
   reg-ext-protocol:02:EXTCAP_REVISION = 0x02000802
   reg-ext-protocol:02:EXTCAP_PORTINFO = 0x00190c06

Most xHC hosts used to list their USB 2.0 ports first, meaning there
was no offset difference between usb device port number and xHC port
number for USB 2.0 ports.

Usb device port numbers start from 1 on that hub, in your case it was "3"

xhci driver then checked that usb device with port number "3" does not match
the LPM supported USB 2 port range from 6 to 16 (10 LPM capabale USB 2
ports starting at offset 6).

-Mathias

  reply	other threads:[~2025-01-13 15:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-27 21:59 [REGRESSION] usb: xhci port capability storage change broke fastboot android bootloader utility Forest
2025-01-02 14:13 ` Mathias Nyman
2025-01-05 23:42   ` Forest
2025-01-07 12:29     ` Mathias Nyman
2025-01-11  0:00       ` Forest
2025-01-13 15:05         ` Mathias Nyman [this message]
2025-01-15  1:38           ` Forest
2025-01-15  7:33             ` Greg KH
2025-01-24 19:44           ` Forest
2025-01-29 11:01             ` Mathias Nyman
2025-02-13 20:24               ` Salvatore Bonaccorso
2025-02-14 12:29                 ` Mathias Nyman
2025-02-14 15:55                   ` Salvatore Bonaccorso

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=8a5bef2e-7cf9-4f5c-8281-c8043a090feb@linux.intel.com \
    --to=mathias.nyman@linux.intel.com \
    --cc=forestix@nom.one \
    --cc=linux-usb@vger.kernel.org \
    --cc=regressions@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    /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