From patchwork Fri Nov 18 00:03:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 9435559 X-Patchwork-Delegate: rui.zhang@intel.com 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 3C3A36047D for ; Fri, 18 Nov 2016 00:09:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D00F2936E for ; Fri, 18 Nov 2016 00:09:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 21CFB293B8; Fri, 18 Nov 2016 00:09:13 +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=unavailable 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 C6CE32936E for ; Fri, 18 Nov 2016 00:09:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750849AbcKRAI4 (ORCPT ); Thu, 17 Nov 2016 19:08:56 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:50322 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751476AbcKRAGG (ORCPT ); Thu, 17 Nov 2016 19:06:06 -0500 Received: from localhost ([127.0.0.1] helo=[127.0.1.1]) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1c7WeZ-0000eg-18; Fri, 18 Nov 2016 01:03:39 +0100 Message-Id: <20161117234810.192106647@linutronix.de> User-Agent: quilt/0.63-1 Date: Fri, 18 Nov 2016 00:03:26 -0000 From: Thomas Gleixner To: LKML Cc: Zhang Rui , Eduardo Valentin , linux-pm@vger.kernel.org, Peter Zijlstra , x86@kernel.org, rt@linutronix.de, Borislav Petkov Subject: [patch 04/12] thermal/x86_pkg_temp: Sanitize callback (de)initialization References: <20161117231435.891545908@linutronix.de> MIME-Version: 1.0 Content-Disposition: inline; filename=thermal-x86_pkg_temp--Sanitize-callback--de-initialization.patch 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 The threshold callbacks are installed before the initialization of the online cpus has succeeded and removed after the teardown has been done. That's both wrong as callbacks might be invoked into a half initialized or torn down state. Move them to the proper places: Last in init() and first in exit(). While at it shorten the insane long and horrible named function names. Signed-off-by: Thomas Gleixner --- drivers/thermal/x86_pkg_temp_thermal.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/drivers/thermal/x86_pkg_temp_thermal.c +++ b/drivers/thermal/x86_pkg_temp_thermal.c @@ -281,7 +281,7 @@ static struct thermal_zone_device_ops tz .set_trip_temp = sys_set_trip_temp, }; -static bool pkg_temp_thermal_platform_thermal_rate_control(void) +static bool pkg_thermal_rate_control(void) { return true; } @@ -355,7 +355,7 @@ static void pkg_temp_thermal_threshold_w } } -static int pkg_temp_thermal_platform_thermal_notify(__u64 msr_val) +static int pkg_thermal_notify(__u64 msr_val) { unsigned long flags; int cpu = smp_processor_id(); @@ -579,10 +579,6 @@ static int __init pkg_temp_thermal_init( return -ENODEV; spin_lock_init(&pkg_work_lock); - platform_thermal_package_notify = - pkg_temp_thermal_platform_thermal_notify; - platform_thermal_package_rate_control = - pkg_temp_thermal_platform_thermal_rate_control; cpu_notifier_register_begin(); for_each_online_cpu(i) @@ -591,6 +587,9 @@ static int __init pkg_temp_thermal_init( __register_hotcpu_notifier(&pkg_temp_thermal_notifier); cpu_notifier_register_done(); + platform_thermal_package_notify = pkg_thermal_notify; + platform_thermal_package_rate_control = pkg_thermal_rate_control; + pkg_temp_debugfs_init(); /* Don't care if fails */ return 0; @@ -600,9 +599,6 @@ static int __init pkg_temp_thermal_init( put_core_offline(i); cpu_notifier_register_done(); kfree(pkg_work_scheduled); - platform_thermal_package_notify = NULL; - platform_thermal_package_rate_control = NULL; - return -ENODEV; } @@ -611,6 +607,9 @@ static void __exit pkg_temp_thermal_exit struct phy_dev_entry *phdev, *n; int i; + platform_thermal_package_notify = NULL; + platform_thermal_package_rate_control = NULL; + cpu_notifier_register_begin(); __unregister_hotcpu_notifier(&pkg_temp_thermal_notifier); mutex_lock(&phy_dev_list_mutex); @@ -625,8 +624,6 @@ static void __exit pkg_temp_thermal_exit kfree(phdev); } mutex_unlock(&phy_dev_list_mutex); - platform_thermal_package_notify = NULL; - platform_thermal_package_rate_control = NULL; for_each_online_cpu(i) cancel_delayed_work_sync( &per_cpu(pkg_temp_thermal_threshold_work, i));