Bug 215651

Summary: Battery charge limit is reset on every boot on ASUS laptops
Product: Drivers Reporter: Mthw (matejm98mthw)
Component: Platform_x86Assignee: drivers_platform_x86 (drivers_platform_x86)
Status: RESOLVED INVALID    
Severity: normal CC: adikurthy, dragonn, jimbo2150, jwrdegoede, rui.zhang
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 5.16.10/any Subsystem:
Regression: No Bisected commit-id:

Description Mthw 2022-03-02 07:17:51 UTC
Description:
I have an ASUS TUF laptop that allows setting a battery charge limit. But, one has to re-set this value on every reboot for it to be used.
This causes tools like Powerdevil in KDE Plasma to not work correctly since they assume, that once the value is set, it is remembered until a change happens.
This commit is likely the culprit https://github.com/torvalds/linux/commit/7973353e92ee1e7ca3b2eb361a4b7cb66c92abee#diff-38095ba4871836b9eeaa6e1904739d398da72cda890e5ef932daec2995579db3R429-R434 as it says that the value is reset on every reboot.

Additional info:
* Originally reported on 5.16.10 but applies to every version
* Links:
bad commit?: https://github.com/torvalds/linux/commit/7973353e92ee1e7ca3b2eb361a4b7cb66c92abee#diff-38095ba4871836b9eeaa6e1904739d398da72cda890e5ef932daec2995579db3R429-R434
KDE bug tracker: https://bugs.kde.org/show_bug.cgi?id=450551
Arch Linux bug tracker: https://bugs.archlinux.org/task/73996

Steps to reproduce:
0. Have an ASUS laptop
1. echo 60 > /sys/class/power_supply/BAT0/charge_control_end_threshold
2. reboot
3. the value is reset to 100
Comment 1 Jim 2022-05-29 11:40:22 UTC
Same issue on Asus ZenBook Flip 15 with 5.17 and 5.18 kernel.
Comment 2 Mateusz 2022-06-27 06:23:23 UTC
This is not a bug, this is how the hardware works, you need some kind a program with does reapply that value at boot. They is no way for the kernel to make it persistent just because the hardware doesn't support persisted charger limit.
Most users on ASUS laptops use asusctl for that: https://gitlab.com/asus-linux/asusctl it works on TUF laptops too and charger limit control should work on ZenBooks too, you only need to manually add asusd-alt service and enable it
Comment 3 Mthw 2022-06-27 07:34:29 UTC
(In reply to Mateusz from comment #2)
> This is not a bug, this is how the hardware works, you need some kind a
> program with does reapply that value at boot. They is no way for the kernel
> to make it persistent just because the hardware doesn't support persisted
> charger limit.
> Most users on ASUS laptops use asusctl for that:
> https://gitlab.com/asus-linux/asusctl it works on TUF laptops too and
> charger limit control should work on ZenBooks too, you only need to manually
> add asusd-alt service and enable it

So, if KDE Plasma has a feature that allows you to set a battery charge limit, it's up to them to re-set it on every boot, right?
Comment 4 Hans de Goede 2022-06-27 07:45:01 UTC
> So, if KDE Plasma has a feature that allows you to set a battery charge
> limit, it's up to them to re-set it on every boot, right?

Right.