From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.2 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A461C433ED for ; Fri, 16 Apr 2021 09:20:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E216C61006 for ; Fri, 16 Apr 2021 09:20:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241350AbhDPJVL (ORCPT ); Fri, 16 Apr 2021 05:21:11 -0400 Received: from smtp.radex.nl ([178.250.146.7]:60680 "EHLO radex-web.radex.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238823AbhDPJVK (ORCPT ); Fri, 16 Apr 2021 05:21:10 -0400 Received: from [192.168.1.158] (cust-178-250-146-69.breedbanddelft.nl [178.250.146.69]) by radex-web.radex.nl (Postfix) with ESMTPS id D9EE0240A8; Fri, 16 Apr 2021 11:10:55 +0200 (CEST) From: Ferry Toth Subject: Re: [PATCH v3] usb: dwc3: core: Do core softreset when switch mode To: John Stultz , Thinh Nguyen Cc: Felipe Balbi , Greg Kroah-Hartman , Linux USB List , John Youn , stable , Andy Shevchenko , Wesley Cheng , Yu Chen References: <2cb4e704b059a8cc91f37081c8ceb95c6492e416.1618503587.git.Thinh.Nguyen@synopsys.com> <374440f8dcd4f06c02c2caf4b1efde86774e02d9.1618521663.git.Thinh.Nguyen@synopsys.com> Message-ID: Date: Fri, 16 Apr 2021 11:10:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Hi Op 16-04-2021 om 05:28 schreef John Stultz: > On Thu, Apr 15, 2021 at 5:12 PM John Stultz wrote: >> On Thu, Apr 15, 2021 at 3:20 PM Thinh Nguyen wrote: >>> From: Yu Chen >>> From: John Stultz >>> >>> According to the programming guide, to switch mode for DRD controller, >>> the driver needs to do the following. >>> >>> To switch from device to host: >>> 1. Reset controller with GCTL.CoreSoftReset >>> 2. Set GCTL.PrtCapDir(host mode) >>> 3. Reset the host with USBCMD.HCRESET >>> 4. Then follow up with the initializing host registers sequence >>> >>> To switch from host to device: >>> 1. Reset controller with GCTL.CoreSoftReset >>> 2. Set GCTL.PrtCapDir(device mode) >>> 3. Reset the device with DCTL.CSftRst >>> 4. Then follow up with the initializing registers sequence >>> >>> Currently we're missing step 1) to do GCTL.CoreSoftReset and step 3) of >>> switching from host to device. John Stult reported a lockup issue seen >>> with HiKey960 platform without these steps[1]. Similar issue is observed >>> with Ferry's testing platform[2]. >>> >>> So, apply the required steps along with some fixes to Yu Chen's and John >>> Stultz's version. The main fixes to their versions are the missing wait >>> for clocks synchronization before clearing GCTL.CoreSoftReset and only >>> apply DCTL.CSftRst when switching from host to device. >>> >>> [1]https://lore.kernel.org/linux-usb/20210108015115.27920-1-john.stultz@linaro.org/ >>> [2]https://lore.kernel.org/linux-usb/0ba7a6ba-e6a7-9cd4-0695-64fc927e01f1@gmail.com/ >>> >>> Cc: Andy Shevchenko >>> Cc: Ferry Toth >>> Cc: Wesley Cheng >>> Cc: >>> Fixes: 41ce1456e1db ("usb: dwc3: core: make dwc3_set_mode() work properly") >>> Signed-off-by: Yu Chen >>> Signed-off-by: John Stultz >>> Signed-off-by: Thinh Nguyen >>> --- >>> Changes in v3: >>> - Check if the desired mode is OTG, then keep the old flow >>> - Remove condition for OTG support only since the device can still be >>> configured DRD host/device mode only >>> - Remove redundant hw_mode check since __dwc3_set_mode() only applies when >>> hw_mode is DRD >>> Changes in v2: >>> - Initialize mutex per device and not as global mutex. >>> - Add additional checks for DRD only mode >>> >> I've not been able to test all the different modes on HiKey960 yet, >> but with this patch we avoid the !COREIDLE hangs that we see >> frequently on bootup, so it looks pretty good to me. I'll get back to >> you tonight when I can put hands on the board to test the gadget to >> host switching to make sure all is well (I really don't expect any >> issues, but just want to be sure). > Ok, got a chance to test the mode switching and everything is looking good. I expect to be able to test this weekend on my platform. > Tested-by: John Stultz > > Thanks again for continuing to push this! > -john