LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] platform/x86: thinkpad_acpi: Simplify thermal mode checking
@ 2024-02-14  5:29 Vishnu Sankar
  2024-02-14  5:29 ` [PATCH 2/2] platform/x86: thinkpad_acpi: Fix to correct wrong temp reporting on some ThinkPads Vishnu Sankar
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Vishnu Sankar @ 2024-02-14  5:29 UTC (permalink / raw
  To: hdegoede, ilpo.jarvinen
  Cc: platform-driver-x86, linux-kernel, mpearson-lenovo, vsankar,
	Vishnu Sankar, Ilpo Jarvinen

Add a thermal_read_mode_check helper function to make the code
simpler during init.
This helps particularly when the new TPEC_12 mode is added in
the next patch.

Suggested-by: Ilpo Jarvinen <ilpo.jarvinen@intel.com>
Signed-off-by: Vishnu Sankar <vishnuocv@gmail.com>
---
 drivers/platform/x86/thinkpad_acpi.c | 136 +++++++++++++--------------
 1 file changed, 66 insertions(+), 70 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index c4895e9bc714..2428c8bd0fa2 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -6147,6 +6147,71 @@ struct ibm_thermal_sensors_struct {
 static enum thermal_access_mode thermal_read_mode;
 static bool thermal_use_labels;
 
+/* Function to check thermal read mode */
+static enum thermal_access_mode thermal_read_mode_check(void)
+{
+	u8 t, ta1, ta2, ver = 0;
+	int i;
+
+	if (thinkpad_id.ec_model) {
+		/*
+		 * Direct EC access mode: sensors at registers
+		 * 0x78-0x7F, 0xC0-0xC7.  Registers return 0x00 for
+		 * non-implemented, thermal sensors return 0x80 when
+		 * not available
+		 * The above rule is unfortunately flawed. This has been seen with
+		 * 0xC2 (power supply ID) causing thermal control problems.
+		 * The EC version can be determined by offset 0xEF and at least for
+		 * version 3 the Lenovo firmware team confirmed that registers 0xC0-0xC7
+		 * are not thermal registers.
+		 */
+		if (!acpi_ec_read(TP_EC_FUNCREV, &ver))
+			pr_warn("Thinkpad ACPI EC unable to access EC version\n");
+
+		ta1 = ta2 = 0;
+		for (i = 0; i < 8; i++) {
+			if (acpi_ec_read(TP_EC_THERMAL_TMP0 + i, &t)) {
+				ta1 |= t;
+			} else {
+				ta1 = 0;
+				break;
+			}
+			if (ver < 3) {
+				if (acpi_ec_read(TP_EC_THERMAL_TMP8 + i, &t)) {
+					ta2 |= t;
+				} else {
+					ta1 = 0;
+					break;
+				}
+			}
+		}
+
+		if (ta1 == 0) {
+			pr_err("ThinkPad ACPI EC access misbehaving, disabling thermal sensors access\n");
+			return TPACPI_THERMAL_NONE;
+		}
+
+		if (ver >= 3) {
+			thermal_use_labels = true;
+			return TPACPI_THERMAL_TPEC_8;
+		}
+
+		return (ta2 != 0) ? TPACPI_THERMAL_TPEC_16 : TPACPI_THERMAL_TPEC_8;
+	}
+
+	if (acpi_evalf(ec_handle, NULL, "TMP7", "qv")) {
+		if (tpacpi_is_ibm() &&
+		    acpi_evalf(ec_handle, NULL, "UPDT", "qv"))
+			/* 600e/x, 770e, 770x */
+			return TPACPI_THERMAL_ACPI_UPDT;
+		/* IBM/LENOVO DSDT EC.TMPx access, max 8 sensors */
+		return TPACPI_THERMAL_ACPI_TMP07;
+	}
+
+	/* temperatures not supported on 570, G4x, R30, R31, R32 */
+	return TPACPI_THERMAL_NONE;
+}
+
 /* idx is zero-based */
 static int thermal_get_sensor(int idx, s32 *value)
 {
@@ -6375,78 +6440,9 @@ static const struct attribute_group temp_label_attr_group = {
 
 static int __init thermal_init(struct ibm_init_struct *iibm)
 {
-	u8 t, ta1, ta2, ver = 0;
-	int i;
-	int acpi_tmp7;
-
 	vdbg_printk(TPACPI_DBG_INIT, "initializing thermal subdriver\n");
 
-	acpi_tmp7 = acpi_evalf(ec_handle, NULL, "TMP7", "qv");
-
-	if (thinkpad_id.ec_model) {
-		/*
-		 * Direct EC access mode: sensors at registers
-		 * 0x78-0x7F, 0xC0-0xC7.  Registers return 0x00 for
-		 * non-implemented, thermal sensors return 0x80 when
-		 * not available
-		 * The above rule is unfortunately flawed. This has been seen with
-		 * 0xC2 (power supply ID) causing thermal control problems.
-		 * The EC version can be determined by offset 0xEF and at least for
-		 * version 3 the Lenovo firmware team confirmed that registers 0xC0-0xC7
-		 * are not thermal registers.
-		 */
-		if (!acpi_ec_read(TP_EC_FUNCREV, &ver))
-			pr_warn("Thinkpad ACPI EC unable to access EC version\n");
-
-		ta1 = ta2 = 0;
-		for (i = 0; i < 8; i++) {
-			if (acpi_ec_read(TP_EC_THERMAL_TMP0 + i, &t)) {
-				ta1 |= t;
-			} else {
-				ta1 = 0;
-				break;
-			}
-			if (ver < 3) {
-				if (acpi_ec_read(TP_EC_THERMAL_TMP8 + i, &t)) {
-					ta2 |= t;
-				} else {
-					ta1 = 0;
-					break;
-				}
-			}
-		}
-		if (ta1 == 0) {
-			/* This is sheer paranoia, but we handle it anyway */
-			if (acpi_tmp7) {
-				pr_err("ThinkPad ACPI EC access misbehaving, falling back to ACPI TMPx access mode\n");
-				thermal_read_mode = TPACPI_THERMAL_ACPI_TMP07;
-			} else {
-				pr_err("ThinkPad ACPI EC access misbehaving, disabling thermal sensors access\n");
-				thermal_read_mode = TPACPI_THERMAL_NONE;
-			}
-		} else {
-			if (ver >= 3) {
-				thermal_read_mode = TPACPI_THERMAL_TPEC_8;
-				thermal_use_labels = true;
-			} else {
-				thermal_read_mode =
-					(ta2 != 0) ?
-					TPACPI_THERMAL_TPEC_16 : TPACPI_THERMAL_TPEC_8;
-			}
-		}
-	} else if (acpi_tmp7) {
-		if (tpacpi_is_ibm() &&
-		    acpi_evalf(ec_handle, NULL, "UPDT", "qv")) {
-			/* 600e/x, 770e, 770x */
-			thermal_read_mode = TPACPI_THERMAL_ACPI_UPDT;
-		} else {
-			/* IBM/LENOVO DSDT EC.TMPx access, max 8 sensors */
-			thermal_read_mode = TPACPI_THERMAL_ACPI_TMP07;
-		}
-	} else {
-		/* temperatures not supported on 570, G4x, R30, R31, R32 */
-		thermal_read_mode = TPACPI_THERMAL_NONE;
-	}
+	thermal_read_mode = thermal_read_mode_check();
 
 	vdbg_printk(TPACPI_DBG_INIT, "thermal is %s, mode %d\n",
 		str_supported(thermal_read_mode != TPACPI_THERMAL_NONE),
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] platform/x86: thinkpad_acpi: Fix to correct wrong temp reporting on some ThinkPads
  2024-02-14  5:29 [PATCH 1/2] platform/x86: thinkpad_acpi: Simplify thermal mode checking Vishnu Sankar
@ 2024-02-14  5:29 ` Vishnu Sankar
  2024-02-14 10:22   ` Ilpo Järvinen
  2024-02-14  9:52 ` [PATCH 1/2] platform/x86: thinkpad_acpi: Simplify thermal mode checking Ilpo Järvinen
  2024-02-14 10:16 ` Ilpo Järvinen
  2 siblings, 1 reply; 7+ messages in thread
From: Vishnu Sankar @ 2024-02-14  5:29 UTC (permalink / raw
  To: hdegoede, ilpo.jarvinen
  Cc: platform-driver-x86, linux-kernel, mpearson-lenovo, vsankar,
	Vishnu Sankar

Added non-standard thermal register support for some ThinkPads.

Some of the Thinkpads use a non-standard ECFW which use different
thermal register addresses.
This is a fix to correct the wrong temperature reporting on
those systems.

Tested on Lenovo ThinkPad L13 Yoga Gen2

Suggested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Vishnu Sankar <vishnuocv@gmail.com>
---
-Improvements as requested.
-Improved the readability in case TPACPI_THERMAL_TPEC_12.
-idx < 8 from idx idx <=7 to match idx = 8
-KILO used from linux/units.h instead of 1000.
---
---
 drivers/platform/x86/thinkpad_acpi.c | 74 +++++++++++++++++++++++++---
 1 file changed, 68 insertions(+), 6 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 2428c8bd0fa2..9be114572f17 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -69,6 +69,7 @@
 #include <linux/sysfs.h>
 #include <linux/types.h>
 #include <linux/uaccess.h>
+#include <linux/units.h>
 #include <linux/workqueue.h>
 
 #include <acpi/battery.h>
@@ -6126,12 +6127,15 @@ enum thermal_access_mode {
 	TPACPI_THERMAL_ACPI_TMP07,	/* Use ACPI TMP0-7 */
 	TPACPI_THERMAL_ACPI_UPDT,	/* Use ACPI TMP0-7 with UPDT */
 	TPACPI_THERMAL_TPEC_8,		/* Use ACPI EC regs, 8 sensors */
+	TPACPI_THERMAL_TPEC_12,		/* Use ACPI EC regs, 12 sensors */
 	TPACPI_THERMAL_TPEC_16,		/* Use ACPI EC regs, 16 sensors */
 };
 
 enum { /* TPACPI_THERMAL_TPEC_* */
 	TP_EC_THERMAL_TMP0 = 0x78,	/* ACPI EC regs TMP 0..7 */
 	TP_EC_THERMAL_TMP8 = 0xC0,	/* ACPI EC regs TMP 8..15 */
+	TP_EC_THERMAL_TMP0_NS = 0xA8,	/* ACPI EC Non-Standard regs TMP 0..7 */
+	TP_EC_THERMAL_TMP8_NS = 0xB8,	/* ACPI EC Non-standard regs TMP 8..11 */
 	TP_EC_FUNCREV      = 0xEF,      /* ACPI EC Functional revision */
 	TP_EC_THERMAL_TMP_NA = -128,	/* ACPI EC sensor not available */
 
@@ -6144,8 +6148,22 @@ struct ibm_thermal_sensors_struct {
 	s32 temp[TPACPI_MAX_THERMAL_SENSORS];
 };
 
+static const struct tpacpi_quirk thermal_quirk_table[] __initconst = {
+	/* Non-standard address for thermal registers on some ThinkPads */
+	TPACPI_Q_LNV3('R', '1', 'F', true),	/* L13 Yoga Gen 2 */
+	TPACPI_Q_LNV3('N', '2', 'U', true),	/* X13 Yoga Gen 2*/
+	TPACPI_Q_LNV3('R', '0', 'R', true),	/* L380 */
+	TPACPI_Q_LNV3('R', '1', '5', true),	/* L13 Yoga Gen 1*/
+	TPACPI_Q_LNV3('R', '1', '0', true),	/* L390 */
+	TPACPI_Q_LNV3('N', '2', 'L', true),	/* X13 Yoga Gen 1*/
+	TPACPI_Q_LNV3('R', '0', 'T', true),	/* 11e Gen5 GL*/
+	TPACPI_Q_LNV3('R', '1', 'D', true),	/* 11e Gen5 GL-R*/
+	TPACPI_Q_LNV3('R', '0', 'V', true),	/* 11e Gen5 KL-Y*/
+};
+
 static enum thermal_access_mode thermal_read_mode;
 static bool thermal_use_labels;
+static bool thermal_with_ns_address;	/*Non-standard thermal reg address*/
 
 /* Function to check thermal read mode */
 static enum thermal_access_mode thermal_read_mode_check(void)
@@ -6168,6 +6186,16 @@ static enum thermal_access_mode thermal_read_mode_check(void)
 		if (!acpi_ec_read(TP_EC_FUNCREV, &ver))
 			pr_warn("Thinkpad ACPI EC unable to access EC version\n");
 
+		/* Quirks to check non-standard EC */
+		thermal_with_ns_address = tpacpi_check_quirks(thermal_quirk_table,
+							ARRAY_SIZE(thermal_quirk_table));
+
+		/* Support for Thinkpads with non-standard address */
+		if (thermal_with_ns_address) {
+			pr_info("ECFW with non-standard thermal registers found\n");
+			return TPACPI_THERMAL_TPEC_12;
+		}
+
 		ta1 = ta2 = 0;
 		for (i = 0; i < 8; i++) {
 			if (acpi_ec_read(TP_EC_THERMAL_TMP0 + i, &t)) {
@@ -6239,6 +6267,20 @@ static int thermal_get_sensor(int idx, s32 *value)
 		}
 		break;
 
+	/* The Non-standard EC uses 12 Thermal areas */
+	case TPACPI_THERMAL_TPEC_12:
+		if (idx >= 12)
+			return -EINVAL;
+
+		t = idx < 8 ? TP_EC_THERMAL_TMP0_NS + idx :
+				TP_EC_THERMAL_TMP8_NS + (idx - 8);
+
+		if (!acpi_ec_read(t, &tmp))
+			return -EIO;
+
+		*value = tmp * KILO;
+		return 0;
+
 	case TPACPI_THERMAL_ACPI_UPDT:
 		if (idx <= 7) {
 			snprintf(tmpi, sizeof(tmpi), "TMP%c", '0' + idx);
@@ -6284,6 +6326,8 @@ static int thermal_get_sensors(struct ibm_thermal_sensors_struct *s)
 
 	if (thermal_read_mode == TPACPI_THERMAL_TPEC_16)
 		n = 16;
+	else if (thermal_read_mode == TPACPI_THERMAL_TPEC_12)
+		n = 12;
 
 	for (i = 0 ; i < n; i++) {
 		res = thermal_get_sensor(i, &s->temp[i]);
@@ -6382,18 +6426,36 @@ static struct attribute *thermal_temp_input_attr[] = {
 	NULL
 };
 
+#define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr)
+
 static umode_t thermal_attr_is_visible(struct kobject *kobj,
 				       struct attribute *attr, int n)
 {
-	if (thermal_read_mode == TPACPI_THERMAL_NONE)
+	struct device_attribute *dev_attr = to_dev_attr(attr);
+	struct sensor_device_attribute *sensor_attr =
+					to_sensor_dev_attr(dev_attr);
+
+	int idx = sensor_attr->index;
+
+	switch (thermal_read_mode) {
+	case TPACPI_THERMAL_NONE:
 		return 0;
 
-	if (attr == THERMAL_ATTRS(8) || attr == THERMAL_ATTRS(9) ||
-	    attr == THERMAL_ATTRS(10) || attr == THERMAL_ATTRS(11) ||
-	    attr == THERMAL_ATTRS(12) || attr == THERMAL_ATTRS(13) ||
-	    attr == THERMAL_ATTRS(14) || attr == THERMAL_ATTRS(15)) {
-		if (thermal_read_mode != TPACPI_THERMAL_TPEC_16)
+	case TPACPI_THERMAL_ACPI_TMP07:
+	case TPACPI_THERMAL_ACPI_UPDT:
+	case TPACPI_THERMAL_TPEC_8:
+		if (idx >= 8)
 			return 0;
+		break;
+
+	case TPACPI_THERMAL_TPEC_12:
+		if (idx >= 12)
+			return 0;
+		break;
+
+	default:
+		break;
+
 	}
 
 	return attr->mode;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] platform/x86: thinkpad_acpi: Simplify thermal mode checking
  2024-02-14  5:29 [PATCH 1/2] platform/x86: thinkpad_acpi: Simplify thermal mode checking Vishnu Sankar
  2024-02-14  5:29 ` [PATCH 2/2] platform/x86: thinkpad_acpi: Fix to correct wrong temp reporting on some ThinkPads Vishnu Sankar
@ 2024-02-14  9:52 ` Ilpo Järvinen
  2024-02-14 23:18   ` Vishnu Sankar
  2024-02-14 10:16 ` Ilpo Järvinen
  2 siblings, 1 reply; 7+ messages in thread
From: Ilpo Järvinen @ 2024-02-14  9:52 UTC (permalink / raw
  To: Vishnu Sankar
  Cc: Hans de Goede, platform-driver-x86, LKML, Mark Pearson, vsankar

[-- Attachment #1: Type: text/plain, Size: 6494 bytes --]

On Wed, 14 Feb 2024, Vishnu Sankar wrote:

Thanks for doing this, it's major improvement to readability already as 
is, and even more of after the second patch!!

> Add a thermal_read_mode_check helper function to make the code

thermal_read_mode_check()

remove "function" as it's obvious.

> simpler during init.
> This helps particularly when the new TPEC_12 mode is added in
> the next patch.

Flow the paragraph normally without the premature line break.
 
> Suggested-by: Ilpo Jarvinen <ilpo.jarvinen@intel.com>

This is not my email address, please use

Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

> Signed-off-by: Vishnu Sankar <vishnuocv@gmail.com>
> ---
>  drivers/platform/x86/thinkpad_acpi.c | 136 +++++++++++++--------------
>  1 file changed, 66 insertions(+), 70 deletions(-)
> 
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index c4895e9bc714..2428c8bd0fa2 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -6147,6 +6147,71 @@ struct ibm_thermal_sensors_struct {
>  static enum thermal_access_mode thermal_read_mode;
>  static bool thermal_use_labels;
>  
> +/* Function to check thermal read mode */
> +static enum thermal_access_mode thermal_read_mode_check(void)
> +{
> +	u8 t, ta1, ta2, ver = 0;
> +	int i;
> +
> +	if (thinkpad_id.ec_model) {
> +		/*
> +		 * Direct EC access mode: sensors at registers
> +		 * 0x78-0x7F, 0xC0-0xC7.  Registers return 0x00 for

Remove the double space, one is enough in kernel comments.

> +		 * non-implemented, thermal sensors return 0x80 when
> +		 * not available

Add the missing . please.

Perhaps add a empty line here to make this two paragraphs.

> +		 * The above rule is unfortunately flawed. This has been seen with
> +		 * 0xC2 (power supply ID) causing thermal control problems.
> +		 * The EC version can be determined by offset 0xEF and at least for
> +		 * version 3 the Lenovo firmware team confirmed that registers 0xC0-0xC7
> +		 * are not thermal registers.
> +		 */

While the patch touches this, this entire comment should be reflowed 
properly for 80 columns.

> +		if (!acpi_ec_read(TP_EC_FUNCREV, &ver))
> +			pr_warn("Thinkpad ACPI EC unable to access EC version\n");
> +
> +		ta1 = ta2 = 0;
> +		for (i = 0; i < 8; i++) {
> +			if (acpi_ec_read(TP_EC_THERMAL_TMP0 + i, &t)) {
> +				ta1 |= t;
> +			} else {
> +				ta1 = 0;
> +				break;
> +			}
> +			if (ver < 3) {
> +				if (acpi_ec_read(TP_EC_THERMAL_TMP8 + i, &t)) {
> +					ta2 |= t;
> +				} else {
> +					ta1 = 0;
> +					break;
> +				}
> +			}
> +		}
> +
> +		if (ta1 == 0) {
> +			pr_err("ThinkPad ACPI EC access misbehaving, disabling thermal sensors access\n");
> +			return TPACPI_THERMAL_NONE;
> +		}
> +
> +		if (ver >= 3) {
> +			thermal_use_labels = true;
> +			return TPACPI_THERMAL_TPEC_8;
> +		}
> +
> +		return (ta2 != 0) ? TPACPI_THERMAL_TPEC_16 : TPACPI_THERMAL_TPEC_8;
> +	}
> +
> +	if (acpi_evalf(ec_handle, NULL, "TMP7", "qv")) {
> +		if (tpacpi_is_ibm() &&
> +		    acpi_evalf(ec_handle, NULL, "UPDT", "qv"))

Single line and keep the braces please (I know it will go >80 chars but no 
important info is lost).

> +			/* 600e/x, 770e, 770x */
> +			return TPACPI_THERMAL_ACPI_UPDT;
> +		/* IBM/LENOVO DSDT EC.TMPx access, max 8 sensors */
> +		return TPACPI_THERMAL_ACPI_TMP07;
> +	}
> +
> +	/* temperatures not supported on 570, G4x, R30, R31, R32 */
> +	return TPACPI_THERMAL_NONE;
> +}
> +
>  /* idx is zero-based */
>  static int thermal_get_sensor(int idx, s32 *value)
>  {
> @@ -6375,78 +6440,9 @@ static const struct attribute_group temp_label_attr_group = {
>  
>  static int __init thermal_init(struct ibm_init_struct *iibm)
>  {
> -	u8 t, ta1, ta2, ver = 0;
> -	int i;
> -	int acpi_tmp7;
> -
>  	vdbg_printk(TPACPI_DBG_INIT, "initializing thermal subdriver\n");
>  
> -	acpi_tmp7 = acpi_evalf(ec_handle, NULL, "TMP7", "qv");
> -
> -	if (thinkpad_id.ec_model) {
> -		/*
> -		 * Direct EC access mode: sensors at registers
> -		 * 0x78-0x7F, 0xC0-0xC7.  Registers return 0x00 for
> -		 * non-implemented, thermal sensors return 0x80 when
> -		 * not available
> -		 * The above rule is unfortunately flawed. This has been seen with
> -		 * 0xC2 (power supply ID) causing thermal control problems.
> -		 * The EC version can be determined by offset 0xEF and at least for
> -		 * version 3 the Lenovo firmware team confirmed that registers 0xC0-0xC7
> -		 * are not thermal registers.
> -		 */
> -		if (!acpi_ec_read(TP_EC_FUNCREV, &ver))
> -			pr_warn("Thinkpad ACPI EC unable to access EC version\n");
> -
> -		ta1 = ta2 = 0;
> -		for (i = 0; i < 8; i++) {
> -			if (acpi_ec_read(TP_EC_THERMAL_TMP0 + i, &t)) {
> -				ta1 |= t;
> -			} else {
> -				ta1 = 0;
> -				break;
> -			}
> -			if (ver < 3) {
> -				if (acpi_ec_read(TP_EC_THERMAL_TMP8 + i, &t)) {
> -					ta2 |= t;
> -				} else {
> -					ta1 = 0;
> -					break;
> -				}
> -			}
> -		}
> -		if (ta1 == 0) {
> -			/* This is sheer paranoia, but we handle it anyway */
> -			if (acpi_tmp7) {
> -				pr_err("ThinkPad ACPI EC access misbehaving, falling back to ACPI TMPx access mode\n");
> -				thermal_read_mode = TPACPI_THERMAL_ACPI_TMP07;

Eh, where did this go in the new helper?

-- 
 i.

> -			} else {
> -				pr_err("ThinkPad ACPI EC access misbehaving, disabling thermal sensors access\n");
> -				thermal_read_mode = TPACPI_THERMAL_NONE;
> -			}
> -		} else {
> -			if (ver >= 3) {
> -				thermal_read_mode = TPACPI_THERMAL_TPEC_8;
> -				thermal_use_labels = true;
> -			} else {
> -				thermal_read_mode =
> -					(ta2 != 0) ?
> -					TPACPI_THERMAL_TPEC_16 : TPACPI_THERMAL_TPEC_8;
> -			}
> -		}
> -	} else if (acpi_tmp7) {
> -		if (tpacpi_is_ibm() &&
> -		    acpi_evalf(ec_handle, NULL, "UPDT", "qv")) {
> -			/* 600e/x, 770e, 770x */
> -			thermal_read_mode = TPACPI_THERMAL_ACPI_UPDT;
> -		} else {
> -			/* IBM/LENOVO DSDT EC.TMPx access, max 8 sensors */
> -			thermal_read_mode = TPACPI_THERMAL_ACPI_TMP07;
> -		}
> -	} else {
> -		/* temperatures not supported on 570, G4x, R30, R31, R32 */
> -		thermal_read_mode = TPACPI_THERMAL_NONE;
> -	}
> +	thermal_read_mode = thermal_read_mode_check();
>  
>  	vdbg_printk(TPACPI_DBG_INIT, "thermal is %s, mode %d\n",
>  		str_supported(thermal_read_mode != TPACPI_THERMAL_NONE),
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] platform/x86: thinkpad_acpi: Simplify thermal mode checking
  2024-02-14  5:29 [PATCH 1/2] platform/x86: thinkpad_acpi: Simplify thermal mode checking Vishnu Sankar
  2024-02-14  5:29 ` [PATCH 2/2] platform/x86: thinkpad_acpi: Fix to correct wrong temp reporting on some ThinkPads Vishnu Sankar
  2024-02-14  9:52 ` [PATCH 1/2] platform/x86: thinkpad_acpi: Simplify thermal mode checking Ilpo Järvinen
@ 2024-02-14 10:16 ` Ilpo Järvinen
  2 siblings, 0 replies; 7+ messages in thread
