Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp348760pxp; Wed, 9 Mar 2022 04:20:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZqnTqOUNaFr6z8PwtSsHwffMl44Uu9jyvWe4yz80Be2XEZnjAtNtyk9gZKdoCpFHXZ2Yq X-Received: by 2002:a17:906:6158:b0:6ce:61d6:f243 with SMTP id p24-20020a170906615800b006ce61d6f243mr17482650ejl.268.1646828457876; Wed, 09 Mar 2022 04:20:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646828457; cv=none; d=google.com; s=arc-20160816; b=tRH/+Tc7G/rOcFHA3nqZUGsYJLw0j9n8iOKn3iJ51awn2eOeN9khCEMvSLdTAYvQyj wJEWsLOkY+wKdUg2SyPupVQ35H3p+w8lREwLUQsZTH74KfF5FLxnxgOkRfbrmSh8AcJs PKsF/iYjGPz3S+AlQtEJvqQCX/tymGWU3VGZ4DYDvzRoFqZBhcPNE586tt8jyBUuWB1h O2N+M+R2il71BcccShLpBTdIY1YuKd1i8nTZQSsxvqAWec0ZUvY9I5QF79BR8mMT5N3S cAOqGNFUrOr7Hw4bsiqmzcLw4JXjM7MSZWBbPy2VmaNfgGkq3FUFBrNSdjbRhMr6D50W y09w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ZLXXd9ibKZTZ29Px4rBzPu5cMM9SSyvnpllA4tBHjGk=; b=AUFgCnZ1aQVDVvPJwQaf5lJymY6hkhTBQGsmHdIn/xEtOloOAU/o27AVsjijYtr9+/ qbDssxYBaA4LglByaHdHTTVXWRqCHoeUdWAcVUZAodlHGFg0Y/PpulqGeWlWc8rASIvr sZJ41uHqxOTprN7L89kaEt7mKEPe9YTSPDUfqhpoAz9HSzV/UBEDok1JzFn+0RaQf3mx iTEDA4s7VYqcIdbgjGfLEtj/8dGKOmeFcbq/YVuEAc2P01BB9aPIHboLduuwKT+1yzFh MMibgS4QAjQs7RZwn7hHvkSLg2v5kr+QKtOgNKfNeWIhJ/pmAoGDzBIMu7/n/dumCvCS Inog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Nlz1py1G; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e9-20020a50d4c9000000b00413b3fbad36si1116674edj.57.2022.03.09.04.20.34; Wed, 09 Mar 2022 04:20:57 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=Nlz1py1G; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229877AbiCIKWz (ORCPT + 99 others); Wed, 9 Mar 2022 05:22:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230031AbiCIKWr (ORCPT ); Wed, 9 Mar 2022 05:22:47 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D4F116FDE8; Wed, 9 Mar 2022 02:21:49 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1F43FB81FF7; Wed, 9 Mar 2022 10:21:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50C42C340E8; Wed, 9 Mar 2022 10:21:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646821306; bh=Wm6tZYodnJhLaX2LYxO6sDtIEcS/tDhVWe8DN5ggHFE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Nlz1py1GRsjS+umP2V+rm1oqiosy9OL4/vbrcwaaIQoq/8G9FeyK54V8yKPjafEaM 2S2+p0gTTETq4b61VteUcVjgkb/VZQWeRG/jRn7AFdv4wdLEsu8zX/mAQeDt7caAN1 iUaaHxqIl6xjtMMBhP91Yp3lMEctbv+0aYP0vk5k= Date: Wed, 9 Mar 2022 11:21:41 +0100 From: Greg KH To: Wesley Cheng Cc: balbi@kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, quic_jackp@quicinc.com, Thinh.Nguyen@synopsys.com Subject: Re: [PATCH] usb: dwc3: gadget: Wait for ep0 xfers to complete during dequeue Message-ID: References: <20220309004148.12061-1-quic_wcheng@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220309004148.12061-1-quic_wcheng@quicinc.com> X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 On Tue, Mar 08, 2022 at 04:41:48PM -0800, Wesley Cheng wrote: > From: Thinh Nguyen > > If the request being dequeued is currently active, then the current > logic is to issue a stop transfer command, and allow the command > completion to cleanup the cancelled list. The DWC3 controller will > run into an end transfer command timeout if there is an ongoing EP0 > transaction. If this is the case, wait for the EP0 completion event > before proceeding to retry the endxfer command again. > > Co-developed-by: Wesley Cheng > Signed-off-by: Wesley Cheng > Signed-off-by: Thinh Nguyen You sent this twice? What is the differences between the patches? And as you sent it, your signed-off-by needs to be at the end, as per the kernel documentation. > --- > Patch discussion below: > https://lore.kernel.org/linux-usb/1644836933-141376-1-git-send-email-dh10.jung@samsung.com/T/#t So this is a v2? > > drivers/usb/dwc3/core.h | 2 +- > drivers/usb/dwc3/ep0.c | 14 ++++++++++++++ > drivers/usb/dwc3/gadget.c | 13 ++++++++----- > drivers/usb/dwc3/gadget.h | 1 + > 4 files changed, 24 insertions(+), 6 deletions(-) > > diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h > index eb9c1efced05..f557f5f36a7f 100644 > --- a/drivers/usb/dwc3/core.h > +++ b/drivers/usb/dwc3/core.h > @@ -736,7 +736,7 @@ struct dwc3_ep { > #define DWC3_EP_FIRST_STREAM_PRIMED BIT(10) > #define DWC3_EP_PENDING_CLEAR_STALL BIT(11) > #define DWC3_EP_TXFIFO_RESIZED BIT(12) > - > +#define DWC3_EP_DELAY_STOP BIT(13) Why did you loose the blank line? > /* This last one is specific to EP0 */ > #define DWC3_EP0_DIR_IN BIT(31) > > diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c > index 658739410992..1064be5518f6 100644 > --- a/drivers/usb/dwc3/ep0.c > +++ b/drivers/usb/dwc3/ep0.c > @@ -271,6 +271,7 @@ void dwc3_ep0_out_start(struct dwc3 *dwc) > { > struct dwc3_ep *dep; > int ret; > + int i; > > complete(&dwc->ep0_in_setup); > > @@ -279,6 +280,19 @@ void dwc3_ep0_out_start(struct dwc3 *dwc) > DWC3_TRBCTL_CONTROL_SETUP, false); > ret = dwc3_ep0_start_trans(dep); > WARN_ON(ret < 0); > + for (i = 2; i < DWC3_ENDPOINTS_NUM; i++) { > + struct dwc3_ep *dwc3_ep; > + > + dwc3_ep = dwc->eps[i]; > + if (!dwc3_ep) > + continue; > + > + if (!(dwc3_ep->flags & DWC3_EP_DELAY_STOP)) > + continue; > + > + dwc3_ep->flags &= ~DWC3_EP_DELAY_STOP; > + dwc3_stop_active_transfer(dwc3_ep, true, true); > + } > } > > static struct dwc3_ep *dwc3_wIndex_to_dep(struct dwc3 *dwc, __le16 wIndex_le) > diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c > index a0c883f19a41..ccef508b1296 100644 > --- a/drivers/usb/dwc3/gadget.c > +++ b/drivers/usb/dwc3/gadget.c > @@ -654,9 +654,6 @@ static int dwc3_gadget_set_ep_config(struct dwc3_ep *dep, unsigned int action) > return dwc3_send_gadget_ep_cmd(dep, DWC3_DEPCMD_SETEPCONFIG, ¶ms); > } > > -static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, > - bool interrupt); > - > /** > * dwc3_gadget_calc_tx_fifo_size - calculates the txfifo size value > * @dwc: pointer to the DWC3 context > @@ -1899,6 +1896,7 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) > */ > if ((dep->flags & DWC3_EP_END_TRANSFER_PENDING) || > (dep->flags & DWC3_EP_WEDGE) || > + (dep->flags & DWC3_EP_DELAY_STOP) || > (dep->flags & DWC3_EP_STALL)) { > dep->flags |= DWC3_EP_DELAY_START; > return 0; > @@ -2033,6 +2031,9 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, > if (r == req) { > struct dwc3_request *t; > > + if (dwc->ep0state != EP0_SETUP_PHASE && !dwc->delayed_status) > + dep->flags |= DWC3_EP_DELAY_STOP; > + > /* wait until it is processed */ > dwc3_stop_active_transfer(dep, true, true); > > @@ -2116,7 +2117,8 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol) > list_for_each_entry_safe(req, tmp, &dep->started_list, list) > dwc3_gadget_move_cancelled_request(req, DWC3_REQUEST_STATUS_STALLED); > > - if (dep->flags & DWC3_EP_END_TRANSFER_PENDING) { > + if (dep->flags & DWC3_EP_END_TRANSFER_PENDING || > + (dep->flags & DWC3_EP_DELAY_STOP)) { > dep->flags |= DWC3_EP_PENDING_CLEAR_STALL; > return 0; > } > @@ -3596,7 +3598,7 @@ static void dwc3_reset_gadget(struct dwc3 *dwc) > } > } > > -static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, > +void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, > bool interrupt) This is a horrid api (2 booleans?) But you aren't adding it so I guess we can live with it :( thanks, greg k-h