* [PATCH] soc/tegra: regulators: Fix locking up when voltage-spread is out of range in tegra20
@ 2025-09-06 10:50 Chen Yufeng
2026-01-22 6:04 ` Mikko Perttunen
0 siblings, 1 reply; 2+ messages in thread
From: Chen Yufeng @ 2025-09-06 10:50 UTC (permalink / raw)
To: thierry.reding; +Cc: jonathanh, linux-tegra, Chen Yufeng
This patch is similar to ef85bb582c41("soc/tegra: regulators: Fix
locking up when voltage-spread is out of range").
A potential deadlock issue exists in the voltage coupler code for
Tegra20 when the voltage spread (voltage-spread) goes out of range.
The code does not properly account for the maximum voltage spread
(max-spread) requirement when the CPU regulator has no consumers.
In the tegra20_cpu_voltage_update function, the voltage range is
not properly handled when there are no consumers:
```c
if (!cpu_min_uV_consumers)
cpu_min_uV = cpu_uV;
```
When there are no CPU consumers, cpu_min_uV is directly set to cpu_uV,
without considering the maximum voltage spread constraint.
The issue is resolved by introducing the max function to ensure that
cpu_min_uV is set to the greater value between cpu_uV and cpu_min_uV,
thereby preventing the voltage spread from exceeding the limit:
```c
if (!cpu_min_uV_consumers)
cpu_min_uV = max(cpu_uV, cpu_min_uV);
```
Signed-off-by: Chen Yufeng <chenyufeng@iie.ac.cn>
---
drivers/soc/tegra/regulators-tegra20.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/soc/tegra/regulators-tegra20.c b/drivers/soc/tegra/regulators-tegra20.c
index 6a2f90ab9d3e..48c29b89fa59 100644
--- a/drivers/soc/tegra/regulators-tegra20.c
+++ b/drivers/soc/tegra/regulators-tegra20.c
@@ -305,7 +305,7 @@ static int tegra20_cpu_voltage_update(struct tegra_regulator_coupler *tegra,
* survive the voltage drop if it's running on a higher frequency.
*/
if (!cpu_min_uV_consumers)
- cpu_min_uV = cpu_uV;
+ cpu_min_uV = max(cpu_uV, cpu_min_uV);
/* restore boot voltage level */
if (tegra->sys_reboot_mode)
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] soc/tegra: regulators: Fix locking up when voltage-spread is out of range in tegra20
2025-09-06 10:50 [PATCH] soc/tegra: regulators: Fix locking up when voltage-spread is out of range in tegra20 Chen Yufeng
@ 2026-01-22 6:04 ` Mikko Perttunen
0 siblings, 0 replies; 2+ messages in thread
From: Mikko Perttunen @ 2026-01-22 6:04 UTC (permalink / raw)
To: thierry.reding, Chen Yufeng; +Cc: jonathanh, linux-tegra, Chen Yufeng
On Saturday, September 6, 2025 7:50 PM Chen Yufeng wrote:
> This patch is similar to ef85bb582c41("soc/tegra: regulators: Fix
> locking up when voltage-spread is out of range").
>
> A potential deadlock issue exists in the voltage coupler code for
> Tegra20 when the voltage spread (voltage-spread) goes out of range.
> The code does not properly account for the maximum voltage spread
> (max-spread) requirement when the CPU regulator has no consumers.
>
> In the tegra20_cpu_voltage_update function, the voltage range is
> not properly handled when there are no consumers:
> ```c
> if (!cpu_min_uV_consumers)
> cpu_min_uV = cpu_uV;
> ```
> When there are no CPU consumers, cpu_min_uV is directly set to cpu_uV,
> without considering the maximum voltage spread constraint.
>
> The issue is resolved by introducing the max function to ensure that
> cpu_min_uV is set to the greater value between cpu_uV and cpu_min_uV,
> thereby preventing the voltage spread from exceeding the limit:
> ```c
> if (!cpu_min_uV_consumers)
> cpu_min_uV = max(cpu_uV, cpu_min_uV);
> ```
I don't think this applies to this driver. If cpu_min_uV == cpu_uV, no voltage change will occur, hence the voltage spread will not change.
Thanks,
Mikko
>
> Signed-off-by: Chen Yufeng <chenyufeng@iie.ac.cn>
> ---
> drivers/soc/tegra/regulators-tegra20.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/soc/tegra/regulators-tegra20.c b/drivers/soc/tegra/regulators-tegra20.c
> index 6a2f90ab9d3e..48c29b89fa59 100644
> --- a/drivers/soc/tegra/regulators-tegra20.c
> +++ b/drivers/soc/tegra/regulators-tegra20.c
> @@ -305,7 +305,7 @@ static int tegra20_cpu_voltage_update(struct tegra_regulator_coupler *tegra,
> * survive the voltage drop if it's running on a higher frequency.
> */
> if (!cpu_min_uV_consumers)
> - cpu_min_uV = cpu_uV;
> + cpu_min_uV = max(cpu_uV, cpu_min_uV);
>
> /* restore boot voltage level */
> if (tegra->sys_reboot_mode)
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-22 6:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-06 10:50 [PATCH] soc/tegra: regulators: Fix locking up when voltage-spread is out of range in tegra20 Chen Yufeng
2026-01-22 6:04 ` Mikko Perttunen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox