linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][v2] cpufreq: Bring CPUs up even if cpufreq_online failed
@ 2017-04-09  5:45 Chen Yu
  2017-04-10 21:21 ` Rafael J. Wysocki
  2017-04-11  6:11 ` Viresh Kumar
  0 siblings, 2 replies; 3+ messages in thread
From: Chen Yu @ 2017-04-09  5:45 UTC (permalink / raw)
  To: Chen Yu
  Cc: Rafael J. Wysocki, Viresh Kumar, Sebastian Andrzej Siewior,
	Len Brown, linux-pm, linux-kernel, Stable # 4 . 9+

There is a report that after
commit 27622b061eb4 ("cpufreq: Convert to hotplug state machine"),
the normal CPU offline/online cycle failed on some platforms.
According to the ftrace result, this problem was triggered on
platforms using acpi-freq as the default cpufreq driver,
and due to the lack of some ACPI freq method(_PCT eg), the
cpufreq_online failed and returned a negative value, thus the CPU
hotplug statemachine rollbacked the CPU online process. Actually
from the user's perspective the failure of cpufreq_online should
not prevent that CPU from being brought up, although cpufreq might
not work on that CPU. BTW, during system bootup the cpufreq_online
is not invoked via cpuhotplug statemachine but by the cpufreq device
creation process, thus the APs can be brought up although cpufreq_online
failed in that stage.

This patch ignores the return value of cpufreq_online/offline and
let the cpufreq framework to deal with the failure that, cpufreq_online()
will do a proper rollback in that case. And if the _PCT is missing,
the acpi cpufreq driver will print a warning if the corresponding
debug options have been enabled.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=194581
Fixes: 27622b061eb4 ("cpufreq: Convert to hotplug state machine")
Reported-and-tested-by: Tomasz Maciej Nowak <tmn505@gmail.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Len Brown <lenb@kernel.org>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: Stable <stable@vger.kernel.org> # 4.9+
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
---
v2:
 - According to Rafael and Sebastian's suggestion, remove
   the error log in cpuhp_cpufreq_online/offline, and let
   the cpufreq_online and cpufreq_offline to print the warning
   and do the necessary rollback if they failed.
---
 drivers/cpufreq/cpufreq.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index bc96d42..0e3f649 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2398,6 +2398,20 @@ EXPORT_SYMBOL_GPL(cpufreq_boost_enabled);
  *********************************************************************/
 static enum cpuhp_state hp_online;
 
