From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 90CD0C433FE for ; Fri, 30 Sep 2022 02:42:23 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9704784C4A; Fri, 30 Sep 2022 04:42:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1664505740; bh=BodKEvlkIFv+3/+bWYSabBzdRU/qt06sB4YYJF3NcbE=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=eMZcakpk3fjDwi/YUT9NFQa1AYERqDeN73FHUnsYlobxyN1XuAhOosq7zHqu1MhUY 6G/+C+X11YtKq8uv5GJ0UiGpf+atuWzcf8O/UK4X5MSnrxySSaOpG0aSGrT9500iN4 wED/AI2NxDPW4NKhEVO/n9ba2fhekpUaXgAiidyD6I6AbLwxmxFk/wph3ql4qt/7ra qwHieltIYqG/OLJUoxdesU3IcUdKaOomFYQ2sc8iC3eYCg+ltkBwM4rNeYQPPk2eBZ osjUpZUOOE1dvE6QDoidRGcsghqWic5EN2hyBK81NPY53KNRFiRUbFV/rA8TPr5Ii/ ZntyqWG9/ACbw== Received: from [127.0.0.1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id C80A984956; Fri, 30 Sep 2022 04:42:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1664505738; bh=BodKEvlkIFv+3/+bWYSabBzdRU/qt06sB4YYJF3NcbE=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Eszh3uaSGlHAZA1IWjKmgFwYS7KdvYCApC2v21ydSlu6/0uow5sB9s0zwbp4rMuPS xgMuOWXWf4mu5IiPDYduPEk3PPYiO+Q/31Arlvw1zwt2CBP14SuX++mvbTVVFED7uR dpYMBKpf/W9OzlTS3rBY27PiQRKfMACfV9AAZAj0FA3XXwnK+4fdW/PECFl6dXedz/ JBvMl6d2tYl/b2TkkIzPdskdtLmc4hnh2H/tcmb02I84e77GK5/OHI8Eb9RQqe+b6b t9L/SoR1N/p8+QbVWjgbwi0b5BM3RWerjzD97+a+RZlZV29/fXWpQQNH1k3/t8odAg a+6d3QPYJAVGA== Message-ID: Date: Fri, 30 Sep 2022 04:42:16 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: [PATCH] usb: common: Detect USB storage media with "miscellaneous" USB devices To: =?UTF-8?Q?Christian_Kohlsch=c3=bctter?= Cc: u-boot@lists.denx.de, Lukasz Majewski References: <20220925144609.11727-1-christian@kohlschutter.com> <31608852-c693-5ff3-3ba2-f61b60b9bcd5@denx.de> <6CEF1818-04C9-49E6-A643-C8D92731931F@kohlschutter.com> Content-Language: en-US From: Marek Vasut In-Reply-To: <6CEF1818-04C9-49E6-A643-C8D92731931F@kohlschutter.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean On 9/26/22 23:55, Christian Kohlschütter wrote: > On 26. Sep 2022, at 01:45, Marek Vasut 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 ?