Message ID | 20221106214804.2814-1-j@jannau.net |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1691340wru; Sun, 6 Nov 2022 13:59:08 -0800 (PST) X-Google-Smtp-Source: AMsMyM74rwwhntSV/26HGd4cKqbOHX28OLCDkp5MmdyGgNrQ9Yc4a5GQLFLGbJPQr65pYuEsEhl/ X-Received: by 2002:a50:eb05:0:b0:457:c6f5:5f65 with SMTP id y5-20020a50eb05000000b00457c6f55f65mr46269298edp.311.1667771948770; Sun, 06 Nov 2022 13:59:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667771948; cv=none; d=google.com; s=arc-20160816; b=RDhDHSOg5omBf4AKAkGmem/jFDTtbQRwpgJ0ICDDvqAVAezi6j42faAQOshMTKfJ/K akL7CJklePMFETpGcFNAfK6+nEQGiol1b6/VT1F1xU1BsNc9Jx5tSjH59EM131gsoaIW 18lPbCp3SIqVELkO6++phWCP5Q9QIiugayc1uvoibV+VOLmCRTK6PGQBcEdotoA/Yr3A Knv1D+zirLPdm3mRp49Al6T8ey64uYlK/Agb6cFd8V0MAr7350JzzcIo0Jpi4CN3Q7dG dJ2Ip+PKPQBDNHqagzkJU7eXi+FHOsvu9HN/yo4HDPe3Z317Sf0CsKKxWyawuy5r61XG i/VQ== 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 :message-id:date:subject:cc:to:from; bh=1P6cQJLB3ZzwwPBXeoVw7g6REgTfuWG5cmRqGfMdtqg=; b=vRsb62Ay5kBwqtFg7bcoJt3aXR2QFZNVLwQrqC/nFpnTXIDM+3H9g0MInQ9ICpq8G8 l8QnozNAi22PIdAboVeYGhxi5W8ej8ICMQYVbyLDo9IJFOUgNXOpC4xTz0HdnoQZfDwp bvW2sZ89Kb/xGdKxY5MsY84OVN4GrmIvn3T7VciBBIFFHaGJGdcxDDTtmVH8ASQn1nLH 3sYuKVtqOCXE6hv8q2MSYCQTsaWfMxffSHycFcfQbak4mN8uo0Txh6HZRrqCzXW08y6A wKtWAMuq2v3aXa9laN3nU6imixBYxh3OQF7/mC/+eD8OfIfHtuSEViHBsijhJdVeWAXF UjLQ== 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 r18-20020a170906551200b007919c624eadsi5224962ejp.522.2022.11.06.13.58.44; Sun, 06 Nov 2022 13:59:08 -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 S230204AbiKFV5o (ORCPT <rfc822;hjfbswb@gmail.com> + 99 others); Sun, 6 Nov 2022 16:57:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230003AbiKFV5n (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 6 Nov 2022 16:57:43 -0500 X-Greylist: delayed 574 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sun, 06 Nov 2022 13:57:41 PST Received: from soltyk.jannau.net (soltyk.jannau.net [144.76.91.90]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FA2A111C for <linux-kernel@vger.kernel.org>; Sun, 6 Nov 2022 13:57:41 -0800 (PST) Received: from robin.home.jannau.net (p54acc2ba.dip0.t-ipconnect.de [84.172.194.186]) by soltyk.jannau.net (Postfix) with ESMTPSA id 1CEBC26F2E4; Sun, 6 Nov 2022 22:48:05 +0100 (CET) From: Janne Grunau <j@jannau.net> To: linux-usb@vger.kernel.org Cc: Sven Peter <sven@svenpeter.de>, stable@kernel.org, Thinh Nguyen <Thinh.Nguyen@synopsys.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Andrey Smirnov <andrew.smirnov@gmail.com>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, linux-kernel@vger.kernel.org Subject: [PATCH 1/1] usb: dwc3: Do not get extcon device when usb-role-switch is used Date: Sun, 6 Nov 2022 22:48:04 +0100 Message-Id: <20221106214804.2814-1-j@jannau.net> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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?1748785639156672564?= X-GMAIL-MSGID: =?utf-8?q?1748785639156672564?= |
Series |
[1/1] usb: dwc3: Do not get extcon device when usb-role-switch is used
|
|
Commit Message
Janne Grunau
Nov. 6, 2022, 9:48 p.m. UTC
The change breaks device tree based platforms with PHY device and use
usb-role-switch instead of an extcon switch. extcon_find_edev_by_node()
will return EPROBE_DEFER if it can not find a device so probing without
an extcon device will be deferred indefinitely. Fix this by
explicitly checking for usb-role-switch.
At least the out-of-tree USB3 support on Apple silicon based platforms
using dwc3 with tipd USB Type-C and PD controller is affected by this
issue.
Fixes: d182c2e1bc92 ("usb: dwc3: Don't switch OTG -> peripheral if extcon is present")
Cc: stable@kernel.org
Signed-off-by: Janne Grunau <j@jannau.net>
---
drivers/usb/dwc3/core.c | 10 ++++++++++
1 file changed, 10 insertions(+)
Comments
On Sun, Nov 06, 2022 at 10:48:04PM +0100, Janne Grunau wrote: > The change breaks device tree based platforms with PHY device and use > usb-role-switch instead of an extcon switch. extcon_find_edev_by_node() > will return EPROBE_DEFER if it can not find a device so probing without > an extcon device will be deferred indefinitely. Fix this by > explicitly checking for usb-role-switch. > At least the out-of-tree USB3 support on Apple silicon based platforms > using dwc3 with tipd USB Type-C and PD controller is affected by this > issue. We don't care about out-of-tree modules, do we? OTOH, the problem you are trying to workaround is probably in a (mis)use of deferred probe somewhere. Btw, does it prevent the system boot or you just see the extcon in the list of deferred devices after booting?
On Mon, Nov 7, 2022, at 12:25, Andy Shevchenko wrote: > On Sun, Nov 06, 2022 at 10:48:04PM +0100, Janne Grunau wrote: >> The change breaks device tree based platforms with PHY device and use >> usb-role-switch instead of an extcon switch. extcon_find_edev_by_node() >> will return EPROBE_DEFER if it can not find a device so probing without >> an extcon device will be deferred indefinitely. Fix this by >> explicitly checking for usb-role-switch. >> At least the out-of-tree USB3 support on Apple silicon based platforms >> using dwc3 with tipd USB Type-C and PD controller is affected by this >> issue. > > We don't care about out-of-tree modules, do we? > > OTOH, the problem you are trying to workaround is probably in a (mis)use of > deferred probe somewhere. > > Btw, does it prevent the system boot or you just see the extcon in the list of > deferred devices after booting? Which extcon? The commit description already mentions that the issue is that there is no extcon and that the dwc3 probe gets stuck with EPROBE_DEFER forever. This happens because the code after Janne's new check looks for the PHY and then just assumes that if the PHY has a "port" that the other end always is an extcon. It then tries extcon_find_edev_by_node which will always fail with EPROBE_DEFER if that node never registers an extcon. If "usb-role-switch" is used and configured in the DT there is no extcon. There actually cannot ever be a working extcon with "usb-role-switch" because the very first thing dwc3_drd_init does is to look for a role switch partner and then skip the entire extcon setup: int dwc3_drd_init(struct dwc3 *dwc) { int ret, irq; if (ROLE_SWITCH && device_property_read_bool(dwc->dev, "usb-role-switch")) return dwc3_setup_role_switch(dwc); [....] This entire issue was actually first fixed in ab7aa2866d29, then broken again in 0f0101719138 due to a merge resolution, then fixed again with 7a84e7353e23 (where we actually had a brief discussion about this already on the ML) and then broken again in d182c2e1bc92. Janne's fix is much less subtle and should hopefully survive this time. For the patch: Reviewed-by: Sven Peter <sven@svenpeter.dev> Best, Sven
Hi, On Sun, Nov 06, 2022, Janne Grunau wrote: > The change breaks device tree based platforms with PHY device and use > usb-role-switch instead of an extcon switch. extcon_find_edev_by_node() > will return EPROBE_DEFER if it can not find a device so probing without > an extcon device will be deferred indefinitely. Fix this by > explicitly checking for usb-role-switch. > At least the out-of-tree USB3 support on Apple silicon based platforms > using dwc3 with tipd USB Type-C and PD controller is affected by this > issue. > > Fixes: d182c2e1bc92 ("usb: dwc3: Don't switch OTG -> peripheral if extcon is present") > Cc: stable@kernel.org > Signed-off-by: Janne Grunau <j@jannau.net> > --- > drivers/usb/dwc3/core.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > index c0e7c76dc5c8..1f348bc867c2 100644 > --- a/drivers/usb/dwc3/core.c > +++ b/drivers/usb/dwc3/core.c > @@ -1710,6 +1710,16 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) > if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) > return extcon_get_extcon_dev(name); > > + /* > + * Check explicitly if "usb-role-switch" is used since > + * extcon_find_edev_by_node() can not be used to check the absence of can not -> can't or cannot > + * an extcon device. In the absence of an device it will always return "a" device, > + * EPROBE_DEFER. > + */ > + if (IS_ENABLED(CONFIG_USB_ROLE_SWITCH) && > + device_property_read_bool(dev, "usb-role-switch")) > + return NULL; > + > /* > * Try to get an extcon device from the USB PHY controller's "port" > * node. Check if it has the "port" node first, to avoid printing the > -- > 2.37.3 > Looks like the "port" node check from c824c73a5e08 ("usb: dwc3: drd: Avoid error when extcon is missing") did not account for this platform setup. This looks fine to me. Should we cleanup the incomplete check and stale comment right after this too (as a separate patch)? Thanks, Thinh
On Tue, Nov 08, 2022 at 02:02:19AM +0000, Thinh Nguyen wrote: > Hi, > > On Sun, Nov 06, 2022, Janne Grunau wrote: > > The change breaks device tree based platforms with PHY device and use > > usb-role-switch instead of an extcon switch. extcon_find_edev_by_node() > > will return EPROBE_DEFER if it can not find a device so probing without > > an extcon device will be deferred indefinitely. Fix this by > > explicitly checking for usb-role-switch. > > At least the out-of-tree USB3 support on Apple silicon based platforms > > using dwc3 with tipd USB Type-C and PD controller is affected by this > > issue. > > > > Fixes: d182c2e1bc92 ("usb: dwc3: Don't switch OTG -> peripheral if extcon is present") > > Cc: stable@kernel.org > > Signed-off-by: Janne Grunau <j@jannau.net> > > --- > > drivers/usb/dwc3/core.c | 10 ++++++++++ > > 1 file changed, 10 insertions(+) > > > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > > index c0e7c76dc5c8..1f348bc867c2 100644 > > --- a/drivers/usb/dwc3/core.c > > +++ b/drivers/usb/dwc3/core.c > > @@ -1710,6 +1710,16 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) > > if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) > > return extcon_get_extcon_dev(name); > > > > + /* > > + * Check explicitly if "usb-role-switch" is used since > > + * extcon_find_edev_by_node() can not be used to check the absence of > > can not -> can't or cannot "can not" is fine. > > > + * an extcon device. In the absence of an device it will always return > > "a" device, Not an issue. > > + * EPROBE_DEFER. > > + */ > > + if (IS_ENABLED(CONFIG_USB_ROLE_SWITCH) && > > + device_property_read_bool(dev, "usb-role-switch")) > > + return NULL; > > + > > /* > > * Try to get an extcon device from the USB PHY controller's "port" > > * node. Check if it has the "port" node first, to avoid printing the > > -- > > 2.37.3 > > > > Looks like the "port" node check from c824c73a5e08 ("usb: dwc3: drd: > Avoid error when extcon is missing") did not account for this platform > setup. > > This looks fine to me. Should we cleanup the incomplete check and stale > comment right after this too (as a separate patch)? Is this a Reviewed-by: ? thanks, greg k-h
On Tue, Nov 08, 2022, Greg Kroah-Hartman wrote: > On Tue, Nov 08, 2022 at 02:02:19AM +0000, Thinh Nguyen wrote: > > Hi, > > > > On Sun, Nov 06, 2022, Janne Grunau wrote: > > > The change breaks device tree based platforms with PHY device and use > > > usb-role-switch instead of an extcon switch. extcon_find_edev_by_node() > > > will return EPROBE_DEFER if it can not find a device so probing without > > > an extcon device will be deferred indefinitely. Fix this by > > > explicitly checking for usb-role-switch. > > > At least the out-of-tree USB3 support on Apple silicon based platforms > > > using dwc3 with tipd USB Type-C and PD controller is affected by this > > > issue. > > > > > > Fixes: d182c2e1bc92 ("usb: dwc3: Don't switch OTG -> peripheral if extcon is present") > > > Cc: stable@kernel.org > > > Signed-off-by: Janne Grunau <j@jannau.net> > > > --- > > > drivers/usb/dwc3/core.c | 10 ++++++++++ > > > 1 file changed, 10 insertions(+) > > > > > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > > > index c0e7c76dc5c8..1f348bc867c2 100644 > > > --- a/drivers/usb/dwc3/core.c > > > +++ b/drivers/usb/dwc3/core.c > > > @@ -1710,6 +1710,16 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) > > > if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) > > > return extcon_get_extcon_dev(name); > > > > > > + /* > > > + * Check explicitly if "usb-role-switch" is used since > > > + * extcon_find_edev_by_node() can not be used to check the absence of > > > > can not -> can't or cannot > > "can not" is fine. > > > > > > + * an extcon device. In the absence of an device it will always return > > > > "a" device, > > Not an issue. > > > > + * EPROBE_DEFER. > > > + */ > > > + if (IS_ENABLED(CONFIG_USB_ROLE_SWITCH) && > > > + device_property_read_bool(dev, "usb-role-switch")) > > > + return NULL; > > > + > > > /* > > > * Try to get an extcon device from the USB PHY controller's "port" > > > * node. Check if it has the "port" node first, to avoid printing the > > > -- > > > 2.37.3 > > > > > > > Looks like the "port" node check from c824c73a5e08 ("usb: dwc3: drd: > > Avoid error when extcon is missing") did not account for this platform > > setup. > > > > This looks fine to me. Should we cleanup the incomplete check and stale > > comment right after this too (as a separate patch)? > > Is this a Reviewed-by: ? > Please pick up this fix. Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> Thanks, Thinh
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index c0e7c76dc5c8..1f348bc867c2 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1710,6 +1710,16 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) return extcon_get_extcon_dev(name); + /* + * Check explicitly if "usb-role-switch" is used since + * extcon_find_edev_by_node() can not be used to check the absence of + * an extcon device. In the absence of an device it will always return + * EPROBE_DEFER. + */ + if (IS_ENABLED(CONFIG_USB_ROLE_SWITCH) && + device_property_read_bool(dev, "usb-role-switch")) + return NULL; + /* * Try to get an extcon device from the USB PHY controller's "port" * node. Check if it has the "port" node first, to avoid printing the