Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp4072310rdb; Wed, 30 Aug 2023 14:55:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFbGqRG/nJk2QAZb54b+71tZ+FW7ldHr6hunlE7Nng5hTSjTDWah+A4HNVuCo3QcjHh3hz/ X-Received: by 2002:a17:906:114:b0:99b:e464:bf49 with SMTP id 20-20020a170906011400b0099be464bf49mr2854533eje.51.1693432557729; Wed, 30 Aug 2023 14:55:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693432557; cv=none; d=google.com; s=arc-20160816; b=rUEpU+hCFnGVjO7zuhdi43BE0sIs7tAPiYC1i+4bEvRdsIcr5w/PYZUqt/06SikPgq NYSSYwqrxc3E2vGMNxiPJMqAbk7rRtvOvNIPjxM1N7Lvs8yt8SzW/g6wCK07/bFqjjUE k8xDzPXufVpaWrEATEVoLvjuvaxBie2fo5ACcgfintJKxMF/FJXUBa1BaXy6Tlb6uYRE /fO+s9fRHqtcbtutBC22Q6Fz2+N+337fOvIEgszoschoRkDH8lm5lhNP9E/OC2/jwkPk qwBwXnjqto9qNyQQKHLNJjvd+Nv6ITcJ7oqGuG64rNiJa+VtUuyzS/1KyAGIKFYITSuy AKnQ== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=UQrHq1SPnGExxGpaJLbRrYSuOfyfqUU4OFpq7DP+g1Q=; fh=XnsASkDwoWbxKLJ/ZrrQ6sXFcKllufrThwaenTuqWvE=; b=N1hM4z58TBB9xidy+1Fk9mxDPLnkPlSAdYbEOrEtORcBmKzH2RX5JqvmxspuGr+nx2 H/iJxBIdroEp7cne/Mgg/Qq6Q/XoYReAc4Vq2WibgaM+/laTLUik3uUEunlZe5xMzW0d 8cmoVklBdoT45JuY+tflWeIVKqcLg6Edt3wzWxcS1nMOLG5b1rPhG4RthcenzWyFcxbD 0rhv7udeB7VXQ8v3luHf9j1/26w/rJ6WvPg1vPxv95JfZ6e9fGyjvWO4pKPFLdVZIxzO 6DIOD7R35c/yOiijSax66QuLdh+vncupPWk2W4svBSPnLjMqDdN2wfPtIzMeQFCPJ4Ae lfhw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ss4-20020a170907c00400b0099bbed21b65si26112ejc.1014.2023.08.30.14.55.28; Wed, 30 Aug 2023 14:55:57 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244851AbjH3Svb (ORCPT + 99 others); Wed, 30 Aug 2023 14:51:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245209AbjH3OsH (ORCPT ); Wed, 30 Aug 2023 10:48:07 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id A744B11B for ; Wed, 30 Aug 2023 07:48:03 -0700 (PDT) Received: (qmail 423072 invoked by uid 1000); 30 Aug 2023 10:48:02 -0400 Date: Wed, 30 Aug 2023 10:48:02 -0400 From: Alan Stern To: Thinh Nguyen Cc: Andrey Konovalov , Felipe Balbi , Greg Kroah-Hartman , USB list , LKML Subject: Re: dwc3: unusual handling of setup requests with wLength == 0 Message-ID: <61cf24db-9dbb-4bf3-aafe-d515fc37cca8@rowland.harvard.edu> References: <20230823021429.rlgixqehry4rsqmm@synopsys.com> <5d5973b9-d590-4567-b1d6-4b5f8aeca68b@rowland.harvard.edu> <20230823175903.bpumanwv5fkpwc44@synopsys.com> <08a3759d-4c6b-4034-8516-685e4d96a41e@rowland.harvard.edu> <20230823222202.k7y7hxndsbi7h4x7@synopsys.com> <9b175f9e-ab70-47a3-a943-bfd05601aa23@rowland.harvard.edu> <20230826012024.mboftu3wk7fsrslp@synopsys.com> <20230830013222.ukw5dtburjnrrjko@synopsys.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230830013222.ukw5dtburjnrrjko@synopsys.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,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 Wed, Aug 30, 2023 at 01:32:28AM +0000, Thinh Nguyen wrote: > That reminds me another thing, if the host (xhci in this case) does a > hard reset to the endpoint, it also resets the TRB pointer with dequeue > ep command. So, the transfer should not resume. It needs to be > cancelled. This xHCI behavior is the same for Windows and Linux. That's on the host side, right? How does this affect the gadget side? That is, cancelling a transfer on the host doesn't necessarily mean it has to be cancelled on the gadget. Does it have any implications at all for the gadget driver? > > I think it should be the opposite; the class protocol should specify > > how to recover from errors. If for no other reason then to avoid the > > data duplication problem for USB-2. However, if it doesn't specify a > > recovery procedure then there's not much else you can do. > > Right, unfortunately that's not always the case that class protocol > spell out how to handle transaction error. All too true... > > But regardless, how can the gadget driver make any use of the > > knowledge that the UDC received a Clear-Halt? What would it do > > differently? If the intent is simply to clear an error condition and > > continue with the existing transfer, the gadget driver doesn't need to > > do anything. > > It's not simple to clear an error. It is to notify the gadget driver to > cancel the active transfer and resync with the host. How does the gadget driver sync with the host if the class protocol doesn't say what should be done? Also, what if there is no active transfer? That is, what if the transaction that got an error on the host appeared to be successful on the gadget and it was the last transaction in the final transfer queued for the endpoint? How would the UDC driver notify the gadget driver in this situation? > This is observed in > UASP driver in Windows and how various consumer UASP devices handle it. I don't understand what you're saying here. How can you observe whether a transfer is cancelled in a consumer UAS device? And how does the consumer device resync with the host? > There no eqivalent of Bulk-Only Mass Storage Reset request from the > class protocol. We still have the USB analyzer traces for this. Can you post an example? Not necessarily in complete detail, but enough so that we can see what's going on. > Regardless whether the class protocol spells out how to handle the > transaction error, if there's transaction error, the host may send > CLEAR_FEATURE(halt_ep) as observed in Windows. The gadget driver needs > to know about it to cancel the active transfer and resync with the host. I'll be able to understand this better after seeing an example. Do you have any traces that were made for a High-speed connection (say, using a USB-2 cable)? It would probably be easier to follow than a SuperSpeed example. Alan Stern