[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <85c760b1-2279-44f9-8dac-77cbf6a4835b@nvidia.com>
Date: Tue, 13 Jan 2026 16:36:47 +0000
From: Jon Hunter <jonathanh@...dia.com>
To: Diogo Ivo <diogo.ivo@...nico.ulisboa.pt>,
Mathias Nyman <mathias.nyman@...el.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Thierry Reding <thierry.reding@...il.com>, JC Kuo <jckuo@...dia.com>,
Vinod Koul <vkoul@...nel.org>, Kishon Vijay Abraham I <kishon@...nel.org>,
Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>
Cc: linux-usb@...r.kernel.org, linux-tegra@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-phy@...ts.infradead.org,
devicetree@...r.kernel.org
Subject: Re: [PATCH 3/5] phy: tegra: xusb: Fix ordering issue when switching
roles on USB2 ports
On 13/01/2026 15:10, Diogo Ivo wrote:
...
>>>>> - 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;
>>>>> + role = USB_ROLE_HOST;
>>>>> + }
>>>>> +
>>>>> + mutex_lock(&tegra->lock);
>>>>> + phy_set_mode_ext(phy, PHY_MODE_USB_OTG, role);
>>>>> mutex_unlock(&tegra->lock);
>>>>
>>>> I am trying to understand why you opted to implement it this way
>>>> around and not add the wait loop after setting to the mode to
>>>> USB_ROLE_NONE in the original code all within the context of the mutex?
>>>
>>> I did that to minimize the amount of time we wait while holding the
>>> mutex, as we can now possibly wait a significant amount of time for the
>>> role switch. Is this an unneccessary optimization?
>>
>> Do you mean it will be longer than a few 100us?
>
> Currently the worst case in wait_role_none() is around 300us but again
> this is simply because I chose the values with no criteria except that
> in my testing they have worked thus far. Do you have access to any
> internal documentation where the transition length is documented?
>
> In any case I think that the underlying principle of minimizing the time
> we hold the mutex is solid, no?
Yes, but it was unclear to me if there could be a case where we are
waiting for USB_ROLE_NONE but we have already transitioned to host. May
be that will never happen, but it was not clear.
Jon
--
nvpublic
Powered by blists - more mailing lists