From patchwork Tue Nov 22 17:57:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 9441861 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 954BA605EE for ; Tue, 22 Nov 2016 18:03:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CA6A27FC0 for ; Tue, 22 Nov 2016 18:03:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80FC5285C4; Tue, 22 Nov 2016 18:03:00 +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 9ABF128448 for ; Tue, 22 Nov 2016 18:02:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756338AbcKVSCT (ORCPT ); Tue, 22 Nov 2016 13:02:19 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:60553 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933867AbcKVSAI (ORCPT ); Tue, 22 Nov 2016 13:00:08 -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 1c9FJa-0000X2-QU; Tue, 22 Nov 2016 18:57:06 +0100 Message-Id: <20161122175357.191441233@linutronix.de> User-Agent: quilt/0.63-1 Date: Tue, 22 Nov 2016 17:57:06 -0000 From: Thomas Gleixner To: LKML Cc: Rui Zhang , edubezval@gmail.com, Peter Zijlstra , Borislav Petkov , linux-pm@vger.kernel.org, x86@kernel.org, rt@linutronix.de, Srinivas Pandruvada Subject: [patch V2 04/12] thermal/x86_pkg_temp: Sanitize callback (de)initialization References: <20161122175256.922158782@linutronix.de> MIME-Version: 1.0 Content-Disposition: inline; filename=thermalx86_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));