From patchwork Thu Nov 17 20:54:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferry Toth X-Patchwork-Id: 13047284 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45FA4C4332F for ; Thu, 17 Nov 2022 20:55:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239207AbiKQUzf (ORCPT ); Thu, 17 Nov 2022 15:55:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239229AbiKQUze (ORCPT ); Thu, 17 Nov 2022 15:55:34 -0500 X-Greylist: delayed 62 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 17 Nov 2022 12:55:32 PST Received: from mailfilter03-out40.webhostingserver.nl (mailfilter03-out40.webhostingserver.nl [195.211.72.99]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB7945ADDD for ; Thu, 17 Nov 2022 12:55:32 -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=Pc/8xsignvpb7hB1IAB5J46UWvZn4zJkaYhKUZ3kXYA=; b=fBkyeFIAvIHuBpWxkopNlU0s0jmiZ0nClgzFjBf1U5Fg+FSegUv0B1lwH5D5rhFJmJk0c7k+bmq9V WrmICmEuf/aFU8sJsIuyYL/zaYYMrlYtFI25aZrSaKDvSNsBgLvhJPsuuh6Tqs0ADbuVuELh8ui/Im ti8K0oyPVy0rlZdeNmbbE93NUgmuHXeARwwsRQVjHrLqd0wA7O52hrKtbmqsWdEd7hyTufvjTNx4He d5LzxcYaBLBJah6ROmxCg8ZcUPAVyMto4aazd+nNs/fhQMwsJqarD1tpPPiRz5y6qpGvB6SN+FJqKW ypUTLzKeq2RoviHALqpzpXBdLYgpwDA== X-Halon-ID: ccbc479a-66b9-11ed-af3a-001a4a4cb9a5 Received: from s198.webhostingserver.nl (s198.webhostingserver.nl [141.138.168.154]) by mailfilter03.webhostingserver.nl (Halon) with ESMTPSA id ccbc479a-66b9-11ed-af3a-001a4a4cb9a5; Thu, 17 Nov 2022 21:52:50 +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 ) id 1ovltz-0054mk-1t; Thu, 17 Nov 2022 21:54:27 +0100 From: Ferry Toth To: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Heikki Krogerus , Greg Kroah-Hartman , Thinh Nguyen , Sean Anderson , Liu Shixin , Ferry Toth , Andrey Smirnov , Andy Shevchenko , stable@vger.kernel.org, Ferry Toth Subject: [PATCH v3 1/2] usb: ulpi: defer ulpi_register on ulpi_read_id timeout Date: Thu, 17 Nov 2022 21:54:10 +0100 Message-Id: <20221117205411.11489-2-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 X-Antivirus-Scanner: Clean mail though you should still use an Antivirus Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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() on the first test write failing with -ETIMEDOUT. Currently ulpi_read_id() expects to discover the phy via DT when the test write fails and returns 0 in that case even if DT does not provide the phy. As a result usb probe completes without phy. Signed-off-by: Ferry Toth --- drivers/usb/common/ulpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c index d7c8461976ce..60e8174686a1 100644 --- a/drivers/usb/common/ulpi.c +++ b/drivers/usb/common/ulpi.c @@ -207,7 +207,7 @@ static int ulpi_read_id(struct ulpi *ulpi) /* Test the interface */ ret = ulpi_write(ulpi, ULPI_SCRATCH, 0xaa); if (ret < 0) - goto err; + return ret; ret = ulpi_read(ulpi, ULPI_SCRATCH); if (ret < 0) From patchwork Thu Nov 17 20:54:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferry Toth X-Patchwork-Id: 13047283 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E52D4C4332F for ; Thu, 17 Nov 2022 20:54:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231194AbiKQUyn (ORCPT ); Thu, 17 Nov 2022 15:54:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234821AbiKQUym (ORCPT ); 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 E7DC0218D for ; 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 ) id 1ovlu9-0054mk-31; Thu, 17 Nov 2022 21:54:38 +0100 From: Ferry Toth To: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Heikki Krogerus , Greg Kroah-Hartman , Thinh Nguyen , Sean Anderson , Liu Shixin , Ferry Toth , Andrey Smirnov , Andy Shevchenko , stable@vger.kernel.org, Ferry Toth 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 X-Antivirus-Scanner: Clean mail though you should still use an Antivirus Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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 --- 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; }