2019-01-08 20:09:07

by Paweł Chmiel

[permalink] [raw]
Subject: [PATCH 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.

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 | 35 ++++++++++++++++++------------
3 files changed, 39 insertions(+), 14 deletions(-)

--
2.17.1



2019-01-08 20:07:49

by Paweł Chmiel

[permalink] [raw]
Subject: [PATCH 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-08 20:08:05

by Paweł Chmiel

[permalink] [raw]
Subject: [PATCH 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]>
---
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-08 22:52:24

by Paweł Chmiel

[permalink] [raw]
Subject: [PATCH 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]>
---
drivers/cpufreq/s5pv210-cpufreq.c | 33 +++++++++++++++++++------------
1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
index f51697f1e0b3..2d0e4dc7ede7 100644
--- a/drivers/cpufreq/s5pv210-cpufreq.c
+++ b/drivers/cpufreq/s5pv210-cpufreq.c
@@ -594,6 +594,26 @@ 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 (PTR_ERR(arm_regulator) == -EPROBE_DEFER) {
+ pr_dbg("vddarm regulator not ready, defer\n");
+ return -EPROBE_DEFER;
+ } else 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 (PTR_ERR(int_regulator == -EPROBE_DEFER) {
+ regulator_put(arm_regulator);
+ pr_dbg("vddint regulator not ready, defer\n");
+ return -EPROBE_DEFER;
+ } else if (IS_ERR(int_regulator)) {
+ regulator_put(arm_regulator);
+ pr_err("failed to get regulator vddint\n");
+ 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 +653,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-08 23:54:38

by Paweł Chmiel

[permalink] [raw]
Subject: [PATCH 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-09 10:37:46

by Krzysztof Kozlowski

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

On Tue, 8 Jan 2019 at 21:05, Paweł Chmiel
<[email protected]> wrote:
>
> This commit replaces printk with pr_debug, so we don't flood kernel log.
>
> Signed-off-by: Paweł Chmiel <[email protected]>
> ---
> drivers/cpufreq/s5pv210-cpufreq.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

Acked-by: Krzysztof Kozlowski <[email protected]>

Best regards,
Krzysztof

2019-01-10 07:05:12

by Viresh Kumar

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

On 08-01-19, 21:05, 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 ++++++
> 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

You don't want to use schedutil ? That is the default governor for
everyone now a days.

--
viresh

2019-01-10 07:22:34

by Viresh Kumar

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

On 08-01-19, 21:05, Paweł Chmiel 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]>
> ---
> drivers/cpufreq/s5pv210-cpufreq.c | 33 +++++++++++++++++++------------
> 1 file changed, 20 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
> index f51697f1e0b3..2d0e4dc7ede7 100644
> --- a/drivers/cpufreq/s5pv210-cpufreq.c
> +++ b/drivers/cpufreq/s5pv210-cpufreq.c
> @@ -594,6 +594,26 @@ 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 (PTR_ERR(arm_regulator) == -EPROBE_DEFER) {
> + pr_dbg("vddarm regulator not ready, defer\n");
> + return -EPROBE_DEFER;
> + } else if (IS_ERR(arm_regulator)) {
> + pr_err("failed to get regulator vddarm\n");
> + return PTR_ERR(arm_regulator);
> + }

The only difference between the two cases is pr_dbg vs pr_err, its
ugly that we have to add special code for that :(

Maybe write it as:

if (IS_ERR(arm_regulator)) {
if (PTR_ERR(arm_regulator) == -EPROBE_DEFER)
pr_dbg...
else
pr_err
return PTR_ERR(arm_regulator);
}

> +
> + int_regulator = regulator_get(NULL, "vddint");
> + if (PTR_ERR(int_regulator == -EPROBE_DEFER) {

Does this even compile ?

> + regulator_put(arm_regulator);
> + pr_dbg("vddint regulator not ready, defer\n");
> + return -EPROBE_DEFER;
> + } else if (IS_ERR(int_regulator)) {
> + regulator_put(arm_regulator);
> + pr_err("failed to get regulator vddint\n");
> + 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 +653,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

--
viresh

2019-01-10 07:57:25

by Paweł Chmiel

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

czw., 10 sty 2019 o 08:02 Viresh Kumar <[email protected]> napisał(a):
>
> On 08-01-19, 21:05, 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 ++++++
> > 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
>
> You don't want to use schedutil ? That is the default governor for
> everyone now a days.
schedutil depends on SMP, which is not enabled on s5pv210 (it has only
one cpu core).
>
> --
> viresh

2019-01-10 08:06:31

by Paweł Chmiel

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

czw., 10 sty 2019 o 08:01 Viresh Kumar <[email protected]> napisał(a):
>
> On 08-01-19, 21:05, Paweł Chmiel 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]>
> > ---
> > drivers/cpufreq/s5pv210-cpufreq.c | 33 +++++++++++++++++++------------
> > 1 file changed, 20 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
> > index f51697f1e0b3..2d0e4dc7ede7 100644
> > --- a/drivers/cpufreq/s5pv210-cpufreq.c
> > +++ b/drivers/cpufreq/s5pv210-cpufreq.c
> > @@ -594,6 +594,26 @@ 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 (PTR_ERR(arm_regulator) == -EPROBE_DEFER) {
> > + pr_dbg("vddarm regulator not ready, defer\n");
> > + return -EPROBE_DEFER;
> > + } else if (IS_ERR(arm_regulator)) {
> > + pr_err("failed to get regulator vddarm\n");
> > + return PTR_ERR(arm_regulator);
> > + }
>
> The only difference between the two cases is pr_dbg vs pr_err, its
> ugly that we have to add special code for that :(
>
> Maybe write it as:
>
> if (IS_ERR(arm_regulator)) {
> if (PTR_ERR(arm_regulator) == -EPROBE_DEFER)
> pr_dbg...
> else
> pr_err
> return PTR_ERR(arm_regulator);
> }
>
> > +
> > + int_regulator = regulator_get(NULL, "vddint");
> > + if (PTR_ERR(int_regulator == -EPROBE_DEFER) {
>
> Does this even compile ?
Looks like i broke it after testing (where it was working fine - was
able to change freq and gov),
and didn't catch this before sending patch for review :/.
Sorry, this (and first issue) will be fixed in v2.

Thanks for review
>
> > + regulator_put(arm_regulator);
> > + pr_dbg("vddint regulator not ready, defer\n");
> > + return -EPROBE_DEFER;
> > + } else if (IS_ERR(int_regulator)) {
> > + regulator_put(arm_regulator);
> > + pr_err("failed to get regulator vddint\n");
> > + 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 +653,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
>
> --
> viresh