Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp613904ybc; Tue, 12 Nov 2019 06:42:20 -0800 (PST) X-Google-Smtp-Source: APXvYqx3B/k3feEWPOJiTQp2TQc9bBmAcgIFtaHSIVbhWkixKxKKmGxNRNxNqxIL+/vm4ATbMyQo X-Received: by 2002:a17:906:5502:: with SMTP id r2mr29149524ejp.3.1573569739852; Tue, 12 Nov 2019 06:42:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573569739; cv=none; d=google.com; s=arc-20160816; b=KZf4BVO1hgTKrgDuHWcCgs5lM7Sn+xHcKdfhiw9uQeGC/A2uVa/8Mf3o/Zuhbys+/z 1xzqpGHa4EbA0gXoumrOs+UmbbNHvk728bwFX4ObzUVI9LzkZUWLQhhOS2SXlITASKhx 9wdnUHRtKVud4fqkYtj5wCiTvEFcVkIPa6ethUZeOkmpYzTMMxsLTa9qWQZLcsWS5elp SICtPdimBU/QNAB+xnt6mMUGwKdsL2cJl8dSFNCY9DYOiSMPTWNxoHHbbjVIPSBz8p2K a9WLm7gNhXvXs0iX+pAkhhaS460CL+p0PX92bD65IDOqCP2pFVYVs1vLsDI5+OolmEVa 2Ytg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date; bh=6W7fQ5Qyx+KWDPHZEyriF9Gz/xpCpKljV7Hs5VkXSIQ=; b=uwObAW8IeQETrDiztOOel/TKnfYD3FXbSFyKVHOcakMNzhYfQcXe4mDS+QE94X9Q7Q U6vxGAeNJvlAoM4yKto+tPOUsvglwDcEvFpZhR2TSvCO/9XRx/uZ3oOQ0dkEnBzJX+P1 v2wkh1KavCsHPtl0/XkM9eRBjZsyGtsiKr6sY/n1tOrcY3xbmtgzfAgnK8EhhYxdisrf enhe75KFBoGzyAW5RBaHU4lQ5f4vxl/VeT9NMuglF0HrkrXmLRJMvVcpfL2lwFpgXUdG W1xF4/zD2P+IBndlhmayNelaHUR8SYPAGB788h11nEyylFBdjZ/3VooaOWhbNdb5ZS7H 8hkw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v11si86858eju.135.2019.11.12.06.41.55; Tue, 12 Nov 2019 06:42:19 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727337AbfKLOlN (ORCPT + 99 others); Tue, 12 Nov 2019 09:41:13 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:51105 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726008AbfKLOlN (ORCPT ); Tue, 12 Nov 2019 09:41:13 -0500 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28] helo=dude02.lab.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iUXLy-00032n-JI; Tue, 12 Nov 2019 15:41:10 +0100 Received: from mol by dude02.lab.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1iUXLw-0005WA-PK; Tue, 12 Nov 2019 15:41:08 +0100 Date: Tue, 12 Nov 2019 15:41:08 +0100 From: Michael Olbrich To: Alexandru Ardelean Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, balbi@kernel.org, gregkh@linuxfoundation.org, bigeasy@linutronix.de, Lars-Peter Clausen Subject: Re: [PATCH] usb: dwc3: gadget: Handle dequeuing of non queued URB gracefully Message-ID: <20191112144108.GA1859@pengutronix.de> Mail-Followup-To: Alexandru Ardelean , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, balbi@kernel.org, gregkh@linuxfoundation.org, bigeasy@linutronix.de, Lars-Peter Clausen References: <20191106144553.16956-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191106144553.16956-1-alexandru.ardelean@analog.com> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 15:39:32 up 75 days, 2:53, 130 users, load average: 3.78, 4.01, 2.72 User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mol@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 06, 2019 at 04:45:53PM +0200, Alexandru Ardelean wrote: > From: Lars-Peter Clausen > > Trying to dequeue and URB that is currently not queued should be a no-op > and be handled gracefully. > > Use the list field of the URB to indicate whether it is queued or not by > setting it to the empty list when it is not queued. > > Handling this gracefully allows for race condition free synchronization > between the complete callback being called to to a completed transfer and > trying to call usb_ep_dequeue() at the same time. > > Signed-off-by: Lars-Peter Clausen > Signed-off-by: Alexandru Ardelean Thanks, no more "dwc3 fe200000.usb: request 00000000cdd42e4a was not queued to ep2in" messages with this patch applied. Tested-by: Michael Olbrich > --- > drivers/usb/dwc3/gadget.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c > index a9aba716bf80..b500ec6b0aa8 100644 > --- a/drivers/usb/dwc3/gadget.c > +++ b/drivers/usb/dwc3/gadget.c > @@ -174,7 +174,7 @@ static void dwc3_gadget_del_and_unmap_request(struct dwc3_ep *dep, > { > struct dwc3 *dwc = dep->dwc; > > - list_del(&req->list); > + list_del_init(&req->list); > req->remaining = 0; > req->needs_extra_trb = false; > > @@ -844,6 +844,7 @@ static struct usb_request *dwc3_gadget_ep_alloc_request(struct usb_ep *ep, > req->epnum = dep->number; > req->dep = dep; > req->status = DWC3_REQUEST_STATUS_UNKNOWN; > + INIT_LIST_HEAD(&req->list); > > trace_dwc3_alloc_request(req); > > @@ -1540,6 +1541,10 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, > > spin_lock_irqsave(&dwc->lock, flags); > > + /* Not queued, nothing to do */ > + if (list_empty(&req->list)) > + goto out0; > + > list_for_each_entry(r, &dep->pending_list, list) { > if (r == req) > break; -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |