Odd behaviour of charge controls in sysfs

Hello,

I’m trying to control now the battery charges with the recently merged kernel patches from @Thomas_Weissschuh , and can’t get it to behave similarly to the bios setting.
Setting the battery limit in bios to, say, 80%, causes the laptop to charge up to that level and stay there, with reported charge/discharge current of 0. All I want for now is to be able to change this limit without reboots/GUIs/etc.

There are 2 relevant charge_behaviour modes, but neither does that “out of the box”.

  • auto allows setting the charge_control_{start,end}_threshold values to some percentages (the start/end values must differ). Then the battery charge cycles between those thresholds, as if charger is physically plugged when the battery drained to the “start” level, and physically unplugged at the “end” level. With my limited knowledge this doesn’t seem helpful at all in extending the battery life.
  • inhibit-charge is much closer: the battery level stays the same, reported charge/discharge current is zero. 2 problems, however:
    • there is no way to tell it to charge the battery to the given level, and only then go to the “inhibit” mode, as the bios setting does
    • the state is silently ignored after replugging the cable: the behaviour reads as inhubit-charge, but the battery charges at maximum possible rate up until the limit previously set in bios.
      Am I missing something? Is there a bug (I suspect the replug case is)?

PS:
I understand that it’s trivial to make a small script that will monitor battery level, and go to the inhibit mode at certain level, but

  • doing this in userspace doesn’t feel reliable enough
  • it won’t work when the laptop is off/sleeping

I can’t test this right now, but please disable all the BIOS stuff while using the sysfs API.

The bios charge limit setting can’t really be disabled, only set to 100% (which I believe is the factory default). So I did. I don’t see any other battery-related settings there.
Nothing really changed.
After reboot:

  • I set charge_control_end_threshold to 80,
  • charge_behaviour to auto.
  • the laptop charged to 80%, then started discharging at ~28W rate (as if there was no charger plugged in.).

The inhibit-charge behaviour is also the same:

  • start with plugged charger, battery at some random level
  • set inhibit-charge
  • battery charge stays the same, 0 charge/discharge current
  • unplug and plug back the charger
  • /sys/class/power_supply/BAT1/charge_behaviour still shows inhibit-charge
  • the battery is charging at ~60W rate (maximum my charger can provide), looks like will go up to 100%
  • echo inhibit-charge > charge_behaviour stops charging/discharging