Very considerate, thank you. Support will provide a one liner that works in a similar fashion.
Of course, now that I am trying to force this to happen, I cannot get it to trigger. I disabled the service provided by @real_or_random , and I think I reverted the EC settings looking through it, but I cannot get this to happen and itâs been three days.
If there is anything you can think of that I missed in the list below I would be happy to keep driving this with support if I can break it again.
Changes
-
Manually stopped charge-limiter.service
systemctl stop charge-limiter.service
-
Disabled charge-limiter.service
-
Reverted chargecurrentlimit to âNO_LIMITâ (4294967295) by hand (tested with fw-ectool as well)
ectool chargecurrentlimit 4294967295
-
Tested recreation script (fw-ectool changed from original as I have both ectool and fw-ectool on my system now)
#!/bin/bash while true; do date ; fw-ectool fwchargelimit 30 ; fw-ectool console | grep "Battery\|Charge Limit" ; sleep 60 ; date ; fw-ectool fwchargelimit 99 ; fw-ectool console | grep "Battery\|Charge Limit"; sleep 10 done
-
Have run in state with service disabled for 3 days (2 of normal workload, 1 of light workload)
Do you still have a battery limit <100% set in the BIOS? Have you tried the script with a battery level between 31% and 99%? This is required for the fwchargelimit
commands to be effective. (Only then fwchargelimit 30
stops charging and fwchargelimit 99
starts charging.)
Otherwise you may actually be lucky. I can still reproduce it reliably with the script.
Yea, I used the script, and I still have it set to 80% charge in the BIOS. I agree that I may be lucky (though it feels the opposite now that I am trying to capture it), I also ran for months before I encountered this before. I will go ahead and leave it in this state, and see if I can get it to come back.
Had to smile because I can relate (for me, it was something with my car) I digress.
Do keep us posted.
I finally captured it, and got an exact timestamp of the disconnect. Log bundle uploaded to support.
Same problem here, with an 11gen and 13gen intel.
Original charger, original cable.
After months of this problem, I decided to keep track of the charging power with node_expoter and prometheus.
Turns out, even when fully charged, the battery will sometimes report charging of a couple mW (from 20ish to 200ish). This doesnât seem to have a hard correlation with system usage.
But another very interesting thing I noticed after playing around with the official ubuntu battery life guide: I turned off boosting of the CPU completely with TLP. And the âbattery chargin / dischargingâ desktop notifications are now completely gone. So the main culprit of the flipping seems to be the very short bust of required power during clock boosts.
Hereâs a quick graph showing the charge value (calculated with node_power_supply_current_ampere * node_power_supply_voltage_volt
from node_expoter.
Thereâs a tiny bump in load when the battery ist charging for a bit, but itâs not a lot
I now spend an afternoon playing around with different settings in TLP and the result isâŚ
confusing?
No matter what I configure now, I canât get the power flip-flop to trigger. Even with boosting enabled. (including GPU boosting).
The âchargingâ power keeps at absolutely 0 in my monitoring, and the âfully chargedâ status doesnât budge even for a second. And before it was happily doing it multiple times a minute, at times.
The only thing I can see is, that the maxinum CPU frequencies are not reported as high as before.
Example:
You can see that node_exporter
detects the max frequency at 4.6GHz for the P-cores. Which is the maximum spec for my 1340P. (the short down-spikes you can see are moments where I disconnected power to move the laptop).
I thought those were the actual frequencies the core will boost to, so node exporter reports those.
If I had the laptop disconnected, you can see the reported max to be lower (as boost was disabled on battery)
But now I canât get node_exporter to detect the 4.6GHz, no matter what I do. And I suspect that is connected with the fact that the connection is not flip-flopping anymore.
Hereâs a screenshot of my current TLP CPU settings
So, uh, I have no idea what is going on. I will keep an eye out and see if it returns after a couple reboots, maybe.
For completeness sake, Iâm running Xubuntu Jammy on an Intel 1340P
Additionally, it seems my Ugreen 45W charger also works like a charm now.
I tested it under full load (using all cores with blender rendering)
Note: I have a system tray widget that shows me the power drain/charge from the battery by using/sys/class/power_supply/BAT1/current_now
and /sys/class/power_supply/BAT1/voltage_now
- started off as âfully chargedâ
- after 10ish seconds, my widget showed me a battery drain of 0.5W
- A couple seconds later it increased to 2W
- Only after another couple seconds (maybe half a minute after starting the render), my system reported the battery discharging
- When the render was done, the system reported normal charging of the battery
- After it was full again, the system now is still happy with the 45W charger. I now even attached my phone to it, so the charging is halfed. Still no problems
Hm, I guess these settings in theory shouldnât trigger what you see, i.e., that the CPU is limited even on AC. But Iâd recommend disabling all the options, and starting from scratch.
Hm, I just took a look at Optimizing Ubuntu Battery Life, and I think the recommendations are a bit strange. In general, Iâd recommend keeping most of the defaults. TLP has pretty good defaults, and many ticked checkboxes in the guide are not necessary because they correspond to the default. And where they differ, what the guide recommends can be questionable. For example, CPU_SCALING_GOVERNOR_ON_AC=performance
seems to be a strange recommendation. Okay, it doesnât matter that much on AC, but performance
just disables all energy CPU optimizations, even those that make sense on AC and donât hurt performance noticeably. Also, this setting just means that CPU_ERNGERY_PERF_POLICY_ON_AC
will be ignored anyway, so itâs rather confusing to set both. See intel_pstate CPU Performance Scaling Driver â The Linux Kernel documentation for details.
The recommendations may seem odd, but the idea is a user is either connected to power or not, thus disabling everything in terms of noticeable performance or not noticeable performance. Itâs merely a suggestion based on what worked best for us.
Do try the TLP defaults to see if you end up with any difference in flipping.
@real_or_random agreed, that most settings donât make much sense.
After playing around some more, I can definitely say that the boosting is causing this.
But that includes the GPU boosting!
For 2 days I now only have following settings set via TLP (and kept BAT and AC settings the same):
-
CPU_BOOST
set to off -
CPU_HWP_DYN_BOOST
to off - GPU frequencies set to the max that is output via
tlp-stat -g
, but set the boost frequency to the regular max frequency, so it doesnât boost up.
Important: it seems that TLPUI doesnât always load the new settings when saving, so a quick tlp start
is often needed to actually apply the changes (I suspect this behavior screwed with some of the tests I did before)
This works on a i7-1260P
as well as i5-1340P
framework
Do keep sharing what you find as I lack the cycles right now to dedicate specific time to replicate this. If you find something hyper-specific we can improve in docs, awesome share how you arrived there and with your specific hardware and TLP config.
The other day I had some rare flipping again, and I suspect itâs because my kernel got updated from oem-22.04c
to the generic one.
Some of the TLP settings didnât seem to apply with the generic kernel running (mostly the CPU performance settings).
I switched to the newer oem-22.04d
and the problem went away again
Glad to hear this resolved itself. We do have a little application that installed, will monitor for changes in the kernel and alert you.
On my 11th Gen, IF I have an external hub plugged into the back right USB C port, the back left USB C port where I have the power plug will flip-flop between charging and discharging the battery. The solution is a kludge. Unplug the left power for a second and plug it back in. The system then prioritizes that USB C port or so it seems to this layman. The other way to go here is to not plug in the right-hand USB C hub until after the laptop powers up, in which case no flip-flopping. (This on Windows 11 Pro)
I get similar behaviour on the framework 13 amd with ec3.03 watching the EC console I see no events for when itâs been booted powered from the left PD port after an unplug. I get an event again from the right. But itâs not complete and there is a TODO message in the EC console about implementing PD port switching logic. Suspending unplugged seems to bring proper AC powered messages back again after resume when plugging on either side
What I donât understand is why the right USB C port causes problems?
Are both right ports affected by this?
II was responding to jwp who has done a more detailed study of the issue. Mine was the left back port flip-flopping. My guess would be that having a usb hub plugged in to the right back port reduces the power to the left meaning that there is no dedicated power plug USB C port at all.