linrunner / TLP

TLP - Optimize Linux Laptop Battery Life
https://linrunner.de/tlp
GNU General Public License v2.0
2.51k stars 129 forks source link

STOP_CHARGE_THRESH_BAT1 not honored for Slice 19+ on X220 #735

Closed samveen closed 3 months ago

samveen commented 3 months ago

[x] I've read and accepted the Bug Reporting Howto [x] I've provided all required tlp-stat outputs via Gist (see below)

Describe the bug

The STOP_CHARGE_THRESH_BAT1 threshold for BAT1 (Lenovo Slice 19+) are not honored when charging, and the charging continues till 100%

Expected behavior

The STOP_CHARGE_THRESH_BAT1 threshold for BAT1 (Lenovo Slice 19+) should be honored when charging, and the charging should stop at the configured percentage.

To Reproduce

Steps to reproduce the unexpected behavior:

  1. Let the battery discharge below the STOP_CHARGE_THRESH_BAT1.
  2. Connect the charger back to the Slice 19+ and start charging.
  3. Let charging complete.

** tlp-stat -b while discharging

samveen@samveen-x220:~$ sudo tlp-stat -b
--- TLP 1.6.1 --------------------------------------------

+++ Battery Care
Plugin: thinkpad
Supported features: charge thresholds, recalibration
Driver usage:
* natacpi (thinkpad_acpi) = active (charge thresholds, recalibration)
* tp-smapi (tp_smapi)     = readonly (status)
Parameter value ranges:
* START_CHARGE_THRESH_BAT0/1:  0(off)..96(default)..99
* STOP_CHARGE_THRESH_BAT0/1:   1..100(default)

+++ ThinkPad Battery Status: BAT0 (Main / Internal)
/sys/devices/platform/smapi/BAT0/manufacturer               = LGC
/sys/devices/platform/smapi/BAT0/model                      = 45N1029
/sys/devices/platform/smapi/BAT0/manufacture_date           = 2016-03-22
/sys/devices/platform/smapi/BAT0/first_use_date             = 2016-10-04
/sys/devices/platform/smapi/BAT0/cycle_count                =    219
/sys/devices/platform/smapi/BAT0/temperature                =     37 [°C]
/sys/devices/platform/smapi/BAT0/design_capacity            =  86580 [mWh]
/sys/devices/platform/smapi/BAT0/last_full_capacity         =   4970 [mWh]
/sys/devices/platform/smapi/BAT0/remaining_capacity         =   4090 [mWh]
/sys/devices/platform/smapi/BAT0/remaining_percent          =     82 [%]
/sys/devices/platform/smapi/BAT0/remaining_running_time_now = not_discharging [min]
/sys/devices/platform/smapi/BAT0/remaining_charging_time    = not_charging [min]
/sys/devices/platform/smapi/BAT0/power_now                  =      0 [mW]
/sys/devices/platform/smapi/BAT0/power_avg                  =      0 [mW]
/sys/devices/platform/smapi/BAT0/state                      = idle

/sys/class/power_supply/BAT0/charge_control_start_threshold =     75 [%]
/sys/class/power_supply/BAT0/charge_control_end_threshold   =     85 [%]
/sys/class/power_supply/BAT0/charge_behaviour               = [auto] inhibit-charge force-discharge

Charge                                                      =   82.3 [%]
Capacity                                                    =    5.7 [%]

+++ ThinkPad Battery Status: BAT1 (Ultrabay / Slice / Replaceable)
/sys/devices/platform/smapi/BAT1/manufacturer               = SONY
/sys/devices/platform/smapi/BAT1/model                      = 42T4967
/sys/devices/platform/smapi/BAT1/manufacture_date           = 2015-06-12
/sys/devices/platform/smapi/BAT1/first_use_date             = 2020-02-21
/sys/devices/platform/smapi/BAT1/cycle_count                =     19
/sys/devices/platform/smapi/BAT1/temperature                =     37 [°C]
/sys/devices/platform/smapi/BAT1/design_capacity            =  64380 [mWh]
/sys/devices/platform/smapi/BAT1/last_full_capacity         =  61330 [mWh]
/sys/devices/platform/smapi/BAT1/remaining_capacity         =  48340 [mWh]
/sys/devices/platform/smapi/BAT1/remaining_percent          =     79 [%]
/sys/devices/platform/smapi/BAT1/remaining_running_time_now =    182 [min]
/sys/devices/platform/smapi/BAT1/remaining_charging_time    = not_charging [min]
/sys/devices/platform/smapi/BAT1/power_now                  = -12842 [mW]
/sys/devices/platform/smapi/BAT1/power_avg                  = -13111 [mW]
/sys/devices/platform/smapi/BAT1/state                      = discharging

