From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39B611C5F12 for ; Sat, 1 Feb 2025 16:44:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.25 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738428246; cv=none; b=ZUGJ2Bkfs6py0xWrmeydIpPRiArmyQszyTXP5d33ePVwiDNcGZpmOy3Vevc3iCY9w2UDZD2Mht9+Nq0yjdKsGKAYFup65aH+Vbm7larpLkqMasP8rRE4ol2wAUqINdjjKpTz/LsRO+tnYQ4pA07DSOh1dX7yd9sxRsgSRIQOICk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738428246; c=relaxed/simple; bh=DDtWvqSvTMHlhlSfjRB65K77J85x2N5Zg2ez4O5SvaY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:From:In-Reply-To: Content-Type:References; b=Dmi+5MAnnH0cTuZctErjSEoYg2poN/U3JeZufTpXQ7QUC2ixmIl9W7G7COrRbTA4BOEy3Yb6g64Zt8cTPo+y69rxiBiDup+U2g/AoDZeZTWpqnCRFwon1KBJ3ztCbl2cF5DCmoZ2YaxuA3pQT5MfoxEoUirACNbyaNlrZsYihZQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=Kyi8k3dG; arc=none smtp.client-ip=203.254.224.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="Kyi8k3dG" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20250201164402epoutp02072122a57d1944209cf2426e0ed0a24c~gI0aw8Q5S1663316633epoutp02z for ; Sat, 1 Feb 2025 16:44:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20250201164402epoutp02072122a57d1944209cf2426e0ed0a24c~gI0aw8Q5S1663316633epoutp02z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1738428242; bh=jLUb5G3NKhilcETtJx9Mx0srRqluN5dRf++Eobd3kOw=; h=Date:Subject:To:Cc:From:In-Reply-To:References:From; b=Kyi8k3dG0rOA7rAhVKjyui2kGevL5frPoScke9D18bDoRGEjbvQ0dyomy9adme/bs WXbK+0ZHGheJaI50GKGQp62YgNM5NHcWnpMtL4aoefaZpMzYEUD9Jyk/K0cl3jJxI8 ZxVWtYSlHpWbHfVTKzOZIjjZqIMRp+mO4ZiA2RlI= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20250201164401epcas5p1d8b5507f22d418533d286b0fd2bba7fe~gI0ZS1p3Y2779827798epcas5p1g; Sat, 1 Feb 2025 16:44:01 +0000 (GMT) Received: from epsmgec5p1new.samsung.com (unknown [182.195.38.179]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4YldrH55Rbz4x9Pv; Sat, 1 Feb 2025 16:43:59 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmgec5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 2F.61.19710.F4F4E976; Sun, 2 Feb 2025 01:43:59 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20250201164359epcas5p3a6373dcd0dffd7fe3946e4288d1f98ce~gI0XmMTPh0094000940epcas5p3x; Sat, 1 Feb 2025 16:43:59 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20250201164359epsmtrp2bfe597065193358e8e85f6fe616cfee6~gI0Xlcktq2528825288epsmtrp2X; Sat, 1 Feb 2025 16:43:59 +0000 (GMT) X-AuditID: b6c32a44-36bdd70000004cfe-07-679e4f4fe8b9 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 56.B4.23488.F4F4E976; Sun, 2 Feb 2025 01:43:59 +0900 (KST) Received: from [107.122.5.126] (unknown [107.122.5.126]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20250201164357epsmtip197df7a5ce24460cf26018c73563685a8~gI0VpLGqw1429514295epsmtip13; Sat, 1 Feb 2025 16:43:57 +0000 (GMT) Message-ID: Date: Sat, 1 Feb 2025 22:13:55 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] usb: dwc3: Fix timeout issue during controller enter/exit from halt state To: Thinh Nguyen Cc: "gregkh@linuxfoundation.org" , "balbi@ti.com" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "jh0801.jung@samsung.com" , "dh10.jung@samsung.com" , "naushad@samsung.com" , "akash.m5@samsung.com" , "h10.kim@samsung.com" , "eomji.oh@samsung.com" , "alim.akhtar@samsung.com" , "thiagu.r@samsung.com" , "stable@vger.kernel.org" Content-Language: en-US From: Selvarasu Ganesan In-Reply-To: <20250201001506.jr3yw4twwr7zutzd@synopsys.com> Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrHJsWRmVeSWpSXmKPExsWy7bCmpq6//7x0g9NT1CzeXF3FavFg3jY2 i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3v5oEVm+p6rX6Rcq9bK8fdxL++0iGn5zmV/j7vW0zeTLa1y4pvm2IOR DwTUbgtx9kTNn8X1fvOurvMKx18bRJkJG0gem7Lr2bRXs7hWcfeVTMhfv0yJpTgj0VCLuag4 EQBXQHLhLAMAAA== X-CMS-MailID: 20250201164359epcas5p3a6373dcd0dffd7fe3946e4288d1f98ce X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20250131110910epcas5p25ee5f0ab53949ad3759c0825d11170b3 References: <20250131110832.438-1-selvarasu.g@samsung.com> <20250201001506.jr3yw4twwr7zutzd@synopsys.com> On 2/1/2025 5:45 AM, Thinh Nguyen wrote: > On Fri, Jan 31, 2025, Selvarasu Ganesan wrote: >> There is a frequent timeout during controller enter/exit from halt state >> after toggling the run_stop bit by SW. This timeout occurs when >> performing frequent role switches between host and device, causing >> device enumeration issues due to the timeout. This issue was not present >> when USB2 suspend PHY was disabled by passing the SNPS quirks >> (snps,dis_u2_susphy_quirk and snps,dis_enblslpm_quirk) from the DTS. >> However, there is a requirement to enable USB2 suspend PHY by setting of >> GUSB2PHYCFG.ENBLSLPM and GUSB2PHYCFG.SUSPHY bits when controller starts >> in gadget or host mode results in the timeout issue. >> >> This commit addresses this timeout issue by ensuring that the bits >> GUSB2PHYCFG.ENBLSLPM and GUSB2PHYCFG.SUSPHY are cleared before starting >> the dwc3_gadget_run_stop sequence and restoring them after the >> dwc3_gadget_run_stop sequence is completed. >> >> Fixes: 72246da40f37 ("usb: Introduce DesignWare USB3 DRD Driver") >> Cc: stable@vger.kernel.org >> Signed-off-by: Selvarasu Ganesan >> --- >> drivers/usb/dwc3/gadget.c | 21 +++++++++++++++++++++ >> 1 file changed, 21 insertions(+) >> >> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c >> index d27af65eb08a..4a158f703d64 100644 >> --- a/drivers/usb/dwc3/gadget.c >> +++ b/drivers/usb/dwc3/gadget.c >> @@ -2629,10 +2629,25 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on) >> { >> u32 reg; >> u32 timeout = 2000; >> + u32 saved_config = 0; >> >> if (pm_runtime_suspended(dwc->dev)) >> return 0; >> > Can you add some comments here that this was added through experiment > since it is not documented in the programming guide. It would be great > to also note which platform you used to test this with. > >> + reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); >> + if (unlikely(reg & DWC3_GUSB2PHYCFG_SUSPHY)) { > I know we have "unlikely" in the other check, but we should not need it > here or the other place. Please remove this here. Hi Thinh, Thanks for your review comments. I updated below newer version with addressed your comments. Please review it. https://lore.kernel.org/linux-usb/20250201163903.459-1-selvarasu.g@samsung.com/ Thanks, Selva >> + saved_config |= DWC3_GUSB2PHYCFG_SUSPHY; >> + reg &= ~DWC3_GUSB2PHYCFG_SUSPHY; >> + } >> + >> + if (reg & DWC3_GUSB2PHYCFG_ENBLSLPM) { >> + saved_config |= DWC3_GUSB2PHYCFG_ENBLSLPM; >> + reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM; >> + } >> + >> + if (saved_config) >> + dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); >> + >> reg = dwc3_readl(dwc->regs, DWC3_DCTL); >> if (is_on) { >> if (DWC3_VER_IS_WITHIN(DWC3, ANY, 187A)) { >> @@ -2660,6 +2675,12 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on) >> reg &= DWC3_DSTS_DEVCTRLHLT; >> } while (--timeout && !(!is_on ^ !reg)); >> >> + if (saved_config) { >> + reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); >> + reg |= saved_config; >> + dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); >> + } >> + >> if (!timeout) >> return -ETIMEDOUT; >> >> -- >> 2.17.1 >> > Thanks, > Thinh