Hi Dave! On Sat, Apr 27, 2024 at 09:57:41PM +0100, Dave Tyson wrote: > On Thu, 2024-04-25 at 21:54 -0400, Malte Dehling wrote: > > I've added some things to the thinkpad acpi driver to allow > > modifying battery charging behavior: keep charge within a range, > > force discharge, disable charging on AC. I think something like > > this would be good to have in NetBSD, but not necessarily how I > > implemented it. So this is mainly a request for discussion :) > > > > I've attached patches for reference and in case anyone wants to use > > them -- tested on my old X230 and W530 but based on my reading and > > studying acpidumps the same should work on most newer models. > > I applied your patch to NetBSD-10.0_STABLE successfully and tested the > kernel on a thinkpad T420s. I set charge_stop=85 and charge_start=15. > With the laptop on mains it stopped charging the battery at the 85% > value. I switched force_discharge=1 and ran a build release to put > some load on, the battery level dropped down and sailed past 15% > towards zero - the thinkpad alarm alerted me and a quick unplug/replug > of the power lead started recharging it. I had vaguely hoped that as > the 15% level was breached the charging of the battery might restart > automatically, i.e force_discharge would reset to zero :-) > > I think this is a really useful feature as there seems to be a view > that charging li-ion cells to 100% reduces their life and it is best > to avoid discharging them below 15%. These figures are what Samsung > recommend on mobiles phones. Thank you for taking the time to test! As you noticed, the force discharge setting will completely empty the battery. This should not trigger an emergency shutdown since your AC adapter remains connected, so at least in that way it's harmless. The only reason I can think of to use force_discharge is for calibration purposes. Some more observations from my systems (the behavior may vary a bit between models): - force_discharge is disabled when the AC adapter is disconnected or the battery is fully drained. - enabling charge_inhibit seems to affect both batteries though disabling it must be done for each battery individually? my systems only have one battery so I can't _really_ test this. - charge_inhibit is _not_ reset when AC power is removed or the battery is drained, so be careful with it -- especially in conjunction with force_discharge. Note that these are not things I programmed, it's just how the embedded controller handles things. In normal operation my thinkpad sits on its docking station and I have charge_start=70 and charge_stop=85 set. This way it will charge to 85% and then over time slowly lose charge until it hits 70% at which point it will charge back up to 85%. I found a lot of discussion online over which numbers are best, but ultimately it's a trade-off. Cheers, -- Malte Dehling
Attachment:
signature.asc
Description: PGP signature