Lenovo ThinkPad T14s EC thermal monitoring and thermal zone integration
Subsystems (7)
cover Lenovo ThinkPad T14s EC thermal monitoring and thermal zone integration
Hi,
This series extends the Lenovo ThinkPad T14s embedded controller driver with environmental monitoring capabilities and integrates the exposed sensors into the Linux thermal framework.
The EC provides access to several platform temperature sensors covering the SoC, keyboard area, bottom cover, charging circuitry, QTM module and SSD, as well as fan speed information. These sensors are currently used by the firmware for thermal management but are not exposed to Linux.
The first patch adds hwmon support for the EC temperature sensors and fan RPM reporting.
The second patch wires EC thermal notifications into the hwmon event framework, allowing userspace to receive alarm notifications when the EC reports thermal zone state changes.
The last patch exposes the EC as a thermal sensor provider in the device tree and defines thermal zones for the keyboard skin temperature and the charging circuitry temperature. This allows the generic thermal framework to react to EC-reported temperatures and apply standard Linux thermal mitigation policies.
With the latest patch, this series fixes thermal issues happening on this platform where a kernel compilation leads to a system reboot.
Tested on a Lenovo ThinkPad T14s Gen 6 (Snapdragon X Elite).
Thanks,
Daniel
Daniel Lezcano (3):
drivers/platform: lenovo-t14s-ec: Add hwmon support for temperatures
and fan speed
platform: arm64: thinkpad-t14s-ec: Wire EC thermal events to hwmon
arm64: dts: qcom: x1e78100-t14s: Add thermal zones for keyboard skin
and charging sensors
.../qcom/x1e78100-lenovo-thinkpad-t14s.dtsi | 68 +++++- drivers/platform/arm64/lenovo-thinkpad-t14s.c | 193 +++++++++++++++++- 2 files changed, 255 insertions(+), 6 deletions(-)
Signature · 1 line
2.53.0
PATCH 1/3 drivers/platform: lenovo-t14s-ec: Add hwmon support for temperatures and fan speed
Expose the Lenovo ThinkPad T14s EC environmental sensors through the hwmon subsystem.
The driver now registers a hwmon device providing access to six EC temperature sensors corresponding to the SoC, keyboard area, base cover, PMIC/charging circuitry, QTM module and SSD. Sensor labels are exported to allow user space to identify each measurement.
Additionally, expose the system fan speed by reading the fan RPM registers from the embedded controller.
This allows standard monitoring tools such as lm-sensors to report platform temperatures and fan speed.
--- drivers/platform/arm64/lenovo-thinkpad-t14s.c | 147 ++++++++++++++++++ 1 file changed, 147 insertions(+)
drivers/platform/arm64/lenovo-thinkpad-t14s.c +147 -0
@@ -11,6 +11,7 @@#include <linux/delay.h> #include <linux/dev_printk.h> #include <linux/err.h> +#include <linux/hwmon.h> #include <linux/i2c.h> #include <linux/input.h> #include <linux/input/sparse-keymap.h>
@@ -67,6 +68,16 @@#define T14S_EC_EVT_KEY_FN_F11 0x7a#define T14S_EC_EVT_KEY_FN_G 0x7e +#define T14S_EC_SYS_THERM0 0x78/* SoC (CPU+GPU) */ +#define T14S_EC_SYS_THERM1 0x79/* Keyboard */ +#define T14S_EC_SYS_THERM2 0x7a/* Back cover */ +#define T14S_EC_SYS_THERM3 0x7b/* Charger / PMIC */ +#define T14S_EC_SYS_THERM6 0x7c/* QTM West */ +#define T14S_EC_SYS_THERM7 0x7d/* SSD */ + +#define T14S_EC_FAN_RPM_LSB 0x84 +#define T14S_EC_FAN_RPM_MSB 0x85 +/* Hardware LED blink rate is 1 Hz (500ms off, 500ms on) */ #define T14S_EC_BLINK_RATE_ON_OFF_MS 500
@@ -93,9 +104,19 @@ struct t14s_ec_led_classdev {struct t14s_ec *ec; }; +struct t14s_ec_hwmon_sys_thermx { +const char *label; +int reg; +}; + +struct t14s_ec_hwmon { +struct t14s_ec_hwmon_sys_thermx *sys_thermx; +}; +struct t14s_ec {struct regmap *regmap;struct device *dev; +struct t14s_ec_hwmon ec_hwmon;struct t14s_ec_led_classdev led_pwr_btn;struct t14s_ec_led_classdev led_chrg_orange;struct t14s_ec_led_classdev led_chrg_white;
@@ -555,6 +576,128 @@ static irqreturn_t t14s_ec_irq_handler(int irq, void *data)return IRQ_HANDLED ; } +static umode_t t14s_ec_hwmon_is_visible (const void *drvdata, +enum hwmon_sensor_types type, +u32 attr,int channel) +{ +switch (type) { +case hwmon_temp: +return 0444 ; +case hwmon_fan: +return 0444 ; +default : +return 0 ; + } +} + +static int t14s_ec_hwmon_read_string (struct device *dev,enum hwmon_sensor_types type, +u32 attr,int channel,const char **str) +{ +struct t14s_ec *ec =dev_get_drvdata (dev); +switch (type) { +case hwmon_temp: +if (attr == hwmon_temp_label) { + *str = ec->ec_hwmon.sys_thermx[channel].label; +return 0 ; + } +break ; +default : +return -EOPNOTSUPP ; + } + +return -EOPNOTSUPP ; +} + +static int t14s_ec_hwmon_read (struct device *dev,enum hwmon_sensor_types type, +u32 attr,int channel,long *val) +{ +struct t14s_ec *ec =dev_get_drvdata (dev); +unsigned int value; +int ret; + +switch (type) { +case hwmon_temp: +if (attr == hwmon_temp_input) { + ret =t14s_ec_read (ec, ec->ec_hwmon.sys_thermx[channel].reg, &value); +if (ret) +return ret; + *val = value *1000 ; + +return 0 ; + } +break ; + +case hwmon_fan: +if (attr == hwmon_fan_input) { +int lsb, msb; + ret =t14s_ec_read (ec,T14S_EC_FAN_RPM_LSB , &lsb); +if (ret) +return ret; + + ret =t14s_ec_read (ec,T14S_EC_FAN_RPM_MSB , &msb); +if (ret) +return ret; + + *val =0 ; + *val = lsb + (msb <<8 ); + +return 0 ; + } +break ; +default : +break ; + } + +return -EOPNOTSUPP ; +} + +static const struct hwmon_ops t14s_ec_hwmon_ops = { + .is_visible = t14s_ec_hwmon_is_visible, + .read = t14s_ec_hwmon_read, + .read_string = t14s_ec_hwmon_read_string, +}; + +static const struct hwmon_channel_info *t14s_ec_hwmon_info[] = { +HWMON_CHANNEL_INFO (temp, +HWMON_T_INPUT |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_LABEL ), +HWMON_CHANNEL_INFO (fan,HWMON_F_INPUT ), +NULL +}; + +static const struct hwmon_chip_info t14s_ec_chip_info = { + .ops = &t14s_ec_hwmon_ops, + .info = t14s_ec_hwmon_info, +}; + +static int t14s_ec_hwmon_probe (struct t14s_ec *ec) +{ +struct device *dev; +struct t14s_ec_hwmon_sys_thermx sys_thermx[] = { + {T14S_EC_SYS_THERM0 ,"soc" }, + {T14S_EC_SYS_THERM1 ,"keyboard" }, + {T14S_EC_SYS_THERM2 ,"base" }, + {T14S_EC_SYS_THERM3 ,"pmbm" }, + {T14S_EC_SYS_THERM6 ,"qtm" }, + {T14S_EC_SYS_THERM7 ,"ssd" }, + }; + + ec->ec_hwmon.sys_thermx =devm_kmemdup_array (ec->dev, sys_thermx, +ARRAY_SIZE (sys_thermx), +sizeof (sys_thermx[0 ]),GFP_KERNEL ); +if (!ec->ec_hwmon.sys_thermx) +return -ENOMEM ; + + dev =devm_hwmon_device_register_with_info (ec->dev,"t14s_ec" , ec, + &t14s_ec_chip_info,NULL ); + +return PTR_ERR_OR_ZERO (dev); +} +static int t14s_ec_probe (struct i2c_client *client) {struct device *dev = &client->dev;
@@ -590,6 +733,10 @@ static int t14s_ec_probe(struct i2c_client *client)if (ret <0 )return ret; + ret =t14s_ec_hwmon_probe (ec); +if (ret <0 ) +return ret; + ret =devm_request_threaded_irq (dev, client->irq,NULL , t14s_ec_irq_handler,IRQF_ONESHOT ,dev_name (dev), ec);
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v1 1/3] drivers/platform: lenovo-t14s-ec: Add hwmon support for temperatures and fan speed
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
New issues:
- [High] Direct calls to t14s_ec_read bypass the regmap mutex, violating the mandatory 10ms hardware recovery delay between EC commands.
- [Medium] Reading the fan RPM requires two separate I2C transfers for the LSB and MSB, allowing the hardware value to update in between and cause torn reads.
- [Low] Passing int * arguments to a function expecting unsigned int * for I2C register reads.
Pre-existing issues:
- [High] The t14s_ec_read function passes buffers allocated on the kernel stack to __i2c_transfer(), which violates DMA mapping rules and can cause panics. --
commit d0870f0c919ef26da98287c26fc38bc327dcd76b
Author: Daniel Lezcano <[email protected]>
drivers/platform: lenovo-t14s-ec: Add hwmon support for temperatures and fan speed
Expose the Lenovo ThinkPad T14s EC environmental sensors through the hwmon subsystem.
Quoted 4 lines
drivers/platform/arm64/lenovo-thinkpad-t14s.c +0
-0
[ ... ]
Quoted 5 lines
drivers/platform/arm64/lenovo-thinkpad-t14s.c +1
-0@@ -555,6 +576,128 @@ static irqreturn_t t14s_ec_irq_handler(int irq, void *data)return IRQ_HANDLED ; } +static umode_t t14s_ec_hwmon_is_visible(const void *drvdata,
[ ... ]
drivers/platform/arm64/lenovo-thinkpad-t14s.c static irqreturn_t t14s_ec_irq_handler(int irq, void *data) · line 621
Quoted 11 lines
drivers/platform/arm64/lenovo-thinkpad-t14s.c +11
-0+static int t14s_ec_hwmon_read (struct device *dev,enum hwmon_sensor_types type, +u32 attr,int channel,long *val) +{ +struct t14s_ec *ec =dev_get_drvdata (dev); +unsigned int value; +int ret; + +switch (type) { +case hwmon_temp: +if (attr == hwmon_temp_input) { + ret =t14s_ec_read (ec, ec->ec_hwmon.sys_thermx[channel].reg, &value);
[Severity: High]
Does calling t14s_ec_read() directly here bypass the regmap mutex?
Because the embedded controller requires a 10ms hardware recovery delay between commands, regmap serializes accesses and includes the sleep while holding the lock. Calling t14s_ec_read() directly appears to bypass this locking, potentially allowing concurrent sysfs reads to interleave with other subsystem I2C transfers and violate the hardware constraint.
[Severity: High]
This isn't a bug introduced by this patch, but because this exposes new sysfs attributes that userspace can trigger, does t14s_ec_read() pass stack-allocated buffers to __i2c_transfer()?
Looking at t14s_ec_read():
static int t14s_ec_read(void *context, unsigned int reg,
unsigned int *val)
{
...
u8 buf[4] = {T14S_EC_CMD_ECRD, reg, 0x00, 0x01};
struct i2c_msg request, response;
u8 result;
...
request.buf = buf;
...
response.buf = &result;
...
ret = __i2c_transfer(client->adapter, &request, 1);On ARM64 architectures with CONFIG_VMAP_STACK, passing stack memory to I2C drivers using DMA (like Qualcomm GENI) can trigger a BUG() panic or corrupt adjacent physical memory. Is it possible to use heap-allocated buffers here instead?
drivers/platform/arm64/lenovo-thinkpad-t14s.c static irqreturn_t t14s_ec_irq_handler(int irq, void *data) · line 633
Quoted 12 lines
drivers/platform/arm64/lenovo-thinkpad-t14s.c +12
-0+if (ret) +return ret; + *val = value *1000 ; + +return 0 ; + } +break ; + +case hwmon_fan: +if (attr == hwmon_fan_input) { +int lsb, msb; + ret =t14s_ec_read (ec,T14S_EC_FAN_RPM_LSB , &lsb);
[Severity: Low]
Does this pass pointers of type int * to t14s_ec_read() which expects unsigned int *?
Newer compilers like GCC 14 treat -Wincompatible-pointer-types as an error by default, which might break the build here.
[Severity: Medium]
Is there a risk of torn reads when reading the lsb and msb sequentially?
Because t14s_ec_read() enforces a 10ms sleep after each I2C transfer, there is a large race window between reading T14S_EC_FAN_RPM_LSB and T14S_EC_FAN_RPM_MSB. If the fan RPM rolls over (e.g., from 0x01ff to 0x0200) during that window, could we combine an old lsb with a new msb and report a wildly incorrect fan speed?
Quoted 13 lines
drivers/platform/arm64/lenovo-thinkpad-t14s.c +13
-0+if (ret) +return ret; + + ret =t14s_ec_read (ec,T14S_EC_FAN_RPM_MSB , &msb); +if (ret) +return ret; + + *val =0 ; + *val = lsb + (msb <<8 ); + +return 0 ; + } +break ;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH v1 1/3] drivers/platform: lenovo-t14s-ec: Add hwmon support for temperatures and fan speed
In reply to Daniel LezcanoQuoted 16 lines · Daniel Lezcano
Expose the Lenovo ThinkPad T14s EC environmental sensors through the hwmon subsystem.
The driver now registers a hwmon device providing access to six EC temperature sensors corresponding to the SoC, keyboard area, base cover, PMIC/charging circuitry, QTM module and SSD. Sensor labels are exported to allow user space to identify each measurement.
Additionally, expose the system fan speed by reading the fan RPM registers from the embedded controller.
This allows standard monitoring tools such as lm-sensors to report platform temperatures and fan speed.
Signed-off-by Daniel Lezcano [email protected]---
[...]
drivers/platform/arm64/lenovo-thinkpad-t14s.c static irqreturn_t t14s_ec_irq_handler(int irq, void *data) · line 642
Quoted 13 lines
drivers/platform/arm64/lenovo-thinkpad-t14s.c +13
-0+case hwmon_fan: +if (attr == hwmon_fan_input) { +int lsb, msb; + ret =t14s_ec_read (ec,T14S_EC_FAN_RPM_LSB , &lsb); +if (ret) +return ret; + + ret =t14s_ec_read (ec,T14S_EC_FAN_RPM_MSB , &msb); +if (ret) +return ret; + + *val =0 ; + *val = lsb + (msb <<8 );
'+' looks funny here.. although t14s_ec_read() only reads a single byte and assigns a u8 value to the u32 that's being passed to it, so it never *actually* breaks..
[...]
Quoted 17 lines
drivers/platform/arm64/lenovo-thinkpad-t14s.c +17
-0+static const struct hwmon_channel_info *t14s_ec_hwmon_info[] = { +HWMON_CHANNEL_INFO (temp, +HWMON_T_INPUT |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_LABEL ), +HWMON_CHANNEL_INFO (fan,HWMON_F_INPUT ), +NULL +}; + +static const struct hwmon_chip_info t14s_ec_chip_info = { + .ops = &t14s_ec_hwmon_ops, + .info = t14s_ec_hwmon_info, +}; +
drivers/platform/arm64/lenovo-thinkpad-t14s.c static irqreturn_t t14s_ec_irq_handler(int irq, void *data) · line 686
Quoted 10 lines
drivers/platform/arm64/lenovo-thinkpad-t14s.c +10
-0+static int t14s_ec_hwmon_probe (struct t14s_ec *ec) +{ +struct device *dev; +struct t14s_ec_hwmon_sys_thermx sys_thermx[] = { + {T14S_EC_SYS_THERM0 ,"soc" }, + {T14S_EC_SYS_THERM1 ,"keyboard" }, + {T14S_EC_SYS_THERM2 ,"base" }, + {T14S_EC_SYS_THERM3 ,"pmbm" }, + {T14S_EC_SYS_THERM6 ,"qtm" }, + {T14S_EC_SYS_THERM7 ,"ssd" },
Makes one wonder what happened to THERM4/5 - may they be dedicated to the 5G modem, perhaps?
Konrad
Re: [PATCH v1 1/3] drivers/platform: lenovo-t14s-ec: Add hwmon support for temperatures and fan speed
Le 25/06/2026 à 10:03, Konrad Dybcio a écrit :
Quoted 62 lines · Daniel Lezcano
Quoted 16 lines
Expose the Lenovo ThinkPad T14s EC environmental sensors through the hwmon subsystem.
The driver now registers a hwmon device providing access to six EC temperature sensors corresponding to the SoC, keyboard area, base cover, PMIC/charging circuitry, QTM module and SSD. Sensor labels are exported to allow user space to identify each measurement.
Additionally, expose the system fan speed by reading the fan RPM registers from the embedded controller.
This allows standard monitoring tools such as lm-sensors to report platform temperatures and fan speed.
Signed-off-by Daniel Lezcano [email protected]---
[...]
drivers/platform/arm64/lenovo-thinkpad-t14s.c static irqreturn_t t14s_ec_irq_handler(int irq, void *data) · line 642
Quoted 13 lines
drivers/platform/arm64/lenovo-thinkpad-t14s.c +13
-0+case hwmon_fan: +if (attr == hwmon_fan_input) { +int lsb, msb; + ret =t14s_ec_read (ec,T14S_EC_FAN_RPM_LSB , &lsb); +if (ret) +return ret; + + ret =t14s_ec_read (ec,T14S_EC_FAN_RPM_MSB , &msb); +if (ret) +return ret; + + *val =0 ; + *val = lsb + (msb <<8 );'+' looks funny here.. although
t14s_ec_read()only reads a single byte and assigns a u8 value to the u32 that's being passed to it, so it never *actually* breaks..[...]
Quoted 22 lines
drivers/platform/arm64/lenovo-thinkpad-t14s.c +22
-0+static const struct hwmon_channel_info *t14s_ec_hwmon_info[] = { +HWMON_CHANNEL_INFO (temp, +HWMON_T_INPUT |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_LABEL ), +HWMON_CHANNEL_INFO (fan,HWMON_F_INPUT ), +NULL +}; + +static const struct hwmon_chip_info t14s_ec_chip_info = { + .ops = &t14s_ec_hwmon_ops, + .info = t14s_ec_hwmon_info, +}; + +static int t14s_ec_hwmon_probe (struct t14s_ec *ec) +{ +struct device *dev; +struct t14s_ec_hwmon_sys_thermx sys_thermx[] = { + {T14S_EC_SYS_THERM0 ,"soc" },
Quoted 8 lines
drivers/platform/arm64/lenovo-thinkpad-t14s.c static irqreturn_t t14s_ec_irq_handler(int irq, void *data) · line 686
Quoted 5 lines
drivers/platform/arm64/lenovo-thinkpad-t14s.c +5
-0+ { T14S_EC_SYS_THERM1, "keyboard" }, + { T14S_EC_SYS_THERM2, "base" }, + { T14S_EC_SYS_THERM3, "pmbm" }, + { T14S_EC_SYS_THERM6, "qtm" }, + { T14S_EC_SYS_THERM7, "ssd" },Makes one wonder what happened to THERM4/5 - may they be dedicated to the 5G modem, perhaps?
May be, I sticked to the documentation description which is not describing THERM4/5
Sebastian Reichel
maintainerRe: [PATCH v1 1/3] drivers/platform: lenovo-t14s-ec: Add hwmon support for temperatures and fan speed
In reply to Daniel LezcanoHi,
Quoted 8 lines · Daniel Lezcano
Expose the Lenovo ThinkPad T14s EC environmental sensors through the hwmon subsystem.
The driver now registers a hwmon device providing access to six EC temperature sensors corresponding to the SoC, keyboard area, base cover, PMIC/charging circuitry, QTM module and SSD. Sensor labels are exported to allow user space to identify each measurement.
Quoted 8 lines
Additionally, expose the system fan speed by reading the fan RPM registers from the embedded controller.
This allows standard monitoring tools such as lm-sensors to report platform temperatures and fan speed.
Signed-off-by Daniel Lezcano [email protected]---
I gave this a try and for me the fan data is always 65535 (i.e. -1):
$ cat /sys/class/hwmon/hwmon66/{name,fan1_input}
t14s_ec
65535This is with the fan running:
$ cat /sys/class/hwmon/hwmon57/{name,fan1_input}
fan-controller
2564The thermal data looks good.
Greetings,
-- Sebastian
Quoted 195 lines
drivers/platform/arm64/lenovo-thinkpad-t14s.c | 147 ++++++++++++++++++ 1 file changed, 147 insertions(+)drivers/platform/arm64/lenovo-thinkpad-t14s.c +147
-0@@ -11,6 +11,7 @@#include <linux/delay.h> #include <linux/dev_printk.h> #include <linux/err.h> +#include <linux/hwmon.h> #include <linux/i2c.h> #include <linux/input.h> #include <linux/input/sparse-keymap.h> @@ -67,6 +68,16 @@#define T14S_EC_EVT_KEY_FN_F11 0x7a#define T14S_EC_EVT_KEY_FN_G 0x7e +#define T14S_EC_SYS_THERM0 0x78/* SoC (CPU+GPU) */ +#define T14S_EC_SYS_THERM1 0x79/* Keyboard */ +#define T14S_EC_SYS_THERM2 0x7a/* Back cover */ +#define T14S_EC_SYS_THERM3 0x7b/* Charger / PMIC */ +#define T14S_EC_SYS_THERM6 0x7c/* QTM West */ +#define T14S_EC_SYS_THERM7 0x7d/* SSD */ + +#define T14S_EC_FAN_RPM_LSB 0x84 +#define T14S_EC_FAN_RPM_MSB 0x85 +/* Hardware LED blink rate is 1 Hz (500ms off, 500ms on) */ #define T14S_EC_BLINK_RATE_ON_OFF_MS 500@@ -93,9 +104,19 @@ struct t14s_ec_led_classdev {struct t14s_ec *ec; }; +struct t14s_ec_hwmon_sys_thermx { +const char *label; +int reg; +}; + +struct t14s_ec_hwmon { +struct t14s_ec_hwmon_sys_thermx *sys_thermx; +}; +struct t14s_ec {struct regmap *regmap;struct device *dev; +struct t14s_ec_hwmon ec_hwmon;struct t14s_ec_led_classdev led_pwr_btn;struct t14s_ec_led_classdev led_chrg_orange;struct t14s_ec_led_classdev led_chrg_white;@@ -555,6 +576,128 @@ static irqreturn_t t14s_ec_irq_handler(int irq, void *data)return IRQ_HANDLED ; } +static umode_t t14s_ec_hwmon_is_visible (const void *drvdata, +enum hwmon_sensor_types type, +u32 attr,int channel) +{ +switch (type) { +case hwmon_temp: +return 0444 ; +case hwmon_fan: +return 0444 ; +default : +return 0 ; + } +} + +static int t14s_ec_hwmon_read_string (struct device *dev,enum hwmon_sensor_types type, +u32 attr,int channel,const char **str) +{ +struct t14s_ec *ec =dev_get_drvdata (dev); +switch (type) { +case hwmon_temp: +if (attr == hwmon_temp_label) { + *str = ec->ec_hwmon.sys_thermx[channel].label; +return 0 ; + } +break ; +default : +return -EOPNOTSUPP ; + } + +return -EOPNOTSUPP ; +} + +static int t14s_ec_hwmon_read (struct device *dev,enum hwmon_sensor_types type, +u32 attr,int channel,long *val) +{ +struct t14s_ec *ec =dev_get_drvdata (dev); +unsigned int value; +int ret; + +switch (type) { +case hwmon_temp: +if (attr == hwmon_temp_input) { + ret =t14s_ec_read (ec, ec->ec_hwmon.sys_thermx[channel].reg, &value); +if (ret) +return ret; + *val = value *1000 ; + +return 0 ; + } +break ; + +case hwmon_fan: +if (attr == hwmon_fan_input) { +int lsb, msb; + ret =t14s_ec_read (ec,T14S_EC_FAN_RPM_LSB , &lsb); +if (ret) +return ret; + + ret =t14s_ec_read (ec,T14S_EC_FAN_RPM_MSB , &msb); +if (ret) +return ret; + + *val =0 ; + *val = lsb + (msb <<8 ); + +return 0 ; + } +break ; +default : +break ; + } + +return -EOPNOTSUPP ; +} + +static const struct hwmon_ops t14s_ec_hwmon_ops = { + .is_visible = t14s_ec_hwmon_is_visible, + .read = t14s_ec_hwmon_read, + .read_string = t14s_ec_hwmon_read_string, +}; + +static const struct hwmon_channel_info *t14s_ec_hwmon_info[] = { +HWMON_CHANNEL_INFO (temp, +HWMON_T_INPUT |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_LABEL ), +HWMON_CHANNEL_INFO (fan,HWMON_F_INPUT ), +NULL +}; + +static const struct hwmon_chip_info t14s_ec_chip_info = { + .ops = &t14s_ec_hwmon_ops, + .info = t14s_ec_hwmon_info, +}; + +static int t14s_ec_hwmon_probe (struct t14s_ec *ec) +{ +struct device *dev; +struct t14s_ec_hwmon_sys_thermx sys_thermx[] = { + {T14S_EC_SYS_THERM0 ,"soc" }, + {T14S_EC_SYS_THERM1 ,"keyboard" }, + {T14S_EC_SYS_THERM2 ,"base" }, + {T14S_EC_SYS_THERM3 ,"pmbm" }, + {T14S_EC_SYS_THERM6 ,"qtm" }, + {T14S_EC_SYS_THERM7 ,"ssd" }, + }; + + ec->ec_hwmon.sys_thermx =devm_kmemdup_array (ec->dev, sys_thermx, +ARRAY_SIZE (sys_thermx), +sizeof (sys_thermx[0 ]),GFP_KERNEL ); +if (!ec->ec_hwmon.sys_thermx) +return -ENOMEM ; + + dev =devm_hwmon_device_register_with_info (ec->dev,"t14s_ec" , ec, + &t14s_ec_chip_info,NULL ); + +return PTR_ERR_OR_ZERO (dev); +} +static int t14s_ec_probe (struct i2c_client *client) {struct device *dev = &client->dev;@@ -590,6 +733,10 @@ static int t14s_ec_probe(struct i2c_client *client)if (ret <0 )return ret; + ret =t14s_ec_hwmon_probe (ec); +if (ret <0 ) +return ret; + ret =devm_request_threaded_irq (dev, client->irq,NULL , t14s_ec_irq_handler,IRQF_ONESHOT ,dev_name (dev), ec);Signature · 1 line
2.53.0
Guenter Roeck
maintainerRe: [PATCH v1 1/3] drivers/platform: lenovo-t14s-ec: Add hwmon support for temperatures and fan speed
Quoted 26 lines · Sebastian Reichel
Hi,
Quoted 8 lines · Daniel Lezcano
Expose the Lenovo ThinkPad T14s EC environmental sensors through the hwmon subsystem.
The driver now registers a hwmon device providing access to six EC temperature sensors corresponding to the SoC, keyboard area, base cover, PMIC/charging circuitry, QTM module and SSD. Sensor labels are exported to allow user space to identify each measurement.
Quoted 8 lines
Additionally, expose the system fan speed by reading the fan RPM registers from the embedded controller.
This allows standard monitoring tools such as lm-sensors to report platform temperatures and fan speed.
Signed-off-by Daniel Lezcano [email protected]---
I gave this a try and for me the fan data is always 65535 (i.e. -1):
$ cat /sys/class/hwmon/hwmon66/{name,fan1_input} t14s_ec 65535
Quoted 6 lines
This is with the fan running:
$ cat /sys/class/hwmon/hwmon57/{name,fan1_input} fan-controller 2564
Not really my concern, but those names really add zero value, and I would argue that they do not "allow user space to identify each measurement".
Also, do you really have 66 hwmon devices on those systems ? Seems unusual.
Guenter
Re: [PATCH v1 1/3] drivers/platform: lenovo-t14s-ec: Add hwmon support for temperatures and fan speed
Quoted 34 lines · Guenter Roeck
Quoted 26 lines · Sebastian Reichel
Hi,
Quoted 8 lines · Daniel Lezcano
Expose the Lenovo ThinkPad T14s EC environmental sensors through the hwmon subsystem.
The driver now registers a hwmon device providing access to six EC temperature sensors corresponding to the SoC, keyboard area, base cover, PMIC/charging circuitry, QTM module and SSD. Sensor labels are exported to allow user space to identify each measurement.
Quoted 8 lines
Additionally, expose the system fan speed by reading the fan RPM registers from the embedded controller.
This allows standard monitoring tools such as lm-sensors to report platform temperatures and fan speed.
Signed-off-by Daniel Lezcano [email protected]---
I gave this a try and for me the fan data is always 65535 (i.e. -1):
$ cat /sys/class/hwmon/hwmon66/{name,fan1_input} t14s_ec 65535Quoted 6 lines
This is with the fan running:
$ cat /sys/class/hwmon/hwmon57/{name,fan1_input} fan-controller 2564
Quoted 6 lines
Not really my concern, but those names really add zero value, and I would argue that they do not "allow user space to identify each measurement".
Also, do you really have 66 hwmon devices on those systems ? Seems unusual.
There's a couple dozen thermal sensors on the SoC and each one is registered with a thermal zone, plus a couple here and there for other onboard peripherals (PMICs and whatnot)
Konrad
Re: [PATCH v1 1/3] drivers/platform: lenovo-t14s-ec: Add hwmon support for temperatures and fan speed
Quoted 39 lines · Konrad Dybcio
Quoted 38 lines · Guenter Roeck
Quoted 26 lines · Sebastian Reichel
Hi,
Quoted 8 lines · Daniel Lezcano
Expose the Lenovo ThinkPad T14s EC environmental sensors through the hwmon subsystem.
The driver now registers a hwmon device providing access to six EC temperature sensors corresponding to the SoC, keyboard area, base cover, PMIC/charging circuitry, QTM module and SSD. Sensor labels are exported to allow user space to identify each measurement.
Quoted 8 lines
Additionally, expose the system fan speed by reading the fan RPM registers from the embedded controller.
This allows standard monitoring tools such as lm-sensors to report platform temperatures and fan speed.
Signed-off-by Daniel Lezcano [email protected]---
I gave this a try and for me the fan data is always 65535 (i.e. -1):
$ cat /sys/class/hwmon/hwmon66/{name,fan1_input} t14s_ec 65535Quoted 6 lines
This is with the fan running:
$ cat /sys/class/hwmon/hwmon57/{name,fan1_input} fan-controller 2564Not really my concern, but those names really add zero value, and I would argue that they do not "allow user space to identify each measurement".
Quoted 6 lines
Quoted 2 lines
Also, do you really have 66 hwmon devices on those systems ? Seems unusual.
There's a couple dozen thermal sensors on the SoC and each one is registered with a thermal zone, plus a couple here and there for other onboard peripherals (PMICs and whatnot)
Yes, the amount of sensors on the SoC is incredibility high and when adding the platform sensors it is even more. Here on my laptop there are 59 thermal zones and 68 hwmon sensors.
I agree with Guenter comment. With all these sensors, from userspace it is painful to find out a specific sensor without going through all sensors name.
While testing the changes at every reboot, the sensor number changed and I have to find out which one it is. It is annoying.
Would it make sense to have a per-name link pointing to the corresponding hwmon / thermal zone directory ?
Re: [PATCH v1 1/3] drivers/platform: lenovo-t14s-ec: Add hwmon support for temperatures and fan speed
In reply to Sebastian ReichelQuoted 17 lines · Sebastian Reichel
Hi,
Quoted 14 lines · Daniel Lezcano
Expose the Lenovo ThinkPad T14s EC environmental sensors through the hwmon subsystem.
The driver now registers a hwmon device providing access to six EC temperature sensors corresponding to the SoC, keyboard area, base cover, PMIC/charging circuitry, QTM module and SSD. Sensor labels are exported to allow user space to identify each measurement.
Additionally, expose the system fan speed by reading the fan RPM registers from the embedded controller.
This allows standard monitoring tools such as lm-sensors to report platform temperatures and fan speed.
Quoted 8 lines
Quoted 2 lines
Signed-off-by Daniel Lezcano [email protected]---
I gave this a try and for me the fan data is always 65535 (i.e. -1):
$ cat /sys/class/hwmon/hwmon66/{name,fan1_input} t14s_ec 65535
Strange, I have:
fan speed=0, temp=40000
fan speed=0, temp=41000
fan speed=0, temp=41000
fan speed=0, temp=43000
fan speed=0, temp=43000
fan speed=0, temp=44000
fan speed=0, temp=44000
fan speed=0, temp=45000
fan speed=0, temp=46000
fan speed=0, temp=46000
fan speed=65535, temp=48000
^^^
fan speed=1903, temp=48000
fan speed=2345, temp=49000
fan speed=2367, temp=49000
fan speed=2417, temp=50000
fan speed=2431, temp=50000
fan speed=2430, temp=51000
fan speed=2441, temp=51000
fan speed=2450, temp=52000
fan speed=2457, temp=52000
fan speed=2458, temp=53000
fan speed=2458, temp=53000
fan speed=2458, temp=54000
fan speed=2460, temp=54000
fan speed=2572, temp=55000
fan speed=2788, temp=55000
fan speed=3009, temp=55000
fan speed=3229, temp=56000
fan speed=3424, temp=56000
fan speed=3610, temp=56000
fan speed=3631, temp=56000
fan speed=3597, temp=56000
fan speed=3594, temp=56000
fan speed=3592, temp=56000
fan speed=3592, temp=56000
fan speed=3588, temp=56000
fan speed=3588, temp=56000
fan speed=3594, temp=56000
fan speed=3594, temp=56000
fan speed=3597, temp=56000
fan speed=3597, temp=56000
fan speed=3594, temp=56000
fan speed=3597, temp=55000
fan speed=3594, temp=55000
fan speed=3594, temp=55000
fan speed=3592, temp=55000
fan speed=3592, temp=54000
fan speed=3588, temp=54000
fan speed=3592, temp=53000
fan speed=3590, temp=53000
fan speed=3592, temp=52000
fan speed=3590, temp=52000
fan speed=3588, temp=52000
fan speed=3588, temp=52000
Quoted 5 lines
This is with the fan running:
$ cat /sys/class/hwmon/hwmon57/{name,fan1_input} fan-controller 2564
PATCH 2/3 platform: arm64: thinkpad-t14s-ec: Wire EC thermal events to hwmon
In reply to Daniel LezcanoThe EC generates thermal zone status change notifications for a subset of the exposed temperature sensors. Wire these EC events to the hwmon notification framework so userspace can be informed when a thermal alarm state changes.
Associate each hwmon temperature channel with its corresponding EC thermal event and emit hwmon_temp_alarm notifications through hwmon_notify_event() when the EC reports a thermal zone status change.
Also register thermal zones in the hwmon chip capabilities and keep a reference to the hwmon device to allow event propagation from the IRQ handler.
This allows userspace monitoring tools to receive thermal alarm updates without polling the sensors and gives the opportuniy to the kernel to cool them down.
--- drivers/platform/arm64/lenovo-thinkpad-t14s.c | 66 ++++++++++++++----- 1 file changed, 51 insertions(+), 15 deletions(-)
drivers/platform/arm64/lenovo-thinkpad-t14s.c +51 -15
@@ -107,10 +107,13 @@ struct t14s_ec_led_classdev {struct t14s_ec_hwmon_sys_thermx {const char *label;int reg; +u8 event; };struct t14s_ec_hwmon { +struct device *dev;struct t14s_ec_hwmon_sys_thermx *sys_thermx; +size_t num_sys_thermx; };struct t14s_ec {
@@ -493,6 +496,20 @@ static int t14s_input_probe(struct t14s_ec *ec)return input_register_device (ec->inputdev); } +static void t14s_ec_hwmon_notify_event (struct t14s_ec *ec,u8 event) +{ +for (int i =0 ; i < ec->ec_hwmon.num_sys_thermx; i++) { +if (ec->ec_hwmon.sys_thermx[i].event != event) +continue ; + +hwmon_notify_event (ec->ec_hwmon.dev, hwmon_temp, + hwmon_temp_alarm, i); + +dev_dbg (ec->dev,"Thermal Zone (%s) Status Change Event\n" , + ec->ec_hwmon.sys_thermx[i].label); + } +} +static irqreturn_t t14s_ec_irq_handler (int irq,void *data) {struct t14s_ec *ec = data;
@@ -542,13 +559,9 @@ static irqreturn_t t14s_ec_irq_handler(int irq, void *data)dev_dbg (ec->dev,"LID closed\n" );break ;case T14S_EC_EVT_THERMAL_TZ40 : -dev_dbg (ec->dev,"Thermal Zone 40 Status Change Event (CPU/GPU)\n" ); -break ;case T14S_EC_EVT_THERMAL_TZ42 : -dev_dbg (ec->dev,"Thermal Zone 42 Status Change Event (Battery)\n" ); -break ;case T14S_EC_EVT_THERMAL_TZ39 : -dev_dbg (ec->dev,"Thermal Zone 39 Status Change Event (CPU/GPU)\n" ); +t14s_ec_hwmon_notify_event (ec, val);break ;case T14S_EC_EVT_KEY_FN_G :dev_dbg (ec->dev,"FN + G - toggle double-tapping\n" );
@@ -658,6 +671,7 @@ static const struct hwmon_ops t14s_ec_hwmon_ops = { };static const struct hwmon_channel_info *t14s_ec_hwmon_info[] = { +HWMON_CHANNEL_INFO (chip,HWMON_C_REGISTER_TZ ), HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_LABEL, HWMON_T_INPUT | HWMON_T_LABEL,
@@ -676,14 +690,34 @@ static const struct hwmon_chip_info t14s_ec_chip_info = {static int t14s_ec_hwmon_probe (struct t14s_ec *ec) { -struct device *dev;struct t14s_ec_hwmon_sys_thermx sys_thermx[] = { - {T14S_EC_SYS_THERM0 ,"soc" }, - {T14S_EC_SYS_THERM1 ,"keyboard" }, - {T14S_EC_SYS_THERM2 ,"base" }, - {T14S_EC_SYS_THERM3 ,"pmbm" }, - {T14S_EC_SYS_THERM6 ,"qtm" }, - {T14S_EC_SYS_THERM7 ,"ssd" }, + { + .label ="soc" , + .reg =T14S_EC_SYS_THERM0 , + .event =T14S_EC_EVT_THERMAL_TZ39 + }, + { + .label ="keyboard" , + .reg =T14S_EC_SYS_THERM1 , + .event =T14S_EC_EVT_THERMAL_TZ40 + }, + { + .label ="base" , + .reg =T14S_EC_SYS_THERM2 , + }, + { + .label ="pmbm" , + .reg =T14S_EC_SYS_THERM3 , + .event =T14S_EC_EVT_THERMAL_TZ42 + }, + { + .label ="qtm" , + .reg =T14S_EC_SYS_THERM6 + }, + { + .label ="ssd" , + .reg =T14S_EC_SYS_THERM7 + }, }; ec->ec_hwmon.sys_thermx = devm_kmemdup_array(ec->dev, sys_thermx,
@@ -692,10 +726,12 @@ static int t14s_ec_hwmon_probe(struct t14s_ec *ec)if (!ec->ec_hwmon.sys_thermx)return -ENOMEM ; - dev =devm_hwmon_device_register_with_info (ec->dev,"t14s_ec" , ec, - &t14s_ec_chip_info,NULL ); + ec->ec_hwmon.num_sys_thermx =ARRAY_SIZE (sys_thermx); + + ec->ec_hwmon.dev =devm_hwmon_device_register_with_info (ec->dev,"t14s_ec" , ec, + &t14s_ec_chip_info,NULL ); -return PTR_ERR_OR_ZERO (dev); +return PTR_ERR_OR_ZERO (ec->ec_hwmon.dev); }static int t14s_ec_probe (struct i2c_client *client)
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v1 2/3] platform: arm64: thinkpad-t14s-ec: Wire EC thermal events to hwmon
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Missing HWMON_T_ALARM capability prevents sysfs notification from working. --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Missing HWMON_T_ALARM capability prevents sysfs notification from working. --
commit 1242d377b6327e98b089989a953188982e0ca595
Author: Daniel Lezcano <[email protected]>
platform: arm64: thinkpad-t14s-ec: Wire EC thermal events to hwmon
This patch wires up EC thermal zone status change notifications to the hwmon notification framework. It associates hwmon temperature channels with EC thermal events and emits hwmon_temp_alarm notifications to userspace.
Quoted 4 lines
drivers/platform/arm64/lenovo-thinkpad-t14s.c +0
-0
[ ... ]
Quoted 18 lines
drivers/platform/arm64/lenovo-thinkpad-t14s.c +14
-0@@ -493,6 +496,20 @@ static int t14s_input_probe(struct t14s_ec *ec)return input_register_device (ec->inputdev); } +static void t14s_ec_hwmon_notify_event (struct t14s_ec *ec,u8 event) +{ +for (int i =0 ; i < ec->ec_hwmon.num_sys_thermx; i++) { +if (ec->ec_hwmon.sys_thermx[i].event != event) +continue ; + +hwmon_notify_event (ec->ec_hwmon.dev, hwmon_temp, + hwmon_temp_alarm, i); + +dev_dbg (ec->dev,"Thermal Zone (%s) Status Change Event\n" , + ec->ec_hwmon.sys_thermx[i].label); + } +} +
[ ... ]
drivers/platform/arm64/lenovo-thinkpad-t14s.c static const struct hwmon_ops t14s_ec_hwmon_ops = {
Quoted 12 lines
drivers/platform/arm64/lenovo-thinkpad-t14s.c +1
-0@@ -658,6 +671,7 @@ static const struct hwmon_ops t14s_ec_hwmon_ops = { };static const struct hwmon_channel_info *t14s_ec_hwmon_info[] = { +HWMON_CHANNEL_INFO (chip,HWMON_C_REGISTER_TZ ), HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_LABEL, HWMON_T_INPUT | HWMON_T_LABEL,drivers/platform/arm64/lenovo-thinkpad-t14s.c +0
-0HWMON_T_INPUT |HWMON_T_LABEL ,HWMON_T_INPUT |HWMON_T_LABEL ,HWMON_T_INPUT |HWMON_T_LABEL , HWMON_T_INPUT | HWMON_T_LABEL),
[Severity: Medium]
Will the hwmon_temp_alarm notifications successfully reach userspace?
The channel configuration array does not include the HWMON_T_ALARM capability for any of the temperature channels. Without this, the hwmon core will not create the corresponding tempX_alarm sysfs attributes.
When t14s_ec_hwmon_notify_event() calls hwmon_notify_event() for hwmon_temp_alarm, it appears the sysfs notification will fail silently because the attribute does not exist. The thermal subsystem still receives the event via hwmon_thermal_notify(), but userspace monitoring tools will not be able to read or poll the sysfs attributes.
Does HWMON_T_ALARM need to be added to the channel configurations here to make the sysfs event notification work as described in the commit message?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
PATCH 3/3 arm64: dts: qcom: x1e78100-t14s: Add thermal zones for keyboard skin and charging sensors
In reply to Daniel LezcanoAdd thermal zone descriptions for the keyboard skin temperature and battery charging circuitry sensors exposed by the embedded controller.
Expose the EC as a thermal sensor provider and define two thermal zones using the temperatures reported by the EC:
- a keyboard skin temperature zone with passive and hot trip points,
- a charging circuitry temperature zone with multiple passive trip points and CPU frequency mitigation levels.
The charging thermal zone progressively throttles the different CPU clusters as the charging circuitry temperature rises and triggers a hot condition at the highest trip point.
This provides thermal framework integration for the EC temperature sensors and enables platform thermal management through standard thermal zone definitions.
--- .../qcom/x1e78100-lenovo-thinkpad-t14s.dtsi | 68 ++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dtsi +67 -1
@@ -979,7 +979,7 @@ &i2c6 { status = "okay"; - embedded-controller@28 { + ec: embedded-controller@28 { compatible = "lenovo,thinkpad-t14s-ec"; reg = <0x28>;
@@ -988,6 +988,8 @@ embedded-controller@28 { pinctrl-0 = <&ec_int_n_default>; pinctrl-names = "default"; + #thermal-sensor-cells = <1>; + wakeup-source; }; };
@@ -1729,3 +1731,67 @@ &usb_mp_qmpphy1 { status = "okay"; }; + +&thermal_zones { + ec-keyboard-thermal { + polling-delay = <5000>; + polling-delay-passive = <1000>; + + thermal-sensors = <&ec 1>; + + trips { + trip-point0 { + temperature = <55000>; + hysteresis = <2000>; + type = "passive"; + }; + + trip-point1 { + temperature = <62000>; + hysteresis = <0>; + type = "hot"; + }; + }; + }; + + ec-charging-thermal { + polling-delay = <5000>; + polling-delay-passive = <2000>; + + thermal-sensors = <&ec 3>; + + trips { + psv0: trip-point0 { + temperature = <55000>; + hysteresis = <0>; + type = "passive"; + }; + + alert0: trip-point1 { + temperature = <63000>; + hysteresis = <0>; + type = "hot"; + }; + }; + + cooling-maps { + map0 { + trip = <&psv0>; + cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu8 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu9 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu10 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu11 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + + }; + }; + + }; +};
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v1 3/3] arm64: dts: qcom: x1e78100-t14s: Add thermal zones for keyboard skin and charging sensors
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The commit message claims the charging thermal zone uses 'multiple passive trip points' to…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The commit message claims the charging thermal zone uses 'multiple passive trip points' to 'progressively throttle the different CPU clusters', but the implementation provides only a single passive trip point that throttles all CPUs simultaneously. --
commit 165036bedb34a29493f4bd0a7af23dab152aff0c
Author: Daniel Lezcano <[email protected]>
arm64: dts: qcom: x1e78100-t14s: Add thermal zones for keyboard skin and charging sensors
Add thermal zone descriptions for the keyboard skin temperature and battery charging circuitry sensors exposed by the embedded controller.
Quoted 6 lines
- a charging circuitry temperature zone with multiple passive trip points and CPU frequency mitigation levels.
The charging thermal zone progressively throttles the different CPU clusters as the charging circuitry temperature rises and triggers a hot condition at the highest trip point.
[Severity: Medium]
Does the implementation match this commit message description?
The commit message claims there are multiple passive trip points and progressive throttling across different CPU clusters. Is a chunk of the patch missing, or should the commit message be updated to reflect the final design shown below?
Quoted 3 lines
arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dtsi +0
-0
[ ... ]
Quoted 9 lines
arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dtsi +9
-0+ ec-charging-thermal { + polling-delay = <5000>; + polling-delay-passive = <2000>; + + thermal-sensors = <&ec 3>; + + trips { + psv0: trip-point0 { + temperature = <55000>;
arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dtsi &usb_mp_qmpphy1 { · line 1775
Quoted 10 lines
arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dtsi +10
-0+ hysteresis = <0>; + type = "passive"; + }; + + alert0: trip-point1 { + temperature = <63000>; + hysteresis = <0>; + type = "hot"; + }; + };
[Severity: Medium]
Only a single passive trip point is defined here in ec-charging-thermal, which doesn't match the "multiple passive trip points" mentioned in the commit message.
Quoted 9 lines
arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dtsi +9
-0+ + cooling-maps { + map0 { + trip = <&psv0>; + cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dtsi &usb_mp_qmpphy1 { · line 1794
Quoted 10 lines
arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dtsi +10
-0+ <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu8 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu9 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu10 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu11 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + + }; + };
[Severity: Medium]
Additionally, all 12 CPUs are tied uniformly to this single trip point. Should this define progressive throttling across different CPU clusters as described in the commit message?
Quoted 3 lines
arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dtsi +3
-0+ + }; +};
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: [PATCH v1 3/3] arm64: dts: qcom: x1e78100-t14s: Add thermal zones for keyboard skin and charging sensors
In reply to Daniel LezcanoQuoted 20 lines · Daniel Lezcano
Add thermal zone descriptions for the keyboard skin temperature and battery charging circuitry sensors exposed by the embedded controller.
Expose the EC as a thermal sensor provider and define two thermal zones using the temperatures reported by the EC:
- a keyboard skin temperature zone with passive and hot trip points,
- a charging circuitry temperature zone with multiple passive trip points and CPU frequency mitigation levels.The charging thermal zone progressively throttles the different CPU clusters as the charging circuitry temperature rises and triggers a hot condition at the highest trip point.
This provides thermal framework integration for the EC temperature sensors and enables platform thermal management through standard thermal zone definitions.
Signed-off-by Daniel Lezcano <[email protected]>---
[...]
arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dtsi &usb_mp_qmpphy1 { · line 1764
Quoted 8 lines
arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dtsi +8
-0+ ec-charging-thermal { + polling-delay = <5000>; + polling-delay-passive = <2000>; + + thermal-sensors = <&ec 3>; + + trips { + psv0: trip-point0 {
"ec_charging_tripN", please - these labels are file-wide, so it's better if they're not overly short
Quoted 19 lines
arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dtsi +19
-0+ temperature = <55000>; + hysteresis = <0>; + type = "passive"; + }; + + alert0: trip-point1 { + temperature = <63000>; + hysteresis = <0>; + type = "hot"; + }; + }; + + cooling-maps { + map0 { + trip = <&psv0>; + cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dtsi &usb_mp_qmpphy1 { · line 1793
Quoted 10 lines
arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dtsi +10
-0+ <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu8 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu9 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu10 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu11 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + + };
Stray \n above, might also possibly want to throttle the GPU. I don't know.
Konrad
Re: [PATCH v1 3/3] arm64: dts: qcom: x1e78100-t14s: Add thermal zones for keyboard skin and charging sensors
Quoted 59 lines · Konrad Dybcio
Quoted 20 lines · Daniel Lezcano
Add thermal zone descriptions for the keyboard skin temperature and battery charging circuitry sensors exposed by the embedded controller.
Expose the EC as a thermal sensor provider and define two thermal zones using the temperatures reported by the EC:
- a keyboard skin temperature zone with passive and hot trip points,
- a charging circuitry temperature zone with multiple passive trip points and CPU frequency mitigation levels.The charging thermal zone progressively throttles the different CPU clusters as the charging circuitry temperature rises and triggers a hot condition at the highest trip point.
This provides thermal framework integration for the EC temperature sensors and enables platform thermal management through standard thermal zone definitions.
Signed-off-by Daniel Lezcano <[email protected]>---
[...]
arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dtsi &usb_mp_qmpphy1 { · line 1764
Quoted 8 lines
arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dtsi +8
-0+ ec-charging-thermal { + polling-delay = <5000>; + polling-delay-passive = <2000>; + + thermal-sensors = <&ec 3>; + + trips { + psv0: trip-point0 {"
ec_charging_tripN", please - these labels are file-wide, so it's better if they're not overly shortQuoted 23 lines
arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dtsi +23
-0+ temperature = <55000>; + hysteresis = <0>; + type = "passive"; + }; + + alert0: trip-point1 { + temperature = <63000>; + hysteresis = <0>; + type = "hot"; + }; + }; + + cooling-maps { + map0 { + trip = <&psv0>; + cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
Quoted 8 lines
arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dtsi &usb_mp_qmpphy1 { · line 1793
Quoted 6 lines
arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dtsi +6
-0+ <&cpu8 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu9 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu10 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu11 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + + };Stray \n above, might also possibly want to throttle the GPU.
At this point, I don't think GPU throttling is needed