2019-01-10 21:33:20

by Paweł Chmiel

[permalink] [raw]
Subject: [PATCH v2 0/4] ARM: dts: s5pv210: Enable cpufreq support

This patchset enables cpufreq support using s5pv210-cpufreq driver.

First patch adds missing dmc nodes, which are required by driver.

Second patch is cosmetic, it stops driver from flooding kernel log with
messages, after every change of freq.

Third patch adds defer probe support for regulators, needed by driver.
It was observed, that those regulators can be no yet initialized, when
driver is probed, so we should wait till we can get them.

Last patch enables required kernel config options.

Changes from v1:
- Added Acked-by to one of patches
- Fix compilation error after changes in driver
- Reorganize code (so it's smaller), inside patch which logs information
about defered probe of regulators

Paweł Chmiel (4):
ARM: dts: s5pv210: Add dmc nodes
cpufreq: s5pv210: Don't flood kernel log after cpufreq change
cpufreq: s5pv210: Defer probe if getting regulators fail
ARM: defconfig: s5pv210: Add cpufreq support

arch/arm/boot/dts/s5pv210.dtsi | 12 +++++++++++
arch/arm/configs/s5pv210_defconfig | 6 ++++++
drivers/cpufreq/s5pv210-cpufreq.c | 34 ++++++++++++++++++------------
3 files changed, 38 insertions(+), 14 deletions(-)

--
2.17.1



2019-01-10 21:31:54

by Paweł Chmiel

[permalink] [raw]
Subject: [PATCH v2 2/4] cpufreq: s5pv210: Don't flood kernel log after cpufreq change

This commit replaces printk with pr_debug, so we don't flood kernel log.

Signed-off-by: Paweł Chmiel <[email protected]>
Acked-by: Krzysztof Kozlowski <[email protected]>
---
Changes from v1:
- Added Acked-by
---
drivers/cpufreq/s5pv210-cpufreq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
index dbecd7667db2..f51697f1e0b3 100644
--- a/drivers/cpufreq/s5pv210-cpufreq.c
+++ b/drivers/cpufreq/s5pv210-cpufreq.c
@@ -481,7 +481,7 @@ static int s5pv210_target(struct cpufreq_policy *policy, unsigned int index)
arm_volt, arm_volt_max);
}

- printk(KERN_DEBUG "Perf changed[L%d]\n", index);
+ pr_debug("Perf changed[L%d]\n", index);

exit:
mutex_unlock(&set_freq_lock);
--
2.17.1


2019-01-10 21:32:42

by Paweł Chmiel

[permalink] [raw]
Subject: [PATCH v2 4/4] ARM: defconfig: s5pv210: Add cpufreq support

This commit enables cpufreq support for all s5pv210 devices.

Signed-off-by: Paweł Chmiel <[email protected]>
---
arch/arm/configs/s5pv210_defconfig | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/arch/arm/configs/s5pv210_defconfig b/arch/arm/configs/s5pv210_defconfig
index 951196bdf008..fd4f28aabda6 100644
--- a/arch/arm/configs/s5pv210_defconfig
+++ b/arch/arm/configs/s5pv210_defconfig
@@ -11,6 +11,12 @@ CONFIG_ARCH_S5PV210=y
CONFIG_VMSPLIT_2G=y
CONFIG_ARM_APPENDED_DTB=y
CONFIG_CMDLINE="root=/dev/ram0 rw ramdisk=8192 initrd=0x20800000,8M console=ttySAC1,115200 init=/linuxrc"
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_STAT=y
+CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
+CONFIG_CPU_FREQ_GOV_POWERSAVE=m
+CONFIG_CPU_FREQ_GOV_USERSPACE=m
+CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
CONFIG_VFP=y
CONFIG_NEON=y
CONFIG_MODULES=y
--
2.17.1


2019-01-10 23:18:22

by Paweł Chmiel

[permalink] [raw]
Subject: [PATCH v2 3/4] cpufreq: s5pv210: Defer probe if getting regulators fail

There is possibility, that when probing driver, regulators are not yet
initialized. In this case we should return EPROBE_DEFER and wait till
they're initialized, since they're required currently for cpufreq driver
to work. Also move regulator initialization code at beginning of probe,
so we can defer as fast as posibble.

Signed-off-by: Paweł Chmiel <[email protected]>
---
Changes from v1:
- Fix compilation error
- Reorganize code so it's smaller
---
drivers/cpufreq/s5pv210-cpufreq.c | 32 ++++++++++++++++++-------------
1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
index f51697f1e0b3..6df95941ba96 100644
--- a/drivers/cpufreq/s5pv210-cpufreq.c
+++ b/drivers/cpufreq/s5pv210-cpufreq.c
@@ -594,6 +594,25 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev)
* this whole driver as soon as S5PV210 gets migrated to use
* cpufreq-dt driver.
*/
+ arm_regulator = regulator_get(NULL, "vddarm");
+ if (IS_ERR(arm_regulator)) {
+ if (PTR_ERR(arm_regulator) == -EPROBE_DEFER)
+ pr_debug("vddarm regulator not ready, defer\n");
+ else
+ pr_err("failed to get regulator vddarm\n");
+ return PTR_ERR(arm_regulator);
+ }
+
+ int_regulator = regulator_get(NULL, "vddint");
+ if (IS_ERR(int_regulator)) {
+ if (PTR_ERR(int_regulator) == -EPROBE_DEFER)
+ pr_debug("vddint regulator not ready, defer\n");
+ else
+ pr_err("failed to get regulator vddint\n");
+ regulator_put(arm_regulator);
+ return PTR_ERR(int_regulator);
+ }
+
np = of_find_compatible_node(NULL, NULL, "samsung,s5pv210-clock");
if (!np) {
pr_err("%s: failed to find clock controller DT node\n",
@@ -633,19 +652,6 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev)
}
}

- arm_regulator = regulator_get(NULL, "vddarm");
- if (IS_ERR(arm_regulator)) {
- pr_err("failed to get regulator vddarm\n");
- return PTR_ERR(arm_regulator);
- }
-
- int_regulator = regulator_get(NULL, "vddint");
- if (IS_ERR(int_regulator)) {
- pr_err("failed to get regulator vddint\n");
- regulator_put(arm_regulator);
- return PTR_ERR(int_regulator);
- }
-
register_reboot_notifier(&s5pv210_cpufreq_reboot_notifier);

return cpufreq_register_driver(&s5pv210_driver);
--
2.17.1


2019-01-10 23:18:54

by Paweł Chmiel

[permalink] [raw]
Subject: [PATCH v2 1/4] ARM: dts: s5pv210: Add dmc nodes

This commit adds dmc nodes, which are needed by s5pv210 cpufreq driver
to work.

Signed-off-by: Paweł Chmiel <[email protected]>
---
arch/arm/boot/dts/s5pv210.dtsi | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/s5pv210.dtsi b/arch/arm/boot/dts/s5pv210.dtsi
index e9613418228d..2d55a3a6e79e 100644
--- a/arch/arm/boot/dts/s5pv210.dtsi
+++ b/arch/arm/boot/dts/s5pv210.dtsi
@@ -25,6 +25,8 @@

aliases {
csis0 = &csis0;
+ dmc0 = &dmc0;
+ dmc1 = &dmc1;
fimc0 = &fimc0;
fimc1 = &fimc1;
fimc2 = &fimc2;
@@ -521,6 +523,16 @@
status = "disabled";
};

+ dmc0: dmc@f0000000 {
+ compatible = "samsung,s5pv210-dmc";
+ reg = <0xf0000000 0x1000>;
+ };
+
+ dmc1: dmc@f1400000 {
+ compatible = "samsung,s5pv210-dmc";
+ reg = <0xf1400000 0x1000>;
+ };
+
g2d: g2d@fa000000 {
compatible = "samsung,s5pv210-g2d";
reg = <0xfa000000 0x1000>;
--
2.17.1


2019-01-11 09:50:54

by Viresh Kumar

[permalink] [raw]
Subject: Re: [PATCH v2 1/4] ARM: dts: s5pv210: Add dmc nodes

On 11-01-19, 09:32, Krzysztof Kozlowski wrote:
> On Thu, 10 Jan 2019 at 21:53, Paweł Chmiel
> <[email protected]> wrote:
> >
> > This commit adds dmc nodes, which are needed by s5pv210 cpufreq driver
> > to work.
> >
> > Signed-off-by: Paweł Chmiel <[email protected]>
> > ---
> > arch/arm/boot/dts/s5pv210.dtsi | 12 ++++++++++++
> > 1 file changed, 12 insertions(+)
> >
>
> Thanks, applied (actually I applied v1 - I hope there were no changes).

Would you like to Ack the other patches so that I can apply them ?

--
viresh

2019-01-11 11:03:28

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v2 1/4] ARM: dts: s5pv210: Add dmc nodes

On Thu, 10 Jan 2019 at 21:53, Paweł Chmiel
<[email protected]> wrote:
>
> This commit adds dmc nodes, which are needed by s5pv210 cpufreq driver
> to work.
>
> Signed-off-by: Paweł Chmiel <[email protected]>
> ---
> arch/arm/boot/dts/s5pv210.dtsi | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>

Thanks, applied (actually I applied v1 - I hope there were no changes).

Best regards,
Krzysztof

2019-01-11 12:40:00

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v2 3/4] cpufreq: s5pv210: Defer probe if getting regulators fail

On Thu, 10 Jan 2019 at 21:53, Paweł Chmiel
<[email protected]> wrote:
>
> There is possibility, that when probing driver, regulators are not yet
> initialized. In this case we should return EPROBE_DEFER and wait till
> they're initialized, since they're required currently for cpufreq driver
> to work. Also move regulator initialization code at beginning of probe,
> so we can defer as fast as posibble.
>
> Signed-off-by: Paweł Chmiel <[email protected]>
> ---
> Changes from v1:
> - Fix compilation error
> - Reorganize code so it's smaller
> ---
> drivers/cpufreq/s5pv210-cpufreq.c | 32 ++++++++++++++++++-------------
> 1 file changed, 19 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
> index f51697f1e0b3..6df95941ba96 100644
> --- a/drivers/cpufreq/s5pv210-cpufreq.c
> +++ b/drivers/cpufreq/s5pv210-cpufreq.c
> @@ -594,6 +594,25 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev)
> * this whole driver as soon as S5PV210 gets migrated to use
> * cpufreq-dt driver.
> */
> + arm_regulator = regulator_get(NULL, "vddarm");
> + if (IS_ERR(arm_regulator)) {
> + if (PTR_ERR(arm_regulator) == -EPROBE_DEFER)
> + pr_debug("vddarm regulator not ready, defer\n");
> + else
> + pr_err("failed to get regulator vddarm\n");
> + return PTR_ERR(arm_regulator);
> + }
> +
> + int_regulator = regulator_get(NULL, "vddint");
> + if (IS_ERR(int_regulator)) {
> + if (PTR_ERR(int_regulator) == -EPROBE_DEFER)
> + pr_debug("vddint regulator not ready, defer\n");
> + else
> + pr_err("failed to get regulator vddint\n");
> + regulator_put(arm_regulator);
> + return PTR_ERR(int_regulator);
> + }
> +

Error paths are now not correct. You should put the regulators when
returning later. The previous code had these error paths wrong as well
- not iounmapping - but if you move things around, maybe let's fix
things.

Best regards,
Krzysztof

2019-01-11 12:40:00

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v2 1/4] ARM: dts: s5pv210: Add dmc nodes

