Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp2553797rdb; Mon, 28 Aug 2023 07:58:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGOSBZAOAFSD7eNn/WcEC18HAJplH2666YJD6N+UPYsfkLPhgEiT6UiG6S21XMap/X8ellT X-Received: by 2002:a05:6808:1b27:b0:3a1:db18:401e with SMTP id bx39-20020a0568081b2700b003a1db18401emr14264925oib.1.1693234682477; Mon, 28 Aug 2023 07:58:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693234682; cv=none; d=google.com; s=arc-20160816; b=iO8HonLW/CbrfAvrFEgxYWmAwryxu2vf7NgnM35bAuFId+/OXDOUD+XWv7j+akwMUm LgCyvVgZIdQuzDJXkLipnJsL1b4CP5L+9VMnYOU3uZiUIFwQkYQHbZXUOzS4+q1vBX4f H3DUyvlY0d1FCraBoq9vY/QYwe4r8jmj/xpLQCnKK/6NhV0IHP9GUpX5CnS7eLr0KyVO IIhHyH4w46bxkFrXoyDSkQ6NTY/W1TWfGAZ5M9O41CziaRplXr9fdB2qQiAeAO6Rv/iv eg3yJEPOuMd66GdspAFwFs66Ppw20T+1Cqh1as56uD+BamCV0jrP7zVbEx4q3wb3hvsK UwMQ== 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=8N/JS1iaNFqHqqEqYpoJAWYMnuubStDK6bmLZ0BT1Ok=; fh=gqya26SlTJD2dRhVp6PQwirxJmh8r7SjNzbC3fMzgOM=; b=fDh+cpu8Ujv7OCuaVEA4Ic5U4CZkx4td3KOr4y/w0y6emjfyXaPb+DatqA6VKqXDR3 NCEKgqVi6VzGdD17PtoBJCU2gG+ozGK1W2Uhrez+5dgDYv8qJkk8CvP7qiZ+vegmpk84 RScXICfObZ9pbHRXXZgb+rSSZDQZGJKYMhgnCbwQDjdO4vRWCpms5e2T46rrpbyLOscz fLQd4O43jySf6brnnKqX7cCvqILPBTdr51UNXzP5myBTWTVM9UVVyDp21KgPYggmfktS ftnXVnumRg4LsRjvJ4NXpA7WM1+Qm67HvvAqFxPB1RVWC5d2zTBNflZhua8tMFGANsqT 4EsA== 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 m20-20020a637d54000000b0056950e15476si7486142pgn.159.2023.08.28.07.57.42; Mon, 28 Aug 2023 07:58:02 -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 S231310AbjH1Oon (ORCPT + 99 others); Mon, 28 Aug 2023 10:44:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230156AbjH1OoO (ORCPT ); Mon, 28 Aug 2023 10:44:14 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 60C7DDA for ; Mon, 28 Aug 2023 07:44:10 -0700 (PDT) Received: (qmail 352516 invoked by uid 1000); 28 Aug 2023 10:44:09 -0400 Date: Mon, 28 Aug 2023 10:44:09 -0400 From: Alan Stern To: andrey.konovalov@linux.dev Cc: Greg Kroah-Hartman , Andrey Konovalov , Felipe Balbi , Thinh Nguyen , Pawel Laszczak , Chunfeng Yun , Minas Harutyunyan , Justin Chen , Al Cooper , Herve Codina , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] usb: gadget: clarify usage of USB_GADGET_DELAYED_STATUS Message-ID: <4945ba1a-296c-49da-be09-fbbc3aba6738@rowland.harvard.edu> References: <5c2913d70556b03c9bb1893c6941e8ece04934b0.1693188390.git.andreyknvl@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5c2913d70556b03c9bb1893c6941e8ece04934b0.1693188390.git.andreyknvl@gmail.com> 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 Mon, Aug 28, 2023 at 04:10:30AM +0200, andrey.konovalov@linux.dev wrote: > From: Andrey Konovalov > > USB_GADGET_DELAYED_STATUS was introduced in commit 1b9ba000177e ("usb: > gadget: composite: Allow function drivers to pause control transfers"). > It was initially intended for the composite framework to allow delaying > completing the status stage of a SET_CONFIGURATION request until all > functions are ready. > > Unfortunately, that commit had an unintended side-effect of returning > USB_GADGET_DELAYED_STATUS from the ->setup() call of the composite > framework gadget driver. > > As a result of this and the incomplete documentation, some UDC drivers > started relying on USB_GADGET_DELAYED_STATUS to decide when to avoid > autocompleting the status stage for 0-length control transfers. dwc3 was > the first in commit 5bdb1dcc6330 ("usb: dwc3: ep0: handle delayed_status > again"). And a number of other UDC drivers followed later, probably > relying on the dwc3 behavior as a reference. > > Unfortunately, this violated the interface between the UDC and the > gadget driver for 0-length control transfers: the UDC driver must only > proceed with the status stage for a 0-length control transfer once the > gadget driver queued a response to EP0. > > As a result, a few gadget drivers are partially broken when used with > a UDC that only delays the status stage for 0-length transfers when > USB_GADGET_DELAYED_STATUS is returned from the setup() callback. > > This includes Raw Gadget and GadgetFS. For FunctionFS, a workaround was > added in commit 946ef68ad4e4 ("usb: gadget: ffs: Let setup() return > USB_GADGET_DELAYED_STATUS") and commit 4d644abf2569 ("usb: gadget: f_fs: > Only return delayed status when len is 0"). > > The proper solution to this issue would be to contain > USB_GADGET_DELAYED_STATUS within the composite framework and make all > UDC drivers to not complete the status stage for 0-length requests on > their own. > > Unfortunately, there is quite a few UDC drivers that need to get fixed > and the required changes for some of them are not trivial. > > For now, update the comments to clarify that USB_GADGET_DELAYED_STATUS > must not be used by the UDC drivers. > > The following two commits also add workarounds to Raw Gadget and GadgetFS > to make them compatible with the broken UDC drivers until they are fixed. > > Signed-off-by: Andrey Konovalov > --- Acked-by: Alan Stern