/sys/class/power_supply/BAT1/charge_control_start_threshold =     75 [%]
/sys/class/power_supply/BAT1/charge_control_end_threshold   =     85 [%]
/sys/class/power_supply/BAT1/charge_behaviour               = [auto] inhibit-charge force-discharge

Charge                                                      =   78.8 [%]
Capacity                                                    =   95.3 [%]

+++ Charge total                                            =   79.1 [%]

** tlp-stat -b while charging

samveen@samveen-x220:~$ sudo tlp-stat -b
--- TLP 1.6.1 --------------------------------------------

+++ Battery Care
Plugin: thinkpad
Supported features: charge thresholds, recalibration
Driver usage:
* natacpi (thinkpad_acpi) = active (charge thresholds, recalibration)
* tp-smapi (tp_smapi)     = readonly (status)
Parameter value ranges:
* START_CHARGE_THRESH_BAT0/1:  0(off)..96(default)..99
* STOP_CHARGE_THRESH_BAT0/1:   1..100(default)

+++ ThinkPad Battery Status: BAT0 (Main / Internal)
/sys/devices/platform/smapi/BAT0/manufacturer               = LGC
/sys/devices/platform/smapi/BAT0/model                      = 45N1029
/sys/devices/platform/smapi/BAT0/manufacture_date           = 2016-03-22
/sys/devices/platform/smapi/BAT0/first_use_date             = 2016-10-04
/sys/devices/platform/smapi/BAT0/cycle_count                =    219
/sys/devices/platform/smapi/BAT0/temperature                =     37 [°C]
/sys/devices/platform/smapi/BAT0/design_capacity            =  86580 [mWh]
/sys/devices/platform/smapi/BAT0/last_full_capacity         =   4970 [mWh]
/sys/devices/platform/smapi/BAT0/remaining_capacity         =   4090 [mWh]
/sys/devices/platform/smapi/BAT0/remaining_percent          =     82 [%]
/sys/devices/platform/smapi/BAT0/remaining_running_time_now = not_discharging [min]
/sys/devices/platform/smapi/BAT0/remaining_charging_time    = not_charging [min]
/sys/devices/platform/smapi/BAT0/power_now                  =      0 [mW]
/sys/devices/platform/smapi/BAT0/power_avg                  =      0 [mW]
/sys/devices/platform/smapi/BAT0/state                      = idle

/sys/class/power_supply/BAT0/charge_control_start_threshold =     75 [%]
/sys/class/power_supply/BAT0/charge_control_end_threshold   =     85 [%]
/sys/class/power_supply/BAT0/charge_behaviour               = [auto] inhibit-charge force-discharge

Charge                                                      =   82.3 [%]
Capacity                                                    =    5.7 [%]

+++ ThinkPad Battery Status: BAT1 (Ultrabay / Slice / Replaceable)
/sys/devices/platform/smapi/BAT1/manufacturer               = SONY
/sys/devices/platform/smapi/BAT1/model                      = 42T4967
/sys/devices/platform/smapi/BAT1/manufacture_date           = 2015-06-12
/sys/devices/platform/smapi/BAT1/first_use_date             = 2020-02-21
/sys/devices/platform/smapi/BAT1/cycle_count                =     19
/sys/devices/platform/smapi/BAT1/temperature                =     37 [°C]
/sys/devices/platform/smapi/BAT1/design_capacity            =  64380 [mWh]
/sys/devices/platform/smapi/BAT1/last_full_capacity         =  61330 [mWh]
/sys/devices/platform/smapi/BAT1/remaining_capacity         =  49310 [mWh]
/sys/devices/platform/smapi/BAT1/remaining_percent          =     80 [%]
/sys/devices/platform/smapi/BAT1/remaining_running_time_now = not_discharging [min]
/sys/devices/platform/smapi/BAT1/remaining_charging_time    =     78 [min]
/sys/devices/platform/smapi/BAT1/power_now                  =  17394 [mW]
/sys/devices/platform/smapi/BAT1/power_avg                  =  17346 [mW]
/sys/devices/platform/smapi/BAT1/state                      = charging

/sys/class/power_supply/BAT1/charge_control_start_threshold =     75 [%]
/sys/class/power_supply/BAT1/charge_control_end_threshold   =     85 [%]
/sys/class/power_supply/BAT1/charge_behaviour               = [auto] inhibit-charge force-discharge

Charge                                                      =   80.4 [%]
Capacity                                                    =   95.3 [%]

+++ Charge total                                            =   80.5 [%]

** tlp-stat -b once the threshold is breached:

samveen@samveen-x220:~$ sudo tlp-stat -b
--- TLP 1.6.1 --------------------------------------------

+++ Battery Care
Plugin: thinkpad
Supported features: charge thresholds, recalibration
Driver usage:
* natacpi (thinkpad_acpi) = active (charge thresholds, recalibration)
* tp-smapi (tp_smapi)     = readonly (status)
Parameter value ranges:
* START_CHARGE_THRESH_BAT0/1:  0(off)..96(default)..99
* STOP_CHARGE_THRESH_BAT0/1:   1..100(default)

+++ ThinkPad Battery Status: BAT0 (Main / Internal)
/sys/devices/platform/smapi/BAT0/manufacturer               = LGC
/sys/devices/platform/smapi/BAT0/model                      = 45N1029
/sys/devices/platform/smapi/BAT0/manufacture_date           = 2016-03-22
/sys/devices/platform/smapi/BAT0/first_use_date             = 2016-10-04
/sys/devices/platform/smapi/BAT0/cycle_count                =    219
/sys/devices/platform/smapi/BAT0/temperature                =     37 [°C]
/sys/devices/platform/smapi/BAT0/design_capacity            =  86580 [mWh]
/sys/devices/platform/smapi/BAT0/last_full_capacity         =   4970 [mWh]
/sys/devices/platform/smapi/BAT0/remaining_capacity         =   4090 [mWh]
/sys/devices/platform/smapi/BAT0/remaining_percent          =     82 [%]
/sys/devices/platform/smapi/BAT0/remaining_running_time_now = not_discharging [min]
/sys/devices/platform/smapi/BAT0/remaining_charging_time    = not_charging [min]
/sys/devices/platform/smapi/BAT0/power_now                  =      0 [mW]
/sys/devices/platform/smapi/BAT0/power_avg                  =      0 [mW]
/sys/devices/platform/smapi/BAT0/state                      = idle

/sys/class/power_supply/BAT0/charge_control_start_threshold =     75 [%]
/sys/class/power_supply/BAT0/charge_control_end_threshold   =     85 [%]
/sys/class/power_supply/BAT0/charge_behaviour               = [auto] inhibit-charge force-discharge

Charge                                                      =   82.3 [%]
Capacity                                                    =    5.7 [%]

+++ ThinkPad Battery Status: BAT1 (Ultrabay / Slice / Replaceable)
/sys/devices/platform/smapi/BAT1/manufacturer               = SONY
/sys/devices/platform/smapi/BAT1/model                      = 42T4967
/sys/devices/platform/smapi/BAT1/manufacture_date           = 2015-06-12
/sys/devices/platform/smapi/BAT1/first_use_date             = 2020-02-21
/sys/devices/platform/smapi/BAT1/cycle_count                =     19
/sys/devices/platform/smapi/BAT1/temperature                =     37 [°C]
/sys/devices/platform/smapi/BAT1/design_capacity            =  64380 [mWh]
/sys/devices/platform/smapi/BAT1/last_full_capacity         =  61330 [mWh]
/sys/devices/platform/smapi/BAT1/remaining_capacity         =  52920 [mWh]
/sys/devices/platform/smapi/BAT1/remaining_percent          =     86 [%]
/sys/devices/platform/smapi/BAT1/remaining_running_time_now = not_discharging [min]
/sys/devices/platform/smapi/BAT1/remaining_charging_time    =     65 [min]
/sys/devices/platform/smapi/BAT1/power_now                  =  17538 [mW]
/sys/devices/platform/smapi/BAT1/power_avg                  =  17526 [mW]
/sys/devices/platform/smapi/BAT1/state                      = charging

/sys/class/power_supply/BAT1/charge_control_start_threshold =     75 [%]
/sys/class/power_supply/BAT1/charge_control_end_threshold   =     85 [%]
/sys/class/power_supply/BAT1/charge_behaviour               = [auto] inhibit-charge force-discharge

Charge                                                      =   86.3 [%]
Capacity                                                    =   95.3 [%]

+++ Charge total                                            =   86.0 [%]

Additional Environment Context

