Closed ncfavier closed 2 years ago
Hi,
tlp recalibrate
and tlp discharge
use the same code section to enable discharge. A loop waits until the battery actually discharges. Every second it outputs a dot, for a maximum of 15 seconds.
With my X1C6 (Intel) I have observed very different times for the process. It takes up to about 10 seconds.
How many dots does tlp discharge
output when successful?
Actually this issue only happens when the battery is charged above the start threshold: running recalibrate
sets the threshold to 96 so the battery transitions from Unknown to Charging first, and the command fails. Running it again transitions from Charging to Discharging and works.
Now I'm hitting another issue mentioned in the FAQ: after reaching 0%, recalibrate
fails with Error: battery BAT0 was not discharged completely i.e. terminated by the firmware -- check your hardware.
. Same brand new hardware.
As said above: the output of tlp recalibrate
in exactly the error situation would be helpful.
About the 0%: everything is said in the FAQ, i do not intend to intercept every peculiarity (bug?) of the Lenovo firmware.
$ # battery is at 80% Unknown
$ sudo tlp recalibrate
Setting temporary charge thresholds for BAT0:
stop = 100
start = 96
Initiating discharge of battery BAT0 ...............
Error: discharge BAT0 malfunction -- check your hardware (battery, charger).
Battery recalibration aborted.
$ # battery is now at 80% Charging
$ sudo tlp recalibrate
Setting temporary charge thresholds for BAT0:
start = 96 (no change)
stop = 100 (no change)
Initiating discharge of battery BAT0 ..
[screen clears]
Currently discharging battery BAT0:
voltage = 12184 [mV]
remaining capacity = 47270 [mWh]
remaining percent = 80 [%]
remaining time = 217 [min]
power = 13036 [mW]
state = Discharging
force discharge = 1
Press Ctrl+C to cancel.
I enhanced the trace output and would like you to retest this situation with the main branch. After installing, please enable trace mode by adding
TLP_DEBUG="bat ps run"
to your configuration.
Then i need again the output of tlp recalibrate
and the trace output:
sudo tlp-stat -T
On f7b7ff747ab1fb479cd83d6bc25902ab70ecdbf9:
Nov 24 20:08:00 no tlp[548384]: batdrv.thinkpad.write_force_discharge(BAT0, 1): bm_dischg=tpacpi; bf_dischg=; bat_idx=1; rc=0
tpacpi-bat returns success when setting force-discharge
Nov 24 20:08:16 no tlp[548384]: batdrv.thinkpad.read_force_discharge(BAT0): bm_dischg=tpacpi; bf_dischg=; bat_idx=1; out=0; rc=0
but the actual state doesn't change. Looks like the EC firmware silently discards force-discharge when the battery status is "Charging". Lets try to reproduce it with tpacpi-bat alone:
Starting point as before:
sudo tlp-stat -b; sudo /usr/share/tlp/tpacpi-bat -v -s FD 1 1; sudo /usr/share/tlp/tpacpi-bat -v -g FD 1; sudo tlp-stat -b
When I ran the commands above, the status wasn't Charging, it was Idle/Unknown. It then transitioned to Charging after running recalibrate
(as described in this comment).
I ran your commands twice:
To be clear: this issue is not about tlp recalibrate
. tlp recalibrate
is just tlp setcharge 96 100
(causing the "Charging") followed by tlp discharge
.
The problem is to actually start the forced discharge while "Charging". My last command above is just what tlp discharge
does first, then it waits for "Discharging".
Your outputs show that force-discharge is enabled correctly:
/sys/class/power_supply/BAT0/status = Charging tpacpi-bat.BAT0.forceDischarge = 1
How long does it take afterwards until the battery turns to "Discharging"?
How long does it take afterwards until the battery turns to "Discharging"?
About 2-4 seconds.
Weirdly, sudo tlp setcharge DEF DEF; sleep 1; sudo tlp discharge
works, which seems to be exactly what the script does for recalibrate
. In this case the battery goes from Idle to Discharging (or to Not charging and then Discharging) after 2-3 seconds.
Almost. recalibrate
does not have the sleep 1
. I still don't get what really happens in TLP. Please post the trace output for
sudo tlp setcharge DEF DEF; sudo tlp discharge
Almost.
recalibrate
does not have thesleep 1
.
https://github.com/linrunner/TLP/blob/f7b7ff747ab1fb479cd83d6bc25902ab70ecdbf9/tlp.in#L501
sudo tlp setcharge DEF DEF; sudo tlp discharge
works too.
Nov 25 20:30:42 no tlp[1234931]: batdrv.thinkpad.force_discharge_active(BAT0): bm_read=natacpi; bf=/sys/class/power_supply/BAT0/status; st=Not charging; rc=1
An initial "Not charging" is not the necessary condition to reproduce the problem. The "malfunction" message happens when setcharge DEF DEF
makes the battery "Charging".
We need a starting point like above
battery is at 80% Unknown
<= 94% is also sufficient.
Or does your hardware behave differently each time?
ps.
https://github.com/linrunner/TLP/blob/f7b7ff747ab1fb479cd83d6bc25902ab70ecdbf9/tlp.in#L501
Oops. Maybe i should look into my code from time to time ;-). But the sleep 1
doesn't cause the problem at hand.
We need a starting point like above
battery is at 80% Unknown
That was the starting point! See the earlier line:
Nov 25 20:30:41 no tlp[1234931]: batdrv.thinkpad.force_discharge_active(BAT0): bm_read=natacpi; bf=/sys/class/power_supply/BAT0/status; st=Unknown; rc=1
All right. But then we still have no trace of the actual error situation.
My hypothesis for the occurrence of the error is:
setcharge DEF DEF
results in battery status "Charging" discharge
sets force-discharge for the batteryProbably your hardware behaves differently sometimes. In the TLP logic, on the other hand, I can see no problem so far.
I suggest you make more attempts to get a trace that shows the timeout. I don't think you need to start from 80% every time.
Any news on this?
No, sorry. Feel free to close for now
[x] I've read and accepted the Bug Reporting Howto [x] I've attached all required
tlp-stat
outputs via Gist (see below)Describe the bug
To Reproduce
Steps to reproduce the unexpected behavior:
tlp-stat
via https://gist.github.com/ for all matching cases of 1. https://gist.github.com/ncfavier/f578877763fc99afad32dde333ecb5f3Additional context
The laptop and charger are brand new and otherwise working properly. The battery is internal.
tlp discharge
seems to work: