All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cpufreq: powernv: Register the driver with reboot notifier
@ 2014-08-14 11:19 ` Shilpasri G Bhat
  0 siblings, 0 replies; 16+ messages in thread
From: Shilpasri G Bhat @ 2014-08-14 11:19 UTC (permalink / raw)
  To: benh, linuxppc-dev
  Cc: rjw, viresh.kumar, linux-pm, linux-kernel, Shilpasri G Bhat

This patch ensures the cpus to kexec/reboot at nominal frequency.
Nominal frequency is the highest cpu frequency on PowerPC at
which the cores can run without getting throttled.

If the host kernel had set the cpus to a low pstate and then it
kexecs/reboots to a cpufreq disabled kernel it would cause the target
kernel to perform poorly. It will also increase the boot up time of
the target kernel. So set the cpus to high pstate, in this case to
nominal frequency before rebooting to avoid such scenarios.

The reboot notifier will suspend the cpufreq governor and enable
nominal frequency to be set during a reboot/kexec similar to the
suspend operartion.

Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
Reviewed-by: Preeti U Murthy <preeti@linux.vnet.ibm.com>
---
 drivers/cpufreq/powernv-cpufreq.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
index 379c083..e9f3d3a 100644
--- a/drivers/cpufreq/powernv-cpufreq.c
+++ b/drivers/cpufreq/powernv-cpufreq.c
@@ -26,6 +26,7 @@
 #include <linux/cpufreq.h>
 #include <linux/smp.h>
 #include <linux/of.h>
+#include <linux/reboot.h>
 
 #include <asm/cputhreads.h>
 #include <asm/firmware.h>
@@ -314,9 +315,21 @@ static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy)
 	for (i = 0; i < threads_per_core; i++)
 		cpumask_set_cpu(base + i, policy->cpus);
 
+	policy->suspend_freq = pstate_id_to_freq(powernv_pstate_info.nominal);
 	return cpufreq_table_validate_and_show(policy, powernv_freqs);
 }
 
+static int powernv_cpufreq_reboot_notifier(struct notifier_block *nb,
+				unsigned long action, void *unused)
+{
+	cpufreq_suspend();
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block powernv_cpufreq_reboot_nb = {
+	.notifier_call = powernv_cpufreq_reboot_notifier,
+};
+
 static struct cpufreq_driver powernv_cpufreq_driver = {
 	.name		= "powernv-cpufreq",
 	.flags		= CPUFREQ_CONST_LOOPS,
@@ -325,6 +338,7 @@ static struct cpufreq_driver powernv_cpufreq_driver = {
 	.target_index	= powernv_cpufreq_target_index,
 	.get		= powernv_cpufreq_get,
 	.attr		= powernv_cpu_freq_attr,
+	.suspend        = cpufreq_generic_suspend,
 };
 
 static int __init powernv_cpufreq_init(void)
@@ -342,12 +356,14 @@ static int __init powernv_cpufreq_init(void)
 		return rc;
 	}
 
+	register_reboot_notifier(&powernv_cpufreq_reboot_nb);
 	return cpufreq_register_driver(&powernv_cpufreq_driver);
 }
 module_init(powernv_cpufreq_init);
 
 static void __exit powernv_cpufreq_exit(void)
 {
+	unregister_reboot_notifier(&powernv_cpufreq_reboot_nb);
 	cpufreq_unregister_driver(&powernv_cpufreq_driver);
 }
 module_exit(powernv_cpufreq_exit);
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH] cpufreq: powernv: Register the driver with reboot notifier
@ 2014-08-14 11:19 ` Shilpasri G Bhat
  0 siblings, 0 replies; 16+ messages in thread
From: Shilpasri G Bhat @ 2014-08-14 11:19 UTC (permalink / raw)
  To: benh, linuxppc-dev
  Cc: rjw, viresh.kumar, linux-pm, linux-kernel, Shilpasri G Bhat

This patch ensures the cpus to kexec/reboot at nominal frequency.
Nominal frequency is the highest cpu frequency on PowerPC at
which the cores can run without getting throttled.

If the host kernel had set the cpus to a low pstate and then it
kexecs/reboots to a cpufreq disabled kernel it would cause the target
kernel to perform poorly. It will also increase the boot up time of
the target kernel. So set the cpus to high pstate, in this case to
nominal frequency before rebooting to avoid such scenarios.

The reboot notifier will suspend the cpufreq governor and enable
nominal frequency to be set during a reboot/kexec similar to the
suspend operartion.

Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
Reviewed-by: Preeti U Murthy <preeti@linux.vnet.ibm.com>
---
 drivers/cpufreq/powernv-cpufreq.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
index 379c083..e9f3d3a 100644
--- a/drivers/cpufreq/powernv-cpufreq.c
+++ b/drivers/cpufreq/powernv-cpufreq.c
@@ -26,6 +26,7 @@
 #include <linux/cpufreq.h>
 #include <linux/smp.h>
 #include <linux/of.h>
+#include <linux/reboot.h>
 
 #include <asm/cputhreads.h>
 #include <asm/firmware.h>
@@ -314,9 +315,21 @@ static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy)
 	for (i = 0; i < threads_per_core; i++)
 		cpumask_set_cpu(base + i, policy->cpus);
 
+	policy->suspend_freq = pstate_id_to_freq(powernv_pstate_info.nominal);
 	return cpufreq_table_validate_and_show(policy, powernv_freqs);
 }
 
+static int powernv_cpufreq_reboot_notifier(struct notifier_block *nb,
+				unsigned long action, void *unused)
+{
+	cpufreq_suspend();
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block powernv_cpufreq_reboot_nb = {
+	.notifier_call = powernv_cpufreq_reboot_notifier,
+};
+
 static struct cpufreq_driver powernv_cpufreq_driver = {
 	.name		= "powernv-cpufreq",
 	.flags		= CPUFREQ_CONST_LOOPS,
@@ -325,6 +338,7 @@ static struct cpufreq_driver powernv_cpufreq_driver = {
 	.target_index	= powernv_cpufreq_target_index,
 	.get		= powernv_cpufreq_get,
 	.attr		= powernv_cpu_freq_attr,
+	.suspend        = cpufreq_generic_suspend,
 };
 
 static int __init powernv_cpufreq_init(void)
@@ -342,12 +356,14 @@ static int __init powernv_cpufreq_init(void)
 		return rc;
 	}
 
+	register_reboot_notifier(&powernv_cpufreq_reboot_nb);
 	return cpufreq_register_driver(&powernv_cpufreq_driver);
 }
 module_init(powernv_cpufreq_init);
 
 static void __exit powernv_cpufreq_exit(void)
 {
+	unregister_reboot_notifier(&powernv_cpufreq_reboot_nb);
 	cpufreq_unregister_driver(&powernv_cpufreq_driver);
 }
 module_exit(powernv_cpufreq_exit);
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH] cpufreq: powernv: Register the driver with reboot notifier
@ 2014-08-14 11:19 ` Shilpasri G Bhat
  0 siblings, 0 replies; 16+ messages in thread
From: Shilpasri G Bhat @ 2014-08-14 11:19 UTC (permalink / raw)
  To: benh, linuxppc-dev
  Cc: viresh.kumar, rjw, linux-kernel, Shilpasri G Bhat, linux-pm

This patch ensures the cpus to kexec/reboot at nominal frequency.
Nominal frequency is the highest cpu frequency on PowerPC at
which the cores can run without getting throttled.

If the host kernel had set the cpus to a low pstate and then it
kexecs/reboots to a cpufreq disabled kernel it would cause the target
kernel to perform poorly. It will also increase the boot up time of
the target kernel. So set the cpus to high pstate, in this case to
nominal frequency before rebooting to avoid such scenarios.

The reboot notifier will suspend the cpufreq governor and enable
nominal frequency to be set during a reboot/kexec similar to the
suspend operartion.

Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
Reviewed-by: Preeti U Murthy <preeti@linux.vnet.ibm.com>
---
 drivers/cpufreq/powernv-cpufreq.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
index 379c083..e9f3d3a 100644
--- a/drivers/cpufreq/powernv-cpufreq.c
+++ b/drivers/cpufreq/powernv-cpufreq.c
@@ -26,6 +26,7 @@
 #include <linux/cpufreq.h>
 #include <linux/smp.h>
 #include <linux/of.h>
+#include <linux/reboot.h>
 
 #include <asm/cputhreads.h>
 #include <asm/firmware.h>
@@ -314,9 +315,21 @@ static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy)
 	for (i = 0; i < threads_per_core; i++)
 		cpumask_set_cpu(base + i, policy->cpus);
 
+	policy->suspend_freq = pstate_id_to_freq(powernv_pstate_info.nominal);
 	return cpufreq_table_validate_and_show(policy, powernv_freqs);
 }
 
+static int powernv_cpufreq_reboot_notifier(struct notifier_block *nb,
+				unsigned long action, void *unused)
+{
+	cpufreq_suspend();
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block powernv_cpufreq_reboot_nb = {
+	.notifier_call = powernv_cpufreq_reboot_notifier,
+};
+
 static struct cpufreq_driver powernv_cpufreq_driver = {
 	.name		= "powernv-cpufreq",
 	.flags		= CPUFREQ_CONST_LOOPS,
@@ -325,6 +338,7 @@ static struct cpufreq_driver powernv_cpufreq_driver = {
 	.target_index	= powernv_cpufreq_target_index,
 	.get		= powernv_cpufreq_get,
 	.attr		= powernv_cpu_freq_attr,
+	.suspend        = cpufreq_generic_suspend,
 };
 
 static int __init powernv_cpufreq_init(void)
@@ -342,12 +356,14 @@ static int __init powernv_cpufreq_init(void)
 		return rc;
 	}
 
+	register_reboot_notifier(&powernv_cpufreq_reboot_nb);
 	return cpufreq_register_driver(&powernv_cpufreq_driver);
 }
 module_init(powernv_cpufreq_init);
 
 static void __exit powernv_cpufreq_exit(void)
 {
+	unregister_reboot_notifier(&powernv_cpufreq_reboot_nb);
 	cpufreq_unregister_driver(&powernv_cpufreq_driver);
 }
 module_exit(powernv_cpufreq_exit);
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH] cpufreq: powernv: Register the driver with reboot notifier
  2014-08-14 11:19 ` Shilpasri G Bhat
@ 2014-08-18  7:46   ` Viresh Kumar
  -1 siblings, 0 replies; 16+ messages in thread
From: Viresh Kumar @ 2014-08-18  7:46 UTC (permalink / raw)
  To: Shilpasri G Bhat
  Cc: Benjamin Herrenschmidt, linuxppc-dev, Rafael J. Wysocki,
	linux-pm, Linux Kernel Mailing List

On 14 August 2014 16:49, Shilpasri G Bhat
<shilpa.bhat@linux.vnet.ibm.com> wrote:
> This patch ensures the cpus to kexec/reboot at nominal frequency.
> Nominal frequency is the highest cpu frequency on PowerPC at
> which the cores can run without getting throttled.
>
> If the host kernel had set the cpus to a low pstate and then it
> kexecs/reboots to a cpufreq disabled kernel it would cause the target
> kernel to perform poorly. It will also increase the boot up time of
> the target kernel. So set the cpus to high pstate, in this case to
> nominal frequency before rebooting to avoid such scenarios.
>
> The reboot notifier will suspend the cpufreq governor and enable
> nominal frequency to be set during a reboot/kexec similar to the
> suspend operartion.
>
> Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
> Reviewed-by: Preeti U Murthy <preeti@linux.vnet.ibm.com>
> ---
>  drivers/cpufreq/powernv-cpufreq.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
> index 379c083..e9f3d3a 100644
> --- a/drivers/cpufreq/powernv-cpufreq.c
> +++ b/drivers/cpufreq/powernv-cpufreq.c
> @@ -26,6 +26,7 @@
>  #include <linux/cpufreq.h>
>  #include <linux/smp.h>
>  #include <linux/of.h>
> +#include <linux/reboot.h>
>
>  #include <asm/cputhreads.h>
>  #include <asm/firmware.h>
> @@ -314,9 +315,21 @@ static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy)
>         for (i = 0; i < threads_per_core; i++)
>                 cpumask_set_cpu(base + i, policy->cpus);
>
> +       policy->suspend_freq = pstate_id_to_freq(powernv_pstate_info.nominal);
>         return cpufreq_table_validate_and_show(policy, powernv_freqs);
>  }
>
> +static int powernv_cpufreq_reboot_notifier(struct notifier_block *nb,
> +                               unsigned long action, void *unused)
> +{
> +       cpufreq_suspend();
> +       return NOTIFY_DONE;
> +}
> +
> +static struct notifier_block powernv_cpufreq_reboot_nb = {
> +       .notifier_call = powernv_cpufreq_reboot_notifier,
> +};
> +
>  static struct cpufreq_driver powernv_cpufreq_driver = {
>         .name           = "powernv-cpufreq",
>         .flags          = CPUFREQ_CONST_LOOPS,
> @@ -325,6 +338,7 @@ static struct cpufreq_driver powernv_cpufreq_driver = {
>         .target_index   = powernv_cpufreq_target_index,
>         .get            = powernv_cpufreq_get,
>         .attr           = powernv_cpu_freq_attr,
> +       .suspend        = cpufreq_generic_suspend,

I couldn't understand why you have added a notifier here. This callback
by itself should be enough. Isn't it?

And then you have called cpufreq_suspend(), which is absolutely wrong,
from that notifier..

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] cpufreq: powernv: Register the driver with reboot notifier
@ 2014-08-18  7:46   ` Viresh Kumar
  0 siblings, 0 replies; 16+ messages in thread
From: Viresh Kumar @ 2014-08-18  7:46 UTC (permalink / raw)
  To: Shilpasri G Bhat
  Cc: linux-pm, linuxppc-dev, Linux Kernel Mailing List, Rafael J. Wysocki

On 14 August 2014 16:49, Shilpasri G Bhat
<shilpa.bhat@linux.vnet.ibm.com> wrote:
> This patch ensures the cpus to kexec/reboot at nominal frequency.
> Nominal frequency is the highest cpu frequency on PowerPC at
> which the cores can run without getting throttled.
>
> If the host kernel had set the cpus to a low pstate and then it
> kexecs/reboots to a cpufreq disabled kernel it would cause the target
> kernel to perform poorly. It will also increase the boot up time of
> the target kernel. So set the cpus to high pstate, in this case to
> nominal frequency before rebooting to avoid such scenarios.
>
> The reboot notifier will suspend the cpufreq governor and enable
> nominal frequency to be set during a reboot/kexec similar to the
> suspend operartion.
>
> Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
> Reviewed-by: Preeti U Murthy <preeti@linux.vnet.ibm.com>
> ---
>  drivers/cpufreq/powernv-cpufreq.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
> index 379c083..e9f3d3a 100644
> --- a/drivers/cpufreq/powernv-cpufreq.c
> +++ b/drivers/cpufreq/powernv-cpufreq.c
> @@ -26,6 +26,7 @@
>  #include <linux/cpufreq.h>
>  #include <linux/smp.h>
>  #include <linux/of.h>
> +#include <linux/reboot.h>
>
>  #include <asm/cputhreads.h>
>  #include <asm/firmware.h>
> @@ -314,9 +315,21 @@ static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy)
>         for (i = 0; i < threads_per_core; i++)
>                 cpumask_set_cpu(base + i, policy->cpus);
>
> +       policy->suspend_freq = pstate_id_to_freq(powernv_pstate_info.nominal);
>         return cpufreq_table_validate_and_show(policy, powernv_freqs);
>  }
>
> +static int powernv_cpufreq_reboot_notifier(struct notifier_block *nb,
> +                               unsigned long action, void *unused)
> +{
> +       cpufreq_suspend();
> +       return NOTIFY_DONE;
> +}
> +
> +static struct notifier_block powernv_cpufreq_reboot_nb = {
> +       .notifier_call = powernv_cpufreq_reboot_notifier,
> +};
> +
>  static struct cpufreq_driver powernv_cpufreq_driver = {
>         .name           = "powernv-cpufreq",
>         .flags          = CPUFREQ_CONST_LOOPS,
> @@ -325,6 +338,7 @@ static struct cpufreq_driver powernv_cpufreq_driver = {
>         .target_index   = powernv_cpufreq_target_index,
>         .get            = powernv_cpufreq_get,
>         .attr           = powernv_cpu_freq_attr,
> +       .suspend        = cpufreq_generic_suspend,

I couldn't understand why you have added a notifier here. This callback
by itself should be enough. Isn't it?

And then you have called cpufreq_suspend(), which is absolutely wrong,
from that notifier..

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] cpufreq: powernv: Register the driver with reboot notifier
  2014-08-18  7:46   ` Viresh Kumar
@ 2014-08-21  5:06     ` Shilpasri G Bhat
  -1 siblings, 0 replies; 16+ messages in thread
From: Shilpasri G Bhat @ 2014-08-21  5:06 UTC (permalink / raw)
  To: Viresh Kumar, Shilpasri G Bhat
  Cc: Benjamin Herrenschmidt, linuxppc-dev, Rafael J. Wysocki,
	linux-pm, Linux Kernel Mailing List


On 08/18/2014 01:16 PM, Viresh Kumar wrote:
> On 14 August 2014 16:49, Shilpasri G Bhat
> <shilpa.bhat@linux.vnet.ibm.com> wrote:
>> This patch ensures the cpus to kexec/reboot at nominal frequency.
>> Nominal frequency is the highest cpu frequency on PowerPC at
>> which the cores can run without getting throttled.
>>
>> If the host kernel had set the cpus to a low pstate and then it
>> kexecs/reboots to a cpufreq disabled kernel it would cause the target
>> kernel to perform poorly. It will also increase the boot up time of
>> the target kernel. So set the cpus to high pstate, in this case to
>> nominal frequency before rebooting to avoid such scenarios.
>>
>> The reboot notifier will suspend the cpufreq governor and enable
>> nominal frequency to be set during a reboot/kexec similar to the
>> suspend operartion.
>>
>> Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
>> Reviewed-by: Preeti U Murthy <preeti@linux.vnet.ibm.com>
>> ---
>>   drivers/cpufreq/powernv-cpufreq.c | 16 ++++++++++++++++
>>   1 file changed, 16 insertions(+)
>>
>> diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
>> index 379c083..e9f3d3a 100644
>> --- a/drivers/cpufreq/powernv-cpufreq.c
>> +++ b/drivers/cpufreq/powernv-cpufreq.c
>> @@ -26,6 +26,7 @@
>>   #include <linux/cpufreq.h>
>>   #include <linux/smp.h>
>>   #include <linux/of.h>
>> +#include <linux/reboot.h>
>>
>>   #include <asm/cputhreads.h>
>>   #include <asm/firmware.h>
>> @@ -314,9 +315,21 @@ static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy)
>>          for (i = 0; i < threads_per_core; i++)
>>                  cpumask_set_cpu(base + i, policy->cpus);
>>
>> +       policy->suspend_freq = pstate_id_to_freq(powernv_pstate_info.nominal);
>>          return cpufreq_table_validate_and_show(policy, powernv_freqs);
>>   }
>>
>> +static int powernv_cpufreq_reboot_notifier(struct notifier_block *nb,
>> +                               unsigned long action, void *unused)
>> +{
>> +       cpufreq_suspend();
>> +       return NOTIFY_DONE;
>> +}
>> +
>> +static struct notifier_block powernv_cpufreq_reboot_nb = {
>> +       .notifier_call = powernv_cpufreq_reboot_notifier,
>> +};
>> +
>>   static struct cpufreq_driver powernv_cpufreq_driver = {
>>          .name           = "powernv-cpufreq",
>>          .flags          = CPUFREQ_CONST_LOOPS,
>> @@ -325,6 +338,7 @@ static struct cpufreq_driver powernv_cpufreq_driver = {
>>          .target_index   = powernv_cpufreq_target_index,
>>          .get            = powernv_cpufreq_get,
>>          .attr           = powernv_cpu_freq_attr,
>> +       .suspend        = cpufreq_generic_suspend,
> I couldn't understand why you have added a notifier here. This callback
> by itself should be enough. Isn't it?
>
> And then you have called cpufreq_suspend(), which is absolutely wrong,
> from that notifier..

Hi Viresh,

The intention here is stop the cpufreq governor and then to set the cpus to
nominal frequency so as to ensure that the frequency won't be changed later.

The .suspend callback of the driver is not called during reboot/kexec.
So we need an explicit reboot notifier to call cpufreq-suspend() to
suffice the requirement.

Thanks and Regards,
Shilpa


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] cpufreq: powernv: Register the driver with reboot notifier
@ 2014-08-21  5:06     ` Shilpasri G Bhat
  0 siblings, 0 replies; 16+ messages in thread
From: Shilpasri G Bhat @ 2014-08-21  5:06 UTC (permalink / raw)
  To: Viresh Kumar, Shilpasri G Bhat
  Cc: linux-pm, linuxppc-dev, Linux Kernel Mailing List, Rafael J. Wysocki


On 08/18/2014 01:16 PM, Viresh Kumar wrote:
> On 14 August 2014 16:49, Shilpasri G Bhat
> <shilpa.bhat@linux.vnet.ibm.com> wrote:
>> This patch ensures the cpus to kexec/reboot at nominal frequency.
>> Nominal frequency is the highest cpu frequency on PowerPC at
>> which the cores can run without getting throttled.
>>
>> If the host kernel had set the cpus to a low pstate and then it
>> kexecs/reboots to a cpufreq disabled kernel it would cause the target
>> kernel to perform poorly. It will also increase the boot up time of
>> the target kernel. So set the cpus to high pstate, in this case to
>> nominal frequency before rebooting to avoid such scenarios.
>>
>> The reboot notifier will suspend the cpufreq governor and enable
>> nominal frequency to be set during a reboot/kexec similar to the
>> suspend operartion.
>>
>> Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
>> Reviewed-by: Preeti U Murthy <preeti@linux.vnet.ibm.com>
>> ---
>>   drivers/cpufreq/powernv-cpufreq.c | 16 ++++++++++++++++
>>   1 file changed, 16 insertions(+)
>>
>> diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
>> index 379c083..e9f3d3a 100644
>> --- a/drivers/cpufreq/powernv-cpufreq.c
>> +++ b/drivers/cpufreq/powernv-cpufreq.c
>> @@ -26,6 +26,7 @@
>>   #include <linux/cpufreq.h>
>>   #include <linux/smp.h>
>>   #include <linux/of.h>
>> +#include <linux/reboot.h>
>>
>>   #include <asm/cputhreads.h>
>>   #include <asm/firmware.h>
>> @@ -314,9 +315,21 @@ static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy)
>>          for (i = 0; i < threads_per_core; i++)
>>                  cpumask_set_cpu(base + i, policy->cpus);
>>
>> +       policy->suspend_freq = pstate_id_to_freq(powernv_pstate_info.nominal);
>>          return cpufreq_table_validate_and_show(policy, powernv_freqs);
>>   }
>>
>> +static int powernv_cpufreq_reboot_notifier(struct notifier_block *nb,
>> +                               unsigned long action, void *unused)
>> +{
>> +       cpufreq_suspend();
>> +       return NOTIFY_DONE;
>> +}
>> +
>> +static struct notifier_block powernv_cpufreq_reboot_nb = {
>> +       .notifier_call = powernv_cpufreq_reboot_notifier,
>> +};
>> +
>>   static struct cpufreq_driver powernv_cpufreq_driver = {
>>          .name           = "powernv-cpufreq",
>>          .flags          = CPUFREQ_CONST_LOOPS,
>> @@ -325,6 +338,7 @@ static struct cpufreq_driver powernv_cpufreq_driver = {
>>          .target_index   = powernv_cpufreq_target_index,
>>          .get            = powernv_cpufreq_get,
>>          .attr           = powernv_cpu_freq_attr,
>> +       .suspend        = cpufreq_generic_suspend,
> I couldn't understand why you have added a notifier here. This callback
> by itself should be enough. Isn't it?
>
> And then you have called cpufreq_suspend(), which is absolutely wrong,
> from that notifier..

Hi Viresh,

The intention here is stop the cpufreq governor and then to set the cpus to
nominal frequency so as to ensure that the frequency won't be changed later.

The .suspend callback of the driver is not called during reboot/kexec.
So we need an explicit reboot notifier to call cpufreq-suspend() to
suffice the requirement.

Thanks and Regards,
Shilpa

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] cpufreq: powernv: Register the driver with reboot notifier
  2014-08-21  5:06     ` Shilpasri G Bhat
@ 2014-08-21  6:26       ` Viresh Kumar
  -1 siblings, 0 replies; 16+ messages in thread
From: Viresh Kumar @ 2014-08-21  6:26 UTC (permalink / raw)
  To: Shilpasri G Bhat
  Cc: Shilpasri G Bhat, Benjamin Herrenschmidt, linuxppc-dev,
	Rafael J. Wysocki, linux-pm, Linux Kernel Mailing List

On 21 August 2014 10:36, Shilpasri G Bhat <shilpabhatppc@gmail.com> wrote:
> The intention here is stop the cpufreq governor and then to set the cpus to
> nominal frequency so as to ensure that the frequency won't be changed later.
>
> The .suspend callback of the driver is not called during reboot/kexec.
> So we need an explicit reboot notifier to call cpufreq-suspend() to
> suffice the requirement.

Hi Shilpa,

No, we can't allow any platform driver to misuse cpufreq_suspend().
Platform drivers aren't *allowed* to call this routine.

Now the deal is how do we move to nominal frequency on reboot..
@Rafael: Any suggestions? How do we ensure that governors
are stopped on these notifiers, or if there is some other solution here?

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] cpufreq: powernv: Register the driver with reboot notifier
@ 2014-08-21  6:26       ` Viresh Kumar
  0 siblings, 0 replies; 16+ messages in thread
From: Viresh Kumar @ 2014-08-21  6:26 UTC (permalink / raw)
  To: Shilpasri G Bhat
  Cc: linux-pm, Rafael J. Wysocki, Linux Kernel Mailing List,
	Shilpasri G Bhat, linuxppc-dev

On 21 August 2014 10:36, Shilpasri G Bhat <shilpabhatppc@gmail.com> wrote:
> The intention here is stop the cpufreq governor and then to set the cpus to
> nominal frequency so as to ensure that the frequency won't be changed later.
>
> The .suspend callback of the driver is not called during reboot/kexec.
> So we need an explicit reboot notifier to call cpufreq-suspend() to
> suffice the requirement.

Hi Shilpa,

No, we can't allow any platform driver to misuse cpufreq_suspend().
Platform drivers aren't *allowed* to call this routine.

Now the deal is how do we move to nominal frequency on reboot..
@Rafael: Any suggestions? How do we ensure that governors
are stopped on these notifiers, or if there is some other solution here?

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] cpufreq: powernv: Register the driver with reboot notifier
  2014-08-21  6:26       ` Viresh Kumar
  (?)
@ 2014-08-22  2:48         ` Preeti U Murthy
  -1 siblings, 0 replies; 16+ messages in thread
From: Preeti U Murthy @ 2014-08-22  2:48 UTC (permalink / raw)
  To: Viresh Kumar, Shilpasri G Bhat, Rafael J. Wysocki
  Cc: linux-pm, Rafael J. Wysocki, Linux Kernel Mailing List,
	Shilpasri G Bhat, linuxppc-dev

Hi Viresh,

On 08/21/2014 11:56 AM, Viresh Kumar wrote:
> On 21 August 2014 10:36, Shilpasri G Bhat <shilpabhatppc@gmail.com> wrote:
>> The intention here is stop the cpufreq governor and then to set the cpus to
>> nominal frequency so as to ensure that the frequency won't be changed later.
>>
>> The .suspend callback of the driver is not called during reboot/kexec.
>> So we need an explicit reboot notifier to call cpufreq-suspend() to
>> suffice the requirement.
> 
> Hi Shilpa,
> 
> No, we can't allow any platform driver to misuse cpufreq_suspend().
> Platform drivers aren't *allowed* to call this routine.

At the moment this looks like the best way forward. We need to do this
cleanly by ensuring that we stop the governors and then call into the
driver to deal with the cpu frequency in its own way during reboot. The
best way to do this would be by calling this routine. Either this or
cpufreq_suspend() should be called in the reboot path generically. The
latter might not be an enticing option for other platforms.

Regards
Preeti U Murthy
> 
> Now the deal is how do we move to nominal frequency on reboot..
> @Rafael: Any suggestions? How do we ensure that governors
> are stopped on these notifiers, or if there is some other solution here?
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
> 


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] cpufreq: powernv: Register the driver with reboot notifier
@ 2014-08-22  2:48         ` Preeti U Murthy
  0 siblings, 0 replies; 16+ messages in thread
From: Preeti U Murthy @ 2014-08-22  2:48 UTC (permalink / raw)
  To: Viresh Kumar, Shilpasri G Bhat
  Cc: linux-pm, Rafael J. Wysocki, Linux Kernel Mailing List,
	Shilpasri G Bhat, linuxppc-dev

Hi Viresh,

On 08/21/2014 11:56 AM, Viresh Kumar wrote:
> On 21 August 2014 10:36, Shilpasri G Bhat <shilpabhatppc@gmail.com> wrote:
>> The intention here is stop the cpufreq governor and then to set the cpus to
>> nominal frequency so as to ensure that the frequency won't be changed later.
>>
>> The .suspend callback of the driver is not called during reboot/kexec.
>> So we need an explicit reboot notifier to call cpufreq-suspend() to
>> suffice the requirement.
> 
> Hi Shilpa,
> 
> No, we can't allow any platform driver to misuse cpufreq_suspend().
> Platform drivers aren't *allowed* to call this routine.

At the moment this looks like the best way forward. We need to do this
cleanly by ensuring that we stop the governors and then call into the
driver to deal with the cpu frequency in its own way during reboot. The
best way to do this would be by calling this routine. Either this or
cpufreq_suspend() should be called in the reboot path generically. The
latter might not be an enticing option for other platforms.

Regards
Preeti U Murthy
> 
> Now the deal is how do we move to nominal frequency on reboot..
> @Rafael: Any suggestions? How do we ensure that governors
> are stopped on these notifiers, or if there is some other solution here?
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
> 


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] cpufreq: powernv: Register the driver with reboot notifier
@ 2014-08-22  2:48         ` Preeti U Murthy
  0 siblings, 0 replies; 16+ messages in thread
From: Preeti U Murthy @ 2014-08-22  2:48 UTC (permalink / raw)
  To: Viresh Kumar, Shilpasri G Bhat, Rafael J. Wysocki
  Cc: linuxppc-dev, Rafael J. Wysocki, Linux Kernel Mailing List,
	Shilpasri G Bhat, linux-pm

Hi Viresh,

On 08/21/2014 11:56 AM, Viresh Kumar wrote:
> On 21 August 2014 10:36, Shilpasri G Bhat <shilpabhatppc@gmail.com> wrote:
>> The intention here is stop the cpufreq governor and then to set the cpus to
>> nominal frequency so as to ensure that the frequency won't be changed later.
>>
>> The .suspend callback of the driver is not called during reboot/kexec.
>> So we need an explicit reboot notifier to call cpufreq-suspend() to
>> suffice the requirement.
> 
> Hi Shilpa,
> 
> No, we can't allow any platform driver to misuse cpufreq_suspend().
> Platform drivers aren't *allowed* to call this routine.

At the moment this looks like the best way forward. We need to do this
cleanly by ensuring that we stop the governors and then call into the
driver to deal with the cpu frequency in its own way during reboot. The
best way to do this would be by calling this routine. Either this or
cpufreq_suspend() should be called in the reboot path generically. The
latter might not be an enticing option for other platforms.

Regards
Preeti U Murthy
> 
> Now the deal is how do we move to nominal frequency on reboot..
> @Rafael: Any suggestions? How do we ensure that governors
> are stopped on these notifiers, or if there is some other solution here?
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] cpufreq: powernv: Register the driver with reboot notifier
  2014-08-22  2:48         ` Preeti U Murthy
@ 2014-08-25 10:30           ` Viresh Kumar
  -1 siblings, 0 replies; 16+ messages in thread
From: Viresh Kumar @ 2014-08-25 10:30 UTC (permalink / raw)
  To: Preeti U Murthy
  Cc: Shilpasri G Bhat, Rafael J. Wysocki, linux-pm,
	Linux Kernel Mailing List, Shilpasri G Bhat, linuxppc-dev

On 22 August 2014 08:18, Preeti U Murthy <preeti@linux.vnet.ibm.com> wrote:
> At the moment this looks like the best way forward. We need to do this
> cleanly by ensuring that we stop the governors and then call into the
> driver to deal with the cpu frequency in its own way during reboot. The
> best way to do this would be by calling this routine. Either this or
> cpufreq_suspend() should be called in the reboot path generically. The
> latter might not be an enticing option for other platforms.

Its not that I am doubting if this will work or not. But this Hack is using
routines not meant for this purpose. And that being a core routine,
things aren't that straightforward anymore.

@Rafael: Ping!!

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] cpufreq: powernv: Register the driver with reboot notifier
@ 2014-08-25 10:30           ` Viresh Kumar
  0 siblings, 0 replies; 16+ messages in thread
From: Viresh Kumar @ 2014-08-25 10:30 UTC (permalink / raw)
  To: Preeti U Murthy
  Cc: Shilpasri G Bhat, linux-pm, Rafael J. Wysocki,
	Linux Kernel Mailing List, Shilpasri G Bhat, linuxppc-dev

On 22 August 2014 08:18, Preeti U Murthy <preeti@linux.vnet.ibm.com> wrote:
> At the moment this looks like the best way forward. We need to do this
> cleanly by ensuring that we stop the governors and then call into the
> driver to deal with the cpu frequency in its own way during reboot. The
> best way to do this would be by calling this routine. Either this or
> cpufreq_suspend() should be called in the reboot path generically. The
> latter might not be an enticing option for other platforms.

Its not that I am doubting if this will work or not. But this Hack is using
routines not meant for this purpose. And that being a core routine,
things aren't that straightforward anymore.

@Rafael: Ping!!

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] cpufreq: powernv: Register the driver with reboot notifier
  2014-08-25 10:30           ` Viresh Kumar
@ 2014-08-25 10:41             ` Viresh Kumar
  -1 siblings, 0 replies; 16+ messages in thread
From: Viresh Kumar @ 2014-08-25 10:41 UTC (permalink / raw)
  To: Preeti U Murthy
  Cc: Shilpasri G Bhat, Rafael J. Wysocki, linux-pm,
	Linux Kernel Mailing List, Shilpasri G Bhat, linuxppc-dev

On 25 August 2014 16:00, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> Its not that I am doubting if this will work or not. But this Hack is using
> routines not meant for this purpose. And that being a core routine,
> things aren't that straightforward anymore.

Well if you want a working HACK for solving this, what about following ?

diff --git a/drivers/cpufreq/powernv-cpufreq.c
b/drivers/cpufreq/powernv-cpufreq.c
index af49688..d6a1742 100644
--- a/drivers/cpufreq/powernv-cpufreq.c
+++ b/drivers/cpufreq/powernv-cpufreq.c
@@ -34,6 +34,7 @@
 #define POWERNV_MAX_PSTATES    256

 static struct cpufreq_frequency_table powernv_freqs[POWERNV_MAX_PSTATES+1];
+static bool rebooting;

 /*
  * Note: The set of pstates consists of contiguous integers, the
@@ -283,6 +284,9 @@ static int powernv_cpufreq_target_index(struct
cpufreq_policy *policy,
 {
        struct powernv_smp_call_data freq_data;

+       if (unlikely(rebooting))
+               return -EBUSY;
+
        freq_data.pstate_id = powernv_freqs[new_index].driver_data;

        /*
@@ -317,6 +321,19 @@ static struct cpufreq_driver powernv_cpufreq_driver = {
        .attr           = powernv_cpu_freq_attr,
 };

+static int powernv_cpufreq_reboot_notifier(struct notifier_block *nb,
+               unsigned long action, void *unused)
+{
+       /* TODO: Get policy & index */
+       powernv_cpufreq_target_index(policy, index);
+       rebooting = true;
+       return NOTIFY_DONE;
+}
+
+static struct notifier_block powernv_cpufreq_reboot_nb = {
+       .notifier_call = powernv_cpufreq_reboot_notifier,
+};
+
 static int __init powernv_cpufreq_init(void)
 {
        int rc = 0;
@@ -328,12 +345,15 @@ static int __init powernv_cpufreq_init(void)
                return rc;
        }

-       return cpufreq_register_driver(&powernv_cpufreq_driver);
+       rc = cpufreq_register_driver(&powernv_cpufreq_driver);
+       register_reboot_notifier(&powernv_cpufreq_reboot_nb);
+       return rc;
 }
 module_init(powernv_cpufreq_init);

 static void __exit powernv_cpufreq_exit(void)
 {
+       unregister_reboot_notifier(&powernv_cpufreq_reboot_nb);
        cpufreq_unregister_driver(&powernv_cpufreq_driver);
 }
 module_exit(powernv_cpufreq_exit);

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH] cpufreq: powernv: Register the driver with reboot notifier
@ 2014-08-25 10:41             ` Viresh Kumar
  0 siblings, 0 replies; 16+ messages in thread
From: Viresh Kumar @ 2014-08-25 10:41 UTC (permalink / raw)
  To: Preeti U Murthy
  Cc: Shilpasri G Bhat, linux-pm, Rafael J. Wysocki,
	Linux Kernel Mailing List, Shilpasri G Bhat, linuxppc-dev

On 25 August 2014 16:00, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> Its not that I am doubting if this will work or not. But this Hack is using
> routines not meant for this purpose. And that being a core routine,
> things aren't that straightforward anymore.

Well if you want a working HACK for solving this, what about following ?

diff --git a/drivers/cpufreq/powernv-cpufreq.c
b/drivers/cpufreq/powernv-cpufreq.c
index af49688..d6a1742 100644
--- a/drivers/cpufreq/powernv-cpufreq.c
+++ b/drivers/cpufreq/powernv-cpufreq.c
@@ -34,6 +34,7 @@
 #define POWERNV_MAX_PSTATES    256

 static struct cpufreq_frequency_table powernv_freqs[POWERNV_MAX_PSTATES+1];
+static bool rebooting;

 /*
  * Note: The set of pstates consists of contiguous integers, the
@@ -283,6 +284,9 @@ static int powernv_cpufreq_target_index(struct
cpufreq_policy *policy,
 {
        struct powernv_smp_call_data freq_data;

+       if (unlikely(rebooting))
+               return -EBUSY;
+
        freq_data.pstate_id = powernv_freqs[new_index].driver_data;

        /*
@@ -317,6 +321,19 @@ static struct cpufreq_driver powernv_cpufreq_driver = {
        .attr           = powernv_cpu_freq_attr,
 };

+static int powernv_cpufreq_reboot_notifier(struct notifier_block *nb,
+               unsigned long action, void *unused)
+{
+       /* TODO: Get policy & index */
+       powernv_cpufreq_target_index(policy, index);
+       rebooting = true;
+       return NOTIFY_DONE;
+}
+
+static struct notifier_block powernv_cpufreq_reboot_nb = {
+       .notifier_call = powernv_cpufreq_reboot_notifier,
+};
+
 static int __init powernv_cpufreq_init(void)
 {
        int rc = 0;
@@ -328,12 +345,15 @@ static int __init powernv_cpufreq_init(void)
                return rc;
        }

-       return cpufreq_register_driver(&powernv_cpufreq_driver);
+       rc = cpufreq_register_driver(&powernv_cpufreq_driver);
+       register_reboot_notifier(&powernv_cpufreq_reboot_nb);
+       return rc;
 }
 module_init(powernv_cpufreq_init);

 static void __exit powernv_cpufreq_exit(void)
 {
+       unregister_reboot_notifier(&powernv_cpufreq_reboot_nb);
        cpufreq_unregister_driver(&powernv_cpufreq_driver);
 }
 module_exit(powernv_cpufreq_exit);

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2014-08-25 10:41 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-14 11:19 [PATCH] cpufreq: powernv: Register the driver with reboot notifier Shilpasri G Bhat
2014-08-14 11:19 ` Shilpasri G Bhat
2014-08-14 11:19 ` Shilpasri G Bhat
2014-08-18  7:46 ` Viresh Kumar
2014-08-18  7:46   ` Viresh Kumar
2014-08-21  5:06   ` Shilpasri G Bhat
2014-08-21  5:06     ` Shilpasri G Bhat
2014-08-21  6:26     ` Viresh Kumar
2014-08-21  6:26       ` Viresh Kumar
2014-08-22  2:48       ` Preeti U Murthy
2014-08-22  2:48         ` Preeti U Murthy
2014-08-22  2:48         ` Preeti U Murthy
2014-08-25 10:30         ` Viresh Kumar
2014-08-25 10:30           ` Viresh Kumar
2014-08-25 10:41           ` Viresh Kumar
2014-08-25 10:41             ` Viresh Kumar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.