Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1524914

[patch 04/12] thermal/x86_pkg_temp: Sanitize callback (de)initialization

From Thomas Gleixner <tglx@linutronix.de>
Newsgroups linux.kernel
Subject [patch 04/12] thermal/x86_pkg_temp: Sanitize callback (de)initialization
Date 2016-11-18 01:10 +0100
Message-ID <sEEUG-7T0-31@gated-at.bofh.it> (permalink)
References <sEEUF-7T0-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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 <tglx@linutronix.de>
---
 drivers/thermal/x86_pkg_temp_thermal.c |   19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

--- 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));

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[patch 00/12] thermal/x86_pkg_temp: Sanitize yet another hotplug and  locking trainwreck Thomas Gleixner <tglx@linutronix.de> - 2016-11-18 01:10 +0100
  [patch 12/12] thermal/x86 pkg temp: Convert to hotplug state machine Thomas Gleixner <tglx@linutronix.de> - 2016-11-18 01:10 +0100
  [patch 01/12] thermal/x86_pkg_temp: Cleanup thermal interrupt handling Thomas Gleixner <tglx@linutronix.de> - 2016-11-18 01:10 +0100
  [patch 11/12] thermal/x86_pkg_temp: Sanitize package management Thomas Gleixner <tglx@linutronix.de> - 2016-11-18 01:10 +0100
  [patch 05/12] thermal/x86_pkg_temp: Get rid of ref counting Thomas Gleixner <tglx@linutronix.de> - 2016-11-18 01:10 +0100
  [patch 08/12] thermal/x86_pkg_temp: Sanitize locking Thomas Gleixner <tglx@linutronix.de> - 2016-11-18 01:10 +0100
  [patch 04/12] thermal/x86_pkg_temp: Sanitize callback  (de)initialization Thomas Gleixner <tglx@linutronix.de> - 2016-11-18 01:10 +0100
  [patch 10/12] thermal/x86_pkg_temp: Move work into package struct Thomas Gleixner <tglx@linutronix.de> - 2016-11-18 01:10 +0100
  Re: [patch 00/12] thermal/x86_pkg_temp: Sanitize yet another  hotplug and locking trainwreck "Pandruvada, Srinivas" <srinivas.pandruvada@intel.com> - 2016-11-21 21:10 +0100
    Re: [patch 00/12] thermal/x86_pkg_temp: Sanitize yet another hotplug  and locking trainwreck Thomas Gleixner <tglx@linutronix.de> - 2016-11-21 22:40 +0100
      Re: [patch 00/12] thermal/x86_pkg_temp: Sanitize yet another  hotplug and locking trainwreck "Pandruvada, Srinivas" <srinivas.pandruvada@intel.com> - 2016-11-22 00:20 +0100
        Re: [patch 00/12] thermal/x86_pkg_temp: Sanitize yet another hotplug  and locking trainwreck Thomas Gleixner <tglx@linutronix.de> - 2016-11-22 10:10 +0100

csiph-web