From nobody Fri Dec 19 17:19:38 2025 Received: from smtp1.tecnico.ulisboa.pt (smtp1.tecnico.ulisboa.pt [193.136.128.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 509852FBDFF; Thu, 4 Dec 2025 21:37:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.136.128.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764884228; cv=none; b=WgcyfSFf+BEiHG7oyps7J4FVYrTO34BYQuQONf3MslN34xksZrwALvsz1D3XdEVYCEWVxB8Ft2Zrv/wFV5mNzVz+pz/K1Wj0SFGFzHtkkibYMaVOlVpjYImARnBwwl18+tFci3RwaWuiu9TAXllSGDvnfzGKuGezHUlhg9aR3eA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764884228; c=relaxed/simple; bh=7Bhceul0Djmy/FTqFXQ8yH/nOs3uT2cr4R1ec8CPF5U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GKmCT1EgHdId6KnCSrsVIVJ1/NMx2wwxwu65j8JXBfEE+UOzzcKCfk/EUS5GiKfHHLjTyCzbgRiL7pE21sEksWoB51SAqb2171DQdxMvhvW63dvSE7cty9G+3vCRx73lJClHHkbeUi44qe6navmEbvw5JSdF9jk6MdIbFTLF5fI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tecnico.ulisboa.pt; spf=pass smtp.mailfrom=tecnico.ulisboa.pt; dkim=pass (2048-bit key) header.d=tecnico.ulisboa.pt header.i=@tecnico.ulisboa.pt header.b=caq+uw9w; arc=none smtp.client-ip=193.136.128.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tecnico.ulisboa.pt Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tecnico.ulisboa.pt Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tecnico.ulisboa.pt header.i=@tecnico.ulisboa.pt header.b="caq+uw9w" Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp1.tecnico.ulisboa.pt (Postfix) with ESMTP id 636D26007C0E; Thu, 4 Dec 2025 21:27:30 +0000 (WET) X-Virus-Scanned: by amavis-2.13.0 (20230106) (Debian) at tecnico.ulisboa.pt Received: from smtp1.tecnico.ulisboa.pt ([127.0.0.1]) by localhost (smtp1.tecnico.ulisboa.pt [127.0.0.1]) (amavis, port 10025) with LMTP id BGUSO3u_jN07; Thu, 4 Dec 2025 21:27:28 +0000 (WET) Received: from mail1.tecnico.ulisboa.pt (mail1.ist.utl.pt [IPv6:2001:690:2100:1::b3dd:b9ac]) by smtp1.tecnico.ulisboa.pt (Postfix) with ESMTPS id E1D0D6007C1A; Thu, 4 Dec 2025 21:27:25 +0000 (WET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tecnico.ulisboa.pt; s=mail2; t=1764883646; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i2xJ/PFmcIyGi2LSxLsJ2Rs5bQ0h4NEOjIa44Tuehhw=; b=caq+uw9wNmaYLrBjvqhTf7/lFDUe9ka5PtWeIlUrVyBZRPzqO1ZGVGONmW90vhOTs05ai9 VWJuGEz3e4P9WBw2C/r0pTi4Lo2QwyNWcNdB6qEKzULsY1KkKM4dHNJYOr/pKIfScQHMdc VLV/E1eHRACHg55Nm0phIWWkLVuaImKr+C2VF93JY+zc6CdASHVWBfCuUlxFJ1FdBjaThW tnXujGa92x5Gy5d+OAi7rnjJQ92cqhRqgMcAH0KScW+HVeGWKLzTUb8GBkCLjyFNQq6kCL DRv7Q+r63gQmfa2ONzwhWYOlXRw6h7Xbs60yopU7nHPlUccmR2hL4LrTLSfKuQ== Received: from [192.168.1.151] (unknown [IPv6:2001:8a0:57db:f00:3ee2:38aa:e2c9:7dde]) (Authenticated sender: ist187313) by mail1.tecnico.ulisboa.pt (Postfix) with ESMTPSA id B968436013A; Thu, 4 Dec 2025 21:27:25 +0000 (WET) From: Diogo Ivo Date: Thu, 04 Dec 2025 21:27:17 +0000 Subject: [PATCH 1/5] usb: host: tegra: Remove redundant pm_runtime_mark_last_busy() call Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251204-diogo-tegra_phy-v1-1-51a2016d0be8@tecnico.ulisboa.pt> References: <20251204-diogo-tegra_phy-v1-0-51a2016d0be8@tecnico.ulisboa.pt> In-Reply-To: <20251204-diogo-tegra_phy-v1-0-51a2016d0be8@tecnico.ulisboa.pt> To: Mathias Nyman , Greg Kroah-Hartman , Thierry Reding , Jonathan Hunter , JC Kuo , Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, Diogo Ivo X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1764883644; l=780; i=diogo.ivo@tecnico.ulisboa.pt; s=20240529; h=from:subject:message-id; bh=7Bhceul0Djmy/FTqFXQ8yH/nOs3uT2cr4R1ec8CPF5U=; b=MSFpWziUnBc/OPf/yhVMRKv6Ok/jVF90lG2n6xG4zPodbFDYWpxS6sqYuBVXaUgIVZHBYEOuu zcCx9l7YBjkBXgP/LpUKBo3mcNEBo57EXVFGdhxhMwKm+/I/7MbwEx8 X-Developer-Key: i=diogo.ivo@tecnico.ulisboa.pt; a=ed25519; pk=BRGXhMh1q5KDlZ9y2B8SodFFY8FGupal+NMtJPwRpUQ= As pm_runtime_put_autosuspend() called at the end of tegra_xhci_id_work() already calls pm_runtime_mark_last_busy() remove the prior redundant call. Signed-off-by: Diogo Ivo --- drivers/usb/host/xhci-tegra.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c index 5255b1002893..9c69fccdc6e8 100644 --- a/drivers/usb/host/xhci-tegra.c +++ b/drivers/usb/host/xhci-tegra.c @@ -1399,8 +1399,6 @@ static void tegra_xhci_id_work(struct work_struct *wo= rk) } =20 tegra_xhci_set_port_power(tegra, true, true); - pm_runtime_mark_last_busy(tegra->dev); - } else { if (tegra->otg_usb3_port >=3D 0) tegra_xhci_set_port_power(tegra, false, false); --=20 2.52.0 From nobody Fri Dec 19 17:19:38 2025 Received: from smtp2.tecnico.ulisboa.pt (smtp2.tecnico.ulisboa.pt [193.136.128.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35F7E307AF7; Thu, 4 Dec 2025 21:37:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.136.128.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764884242; cv=none; b=JERUuWWSYkl/gQEcJTnZ2EWLeDhA52Ta5CQg048KutNKDfbsccQUsn3ZfQz/kxUy6P5rnjGgLq6zcM10grTYF2OFdDLS69BGMhaWUUndfhnLiOC+yLbQamE93tFJwcl9d8NKzrI11QeMzLu3Qg4DL2GPwfrvyJdPPrTattHFKcE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764884242; c=relaxed/simple; bh=w6fVfOXdVz6LTWwtRSJOAjJ+BIeklHmzE7MoA8q2mpM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gAGd0/psLMQmdvRY4dntrrjBX6A26BYq4V2xgK72EajoTmjOvtx7YYlCrQRIQ93iT0/tbCipqzmQdfHGHOdCEnbNRZviJBQ7UjxtA03e3YUAHWoRIF2vx+vFOoN3eoMABVL7wQP4MtxvP9rQITGQbkjS3qx23u8SprOxxnbfbBY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tecnico.ulisboa.pt; spf=pass smtp.mailfrom=tecnico.ulisboa.pt; dkim=pass (2048-bit key) header.d=tecnico.ulisboa.pt header.i=@tecnico.ulisboa.pt header.b=ij9SJ9fB; arc=none smtp.client-ip=193.136.128.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tecnico.ulisboa.pt Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tecnico.ulisboa.pt Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tecnico.ulisboa.pt header.i=@tecnico.ulisboa.pt header.b="ij9SJ9fB" Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp2.tecnico.ulisboa.pt (Postfix) with ESMTP id 2B75D245442; Thu, 4 Dec 2025 21:27:30 +0000 (WET) X-Virus-Scanned: by amavis-2.13.0 (20230106) (Debian) at tecnico.ulisboa.pt Received: from smtp2.tecnico.ulisboa.pt ([127.0.0.1]) by localhost (smtp2.tecnico.ulisboa.pt [127.0.0.1]) (amavis, port 10025) with LMTP id 6OYoCyNrcuP8; Thu, 4 Dec 2025 21:27:28 +0000 (WET) Received: from mail1.tecnico.ulisboa.pt (mail1.ist.utl.pt [IPv6:2001:690:2100:1::b3dd:b9ac]) by smtp2.tecnico.ulisboa.pt (Postfix) with ESMTPS id 0C2732453F1; Thu, 4 Dec 2025 21:27:26 +0000 (WET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tecnico.ulisboa.pt; s=mail2; t=1764883646; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IYNRE9yHL8E4dpaM7LuZEB4UxBbEOcv5tHwJnXhtPMM=; b=ij9SJ9fB6tXPhCXQLw8bBGmTjBEKIQiIWzMhKVp5l4lR50m0xY67LpsrrYTY2uDw2lIBbM kEuyCt5X4u+xYNUYol89sNXqSrJL3FKHqjp2JpoVzARS+MN21LLrAZRhn+zgn2Hnvu++XW +SYnzdeSNdsfHUumh+xJRQZqlYnd4rybPBnPLRPLMDXhP9kNcanoNYRUR+IWY03xYgqWgC pkfpz3fWMO3UncGXLDTkzI4J3TFtHeOGlJsIy97LYcXB7xwYU90+oGWCraYv6wU26urbvF 7ev66hfUtENn3Ad+pkyXDLw20rEcoNk86jiA7IRrJgj9qkZdKVUbi8A6jd6uVw== Received: from [192.168.1.151] (unknown [IPv6:2001:8a0:57db:f00:3ee2:38aa:e2c9:7dde]) (Authenticated sender: ist187313) by mail1.tecnico.ulisboa.pt (Postfix) with ESMTPSA id D5B7A36013B; Thu, 4 Dec 2025 21:27:25 +0000 (WET) From: Diogo Ivo Date: Thu, 04 Dec 2025 21:27:18 +0000 Subject: [PATCH 2/5] phy: tegra: xusb: Fix USB2 port regulator disable logic Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251204-diogo-tegra_phy-v1-2-51a2016d0be8@tecnico.ulisboa.pt> References: <20251204-diogo-tegra_phy-v1-0-51a2016d0be8@tecnico.ulisboa.pt> In-Reply-To: <20251204-diogo-tegra_phy-v1-0-51a2016d0be8@tecnico.ulisboa.pt> To: Mathias Nyman , Greg Kroah-Hartman , Thierry Reding , Jonathan Hunter , JC Kuo , Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, Diogo Ivo X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1764883644; l=2313; i=diogo.ivo@tecnico.ulisboa.pt; s=20240529; h=from:subject:message-id; bh=w6fVfOXdVz6LTWwtRSJOAjJ+BIeklHmzE7MoA8q2mpM=; b=xRg0NMEvSnEuvWGJPw3JTgMP9jYi7exp/trncl53q53RM2rVrIznZUm7UPC1b3LqoqYoftvIh OiY87L+0dVSA29+4EHlRBBVYE9OAUut41cHcc7CpmyKFQCTGVkFqyWw X-Developer-Key: i=diogo.ivo@tecnico.ulisboa.pt; a=ed25519; pk=BRGXhMh1q5KDlZ9y2B8SodFFY8FGupal+NMtJPwRpUQ= The USB2 PHY mode handling on Tegra210 incorrectly relied on regulator_is_enabled() when determining whether the VBUS supply should be disabled during role changes. This is because regulator_is_enabled() reports exactly what is states and not if there is an unbalanced number of calls between regulator_enable() and regulator_disable(). For example, regulator_is_enabled() always reports true on a fixed-regulator with no enable gpio, which is the case on the Pixel C. This then leads to the PHY driver wrongfully calling regulator_disable() when transitioning from USB_ROLE_DEVICE to USB_ROLE_NONE since the driver did not previously call the corresponding regulator_enable(). Fix this by keeping track of the current role and updating the logic to disable the regulator only when the previous role was USB_ROLE_HOST. While at it fix a small typo in a comment. Signed-off-by: Diogo Ivo --- drivers/phy/tegra/xusb-tegra210.c | 5 +++-- drivers/phy/tegra/xusb.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/phy/tegra/xusb-tegra210.c b/drivers/phy/tegra/xusb-teg= ra210.c index 3409924498e9..63ad57d95514 100644 --- a/drivers/phy/tegra/xusb-tegra210.c +++ b/drivers/phy/tegra/xusb-tegra210.c @@ -1934,9 +1934,9 @@ static int tegra210_usb2_phy_set_mode(struct phy *phy= , enum phy_mode mode, /* * When port is peripheral only or role transitions to * USB_ROLE_NONE from USB_ROLE_DEVICE, regulator is not - * be enabled. + * enabled. */ - if (regulator_is_enabled(port->supply)) + if (port->role =3D=3D USB_ROLE_HOST) regulator_disable(port->supply); =20 tegra210_xusb_padctl_id_override(padctl, false); @@ -1944,6 +1944,7 @@ static int tegra210_usb2_phy_set_mode(struct phy *phy= , enum phy_mode mode, } } =20 + port->role =3D submode; mutex_unlock(&padctl->lock); =20 return err; diff --git a/drivers/phy/tegra/xusb.h b/drivers/phy/tegra/xusb.h index d2b5f9565132..273af147dfd3 100644 --- a/drivers/phy/tegra/xusb.h +++ b/drivers/phy/tegra/xusb.h @@ -317,6 +317,7 @@ struct tegra_xusb_usb2_port { enum usb_dr_mode mode; bool internal; int usb3_port_fake; + enum usb_role role; }; =20 static inline struct tegra_xusb_usb2_port * --=20 2.52.0 From nobody Fri Dec 19 17:19:38 2025 Received: from smtp1.tecnico.ulisboa.pt (smtp1.tecnico.ulisboa.pt [193.136.128.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 507CE272E56; Thu, 4 Dec 2025 21:37:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.136.128.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764884228; cv=none; b=jNPGM2lpKwHCXFZSfaM7rh49qhGnq4Exne/vdbQ7mqOgGivSRzit3BSEPvLRuT+QnHs6zaxPg8VP13RbFO1gzShvV5or+BFg+Utryy6l7xpMPNi6wNwhDmYFf7+ICnDLWlvAWrmX0TZEMeoz5X2R56V72dxLkorhKBFBeZhtZZ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764884228; c=relaxed/simple; bh=xf9W8khExmmglhR6CvPAqUspKha+T1FNlzX8AdCnkQg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lNZixVaW/0PIUA4uYeRDtT+0FK3ux/59ZfyrSa2Qe2/19eFalkDrUfh2UQJATkbdTjYSJ5ePlzEhm0/pMbFyCuCE8z3sCzpUXukwpR7Z/g2hzm/iAQvJpwl2DsX5RtIudsBOX+rba9R46+Mb7H6KLXAbOhbfdpbTL4FVlqDl8UQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tecnico.ulisboa.pt; spf=pass smtp.mailfrom=tecnico.ulisboa.pt; dkim=pass (2048-bit key) header.d=tecnico.ulisboa.pt header.i=@tecnico.ulisboa.pt header.b=TK9PQ+fq; arc=none smtp.client-ip=193.136.128.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tecnico.ulisboa.pt Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tecnico.ulisboa.pt Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tecnico.ulisboa.pt header.i=@tecnico.ulisboa.pt header.b="TK9PQ+fq" Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp1.tecnico.ulisboa.pt (Postfix) with ESMTP id 93A0C6007C12; Thu, 4 Dec 2025 21:27:30 +0000 (WET) X-Virus-Scanned: by amavis-2.13.0 (20230106) (Debian) at tecnico.ulisboa.pt Received: from smtp1.tecnico.ulisboa.pt ([127.0.0.1]) by localhost (smtp1.tecnico.ulisboa.pt [127.0.0.1]) (amavis, port 10025) with LMTP id r-KcAZ9WELtN; Thu, 4 Dec 2025 21:27:28 +0000 (WET) Received: from mail1.tecnico.ulisboa.pt (mail1.ist.utl.pt [193.136.128.10]) by smtp1.tecnico.ulisboa.pt (Postfix) with ESMTPS id 285216007C27; Thu, 4 Dec 2025 21:27:26 +0000 (WET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tecnico.ulisboa.pt; s=mail2; t=1764883646; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gws7bqKRyNKCnBdDeWO44Ug9p/AFQeyiuCwnVQuZ3wk=; b=TK9PQ+fqy2nXv1tk7PhT4zhyVoHMNwKwQHm2sl5asqJWaSlpZI96R11Q8p4SAx+/lZsWVL TvcrelBK7FtCGqJ5aEDCtzTwcmromNjXWP7XHrmmnGUc4VlytBigoVvMWcORtrtSWoiZ+P UDQ5uaxhzD8ugS7o3vfuLweqCVviyb2cfqVT0mABJ+RFV4OoePuBb8Vh1jmmuJV/0GS8Bt ytYSist3DiXaO0leJbS8MjXWUs48W0BHXu2/Q8B4kby4jvFj6XRDD03NCSdLMlu4g9Yd/e HX4o1tsnccODznC2ZJoFIyS55u86kmusyg6CvVPNHiv9pzHJlfSgmOyPuJZB2Q== Received: from [192.168.1.151] (unknown [IPv6:2001:8a0:57db:f00:3ee2:38aa:e2c9:7dde]) (Authenticated sender: ist187313) by mail1.tecnico.ulisboa.pt (Postfix) with ESMTPSA id 001E836013C; Thu, 4 Dec 2025 21:27:25 +0000 (WET) From: Diogo Ivo Date: Thu, 04 Dec 2025 21:27:19 +0000 Subject: [PATCH 3/5] phy: tegra: xusb: Fix ordering issue when switching roles on USB2 ports Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251204-diogo-tegra_phy-v1-3-51a2016d0be8@tecnico.ulisboa.pt> References: <20251204-diogo-tegra_phy-v1-0-51a2016d0be8@tecnico.ulisboa.pt> In-Reply-To: <20251204-diogo-tegra_phy-v1-0-51a2016d0be8@tecnico.ulisboa.pt> To: Mathias Nyman , Greg Kroah-Hartman , Thierry Reding , Jonathan Hunter , JC Kuo , Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, Diogo Ivo X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1764883644; l=4982; i=diogo.ivo@tecnico.ulisboa.pt; s=20240529; h=from:subject:message-id; bh=xf9W8khExmmglhR6CvPAqUspKha+T1FNlzX8AdCnkQg=; b=aQSppPE/K65eVVqVi1Ey+4rSDItbToDQShSiE2nBqNvkn3KPbsWhZVXUa9fVOUzkdsXDnS/Xd ygSs1457/IIC6VfJjPQFWDkQiKxUn++DiE89U/n761OxxibJyW4ousi X-Developer-Key: i=diogo.ivo@tecnico.ulisboa.pt; a=ed25519; pk=BRGXhMh1q5KDlZ9y2B8SodFFY8FGupal+NMtJPwRpUQ= The current implementation of USB2 role switching on Tegra relies on whichever the previous USB controller driver was using the PHY to first "yield" it back to USB_ROLE_NONE before the next controller configures it for the new role. However, no mechanism to guarantee this ordering was implemented, and currently, in the general case, the configuration functions tegra_xhci_id_work() and tegra_xudc_usb_role_sw_work() end up running in the same order regardless of the transition being HOST->DEVICE or DEVICE->HOST, leading to one of these transitions ending up in a non-working state due to the new configuration being clobbered by the previous controller driver setting USB_ROLE_NONE after the fact. Fix this by introducing a helper that waits for the USB2 port=E2=80=99s cur= rent role to become USB_ROLE_NONE and add it in the configuration functions above before setting the role to either USB_ROLE_HOST or USB_ROLE_DEVICE. The specific parameters of the helper function are choices that seem reasonable in my testing and have no other basis. This was tested on a Tegra210 platform (Smaug). However, due to the similar approach in Tegra186 it is likely that not only this problem exists there but that this patch also fixes it. Signed-off-by: Diogo Ivo --- drivers/phy/tegra/xusb.c | 23 +++++++++++++++++++++++ drivers/usb/gadget/udc/tegra-xudc.c | 4 ++++ drivers/usb/host/xhci-tegra.c | 15 ++++++++++----- include/linux/phy/tegra/xusb.h | 1 + 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c index c89df95aa6ca..e05c3f2d1421 100644 --- a/drivers/phy/tegra/xusb.c +++ b/drivers/phy/tegra/xusb.c @@ -740,6 +740,29 @@ static void tegra_xusb_parse_usb_role_default_mode(str= uct tegra_xusb_port *port) } } =20 +bool tegra_xusb_usb2_port_wait_role_none(struct tegra_xusb_padctl *padctl,= int index) +{ + struct tegra_xusb_usb2_port *usb2 =3D tegra_xusb_find_usb2_port(padctl, + index); + int retries =3D 5; + + if (!usb2) { + dev_err(&usb2->base.dev, "no port found for USB2 lane %u\n", index); + return false; + } + + do { + if (usb2->role =3D=3D USB_ROLE_NONE) + return true; + + usleep_range(50, 60); + } while (retries--); + + dev_err(&usb2->base.dev, "timed out waiting for USB_ROLE_NONE"); + + return false; +} + static int tegra_xusb_usb2_port_parse_dt(struct tegra_xusb_usb2_port *usb2) { struct tegra_xusb_port *port =3D &usb2->base; diff --git a/drivers/usb/gadget/udc/tegra-xudc.c b/drivers/usb/gadget/udc/t= egra-xudc.c index 0c38fc37b6e6..72d725659e5f 100644 --- a/drivers/usb/gadget/udc/tegra-xudc.c +++ b/drivers/usb/gadget/udc/tegra-xudc.c @@ -698,8 +698,12 @@ static void tegra_xudc_restore_port_speed(struct tegra= _xudc *xudc) =20 static void tegra_xudc_device_mode_on(struct tegra_xudc *xudc) { + int port =3D tegra_xusb_padctl_get_port_number(xudc->curr_utmi_phy); int err; =20 + if (!tegra_xusb_usb2_port_wait_role_none(xudc->padctl, port)) + return; + pm_runtime_get_sync(xudc->dev); =20 tegra_phy_xusb_utmi_pad_power_on(xudc->curr_utmi_phy); diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c index 9c69fccdc6e8..9944593166a3 100644 --- a/drivers/usb/host/xhci-tegra.c +++ b/drivers/usb/host/xhci-tegra.c @@ -1352,18 +1352,23 @@ static void tegra_xhci_id_work(struct work_struct *= work) struct tegra_xusb_mbox_msg msg; struct phy *phy =3D tegra_xusb_get_phy(tegra, "usb2", tegra->otg_usb2_port); + enum usb_role role =3D USB_ROLE_NONE; u32 status; int ret; =20 dev_dbg(tegra->dev, "host mode %s\n", str_on_off(tegra->host_mode)); =20 - mutex_lock(&tegra->lock); =20 - if (tegra->host_mode) - phy_set_mode_ext(phy, PHY_MODE_USB_OTG, USB_ROLE_HOST); - else - phy_set_mode_ext(phy, PHY_MODE_USB_OTG, USB_ROLE_NONE); + if (tegra->host_mode) { + if (!tegra_xusb_usb2_port_wait_role_none(tegra->padctl, + tegra->otg_usb2_port)) + return; =20 + role =3D USB_ROLE_HOST; + } + + mutex_lock(&tegra->lock); + phy_set_mode_ext(phy, PHY_MODE_USB_OTG, role); mutex_unlock(&tegra->lock); =20 tegra->otg_usb3_port =3D tegra_xusb_padctl_get_usb3_companion(tegra->padc= tl, diff --git a/include/linux/phy/tegra/xusb.h b/include/linux/phy/tegra/xusb.h index 6ca51e0080ec..a0d3d5b7cf33 100644 --- a/include/linux/phy/tegra/xusb.h +++ b/include/linux/phy/tegra/xusb.h @@ -33,5 +33,6 @@ int tegra_xusb_padctl_disable_phy_sleepwalk(struct tegra_= xusb_padctl *padctl, st int tegra_xusb_padctl_enable_phy_wake(struct tegra_xusb_padctl *padctl, st= ruct phy *phy); int tegra_xusb_padctl_disable_phy_wake(struct tegra_xusb_padctl *padctl, s= truct phy *phy); bool tegra_xusb_padctl_remote_wake_detected(struct tegra_xusb_padctl *padc= tl, struct phy *phy); +bool tegra_xusb_usb2_port_wait_role_none(struct tegra_xusb_padctl *padctl,= int index); =20 #endif /* PHY_TEGRA_XUSB_H */ --=20 2.52.0 From nobody Fri Dec 19 17:19:38 2025 Received: from smtp1.tecnico.ulisboa.pt (smtp1.tecnico.ulisboa.pt [193.136.128.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5086429B8E8; Thu, 4 Dec 2025 21:37:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.136.128.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764884229; cv=none; b=jl1WkbkhlVQrse89XUJUE+UXnkYMNaZtUBOylZ1pjjhb9TKQs91zBMtisqqiaD8S+aNe5pK/R81Y2RJwUaZ6wHQuVrVqqYzLEd9J+GOv6ns6fdyex1kbdVRS9yMyjpoYjbz9wqgwm0n21CAo5qcXDCDFiBKqZ/QgjhzUUFnayEw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764884229; c=relaxed/simple; bh=sfqv4Sr+OMnIY9gPi8e20yGHX5crm0dHFpzYIkqQThU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nVYXLK7N2xBRolZrwvyA7s/WY5ZXm9AzxLiVGAg1bNimVBDYNaz/wOwFPpO17XLiQM2JVTjGkl/uz7L098K+SUTJRPg5u+ID/K8znRnFGllU5qpAwv93HS+DYptsC+LIq+U7ZIfWcC4Bg6y4qecs4r/Ckcafi/8tex3hrxK57Ak= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tecnico.ulisboa.pt; spf=pass smtp.mailfrom=tecnico.ulisboa.pt; dkim=pass (2048-bit key) header.d=tecnico.ulisboa.pt header.i=@tecnico.ulisboa.pt header.b=bjzMUT0d; arc=none smtp.client-ip=193.136.128.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tecnico.ulisboa.pt Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tecnico.ulisboa.pt Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tecnico.ulisboa.pt header.i=@tecnico.ulisboa.pt header.b="bjzMUT0d" Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp1.tecnico.ulisboa.pt (Postfix) with ESMTP id 751846007C07; Thu, 4 Dec 2025 21:27:30 +0000 (WET) X-Virus-Scanned: by amavis-2.13.0 (20230106) (Debian) at tecnico.ulisboa.pt Received: from smtp1.tecnico.ulisboa.pt ([127.0.0.1]) by localhost (smtp1.tecnico.ulisboa.pt [127.0.0.1]) (amavis, port 10025) with LMTP id LtbYQ1UNms0M; Thu, 4 Dec 2025 21:27:28 +0000 (WET) Received: from mail1.tecnico.ulisboa.pt (mail1.ist.utl.pt [193.136.128.10]) by smtp1.tecnico.ulisboa.pt (Postfix) with ESMTPS id 4C6BE6007C2A; Thu, 4 Dec 2025 21:27:26 +0000 (WET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tecnico.ulisboa.pt; s=mail2; t=1764883646; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aM83Mw77rc4YXSunFcfwV7YHy4i8gIDVF0RJQ/BhVzk=; b=bjzMUT0dNT9EyFzPJm70pDW9tN/aT9KJ5QlvIf+ZKkIgHyFlLWFUtVf/WvvrQkk1jGJxYi kZJln2MBCPT4EhTipG4fsOCUaQlqmm5R4ofkkxfhTpq0257GJhxhiAXRDDhGn6JCZpA0Mh uzqxeoMSkh6OSkrDpdYbz86SJPBKVOLE2YdG3UHuf4hlewMVWITcFRDo/LC6m5u1a9crh3 X5blxrCsLBZXNO45VptaSXF+PaHwe2GgqTwgK1RE+Ng+BEtZf9FT/EY0L9WfRGsftzR2/b WxknAPxD/mwg2LhTPk5MIn2pym/wCxAW05KPbijoIwPPYMj+1YdDWlBAiUstHQ== Received: from [192.168.1.151] (unknown [IPv6:2001:8a0:57db:f00:3ee2:38aa:e2c9:7dde]) (Authenticated sender: ist187313) by mail1.tecnico.ulisboa.pt (Postfix) with ESMTPSA id 1DCF336013D; Thu, 4 Dec 2025 21:27:26 +0000 (WET) From: Diogo Ivo Date: Thu, 04 Dec 2025 21:27:20 +0000 Subject: [PATCH 4/5] arm64: tegra: smaug: Complete and enable tegra-udc node Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251204-diogo-tegra_phy-v1-4-51a2016d0be8@tecnico.ulisboa.pt> References: <20251204-diogo-tegra_phy-v1-0-51a2016d0be8@tecnico.ulisboa.pt> In-Reply-To: <20251204-diogo-tegra_phy-v1-0-51a2016d0be8@tecnico.ulisboa.pt> To: Mathias Nyman , Greg Kroah-Hartman , Thierry Reding , Jonathan Hunter , JC Kuo , Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, Diogo Ivo X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1764883644; l=925; i=diogo.ivo@tecnico.ulisboa.pt; s=20240529; h=from:subject:message-id; bh=sfqv4Sr+OMnIY9gPi8e20yGHX5crm0dHFpzYIkqQThU=; b=BnvupjdKsXMIGOQCbH1KdJqWRnJzGtzyBQhBhW5BNYfMdgIF5DCTYTD+y1ag5U/rOm+mlLqyl AJrDL5z+BbNADkNyhq8HkkWwDr5sSqY+TsGyLKDTpY+Ss7c1gvwnNFF X-Developer-Key: i=diogo.ivo@tecnico.ulisboa.pt; a=ed25519; pk=BRGXhMh1q5KDlZ9y2B8SodFFY8FGupal+NMtJPwRpUQ= Complete the missing properties in the tegra-udc node and enable it for Smaug. Signed-off-by: Diogo Ivo --- arch/arm64/boot/dts/nvidia/tegra210-smaug.dts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/arm64/boot/dts/nvidia/tegra210-smaug.dts b/arch/arm64/boo= t/dts/nvidia/tegra210-smaug.dts index 5aa6afd56cbc..b8d854f90be7 100644 --- a/arch/arm64/boot/dts/nvidia/tegra210-smaug.dts +++ b/arch/arm64/boot/dts/nvidia/tegra210-smaug.dts @@ -1843,6 +1843,17 @@ mmc@700b0600 { status =3D "okay"; }; =20 + usb@700d0000 { + phys =3D <&{/padctl@7009f000/pads/usb2/lanes/usb2-0}>, + <&{/padctl@7009f000/pads/pcie/lanes/pcie-6}>; + phy-names =3D "usb2-0", "usb3-0"; + + avddio-usb-supply =3D <&avddio_1v05>; + hvdd-usb-supply =3D <&pp3300>; + + status =3D "okay"; + }; + clock@70110000 { status =3D "okay"; nvidia,cf =3D <6>; --=20 2.52.0 From nobody Fri Dec 19 17:19:38 2025 Received: from smtp1.tecnico.ulisboa.pt (smtp1.tecnico.ulisboa.pt [193.136.128.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C5A71E22E9; Thu, 4 Dec 2025 21:37:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.136.128.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764884229; cv=none; b=sroN8yrjNYBoHsccrEyxsu6UDrrbj9lfUh4Twd/yBiovgtjxogrpB92ZxIaEhJiHoAe1e36Xgj9zO8zbIyktmvGF0OWjAsO1NPlP3ixaJMI2IvwyLnPy+qkHE+ko0ADWXg1xJbEOC7k2pp4AAvcZ74YWVZZmwiaPGwpYcnRbHVk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764884229; c=relaxed/simple; bh=k5kseAlh5a9PKK6R0Ldzp853p/wTGU015EJUvqBOXS8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DNMuVCdUhmWOo+QpWn71exGNH34XdiajJ2c8skQzwNEPHFq+Rqaumv7WgPhSFjA+hcuMT3MhkzYHopy7VLexW2pMjAMs8NQ0ewcVOk1c/h2fIvONVvN32/QCssWhCH+9BR6hAuryZymXy9o3Uy04vWvG9bcHyL0uz2IGCi5iWBM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tecnico.ulisboa.pt; spf=pass smtp.mailfrom=tecnico.ulisboa.pt; dkim=pass (2048-bit key) header.d=tecnico.ulisboa.pt header.i=@tecnico.ulisboa.pt header.b=pUrFTV2I; arc=none smtp.client-ip=193.136.128.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tecnico.ulisboa.pt Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tecnico.ulisboa.pt Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tecnico.ulisboa.pt header.i=@tecnico.ulisboa.pt header.b="pUrFTV2I" Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp1.tecnico.ulisboa.pt (Postfix) with ESMTP id AC2E76007C1A; Thu, 4 Dec 2025 21:27:30 +0000 (WET) X-Virus-Scanned: by amavis-2.13.0 (20230106) (Debian) at tecnico.ulisboa.pt Received: from smtp1.tecnico.ulisboa.pt ([127.0.0.1]) by localhost (smtp1.tecnico.ulisboa.pt [127.0.0.1]) (amavis, port 10025) with LMTP id XNRBWlhjOxY5; Thu, 4 Dec 2025 21:27:28 +0000 (WET) Received: from mail1.tecnico.ulisboa.pt (mail1.ist.utl.pt [193.136.128.10]) by smtp1.tecnico.ulisboa.pt (Postfix) with ESMTPS id 0CEF46007C2B; Thu, 4 Dec 2025 21:27:28 +0000 (WET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tecnico.ulisboa.pt; s=mail2; t=1764883648; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ju0IKFzoz63GeJ4sByij1Pot+ZusvvtRcKzP/L0CthY=; b=pUrFTV2IU+7vUAWpptYhfZS68J9pG50NogQCK9iP6QyiMIOs2FTbqL1KJz3OeeIGWS/Sdg SAJkQ6dEvXMpcSDZLOCMkaBO8L1zH1kmKCFbuWGeeityWIlzS3SlmQPgok813lk2MAgtjG pp5VYhHFDfVXvfcLrkx4m3OaSJ6LYQs63uQQSCUlz0+jar16lMWjEjEHl7sRyuWGLf6pJ6 ckgq+zbzepcOcQAEYX3w9wE3x3t3zaJW9qmo8Dfbv5+ioYGfLdoOPD/gsuyBACL9FSoABD 28gAriKHQZhfSbIVWXvTN0/gHry2X2OnFc+dR+r3U+xGoMxsNd3eiM3qet+G3w== Received: from [192.168.1.151] (unknown [IPv6:2001:8a0:57db:f00:3ee2:38aa:e2c9:7dde]) (Authenticated sender: ist187313) by mail1.tecnico.ulisboa.pt (Postfix) with ESMTPSA id 3A76A36013E; Thu, 4 Dec 2025 21:27:26 +0000 (WET) From: Diogo Ivo Date: Thu, 04 Dec 2025 21:27:21 +0000 Subject: [PATCH 5/5] arm64: tegra: smaug: Add usb-role-switch support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251204-diogo-tegra_phy-v1-5-51a2016d0be8@tecnico.ulisboa.pt> References: <20251204-diogo-tegra_phy-v1-0-51a2016d0be8@tecnico.ulisboa.pt> In-Reply-To: <20251204-diogo-tegra_phy-v1-0-51a2016d0be8@tecnico.ulisboa.pt> To: Mathias Nyman , Greg Kroah-Hartman , Thierry Reding , Jonathan Hunter , JC Kuo , Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, Diogo Ivo X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1764883644; l=854; i=diogo.ivo@tecnico.ulisboa.pt; s=20240529; h=from:subject:message-id; bh=k5kseAlh5a9PKK6R0Ldzp853p/wTGU015EJUvqBOXS8=; b=28zNziToJmNiz0XMrWNVpPoY4soMnfoxl9fgEfUGM+2G4OrGSzVb5cQqeu0zyGk2adkYiprkF 5WxkvW2G82XBStGxypKDOifVbDOfcxsPQ5O59/Ezu6ZXDxzox7QSLBE X-Developer-Key: i=diogo.ivo@tecnico.ulisboa.pt; a=ed25519; pk=BRGXhMh1q5KDlZ9y2B8SodFFY8FGupal+NMtJPwRpUQ= The USB2 port on Smaug is configured for OTG operation but lacked the required 'usb-role-switch' property, leading to a failed probe and a non-functioning USB port. Add the property along with setting the default role to host. Signed-off-by: Diogo Ivo --- arch/arm64/boot/dts/nvidia/tegra210-smaug.dts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/boot/dts/nvidia/tegra210-smaug.dts b/arch/arm64/boo= t/dts/nvidia/tegra210-smaug.dts index b8d854f90be7..49bf23d6f593 100644 --- a/arch/arm64/boot/dts/nvidia/tegra210-smaug.dts +++ b/arch/arm64/boot/dts/nvidia/tegra210-smaug.dts @@ -1809,6 +1809,8 @@ usb2-0 { status =3D "okay"; vbus-supply =3D <&usbc_vbus>; mode =3D "otg"; + usb-role-switch; + role-switch-default-mode =3D "host"; }; =20 usb3-0 { --=20 2.52.0