Fix regulators coupling for Exynos5800
Subsystems (4)
A message that is not in the archive (sent off-list or not yet received): CGME20200529124948eucas1p175379ead8afd1932f7b7ae61e35cf632@eucas1p1.samsung.com
cover Fix regulators coupling for Exynos5800
Hi!
This patchset is another attempt to fix the regulator coupling on Exynos5800/5422 SoCs. Here are links to the previous attempts:
https://lore.kernel.org/linux-samsung-soc/20191008101709.qVNy8eijBi0LynOteWFMnTg4GUwKG599n6OyYoX1Abs@z/
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/linux-pm/[email protected]/
https://lore.kernel.org/linux-pm/[email protected]/
The problem is with "vdd_int" regulator coupled with "vdd_arm" on Odroid XU3/XU4 boards family. "vdd_arm" is handled by CPUfreq. "vdd_int" is handled by devfreq. CPUfreq initialized quite early during boot and it starts changing OPPs and "vdd_arm" value. Sometimes CPU activity during boot goes down and some low-frequency OPPs are selected, what in turn causes lowering "vdd_arm". This happens before devfreq applies its requirements on "vdd_int". Regulator balancing code reduces "vdd_arm" voltage value, what in turn causes lowering "vdd_int" value to the lowest possible value. This is much below the operation point of the wcore bus, which still runs at the highest frequency.
The issue was hard to notice because in the most cases the board managed to boot properly, even when the regulator was set to lowest value allowed by the regulator constraints. However, it caused some random issues, which can be observed as "Unhandled prefetch abort" or low USB stability.
Adding more and more special cases to the generic code has been rejected, so the only way to ensure the desired behavior on Exynos5800-based SoCs is to make a custom regulator coupler driver.
Best regards,
Marek Szyprowski
Patch summary:
Marek Szyprowski (2):
regulator: extract voltage balancing code to separate function
soc: samsung: Add simple voltage coupler for Exynos5800
arch/arm/mach-exynos/Kconfig | 1 + drivers/regulator/core.c | 49 ++++++++------- drivers/soc/samsung/Kconfig | 3 + drivers/soc/samsung/Makefile | 1 + .../soc/samsung/exynos-regulator-coupler.c | 59 +++++++++++++++++++ include/linux/regulator/coupler.h | 8 +++ 6 files changed, 101 insertions(+), 20 deletions(-) create mode 100644 drivers/soc/samsung/exynos-regulator-coupler.c
Signature · 1 line
2.17.1
PATCH 1/2 regulator: extract voltage balancing code to the separate function
Move the coupled regulators voltage balancing code to the separate function and allow to call it from the custom regulator couplers.
--- drivers/regulator/core.c | 49 ++++++++++++++++++------------- include/linux/regulator/coupler.h | 8 +++++ 2 files changed, 37 insertions(+), 20 deletions(-)
drivers/regulator/core.c +29 -20
@@ -3642,36 +3642,19 @@ static int regulator_get_optimal_voltage(struct regulator_dev *rdev,return done; } -static int regulator_balance_voltage (struct regulator_dev *rdev, -suspend_state_t state) +int regulator_do_balance_voltage (struct regulator_dev *rdev, +suspend_state_t state,bool skip_coupled) {struct regulator_dev **c_rdevs;struct regulator_dev *best_rdev;struct coupling_desc *c_desc = &rdev->coupling_desc; -struct regulator_coupler *coupler = c_desc->coupler;int i, ret, n_coupled, best_min_uV, best_max_uV, best_c_rdev;unsigned int delta, best_delta;unsigned long c_rdev_done =0 ;bool best_c_rdev_done; c_rdevs = c_desc->coupled_rdevs; - n_coupled = c_desc->n_coupled; - -/* -* If system is in a state other than PM_SUSPEND_ON, don't check -* other coupled regulators. -*/ -if (state !=PM_SUSPEND_ON ) - n_coupled =1 ; - -if (c_desc->n_resolved < n_coupled) { -rdev_err (rdev,"Not all coupled regulators registered\n" ); -return -EPERM ; - } - -/* Invoke custom balancer for customized couplers */ -if (coupler && coupler->balance_voltage) -return coupler->balance_voltage (coupler, rdev, state); + n_coupled = skip_coupled ?1 : c_desc->n_coupled;/* * Find the best possible voltage change on each loop. Leave the loop
@@ -3742,6 +3725,32 @@ static int regulator_balance_voltage(struct regulator_dev *rdev,return ret; } +static int regulator_balance_voltage (struct regulator_dev *rdev, +suspend_state_t state) +{ +struct coupling_desc *c_desc = &rdev->coupling_desc; +struct regulator_coupler *coupler = c_desc->coupler; +bool skip_coupled = false; + +/* +* If system is in a state other than PM_SUSPEND_ON, don't check +* other coupled regulators. +*/ +if (state !=PM_SUSPEND_ON ) + skip_coupled = true; + +if (c_desc->n_resolved < c_desc->n_coupled) { +rdev_err (rdev,"Not all coupled regulators registered\n" ); +return -EPERM ; + } + +/* Invoke custom balancer for customized couplers */ +if (coupler && coupler->balance_voltage) +return coupler->balance_voltage (coupler, rdev, state); + +return regulator_do_balance_voltage (rdev, state, skip_coupled); +} +/** * regulator_set_voltage - set regulator output voltage * @regulator: regulator source
include/linux/regulator/coupler.h +8 -0
@@ -62,6 +62,8 @@ int regulator_get_voltage_rdev(struct regulator_dev *rdev);int regulator_set_voltage_rdev (struct regulator_dev *rdev,int min_uV,int max_uV,suspend_state_t state); +int regulator_do_balance_voltage (struct regulator_dev *rdev, +suspend_state_t state,bool skip_coupled);#else static inline int regulator_coupler_register (struct regulator_coupler *coupler) {
@@ -92,6 +94,12 @@ static inline int regulator_set_voltage_rdev(struct regulator_dev *rdev, {return -EINVAL ; } +static inline int regulator_do_balance_voltage (struct regulator_dev *rdev, +suspend_state_t state, +bool skip_coupled) +{ +return -EINVAL ; +}#endif #endif
Signature · 1 line
2.17.1
PATCH 2/2 soc: samsung: Add simple voltage coupler for Exynos5800
In reply to Marek SzyprowskiAdd custom voltage regulator coupler for Exynos5800 SoCs, which require coupling between "vdd_arm" and "vdd_int" regulators. This coupler ensures that coupled regulators voltage balancing is done only when clients for each regulator (cpufreq for "vdd_arm" and devfreq for "vdd_int") apply their constraints, so the voltage values don't go beyond the bootloader-selected operation point during the boot process. This also ensures proper voltage balancing if any of those drivers is missing.
--- arch/arm/mach-exynos/Kconfig | 1 + drivers/soc/samsung/Kconfig | 3 + drivers/soc/samsung/Makefile | 1 + .../soc/samsung/exynos-regulator-coupler.c | 59 +++++++++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 drivers/soc/samsung/exynos-regulator-coupler.c
arch/arm/mach-exynos/Kconfig +1 -0
@@ -118,6 +118,7 @@ config SOC_EXYNOS5800 bool "Samsung EXYNOS5800" default y depends on SOC_EXYNOS5420 + select EXYNOS_REGULATOR_COUPLER config EXYNOS_MCPM bool
drivers/soc/samsung/Kconfig +3 -0
@@ -37,4 +37,7 @@ config EXYNOS_PM_DOMAINS bool "Exynos PM domains" if COMPILE_TEST depends on PM_GENERIC_DOMAINS || COMPILE_TEST +config EXYNOS_REGULATOR_COUPLER + bool "Exynos SoC Regulator Coupler" if COMPILE_TEST + depends on ARCH_EXYNOS || COMPILE_TEST endif
drivers/soc/samsung/Makefile +1 -0
@@ -9,3 +9,4 @@ obj-$(CONFIG_EXYNOS_PMU) += exynos-pmu.o obj-$(CONFIG_EXYNOS_PMU_ARM_DRIVERS) += exynos3250-pmu.o exynos4-pmu.o \ exynos5250-pmu.o exynos5420-pmu.o obj-$(CONFIG_EXYNOS_PM_DOMAINS) += pm_domains.o +obj-$(CONFIG_EXYNOS_REGULATOR_COUPLER) += exynos-regulator-coupler.o
drivers/soc/samsung/exynos-regulator-coupler.c new file +59 -0
59 lines not on this page · raw message
Signature · 1 line
2.17.1
Krzysztof Kozlowski
maintainerRe: [PATCH 2/2] soc: samsung: Add simple voltage coupler for Exynos5800
Quoted 87 lines · Marek Szyprowski
Add custom voltage regulator coupler for Exynos5800 SoCs, which require coupling between "
vdd_arm" and "vdd_int" regulators. This coupler ensures that coupled regulators voltage balancing is done only when clients for each regulator (cpufreq for "vdd_arm" and devfreq for "vdd_int") apply their constraints, so the voltage values don't go beyond the bootloader-selected operation point during the boot process. This also ensures proper voltage balancing if any of those drivers is missing.Signed-off-by Marek Szyprowski <[email protected]>--- arch/arm/mach-exynos/Kconfig | 1 + drivers/soc/samsung/Kconfig | 3 + drivers/soc/samsung/Makefile | 1 + .../soc/samsung/exynos-regulator-coupler.c | 59 +++++++++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 drivers/soc/samsung/exynos-regulator-coupler.carch/arm/mach-exynos/Kconfig +1
-0@@ -118,6 +118,7 @@ config SOC_EXYNOS5800 bool "Samsung EXYNOS5800" default y depends on SOC_EXYNOS5420 + select EXYNOS_REGULATOR_COUPLER config EXYNOS_MCPM booldrivers/soc/samsung/Kconfig +3
-0@@ -37,4 +37,7 @@ config EXYNOS_PM_DOMAINS bool "Exynos PM domains" if COMPILE_TEST depends on PM_GENERIC_DOMAINS || COMPILE_TEST +config EXYNOS_REGULATOR_COUPLER + bool "Exynos SoC Regulator Coupler" if COMPILE_TEST + depends on ARCH_EXYNOS || COMPILE_TEST endifdrivers/soc/samsung/Makefile +1
-0@@ -9,3 +9,4 @@ obj-$(CONFIG_EXYNOS_PMU) += exynos-pmu.o obj-$(CONFIG_EXYNOS_PMU_ARM_DRIVERS) += exynos3250-pmu.o exynos4-pmu.o \ exynos5250-pmu.o exynos5420-pmu.o obj-$(CONFIG_EXYNOS_PM_DOMAINS) += pm_domains.o +obj-$(CONFIG_EXYNOS_REGULATOR_COUPLER) += exynos-regulator-coupler.odrivers/soc/samsung/exynos-regulator-coupler.c new file +31
-0@@ -0,0 +1,59 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2020 Samsung Electronics Co., Ltd. +* http://www.samsung.com/ +* Author: Marek Szyprowski <[email protected]> +* +* Samsung Exynos SoC voltage coupler +*/ + +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/of.h> +#include <linux/regulator/coupler.h> +#include <linux/regulator/driver.h> + +static int exynos_coupler_balance_voltage (struct regulator_coupler *coupler, +struct regulator_dev *rdev, +suspend_state_t state) +{ +struct coupling_desc *c_desc = &rdev->coupling_desc; +int ret, cons_uV =0 , cons_max_uV =INT_MAX ; +bool skip_coupled = false; + +/* get coupled regulator constraints */ + ret =regulator_check_consumers (c_desc->coupled_rdevs[1 ], &cons_uV, + &cons_max_uV, state); +if (ret <0 ) +return ret; + +/* skip adjusting coupled regulator if it has no constraints set yet */ +if (cons_uV ==0 )
drivers/soc/samsung/exynos-regulator-coupler.c line 41
Quoted 10 lines
drivers/soc/samsung/exynos-regulator-coupler.c new file +10
-0+ skip_coupled = true; + +return regulator_do_balance_voltage (rdev, state, skip_coupled); +} + +static int exynos_coupler_attach (struct regulator_coupler *coupler, +struct regulator_dev *rdev) +{ +if (strcmp (rdev_get_name (rdev),"vdd_arm" ) ==0 || +strcmp (rdev_get_name (rdev),"vdd_int" ) ==0 )
Thanks for the patch!
You hard-coded specific names of regulators existing
only in DTS. They do not come from any driver nor bindings, therefore they could change making driver unusable. Someone could add a new DTS with different names and expect this to work as well.
You need bindings for this. Something like:Documentation/devicetree/bindings/regulator/nvidia,tegra-regulators-coupling.txt But better in YAML, if possible.
Best regards,
Krzysztof
Re: [PATCH 2/2] soc: samsung: Add simple voltage coupler for Exynos5800
Hi Krzysztof,
Quoted 8 lines · Krzysztof Kozlowski
Quoted 7 lines · Marek Szyprowski
Add custom voltage regulator coupler for Exynos5800 SoCs, which require coupling between "
vdd_arm" and "vdd_int" regulators. This coupler ensures that coupled regulators voltage balancing is done only when clients for each regulator (cpufreq for "vdd_arm" and devfreq for "vdd_int") apply their constraints, so the voltage values don't go beyond the bootloader-selected operation point during the boot process. This also ensures proper voltage balancing if any of those drivers is missing.
I've intentionally didn't add any new properties nor bindings, because I assume that the generic regulator coupling bindings fully describe what is needed for Exynos5800 SoCs. This driver 'fixes' only the issue (or lets it call undefined behavior) in the regulator core, which is fatal for Exynos5800.
Please note that this "attach" callback is called only for the regulators, which are marked as coupled, so for all existing board it might be even enough to simply return 0 without any check. IMHO for all existing Exynos5422/5800 the name-based check is enough. I can change it to a check for particular DT path peculiar for Exynos5422/5800 (the check if the given regulator mathes the phandle specificied in the exynos-bus node for "wcore" or A15's CPU).
Quoted 96 lines
Quoted 79 lines
Signed-off-by Marek Szyprowski <[email protected]>--- arch/arm/mach-exynos/Kconfig | 1 + drivers/soc/samsung/Kconfig | 3 + drivers/soc/samsung/Makefile | 1 + .../soc/samsung/exynos-regulator-coupler.c | 59 +++++++++++++++++++ 4 files changed, 64 insertions(+)create mode 100644
drivers/soc/samsung/exynos-regulator-coupler.carch/arm/mach-exynos/Kconfig +1
-0@@ -118,6 +118,7 @@ config SOC_EXYNOS5800 bool "Samsung EXYNOS5800" default y depends on SOC_EXYNOS5420 + select EXYNOS_REGULATOR_COUPLER config EXYNOS_MCPM booldrivers/soc/samsung/Kconfig +3
-0@@ -37,4 +37,7 @@ config EXYNOS_PM_DOMAINS bool "Exynos PM domains" if COMPILE_TEST depends on PM_GENERIC_DOMAINS || COMPILE_TEST +config EXYNOS_REGULATOR_COUPLER + bool "Exynos SoC Regulator Coupler" if COMPILE_TEST + depends on ARCH_EXYNOS || COMPILE_TEST endifdrivers/soc/samsung/Makefile +1
-0@@ -9,3 +9,4 @@ obj-$(CONFIG_EXYNOS_PMU) += exynos-pmu.o obj-$(CONFIG_EXYNOS_PMU_ARM_DRIVERS) += exynos3250-pmu.o exynos4-pmu.o \ exynos5250-pmu.o exynos5420-pmu.o obj-$(CONFIG_EXYNOS_PM_DOMAINS) += pm_domains.o +obj-$(CONFIG_EXYNOS_REGULATOR_COUPLER) += exynos-regulator-coupler.odrivers/soc/samsung/exynos-regulator-coupler.c new file +31
-0@@ -0,0 +1,59 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2020 Samsung Electronics Co., Ltd. +* http://www.samsung.com/ +* Author: Marek Szyprowski <[email protected]> +* +* Samsung Exynos SoC voltage coupler +*/ + +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/of.h> +#include <linux/regulator/coupler.h> +#include <linux/regulator/driver.h> + +static int exynos_coupler_balance_voltage (struct regulator_coupler *coupler, +struct regulator_dev *rdev, +suspend_state_t state) +{ +struct coupling_desc *c_desc = &rdev->coupling_desc; +int ret, cons_uV =0 , cons_max_uV =INT_MAX ; +bool skip_coupled = false; + +/* get coupled regulator constraints */ + ret =regulator_check_consumers (c_desc->coupled_rdevs[1 ], &cons_uV, + &cons_max_uV, state); +if (ret <0 ) +return ret; + +/* skip adjusting coupled regulator if it has no constraints set yet */ +if (cons_uV ==0 )drivers/soc/samsung/exynos-regulator-coupler.c line 41
Quoted 10 lines
drivers/soc/samsung/exynos-regulator-coupler.c new file +10
-0+ skip_coupled = true; + +return regulator_do_balance_voltage (rdev, state, skip_coupled); +} + +static int exynos_coupler_attach (struct regulator_coupler *coupler, +struct regulator_dev *rdev) +{ +if (strcmp (rdev_get_name (rdev),"vdd_arm" ) ==0 || +strcmp (rdev_get_name (rdev),"vdd_int" ) ==0 )Thanks for the patch!
You hard-coded specific names of regulators existing
only in DTS. They do not come from any driver nor bindings, therefore they could change making driver unusable. Someone could add a new DTS with different names and expect this to work as well.
Quoted 7 lines
You need bindings for this. Something like:
Documentation/devicetree/bindings/regulator/nvidia,tegra-regulators-coupling.txtBut better in YAML, if possible.Best regards,
Krzysztof
Best regards
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland
PATCH v2 1/1 soc: samsung: Add simple voltage coupler for Exynos5800
Add a simple custom voltage regulator coupler for Exynos5800 SoCs, which require coupling between "vdd_arm" and "vdd_int" regulators. This coupler ensures that the voltage balancing for the coupled regulators is done only when clients for the each regulator apply their constraints, so the voltage values don't go beyond the bootloader-selected operation point during the boot process. This also ensures proper voltage balancing if any of the client driver is missing.
---
v2:
- removed dependency on the regulator names as pointed by krzk, now it works with all coupled regulators. So far the coupling between the regulators on Exynos5800 based boards is defined only between "vdd_arm" and "vdd_int" supplies.
--- arch/arm/mach-exynos/Kconfig | 1 + drivers/soc/samsung/Kconfig | 3 + drivers/soc/samsung/Makefile | 1 + .../soc/samsung/exynos-regulator-coupler.c | 56 +++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 drivers/soc/samsung/exynos-regulator-coupler.c
arch/arm/mach-exynos/Kconfig +1 -0
@@ -118,6 +118,7 @@ config SOC_EXYNOS5800 bool "Samsung EXYNOS5800" default y depends on SOC_EXYNOS5420 + select EXYNOS_REGULATOR_COUPLER config EXYNOS_MCPM bool
drivers/soc/samsung/Kconfig +3 -0
@@ -37,4 +37,7 @@ config EXYNOS_PM_DOMAINS bool "Exynos PM domains" if COMPILE_TEST depends on PM_GENERIC_DOMAINS || COMPILE_TEST +config EXYNOS_REGULATOR_COUPLER + bool "Exynos SoC Regulator Coupler" if COMPILE_TEST + depends on ARCH_EXYNOS || COMPILE_TEST endif
drivers/soc/samsung/Makefile +1 -0
@@ -9,3 +9,4 @@ obj-$(CONFIG_EXYNOS_PMU) += exynos-pmu.o obj-$(CONFIG_EXYNOS_PMU_ARM_DRIVERS) += exynos3250-pmu.o exynos4-pmu.o \ exynos5250-pmu.o exynos5420-pmu.o obj-$(CONFIG_EXYNOS_PM_DOMAINS) += pm_domains.o +obj-$(CONFIG_EXYNOS_REGULATOR_COUPLER) += exynos-regulator-coupler.o
drivers/soc/samsung/exynos-regulator-coupler.c new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH v2] soc: samsung: Add simple voltage coupler for Exynos5800
02.06.2020 16:02, Marek Szyprowski пишет:
Quoted 85 lines
Add a simple custom voltage regulator coupler for Exynos5800 SoCs, which require coupling between "
vdd_arm" and "vdd_int" regulators. This coupler ensures that the voltage balancing for the coupled regulators is done only when clients for the each regulator apply their constraints, so the voltage values don't go beyond the bootloader-selected operation point during the boot process. This also ensures proper voltage balancing if any of the client driver is missing.Signed-off-by Marek Szyprowski <[email protected]>---
v2:
- removed dependency on the regulator names as pointed by krzk, now it works with all coupled regulators. So far the coupling between the regulators on Exynos5800 based boards is defined only between "vdd_arm" and "vdd_int" supplies.--- arch/arm/mach-exynos/Kconfig | 1 + drivers/soc/samsung/Kconfig | 3 + drivers/soc/samsung/Makefile | 1 + .../soc/samsung/exynos-regulator-coupler.c | 56 +++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 drivers/soc/samsung/exynos-regulator-coupler.carch/arm/mach-exynos/Kconfig +1
-0@@ -118,6 +118,7 @@ config SOC_EXYNOS5800 bool "Samsung EXYNOS5800" default y depends on SOC_EXYNOS5420 + select EXYNOS_REGULATOR_COUPLER config EXYNOS_MCPM booldrivers/soc/samsung/Kconfig +3
-0@@ -37,4 +37,7 @@ config EXYNOS_PM_DOMAINS bool "Exynos PM domains" if COMPILE_TEST depends on PM_GENERIC_DOMAINS || COMPILE_TEST +config EXYNOS_REGULATOR_COUPLER + bool "Exynos SoC Regulator Coupler" if COMPILE_TEST + depends on ARCH_EXYNOS || COMPILE_TEST endifdrivers/soc/samsung/Makefile +1
-0@@ -9,3 +9,4 @@ obj-$(CONFIG_EXYNOS_PMU) += exynos-pmu.o obj-$(CONFIG_EXYNOS_PMU_ARM_DRIVERS) += exynos3250-pmu.o exynos4-pmu.o \ exynos5250-pmu.o exynos5420-pmu.o obj-$(CONFIG_EXYNOS_PM_DOMAINS) += pm_domains.o +obj-$(CONFIG_EXYNOS_REGULATOR_COUPLER) += exynos-regulator-coupler.odrivers/soc/samsung/exynos-regulator-coupler.c new file +23
-0@@ -0,0 +1,56 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2020 Samsung Electronics Co., Ltd. +* http://www.samsung.com/ +* Author: Marek Szyprowski <[email protected]> +* +* Simple Samsung Exynos SoC voltage coupler. Ensures that all +* clients set their constraints before balancing the voltages. +*/ + +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/of.h> +#include <linux/regulator/coupler.h> +#include <linux/regulator/driver.h> + +static int exynos_coupler_balance_voltage (struct regulator_coupler *coupler, +struct regulator_dev *rdev, +suspend_state_t state) +{ +struct coupling_desc *c_desc = &rdev->coupling_desc; +int ret, cons_uV =0 , cons_max_uV =INT_MAX ; +bool skip_coupled = false;
drivers/soc/samsung/exynos-regulator-coupler.c line 33
Quoted 10 lines
drivers/soc/samsung/exynos-regulator-coupler.c new file +10
-0+ +/* get coupled regulator constraints */ + ret =regulator_check_consumers (c_desc->coupled_rdevs[1 ], &cons_uV, + &cons_max_uV, state); +if (ret <0 ) +return ret; + +/* skip adjusting coupled regulator if it has no constraints set yet */ +if (cons_uV ==0 ) + skip_coupled = true;
Hello Marek,
Does this mean that you're going to allow to violate the coupling constraints while coupled regulator has no consumers?
I don't think that you may want to skip the coupled balancing ever. Instead you may want to assume that the min-voltage constraint equals to the current regulator's voltage while the coupled regulator has no consumers.
Yours variant of the balancer doesn't prevent the voltage dropping on regulator's enabling while coupled regulator doesn't have active consumers. This is the problem which we previously had once OPP code was changed to enable regulator.
Secondly, yours variant of the balancer also doesn't handle the case where set_voltage() is invoked while one of the couples doesn't have active consumers because voltage of this couple may drop more than allowed on the voltage re-balancing.
I'd suggest to simply change the regulator_get_optimal_voltage() to limit the desired_min_uV to the current voltage if coupled regulator has no consumers.
I don't think that any of the today's upstream kernel coupled-regulator users really need to support the case where a regulator couple is allowed *not* to have active consumers, so for now it should be fine to change the core code to accommodate the needs of the Exynos regulators (IMO). We may get back to this later on once there will be a real need support that case.
Please also note that I'm assuming that each of the coupled regulators doesn't have more than one consumer at a time in yours case (correct?), because yours solution won't work well in a case of multiple consumers. There is no universal solution for this bootstrapping problem yet.
Quoted 23 lines
drivers/soc/samsung/exynos-regulator-coupler.c new file +22
-0+return regulator_do_balance_voltage (rdev, state, skip_coupled); +} + +static int exynos_coupler_attach (struct regulator_coupler *coupler, +struct regulator_dev *rdev) +{ +return 0 ; +} + +static struct regulator_coupler exynos_coupler = { + .attach_regulator = exynos_coupler_attach, + .balance_voltage = exynos_coupler_balance_voltage, +}; + +static int __init exynos_coupler_init (void ) +{ +if (!of_machine_is_compatible ("samsung,exynos5800" )) +return 0 ; + +return regulator_coupler_register (&exynos_coupler); +} +arch_initcall (exynos_coupler_init);
Re: [PATCH v2] soc: samsung: Add simple voltage coupler for Exynos5800
Hi Dmitry,
Quoted 27 lines · Dmitry Osipenko
02.06.2020 16:02, Marek Szyprowski пишет:
Quoted 11 lines
Add a simple custom voltage regulator coupler for Exynos5800 SoCs, which require coupling between "
vdd_arm" and "vdd_int" regulators. This coupler ensures that the voltage balancing for the coupled regulators is done only when clients for the each regulator apply their constraints, so the voltage values don't go beyond the bootloader-selected operation point during the boot process. This also ensures proper voltage balancing if any of the client driver is missing.Signed-off-by Marek Szyprowski <[email protected]>---
(...)Hello Marek,
Does this mean that you're going to allow to violate the coupling constraints while coupled regulator has no consumers?
I don't think that you may want to skip the coupled balancing ever. Instead you may want to assume that the min-voltage constraint equals to the current regulator's voltage while the coupled regulator has no consumers.
Yours variant of the balancer doesn't prevent the voltage dropping on regulator's enabling while coupled regulator doesn't have active consumers. This is the problem which we previously had once OPP code was changed to enable regulator.
Quoted 4 lines
Secondly, yours variant of the balancer also doesn't handle the case where
set_voltage()is invoked while one of the couples doesn't have active consumers because voltage of this couple may drop more than allowed on the voltage re-balancing.
Indeed. I've focused on disabling balancing when there are no consumers and I didn't notice that the max_spread might be violated in such case.
Quoted 3 lines
I'd suggest to simply change the
regulator_get_optimal_voltage()to limit thedesired_min_uVto the current voltage if coupled regulator has no consumers.
Right, this sounds like a best solution. I have an idea to try to add it again to the core as a simple check: if regultor is boot_on, use current voltage as min_uV until a consumer is registered. I've checked and this approach fixes the issue. I will submit a patch in a few minutes.
Quoted 11 lines
I don't think that any of the today's upstream kernel coupled-regulator users really need to support the case where a regulator couple is allowed *not* to have active consumers, so for now it should be fine to change the core code to accommodate the needs of the Exynos regulators (IMO). We may get back to this later on once there will be a real need support that case.
Please also note that I'm assuming that each of the coupled regulators doesn't have more than one consumer at a time in yours case (correct?), because yours solution won't work well in a case of multiple consumers. There is no universal solution for this bootstrapping problem yet.
There are only a single consumers for each coupled regulator (cpufreq for vdd_arm and devfreq for vdd_int).
Best regards
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland
Mark Brown
maintainerQuoted 9 lines · Marek Szyprowski
This patchset is another attempt to fix the regulator coupling on Exynos5800/5422 SoCs. Here are links to the previous attempts:
https://lore.kernel.org/linux-samsung-soc/20191008101709.qVNy8eijBi0LynOteWFMnTg4GUwKG599n6OyYoX1Abs@z/
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/linux-pm/[email protected]/
https://lore.kernel.org/linux-pm/[email protected]/[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
Thanks!
[1/1] regulator: extract voltage balancing code to the separate function
commit: 752db83a5dfd4fd3a0624b9ab440ed947fa003ca
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Mark Brown
maintainerQuoted 2 lines · Mark Brown
[1/1] regulator: extract voltage balancing code to the separate function
commit: 752db83a5dfd4fd3a0624b9ab440ed947fa003ca
Let me know if you need a pull request for this - I figured it was too late to apply the second patch before the merge window with the cross tree stuff.
Krzysztof Kozlowski
maintainerQuoted 8 lines · Mark Brown
Quoted 2 lines · Mark Brown
[1/1] regulator: extract voltage balancing code to the separate function
commit: 752db83a5dfd4fd3a0624b9ab440ed947fa003caLet me know if you need a pull request for this - I figured it was too late to apply the second patch before the merge window with the cross tree stuff.
Thanks, I think it will not be needed. I'll apply the second patch after the merge window.
Best regards,
Krzysztof