Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp9767403rwl; Sun, 1 Jan 2023 09:39:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXuFSlY9O7xHzU8cBKoIyiQeZgrjWdFhSlBZpNlvIP8bqRMPPwjWSVTn1dVUKNyoWpgQuNt2 X-Received: by 2002:aa7:df82:0:b0:473:280e:1959 with SMTP id b2-20020aa7df82000000b00473280e1959mr31056412edy.16.1672594779173; Sun, 01 Jan 2023 09:39:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672594779; cv=none; d=google.com; s=arc-20160816; b=CFO+GJt++D2nPBxSadr7O9fPd95iqWUm5pkiE8xp889gqz6YgHIJVLv4doc2ILoztr vVN4jfA9sSxgZFV/SQsFn3v3cJeKVt+wUFxlN5JlvyXnhG9HWrlK2/4Ugyi+au9POHqO 7v7LdyzomHZxGFsl0x0zaU4u/5HFz409YnrVrC73UVIeHcAbd4XisDWH4BN0ja4t2jVf E6JVQcz82ytpt/aHaSa+ZlzT6iv86sUlVLFlBAZoHevrM0JEEpCmFXv6FK2oX0f1ZVbS mLRyV0n7kE4BDkNAMdljkCCMCenxtxxskL2wospDBiHCvMV+TQijZVcclR5ocVclj+5g 8Ruw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=KcQzvQ4FDAEVMBsI1bhb+VPLRZbKQnXjwuCFqpQ7+7w=; b=xKbhVLbKg8+EfxkL0Lwek06k+YuJnqqz/X5ePjq0zXOMYWeiqRGPGAlJEX1hdcq+Pj S8QmEcW3PulXmGD54/jOE8Pl+m/dxcWLtFqIF8aN8Jb6UAZrclmtINU3NrAskIcH2UI0 SWhAv+KAdf4q/WPBE7eUZc46OlbaEWkao+wqPwQHLkce70LDOopsDAmlD7eyusc4rlkK hBWSR/xyi4hXWSORZNmPJF10ZYLds/2WNtKIPLnx7LenP4RrVHYj/7eNQS43lyr5yhY/ pnzSLUy0RrLSHuUrBM9lu5a9b7AfRZdbvi1stobH1xBsDpzFEAB9t/Efcr/sKymEddNo Spzg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r26-20020aa7c15a000000b00485dea76f09si13593563edp.634.2023.01.01.09.39.19; Sun, 01 Jan 2023 09:39:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229817AbjAAQVi (ORCPT + 60 others); Sun, 1 Jan 2023 11:21:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229883AbjAAQVf (ORCPT ); Sun, 1 Jan 2023 11:21:35 -0500 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 57834DFC for ; Sun, 1 Jan 2023 08:21:34 -0800 (PST) Received: (qmail 386026 invoked by uid 1000); 1 Jan 2023 11:21:33 -0500 Date: Sun, 1 Jan 2023 11:21:33 -0500 From: Alan Stern To: =?iso-8859-1?Q?J=F3_=C1gila?= Bitsch Cc: Christophe JAILLET , gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: Re: [PATCH v1] usb: gadget: add WebUSB support Message-ID: References: <7615b2ac-a849-94a7-94a5-fb1c2075d7db@wanadoo.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Dec 31, 2022 at 09:26:44PM +0100, J? ?gila Bitsch wrote: > On Sat, Dec 31, 2022 at 8:47 PM Alan Stern wrote: > > > > On Fri, Dec 30, 2022 at 09:11:43PM +0100, J? ?gila Bitsch wrote: > > > > > > During device enumeration, a host recognizes that the announced > > > USB version is at least 2.01, which means, that there are BOS > > > > Where is this 2.01 value specified? I don't remember seeing it in the > > usual USBIF documents. > > This is actually from the backport of BOS descriptors to USB 2 > > Citing Randy Aull from > https://community.osr.com/discussion/comment/249742/#Comment_249742 > > There is no specification called USB 2.1, however there is such a thing as a USB 2.1 device. > > The USB 2.0 ECN for LPM introduced a new descriptor request to the enumeration process > > for USB 2 devices (the BOS descriptor set). The problem is that software can't request a new > > descriptor type to old devices that don't understand it without introducing compatibility issues > > with some devices (more than you would probably expect). So, software needed a way to > > identify whether a device could support the host requesting a BOS descriptor set. The solution > > in this ECN was to require devices supporting the ECN to set their bcdUSB to 0x0201 (2.01). > > > > Now, when we created the USB 3.0 spec, we again wanted to leverage the BOS descriptor, not > > only because we wanted to mandate USB 2 LPM in 3.0 devices when operating at high-speed, > > but also so the device can indicate to a host that it can operate at SuperSpeed (to support > > everyone's favorite "your device can perform faster" popup). Knowing that when operating at > > high-speed these devices needed to report the BOS descriptor set, we knew that it couldn't > > set the bcdUSB to 0x0200. We mistakenly wrote it down as 0x0210 instead of 0x0201 in the > > 3.0 spec (perhaps we just said "two point one" which might have been ambiguous) when we > > were trying to just be consistent with the requirement from the LPM ECN. So, rather than > > changing it back to 0x0201 in the USB 3.0 spec, we just ran with it. > > > > So, there are USB 2.0 devices, USB 2.01 devices and USB 2.1 devices, even though the latest > > revision of the USB 2 spec is USB 2.0. I have recommended that the USB-IF actually create a > > USB 2.1 specification that captures all of the various errata, ECNs, etc from over the years, but > > it hasn't happened yet. Interesting history. And now that you point it out, I do see at the end of section 3 of the USB 2.0 Link Power Management ECN: Devices that support the BOS descriptor must have a bcdUSB value of 0201H or larger. > Btw, configfs already includes these version codes to support Link > Power Management (LPM) and > the associated BOS descriptor, so I didn't add that part, I only added > webusb as a condition as to > when to send BOS descriptors. Right. > > > @@ -713,14 +714,16 @@ static int bos_desc(struct usb_composite_dev *cdev) > > > * A SuperSpeed device shall include the USB2.0 extension descriptor > > > * and shall support LPM when operating in USB2.0 HS mode. > > > */ > > > - usb_ext = cdev->req->buf + le16_to_cpu(bos->wTotalLength); > > > - bos->bNumDeviceCaps++; > > > - le16_add_cpu(&bos->wTotalLength, USB_DT_USB_EXT_CAP_SIZE); > > > - usb_ext->bLength = USB_DT_USB_EXT_CAP_SIZE; > > > - usb_ext->bDescriptorType = USB_DT_DEVICE_CAPABILITY; > > > - usb_ext->bDevCapabilityType = USB_CAP_TYPE_EXT; > > > - usb_ext->bmAttributes = cpu_to_le32(USB_LPM_SUPPORT | > > > - USB_BESL_SUPPORT | besl); > > > + if (cdev->gadget->lpm_capable) { > > > > This change doesn't seem to be related to the purpose of this patch. > > Actually, it is. > > Previously, BOS descriptors would only ever be sent if the device was > lpm_capable. > For this reason, this descriptor was previously sent unconditionally. > > With my patch in place, it could be that a device is not lpm_capable, but still > wants to send BOS descriptors to announce its WebUSB capability, > therefore I added > this condition. Okay. It would be good to explain this in the patch description. Alan Stern