Skip to contentSkip to conversation

hwmon: (coretemp) Let the user force TjMax

PATCH Applied Jean Delvare 3 participants 3 messages Sep 16, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 2/2 hwmon: (coretemp) Let the user force TjMax

On old CPUs (and even some recent Atom CPUs) TjMax can't be read from the CPU registers, so it is guessed by the driver using a complex heuristic which isn't reliable. So let users who know their CPU's TjMax pass it as a module parameter.

Cc Fenghua Yu <[email protected]>
Cc "R, Durgadoss" <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Alexander Stein <[email protected]>
---
 Documentation/hwmon/coretemp |    7 ++++---
 drivers/hwmon/coretemp.c     |   15 +++++++++++++++
 2 files changed, 19 insertions(+), 3 deletions(-)
drivers/hwmon/coretemp.c +15 -0
@@ -36,11 +36,20 @@
 #include <linux/cpu.h>
 #include <linux/pci.h>
 #include <linux/smp.h>
+#include <linux/moduleparam.h>
 #include <asm/msr.h>
 #include <asm/processor.h>
 
 #define DRVNAME	"coretemp"
 
+/*
+ * force_tjmax only matters when TjMax can't be read from the CPU itself.
+ * When set, it replaces the driver's suboptimal heuristic.
+ */
+static int force_tjmax;
+module_param_named(tjmax, force_tjmax, int, 0444);
+MODULE_PARM_DESC(tjmax, "TjMax value in degrees Celsius");
+
 #define BASE_SYSFS_ATTR_NO	2	/* Sysfs Base attr no for coretemp */
 #define NUM_REAL_CORES		16	/* Number of Real cores per cpu */
 #define CORETEMP_NAME_LENGTH	17	/* String Length of attrs */
@@ -398,6 +407,12 @@ static int get_tjmax(struct cpuinfo_x86
 		}
 	}
 
+	if (force_tjmax) {
+		dev_notice(dev, "TjMax forced to %d degrees C by user\n",
+			   force_tjmax);
+		return force_tjmax * 1000;
+	}
+
 	/*
 	 * An assumption is made for early CPUs and unreadable MSR.
 	 * NOTE: the calculated value may not be correct.
Documentation/hwmon/coretemp +4 -3
@@ -49,9 +49,10 @@ tempX_label	 - Contains string "Core X",
 		   number. For Package temp, this will be "Physical id Y",
 		   where Y is the package number.
 
-The TjMax temperature is set to 85 degrees C if undocumented model specific
-register (UMSR) 0xee has bit 30 set. If not the TjMax is 100 degrees C as
-(sometimes) documented in processor datasheet.
+On CPU models which support it, TjMax is read from a model-specific register.
+On other models, it is set to an arbitrary value based on weak heuristics.
+If these heuristics don't work for you, you can pass the correct TjMax value
+as a module parameter (tjmax).
 
 Appendix A. Known TjMax lists (TBD):
 Some information comes from ark.intel.com
Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Acked-by on v1 2/2
#1 lore raw

Re: [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Let the user force

-----Original Message-----

Quoted 11 lines

From: Jean Delvare [mailto:[email protected]]
Sent: Friday, September 16, 2011 12:24 PM
To: LM Sensors
Cc: Yu, Fenghua; R, Durgadoss; Guenter Roeck; Alexander Stein
Subject: [PATCH 2/2] hwmon: (coretemp) Let the user force TjMax

On old CPUs (and even some recent Atom CPUs) TjMax can't be read from the CPU registers, so it is guessed by the driver using a complex heuristic which isn't reliable. So let users who know their CPU's TjMax pass it as a module parameter.

Quoted 5 lines
Cc Fenghua Yu <[email protected]>
Cc "R, Durgadoss" <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Alexander Stein <[email protected]>

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#2 lore raw

Re: [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Let the user force

In reply to Jean Delvare
Quoted 11 lines · Jean Delvare

On old CPUs (and even some recent Atom CPUs) TjMax can't be read from the CPU registers, so it is guessed by the driver using a complex heuristic which isn't reliable. So let users who know their CPU's TjMax pass it as a module parameter.

Cc Fenghua Yu <[email protected]>
Cc "R, Durgadoss" <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Alexander Stein <[email protected]>

---

Applied.

Thanks,
Guenter

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors