Message ID | 20221205201527.13525-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 q4csp2465511wrr; Mon, 5 Dec 2022 12:47:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf7S1WSgcs+iMJwhzTFizchR18bB8bi+xjWo1MCDtUJ0PXOvKlGFPnqcuSRJVr4q1fgUwc5v X-Received: by 2002:a17:906:fac9:b0:7c0:d31d:638 with SMTP id lu9-20020a170906fac900b007c0d31d0638mr10732364ejb.206.1670273227458; Mon, 05 Dec 2022 12:47:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670273227; cv=none; d=google.com; s=arc-20160816; b=iic4H0bnlRVXt35xSv/PXPEZPQH/2wfIwDL5KyijCs2ptLMFwsuGsx5chghclcNNeL wZ66EZO2J2YUoMF8yr4pys8mHNV3kfv6Mfo5k5GikD65bY6ajdwLnqv06FJ1UjETF3Et XtWQ6sy5ecoB7gBpfcR5fevFfTzFqjOh6yzPB6P2jBCnNeI0/4HBOWZfDBwJcoSqM5Jo JFAz4JKAEcbNLIMVzXj7KsWLzG9B+SxjyCBe8cT5TmTXyQcMJe39u89WD0LH093ACrCg 9GaSwkI+OQxVYZTi78dyTCiwKoAFOsHniq71cAEHtc4AF9/I2qYRzcPUseiEdi4ic4ik 9MvQ== 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=AL68zLQaEqSRdRgznjgITv4ps8SL1cEIOEoowj++pC0=; b=QzmTXhgIEzfCGYOahGf+saCEkvLnSPsimzmTPHPVtypjEH92AdtkkAP2n+5YUfKbWK OnaI3R+o+l8XZwatRO2Td9/JQYgA0KoscUZ/9ViSsl97KM1Pu6QRWN7YZtluSgQHYAT1 VSbaRslP6zVtHh7SM6bT+T6DHyVZOjaJ0dH9wIoB8LowTGKaV1cXKsS7bTUm1zHV7xsT lw20B+x2WpthbhwhkmMCbUZWLhZIPwpTZjUFGmcZNB2OsRAlSfAmP9nkffJOddbHLOc5 wD7VLtqCgOs4GKdlDicgvhgjNBxXfTFfySc+UJZwbtuFZRUlWPf+dZfAL9an2UERZiiF HVRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@exalondelft.nl header.s=whs1 header.b=LdS12Pfv; 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 w15-20020aa7dccf000000b0046c46bc5c9csi353746edu.327.2022.12.05.12.46.43; Mon, 05 Dec 2022 12:47:07 -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=LdS12Pfv; 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 S233189AbiLEUQC (ORCPT <rfc822;jaysivo@gmail.com> + 99 others); Mon, 5 Dec 2022 15:16:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233250AbiLEUP5 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 5 Dec 2022 15:15:57 -0500 Received: from mailfilter02-out40.webhostingserver.nl (mailfilter02-out40.webhostingserver.nl [195.211.72.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B965A28725 for <linux-kernel@vger.kernel.org>; Mon, 5 Dec 2022 12:15:55 -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=AL68zLQaEqSRdRgznjgITv4ps8SL1cEIOEoowj++pC0=; b=LdS12PfvgO5v8km82BezuW5J7/N+8R0QJmVHg5WCv4c2rBVONAILw2o5N2+KXgYO91Zy0658TRUPf o8lpPyIMVCTlQe5ipASaefd3/OsYLGbhrvKQ8g3e+xtusdTdgrwBZilus7V2RkwbgPLhNF1V1Tlc0Z VS/3AT8MmDjNPk9ZfG4vyVS9VCF2K6futTKdwrkRfeXN/WpzXr55i6yaKmaMfgMrOiNOyfN2vkpaQ0 wNtEah/xcTLXS0v28pHx1ZATXIeYXDSsFjdKg40jkO7SmBKqpbMC3HIPbbN/hGl8pW9xyB/r0wqcMW CVGeBWDep4K/pm9cCKIIhUumeLXMMmw== X-Halon-ID: 9e8bd91a-74d9-11ed-aeca-001a4a4cb922 Received: from s198.webhostingserver.nl (s198.webhostingserver.nl [141.138.168.154]) by mailfilter02.webhostingserver.nl (Halon) with ESMTPSA id 9e8bd91a-74d9-11ed-aeca-001a4a4cb922; Mon, 05 Dec 2022 21:15:53 +0100 (CET) Received: from 2a02-a466-68ed-1-f633-1bb8-92a6-ba5d.fixed6.kpn.net ([2a02:a466:68ed:1:f633:1bb8:92a6:ba5d] helo=delfion.fritz.box) by s198.webhostingserver.nl with esmtpa (Exim 4.96) (envelope-from <ftoth@exalondelft.nl>) id 1p2HsX-001b54-0z; Mon, 05 Dec 2022 21:15:53 +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>, Ferry Toth <ftoth@exalondelft.nl>, stable@vger.kernel.org Subject: [PATCH v5 2/2] usb: dwc3: core: defer probe on ulpi_read_id timeout Date: Mon, 5 Dec 2022 21:15:27 +0100 Message-Id: <20221205201527.13525-3-ftoth@exalondelft.nl> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221205201527.13525-1-ftoth@exalondelft.nl> References: <20221205201527.13525-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,SPF_HELO_PASS, SPF_PASS autolearn=unavailable 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?1751407160378363369?= X-GMAIL-MSGID: =?utf-8?q?1751408420004218717?= |
Series |
usb: dwc3: core: defer probe on ulpi_read_id timeout
|
|
Commit Message
Ferry Toth
Dec. 5, 2022, 8:15 p.m. UTC
Since commit 0f0101719138 ("usb: dwc3: Don't switch OTG -> peripheral
if extcon is present"), 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. Due to above mentioned
rearranging -EPROBE_DEFER is not returned and probe completes without phy.
On Intel Merrifield the timeout on the first test write issue is reproducible
but it is difficult to find the root cause. Using a mainline kernel and
rootfs with buildroot ulpi_read_id() succeeds. As soon as adding
ftrace / bootconfig to find out why, ulpi_read_id() fails and we can't
analyze the flow. Using another rootfs ulpi_read_id() fails even without
adding ftrace. We suspect the issue is some kind of timing / race, but
merely retrying ulpi_read_id() does not resolve the issue.
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.
Fixes: ef6a7bcfb01c ("usb: ulpi: Support device discovery via DT")
Cc: stable@vger.kernel.org
Signed-off-by: Ferry Toth <ftoth@exalondelft.nl>
---
drivers/usb/dwc3/core.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
Comments
On Mon, Dec 05, 2022, Ferry Toth wrote: > Since commit 0f0101719138 ("usb: dwc3: Don't switch OTG -> peripheral > if extcon is present"), 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. Due to above mentioned > rearranging -EPROBE_DEFER is not returned and probe completes without phy. > > On Intel Merrifield the timeout on the first test write issue is reproducible > but it is difficult to find the root cause. Using a mainline kernel and > rootfs with buildroot ulpi_read_id() succeeds. As soon as adding > ftrace / bootconfig to find out why, ulpi_read_id() fails and we can't > analyze the flow. Using another rootfs ulpi_read_id() fails even without > adding ftrace. We suspect the issue is some kind of timing / race, but > merely retrying ulpi_read_id() does not resolve the issue. > > 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. > > Fixes: ef6a7bcfb01c ("usb: ulpi: Support device discovery via DT") > Cc: stable@vger.kernel.org > 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); > + ret = -EPROBE_DEFER; > + } > goto err0; > + } > dwc->ulpi_ready = true; > } > > -- > 2.37.2 > 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 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; }