On Fri, 11 Jan 2019 at 10:41, Viresh Kumar <[email protected]> wrote:
>
> On 11-01-19, 09:32, Krzysztof Kozlowski wrote:
> > On Thu, 10 Jan 2019 at 21:53, Paweł Chmiel
> > <[email protected]> wrote:
> > >
> > > This commit adds dmc nodes, which are needed by s5pv210 cpufreq driver
> > > to work.
> > >
> > > Signed-off-by: Paweł Chmiel <[email protected]>
> > > ---
> > > arch/arm/boot/dts/s5pv210.dtsi | 12 ++++++++++++
> > > 1 file changed, 12 insertions(+)
> > >
> >
> > Thanks, applied (actually I applied v1 - I hope there were no changes).
>
> Would you like to Ack the other patches so that I can apply them ?

Sure, let me take a look. Anyway, I will take patch 4/4 (defconfig). I
left it for later because of ongoing discussion.

Best regards,
Krzysztof

2019-01-11 12:41:07

by Paweł Chmiel

[permalink] [raw]
Subject: Re: [PATCH v2 3/4] cpufreq: s5pv210: Defer probe if getting regulators fail

pt., 11 sty 2019 o 10:46 Krzysztof Kozlowski <[email protected]> napisał(a):
>
> On Thu, 10 Jan 2019 at 21:53, Paweł Chmiel
> <[email protected]> wrote:
> >
> > There is possibility, that when probing driver, regulators are not yet
> > initialized. In this case we should return EPROBE_DEFER and wait till
> > they're initialized, since they're required currently for cpufreq driver
> > to work. Also move regulator initialization code at beginning of probe,
> > so we can defer as fast as posibble.
> >
> > Signed-off-by: Paweł Chmiel <[email protected]>
> > ---
> > Changes from v1:
> > - Fix compilation error
> > - Reorganize code so it's smaller
> > ---
> > drivers/cpufreq/s5pv210-cpufreq.c | 32 ++++++++++++++++++-------------
> > 1 file changed, 19 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
> > index f51697f1e0b3..6df95941ba96 100644
> > --- a/drivers/cpufreq/s5pv210-cpufreq.c
> > +++ b/drivers/cpufreq/s5pv210-cpufreq.c
> > @@ -594,6 +594,25 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev)
> > * this whole driver as soon as S5PV210 gets migrated to use
> > * cpufreq-dt driver.
> > */
> > + arm_regulator = regulator_get(NULL, "vddarm");
> > + if (IS_ERR(arm_regulator)) {
> > + if (PTR_ERR(arm_regulator) == -EPROBE_DEFER)
> > + pr_debug("vddarm regulator not ready, defer\n");
> > + else
> > + pr_err("failed to get regulator vddarm\n");
> > + return PTR_ERR(arm_regulator);
> > + }
> > +
> > + int_regulator = regulator_get(NULL, "vddint");
> > + if (IS_ERR(int_regulator)) {
> > + if (PTR_ERR(int_regulator) == -EPROBE_DEFER)
> > + pr_debug("vddint regulator not ready, defer\n");
> > + else
> > + pr_err("failed to get regulator vddint\n");
> > + regulator_put(arm_regulator);
> > + return PTR_ERR(int_regulator);
> > + }
> > +
>
> Error paths are now not correct. You should put the regulators when
> returning later. The previous code had these error paths wrong as well
> - not iounmapping - but if you move things around, maybe let's fix
> things.
Ok, will fix this in new version and will resend it (only this one
patch, since all other looks ok/applied).
Also will add missing iounmapping/etc to fix all other error paths.

Thanks
>
> Best regards,
> Krzysztof

2019-01-13 09:36:04

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v2 4/4] ARM: defconfig: s5pv210: Add cpufreq support

On Thu, Jan 10, 2019 at 09:52:15PM +0100, Paweł Chmiel wrote:
> This commit enables cpufreq support for all s5pv210 devices.
>
> Signed-off-by: Paweł Chmiel <[email protected]>
> ---
> arch/arm/configs/s5pv210_defconfig | 6 ++++++

Thanks, applied.

Best regards,
Krzysztof