Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp6025079pxb; Mon, 14 Feb 2022 13:23:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJxg6SYG5J0HVuQz/LOKfBSGrBk3sHxrm/ryDYfCNpuvk4VVUN3PsgKKrde7XUFOsPi62DQN X-Received: by 2002:a17:902:9307:: with SMTP id bc7mr828876plb.140.1644873807959; Mon, 14 Feb 2022 13:23:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644873807; cv=none; d=google.com; s=arc-20160816; b=JXeE9C/OZkST3RHUXVuHd9tYszwdScG/6IjW7g8rh1cJFHx5joXB8sAm+BQDjJbBf5 BSb/Zu0VTz0trudt94S2wkJr5Hiw9teF+ap49EoRq0SVQG4oL0l7+GKB0saXmyc1BrPo kx2PpGkBUVL6DCoyhrcGy7AA4Pj2NELg8iTDfECMDjIAiVjUeWVhG647lLjjg06UnhLo aenKno/W4xsPH1lgsnZt4xAEXrgstJfme8cWS6NCGKYkPT98YjXxtRU5BKWFP5yQSu0D sN6+xbcGh1iiPvMItYL0tL7749CqAlQcep4pQfraXJHCu9yDXLD4n/86+zb9LvWN3E4I 0VLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=hqUWCkwFgLNSlm3+0KgS55gIZECqY05ZG+GhSPxmO5Y=; b=gnA1V0MpQayD3+SlYY4XjUQowMiM3k/GlAsD+gZmJbTzEnI4N9jFbCaM4YRk3yagdZ PXkLP4+QklyEc4GTMoMRHN95tf8m+cmMR8Fsv/spsqfqRF5M3Rush/0+nb5AGTxeD2lR cqq5j+Z07tS7CCpxr3ZwpjGVcMx3ZTfiypb6Sn/H4NtqKTy2Opgmyz2nOQsC7NoxMcNW eFxKhnttqh5l79+R/+mKqEvdZiIqX9E2y7XhXFm7hwU23RmHJJT0/i7aE2wSlUIbNnyF y+5z0+4McHkeUXWEO5uaPnqa5ocWHEkSmhMw4qT3Cx/J7zLlGQcI0YVm0SjUlwZ0gck+ MFFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=x+ESaLuY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e27si857629pge.40.2022.02.14.13.23.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 13:23:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=x+ESaLuY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8F6141B10F8; Mon, 14 Feb 2022 12:40:01 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229625AbiBNS7T (ORCPT + 99 others); Mon, 14 Feb 2022 13:59:19 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:52750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229880AbiBNS7J (ORCPT ); Mon, 14 Feb 2022 13:59:09 -0500 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23301D227A; Mon, 14 Feb 2022 10:58:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1644865131; x=1676401131; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=hqUWCkwFgLNSlm3+0KgS55gIZECqY05ZG+GhSPxmO5Y=; b=x+ESaLuY55jFioNmD/65//hsgoxCcZuiwXKpY+HZB5NGZdhJ/d4QHtZV e1Vnjwpj2soCiPvNcRDRJqtKQ86736VqdVx45oXDavnKVMcao9PVfHuTb 5QS7BvRkwNPtu2Fte086U3a/qNynCVh3b/uGKHT3XohIE/SKPTua+DVwq g=; Received: from ironmsg07-lv.qualcomm.com ([10.47.202.151]) by alexa-out.qualcomm.com with ESMTP; 14 Feb 2022 10:53:37 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg07-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2022 10:53:37 -0800 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.15; Mon, 14 Feb 2022 10:53:16 -0800 Received: from [10.110.117.25] (10.80.80.8) 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.922.19; Mon, 14 Feb 2022 10:53:16 -0800 Message-ID: Date: Mon, 14 Feb 2022 10:53:14 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v1 1/2] usb: dwc3: Not set DWC3_EP_END_TRANSFER_PENDING in ep cmd fails Content-Language: en-US To: Daehwan Jung , Felipe Balbi , Greg Kroah-Hartman CC: , open list , , References: <1644831438-125403-1-git-send-email-dh10.jung@samsung.com> <1644831438-125403-2-git-send-email-dh10.jung@samsung.com> From: Wesley Cheng In-Reply-To: <1644831438-125403-2-git-send-email-dh10.jung@samsung.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no 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 Hi Daehwan, On 2/14/2022 1:37 AM, Daehwan Jung wrote: > It always sets DWC3_EP_END_TRANSFER_PENDING in dwc3_stop_active_transfer > even if dwc3_send_gadget_ep_cmd fails. It can cause some problems like > skipping clear stall commmand or giveback from dequeue. We fix to set it > only when ep cmd success. Additionally, We clear DWC3_EP_TRANSFER_STARTED > for next trb to start transfer not update transfer. > > Change-Id: I2e6b58acc99f385e467e8b639a3792a5e5f4d2bb > Signed-off-by: Daehwan Jung > --- > drivers/usb/dwc3/gadget.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c > index 183b90923f51..3ad3bc5813ca 100644 > --- a/drivers/usb/dwc3/gadget.c > +++ b/drivers/usb/dwc3/gadget.c > @@ -2044,6 +2044,12 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, > dwc3_gadget_move_cancelled_request(r, > DWC3_REQUEST_STATUS_DEQUEUED); > > + /* If ep cmd fails, then force to giveback cancelled requests here */ > + if (!(dep->flags & DWC3_EP_END_TRANSFER_PENDING)) { > + dep->flags &= ~DWC3_EP_TRANSFER_STARTED; > + dwc3_gadget_ep_cleanup_cancelled_requests(dep); > + } > + What I realized when looking at the endxfer command fail due to TIMEOUT, was that it would lead to subsequent controller halt failures as well (during pullup disable case). It might not be safe to forcefully unmap the request buffers if the controller may still be "working" on it. I found some interesting quirks with regards to endxfer timeouts as well, which I'm trying to get some more feedback on [1]. What is the end issue being seen that requires this change? (we may have run into the same issue as well. [1] - https://lore.kernel.org/linux-usb/20220203080017.27339-1-quic_wcheng@quicinc.com/ Thanks Wesley Cheng > dep->flags &= ~DWC3_EP_WAIT_TRANSFER_COMPLETE; > > goto out; > @@ -3645,7 +3651,7 @@ static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, > > if (!interrupt) > dep->flags &= ~DWC3_EP_TRANSFER_STARTED; > - else > + else if (!ret) > dep->flags |= DWC3_EP_END_TRANSFER_PENDING; > } >