Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp215726imw; Tue, 12 Jul 2022 18:07:21 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tIiHQvE9rneZQLWdXA2EPPOIVHy193Re6sh1H9s7WEyMMeEuPhAoP6iACMSBgY1lWB2UEF X-Received: by 2002:a17:906:8a49:b0:72b:3b8d:31c3 with SMTP id gx9-20020a1709068a4900b0072b3b8d31c3mr854339ejc.279.1657674441251; Tue, 12 Jul 2022 18:07:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657674441; cv=none; d=google.com; s=arc-20160816; b=O0ddsCzELYXp2aVyVUB5ShDTVyafkVGiLbkgftu43MJCbXNGBeq83dBfiLbUrm44KL /DGc7/Ip6xjmFMeO9c2yzjbvt/2y1nGf5fMoZt/4MP4AS25yNwzRmPYdqfL6pQp7vFUu I1eVPLrIbHWSv2IUNlE5Sf73l/oVd7ipRonvVW8y94KAG9imXJ3ZubKbyP97Caa5R3oG A3SHF9sTlSB91mA+5reocoUH/jcn29Fc0+F4mWoQsgV2cfZgd3MAxCsaTu0i1BAQWxTz cD2uYJkP7c1Ge0HCYVGbv01gxatE+C71qdBvZGy3X+dHF3Ofr24q3ISZyaz07rhOE841 odtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=+SUBg7VmfpDJk8DbV9zlCP/oaaU5j9wRDSrdHrLZVow=; b=NYnuM/F9tMW5/Qwaj/Ku9a9SScUUZ5VyNSGAuFFHHo1zF2sY2ix/F7zfzxWSaKx9wc yutgXHgQpPtZBDYklTlsDjwWtbqzSX5Y49L98nQhUEpea2YFYhDE5uhsmww246hR6qFb 2br7vwK2WKE5OoiMa26cWRjo44q5R8l84Y9rXdEB28GVz6LfBUi1IbpHBFwLYqRtjB1Z 4Xend6unHsCeGdc2yGyYQB98j1j03J1r+n/Fn4JBD9FBVAO/6Pm+o46ZBWzcvJ4cJare USzJWxGTYEf7h8IUXuZFGrDDHqP7WVRyZND8SWD0fNg/CN2oxU2JEtam3oHx+LY8z1FD rttQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=B34pg6s3; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb42-20020a1709076daa00b00727c6da65fasi2194426ejc.259.2022.07.12.18.06.51; Tue, 12 Jul 2022 18:07:21 -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; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=B34pg6s3; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231516AbiGMAgE (ORCPT + 99 others); Tue, 12 Jul 2022 20:36:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbiGMAf5 (ORCPT ); Tue, 12 Jul 2022 20:35:57 -0400 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF38795C2A; Tue, 12 Jul 2022 17:35:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1657672556; x=1689208556; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=+SUBg7VmfpDJk8DbV9zlCP/oaaU5j9wRDSrdHrLZVow=; b=B34pg6s37VXHJEDbnlYvT7MIUVPO8JBheX9MwIxlz14CXVXk01lhsUP8 +QjdzdQH0AIVMdKNPz2gbD60DaIzF1UqFGwidNa2/qGafng5VZfotvhFU BLMlGYb44xq8C4OpLstR0JlbZNAqReAsjd8z0irLvIyFXNo6DEfvCRRvb s=; Received: from unknown (HELO ironmsg-SD-alpha.qualcomm.com) ([10.53.140.30]) by alexa-out-sd-01.qualcomm.com with ESMTP; 12 Jul 2022 17:35:54 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg-SD-alpha.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2022 17:35:54 -0700 Received: from nalasex01b.na.qualcomm.com (10.47.209.197) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Tue, 12 Jul 2022 17:35:37 -0700 Received: from hu-wcheng-lv.qualcomm.com (10.49.16.6) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Tue, 12 Jul 2022 17:35:37 -0700 From: Wesley Cheng To: , CC: , , , , Wesley Cheng Subject: [PATCH v2 4/5] usb: dwc3: Allow end transfer commands to be sent during soft disconnect Date: Tue, 12 Jul 2022 17:35:22 -0700 Message-ID: <20220713003523.29309-5-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220713003523.29309-1-quic_wcheng@quicinc.com> References: <20220713003523.29309-1-quic_wcheng@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nalasex01b.na.qualcomm.com (10.47.209.197) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 If soft disconnect is in progress, allow the endxfer command to be sent, without this, there is an issue where the stop active transfer call (during pullup disable) wouldn't actually issue the endxfer command, while clearing the DEP flag. In addition, if the DWC3_EP_DELAY_STOP flag was set before soft disconnect started (i.e. from the dequeue path), ensure that when the EP0 transaction completes during soft disconnect, to issue the endxfer with the force parameter set, as it does not expect a command complete event. Fixes: e4cf6580ac740 ("usb: dwc3: gadget: Wait for ep0 xfers to complete during dequeue") Suggested-by: Thinh Nguyen Signed-off-by: Wesley Cheng --- Link: https://lore.kernel.org/linux-usb/1a1a5485-790e-79ce-f5a6-1e96d9b49a47@synopsys.com/ drivers/usb/dwc3/ep0.c | 3 +-- drivers/usb/dwc3/gadget.c | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c index 506ef717fdc0..5851b0e9db0a 100644 --- a/drivers/usb/dwc3/ep0.c +++ b/drivers/usb/dwc3/ep0.c @@ -290,8 +290,7 @@ void dwc3_ep0_out_start(struct dwc3 *dwc) if (!(dwc3_ep->flags & DWC3_EP_DELAY_STOP)) continue; - dwc3_ep->flags &= ~DWC3_EP_DELAY_STOP; - dwc3_stop_active_transfer(dwc3_ep, true, true); + dwc3_stop_active_transfer(dwc3_ep, true, dwc->connected); } } diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index ee85b773e3fe..41b7007358de 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1693,6 +1693,7 @@ static int __dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, bool int dep->flags &= ~DWC3_EP_TRANSFER_STARTED; else if (!ret) dep->flags |= DWC3_EP_END_TRANSFER_PENDING; + dep->flags &= ~DWC3_EP_DELAY_STOP; return ret; } @@ -3686,8 +3687,10 @@ void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, if (dep->number <= 1 && dwc->ep0state != EP0_DATA_PHASE) return; + if (interrupt && (dep->flags & DWC3_EP_DELAY_STOP)) + return; + if (!(dep->flags & DWC3_EP_TRANSFER_STARTED) || - (dep->flags & DWC3_EP_DELAY_STOP) || (dep->flags & DWC3_EP_END_TRANSFER_PENDING)) return;