From: Jon Hunter <jonathanh@nvidia.com>
To: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt>,
Mathias Nyman <mathias.nyman@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Thierry Reding <thierry.reding@gmail.com>,
JC Kuo <jckuo@nvidia.com>, Vinod Koul <vkoul@kernel.org>,
Kishon Vijay Abraham I <kishon@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>
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
Subject: Re: [PATCH 3/5] phy: tegra: xusb: Fix ordering issue when switching roles on USB2 ports
Date: Tue, 13 Jan 2026 11:44:51 +0000 [thread overview]
Message-ID: <6a0d379f-d215-4efc-bdd0-c9a74d31614a@nvidia.com> (raw)
In-Reply-To: <e9f18b0d-6462-43e7-955f-45337914b321@nvidia.com>
On 13/01/2026 11:35, Jon Hunter wrote:
>
> On 04/12/2025 21:27, Diogo Ivo wrote:
>> 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’s current
>> 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 <diogo.ivo@tecnico.ulisboa.pt>
>> ---
>> 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(struct tegra_xusb_port *port)
>> }
>> }
>> +bool tegra_xusb_usb2_port_wait_role_none(struct tegra_xusb_padctl
>> *padctl, int index)
>> +{
>> + struct tegra_xusb_usb2_port *usb2 =
>> tegra_xusb_find_usb2_port(padctl,
>> + index);
>> + int retries = 5;
>> +
>> + if (!usb2) {
>> + dev_err(&usb2->base.dev, "no port found for USB2 lane %u\n",
>> index);
>> + return false;
>> + }
>> +
>> + do {
>> + if (usb2->role == 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;
>> +}
>
>
> This patch is causing the following build error today with -next ...
Sorry this is not in -next, I had just applied locally on top!
> MODPOST Module.symvers
> ERROR: modpost: "tegra_xusb_usb2_port_wait_role_none" [drivers/usb/host/
> xhci-tegra.ko] undefined!
>
> The above function symbol needs to be exported.
Nonetheless this needs to be fixed.
Jon
--
nvpublic
next prev parent reply other threads:[~2026-01-13 11:44 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-04 21:27 [PATCH 0/5] Fixes to Tegra USB role switching and Smaug USB role switching enablement Diogo Ivo
2025-12-04 21:27 ` [PATCH 1/5] usb: host: tegra: Remove redundant pm_runtime_mark_last_busy() call Diogo Ivo
2025-12-07 10:37 ` Diogo Ivo
2025-12-04 21:27 ` [PATCH 2/5] phy: tegra: xusb: Fix USB2 port regulator disable logic Diogo Ivo
2025-12-24 7:27 ` Vinod Koul
2026-01-13 13:30 ` Diogo Ivo
2026-01-13 12:01 ` Jon Hunter
2026-01-13 13:59 ` Diogo Ivo
2026-01-13 14:42 ` Jon Hunter
2026-01-13 15:05 ` Diogo Ivo
2025-12-04 21:27 ` [PATCH 3/5] phy: tegra: xusb: Fix ordering issue when switching roles on USB2 ports Diogo Ivo
2026-01-13 11:35 ` Jon Hunter
2026-01-13 11:44 ` Jon Hunter [this message]
2026-01-13 13:59 ` Diogo Ivo
2026-01-13 11:56 ` Jon Hunter
2026-01-13 14:05 ` Diogo Ivo
2026-01-13 14:48 ` Jon Hunter
2026-01-13 15:10 ` Diogo Ivo
2026-01-13 16:36 ` Jon Hunter
2026-01-15 11:06 ` Diogo Ivo
2026-01-19 14:31 ` Jon Hunter
2025-12-04 21:27 ` [PATCH 4/5] arm64: tegra: smaug: Complete and enable tegra-udc node Diogo Ivo
2025-12-04 21:27 ` [PATCH 5/5] arm64: tegra: smaug: Add usb-role-switch support Diogo Ivo
2026-01-12 22:03 ` Jon Hunter
2026-01-13 14:20 ` Diogo Ivo
2026-01-13 14:49 ` Jon Hunter
2026-01-13 15:11 ` Diogo Ivo
2025-12-05 22:36 ` [PATCH 0/5] Fixes to Tegra USB role switching and Smaug USB role switching enablement Rob Herring
2026-01-13 10:58 ` Jon Hunter
2026-01-12 13:46 ` Diogo Ivo
2026-01-17 0:25 ` (subset) " Thierry Reding
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6a0d379f-d215-4efc-bdd0-c9a74d31614a@nvidia.com \
--to=jonathanh@nvidia.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=diogo.ivo@tecnico.ulisboa.pt \
--cc=gregkh@linuxfoundation.org \
--cc=jckuo@nvidia.com \
--cc=kishon@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux-tegra@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
--cc=robh@kernel.org \
--cc=thierry.reding@gmail.com \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox