Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8190867imu; Tue, 4 Dec 2018 04:35:15 -0800 (PST) X-Google-Smtp-Source: AFSGD/WENp0eDrzgaSQ4xArTVpnd9S8SQwGeBpR38NBZnm0bf81su8THl+w//xVrpUEQ45rMI/xh X-Received: by 2002:a62:60c5:: with SMTP id u188mr19960377pfb.4.1543926915349; Tue, 04 Dec 2018 04:35:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543926915; cv=none; d=google.com; s=arc-20160816; b=fK3MU5bArUr4gYZJXVbW+UidfT5zyqyOEUOcGhAjMKJAOvKeUTravTtuVB+R81V+e8 cPXjrEHAyBbaJHo7/1bXt+BD10Atzpdr2VMTzkFC/Kvl1C01KgAkvfBmSuQ6pPjEuz9F Xlmob3zmYsZtY7tWEPx9KzKMZgK2X8FIRuwmwfpDEhymygWZCDxLEutLcUMctxosNwCo SXI4hvj+awORrMd7/wlWWHlb5l5+269Zdp0J3hNJmCjf8lz57L4eICn60lw5mfsjWX5y 8hW0+BRhz6B9PgGgCCT9j3D0NT6b0piSGGBFgW600c+/k1ivtFFPq2GUHEeWHJosnOen w2Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:references:message-id:date :thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=Mu/sv/aV4UyHCDad09OKl7+kS3gL8LLXDnSCwX8OUtk=; b=IdRT+erOSzEya/7LSwhEIwOaFISAxo48d6LBB3lVb27LbAVsYr7jtYikYghffPtDUc pX2g8fM7lnDhWAPdcEqw61IN4bWQVQlCDhWDdTbl16bDLBeKz52MsjODutmJ82I0/1hU 3CzKI5VAXsQ9becARbDszRlWOZidCerw7HmJNG5WVVOKpqF7vX8IIRlUn4/+mTFWdup2 6jKDo8pzlJ/FdkAz6yPfEAxP9t4krDCh/YVSGogCk0AL0uFRXa3qIMdYMWMxj7SsgjYt 6HMQzI0/yyMFk7Dg2dnGrjwSMIFnfFFWNYN08vCcScVHmyzEJYPLRn9oUSg3DEw4FmAs IcIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=JNHnUbnp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t65si17481120pfb.247.2018.12.04.04.34.58; Tue, 04 Dec 2018 04:35:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=JNHnUbnp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726314AbeLDMeO (ORCPT + 99 others); Tue, 4 Dec 2018 07:34:14 -0500 Received: from smtprelay.synopsys.com ([198.182.60.111]:51370 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726250AbeLDMeO (ORCPT ); Tue, 4 Dec 2018 07:34:14 -0500 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 6177C10C08C9; Tue, 4 Dec 2018 04:34:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1543926853; bh=aj3lGISrtWx/MnlW87X50xgt7wP60ecxKLpm3PF9o1Y=; h=From:To:CC:Subject:Date:References:From; b=JNHnUbnpswj3LoL7GWtYaLGKVdblaQ1sIVqvzzV75eV906i51J3Pv4Mmq9khPTcRy zJlFQPDHyiukoCxi6EfsHLNHuebAV3K5kB0pWSc6+TQx1auBz7LNLJ8Odv4+rPOnFW nECvdmDn0Man+ET22RlYKIMnX5ndgisAywfzLrHfMhUIOnZQNhaQNoTWUW+OpHDryt PT/nx+rGPHhy8PGaQYUM3qK2xYhUe3oy8Xo/z6WgJgqSQIY+/gjns6u9WHAJy4ANiN geA5itC5eZ7VGOf3rAYB6/3Om3h92t9CP26aNn4hl9UybX/PWsrEsYIkvKtI6pfs8U Q4HSQhwHrdRRA== Received: from us01wehtc1.internal.synopsys.com (us01wehtc1-vip.internal.synopsys.com [10.12.239.236]) by mailhost.synopsys.com (Postfix) with ESMTP id 8E6CA5AEF; Tue, 4 Dec 2018 04:34:12 -0800 (PST) Received: from AM04WEHTCB.internal.synopsys.com (10.116.16.192) by us01wehtc1.internal.synopsys.com (10.12.239.231) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 4 Dec 2018 04:34:11 -0800 Received: from AM04WEMBXA.internal.synopsys.com ([fe80::79c3:55f2:1f20:5bf4]) by am04wehtcb.internal.synopsys.com ([::1]) with mapi id 14.03.0415.000; Tue, 4 Dec 2018 16:34:08 +0400 From: Minas Harutyunyan To: Dan Carpenter , Minas Harutyunyan , Marek Szyprowski , Maynard CABIENTE CC: "linux-kernel@vger.kernel.org" , "linux-usb@vger.kernel.org" , Greg Kroah-Hartman , Felipe Balbi , Geert Uytterhoeven , Bartlomiej Zolnierkiewicz Subject: Re: [PATCH] usb: dwc2: Revert "usb: dwc2: Disable all EP's on disconnect" Thread-Topic: [PATCH] usb: dwc2: Revert "usb: dwc2: Disable all EP's on disconnect" Thread-Index: AQHUgbE8ouTBXi+nzkarEEkfP9zP5Q== Date: Tue, 4 Dec 2018 12:34:08 +0000 Message-ID: <410670D7E743164D87FA6160E7907A56013A7B19C2@am04wembxa.internal.synopsys.com> References: <20181121154504.13052-1-m.szyprowski@samsung.com> <410670D7E743164D87FA6160E7907A56013A7AA1EE@am04wembxa.internal.synopsys.com> <20181123144307.GC2970@unbuntlaptop> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.116.70.39] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/23/2018 6:43 PM, Dan Carpenter wrote:=0A= > Ugh... We also had a long thread about the v2 patch but it turns out=0A= > the list was not CC'd. I should have checked for that.=0A= > =0A= > You have to pass a flag to say if the caller holds the lock or not...=0A= > =0A= > regards,=0A= > dan carpenter=0A= > =0A= =0A= Hi Dan, Marek, Maynard,=0A= =0A= Could you please apply bellow patch over follow patches:=0A= =0A= dccf1bad4be7 usb: dwc2: Disable all EP's on disconnect=0A= 6f774b501928 usb: dwc2: Fix ep disable spinlock flow.=0A= =0A= Please review and test. Feedback is appreciated :-)=0A= =0A= diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c=0A= index 8eb25e3597b0..db438d13c36a 100644=0A= --- a/drivers/usb/dwc2/gadget.c=0A= +++ b/drivers/usb/dwc2/gadget.c=0A= @@ -3165,8 +3165,6 @@ static void kill_all_requests(struct dwc2_hsotg =0A= *hsotg,=0A= dwc2_hsotg_txfifo_flush(hsotg, ep->fifo_index);=0A= }=0A= =0A= -static int dwc2_hsotg_ep_disable(struct usb_ep *ep);=0A= -=0A= /**=0A= * dwc2_hsotg_disconnect - disconnect service=0A= * @hsotg: The device state.=0A= @@ -3185,12 +3183,13 @@ void dwc2_hsotg_disconnect(struct dwc2_hsotg *hsotg= )=0A= hsotg->connected =3D 0;=0A= hsotg->test_mode =3D 0;=0A= =0A= - /* all endpoints should be shutdown */=0A= for (ep =3D 0; ep < hsotg->num_of_eps; ep++) {=0A= if (hsotg->eps_in[ep])=0A= - dwc2_hsotg_ep_disable(&hsotg->eps_in[ep]->ep);=0A= + kill_all_requests(hsotg, hsotg->eps_in[ep],=0A= + -ESHUTDOWN);=0A= if (hsotg->eps_out[ep])=0A= - dwc2_hsotg_ep_disable(&hsotg->eps_out[ep]->ep);=0A= + kill_all_requests(hsotg, hsotg->eps_out[ep],=0A= + -ESHUTDOWN);=0A= }=0A= =0A= call_gadget(hsotg, disconnect);=0A= @@ -3234,6 +3233,8 @@ static void dwc2_hsotg_irq_fifoempty(struct =0A= dwc2_hsotg *hsotg, bool periodic)=0A= GINTSTS_PTXFEMP | \=0A= GINTSTS_RXFLVL)=0A= =0A= +static int dwc2_hsotg_ep_disable(struct usb_ep *ep);=0A= +=0A= /**=0A= * dwc2_hsotg_core_init - issue softreset to the core=0A= * @hsotg: The device state=0A= @@ -3258,12 +3259,14 @@ void dwc2_hsotg_core_init_disconnected(struct =0A= dwc2_hsotg *hsotg,=0A= return;=0A= } else {=0A= /* all endpoints should be shutdown */=0A= + spin_unlock(&hsotg->lock);=0A= for (ep =3D 1; ep < hsotg->num_of_eps; ep++) {=0A= if (hsotg->eps_in[ep])=0A= =0A= dwc2_hsotg_ep_disable(&hsotg->eps_in[ep]->ep);=0A= if (hsotg->eps_out[ep])=0A= =0A= dwc2_hsotg_ep_disable(&hsotg->eps_out[ep]->ep);=0A= }=0A= + spin_lock(&hsotg->lock);=0A= }=0A= =0A= /*=0A= @@ -4072,7 +4075,6 @@ static int dwc2_hsotg_ep_disable(struct usb_ep *ep)= =0A= unsigned long flags;=0A= u32 epctrl_reg;=0A= u32 ctrl;=0A= - int locked;=0A= =0A= dev_dbg(hsotg->dev, "%s(ep %p)\n", __func__, ep);=0A= =0A= @@ -4088,7 +4090,7 @@ static int dwc2_hsotg_ep_disable(struct usb_ep *ep)= =0A= =0A= epctrl_reg =3D dir_in ? DIEPCTL(index) : DOEPCTL(index);=0A= =0A= - locked =3D spin_trylock_irqsave(&hsotg->lock, flags);=0A= + spin_lock_irqsave(&hsotg->lock, flags);=0A= =0A= ctrl =3D dwc2_readl(hsotg, epctrl_reg);=0A= =0A= @@ -4112,8 +4114,7 @@ static int dwc2_hsotg_ep_disable(struct usb_ep *ep)= =0A= hs_ep->fifo_index =3D 0;=0A= hs_ep->fifo_size =3D 0;=0A= =0A= - if (locked)=0A= - spin_unlock_irqrestore(&hsotg->lock, flags);=0A= + spin_unlock_irqrestore(&hsotg->lock, flags);=0A= =0A= return 0;=0A= }=0A= =0A= Thanks,=0A= Minas=0A=