Message ID | 20221206-dwc2-gadget-dual-role-v1-3-36515e1092cd@theobroma-systems.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp180798wrr; Wed, 7 Dec 2022 05:26:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf5rIsmLEeS9RljOoAejpyFI2aw+OpInkyhHarDskjTf9GehC6DuOrfjeRTAEfWItFgaUYJO X-Received: by 2002:a05:6402:e0d:b0:466:4168:6ea7 with SMTP id h13-20020a0564020e0d00b0046641686ea7mr20849275edh.273.1670419613841; Wed, 07 Dec 2022 05:26:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670419613; cv=none; d=google.com; s=arc-20160816; b=E3UxaAhDp/OLRud++dzRk1rc+F1Rswiwk8X5NmG167c3GTtAMLHs6VM4ga5eIsyI/f DxXCGZK0hyNC+RILZ2xPjAi2ACNAaaxvfXE0JVzV9wwTfGOrgBgp2Gc+vATYg1Qc+Kql lx6UMD4BBkRv4Oht/LY0US/WcXNEdFRbtYekL2d1C+pL/LY+twsAmcPMjOoudQpxEBBJ NneiMtsXfWE+qzEMRICy+A5xWw0innGydmb0EfwZ//LMJqXWJc30bYmdq++/3eV9iavH 9cQdSxw597lZ6b8/iou8/BNGh4uANAwBPKhsL0bVFTrOZnRK77h5nFfTPdDJWY0+6xK5 JiNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=U26f+M4wlDqheSbigFCS6ZSCHSIQRyS1mH7MNJFq3Q0=; b=QfSLetEr+fctl4sgDtAt8uF97TuMA34DIAyR9ONEMw3/AKIeQ3CD5gsoWzMm3yXE3v 8xNUgn8S82rglqlZTPrypOrmMdAKN7KxakCgNTWoyt0P62x3v/IpWHvIeJQY5rs1dtoZ nsHIZsNRFWbo/kC2pSojrOgCm6ALRMsINPwlc+D3UooF9eNG0rPvP7lqLdpmppGg4FR1 DlIAlPh24fe7g3//lj3Z3ShHBZhoczaCUsWXgFzUJml1hHtqXubH8Qm5U8PLSn/N9zpW 8+U3JoVazgFj3hz2+Y9rG8NLFRFEzcwowDHvth+ov49aG9Xbu3SUoNXYuHHFpBydVVLC 7JfQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ne1-20020a1709077b8100b00779f8e7ec5bsi18692031ejc.42.2022.12.07.05.26.30; Wed, 07 Dec 2022 05:26:53 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229962AbiLGNT4 (ORCPT <rfc822;b08248@gmail.com> + 99 others); Wed, 7 Dec 2022 08:19:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229680AbiLGNTu (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 7 Dec 2022 08:19:50 -0500 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::221]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A870140F7; Wed, 7 Dec 2022 05:19:49 -0800 (PST) Received: (Authenticated sender: foss@0leil.net) by mail.gandi.net (Postfix) with ESMTPSA id 72C2B24000F; Wed, 7 Dec 2022 13:19:44 +0000 (UTC) From: Quentin Schulz <foss+kernel@0leil.net> To: Minas Harutyunyan <hminas@synopsys.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Quentin Schulz <quentin.schulz@theobroma-systems.com>, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, William Wu <william.wu@rock-chips.com>, Bin Yang <yangbin@rock-chips.com>, Frank Wang <frank.wang@rock-chips.com> Subject: [PATCH 3/3] usb: dwc2: prevent core phy initialisation Date: Wed, 7 Dec 2022 14:19:18 +0100 Message-Id: <20221206-dwc2-gadget-dual-role-v1-3-36515e1092cd@theobroma-systems.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221206-dwc2-gadget-dual-role-v1-0-36515e1092cd@theobroma-systems.com> References: <20221206-dwc2-gadget-dual-role-v1-0-36515e1092cd@theobroma-systems.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.10.1 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751561917051859156?= X-GMAIL-MSGID: =?utf-8?q?1751561917051859156?= |
Series |
usb: dwc2: fix USB peripheral role in dual-role mode on PX30
|
|
Commit Message
Quentin Schulz
Dec. 7, 2022, 1:19 p.m. UTC
From: Quentin Schulz <quentin.schulz@theobroma-systems.com> From: Bin Yang <yangbin@rock-chips.com> The usb phys need to be controlled dynamically on some Rockchip SoCs. So set the new HCD flag which prevents USB core from trying to manage our phys. Signed-off-by: Bin Yang <yangbin@rock-chips.com> Signed-off-by: Frank Wang <frank.wang@rock-chips.com> Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com> --- drivers/usb/dwc2/hcd.c | 7 +++++++ 1 file changed, 7 insertions(+)
Comments
On Wed, Dec 07, 2022 at 02:19:18PM +0100, Quentin Schulz wrote: > From: Quentin Schulz <quentin.schulz@theobroma-systems.com> > > From: Bin Yang <yangbin@rock-chips.com> Can't have multiple "From:" lines, odd. I'll try to fix this up on my end...
On Wed, Dec 07, 2022 at 02:19:18PM +0100, Quentin Schulz wrote: > From: Bin Yang <yangbin@rock-chips.com> > > The usb phys need to be controlled dynamically on some Rockchip SoCs. > So set the new HCD flag which prevents USB core from trying to manage > our phys. > > Signed-off-by: Bin Yang <yangbin@rock-chips.com> > Signed-off-by: Frank Wang <frank.wang@rock-chips.com> > Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com> > --- > drivers/usb/dwc2/hcd.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c > index 657f1f659ffaf..757a66fa32fa8 100644 > --- a/drivers/usb/dwc2/hcd.c > +++ b/drivers/usb/dwc2/hcd.c > @@ -5315,6 +5315,13 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg) > if (!IS_ERR_OR_NULL(hsotg->uphy)) > otg_set_host(hsotg->uphy->otg, &hcd->self); > > + /* > + * do not manage the PHY state in the HCD core, instead let the driver > + * handle this (for example if the PHY can only be turned on after a > + * specific event) > + */ > + hcd->skip_phy_initialization = 1; Wait, doesn't this mess with the phy logic for all other chips that use this IP block? Have you tested this on other systems? I'd like some verification first before taking this change as it seems very specific-platform. thanks, greg k-h
Hi Greg, On 12/8/22 16:53, Greg Kroah-Hartman wrote: > On Wed, Dec 07, 2022 at 02:19:18PM +0100, Quentin Schulz wrote: >> From: Bin Yang <yangbin@rock-chips.com> >> >> The usb phys need to be controlled dynamically on some Rockchip SoCs. >> So set the new HCD flag which prevents USB core from trying to manage >> our phys. >> >> Signed-off-by: Bin Yang <yangbin@rock-chips.com> >> Signed-off-by: Frank Wang <frank.wang@rock-chips.com> >> Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com> >> --- >> drivers/usb/dwc2/hcd.c | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c >> index 657f1f659ffaf..757a66fa32fa8 100644 >> --- a/drivers/usb/dwc2/hcd.c >> +++ b/drivers/usb/dwc2/hcd.c >> @@ -5315,6 +5315,13 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg) >> if (!IS_ERR_OR_NULL(hsotg->uphy)) >> otg_set_host(hsotg->uphy->otg, &hcd->self); >> >> + /* >> + * do not manage the PHY state in the HCD core, instead let the driver >> + * handle this (for example if the PHY can only be turned on after a >> + * specific event) >> + */ >> + hcd->skip_phy_initialization = 1; > > Wait, doesn't this mess with the phy logic for all other chips that use > this IP block? Have you tested this on other systems? > I have not. I asked this in the cover-letter but I guess I should have made the patch series an RFC for this reason? > I'd like some verification first before taking this change as it seems > very specific-platform. > There's already some platform-specific callbacks for the driver (see dwc2_set_rk_params in drivers/usb/dwc2/params.c) but this gets called too early, before hcd structure is actually allocated. So we either need to use some "proxy"/shadow variable in dwc2_core_params and then update it right after hcd gets allocated or have another platform-specific callback only for hcd (post-)initialization. Nothing too fancy so shouldn't take too long to implement. Any preference? Something else? Also on a side note, after further testing, USB peripheral mode in dual-role mode does not seem to be entirely fixed with this patch series, I still have occasional locks. But considering that it absolutely didn't work before, it is some kind of progress. There are also some issues related to USB host mode in dual-role mode but I saw those happening before the patch series too. I'll see what I can do, really frustrating to work with IPs for which there's no documentation :/ Cheers, Quentin
On Fri, Dec 09, 2022 at 12:15:34PM +0100, Quentin Schulz wrote: > Hi Greg, > > On 12/8/22 16:53, Greg Kroah-Hartman wrote: > > On Wed, Dec 07, 2022 at 02:19:18PM +0100, Quentin Schulz wrote: > > > From: Bin Yang <yangbin@rock-chips.com> > > > > > > The usb phys need to be controlled dynamically on some Rockchip SoCs. > > > So set the new HCD flag which prevents USB core from trying to manage > > > our phys. > > > > > > Signed-off-by: Bin Yang <yangbin@rock-chips.com> > > > Signed-off-by: Frank Wang <frank.wang@rock-chips.com> > > > Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com> > > > --- > > > drivers/usb/dwc2/hcd.c | 7 +++++++ > > > 1 file changed, 7 insertions(+) > > > > > > diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c > > > index 657f1f659ffaf..757a66fa32fa8 100644 > > > --- a/drivers/usb/dwc2/hcd.c > > > +++ b/drivers/usb/dwc2/hcd.c > > > @@ -5315,6 +5315,13 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg) > > > if (!IS_ERR_OR_NULL(hsotg->uphy)) > > > otg_set_host(hsotg->uphy->otg, &hcd->self); > > > + /* > > > + * do not manage the PHY state in the HCD core, instead let the driver > > > + * handle this (for example if the PHY can only be turned on after a > > > + * specific event) > > > + */ > > > + hcd->skip_phy_initialization = 1; > > > > Wait, doesn't this mess with the phy logic for all other chips that use > > this IP block? Have you tested this on other systems? > > > > I have not. I asked this in the cover-letter but I guess I should have made > the patch series an RFC for this reason? Ah, should I drop the first 2 in this series that I already applied? > > I'd like some verification first before taking this change as it seems > > very specific-platform. > > > > There's already some platform-specific callbacks for the driver (see > dwc2_set_rk_params in drivers/usb/dwc2/params.c) but this gets called too > early, before hcd structure is actually allocated. So we either need to use > some "proxy"/shadow variable in dwc2_core_params and then update it right > after hcd gets allocated or have another platform-specific callback only for > hcd (post-)initialization. > > Nothing too fancy so shouldn't take too long to implement. Any preference? > Something else? Which ever you think would be simplest. thanks, greg k-h
Hi Greg, On 12/9/22 13:13, Greg Kroah-Hartman wrote: > On Fri, Dec 09, 2022 at 12:15:34PM +0100, Quentin Schulz wrote: >> Hi Greg, >> >> On 12/8/22 16:53, Greg Kroah-Hartman wrote: >>> On Wed, Dec 07, 2022 at 02:19:18PM +0100, Quentin Schulz wrote: >>>> From: Bin Yang <yangbin@rock-chips.com> >>>> >>>> The usb phys need to be controlled dynamically on some Rockchip SoCs. >>>> So set the new HCD flag which prevents USB core from trying to manage >>>> our phys. >>>> >>>> Signed-off-by: Bin Yang <yangbin@rock-chips.com> >>>> Signed-off-by: Frank Wang <frank.wang@rock-chips.com> >>>> Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com> >>>> --- >>>> drivers/usb/dwc2/hcd.c | 7 +++++++ >>>> 1 file changed, 7 insertions(+) >>>> >>>> diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c >>>> index 657f1f659ffaf..757a66fa32fa8 100644 >>>> --- a/drivers/usb/dwc2/hcd.c >>>> +++ b/drivers/usb/dwc2/hcd.c >>>> @@ -5315,6 +5315,13 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg) >>>> if (!IS_ERR_OR_NULL(hsotg->uphy)) >>>> otg_set_host(hsotg->uphy->otg, &hcd->self); >>>> + /* >>>> + * do not manage the PHY state in the HCD core, instead let the driver >>>> + * handle this (for example if the PHY can only be turned on after a >>>> + * specific event) >>>> + */ >>>> + hcd->skip_phy_initialization = 1; >>> >>> Wait, doesn't this mess with the phy logic for all other chips that use >>> this IP block? Have you tested this on other systems? >>> >> >> I have not. I asked this in the cover-letter but I guess I should have made >> the patch series an RFC for this reason? > > Ah, should I drop the first 2 in this series that I already applied? > Up to you. I need the three patches to have it (somewhat) working, so only merging the first two isn't going to improve the current situation much for me. I don't mind carrying them over for a v2 (or how many versions are needed). >>> I'd like some verification first before taking this change as it seems >>> very specific-platform. >>> >> >> There's already some platform-specific callbacks for the driver (see >> dwc2_set_rk_params in drivers/usb/dwc2/params.c) but this gets called too >> early, before hcd structure is actually allocated. So we either need to use >> some "proxy"/shadow variable in dwc2_core_params and then update it right >> after hcd gets allocated or have another platform-specific callback only for >> hcd (post-)initialization. >> >> Nothing too fancy so shouldn't take too long to implement. Any preference? >> Something else? > > Which ever you think would be simplest. > Got it. Cheers, Quentin
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 657f1f659ffaf..757a66fa32fa8 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -5315,6 +5315,13 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg) if (!IS_ERR_OR_NULL(hsotg->uphy)) otg_set_host(hsotg->uphy->otg, &hcd->self); + /* + * do not manage the PHY state in the HCD core, instead let the driver + * handle this (for example if the PHY can only be turned on after a + * specific event) + */ + hcd->skip_phy_initialization = 1; + /* * Finish generic HCD initialization and start the HCD. This function * allocates the DMA buffer pool, registers the USB bus, requests the