Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2267680ybb; Fri, 27 Mar 2020 02:16:07 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsmll2lRx9l6KBPsF6dpLP0BuHhpencOvSoukv/Fn3UytImTvM7SYuM/yeZUSN6DumrEEwW X-Received: by 2002:a9d:6446:: with SMTP id m6mr9063027otl.122.1585300566972; Fri, 27 Mar 2020 02:16:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585300566; cv=none; d=google.com; s=arc-20160816; b=p/M1wf7hYbBO48XZ6Enzz/KopP7UOJyJ+zC5jChzogIBP7ZsQWvpUISlhARYM4o5BI YhYuO6qCo+/KkqSGVmdqREHGvHpwpU087+jinIRtxgmYyjQnxp9mg1qCmdF4fjDz+f1y tcHTqbpuu8odc/vyZ4uLhW0c2vJeniI7GGh+RQDQSJ87YK6RCsmM+Yexmfl0BtpwbFU/ B26+z0WZ2m628gzr2LEbg1ToozQuxhgdLC3cwfoM1r1h8CRzZdeTGHfdpK7XwiHcKo6D 9gO9kNe3yPKLi08YYdbRI+zkNtjda6O1hLxix40aW6qAUc5xXPSxfYUuFzkNFH0DbYnI AlTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=i5/GTfOj6acDIGpcrU7CL6Wpgc2I8NpZJXqjKZ1f8xw=; b=KHweRSglckL9j1pv9Bk1aucg9R1n2LBsVAK2vGDWwVhQJ5r7UUwLG/px75Jm0OUxEA R+t2dbBLaK2FnmD8gVCJ/NgLuRyHFoY96iUm6WM+/QT6Yzc1jQs+/2aaWAVOcT/9gq9W RbYeqfumS6rkveHdZIitFOqTOiZZkE2tQVy77zx2YL94QenyoZEysmzW6yrF8jwjv1WR q4HO6c/m2LxqXHixP4AnP7hhu1n/BW4KTTd6LY6e/kuB0JfyNIGTgcSnW3t4ysxlgPEa 8PPF6LOBwDpPnvEntm8AzLggpd7MOND22fSZcgJ2OGtLDLIam/nSVosoBe4ae/iEAVgY hJpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@metafoo.de header.s=default2002 header.b=CXyIlPI1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=metafoo.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e16si2338793ote.190.2020.03.27.02.15.53; Fri, 27 Mar 2020 02:16:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@metafoo.de header.s=default2002 header.b=CXyIlPI1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=metafoo.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726450AbgC0JOV (ORCPT + 99 others); Fri, 27 Mar 2020 05:14:21 -0400 Received: from www381.your-server.de ([78.46.137.84]:60896 "EHLO www381.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726096AbgC0JOV (ORCPT ); Fri, 27 Mar 2020 05:14:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=i5/GTfOj6acDIGpcrU7CL6Wpgc2I8NpZJXqjKZ1f8xw=; b=CXyIlPI1fbD/tvHVU1oew63ga7 V3a4bhgbnN/UCS7lS/EkZ1S+0TX3+VNmhX6mK9xlpH5+hWXm15ypyQguBR18+YMX+se3b0QSPhNUJ HXyZQco3SxOGRcb6NseLfQ8YlojPrJQ9bCN9UbNo2qQ06sxcB3wz0hOMTvo3cdzFvAxvb2kiLzmtC cmUyg/bvUrh0r697HtgZ5gpQDLdYc+f4m5Mz4dcKLKf/fyDWNEB2uVdtL2h3dwqFUQAYzWsHsU5So xYHgA/D2ru9rHCCYq1m3nMPh3Vh4o6rnZJg0INChoLW+sX0f1LWmVPA27Oq55FirZ0qVaeuDRhNfv i/9KZjEQ==; Received: from sslproxy02.your-server.de ([78.47.166.47]) by www381.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1jHl48-0006uj-Ca; Fri, 27 Mar 2020 10:14:16 +0100 Received: from [82.135.64.145] (helo=[192.168.178.20]) by sslproxy02.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jHl48-000RZG-3B; Fri, 27 Mar 2020 10:14:12 +0100 Subject: Re: [PATCH] usb: dwc3: gadget: don't dequeue requests on already disabled endpoints To: Michael Grzeschik , alexandru.Ardelean@analog.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, balbi@kernel.org Cc: gregkh@linuxfoundation.org, bigeasy@linutronix.de, m.olbrich@pengutronix.de, kernel@pengutronix.de References: <20200327084302.606-1-m.grzeschik@pengutronix.de> From: Lars-Peter Clausen Message-ID: Date: Fri, 27 Mar 2020 10:14:10 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200327084302.606-1-m.grzeschik@pengutronix.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.102.2/25763/Thu Mar 26 14:07:34 2020) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/27/20 9:43 AM, Michael Grzeschik wrote: > dwc3_gadget_ep_disable gets called before the last request gets > dequeued. > > In __dwc3_gadget_ep_disable all started, pending and cancelled > lists for this endpoint will call dwc3_gadget_giveback in > dwc3_remove_requests. > > After that no list containing the afterwards dequed request, > therefor it is not necessary to run the dequeue routine. > > Signed-off-by: Michael Grzeschik > --- > @Lars-Peter Clausen: > > This patch addresses the case that not queued requests get dequeued. > The only case that this happens seems on disabling the gadget. I don't believe it does. Calling usb_ep_dequeue() is not limited to be called after the endpoint has been disabled. It is part of the API and can be called at any time. E.g. with function_fs you can abort a queued transfer from userspace at any time. - Lars > > drivers/usb/dwc3/gadget.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c > index 9a6f741d1db0dc..5d4fa8d6c93e49 100644 > --- a/drivers/usb/dwc3/gadget.c > +++ b/drivers/usb/dwc3/gadget.c > @@ -1609,6 +1609,9 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, > > trace_dwc3_ep_dequeue(req); > > + if (!(dep->flags & DWC3_EP_ENABLED)) > + return 0; > + > spin_lock_irqsave(&dwc->lock, flags); > > list_for_each_entry(r, &dep->pending_list, list) {