From: Ilpo Järvinen @ 2024-02-14 10:16 UTC (permalink / raw
  To: Vishnu Sankar
  Cc: Hans de Goede, platform-driver-x86, LKML, Mark Pearson, vsankar

[-- Attachment #1: Type: text/plain, Size: 6542 bytes --]

On Wed, 14 Feb 2024, Vishnu Sankar wrote:

Thanks for doing this, it's major improvement to readability already as
is, and even more of after the second patch!!

> Add a thermal_read_mode_check helper function to make the code

thermal_read_mode_check()

remove "function" as it's obvious.

> simpler during init.
> This helps particularly when the new TPEC_12 mode is added in
> the next patch.

Flow the paragraph normally without the premature line break.

> Suggested-by: Ilpo Jarvinen <ilpo.jarvinen@intel.com>

This is not my email address, please use

Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

> Signed-off-by: Vishnu Sankar <vishnuocv@gmail.com>
> ---
>  drivers/platform/x86/thinkpad_acpi.c | 136 +++++++++++++--------------
>  1 file changed, 66 insertions(+), 70 deletions(-)
> 
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index c4895e9bc714..2428c8bd0fa2 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -6147,6 +6147,71 @@ struct ibm_thermal_sensors_struct {
>  static enum thermal_access_mode thermal_read_mode;
>  static bool thermal_use_labels;
>  
> +/* Function to check thermal read mode */
> +static enum thermal_access_mode thermal_read_mode_check(void)
> +{
> +	u8 t, ta1, ta2, ver = 0;
> +	int i;
> +
> +	if (thinkpad_id.ec_model) {
> +		/*
> +		 * Direct EC access mode: sensors at registers
> +		 * 0x78-0x7F, 0xC0-0xC7.  Registers return 0x00 for

While this comment is touches, lets make minor improvements to it.

Remove the double space, they are not needed in kernel comments.

> +		 * non-implemented, thermal sensors return 0x80 when
> +		 * not available

Please add the missing .

Perhaps add an empty line here to break the comment into two paragraphs?

> +		 * The above rule is unfortunately flawed. This has been seen with
> +		 * 0xC2 (power supply ID) causing thermal control problems.
> +		 * The EC version can be determined by offset 0xEF and at least for
> +		 * version 3 the Lenovo firmware team confirmed that registers 0xC0-0xC7
> +		 * are not thermal registers.

Please reflow the entire comment to 80 chars.

> +		 */
> +		if (!acpi_ec_read(TP_EC_FUNCREV, &ver))
> +			pr_warn("Thinkpad ACPI EC unable to access EC version\n");
> +
> +		ta1 = ta2 = 0;
> +		for (i = 0; i < 8; i++) {
> +			if (acpi_ec_read(TP_EC_THERMAL_TMP0 + i, &t)) {
> +				ta1 |= t;
> +			} else {
> +				ta1 = 0;
> +				break;
> +			}
> +			if (ver < 3) {
> +				if (acpi_ec_read(TP_EC_THERMAL_TMP8 + i, &t)) {
> +					ta2 |= t;
> +				} else {
> +					ta1 = 0;
> +					break;
> +				}
> +			}
> +		}
> +
> +		if (ta1 == 0) {
> +			pr_err("ThinkPad ACPI EC access misbehaving, disabling thermal sensors access\n");
> +			return TPACPI_THERMAL_NONE;
> +		}
> +
> +		if (ver >= 3) {
> +			thermal_use_labels = true;
> +			return TPACPI_THERMAL_TPEC_8;
> +		}
> +
> +		return (ta2 != 0) ? TPACPI_THERMAL_TPEC_16 : TPACPI_THERMAL_TPEC_8;
> +	}
> +
> +	if (acpi_evalf(ec_handle, NULL, "TMP7", "qv")) {
> +		if (tpacpi_is_ibm() &&
> +		    acpi_evalf(ec_handle, NULL, "UPDT", "qv"))

Put this to single line and retain the braces please (I know it will be 
>80 char but nothing important is lost).

> +			/* 600e/x, 770e, 770x */
> +			return TPACPI_THERMAL_ACPI_UPDT;
> +		/* IBM/LENOVO DSDT EC.TMPx access, max 8 sensors */
> +		return TPACPI_THERMAL_ACPI_TMP07;
> +	}
> +
> +	/* temperatures not supported on 570, G4x, R30, R31, R32 */
> +	return TPACPI_THERMAL_NONE;
> +}
> +
>  /* idx is zero-based */
>  static int thermal_get_sensor(int idx, s32 *value)
>  {
> @@ -6375,78 +6440,9 @@ static const struct attribute_group temp_label_attr_group = {
>  
>  static int __init thermal_init(struct ibm_init_struct *iibm)
>  {
> -	u8 t, ta1, ta2, ver = 0;
> -	int i;
> -	int acpi_tmp7;
> -
>  	vdbg_printk(TPACPI_DBG_INIT, "initializing thermal subdriver\n");
>  
> -	acpi_tmp7 = acpi_evalf(ec_handle, NULL, "TMP7", "qv");
> -
> -	if (thinkpad_id.ec_model) {
> -		/*
> -		 * Direct EC access mode: sensors at registers
> -		 * 0x78-0x7F, 0xC0-0xC7.  Registers return 0x00 for
> -		 * non-implemented, thermal sensors return 0x80 when
> -		 * not available
> -		 * The above rule is unfortunately flawed. This has been seen with
> -		 * 0xC2 (power supply ID) causing thermal control problems.
> -		 * The EC version can be determined by offset 0xEF and at least for
> -		 * version 3 the Lenovo firmware team confirmed that registers 0xC0-0xC7
> -		 * are not thermal registers.
> -		 */
> -		if (!acpi_ec_read(TP_EC_FUNCREV, &ver))
> -			pr_warn("Thinkpad ACPI EC unable to access EC version\n");
> -
> -		ta1 = ta2 = 0;
> -		for (i = 0; i < 8; i++) {
> -			if (acpi_ec_read(TP_EC_THERMAL_TMP0 + i, &t)) {
> -				ta1 |= t;
> -			} else {
> -				ta1 = 0;
> -				break;
> -			}
> -			if (ver < 3) {
> -				if (acpi_ec_read(TP_EC_THERMAL_TMP8 + i, &t)) {
> -					ta2 |= t;
> -				} else {
> -					ta1 = 0;
> -					break;
> -				}
> -			}
> -		}
> -		if (ta1 == 0) {
> -			/* This is sheer paranoia, but we handle it anyway */
> -			if (acpi_tmp7) {
> -				pr_err("ThinkPad ACPI EC access misbehaving, falling back to ACPI TMPx access mode\n");
> -				thermal_read_mode = TPACPI_THERMAL_ACPI_TMP07;

Eh, where did this go in the new helper?

-- 
 i.

> -			} else {
> -				pr_err("ThinkPad ACPI EC access misbehaving, disabling thermal sensors access\n");
> -				thermal_read_mode = TPACPI_THERMAL_NONE;
> -			}
> -		} else {
> -			if (ver >= 3) {
> -				thermal_read_mode = TPACPI_THERMAL_TPEC_8;
> -				thermal_use_labels = true;
> -			} else {
> -				thermal_read_mode =
> -					(ta2 != 0) ?
> -					TPACPI_THERMAL_TPEC_16 : TPACPI_THERMAL_TPEC_8;
> -			}
> -		}
> -	} else if (acpi_tmp7) {
> -		if (tpacpi_is_ibm() &&
> -		    acpi_evalf(ec_handle, NULL, "UPDT", "qv")) {
> -			/* 600e/x, 770e, 770x */
> -			thermal_read_mode = TPACPI_THERMAL_ACPI_UPDT;
> -		} else {
> -			/* IBM/LENOVO DSDT EC.TMPx access, max 8 sensors */
> -			thermal_read_mode = TPACPI_THERMAL_ACPI_TMP07;
> -		}
> -	} else {
> -		/* temperatures not supported on 570, G4x, R30, R31, R32 */
> -		thermal_read_mode = TPACPI_THERMAL_NONE;
> -	}
> +	thermal_read_mode = thermal_read_mode_check();
>  
>  	vdbg_printk(TPACPI_DBG_INIT, "thermal is %s, mode %d\n",
>  		str_supported(thermal_read_mode != TPACPI_THERMAL_NONE),
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] platform/x86: thinkpad_acpi: Fix to correct wrong temp reporting on some ThinkPads
  2024-02-14  5:29 ` [PATCH 2/2] platform/x86: thinkpad_acpi: Fix to correct wrong temp reporting on some ThinkPads Vishnu Sankar
@ 2024-02-14 10:22   ` Ilpo Järvinen
  2024-02-14 23:22     ` Vishnu Sankar
  0 siblings, 1 reply; 7+ messages in thread
From: Ilpo Järvinen @ 2024-02-14 10:22 UTC (permalink / raw
  To: Vishnu Sankar
  Cc: Hans de Goede, platform-driver-x86, LKML, Mark Pearson, vsankar

[-- Attachment #1: Type: text/plain, Size: 1470 bytes --]

On Wed, 14 Feb 2024, Vishnu Sankar wrote:

> Added non-standard thermal register support for some ThinkPads.
> 
> Some of the Thinkpads use a non-standard ECFW which use different
> thermal register addresses.
> This is a fix to correct the wrong temperature reporting on
> those systems.
> 
> Tested on Lenovo ThinkPad L13 Yoga Gen2
> 
> Suggested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> Signed-off-by: Vishnu Sankar <vishnuocv@gmail.com>
> ---
> -Improvements as requested.
> -Improved the readability in case TPACPI_THERMAL_TPEC_12.
> -idx < 8 from idx idx <=7 to match idx = 8
> -KILO used from linux/units.h instead of 1000.

>  static enum thermal_access_mode thermal_read_mode;
>  static bool thermal_use_labels;
> +static bool thermal_with_ns_address;	/*Non-standard thermal reg address*/

Comment is missing spaces.

> @@ -6239,6 +6267,20 @@ static int thermal_get_sensor(int idx, s32 *value)
>  		}
>  		break;
>  
> +	/* The Non-standard EC uses 12 Thermal areas */
> +	case TPACPI_THERMAL_TPEC_12:
> +		if (idx >= 12)
> +			return -EINVAL;
> +
> +		t = idx < 8 ? TP_EC_THERMAL_TMP0_NS + idx :
> +				TP_EC_THERMAL_TMP8_NS + (idx - 8);
> +
> +		if (!acpi_ec_read(t, &tmp))
> +			return -EIO;
> +
> +		*value = tmp * KILO;

Hmm, MILLI would be much more approriate here? But if this relates to 
degrees, there is MILLIDEGREE_PER_DEGREE?

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

-- 
 i.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] platform/x86: thinkpad_acpi: Simplify thermal mode checking
  2024-02-14  9:52 ` [PATCH 1/2] platform/x86: thinkpad_acpi: Simplify thermal mode checking Ilpo Järvinen
@ 2024-02-14 23:18   ` Vishnu Sankar
  0 siblings, 0 replies; 7+ messages in thread
From: Vishnu Sankar @ 2024-02-14 23:18 UTC (permalink / raw
  To: Ilpo Järvinen
  Cc: Hans de Goede, platform-driver-x86, LKML, Mark Pearson, vsankar

Ilpo,
Thanks a lot for the review.

On Wed, Feb 14, 2024 at 7:14 PM Ilpo Järvinen
<ilpo.jarvinen@linux.intel.com> wrote:
>
> On Wed, 14 Feb 2024, Vishnu Sankar wrote:
>
> Thanks for doing this, it's major improvement to readability already as
> is, and even more of after the second patch!!
>
> > Add a thermal_read_mode_check helper function to make the code
>
> thermal_read_mode_check()
>
> remove "function" as it's obvious.
Acked
>
> > simpler during init.
> > This helps particularly when the new TPEC_12 mode is added in
> > the next patch.
>
> Flow the paragraph normally without the premature line break.
Acked.
>
> > Suggested-by: Ilpo Jarvinen <ilpo.jarvinen@intel.com>
>
> This is not my email address, please use
>
> Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Sorry for this.
Will correct email address.
>
> > Signed-off-by: Vishnu Sankar <vishnuocv@gmail.com>
> > ---
> >  drivers/platform/x86/thinkpad_acpi.c | 136 +++++++++++++--------------
> >  1 file changed, 66 insertions(+), 70 deletions(-)
> >
> > diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> > index c4895e9bc714..2428c8bd0fa2 100644
> > --- a/drivers/platform/x86/thinkpad_acpi.c
> > +++ b/drivers/platform/x86/thinkpad_acpi.c
> > @@ -6147,6 +6147,71 @@ struct ibm_thermal_sensors_struct {
> >  static enum thermal_access_mode thermal_read_mode;
> >  static bool thermal_use_labels;
> >
> > +/* Function to check thermal read mode */
> > +static enum thermal_access_mode thermal_read_mode_check(void)
> > +{
> > +     u8 t, ta1, ta2, ver = 0;
> > +     int i;
> > +
> > +     if (thinkpad_id.ec_model) {
> > +             /*
> > +              * Direct EC access mode: sensors at registers
> > +              * 0x78-0x7F, 0xC0-0xC7.  Registers return 0x00 for
>
> Remove the double space, one is enough in kernel comments.
Acked
>
> > +              * non-implemented, thermal sensors return 0x80 when
> > +              * not available
>
> Add the missing . please.
>
> Perhaps add a empty line here to make this two paragraphs.
Acked
>
> > +              * The above rule is unfortunately flawed. This has been seen with
> > +              * 0xC2 (power supply ID) causing thermal control problems.
> > +              * The EC version can be determined by offset 0xEF and at least for
> > +              * version 3 the Lenovo firmware team confirmed that registers 0xC0-0xC7
> > +              * are not thermal registers.
> > +              */
>
> While the patch touches this, this entire comment should be reflowed
> properly for 80 columns.
Will try re-writing the comments block for 80 columns.
>
> > +             if (!acpi_ec_read(TP_EC_FUNCREV, &ver))
> > +                     pr_warn("Thinkpad ACPI EC unable to access EC version\n");
> > +
> > +             ta1 = ta2 = 0;
> > +             for (i = 0; i < 8; i++) {
> > +                     if (acpi_ec_read(TP_EC_THERMAL_TMP0 + i, &t)) {
> > +                             ta1 |= t;
> > +                     } else {
> > +                             ta1 = 0;
> > +                             break;
> > +                     }
> > +                     if (ver < 3) {
> > +                             if (acpi_ec_read(TP_EC_THERMAL_TMP8 + i, &t)) {
> > +                                     ta2 |= t;
> > +                             } else {
> > +                                     ta1 = 0;
> > +                                     break;
> > +                             }
> > +                     }
> > +             }
> > +
> > +             if (ta1 == 0) {
> > +                     pr_err("ThinkPad ACPI EC access misbehaving, disabling thermal sensors access\n");
> > +                     return TPACPI_THERMAL_NONE;
> > +             }
> > +
> > +             if (ver >= 3) {
> > +                     thermal_use_labels = true;
> > +                     return TPACPI_THERMAL_TPEC_8;
> > +             }
> > +
> > +             return (ta2 != 0) ? TPACPI_THERMAL_TPEC_16 : TPACPI_THERMAL_TPEC_8;
> > +     }
> > +
> > +     if (acpi_evalf(ec_handle, NULL, "TMP7", "qv")) {
> > +             if (tpacpi_is_ibm() &&
> > +                 acpi_evalf(ec_handle, NULL, "UPDT", "qv"))
>
> Single line and keep the braces please (I know it will go >80 chars but no
> important info is lost).
Acked.
Will change this.
>
> > +                     /* 600e/x, 770e, 770x */
> > +                     return TPACPI_THERMAL_ACPI_UPDT;
> > +             /* IBM/LENOVO DSDT EC.TMPx access, max 8 sensors */
> > +             return TPACPI_THERMAL_ACPI_TMP07;
> > +     }
> > +
> > +     /* temperatures not supported on 570, G4x, R30, R31, R32 */
> > +     return TPACPI_THERMAL_NONE;
> > +}
> > +
> >  /* idx is zero-based */
> >  static int thermal_get_sensor(int idx, s32 *value)
> >  {
> > @@ -6375,78 +6440,9 @@ static const struct attribute_group temp_label_attr_group = {
> >
> >  static int __init thermal_init(struct ibm_init_struct *iibm)
> >  {
> > -     u8 t, ta1, ta2, ver = 0;
> > -     int i;
> > -     int acpi_tmp7;
> > -
> >       vdbg_printk(TPACPI_DBG_INIT, "initializing thermal subdriver\n");
> >
> > -     acpi_tmp7 = acpi_evalf(ec_handle, NULL, "TMP7", "qv");
> > -
> > -     if (thinkpad_id.ec_model) {
> > -             /*
> > -              * Direct EC access mode: sensors at registers
> > -              * 0x78-0x7F, 0xC0-0xC7.  Registers return 0x00 for
> > -              * non-implemented, thermal sensors return 0x80 when
> > -              * not available
> > -              * The above rule is unfortunately flawed. This has been seen with
> > -              * 0xC2 (power supply ID) causing thermal control problems.
> > -              * The EC version can be determined by offset 0xEF and at least for
> > -              * version 3 the Lenovo firmware team confirmed that registers 0xC0-0xC7
> > -              * are not thermal registers.
> > -              */
> > -             if (!acpi_ec_read(TP_EC_FUNCREV, &ver))
> > -                     pr_warn("Thinkpad ACPI EC unable to access EC version\n");
> > -
> > -             ta1 = ta2 = 0;
> > -             for (i = 0; i < 8; i++) {
> > -                     if (acpi_ec_read(TP_EC_THERMAL_TMP0 + i, &t)) {
> > -                             ta1 |= t;
> > -                     } else {
> > -                             ta1 = 0;
> > -                             break;
> > -                     }
> > -                     if (ver < 3) {
> > -                             if (acpi_ec_read(TP_EC_THERMAL_TMP8 + i, &t)) {
> > -                                     ta2 |= t;
> > -                             } else {
> > -                                     ta1 = 0;
> > -                                     break;
> > -                             }
> > -                     }
> > -             }
> > -             if (ta1 == 0) {
> > -                     /* This is sheer paranoia, but we handle it anyway */
> > -                     if (acpi_tmp7) {
> > -                             pr_err("ThinkPad ACPI EC access misbehaving, falling back to ACPI TMPx access mode\n");
> > -                             thermal_read_mode = TPACPI_THERMAL_ACPI_TMP07;
>
> Eh, where did this go in the new helper?
Sorry.
This will be added in V2.
>
> --
>  i.
>
> > -                     } else {
> > -                             pr_err("ThinkPad ACPI EC access misbehaving, disabling thermal sensors access\n");
> > -                             thermal_read_mode = TPACPI_THERMAL_NONE;
> > -                     }
> > -             } else {
> > -                     if (ver >= 3) {
> > -                             thermal_read_mode = TPACPI_THERMAL_TPEC_8;
> > -                             thermal_use_labels = true;
> > -                     } else {
> > -                             thermal_read_mode =
> > -                                     (ta2 != 0) ?
> > -                                     TPACPI_THERMAL_TPEC_16 : TPACPI_THERMAL_TPEC_8;
> > -                     }
> > -             }
> > -     } else if (acpi_tmp7) {
> > -             if (tpacpi_is_ibm() &&
> > -                 acpi_evalf(ec_handle, NULL, "UPDT", "qv")) {
> > -                     /* 600e/x, 770e, 770x */
> > -                     thermal_read_mode = TPACPI_THERMAL_ACPI_UPDT;
> > -             } else {
> > -                     /* IBM/LENOVO DSDT EC.TMPx access, max 8 sensors */
> > -                     thermal_read_mode = TPACPI_THERMAL_ACPI_TMP07;
> > -             }
> > -     } else {
> > -             /* temperatures not supported on 570, G4x, R30, R31, R32 */
> > -             thermal_read_mode = TPACPI_THERMAL_NONE;
> > -     }
> > +     thermal_read_mode = thermal_read_mode_check();
> >
> >       vdbg_printk(TPACPI_DBG_INIT, "thermal is %s, mode %d\n",
> >               str_supported(thermal_read_mode != TPACPI_THERMAL_NONE),
> >



-- 

Regards,

      Vishnu Sankar
     +817015150407 (Japan)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] platform/x86: thinkpad_acpi: Fix to correct wrong temp reporting on some ThinkPads
  2024-02-14 10:22   ` Ilpo Järvinen
@ 2024-02-14 23:22     ` Vishnu Sankar
  0 siblings, 0 replies; 7+ messages in thread
From: Vishnu Sankar @ 2024-02-14 23:22 UTC (permalink / raw
  To: Ilpo Järvinen
  Cc: Hans de Goede, platform-driver-x86, LKML, Mark Pearson, vsankar

Ilpo,
Thanks for the review.

On Wed, Feb 14, 2024 at 7:23 PM Ilpo Järvinen
<ilpo.jarvinen@linux.intel.com> wrote:
>
> On Wed, 14 Feb 2024, Vishnu Sankar wrote:
>
> > Added non-standard thermal register support for some ThinkPads.
> >
> > Some of the Thinkpads use a non-standard ECFW which uses different
> > thermal register addresses.
> > This is a fix to correct the wrong temperature reporting on
> > those systems.
> >
> > Tested on Lenovo ThinkPad L13 Yoga Gen2
> >
> > Suggested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> > Signed-off-by: Vishnu Sankar <vishnuocv@gmail.com>
> > ---
> > -Improvements as requested.
> > -Improved the readability in case TPACPI_THERMAL_TPEC_12.
> > -idx < 8 from idx idx <=7 to match idx = 8
> > -KILO used from linux/units.h instead of 1000.
>
> >  static enum thermal_access_mode thermal_read_mode;
> >  static bool thermal_use_labels;
> > +static bool thermal_with_ns_address; /*Non-standard thermal reg address*/
>
> Comment is missing spaces.
Acked.
>
> > @@ -6239,6 +6267,20 @@ static int thermal_get_sensor(int idx, s32 *value)
> >               }
> >               break;
> >
> > +     /* The Non-standard EC uses 12 Thermal areas */
> > +     case TPACPI_THERMAL_TPEC_12:
> > +             if (idx >= 12)
> > +                     return -EINVAL;
> > +
> > +             t = idx < 8 ? TP_EC_THERMAL_TMP0_NS + idx :
> > +                             TP_EC_THERMAL_TMP8_NS + (idx - 8);
> > +
> > +             if (!acpi_ec_read(t, &tmp))
> > +                     return -EIO;
> > +
> > +             *value = tmp * KILO;
>
> Hmm, MILLI would be much more approriate here? But if this relates to
> degrees, there is MILLIDEGREE_PER_DEGREE?
Will Change to MILLIDEGREE_PER_DEGREE from KILO
>
> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
>
> --
>  i.



-- 

Regards,

      Vishnu Sankar
     +817015150407 (Japan)

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-02-14 23:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-14  5:29 [PATCH 1/2] platform/x86: thinkpad_acpi: Simplify thermal mode checking Vishnu Sankar
2024-02-14  5:29 ` [PATCH 2/2] platform/x86: thinkpad_acpi: Fix to correct wrong temp reporting on some ThinkPads Vishnu Sankar
2024-02-14 10:22   ` Ilpo Järvinen
2024-02-14 23:22     ` Vishnu Sankar
2024-02-14  9:52 ` [PATCH 1/2] platform/x86: thinkpad_acpi: Simplify thermal mode checking Ilpo Järvinen
2024-02-14 23:18   ` Vishnu Sankar
2024-02-14 10:16 ` Ilpo Järvinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).