IA32_PACKAGE_THERM_STATUS can supply a thermal status from a package level granularity. It is shared in each physical processor package. Now put it under /sys directory. Signed-off-by: Chen Gong <gong.chen@xxxxxxxxxxxxxxx> --- Documentation/hwmon/sysfs-interface | 5 +++++ arch/x86/include/asm/msr-index.h | 1 + drivers/hwmon/coretemp.c | 16 ++++++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Documentation/hwmon/sysfs-interface b/Documentation/hwmon/sysfs-interface index d4e2917..96e9f18 100644 --- a/Documentation/hwmon/sysfs-interface +++ b/Documentation/hwmon/sysfs-interface @@ -284,6 +284,11 @@ temp[1-*]_input Temperature input value. Unit: millidegree Celsius RO +pkg_temp[1-*]_input + Package temperature input value. + Unit: millidegree Celsius + RO + temp[1-*]_crit Temperature critical value, typically greater than corresponding temp_max values. Unit: millidegree Celsius diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index 8c7ae43..5d4837b 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -228,6 +228,7 @@ #define THERM_INT_HIGH_ENABLE (1 << 1) #define MSR_IA32_THERM_STATUS 0x0000019c +#define MSR_IA32_PACKAGE_THERM_STATUS 0x000001b1 #define THERM_STATUS_PROCHOT (1 << 0) diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c index 05344af..b89f6a2 100644 --- a/drivers/hwmon/coretemp.c +++ b/drivers/hwmon/coretemp.c @@ -39,8 +39,8 @@ #define DRVNAME "coretemp" -typedef enum { SHOW_TEMP, SHOW_TJMAX, SHOW_TTARGET, SHOW_LABEL, - SHOW_NAME } SHOW; +typedef enum { SHOW_TEMP, SHOW_PKG_TEMP, SHOW_TJMAX, SHOW_TTARGET, + SHOW_LABEL, SHOW_NAME } SHOW; /* * Functions declaration @@ -57,6 +57,7 @@ struct coretemp_data { char valid; /* zero until following fields are valid */ unsigned long last_updated; /* in jiffies */ int temp; + int pkg_temp; int tjmax; int ttarget; u8 alarm; @@ -97,6 +98,8 @@ static ssize_t show_temp(struct device *dev, if (attr->index == SHOW_TEMP) err = data->valid ? sprintf(buf, "%d\n", data->temp) : -EAGAIN; + else if (attr->index == SHOW_PKG_TEMP) + err = sprintf(buf, "%d\n", data->pkg_temp); else if (attr->index == SHOW_TJMAX) err = sprintf(buf, "%d\n", data->tjmax); else @@ -106,6 +109,8 @@ static ssize_t show_temp(struct device *dev, static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, SHOW_TEMP); +static SENSOR_DEVICE_ATTR(pkg_temp1_input, S_IRUGO, show_temp, NULL, + SHOW_PKG_TEMP); static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, show_temp, NULL, SHOW_TJMAX); static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO, show_temp, NULL, @@ -119,6 +124,7 @@ static struct attribute *coretemp_attributes[] = { &sensor_dev_attr_temp1_label.dev_attr.attr, &dev_attr_temp1_crit_alarm.attr, &sensor_dev_attr_temp1_input.dev_attr.attr, + &sensor_dev_attr_pkg_temp1_input.dev_attr.attr, &sensor_dev_attr_temp1_crit.dev_attr.attr, NULL }; @@ -130,6 +136,7 @@ static const struct attribute_group coretemp_group = { static struct coretemp_data *coretemp_update_device(struct device *dev) { struct coretemp_data *data = dev_get_drvdata(dev); + int err; mutex_lock(&data->update_lock); @@ -137,6 +144,11 @@ static struct coretemp_data *coretemp_update_device(struct device *dev) u32 eax, edx; data->valid = 0; + err = rdmsr_safe_on_cpu(data->id, + MSR_IA32_PACKAGE_THERM_STATUS, &eax, &edx); + if (err == 0) + data->pkg_temp = data->tjmax - (((eax >> 16) + & 0x7f) * 1000); rdmsr_on_cpu(data->id, MSR_IA32_THERM_STATUS, &eax, &edx); data->alarm = (eax >> 5) & 1; /* update only if data has been valid */ -- 1.7.1.571.gba4d01 _______________________________________________ lm-sensors mailing list lm-sensors@xxxxxxxxxxxxxx http://lists.lm-sensors.org/mailman/listinfo/lm-sensors