+static int cpuhp_cpufreq_online(unsigned int cpu)
+{
+	cpufreq_online(cpu);
+
+	return 0;
+}
+
+static int cpuhp_cpufreq_offline(unsigned int cpu)
+{
+	cpufreq_offline(cpu);
+
+	return 0;
+}
+
 /**
  * cpufreq_register_driver - register a CPU Frequency driver
  * @driver_data: A struct cpufreq_driver containing the values#
@@ -2460,8 +2474,8 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
 	}
 
 	ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "cpufreq:online",
-					cpufreq_online,
-					cpufreq_offline);
+					cpuhp_cpufreq_online,
+					cpuhp_cpufreq_offline);
 	if (ret < 0)
 		goto err_if_unreg;
 	hp_online = ret;
-- 
2.7.4

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

* Re: [PATCH][v2] cpufreq: Bring CPUs up even if cpufreq_online failed
  2017-04-09  5:45 [PATCH][v2] cpufreq: Bring CPUs up even if cpufreq_online failed Chen Yu
@ 2017-04-10 21:21 ` Rafael J. Wysocki
  2017-04-11  6:11 ` Viresh Kumar
  1 sibling, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2017-04-10 21:21 UTC (permalink / raw)
  To: Chen Yu, Viresh Kumar
  Cc: Rafael J. Wysocki, Sebastian Andrzej Siewior, Len Brown,
	Linux PM, Linux Kernel Mailing List, Srinivas Pandruvada

On Sun, Apr 9, 2017 at 7:45 AM, Chen Yu <yu.c.chen@intel.com> wrote:
> There is a report that after
> commit 27622b061eb4 ("cpufreq: Convert to hotplug state machine"),
> the normal CPU offline/online cycle failed on some platforms.
> According to the ftrace result, this problem was triggered on
> platforms using acpi-freq as the default cpufreq driver,
> and due to the lack of some ACPI freq method(_PCT eg), the
> cpufreq_online failed and returned a negative value, thus the CPU
> hotplug statemachine rollbacked the CPU online process. Actually
> from the user's perspective the failure of cpufreq_online should
> not prevent that CPU from being brought up, although cpufreq might
> not work on that CPU. BTW, during system bootup the cpufreq_online
> is not invoked via cpuhotplug statemachine but by the cpufreq device
> creation process, thus the APs can be brought up although cpufreq_online
> failed in that stage.
>
> This patch ignores the return value of cpufreq_online/offline and
> let the cpufreq framework to deal with the failure that, cpufreq_online()
> will do a proper rollback in that case. And if the _PCT is missing,
> the acpi cpufreq driver will print a warning if the corresponding
> debug options have been enabled.
>
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=194581
> Fixes: 27622b061eb4 ("cpufreq: Convert to hotplug state machine")
> Reported-and-tested-by: Tomasz Maciej Nowak <tmn505@gmail.com>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Cc: Len Brown <lenb@kernel.org>
> Cc: linux-pm@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: Stable <stable@vger.kernel.org> # 4.9+
> Signed-off-by: Chen Yu <yu.c.chen@intel.com>
> ---
> v2:
>  - According to Rafael and Sebastian's suggestion, remove
>    the error log in cpuhp_cpufreq_online/offline, and let
>    the cpufreq_online and cpufreq_offline to print the warning
>    and do the necessary rollback if they failed.
> ---
>  drivers/cpufreq/cpufreq.c | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index bc96d42..0e3f649 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -2398,6 +2398,20 @@ EXPORT_SYMBOL_GPL(cpufreq_boost_enabled);
>   *********************************************************************/
>  static enum cpuhp_state hp_online;
>
> +static int cpuhp_cpufreq_online(unsigned int cpu)
> +{
> +       cpufreq_online(cpu);
> +
> +       return 0;
> +}
> +
> +static int cpuhp_cpufreq_offline(unsigned int cpu)
> +{
> +       cpufreq_offline(cpu);
> +
> +       return 0;
> +}
> +
>  /**
>   * cpufreq_register_driver - register a CPU Frequency driver
>   * @driver_data: A struct cpufreq_driver containing the values#
> @@ -2460,8 +2474,8 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
>         }
>
>         ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "cpufreq:online",
> -                                       cpufreq_online,
> -                                       cpufreq_offline);
> +                                       cpuhp_cpufreq_online,
> +                                       cpuhp_cpufreq_offline);
>         if (ret < 0)
>                 goto err_if_unreg;
>         hp_online = ret;
> --
> 2.7.4

That's straightforward enough.

Concerns, worries, better ideas?

Thanks,
Rafael

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

* Re: [PATCH][v2] cpufreq: Bring CPUs up even if cpufreq_online failed
  2017-04-09  5:45 [PATCH][v2] cpufreq: Bring CPUs up even if cpufreq_online failed Chen Yu
  2017-04-10 21:21 ` Rafael J. Wysocki
@ 2017-04-11  6:11 ` Viresh Kumar
  1 sibling, 0 replies; 3+ messages in thread
From: Viresh Kumar @ 2017-04-11  6:11 UTC (permalink / raw)
  To: Chen Yu
  Cc: Rafael J. Wysocki, Sebastian Andrzej Siewior, Len Brown,
	linux-pm, linux-kernel, Stable # 4 . 9+

On 09-04-17, 13:45, Chen Yu wrote:
> There is a report that after
> commit 27622b061eb4 ("cpufreq: Convert to hotplug state machine"),
> the normal CPU offline/online cycle failed on some platforms.
> According to the ftrace result, this problem was triggered on
> platforms using acpi-freq as the default cpufreq driver,
> and due to the lack of some ACPI freq method(_PCT eg), the
> cpufreq_online failed and returned a negative value, thus the CPU
> hotplug statemachine rollbacked the CPU online process. Actually
> from the user's perspective the failure of cpufreq_online should
> not prevent that CPU from being brought up, although cpufreq might
> not work on that CPU. BTW, during system bootup the cpufreq_online
> is not invoked via cpuhotplug statemachine but by the cpufreq device
> creation process, thus the APs can be brought up although cpufreq_online
> failed in that stage.
> 
> This patch ignores the return value of cpufreq_online/offline and
> let the cpufreq framework to deal with the failure that, cpufreq_online()
> will do a proper rollback in that case. And if the _PCT is missing,
> the acpi cpufreq driver will print a warning if the corresponding
> debug options have been enabled.
> 
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=194581
> Fixes: 27622b061eb4 ("cpufreq: Convert to hotplug state machine")
> Reported-and-tested-by: Tomasz Maciej Nowak <tmn505@gmail.com>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Cc: Len Brown <lenb@kernel.org>
> Cc: linux-pm@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: Stable <stable@vger.kernel.org> # 4.9+
> Signed-off-by: Chen Yu <yu.c.chen@intel.com>
> ---
> v2:
>  - According to Rafael and Sebastian's suggestion, remove
>    the error log in cpuhp_cpufreq_online/offline, and let
>    the cpufreq_online and cpufreq_offline to print the warning
>    and do the necessary rollback if they failed.
> ---
>  drivers/cpufreq/cpufreq.c | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index bc96d42..0e3f649 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -2398,6 +2398,20 @@ EXPORT_SYMBOL_GPL(cpufreq_boost_enabled);
>   *********************************************************************/
>  static enum cpuhp_state hp_online;
>  
> +static int cpuhp_cpufreq_online(unsigned int cpu)
> +{
> +	cpufreq_online(cpu);
> +
> +	return 0;
> +}
> +
> +static int cpuhp_cpufreq_offline(unsigned int cpu)
> +{
> +	cpufreq_offline(cpu);
> +
> +	return 0;
> +}
> +
>  /**
>   * cpufreq_register_driver - register a CPU Frequency driver
>   * @driver_data: A struct cpufreq_driver containing the values#
> @@ -2460,8 +2474,8 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
>  	}
>  
>  	ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "cpufreq:online",
> -					cpufreq_online,
> -					cpufreq_offline);
> +					cpuhp_cpufreq_online,
> +					cpuhp_cpufreq_offline);
>  	if (ret < 0)
>  		goto err_if_unreg;
>  	hp_online = ret;

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

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

end of thread, other threads:[~2017-04-11  6:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-09  5:45 [PATCH][v2] cpufreq: Bring CPUs up even if cpufreq_online failed Chen Yu
2017-04-10 21:21 ` Rafael J. Wysocki
2017-04-11  6:11 ` Viresh Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).