SUMMARY I own a Dell Latitude laptop. While it has been possible to set charging thresholds with `smbios-battery-ctl` for a few years now, Linux 6.12 added support for the standard sysfs charge start/end thresholds in the `dell_laptop` driver. This made powerdevil automatically detect said thresholds and report them to the UI automatically. Neat! ``` # cat /sys/class/power_supply/BAT0/charge_control_{start,end}_threshold 70 85 ``` However, the way the firmware works, exposed now by the driver, is that there is a [`charge_types` attribute](https://lwn.net/Articles/989502/): ``` # cat /sys/class/power_supply/BAT0/charge_types Trickle Fast Standard Adaptive [Custom] ``` The values are documented [in the patchset to be identical to `charge_type`](https://patchwork.kernel.org/project/linux-pm/patch/20241108232438.269156-3-hdegoede@redhat.com/) (which doesn't exist on my system), and the kernel's [sysfs documentation page](https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-power). Two things here: - First, **a bug**: unless `charge_types` is set to `Custom`, **the start/end thresholds sysfs entries have a value but take no effect**. powerdevil incorrectly reports these thresholds (and allows one to change them). So at minimum it should support reading, and perhaps writing, the value `Custom`. - Second, a **feature request**: it'd be awesome for powerdevil to support setting these different values. I primarily use `Custom` with 70-85 during normal use, but when I leave for a long day (e.g. a trip), I set it to `Fast`. Also see #14. SOFTWARE/OS VERSIONS Operating System: Debian GNU/Linux 12 KDE Plasma Version: 6.2.4 Kernel Version: 6.12.3-amd64 (64-bit) Powerdevil 6.2.3, but verified with the code in the master branch.
Thanks for the notice. I'm not yet quite sure how best to tackle this, but I agree it's something that should be implemented somehow. Note: the `charge_types` file does not necessarily exist for all laptops with charge threshold kernel support - also on kernel 6.12, my ThinkPad provides `charge_control_{start,end}_threshold` but lacks `charge_types` .
(In reply to Jakob Petsovits from comment #1) > Thanks for the notice. I'm not yet quite sure how best to tackle this, but I > agree it's something that should be implemented somehow. Thanks for the quick response and confirmation! > Note: the `charge_types` file does not necessarily exist for all laptops > with charge threshold kernel support - also on kernel 6.12, my ThinkPad > provides `charge_control_{start,end}_threshold` but lacks `charge_types` . Indeed. Git grepping through Linux master, it looks like `charge_types` is implemented only by the `dell_laptop` driver. `charge_type` (singular) is implemented by a bunch of power supply drivers (mostly chargers, as far as I can tell), including UCSI (USB-C). `thinkpad_acpi` exposes neither.
(Responding to the priority modification.) I can understand the "wishlist" part for supporting setting/modifying charge types. But as I mentioned, if charge_types is not set to "Custom", charge thresholds are ignored by the firmware (even if set). Powerdevil shows these charge thresholds, making statements like "Battery is configured to charge up to approximately 85%" even when that is not the case. IMHO, this part is a bug, not a wishlist item.
I reported this originally against powerdevil, because powerdevil's daemon/chargethresholdhelper_linux.cpp seems to be the one reading from/writing to sysfs. Was this wrong? Should I be reporting these kind of issues to plasmashell instead?
(In reply to Faidon Liambotis from comment #4) > I reported this originally against powerdevil, because powerdevil's > daemon/chargethresholdhelper_linux.cpp seems to be the one reading > from/writing to sysfs. Was this wrong? Should I be reporting these kind of > issues to plasmashell instead? No, powerdevil was correct at the time. Nate performed a bulk move of powerdevil bugs into a new component within the plasmashell product, so that's where they'll be going forward.
A possibly relevant merge request was started @ https://invent.kde.org/plasma/powerdevil/-/merge_requests/510
Looking for testers of the change proposed in the merge request that was linked in the previous comment! I don't have a laptop of this sort, so I can't quite test if it really fixes your issue. Note that the change only sets the value for `charge_types`, it doesn't read the current one. The idea is that the proposed MR can go into Plasma 6.3 as a bugfix, whereas selecting one of the possible types would require additional code and target an upcoming feature release instead (currently 6.4).
Git commit 54c5159156984265ab6485a2e55152d242eeb130 by Jakob Petsovits. Committed on 02/03/2025 at 22:37. Pushed by jpetso into branch 'master'. daemon: Fix charge threshold support for Dell laptops, maybe more Some kernel drivers expose `charge_types` in addition to start/end charge thresholds for power supply batteries. A prominent example is the `dell_laptop` starting with Linux 6.12, which supports (at least some) Dell Latitude laptops. This commit will attempt to write a charge type on Linux systems if the battery's `charge_types` file exists in sysfs. It will write `Standard` as charge type if the configuration asks for fully charging the laptop, and `Custom` for all other charge threshold values. The KAuth helper also now supports writing explicitly provided charge types, however the settings UI does not make use of this yet. This commit does not (yet) implement reading current or supported charge types, because that's not useful without a settings UI. Note that charge threshold settings are only applied when values are changed, so any pre-existing charge type (e.g. `Fast`) won't be touched without an explicit interaction. M +75 -13 daemon/chargethresholdhelper_linux.cpp https://invent.kde.org/plasma/powerdevil/-/commit/54c5159156984265ab6485a2e55152d242eeb130
Git commit b6fcaca955820f91b94032184cd0173dac9787ae by Jakob Petsovits. Committed on 02/03/2025 at 22:44. Pushed by jpetso into branch 'Plasma/6.3'. daemon: Fix charge threshold support for Dell laptops, maybe more Some kernel drivers expose `charge_types` in addition to start/end charge thresholds for power supply batteries. A prominent example is the `dell_laptop` starting with Linux 6.12, which supports (at least some) Dell Latitude laptops. This commit will attempt to write a charge type on Linux systems if the battery's `charge_types` file exists in sysfs. It will write `Standard` as charge type if the configuration asks for fully charging the laptop, and `Custom` for all other charge threshold values. The KAuth helper also now supports writing explicitly provided charge types, however the settings UI does not make use of this yet. This commit does not (yet) implement reading current or supported charge types, because that's not useful without a settings UI. Note that charge threshold settings are only applied when values are changed, so any pre-existing charge type (e.g. `Fast`) won't be touched without an explicit interaction. (cherry picked from commit 54c5159156984265ab6485a2e55152d242eeb130) Co-authored-by: Jakob Petsovits <jpetso@petsovits.com> M +75 -13 daemon/chargethresholdhelper_linux.cpp https://invent.kde.org/plasma/powerdevil/-/commit/b6fcaca955820f91b94032184cd0173dac9787ae