From patchwork Wed Nov 9 22:17:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferry Toth X-Patchwork-Id: 17855 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp592293wru; Wed, 9 Nov 2022 14:24:15 -0800 (PST) X-Google-Smtp-Source: AMsMyM6fwTrmIig0irT1EsWAQBYYE1CxRH9kM2tHDQLm3ChoMFLkLeP2xHNM4HlFBmGDv4z72Jbq X-Received: by 2002:a17:90a:2f03:b0:213:c57c:f062 with SMTP id s3-20020a17090a2f0300b00213c57cf062mr58575354pjd.35.1668032655232; Wed, 09 Nov 2022 14:24:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668032655; cv=none; d=google.com; s=arc-20160816; b=EKxYcEP+sCNtwvHnrBAqDmTq1HFH3okenKxXFMTGvycZbcNPx7FIwy3Yo1MuPfnyKT RE2AFj+MqJL2Pqi737QycdUxKOqyto7oS1po+JKMLEBFdsMgiwv0rkRhO2mEHTrzkr+z Z5qbmo8kgEkfEychUIJLMArEjPIgZi5fYc05jeH5L94Usf7arNo6eojPusCM3ON4v6dF BHzQiSohZ/lqhaFZbS8v49EzeowG9dqmUsyF8fOdPr8QLUnZufu4dPa+wouTafGeQlNG xQwBBJZ+ctmkd3fE6XEQJdaG31ohBi3VFFPoHjta9ot9JujGPI9nBYG5SlRlNAXcGTda CVkA== 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:dkim-signature; bh=BwQD9pj5b/WWSsnWxPYCsQ/PgXjWas3i27VLj8Y6Clc=; b=EgiA2MBCF+C6cSvuwbX5hH0H2cZuErUGvs1ijZZx2q2gRD4K6wMtCukJq92MwtAOfd sD1mxMycgwCBc2ILf0nB58Dgfk9mtjKtgqGXq0N+V3vGOHRV/NjTbOuF3t5UlXJZPcvi 6ScRBCwKe3VXE72s2dZLcz8XZfHqIlpEiet91aeWC9eWeKy5r6Yl8hQl5XFzWc7Ul81C VMy5XjjUafG/glaUxoA4cNQyux+tg16vB8Qnof7lbqDDX4IB1HMZ1rYbtyoPXk1xXF51 4eZlEEQh1HlQfKAL+YJjSQJTP7LOujKH/ClkHFDYIJrD3T7t5jEG+i4e1x8Y/zia9rIz fT4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@exalondelft.nl header.s=whs1 header.b="ZkY8uv6/"; 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 f4-20020a635104000000b0043ac3ec9d9esi19324194pgb.595.2022.11.09.14.24.01; Wed, 09 Nov 2022 14:24:15 -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="ZkY8uv6/"; 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 S230262AbiKIWUE (ORCPT + 99 others); Wed, 9 Nov 2022 17:20:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229784AbiKIWUC (ORCPT ); Wed, 9 Nov 2022 17:20:02 -0500 X-Greylist: delayed 61 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 09 Nov 2022 14:19:59 PST Received: from mailfilter06-out40.webhostingserver.nl (mailfilter06-out40.webhostingserver.nl [195.211.73.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC4BAF03D for ; Wed, 9 Nov 2022 14:19:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=exalondelft.nl; s=whs1; h=content-transfer-encoding:mime-version:message-id:date:subject:cc:to:from: from; bh=BwQD9pj5b/WWSsnWxPYCsQ/PgXjWas3i27VLj8Y6Clc=; b=ZkY8uv6/hN9/FoAwFfXnWm4GMQg7cJ1jSyMvQ7tJ+ilUOB7nPzqBfUU8u/Z2Snwf1/rbGnOPQvmRA x4K23/yrAMk6SoyyKB9dEolvHKnk0AHgF6bWTNPXFG7pjTfsyiyxWMOOec/B9KdKGtY+3oUTBdEQN0 NSAp+DGOdSRPl3ctQAjzhVRqft37d73lqpX5/3cyuq1oTGW+JOPllcQb0MmM1CVOW9WZBJR2IFirVm aYBgmvkm/Low6Sf6QtTClCfZILKJWtJ+0ZmOqaPC/UQhOy0vULvq7pXS4KY/5Xn4b6sfod+Rhjgrdo HR8ICGNM9BzzHnCac3HStBcVZzQ+2rw== X-Halon-ID: 7f4b7a72-607c-11ed-837b-001a4a4cb958 Received: from s198.webhostingserver.nl (s198.webhostingserver.nl [141.138.168.154]) by mailfilter06.webhostingserver.nl (Halon) with ESMTPSA id 7f4b7a72-607c-11ed-837b-001a4a4cb958; Wed, 09 Nov 2022 23:18:54 +0100 (CET) Received: from 2a02-a466-68ed-1-6127-ee99-b8c1-12c4.fixed6.kpn.net ([2a02:a466:68ed:1:6127:ee99:b8c1:12c4] helo=localhost.localdomain) by s198.webhostingserver.nl with esmtpa (Exim 4.96) (envelope-from ) id 1ostPK-002HIn-0s; Wed, 09 Nov 2022 23:18:54 +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 , Stephen Boyd , Andrey Smirnov , Andy Shevchenko , Ferry Toth Subject: [PATCH v1 1/1] usb: ulpi: defer ulpi_register on ulpi_read_id timeout Date: Wed, 9 Nov 2022 23:17:49 +0100 Message-Id: <20221109221749.8210-1-ftoth@exalondelft.nl> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 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=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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749059009417227040?= X-GMAIL-MSGID: =?utf-8?q?1749059009417227040?= 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. Due to the timeout being masked dwc3 probe continues by calling dwc3_core_soft_reset() followed by dwc3_get_extcon() which happens to return -EPROBE_DEFER. On deferred probe ulpi_read_id() finally succeeds. This patch changes ulpi_read_id() to return -ETIMEDOUT when it occurs and catches the error in dwc3_core_init(). It handles the error by calling dwc3_core_soft_reset() after which it requests -EPROBE_DEFER. On deferred probe ulpi_read_id() again succeeds. Signed-off-by: Ferry Toth --- drivers/usb/common/ulpi.c | 5 +++-- drivers/usb/dwc3/core.c | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c index d7c8461976ce..d8f22bc2f9d0 100644 --- a/drivers/usb/common/ulpi.c +++ b/drivers/usb/common/ulpi.c @@ -206,8 +206,9 @@ static int ulpi_read_id(struct ulpi *ulpi) /* Test the interface */ ret = ulpi_write(ulpi, ULPI_SCRATCH, 0xaa); - if (ret < 0) - goto err; + if (ret < 0) { + return ret; + } ret = ulpi_read(ulpi, ULPI_SCRATCH); if (ret < 0) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 648f1c570021..e293ef70039b 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1106,8 +1106,11 @@ static int dwc3_core_init(struct dwc3 *dwc) if (!dwc->ulpi_ready) { ret = dwc3_core_ulpi_init(dwc); - if (ret) + if (ret) { + dwc3_core_soft_reset(dwc); + ret = -EPROBE_DEFER; goto err0; + } dwc->ulpi_ready = true; }