From patchwork Thu Nov 10 21:11:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferry Toth X-Patchwork-Id: 13039352 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 8B720C433FE for ; Thu, 10 Nov 2022 21:12:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232095AbiKJVMK (ORCPT ); Thu, 10 Nov 2022 16:12:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231818AbiKJVMJ (ORCPT ); Thu, 10 Nov 2022 16:12:09 -0500 Received: from mailfilter06-out40.webhostingserver.nl (mailfilter06-out40.webhostingserver.nl [195.211.73.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36352A1 for ; Thu, 10 Nov 2022 13:12:05 -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=cdesS2DQFWedzwuFw/fxWGknLLF3dzMaZQT1dpDtHwc=; b=caJy+WdUvdRTLCqJVb6LWi2k99CSVAX9qHeRm4DPOqprEfR3XiMiCBE5DIiNwZl8o5XFGSGeA6qC9 Eqp0ADROaIQLGDl3GrQIWo6MLEnpChexBXHJaALaxLkmeN0qvdWfYYmKQe2AyfzzE+BVLKHL2t3UUQ t+AVzLT/+l0RszEnu3EZ5XdbT+CUsQjztrk/oW2rToUEh/8MhxhqapOifrzqii+hrgg9A2Gm6RS9ME i+3iPpZTm1K/3Q0SlTdZ5ixIQzKbUVtaMe5/q28Xw7+CLwsVhWcTBKRa79HrAc+s2gsrLsBYKE6Vo4 PVEtjZOy53fYf/CM8oGguQKP1Vvh19A== X-Halon-ID: 5285229e-613c-11ed-837b-001a4a4cb958 Received: from s198.webhostingserver.nl (s198.webhostingserver.nl [141.138.168.154]) by mailfilter06.webhostingserver.nl (Halon) with ESMTPSA id 5285229e-613c-11ed-837b-001a4a4cb958; Thu, 10 Nov 2022 22:12:03 +0100 (CET) Received: from 2a02-a466-68ed-1-7ff6-3899-7171-85b5.fixed6.kpn.net ([2a02:a466:68ed:1:7ff6:3899:7171:85b5] helo=delfion.fritz.box) by s198.webhostingserver.nl with esmtpa (Exim 4.96) (envelope-from ) id 1otEqA-005Dpg-28; Thu, 10 Nov 2022 22:12:02 +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 , Ferry Toth Subject: [PATCH v2 1/2] usb: ulpi: defer ulpi_register on ulpi_read_id timeout Date: Thu, 10 Nov 2022 22:11:31 +0100 Message-Id: <20221110211132.297512-2-ftoth@exalondelft.nl> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221110211132.297512-1-ftoth@exalondelft.nl> References: <20221110211132.297512-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 Reviewed-by: Stephen Boyd --- 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 10 21:11:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferry Toth X-Patchwork-Id: 13039354 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 A2EBEC433FE for ; Thu, 10 Nov 2022 21:13:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232343AbiKJVNp (ORCPT ); Thu, 10 Nov 2022 16:13:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232260AbiKJVNV (ORCPT ); Thu, 10 Nov 2022 16:13:21 -0500 Received: from mailfilter05-out40.webhostingserver.nl (mailfilter05-out40.webhostingserver.nl [195.211.74.36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A39C35D6A1 for ; Thu, 10 Nov 2022 13:13:16 -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=A4MtRV/Oz/92ZR5qGyeTjm00+NMx36cJ5lbhoagSP70=; b=Mv7dlS1SmB5BpnCMLPauvzc5SGhClRH8tqUa1YhqKZsA9nFJTZk6I5VX/EcvmTFDsEo9BBEAiC+sB eCjKeZr8JwGdRLXgtoDNe6HSZFOxP9bjE8BAobx94xsx5KJV0dnPAFnEp90Xd2snK4xRdBWL3tRBH4 XHj3yDb3ahhc8f3UTUhA8uqvDKG+wQHnIox56svGnnPmGOTyuwQBAgjltW96d0LP7R6tEdS0luUeFZ SSzeqipG02o+WRR+ZoE/vZ7oitBhMTlxjkHRb8eGO1urOXGY24CF7Z1CHoaHHo4u4YO5POtlF1bcn8 yKtsUCgu0viJsXgB4oRgSk/Rfx+pJmg== X-Halon-ID: 580cd1a3-613c-11ed-9686-001a4a4cb933 Received: from s198.webhostingserver.nl (s198.webhostingserver.nl [141.138.168.154]) by mailfilter05.webhostingserver.nl (Halon) with ESMTPSA id 580cd1a3-613c-11ed-9686-001a4a4cb933; Thu, 10 Nov 2022 22:12:12 +0100 (CET) Received: from 2a02-a466-68ed-1-7ff6-3899-7171-85b5.fixed6.kpn.net ([2a02:a466:68ed:1:7ff6:3899:7171:85b5] helo=delfion.fritz.box) by s198.webhostingserver.nl with esmtpa (Exim 4.96) (envelope-from ) id 1otEqJ-005Dpg-3B; Thu, 10 Nov 2022 22:12:12 +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 , Ferry Toth Subject: [PATCH v2 2/2] usb: dwc3: core: defer probe on ulpi_read_id timeout Date: Thu, 10 Nov 2022 22:11:32 +0100 Message-Id: <20221110211132.297512-3-ftoth@exalondelft.nl> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221110211132.297512-1-ftoth@exalondelft.nl> References: <20221110211132.297512-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; }