public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: "Christian Kohlschütter" <christian@kohlschutter.com>
Cc: u-boot@lists.denx.de, Lukasz Majewski <lukma@denx.de>
Subject: Re: [PATCH] usb: common: Detect USB storage media with "miscellaneous" USB devices
Date: Fri, 30 Sep 2022 04:42:16 +0200	[thread overview]
Message-ID: <c6f25cf7-23f9-059b-87e2-d5810adfb17a@denx.de> (raw)
In-Reply-To: <6CEF1818-04C9-49E6-A643-C8D92731931F@kohlschutter.com>

On 9/26/22 23:55, Christian Kohlschütter wrote:
> On 26. Sep 2022, at 01:45, Marek Vasut <marex@denx.de> wrote:
>>
>> On 9/25/22 16:46, Christian Kohlschütter wrote:
>>> When detecting USB storage devices, we currently skip everything that is
>>> not marked as "undefined device class".
>>> Composite devices such as tinyusb's CDC+MSC identify as "miscellaneous"
>>> (class 0xEF).
>>> Introduce a new constant, USB_CLASS_MISC (0xEF), and allow the detection
>>> process to proceed for USB devices with this device class.
>>
>> What does Linux do with such a device , is there a specific quirk or does it simply not check the bDeviceClass at all ?
> 
> I didn't see any  relevant checks in drivers/usb/storage, however changing the bDeviceClass from "MISC" (0xEF) to "UNSPECIFIED"/"PER_INTERFACE" (0x00) causes the device to be no longer detected by either Linux or macOS, but it would work with U-Boot (i.e., without the change).
> 
> macOS' USB prober would report the USB device as "unconfigured". On Linux, using usbutils but not busybox, lsusb would actually hang.
> 
> I think it's a good idea to keep the set of permitted device classes to a minimum (0x00 / 0xEF) and abort early in all other cases. This way, we can skip the more elaborate checks in usb_storage_probe for devices that are definitely not supported.

I think the check in the usb_storage.c is actually correct as-is and the 
device you have might be odd.

https://www.usb.org/sites/default/files/usbmassbulk_10.pdf

"
4.1 Device Descriptor
Each USB device has one device descriptor (per USB Specification). The 
device shall specify the device class and subclass codes in the 
interface descriptor, and not in the device descriptor.
...
4 | bDeviceClass | Byte | 00h | Class is specified in the interface 
descriptor.
...
NOTE: Information in this table is from the USB Specification version 
1.1 table 9-7. Bold text has been added for clarifications when using 
these descriptors with this specification.
"

And then

"
4.3 Interface Descriptors
The device shall support at least one interface, known herein as the 
Bulk-Only Data Interface. The Bulk-Only Data Interface uses three endpoints.
Composite mass storage devices may support additional interfaces, to 
provide other features such as audio or video capabilities. This 
specification does not define such interfaces.
The interface may have multiple alternate settings. The host shall 
examine each of the alternate settings to look for the 
bInterfaceProtocol and bInterfaceSubClass it supports optimally.
"

If I read this right, then such a composite device like you have should 
have bDeviceClass=0x00 and two Interface descriptors, one for the mass 
storage device and one for CDC ?

  reply	other threads:[~2022-09-30  2:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-25 14:46 [PATCH] usb: common: Detect USB storage media with "miscellaneous" USB devices Christian Kohlschütter
2022-09-25 23:45 ` Marek Vasut
2022-09-26 21:55   ` Christian Kohlschütter
2022-09-30  2:42     ` Marek Vasut [this message]
2022-09-30 21:58       ` Christian Kohlschütter
2022-09-30 22:02         ` Marek Vasut
2022-09-30 22:21           ` Christian Kohlschütter
2022-09-30 22:58             ` Christian Kohlschütter
2022-10-01 10:34               ` Christian Kohlschütter

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=c6f25cf7-23f9-059b-87e2-d5810adfb17a@denx.de \
    --to=marex@denx.de \
    --cc=christian@kohlschutter.com \
    --cc=lukma@denx.de \
    --cc=u-boot@lists.denx.de \
    /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