Message ID | 20221117205411.11489-3-ftoth@exalondelft.nl |
---|---|
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 q4csp620735wrr; Thu, 17 Nov 2022 13:04:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf4uKrYD/JPDrnqsu+w31kY7/TJUzZGbC8XSH0HdEfyGWrxeouttpCitb8eBmWhXIjO/PYtq X-Received: by 2002:a17:902:d38c:b0:186:c090:fc56 with SMTP id e12-20020a170902d38c00b00186c090fc56mr4439706pld.99.1668719044100; Thu, 17 Nov 2022 13:04:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668719044; cv=none; d=google.com; s=arc-20160816; b=i9RNjf9DkrwXRGM73DO7GRp0kWY5HUI+yHGDdmMw1EC6onW4mnf6ztsxl5AOY73lGQ MdhBtGcW2JfsrYaurrv1VJXgF7/6epQ4+3tbV6jAXVK2SD1aR4cJNkmWzDbd9kTv7nwc N3myh3hjnuxk/Lbj4LQ978sDbsfvbg73T3o2Iyd315u6UhNEPNMspJf+Z3pGp3i+l1E9 gKWdl+hN68jsmdjtTuLVqp4GyZhWdZ9rnIFAw+AWdSDHzxkh4JzHbluz7RQeT7pTP1cu vXq9Bo91qEvyrwdAbYCMtsTG8tS9cpdWPbjZi3QdFplwPVosxmrtfQtAsdWlUUVHOBGA kTDw== 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 :dkim-signature; bh=c3TOJ8pLm5BTTzG2jJheyd3COeod2HsVvmxYNZzeA0Y=; b=k9F6ccWPbjTzpviiXLV6ySu1xhj+lTLwDa4kYypUMYXwA2UM60xrlA8YvnCPlfjhGa ux/JegxvKxWNJuymX/tNnAcym83Kj59a3dU0CRflkNuP3rndCZw0RW5SNYmn5j2Y9KRj agvvfXGu49jDmvrb6hBf9ce8CHHROMGB32gHk9gaSXCubNV/Pn3ONz7mtmhn2GIiMbA1 C0yLCJM0ZwmbwvdUc/ZVSKCiwyEhY2HJZX1QYbPMKy5g7QC+s7w5Fl/DyS306NYRomLb d+mmLuUZDpdT4HHXripPNRo5q+ShFljJIAjMRLACCI641iVJjGThZ8MYmtIGNPwIRa4s hhUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@exalondelft.nl header.s=whs1 header.b=OitFVDhG; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=exalondelft.nl Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i12-20020a639d0c000000b0043c1cb75c22si1934381pgd.333.2022.11.17.13.03.50; Thu, 17 Nov 2022 13:04:04 -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; dkim=pass header.i=@exalondelft.nl header.s=whs1 header.b=OitFVDhG; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=exalondelft.nl Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234821AbiKQUyo (ORCPT <rfc822;a1648639935@gmail.com> + 99 others); Thu, 17 Nov 2022 15:54:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233894AbiKQUym (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 17 Nov 2022 15:54:42 -0500 Received: from mailfilter01-out40.webhostingserver.nl (mailfilter01-out40.webhostingserver.nl [195.211.73.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E83B85F8F for <linux-kernel@vger.kernel.org>; Thu, 17 Nov 2022 12:54:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=exalondelft.nl; s=whs1; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=c3TOJ8pLm5BTTzG2jJheyd3COeod2HsVvmxYNZzeA0Y=; b=OitFVDhGl+xE2L/yPPVmM2x/+/zb0GEoILRwTaL/meW8inP2r9oXA9+HZ+L7SCnbZ3RD+HrihIz9a OnHHU2AE/+fstcLs8lM6JOSHNo2Gqc76oE2DzIpHI/qghZvrb+YZ0WtQvQucS9LXhgRKRgkIBPCEIt RcqHnVW1glSUtUKKKa8/tQHne9fEMujKdoYnNbRU9lOUyr23XxItvw8dDdXivoZRCyXiTR7BHlDhZs DR8x/hidI+6685pGo3LWrkiZ4qM8Xr2NVwp/yyqswuFz2pK0A1qrvq5NhHHYlqsVRrNq/bB5ryK2fS dcEaMExaVLZ3ujtlwbzcP4KtA84ZikA== X-Halon-ID: 0c702c26-66ba-11ed-a6af-001a4a4cb906 Received: from s198.webhostingserver.nl (s198.webhostingserver.nl [141.138.168.154]) by mailfilter01.webhostingserver.nl (Halon) with ESMTPSA id 0c702c26-66ba-11ed-a6af-001a4a4cb906; Thu, 17 Nov 2022 21:54:37 +0100 (CET) Received: from 2a02-a466-68ed-1-6f6f-9a68-8ab0-3e9e.fixed6.kpn.net ([2a02:a466:68ed:1:6f6f:9a68:8ab0:3e9e] helo=delfion.fritz.box) by s198.webhostingserver.nl with esmtpa (Exim 4.96) (envelope-from <ftoth@exalondelft.nl>) id 1ovlu9-0054mk-31; Thu, 17 Nov 2022 21:54:38 +0100 From: Ferry Toth <ftoth@exalondelft.nl> To: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Thinh Nguyen <Thinh.Nguyen@synopsys.com>, Sean Anderson <sean.anderson@seco.com>, Liu Shixin <liushixin2@huawei.com>, Ferry Toth <fntoth@gmail.com>, Andrey Smirnov <andrew.smirnov@gmail.com>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, stable@vger.kernel.org, Ferry Toth <ftoth@exalondelft.nl> Subject: [PATCH v3 2/2] usb: dwc3: core: defer probe on ulpi_read_id timeout Date: Thu, 17 Nov 2022 21:54:11 +0100 Message-Id: <20221117205411.11489-3-ftoth@exalondelft.nl> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221117205411.11489-1-ftoth@exalondelft.nl> References: <20221117205411.11489-1-ftoth@exalondelft.nl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Antivirus-Scanner: Clean mail though you should still use an Antivirus X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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?1749778737171054160?= X-GMAIL-MSGID: =?utf-8?q?1749778739890743244?= |
Series |
usb: dwc3: core: defer probe on ulpi_read_id timeout
|
|
Commit Message
Ferry Toth
Nov. 17, 2022, 8:54 p.m. UTC
Since commit 0f010171
Dual Role support on Intel Merrifield platform broke due to rearranging
the call to dwc3_get_extcon().
It appears to be caused by ulpi_read_id() masking the timeout on the first
test write. In the past dwc3 probe continued by calling dwc3_core_soft_reset()
followed by dwc3_get_extcon() which happend to return -EPROBE_DEFER.
On deferred probe ulpi_read_id() finally succeeded.
As we now changed ulpi_read_id() to return -ETIMEDOUT in this case, we
need to handle the error by calling dwc3_core_soft_reset() and request
-EPROBE_DEFER. On deferred probe ulpi_read_id() is retried and succeeds.
Signed-off-by: Ferry Toth <ftoth@exalondelft.nl>
---
drivers/usb/dwc3/core.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
Comments
On Thu, Nov 17, 2022, Ferry Toth wrote: > Since commit 0f010171 I don't your update as noted in the v3 change (ie. Greg's suggestions). > Dual Role support on Intel Merrifield platform broke due to rearranging > the call to dwc3_get_extcon(). > > It appears to be caused by ulpi_read_id() masking the timeout on the first > test write. In the past dwc3 probe continued by calling dwc3_core_soft_reset() > followed by dwc3_get_extcon() which happend to return -EPROBE_DEFER. > On deferred probe ulpi_read_id() finally succeeded. > > As we now changed ulpi_read_id() to return -ETIMEDOUT in this case, we > need to handle the error by calling dwc3_core_soft_reset() and request > -EPROBE_DEFER. On deferred probe ulpi_read_id() is retried and succeeds. > > Signed-off-by: Ferry Toth <ftoth@exalondelft.nl> > --- > drivers/usb/dwc3/core.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > index 648f1c570021..2779f17bffaf 100644 > --- a/drivers/usb/dwc3/core.c > +++ b/drivers/usb/dwc3/core.c > @@ -1106,8 +1106,13 @@ static int dwc3_core_init(struct dwc3 *dwc) > > if (!dwc->ulpi_ready) { > ret = dwc3_core_ulpi_init(dwc); > - if (ret) > + if (ret) { > + if (ret == -ETIMEDOUT) { > + dwc3_core_soft_reset(dwc); I'm not sure if you saw my previous response. I wanted to check to see if we need to do soft-reset once before ulpi init as part of its initialization. I'm just curious why Andrey Smirnov test doesn't require this change. If it's a quirk for this specific configuration, then the change here is fine. If it's required for all ULPI setup, then we can unconditionally do that for all ULPI setup during initialization. > + ret = -EPROBE_DEFER; > + } > goto err0; > + } > dwc->ulpi_ready = true; > } > > -- > 2.37.2 > Thanks, Thinh
On 18-11-2022 03:11, Thinh Nguyen wrote: > On Thu, Nov 17, 2022, Ferry Toth wrote: >> Since commit 0f010171 > I don't your update as noted in the v3 change (ie. Greg's suggestions). Indeed. I seem to have sent in the wrong sha. Sorry about this. >> Dual Role support on Intel Merrifield platform broke due to rearranging >> the call to dwc3_get_extcon(). >> >> It appears to be caused by ulpi_read_id() masking the timeout on the first >> test write. In the past dwc3 probe continued by calling dwc3_core_soft_reset() >> followed by dwc3_get_extcon() which happend to return -EPROBE_DEFER. >> On deferred probe ulpi_read_id() finally succeeded. >> >> As we now changed ulpi_read_id() to return -ETIMEDOUT in this case, we >> need to handle the error by calling dwc3_core_soft_reset() and request >> -EPROBE_DEFER. On deferred probe ulpi_read_id() is retried and succeeds. >> >> Signed-off-by: Ferry Toth <ftoth@exalondelft.nl> >> --- >> drivers/usb/dwc3/core.c | 7 ++++++- >> 1 file changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c >> index 648f1c570021..2779f17bffaf 100644 >> --- a/drivers/usb/dwc3/core.c >> +++ b/drivers/usb/dwc3/core.c >> @@ -1106,8 +1106,13 @@ static int dwc3_core_init(struct dwc3 *dwc) >> >> if (!dwc->ulpi_ready) { >> ret = dwc3_core_ulpi_init(dwc); >> - if (ret) >> + if (ret) { >> + if (ret == -ETIMEDOUT) { >> + dwc3_core_soft_reset(dwc); > I'm not sure if you saw my previous response. I wanted to check to see > if we need to do soft-reset once before ulpi init as part of its > initialization. I missed it but found it now. I will try your suggestion and answer. > I'm just curious why Andrey Smirnov test doesn't require this change. If > it's a quirk for this specific configuration, then the change here is > fine. If it's required for all ULPI setup, then we can unconditionally > do that for all ULPI setup during initialization. Yes me too. I can reproduce that when I build kernel and rootfs with buildroot there is no issue. But as soon as I add ftrace / bootconfig the issue appears and then I can't analyze the flow. It's seems some kind of timing / race. However, I have tried deferring without dwc3_core_soft_reset() (to verify if it is just a matter of time) and that doesn't work. dwc3 is deferred about 10x and then gives up without phy. So, it's not just the time and not just a matter of retrying the test write. >> + ret = -EPROBE_DEFER; >> + } >> goto err0; >> + } >> dwc->ulpi_ready = true; >> } >> >> -- >> 2.37.2 >> > Thanks, > Thinh
On Fri, Nov 18, 2022, Ferry Toth wrote: > > On 18-11-2022 03:11, Thinh Nguyen wrote: > > On Thu, Nov 17, 2022, Ferry Toth wrote: > > > Since commit 0f010171 > > I don't your update as noted in the v3 change (ie. Greg's suggestions). > > Indeed. I seem to have sent in the wrong sha. Sorry about this. > > > > Dual Role support on Intel Merrifield platform broke due to rearranging > > > the call to dwc3_get_extcon(). > > > > > > It appears to be caused by ulpi_read_id() masking the timeout on the first > > > test write. In the past dwc3 probe continued by calling dwc3_core_soft_reset() > > > followed by dwc3_get_extcon() which happend to return -EPROBE_DEFER. > > > On deferred probe ulpi_read_id() finally succeeded. > > > > > > As we now changed ulpi_read_id() to return -ETIMEDOUT in this case, we > > > need to handle the error by calling dwc3_core_soft_reset() and request > > > -EPROBE_DEFER. On deferred probe ulpi_read_id() is retried and succeeds. > > > > > > Signed-off-by: Ferry Toth <ftoth@exalondelft.nl> > > > --- > > > drivers/usb/dwc3/core.c | 7 ++++++- > > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > > > index 648f1c570021..2779f17bffaf 100644 > > > --- a/drivers/usb/dwc3/core.c > > > +++ b/drivers/usb/dwc3/core.c > > > @@ -1106,8 +1106,13 @@ static int dwc3_core_init(struct dwc3 *dwc) > > > if (!dwc->ulpi_ready) { > > > ret = dwc3_core_ulpi_init(dwc); > > > - if (ret) > > > + if (ret) { > > > + if (ret == -ETIMEDOUT) { > > > + dwc3_core_soft_reset(dwc); > > I'm not sure if you saw my previous response. I wanted to check to see > > if we need to do soft-reset once before ulpi init as part of its > > initialization. > I missed it but found it now. I will try your suggestion and answer. I think it may not be needed now from your experiments noted below. > > I'm just curious why Andrey Smirnov test doesn't require this change. If > > it's a quirk for this specific configuration, then the change here is > > fine. If it's required for all ULPI setup, then we can unconditionally > > do that for all ULPI setup during initialization. > > Yes me too. I can reproduce that when I build kernel and rootfs with > buildroot there is no issue. But as soon as I add ftrace / bootconfig the > issue appears and then I can't analyze the flow. It's seems some kind of > timing / race. I think this is very useful info that should go into the commit message. > > However, I have tried deferring without dwc3_core_soft_reset() (to verify if > it is just a matter of time) and that doesn't work. dwc3 is deferred about > 10x and then gives up without phy. So, it's not just the time and not just a > matter of retrying the test write. Even though we can't root cause the problem, this fix should be fine. > > > > + ret = -EPROBE_DEFER; > > > + } > > > goto err0; > > > + } > > > dwc->ulpi_ready = true; > > > } > > > -- > > > 2.37.2 > > > Thanks, Thinh
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 648f1c570021..2779f17bffaf 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1106,8 +1106,13 @@ static int dwc3_core_init(struct dwc3 *dwc) if (!dwc->ulpi_ready) { ret = dwc3_core_ulpi_init(dwc); - if (ret) + if (ret) { + if (ret == -ETIMEDOUT) { + dwc3_core_soft_reset(dwc); + ret = -EPROBE_DEFER; + } goto err0; + } dwc->ulpi_ready = true; }