From patchwork Sat Mar 25 04:20:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Yu X-Patchwork-Id: 9644385 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 49E2760327 for ; Sat, 25 Mar 2017 04:20:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B38425223 for ; Sat, 25 Mar 2017 04:20:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C5A726E4D; Sat, 25 Mar 2017 04:20:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 11D6826E1A for ; Sat, 25 Mar 2017 04:20:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933339AbdCYEUM (ORCPT ); Sat, 25 Mar 2017 00:20:12 -0400 Received: from mga07.intel.com ([134.134.136.100]:64186 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932086AbdCYEUL (ORCPT ); Sat, 25 Mar 2017 00:20:11 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP; 24 Mar 2017 21:20:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,217,1486454400"; d="scan'208";a="64797990" Received: from yu-desktop-1.sh.intel.com ([10.239.160.134]) by orsmga002.jf.intel.com with ESMTP; 24 Mar 2017 21:20:08 -0700 From: Chen Yu To: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Sebastian Andrzej Siewior , Chen Yu , "Rafael J. Wysocki" , Viresh Kumar , "Stable # 4 . 9+" Subject: [PATCH][RFC] cpufreq: Bring CPUs up even if cpufreq_online failed Date: Sat, 25 Mar 2017 12:20:11 +0800 Message-Id: <1490415611-16945-1-git-send-email-yu.c.chen@intel.com> X-Mailer: git-send-email 2.7.4 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 the failure of cpufreq_online should not impact the whole CPU online process according to the original semantics before above patch. 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 prints a warning if there is a failure. 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 Cc: "Rafael J. Wysocki" Cc: Viresh Kumar Cc: linux-pm@vger.kernel.org Cc: Stable # 4.9+ Signed-off-by: Chen Yu --- drivers/cpufreq/cpufreq.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index b8ff617..1c13873 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2391,6 +2391,28 @@ EXPORT_SYMBOL_GPL(cpufreq_boost_enabled); *********************************************************************/ static enum cpuhp_state hp_online; +static int cpuhp_cpufreq_online(unsigned int cpu) +{ + int ret = cpufreq_online(cpu); + + if (ret) + pr_err("Failed to bring cpufreq online for CPU%u. (%d)\n", + cpu, ret); + + return 0; +} + +static int cpuhp_cpufreq_offline(unsigned int cpu) +{ + int ret = cpufreq_offline(cpu); + + if (ret) + pr_err("Failed to put cpufreq offline for CPU%u. (%d)\n", + cpu, ret); + + return 0; +} + /** * cpufreq_register_driver - register a CPU Frequency driver * @driver_data: A struct cpufreq_driver containing the values# @@ -2453,8 +2475,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;