All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: "Bjørn Mork" <bjorn@mork.no>
Cc: Oliver Neukum <oneukum@suse.com>,
	Marcel Holtmann <marcel@holtmann.org>,
	Jose Ignacio Tornos Martinez <jtornosm@redhat.com>,
	gregkh@linuxfoundation.org, linux-usb@vger.kernel.org
Subject: Re: [PATCH v4] USB: core: skip unconfiguration if device doesn't support it
Date: Thu, 5 May 2022 10:14:43 -0400	[thread overview]
Message-ID: <YnPb04ynkSTlhg4H@rowland.harvard.edu> (raw)
In-Reply-To: <87levgkyjy.fsf@miraculix.mork.no>

On Thu, May 05, 2022 at 01:29:21PM +0200, Bjørn Mork wrote:
> Oliver Neukum <oneukum@suse.com> writes:
> > On 04.05.22 14:23, Marcel Holtmann wrote:
> >>
> >>> @@ -394,6 +397,9 @@ static const struct usb_device_id usb_quirk_list[] = {
> >>> 	/* ELMO L-12F document camera */
> >>> 	{ USB_DEVICE(0x09a1, 0x0028), .driver_info = USB_QUIRK_DELAY_CTRL_MSG },
> >>>
> >>> +	/* CSR Bluetooth */
> >>> +	{ USB_DEVICE(0x0a12, 0x0001), .driver_info = USB_QUIRK_SKIP_UNCONFIGURE },
> >>> +
> >> NAK. I said this before.
> >>
> >> The VID:PID 0a12:0001 is used in millions of products that work
> >> correctly. Only because some counterfeit products get things wrong
> >> doesn’t mean all get marked as broken.
> >>
> >
> > Hi,
> >
> > if I may ask, how certain is that?
> 
> 100%.  Just get a real CSR device and try it.

Please pardon me for butting in, but I don't see how this tests the 
condition that Jose is worried about.

You start with the device being configured and working:

> canardo:/tmp# sed -ne '/ Port=07 /,/^$/p' /sys/kernel/debug/usb/devices 
> T:  Bus=01 Lev=01 Prnt=01 Port=07 Cnt=05 Dev#=  6 Spd=12   MxCh= 0
> D:  Ver= 2.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
> P:  Vendor=0a12 ProdID=0001 Rev=88.91
> C:* #Ifs= 2 Cfg#= 1 Atr=c0 MxPwr=  0mA
> I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
> E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
> E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
> I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
> E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
> I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
> E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
> I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
> E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
> I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
> E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
> I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
> E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
> I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
> E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
> 
> canardo:/tmp# hciconfig hci0
> hci0:   Type: Primary  Bus: USB
>         BD Address: 00:1A:7D:DA:71:15  ACL MTU: 310:10  SCO MTU: 64:8
>         UP RUNNING 
>         RX bytes:660 acl:0 sco:0 events:43 errors:0
>         TX bytes:2178 acl:0 sco:0 commands:43 errors:0
> 
> canardo:/tmp# ls -l /sys/bus/usb/drivers/btusb/
> total 0
> lrwxrwxrwx 1 root root    0 May  5 13:23 1-8:1.0 -> ../../../../devices/pci0000:00/0000:00:14.0/usb1/1-8/1-8:1.0
> lrwxrwxrwx 1 root root    0 May  5 13:23 1-8:1.1 -> ../../../../devices/pci0000:00/0000:00:14.0/usb1/1-8/1-8:1.1
> --w------- 1 root root 4096 May  5 13:23 bind
> lrwxrwxrwx 1 root root    0 May  5 13:22 module -> ../../../../module/btusb
> -rw-r--r-- 1 root root 4096 May  5 13:22 new_id
> -rw-r--r-- 1 root root 4096 May  5 13:22 remove_id
> --w------- 1 root root 4096 May  5 13:22 uevent
> --w------- 1 root root 4096 May  5 13:23 unbind

Then you unbind the Bluetooth driver:

> canardo:/tmp# echo 1-8:1.0 > /sys/bus/usb/drivers/btusb/unbind

But the device is still configured, as proved by the fact that there is 
a '*' following the "C:" below:

> canardo:/tmp# sed -ne '/ Port=07 /,/^$/p' /sys/kernel/debug/usb/devices 
> T:  Bus=01 Lev=01 Prnt=01 Port=07 Cnt=05 Dev#=  6 Spd=12   MxCh= 0
> D:  Ver= 2.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
> P:  Vendor=0a12 ProdID=0001 Rev=88.91
> C:* #Ifs= 2 Cfg#= 1 Atr=c0 MxPwr=  0mA
> I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=(none)
> E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
> E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
> E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
> I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=(none)
> E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
> E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
> I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=(none)
> E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
> E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
> I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=(none)
> E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
> E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
> I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=(none)
> E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
> E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
> I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=(none)
> E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
> E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
> I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=(none)
> E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
> E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms

Of course, since the btusb driver isn't bound, there is no corresponding 
Bluetooth interface in the kernel:

> canardo:/tmp# hciconfig hci0
> Can't get device info: No such device
> canardo:/tmp# ls -l /sys/bus/usb/drivers/btusb/
> total 0
> --w------- 1 root root 4096 May  5 13:23 bind
> lrwxrwxrwx 1 root root    0 May  5 13:22 module -> ../../../../module/btusb
> -rw-r--r-- 1 root root 4096 May  5 13:22 new_id
> -rw-r--r-- 1 root root 4096 May  5 13:22 remove_id
> --w------- 1 root root 4096 May  5 13:22 uevent
> --w------- 1 root root 4096 May  5 13:26 unbind

Then you rebind the driver:

> canardo:/tmp# echo 1-8:1.0 > /sys/bus/usb/drivers/btusb/bind
> canardo:/tmp# sed -ne '/ Port=07 /,/^$/p' /sys/kernel/debug/usb/devices 
> T:  Bus=01 Lev=01 Prnt=01 Port=07 Cnt=05 Dev#=  6 Spd=12   MxCh= 0
> D:  Ver= 2.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
> P:  Vendor=0a12 ProdID=0001 Rev=88.91
> C:* #Ifs= 2 Cfg#= 1 Atr=c0 MxPwr=  0mA
> I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
> E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
> E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
> I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
> E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
> I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
> E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
> I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
> E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
> I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
> E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
> I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
> E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
> I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
> E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
> 
> canardo:/tmp# hciconfig hci0
> hci0:   Type: Primary  Bus: USB
>         BD Address: 00:1A:7D:DA:71:15  ACL MTU: 310:10  SCO MTU: 64:8
>         UP RUNNING 
>         RX bytes:660 acl:0 sco:0 events:43 errors:0
>         TX bytes:2178 acl:0 sco:0 commands:43 errors:0
> 
> canardo:/tmp# ls -l /sys/bus/usb/drivers/btusb/
> total 0
> lrwxrwxrwx 1 root root    0 May  5 13:27 1-8:1.0 -> ../../../../devices/pci0000:00/0000:00:14.0/usb1/1-8/1-8:1.0
> lrwxrwxrwx 1 root root    0 May  5 13:27 1-8:1.1 -> ../../../../devices/pci0000:00/0000:00:14.0/usb1/1-8/1-8:1.1
> --w------- 1 root root 4096 May  5 13:27 bind
> lrwxrwxrwx 1 root root    0 May  5 13:22 module -> ../../../../module/btusb
> -rw-r--r-- 1 root root 4096 May  5 13:22 new_id
> -rw-r--r-- 1 root root 4096 May  5 13:22 remove_id
> --w------- 1 root root 4096 May  5 13:22 uevent
> --w------- 1 root root 4096 May  5 13:26 unbind

And presumably the device is working again.  However, none of this shows 
what happens when the device is unconfigured.  To test that, you would 
have to do:

	echo 0 >/sys/bus/usb/devices/1-8/bConfigurationValue
	echo 1 >/sys/bus/usb/devices/1-8/bConfigurationValue

and then see if the device continues to work.

Alan Stern

> I do have a couple of fake ones too.  They are mostly interesting from a
> "why the h... would anyone do that?" perspective
> 
> 
> 
> Bjørn

  reply	other threads:[~2022-05-05 14:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-04  8:36 [PATCH v4] USB: core: skip unconfiguration if device doesn't support it Jose Ignacio Tornos Martinez
2022-05-04 12:23 ` Marcel Holtmann
2022-05-04 12:32   ` Jose Ignacio Tornos Martinez
2022-05-05 10:19   ` Oliver Neukum
2022-05-05 11:15     ` Jose Ignacio Tornos Martinez
2022-05-05 12:06       ` Oliver Neukum
2022-05-05 12:35         ` Jose Ignacio Tornos Martinez
2022-05-05 11:29     ` Bjørn Mork
2022-05-05 14:14       ` Alan Stern [this message]
2022-05-05 15:22         ` Bjørn Mork
2022-05-05 16:48           ` Jose Ignacio Tornos Martinez
2022-05-05 17:04           ` Alan Stern

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=YnPb04ynkSTlhg4H@rowland.harvard.edu \
    --to=stern@rowland.harvard.edu \
    --cc=bjorn@mork.no \
    --cc=gregkh@linuxfoundation.org \
    --cc=jtornosm@redhat.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=oneukum@suse.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.