Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp823702pxb; Tue, 3 Nov 2020 13:34:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJw0OdcqMzOVh2+aIxX7bVdsHvfJqAw6+K8bcaSybXiJVPnJqh6GcqfGMVDx1pqGTDhR8C4r X-Received: by 2002:a17:906:e15:: with SMTP id l21mr23074914eji.509.1604439261436; Tue, 03 Nov 2020 13:34:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604439261; cv=none; d=google.com; s=arc-20160816; b=j86O/mjhusC1n7glMvBGv9ftmT/fXjucQCUMOolZBM2xdb2GYczNNFMhs5aX7N9zRs NKHreXXeixsczJL6+g8usZazTHaEMVId4JzUiAaolZylnFYigVu4bQC4+DzIhqRDiRML CtjN8085GMk983pA4ht/rFZuoA/7SqeQ1FY/HdXlYv1184id5vXQAFUi6BCBjzXwO1oQ Ctr2tkcURouY5LdH7zplbFL0Zu+RJ4DTrPrjpCsbuTbJd2Ny4uoyCeDpALw2RJq9L1SG fLUXC8golWNX2uSVIqjKKMFuzsrx1xahudPyu+6mseeagJ3frWGWwGlSgqSCJY2/5O4v iNzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LiCe50G1pjbVOsqdGp9jolGaikhh9LEijLNWYORnSVg=; b=ShTBrtC78QAtwQ/mbK7EkYup6HmsS6pqgsZiMI2ZGoyWOPUUtKXf93/6M5ZIvWCR89 3uBpU0XqG2+ktgvFjZQmi3uc9GMKg9vLn8gFGCNWCSS3IL8/fk3MPuWN6Y5VT47nPNmV X2FATejZrHEiFuMArpfrP6ocYs5w99yyAMxJPT5CgOrcdPDEWUxsM84GkYy5THZlQbVr uERLU7pdVbaNqzGy/R2LnZYtRbcXuwILMH8HnTINWGlPTKkFVJoom/zLTgaT8TN7MRcX 3xXFJ4/Ox/VyNLayknzHwKlFG4moqO9Citfu4s2UfyQtlCYdGxjTzczPuphxum2MhhI5 DnHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="I6X+Ur/1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l14si12237715edq.543.2020.11.03.13.33.58; Tue, 03 Nov 2020 13:34:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="I6X+Ur/1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732833AbgKCVab (ORCPT + 99 others); Tue, 3 Nov 2020 16:30:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:60662 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732822AbgKCU6E (ORCPT ); Tue, 3 Nov 2020 15:58:04 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 42FC6223AC; Tue, 3 Nov 2020 20:58:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437083; bh=vtbQ9rDNVPi+7e9cw7/1BDc9XPgJvcQ1yasgkOTW7Qw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I6X+Ur/1LEcNyfqVvG2d7aKNTkLD/uBnbzji9DgYfr+gc+shCqtjNlfT90nzrWQ/L PiMkuhwHSsqzmdvj6spH/vbEDPJPjYLZ5JjY3VehIvumXuNXVvNxBw6q9VaB/jPwE8 qAy1Uom9D0DCo8mao7sdP1a+DWoLl9lw+5+xtjWE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thinh Nguyen , Felipe Balbi Subject: [PATCH 5.4 139/214] usb: dwc3: gadget: Resume pending requests after CLEAR_STALL Date: Tue, 3 Nov 2020 21:36:27 +0100 Message-Id: <20201103203303.858633715@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thinh Nguyen commit c503672abe1348f10f5a54a662336358c6e1a297 upstream. The function driver may queue new requests right after halting the endpoint (i.e. queue new requests while the endpoint is stalled). There's no restriction preventing it from doing so. However, dwc3 currently drops those requests after CLEAR_STALL. The driver should only drop started requests. Keep the pending requests in the pending list to resume and process them after the host issues ClearFeature(Halt) to the endpoint. Cc: stable@vger.kernel.org Fixes: cb11ea56f37a ("usb: dwc3: gadget: Properly handle ClearFeature(halt)") Signed-off-by: Thinh Nguyen Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/gadget.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1521,8 +1521,13 @@ static int __dwc3_gadget_ep_queue(struct list_add_tail(&req->list, &dep->pending_list); req->status = DWC3_REQUEST_STATUS_QUEUED; - /* Start the transfer only after the END_TRANSFER is completed */ - if (dep->flags & DWC3_EP_END_TRANSFER_PENDING) { + /* + * Start the transfer only after the END_TRANSFER is completed + * and endpoint STALL is cleared. + */ + if ((dep->flags & DWC3_EP_END_TRANSFER_PENDING) || + (dep->flags & DWC3_EP_WEDGE) || + (dep->flags & DWC3_EP_STALL)) { dep->flags |= DWC3_EP_DELAY_START; return 0; } @@ -1728,13 +1733,14 @@ int __dwc3_gadget_ep_set_halt(struct dwc list_for_each_entry_safe(req, tmp, &dep->started_list, list) dwc3_gadget_move_cancelled_request(req); - list_for_each_entry_safe(req, tmp, &dep->pending_list, list) - dwc3_gadget_move_cancelled_request(req); - - if (!(dep->flags & DWC3_EP_END_TRANSFER_PENDING)) { - dep->flags &= ~DWC3_EP_DELAY_START; + if (!(dep->flags & DWC3_EP_END_TRANSFER_PENDING)) dwc3_gadget_ep_cleanup_cancelled_requests(dep); - } + + if ((dep->flags & DWC3_EP_DELAY_START) && + !usb_endpoint_xfer_isoc(dep->endpoint.desc)) + __dwc3_gadget_kick_transfer(dep); + + dep->flags &= ~DWC3_EP_DELAY_START; } return ret;