lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <54afff11-df9b-4c25-bd1d-8134196ce093@tecnico.ulisboa.pt>
Date: Tue, 13 Jan 2026 13:59:01 +0000
From: Diogo Ivo <diogo.ivo@...nico.ulisboa.pt>
To: Jon Hunter <jonathanh@...dia.com>, 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 2/5] phy: tegra: xusb: Fix USB2 port regulator disable
 logic



On 1/13/26 12:01, Jon Hunter wrote:
> 
> On 04/12/2025 21:27, Diogo Ivo wrote:
>> 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 <diogo.ivo@...nico.ulisboa.pt>
>> ---
>>   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-tegra210.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 == USB_ROLE_HOST)
>>                   regulator_disable(port->supply);
>>               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,
>>           }
>>       }
>> +    port->role = submode;
>>       mutex_unlock(&padctl->lock);
>>       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;
>>   };
> 
> 
> A similar fix was made to the Tegra186 code by commit cefc1caee9dd 
> ("phy: tegra: xusb: Fix unbalanced regulator disable in UTMI PHY mode"). 
> Although the above looks simpler, I am wondering if we should make a 
> similar change to the Tegra210 code so that they both are implemented in 
> the same way?

Looking at cefc1caee9dd my approach leads to less changes but I do agree
that standardization benefits us here. However in that case I think we
can take it a step further and actually just have a single function
tegra_xusb_padctl_id_override() (and likewise for vbus_override() and
set_mode()) since they all seem to do the same thing in both platforms.

If not I can simply make this patch look like cefc1caee9dd. Let me know
what you think!

Diogo

> Jon

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