samveen@samveen-x220:~$ uname -a
Linux samveen-x220 6.1.65-060165-generic #202312031100-Ubuntu SMP PREEMPT_DYNAMIC Sun Dec  3 12:00:13 UTC x86_64 x86_64 x86_64 GNU/Linux
samveen@samveen-x220:~$ grep VER /etc/os-release 
VERSION="20.04.6 LTS (Focal Fossa)"
VERSION_ID="20.04"
VERSION_CODENAME=focal
samveen@samveen-x220:~$ apt show tp-smapi-dkms acpi-call-dkms tlp 2>/dev/null |grep -E '^Package|^Version|^APT-Sources'
Package: tp-smapi-dkms
Version: 0.43-1
APT-Sources: http://in.archive.ubuntu.com/ubuntu focal/universe amd64 Packages
Package: acpi-call-dkms
Version: 1.2.2-0~focal
APT-Sources: http://ppa.launchpad.net/linrunner/tlp/ubuntu focal/main amd64 Packages
Package: tlp
Version: 1.6.1-2~focal1
APT-Sources: http://ppa.launchpad.net/linrunner/tlp/ubuntu focal/main amd64 Packages

** Non-default configuration

samveen@samveen-x220:~$ sudo tlp-stat --cdiff
--- TLP 1.6.1 --------------------------------------------

+++ Configured Settings (only differences to defaults):
/etc/tlp.d/03-cpu-restrictions.conf L0007: CPU_ENERGY_PERF_POLICY_ON_AC="balance_power"
/etc/tlp.d/01-wlan-powersave-off.conf L0002: WIFI_PWR_ON_BAT="off"
/etc/tlp.d/02-battery-thresholds.conf L0005: START_CHARGE_THRESH_BAT0="75"
/etc/tlp.d/02-battery-thresholds.conf L0006: STOP_CHARGE_THRESH_BAT0="85"
/etc/tlp.d/02-battery-thresholds.conf L0008: START_CHARGE_THRESH_BAT1="75"
/etc/tlp.d/02-battery-thresholds.conf L0009: STOP_CHARGE_THRESH_BAT1="85"
/etc/tlp.d/03-cpu-restrictions.conf L0001: CPU_DRIVER_OPMODE_ON_AC="active"
/etc/tlp.d/03-cpu-restrictions.conf L0002: CPU_DRIVER_OPMODE_ON_BAT="active"
/etc/tlp.d/03-cpu-restrictions.conf L0004: CPU_SCALING_GOVERNOR_ON_AC="powersave"
/etc/tlp.d/03-cpu-restrictions.conf L0005: CPU_SCALING_GOVERNOR_ON_BAT="powersave"
/etc/tlp.d/03-cpu-restrictions.conf L0010: CPU_MIN_PERF_ON_AC="0"
/etc/tlp.d/03-cpu-restrictions.conf L0011: CPU_MAX_PERF_ON_AC="30"
/etc/tlp.d/03-cpu-restrictions.conf L0012: CPU_MIN_PERF_ON_BAT="0"
/etc/tlp.d/03-cpu-restrictions.conf L0013: CPU_MAX_PERF_ON_BAT="30"
/etc/tlp.d/03-cpu-restrictions.conf L0015: CPU_BOOST_ON_AC="0"
/etc/tlp.d/03-cpu-restrictions.conf L0016: CPU_BOOST_ON_BAT="0"
linrunner commented 3 months ago

Your output clearly shows that the thresholds are set correctly:

+++ ThinkPad Battery Status: BAT1 (Ultrabay / Slice / Replaceable) [...] /sys/class/power_supply/BAT1/charge_control_start_threshold = 75 [%] /sys/class/power_supply/BAT1/charge_control_end_threshold = 85 [%]

So the behavior is due to your ThinkPad, not TLP. I wouldn't expect everything to still work perfectly on hardware that is about 12 years old.

samveen commented 3 months ago

@linrunner Would you be able to point me towards where I might check for the underlying issue?

linrunner commented 3 months ago

If I did that for every charge threshold hiccup on ThinkPads, the issue tracker would become a support forum and I wouldn't have time to develop anymore.

Just this much: the standard workaround for older models is to reset the EC - remove all batteries, disconnect the power supply, hold the power button for 30 seconds.

https://linrunner.de/tlp//faq/battery.html#faq-thinkpad-thresholds-not-respected

samveen commented 3 months ago

Thank you !!!

And apologies. It's very easy for forget that helpful people are taking time out from their priorities to make life easier for us, and to not take more of their time. Thank you for making my life easier for the last 4 thinkpads I've had :bow: