Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp370420imw; Fri, 15 Jul 2022 05:04:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t18pxYnJFuH8Mt8hKkZw9bq7y1tl+MCFKHEe9xS8H99yV8Vf6KG3B80n7JSqX9UJtQZZHB X-Received: by 2002:a17:907:2c75:b0:72b:3431:2a0a with SMTP id ib21-20020a1709072c7500b0072b34312a0amr13563630ejc.234.1657886680094; Fri, 15 Jul 2022 05:04:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657886680; cv=none; d=google.com; s=arc-20160816; b=SpPF5MFQBH4gswCzXuzTIhEW975Ib0qNyJGZIA6B3McykQrg23uEWFKCUBk4ZascfX qSRYQXElvKAZ5aGzvmKDPnVflvLudeXULdYJgHT6VGFG7cQBiGZVir/rEgmLx2YU3+II KNSLkGcxklR4s3rg/6l5IZdf3abNk9NvHonS9Enmoc/5dm0MK0yuH+bc/fyf7fMNhPxY CCX3MkN5rtI5tEafDYAiv+i13v2iEYtepDmZknDJCUzlOjIpLUIEORfXF857nZyMyQdm Wv0q9rvmiH5IP8UoLBFNYrsEv+BwOcxA/s1MW6s66zugqhcZbExLfGPpQTjO9+4Bn/Pg 7PTg== 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=f73InilMboQadcPEQySiOBLxSHcT20wfHM2fMme7o1Y=; b=zDLq+4MCl4mgEOwtoPWgaGiiryyzNpH98CpxdTXKC+K+Jl+mK6bQCkTLpTW67bG4VD B2gOFxhHsV8xJb3KlovJRlRWQTlMZwqqAzi0VSyApeUTSV2Gk8BEm9YJgQz5dwJfJO+L TOyqLhXFooH5gREPdKdddbnK3dvl2jLH9J06T9cxrZfRVwG4unl/sByTKSHkKAlVmN2A dYoP1hVScFqs6WPsI3YAA4VX5/cM2PhFDQW1YL9OFl74uOXgxWn75NYPMybDkTwz9jym m+GUet+I0nXw9NbrA2k6e2mZ4S9GvAEQQAXiQhbkCpBopMLT0mgIEV714LxGmUHYAJd7 LuAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2BF3POxP; 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 qa44-20020a17090786ac00b0071256ff7906si5388507ejc.692.2022.07.15.05.04.00; Fri, 15 Jul 2022 05:04:40 -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=@linuxfoundation.org header.s=korg header.b=2BF3POxP; 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 S231698AbiGOLpR (ORCPT + 99 others); Fri, 15 Jul 2022 07:45:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229899AbiGOLpQ (ORCPT ); Fri, 15 Jul 2022 07:45:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 210D76A9EB; Fri, 15 Jul 2022 04:45:15 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id A1CBE622FA; Fri, 15 Jul 2022 11:45:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81A5CC3411E; Fri, 15 Jul 2022 11:45:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657885514; bh=/+65uXj1d7wLF6R2bhq2x02kgR5AGcMhGNsdTYW80lA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=2BF3POxP91QePnwQPPLykOxL4q/kB157rCWU5RjKAYkWQlGLBLvNGwSHoFXOWdnaH 9hp8ImIfTAXCGK0L40HJuWBNq5tSZtQ5Ex5gExjQ6ECtejL1y2FDwX7EHUBWacw7bR 3di5M8v1vvorzUhUlw1EzdhzdI341BY/msEbyhfg= Date: Fri, 15 Jul 2022 13:45:11 +0200 From: "gregkh@linuxfoundation.org" To: Wesley Cheng Cc: Thinh Nguyen , "balbi@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-usb@vger.kernel.org" , "quic_jackp@quicinc.com" Subject: Re: [PATCH v2 3/5] usb: dwc3: gadget: Adjust IRQ management during soft disconnect/connect Message-ID: References: <20220713003523.29309-1-quic_wcheng@quicinc.com> <20220713003523.29309-4-quic_wcheng@quicinc.com> <03434e9c-7a1c-4819-6bfe-54f56401348c@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <03434e9c-7a1c-4819-6bfe-54f56401348c@quicinc.com> X-Spam-Status: No, score=-7.7 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 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 Thu, Jul 14, 2022 at 10:41:01AM -0700, Wesley Cheng wrote: > Hi Thinh, > > On 7/14/2022 10:38 AM, Thinh Nguyen wrote: > > On 7/12/2022, Wesley Cheng wrote: > > > Local interrupts are currently being disabled as part of aquiring the > > > spin lock before issuing the endxfer command. Leave interrupts enabled, so > > > that EP0 events can continue to be processed. Also, ensure that there are > > > no pending interrupts before attempting to handle any soft > > > connect/disconnect. > > > > > > Fixes: 861c010a2ee1 ("usb: dwc3: gadget: Refactor pullup()") > > > Signed-off-by: Wesley Cheng > > > --- > > > drivers/usb/dwc3/gadget.c | 21 ++++++++++++--------- > > > 1 file changed, 12 insertions(+), 9 deletions(-) > > > > > > diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c > > > index a455f8d4631d..ee85b773e3fe 100644 > > > --- a/drivers/usb/dwc3/gadget.c > > > +++ b/drivers/usb/dwc3/gadget.c > > > @@ -1674,6 +1674,7 @@ static int __dwc3_gadget_get_frame(struct dwc3 *dwc) > > > static int __dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, bool interrupt) > > > { > > > struct dwc3_gadget_ep_cmd_params params; > > > + struct dwc3 *dwc = dep->dwc; > > > u32 cmd; > > > int ret; > > > @@ -1682,7 +1683,9 @@ static int __dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, bool int > > > cmd |= interrupt ? DWC3_DEPCMD_CMDIOC : 0; > > > cmd |= DWC3_DEPCMD_PARAM(dep->resource_index); > > > memset(¶ms, 0, sizeof(params)); > > > + spin_unlock(&dwc->lock); > > > ret = dwc3_send_gadget_ep_cmd(dep, cmd, ¶ms); > > > + spin_lock(&dwc->lock); > > > WARN_ON_ONCE(ret); > > > dep->resource_index = 0; > > > @@ -2029,12 +2032,11 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, > > > struct dwc3_ep *dep = to_dwc3_ep(ep); > > > struct dwc3 *dwc = dep->dwc; > > > - unsigned long flags; > > > int ret = 0; > > > trace_dwc3_ep_dequeue(req); > > > - spin_lock_irqsave(&dwc->lock, flags); > > > + spin_lock(&dwc->lock); > > > list_for_each_entry(r, &dep->cancelled_list, list) { > > > if (r == req) > > > @@ -2073,7 +2075,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, > > > request, ep->name); > > > ret = -EINVAL; > > > out: > > > - spin_unlock_irqrestore(&dwc->lock, flags); > > > + spin_unlock(&dwc->lock); > > > return ret; > > > } > > > @@ -2489,9 +2491,7 @@ static int __dwc3_gadget_start(struct dwc3 *dwc); > > > static int dwc3_gadget_soft_disconnect(struct dwc3 *dwc) > > > { > > > - unsigned long flags; > > > - > > > - spin_lock_irqsave(&dwc->lock, flags); > > > + spin_lock(&dwc->lock); > > > dwc->connected = false; > > > /* > > > @@ -2506,10 +2506,10 @@ static int dwc3_gadget_soft_disconnect(struct dwc3 *dwc) > > > reinit_completion(&dwc->ep0_in_setup); > > > - spin_unlock_irqrestore(&dwc->lock, flags); > > > + spin_unlock(&dwc->lock); > > > ret = wait_for_completion_timeout(&dwc->ep0_in_setup, > > > msecs_to_jiffies(DWC3_PULL_UP_TIMEOUT)); > > > - spin_lock_irqsave(&dwc->lock, flags); > > > + spin_lock(&dwc->lock); > > > if (ret == 0) > > > dev_warn(dwc->dev, "timed out waiting for SETUP phase\n"); > > > } > > > @@ -2523,7 +2523,7 @@ static int dwc3_gadget_soft_disconnect(struct dwc3 *dwc) > > > */ > > > dwc3_stop_active_transfers(dwc); > > > __dwc3_gadget_stop(dwc); > > > - spin_unlock_irqrestore(&dwc->lock, flags); > > > + spin_unlock(&dwc->lock); > > > /* > > > * Note: if the GEVNTCOUNT indicates events in the event buffer, the > > > @@ -2569,6 +2569,8 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) > > > return 0; > > > } > > > + synchronize_irq(dwc->irq_gadget); > > > + > > > if (!is_on) { > > > ret = dwc3_gadget_soft_disconnect(dwc); > > > } else { > > > @@ -3729,6 +3731,7 @@ void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, > > > */ > > > __dwc3_stop_active_transfer(dep, force, interrupt); > > > + > > > } > > > static void dwc3_clear_stall_all_ep(struct dwc3 *dwc) > > > > Hi Greg, > > > > Please don't pick up this patch yet. We're still in discussion with > > this. I have some concern with unlocking/locking when sending End > > Transfer command. For example, this patch may cause issues with > > DWC3_EP_END_TRANSFER_PENDING checks. > > > > Agreed. > > > Hi Wesley, > > > > Did you try out my suggestion yet? > > > > In process of testing. Will update you in a few days, since it might take a > day or so to reproduce. Ok, I'll drop this whole series from my tree for now. Please resend when you have it working. greg k-h