Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3912984pxf; Mon, 29 Mar 2021 15:22:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwh+9GViKdwIcuNIz4MShzyQIjYSYMji2Jb32XmSR1q54I7H7kFGWYGED/5mXEGuboyr6cs X-Received: by 2002:a05:6402:104c:: with SMTP id e12mr29681727edu.108.1617056552849; Mon, 29 Mar 2021 15:22:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617056552; cv=none; d=google.com; s=arc-20160816; b=wW+KW2Ipk9qK6U2QYZx6b237VYyPltogfWAnWbktQXq6SR/ccA8dvqWmFbHLd+pHNZ pxK8r0gZpA9G0bZnR5joZnTYpWiCYbRtOF2Vox2XNJVuqlS5TKgj0Q06FBRTmLja4j/8 z8Fa3JdGk01f4YCpKnzjp1MpkGQNMcVXouEaAUPLHsnViXBoYx6NjErLx7LucyNDkQSb vqfcdv6rw3hHnkEnuGMDOOA1wEHF3BMqkxkblLRY5Tcti4bcn4pvEkaBZdC6Rm4/62w9 VLkvFiKcUtCEVaqyup6U97eIJ8shN4ab3lKn+NnDuetBr4uwmJTQ5qCmzlTuZnjbSilV md5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=XEji2TAqL8EMOw/dECJ/SLHPykwIL6tdzk/9l++9ONM=; b=TTzBEkG/ROGvGu+fDODyVXR33lQuNQs/Q4Gwe4paeCLhndIszkAYqZxALBQZlrgUwM MKvCkwHot+90aJYJrU01nAzLgZFy7Sflx/FoO1s4h84eZtpnBIRl8bvSK6c3JpmTdZsp nmMS59jk6CvWKN79c69/bPv+YLVMokGnbGBxL4AP65jQkWg19omO6hD+5mhMsUK9Byps vrmfO9eK4hjAkLVFeLUqijT0KuhVDCvMoQwWgiHWHTt/mSXJ4N6vCzflpfsnoXS+1hV1 E7g1O8mbI1x/YEDtHzn5pacx7r7CGxjnTkGu3yE656rJWMzUAyIDs7FgrBBqQqSM+ckf J2zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xm7vhW9f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c11si14372785edr.72.2021.03.29.15.22.09; Mon, 29 Mar 2021 15:22:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xm7vhW9f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229763AbhC2WVI (ORCPT + 99 others); Mon, 29 Mar 2021 18:21:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230444AbhC2WUw (ORCPT ); Mon, 29 Mar 2021 18:20:52 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C511C061764 for ; Mon, 29 Mar 2021 15:20:52 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id u20so17604734lja.13 for ; Mon, 29 Mar 2021 15:20:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XEji2TAqL8EMOw/dECJ/SLHPykwIL6tdzk/9l++9ONM=; b=Xm7vhW9fpntwFSs6+Gk3zPe6/sKChpK1gUaWx2UEolzwgdCJo2vumLIYJlyPge23nB 9dvzC9l//3Pn4WRhl2py7slEh8xf2C/jA1MuTeppti/T3EKkNI1Fyoj8zk7BE24Qt869 gUpGwmKnKRJfCN46q8tNJdnuN9mRHvszf8SL+Q6R/JPIYK/i+eClBM0ThzPGJHUZlM6N zdiArhgV4Hz0R6zHa5WV2AB14peEFC77Wq0oSdRCOK7UJj1CnZlZFwL3iOLr+LnJUJIT sB6xbk0C26JUh+RFMuRQLtEWwXMyTEn6fLW9WKz3JgInBBjMC3Ijev0tQuDDPBp+wnKN PTSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=XEji2TAqL8EMOw/dECJ/SLHPykwIL6tdzk/9l++9ONM=; b=hEJRhIFI4/9ZkWxo1NRnaZvBAgNCYU4f97nvpTBY1st69wLrl5PPjfs/trZWthuO+X gWxs8WxAmerMrM45euD/3p6EWhZiu0jvXre9mPb96mqzKDPJTrBzknsZBV20c7kVRXHE LvjKWOL4xafgumbcqzK88at6ejwyUeckhxcCQjy3Zg5vXg58CKt8mELidZJzC+1CaiAd SzL8dADbqc3HQezMhRkSwV1QX50OJZnPACZrIJ/TVNzQWMQQ9l216ZMQvz0tDA68TNRl u++0K3fE5dCxpRvQAjdUFpeXlq2ejOA3AxDujVPrjV6rPYfkXtgkyoFZDuXBwLODWK8D 86WQ== X-Gm-Message-State: AOAM532D2kDPTl/MEPSo6TfzMU5dyXGK81/5DydriJtrpSg/tvbIc05h Wpw1SB258NA6n3hni+HszoYvbWaHTOprWC5I6xA3Ow== X-Received: by 2002:a2e:509:: with SMTP id 9mr19246743ljf.170.1617056450500; Mon, 29 Mar 2021 15:20:50 -0700 (PDT) MIME-Version: 1.0 References: <20210108015115.27920-1-john.stultz@linaro.org> <87bldzwr6x.fsf@kernel.org> <06a44245-4f2f-69ba-fe46-b88a19f585c2@codeaurora.org> <3db531c4-7058-68ec-8d4b-ff122c307697@synopsys.com> <8b5f7348-66d7-4902-eac8-593ab503db96@codeaurora.org> <28bc3ce1-7ace-be25-7d7d-ca8ab1b0f0e9@synopsys.com> <62c7ee3a-21c4-009d-bfc0-ce9d3a84fefe@codeaurora.org> In-Reply-To: <62c7ee3a-21c4-009d-bfc0-ce9d3a84fefe@codeaurora.org> From: John Stultz Date: Mon, 29 Mar 2021 15:20:37 -0700 Message-ID: Subject: Re: [PATCH v3 1/2] usb: dwc3: Trigger a GCTL soft reset when switching modes in DRD To: Wesley Cheng Cc: Thinh Nguyen , Felipe Balbi , lkml , Yu Chen , Tejas Joglekar , Yang Fei , YongQin Liu , Andrzej Pietrasiewicz , Jun Li , Mauro Carvalho Chehab , Greg Kroah-Hartman , Linux USB List , Heikki Krogerus , Roger Quadros Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 29, 2021 at 3:15 PM Wesley Cheng wrote: > > > > On 3/19/2021 4:09 PM, Thinh Nguyen wrote: > > Wesley Cheng wrote: > >> > >> > >> On 3/8/2021 10:33 PM, Wesley Cheng wrote: > >>> > >>> > >>> On 3/8/2021 7:05 PM, Thinh Nguyen wrote: > >>>> Wesley Cheng wrote: > >>>>> > >>>>> On 3/6/2021 3:41 PM, Thinh Nguyen wrote: > >>>>>> Wesley Cheng wrote: > >>>>>>> On 1/8/2021 4:44 PM, Thinh Nguyen wrote: > >>>>>>>> Hi, > >>>>>>>> > >>>>>>>> John Stultz wrote: > >>>>>>>>> On Fri, Jan 8, 2021 at 4:26 AM Felipe Balbi wrote: > >>>>>>>>>> Hi, > >>>>>>>>>> > >>>>>>>>>> John Stultz writes: > >>>>>>>>>>> From: Yu Chen > >>>>>>>>>>> > >>>>>>>>>>> Just resending this, as discussion died out a bit and I'm not > >>>>>>>>>>> sure how to make further progress. See here for debug data that > >>>>>>>>>>> was requested last time around: > >>>>>>>>>>> https://urldefense.com/v3/__https://lore.kernel.org/lkml/CALAqxLXdnaUfJKx0aN9xWwtfWVjMWigPpy2aqsNj56yvnbU80g@mail.gmail.com/__;!!A4F2R9G_pg!LNzuprAeg-O80SgolYkIkW4-ne-M-yLWCDUY9MygAIrQC398Z6gRJ9wnsnlqd3w$ > >>>>>>>>>>> > >>>>>>>>>>> With the current dwc3 code on the HiKey960 we often see the > >>>>>>>>>>> COREIDLE flag get stuck off in __dwc3_gadget_start(), which > >>>>>>>>>>> seems to prevent the reset irq and causes the USB gadget to > >>>>>>>>>>> fail to initialize. > >>>>>>>>>>> > >>>>>>>>>>> We had seen occasional initialization failures with older > >>>>>>>>>>> kernels but with recent 5.x era kernels it seemed to be becoming > >>>>>>>>>>> much more common, so I dug back through some older trees and > >>>>>>>>>>> realized I dropped this quirk from Yu Chen during upstreaming > >>>>>>>>>>> as I couldn't provide a proper rational for it and it didn't > >>>>>>>>>>> seem to be necessary. I now realize I was wrong. > >>>>>>>>>>> > >>>>>>>>>>> After resubmitting the quirk, Thinh Nguyen pointed out that it > >>>>>>>>>>> shouldn't be a quirk at all and it is actually mentioned in the > >>>>>>>>>>> programming guide that it should be done when switching modes > >>>>>>>>>>> in DRD. > >>>>>>>>>>> > >>>>>>>>>>> So, to avoid these !COREIDLE lockups seen on HiKey960, this > >>>>>>>>>>> patch issues GCTL soft reset when switching modes if the > >>>>>>>>>>> controller is in DRD mode. > >>>>>>>>>>> > >>>>>>>>>>> Cc: Felipe Balbi > >>>>>>>>>>> Cc: Tejas Joglekar > >>>>>>>>>>> Cc: Yang Fei > >>>>>>>>>>> Cc: YongQin Liu > >>>>>>>>>>> Cc: Andrzej Pietrasiewicz > >>>>>>>>>>> Cc: Thinh Nguyen > >>>>>>>>>>> Cc: Jun Li > >>>>>>>>>>> Cc: Mauro Carvalho Chehab > >>>>>>>>>>> Cc: Greg Kroah-Hartman > >>>>>>>>>>> Cc: linux-usb@vger.kernel.org > >>>>>>>>>>> Signed-off-by: Yu Chen > >>>>>>>>>>> Signed-off-by: John Stultz > >>>>>>>>>>> --- > >>>>>>>>>>> v2: > >>>>>>>>>>> * Rework to always call the GCTL soft reset in DRD mode, > >>>>>>>>>>> rather then using a quirk as suggested by Thinh Nguyen > >>>>>>>>>>> > >>>>>>>>>>> v3: > >>>>>>>>>>> * Move GCTL soft reset under the spinlock as suggested by > >>>>>>>>>>> Thinh Nguyen > >>>>>>>>>> Because this is such an invasive change, I would prefer that we get > >>>>>>>>>> Tested-By tags from a good fraction of the users before applying these > >>>>>>>>>> two changes. > >>>>>>>>> I'm happy to reach out to folks to try to get that. Though I'm > >>>>>>>>> wondering if it would be better to put it behind a dts quirk flag, as > >>>>>>>>> originally proposed? > >>>>>>>>> https://urldefense.com/v3/__https://lore.kernel.org/lkml/20201021181803.79650-1-john.stultz@linaro.org/__;!!A4F2R9G_pg!LNzuprAeg-O80SgolYkIkW4-ne-M-yLWCDUY9MygAIrQC398Z6gRJ9wnRWITZfc$ > >>>>>>>>> > >>>>>>>>> That way folks can enable it for devices as they need? > >>>>>>>>> > >>>>>>>>> Again, I'm not trying to force this in as-is, just mostly sending it > >>>>>>>>> out again for discussion to understand what other approach might work. > >>>>>>>>> > >>>>>>>>> thanks > >>>>>>>>> -john > >>>>>>>> A quirk would imply something is broken/diverged from the design right? > >>>>>>>> But it's not the case here, and at least this is needed for HiKey960. > >>>>>>>> Also, I think Rob will be ok with not adding 1 more quirk to the dwc3 > >>>>>>>> devicetree. :) > >>>>>>>> > >>>>>>>> BR, > >>>>>>>> Thinh > >>>>>>>> > >>>>>>> Hi All, > >>>>>>> > >>>>>>> Sorry for jumping in, but I checked the SNPS v1.90a databook, and that > >>>>>>> seemed to remove the requirement for the GCTL.softreset before writing > >>>>>>> to PRTCAPDIR. Should we consider adding a controller version/IP check? > >>>>>>> > >>>>>> Hi Wesley, > >>>>>> > >>>>>> From what I see in the v1.90a databook and others, the flow remains the > >>>>>> same. I need to check internally, but I'm not aware of the change. > >>>>>> > >>>>> Hi Thinh, > >>>>> > >>>>> Hmmm, can you help check the register description for the PRTCAPDIR on > >>>>> your v1.90a databook? (Table 1-19 Fields for Register: GCTL (Continued) > >>>>> Pg73) When we compared the sequence in the description there to the > >>>>> previous versions it removed the GCTL.softreset. If it still shows up > >>>>> on yours, then maybe my v1.90a isn't the final version? > >>>>> > >>>>> Thanks > >>>>> Wesley Cheng > >>>>> > >>>> > >>>> Hi Wesley, > >>>> > >>>> Actually your IP version type may use the newer flow. Can you print your > >>>> DWC3_VER_TYPE? I still need to verify internally to know which versions > >>>> need the update if any. > >>>> > >>>> Thanks, > >>>> Thinh > >>>> > >>> Hi Thinh, > >>> > >>> Sure, my DWC3_VER_TYPE output = 0x67612A2A > >>> > >>> Thanks > >>> Wesley Cheng > >>> > >> Hi Thinh, > >> > >> Would you happen to have an update on the required sequence on the > >> version shared? Sorry for pushing, but we just wanted to finalize on > >> it, since it does cause some functional issues w/o the soft reset in > >> place, and causes a crash if we have the GCTL.softreset. > >> > >> Thanks > >> Wesley Cheng > >> > > > > Hi Wesley, > > > > I'm still trying to get that info for you. The versions without > > GCTL.softreset should be very new. The flow with GCTL.softreset should > > work for all versions and should not cause functional impact. We can > > create a change to optimize and remove GCTL.softreset for the newer > > controller versions at a later time. > > > > Since you and John Stultz have the setup that can be verified in the > > real world. It would be great if John or you provide a tested patch(es) > > to resolve this issue. > > > > Thanks, > > Thinh > > > Hi Thinh, > > Thanks for the input as always. I tested the GCTL.softreset change just > now, and it is working fine at least on my set up. > > Not sure if we'd need input from other vendors as well to get this > change merged. Did you test the original patch from this thread unchanged, or did you have any modifications? If the latter, feel free to send it out and I'll validate it on my side. thanks -john