Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp361412pxb; Wed, 14 Apr 2021 17:51:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBC8MFzS4q9PLDesftp/RkGlonpyPd6k065hO1yzfixt354XiYnR5AV5th/vyXdA+ghUsw X-Received: by 2002:a05:6402:214:: with SMTP id t20mr1022296edv.229.1618447913031; Wed, 14 Apr 2021 17:51:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618447913; cv=none; d=google.com; s=arc-20160816; b=ORLOkODtPzN3W9qxPpEdlHPknf8q4x13kbOZhPiwy+N/uRrNMCqAzHr3/xMlB8iKpX MCE+aMPvGcUMvsFrl0GlIon4YYvzxQbGdtPm62BGK/959R1PoV5swjf3kPSuPcNDRGkC B9FrkRWVMBMntc0fXMdRGnzhY5eEpAkfyQZKlbZYT0T36VCnKPxYf5BfYMolwC0uAcx0 9Az4AJOTC8dAZHfr8yX2kt9KrAcp98UuN4d5RsSrd+l0ANW3yN/VMpvSlv8dBu1vhKqS HtlcpuVUXIM2fuk+pr+3vua/wyCLtOFJVO0qw2cwCs+DEwcDgPGpav62gqGdJZXz/Ojs Ho3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from:dmarc-filter :sender:dkim-signature; bh=Ycvz7iaQnBHv11QQ3ZVNlWNQgHE9WgMCqAYSdxqayII=; b=Z+o28aX6c8qi0yK6RREkLB1Liv/TkRr3B+2jWwGAOJKoAfWQSZLe4bLLXBPilcnJKX 4eZ1NHAxkJeS1Qmd+UtgDnyjUSNls1dO1BiIJj7Yja/jRVc6xhmVE8kA9o8b7VhiboG6 lg4S8ikTq261cMMWjaQHOp93239UOkju0FnumA2HVVO+IBWBjyUR+zXdQU2As1jGMjMl 0D14assoC4CeYqdPe3XlpNE8wmxwuHvWLH8bIYpp4vbyXI+SzhYD7b5cRGVm7mAIdNwj 8SCywV+vjT0PO8lSE8tKaD133Ey9gZHeSniYk83G+jrN75/rnwlwy1mC6Ad9v+iYDVaJ eFxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=XzMJLXZf; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g8si826917ejm.240.2021.04.14.17.51.30; Wed, 14 Apr 2021 17:51:53 -0700 (PDT) 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=@mg.codeaurora.org header.s=smtp header.b=XzMJLXZf; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233311AbhDNWaU (ORCPT + 99 others); Wed, 14 Apr 2021 18:30:20 -0400 Received: from so254-9.mailgun.net ([198.61.254.9]:42314 "EHLO so254-9.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231207AbhDNWaT (ORCPT ); Wed, 14 Apr 2021 18:30:19 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1618439397; h=Message-Id: Date: Subject: Cc: To: From: Sender; bh=Ycvz7iaQnBHv11QQ3ZVNlWNQgHE9WgMCqAYSdxqayII=; b=XzMJLXZfGRNaM+c/cS/U/VK2u26b2eaogkvWVyXt/NIqptYtcS5bDZj7ezIzPQRxelr5V9OT /8nj97etrKPtT0QU5MshIHPyAIiGBnG7xmTMlORGtTnuHdTHWoDXdKt6mqjPXjz6F7KGUjxk 2qT84b5gkpZqB6TCrqsvdFtn2Y0= X-Mailgun-Sending-Ip: 198.61.254.9 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n07.prod.us-east-1.postgun.com with SMTP id 60776ce287ce1fbb56ef3c10 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 14 Apr 2021 22:29:54 GMT Sender: wcheng=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id C2C8BC433C6; Wed, 14 Apr 2021 22:29:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL autolearn=no autolearn_force=no version=3.4.0 Received: from wcheng-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: wcheng) by smtp.codeaurora.org (Postfix) with ESMTPSA id 8DB80C433C6; Wed, 14 Apr 2021 22:29:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 8DB80C433C6 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=wcheng@codeaurora.org From: Wesley Cheng To: balbi@kernel.org, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, jackp@codeaurora.org, Wesley Cheng Subject: [PATCH] usb: dwc3: gadget: Avoid canceling current request for queuing error Date: Wed, 14 Apr 2021 15:29:48 -0700 Message-Id: <1618439388-20427-1-git-send-email-wcheng@codeaurora.org> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If an error is received when issuing a start or update transfer command, the error handler will stop all active requests (including the current USB request), and call dwc3_gadget_giveback() to notify function drivers of the requests which have been stopped. Avoid having to cancel the current request which is trying to be queued, as the function driver will handle the EP queue error accordingly. Simply unmap the request as it was done before, and allow previously started transfers to be cleaned up. Signed-off-by: Wesley Cheng --- drivers/usb/dwc3/gadget.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index e1b04c97..4200775 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1399,6 +1399,11 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep) if (ret == -EAGAIN) return ret; + /* Avoid canceling current request, as it has not been started */ + if (req->trb) + memset(req->trb, 0, sizeof(struct dwc3_trb)); + dwc3_gadget_del_and_unmap_request(dep, req, ret); + dwc3_stop_active_transfer(dep, true, true); list_for_each_entry_safe(req, tmp, &dep->started_list, list) -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project