Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp758383rwb; Wed, 28 Sep 2022 08:45:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Ar/tHPMNhHwcV3uII0EfD3V/wM0VgR/LqPxTXBxKyQAIusHr2JdfnJ9SUZ+y/fAHr0Yg6 X-Received: by 2002:a05:6402:3547:b0:451:3be6:d55b with SMTP id f7-20020a056402354700b004513be6d55bmr33516267edd.57.1664379922431; Wed, 28 Sep 2022 08:45:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664379922; cv=none; d=google.com; s=arc-20160816; b=zevWbU+lCC203iFBj8eXkJ8o8YPMJBtOygw9hLmGX3+7yWj0vbbrXWZRV9/AFswUtC 8Ie75dbg5wyi9AQN+yvxu4+XP0/CNum+hVRWXvvCSD4yP/JwX0X2+s9Xy/fRBvWC/CIO lAcJhgFTW5PSsWiATHNY9pHLSWO5JhDtX5vITK20CiovLXRw67HbdBP9ZdtokSEOm79H Ci11aTc6DdpaVSYyKl5CF7BsPiY7nhtwh6cidpzH09GAQc3+La3z9O+xS4lQaKPQ+rnX CuGlJIZXVp3+H/d0xIgS28h+xEIBPjFkKaV26HM0nO+OqFMDCAc9oAb+rJaGD4bL43W0 TGxg== 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=cfIZ8eq+j3Gh9hP9C827U+sdjbvAAO1vgo3RR0cOEJg=; b=XtWZDun4ifCJSQ8Gi/v5g73z1XiStb0fU2H638SHzFeryFRgv02DXk9tJBalIPvn9A vqvrN5u0lY1bYln8q5d2UrvvpfLUUhTF8ilAgUAkvQ9YXzAr+MEFaD2AzDuiKu2mI7dj 4GedsYvn6f+kNws5/tTH6qpAD6IuFK0EPOCl3fAkV909N6jqXOkhfB2VLAJGly0MJrcO tmciGNC+g2L0oVhb/ND7huZ/6j2mSYXjtiWdBDoiSI4u1azdpeccoAwVpDARXr3dNwjR bwvfnh2C1csZh3Reqk9Msvq40Lglo3Zpd5xfoFhGsGGBqMxqpO0qRc1YuRREf8LDdQeT sZqg== 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 g6-20020a50d5c6000000b0045166555fddsi5158729edj.481.2022.09.28.08.44.57; Wed, 28 Sep 2022 08:45:22 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234755AbiI1PcO (ORCPT + 99 others); Wed, 28 Sep 2022 11:32:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234595AbiI1Pbz (ORCPT ); Wed, 28 Sep 2022 11:31:55 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 6BA4CCF495 for ; Wed, 28 Sep 2022 08:30:29 -0700 (PDT) Received: (qmail 490088 invoked by uid 1000); 28 Sep 2022 11:30:05 -0400 Date: Wed, 28 Sep 2022 11:30:05 -0400 From: Alan Stern To: Chunfeng Yun Cc: Greg Kroah-Hartman , Matthias Brugger , linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Eddie Hung , Min Guo , Tianping Fang , Stable@vger.kernel.org Subject: Re: [PATCH 1/2] usb: mtu3: fix ep0's stall of out data stage Message-ID: References: <20220928091721.26112-1-chunfeng.yun@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220928091721.26112-1-chunfeng.yun@mediatek.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 Wed, Sep 28, 2022 at 05:17:20PM +0800, Chunfeng Yun wrote: > It happens when enable uvc function, the flow as below: > the controller switch to data stage, then call > -> foward_to_driver() -> composite_setup() -> uvc_function_setup(), > it send out an event to user layer to notify it call > -> ioctl() -> uvc_send_response() -> usb_ep_queue(), > but before the user call ioctl to queue ep0's buffer, the host already send > out data, but the controller find that no buffer is queued to receive data, > it send out STALL handshake. > > To fix the issue, don't send out ACK of setup stage to switch to out data > stage until the buffer is available. You might find it is better to use the delayed_status routines already present in the Gadget core. Instead of delaying the response to the Setup packet of the second control transfer, delay the status response to the first control transfer. This approach has the advantage of working even when the second transfer is not control but something else, such as bulk. Also it agrees better with the way the USB spec intends control transfers to work. The UDC is not supposed to complete the status stage of a control transfer until the gadget has fully processed the transfer's information and is ready to go forward. Alan Stern