lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <D6D887BA8C9DFF48B5233887EF04654105C1173BCE@bgsmsx502.gar.corp.intel.com>
Date:	Sat, 18 Dec 2010 19:44:37 +0530
From:	"R, Durgadoss" <durgadoss.r@...el.com>
To:	"Yu, Fenghua" <fenghua.yu@...el.com>,
	"khali@...ux-fr.org" <khali@...ux-fr.org>,
	Guenter Roeck <guenter.roeck@...csson.com>,
	"Brown, Len" <len.brown@...el.com>,
	"mingo@...hat.com" <mingo@...hat.com>,
	"hpa@...or.com" <hpa@...or.com>
CC:	"lm-sensors@...sensors.org" <lm-sensors@...sensors.org>,
	"x86@...nel.org" <x86@...nel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Patch[2/2] Adding_Notification_Support_to_Coretemp

Hi,

This is the second patch in the series.
This patch adds support for coretemp to notify the
threshold violations using netlink events.

This patch has a dependency on the patch 
"Adding Notification support to the thermal framework"
which can be downloaded from here:
https://patchwork.kernel.org/patch/282042/

Kindly review and merge.
------------------------------------------------------
From: Durgadoss R <durgadoss.r@...el.com>

Date: Sat, 18 Dec 2010 07:23:21 +0530
Subject: [PATCH 2/2] Adding_Notification_Support_to_Coretemp

Thos patch adds event notification support to coretemp.
Whenever a threshold interrupt occurs, it is notified to
the user space by a netlink event.

Signed-off-by: Durgadoss R <durgadoss.r@...el.com>

---
 drivers/hwmon/coretemp.c |   45 +++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 025902f..c28a61f 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -37,9 +37,16 @@
 #include <asm/processor.h>
 #include <asm/smp.h>
 #include <asm/mce.h>
+#include <linux/thermal.h>
 
 #define DRVNAME	"coretemp"
 
+/* An identification number to the DTS sensor.
+ * This will help the user space to figure out which
+ * sensor caused the event
+ */
+#define DTS_ID 0
+
 enum attributes { SHOW_TEMP, SHOW_TJMAX, CORE_TTARGET, CORE_TMIN, SHOW_LABEL,
 		SHOW_NAME, SHOW_CRIT_ALARM, SHOW_MAX_ALARM } attrs;
 
@@ -68,6 +75,22 @@ struct coretemp_data {
 static void update_alarm(struct coretemp_data *data);
 static int set_core_threshold(struct coretemp_data *data, int temp, int thres);
 
+/* Interrupt Handlers for core/package thresholds */
+struct work_struct *t0_netlink_handlr;
+struct work_struct *t1_netlink_handlr;
+
+/* Send netlink event for DTS sensor reaching threshold0 */
+static void gen_netlink_t0(struct work_struct *work)
+{
+	generate_netlink_event(DTS_ID, THERMAL_AUX0);
+}
+
+/* Send netlink event for DTS sensor reaching threshold1 */
+static void gen_netlink_t1(struct work_struct *work)
+{
+	generate_netlink_event(DTS_ID, THERMAL_AUX1);
+}
+
 /*
  * Sysfs stuff
  */
@@ -368,15 +391,19 @@ static int coretemp_interrupt(__u64 msr_val)
 {
 
 	if (msr_val & THERM_LOG_THRESHOLD0) {
-		if (!(msr_val & THERM_STATUS_THRESHOLD0))
+		if (!(msr_val & THERM_STATUS_THRESHOLD0)) {
 			pr_info("%s:Lower Threshold Reached\n", __func__);
+			schedule_work(t0_netlink_handlr);
+		}
 		/* Reset the Threshold0 interrupt */
 		wrmsrl(MSR_IA32_THERM_STATUS, msr_val & ~THERM_LOG_THRESHOLD0);
 	}
 
 	if (msr_val & THERM_LOG_THRESHOLD1) {
-		if (msr_val & THERM_STATUS_THRESHOLD1)
+		if (msr_val & THERM_STATUS_THRESHOLD1) {
 			pr_info("%s:Upper Threshold Reached\n", __func__);
+			schedule_work(t1_netlink_handlr);
+		}
 		/* Reset the Threshold1 interrupt */
 		wrmsrl(MSR_IA32_THERM_STATUS, msr_val & ~THERM_LOG_THRESHOLD1);
 	}
@@ -743,6 +770,20 @@ static int __init coretemp_init(void)
 #endif
 
 	register_hotcpu_notifier(&coretemp_cpu_notifier);
+
+	/* Initialize the Interrupt Handlers */
+	t0_netlink_handlr = kzalloc(sizeof(struct work_struct), GFP_KERNEL);
+	if (!t0_netlink_handlr)
+		return -ENOMEM;
+
+	t1_netlink_handlr = kzalloc(sizeof(struct work_struct), GFP_KERNEL);
+	if (!t1_netlink_handlr) {
+		kfree(t0_netlink_handlr);
+		return -ENOMEM;
+	}
+	INIT_WORK(t0_netlink_handlr, (void *)gen_netlink_t0);
+	INIT_WORK(t1_netlink_handlr, (void *)gen_netlink_t1);
+
 	return 0;
 
 #ifndef CONFIG_HOTPLUG_CPU
-- 
1.6.5.2


Download attachment "0002-Adding_Notification_Support_to_Coretemp.patch" of type "application/octet-stream" (3112 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