[TRACKING] Linux battery life tuning

Indeed, that was it. Thanks!

1 Like

Great! I’ve added such a check to the script now too.

2 Likes

The issue might not be directly related to docking afterall. In the last few days I have specifically paid attention to when the issue appears. I have written a small script which checks for s0ix residency (/sys/kenrel/debug/amd_pmc/s0ix_stats) after every suspend, and I was able to trigger the issue after only a few suspends without attaching or detaching anything in between.

Is there anything I can do to analyze this behavior further?

Is it possible that this is somehow related to [TRACKING] Framework AMD Ryzen 7040 Series lid wakeup behavior feedback?

Observations:

  • Hardware sleep state residency is way smaller if keys are pressed during the 10 second sleep duration of the amd_s2idle.py script (laptop does not wake from sleep due to kernel workaround for spurious IRQs)
  • Without any key presses during suspend, the laptop suspends reliably
  • Randomly pressing keys during suspend makes it more likely for the issue to appear
  • Pressing keys during regular suspend and waking the laptop shortly afterwards sometimes results in weird behavior: Sometimes everything works, sometimes the KDE Plasma Wayland session crashes (back to display manager), and sometimes the whole system crashes (Black Screen → Framework Logo → Bootloader, journald stops after entering s2idle)

Does anyone know whether recent-ish kernels - the 6 series - help with battery life? Thanks.

1 Like

Seems this patch has landed in 6.10.7 as it no longer applies… Is that correct @Mario_Limonciello?

Which patch?

It’s about the same feeling to me. The biggest indicators of battery life are going to be hardware and your tlp profile (disabling turbo boost on bat and throttling to 25% instead of the default 30% on bat made a huge difference for me recently).

New tip I’ve discovered, something I installed enabled avahi-daemon on my laptop (upon further research it may have been CUPS, even though I don’t have cups-browsed installed). Setting it and its socket to disabled on battery power dropped my idle power consumption on an 11th gen i5 (original panel, original speakers) to 5W. Will update if this causes any functionality issues.

h/t sinatosk for teaching me about more systemd options:

sudo systemctl disable --now avahi-daemon.service avahi-daemon.socket
1 Like

Incase you didn’t know, you can do that in one line

sudo systemctl disable --now avahi-daemon.service avahi-daemon.socket

the “–now” option will stop the services/sockets if they are running.

if you use “–now” with enable then it will start the sercices/sockets

1 Like

I found adding rcu_nocbs=all rcutree.enable_rcu_lazy=1 to my kernel cmdline to be pretty helpful in terms of power savings, although upgraded screen kind if wiped out those power savings…

See https://discourse.ubuntu.com/t/fine-tuning-the-ubuntu-24-04-kernel-for-low-latency-throughput-and-power-efficiency/44834

I also have psi=0 because I have more memory than sense (you probably shouldn’t do this, but PSI accounting was showing up in powertop and I didn’t really need it).

2 Likes

Hello there. @Mario_Limonciello asked you, ‘Which patch?’ I too would like an answer to that question. That is: just what problem, to do with battery life, does something within the 6.10.7 kernel solve, please? Thanks.

EDIT: Using the (paid) program called ‘UKUU’, I installed a 6.10.10 kernel on Linux Mint, on my FW-13, and the machine would not boot; It didn’t even make it past the screen showing the Framework logo. Still, 6.8 is the highest kernel that Mint supports officially currently. (Mint has abandoned its ‘Edge’ edition, but in compensation now the normal versions of Mint use slightly newer kernels than they used to.) I tried kernel 6.10.7 - which is the first kernel to have ‘the patch’ at issue - and that one did not boot either.

Sorry, I was on the wrong thread with “what patch”… I meant the better power consumption for video decoding witch was merged a while ago.

Ah. Thanks for the clarification. But: do you know the kernel in which the (or some?) of the power-saving stuff discussed in this thread arrived?

Recieved my 7640u fw13 October batch today. Running Bazzite and ran the amd_s2idle.py script and recieved two errors “AMDGPU ppfeaturemask overridden to 0xffffffff” and “Kernel is tainted 12289”. Is this anything to be worried about (affect battery life) or should i just ignore them? If so any suggestions on how to fix these errors.

Sounds like a good question for @Jorge_Castro, as he’d have a better idea of it on bazzite.

1 Like

I took another shot at gleaning out more battery life from a 7840u board.
I noticed with lspci -vv that ASPM is reported as disabled for all of the reported devices.

00:02.2 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 14ee (prog-if 00 [Normal decode])
		LnkCap:	Port #4, Speed 16GT/s, Width x1, ASPM L1, Exit Latency L1 <64us
		LnkCtl:	ASPM L1 Enabled; RCB 64 bytes, LnkDisable- CommClk+
00:02.4 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 14ee (prog-if 00 [Normal decode])
		LnkCap:	Port #0, Speed 16GT/s, Width x4, ASPM L1, Exit Latency L1 <64us
		LnkCtl:	ASPM L1 Enabled; RCB 64 bytes, LnkDisable- CommClk+
00:03.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Family 19h USB4/Thunderbolt PCIe tunnel (prog-if 00 [Normal decode])
		LnkCap:	Port #247, Speed 2.5GT/s, Width x1, ASPM L1, Exit Latency L1 <4us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk-
00:04.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Family 19h USB4/Thunderbolt PCIe tunnel (prog-if 00 [Normal decode])
		LnkCap:	Port #247, Speed 2.5GT/s, Width x1, ASPM L1, Exit Latency L1 <4us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk-
00:08.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 14eb (prog-if 00 [Normal decode])
pcilib: Error reading /sys/bus/pci/devices/0000:00:08.3/label: Operation not permitted
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
00:08.2 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 14eb (prog-if 00 [Normal decode])
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
00:08.3 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 14eb (prog-if 00 [Normal decode])
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
01:00.0 Network controller: MEDIATEK Corp. MT7922 802.11ax PCI Express Wireless Network Adapter
		LnkCap:	Port #1, Speed 5GT/s, Width x1, ASPM L0s L1, Exit Latency L0s <2us, L1 <8us
		LnkCtl:	ASPM L1 Enabled; RCB 64 bytes, LnkDisable- CommClk+
02:00.0 Non-Volatile memory controller: Samsung Electronics Co Ltd NVMe SSD Controller PM9A1/PM9A3/980PRO (prog-if 02 [NVM Express])
		LnkCap:	Port #0, Speed 16GT/s, Width x4, ASPM L1, Exit Latency L1 <64us
		LnkCtl:	ASPM L1 Enabled; RCB 64 bytes, LnkDisable- CommClk+
c1:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Phoenix1 (rev c4) (prog-if 00 [VGA controller])
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c1:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Rembrandt Radeon High Definition Audio Controller
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c1:00.2 Encryption controller: Advanced Micro Devices, Inc. [AMD] Family 19h (Model 74h) CCP/PSP 3.0 Device
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c1:00.3 USB controller: Advanced Micro Devices, Inc. [AMD] Device 15b9 (prog-if 30 [XHCI])
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c1:00.4 USB controller: Advanced Micro Devices, Inc. [AMD] Device 15ba (prog-if 30 [XHCI])
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c1:00.5 Multimedia controller: Advanced Micro Devices, Inc. [AMD] ACP/ACP3X/ACP6x Audio Coprocessor (rev 63)
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c1:00.6 Audio device: Advanced Micro Devices, Inc. [AMD] Family 17h/19h HD Audio Controller
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c2:00.0 Non-Essential Instrumentation [1300]: Advanced Micro Devices, Inc. [AMD] Device 14ec
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c2:00.1 Signal processing controller: Advanced Micro Devices, Inc. [AMD] AMD IPU Device
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c3:00.0 Non-Essential Instrumentation [1300]: Advanced Micro Devices, Inc. [AMD] Device 14ec
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c3:00.3 USB controller: Advanced Micro Devices, Inc. [AMD] Device 15c0 (prog-if 30 [XHCI])
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c3:00.4 USB controller: Advanced Micro Devices, Inc. [AMD] Device 15c1 (prog-if 30 [XHCI])
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c3:00.5 USB controller: Advanced Micro Devices, Inc. [AMD] Pink Sardine USB4/Thunderbolt NHI controller #1 (prog-if 40 [USB4 Host Interface])
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c3:00.6 USB controller: Advanced Micro Devices, Inc. [AMD] Pink Sardine USB4/Thunderbolt NHI controller #2 (prog-if 40 [USB4 Host Interface])
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
00:02.2 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 14ee (prog-if 00 [Normal decode])
		LnkCap:	Port #4, Speed 16GT/s, Width x1, ASPM L1, Exit Latency L1 <64us
		LnkCtl:	ASPM L1 Enabled; RCB 64 bytes, LnkDisable- CommClk+
00:02.4 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 14ee (prog-if 00 [Normal decode])
		LnkCap:	Port #0, Speed 16GT/s, Width x4, ASPM L1, Exit Latency L1 <64us
		LnkCtl:	ASPM L1 Enabled; RCB 64 bytes, LnkDisable- CommClk+
00:03.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Family 19h USB4/Thunderbolt PCIe tunnel (prog-if 00 [Normal decode])
		LnkCap:	Port #247, Speed 2.5GT/s, Width x1, ASPM L1, Exit Latency L1 <4us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk-
00:04.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Family 19h USB4/Thunderbolt PCIe tunnel (prog-if 00 [Normal decode])
		LnkCap:	Port #247, Speed 2.5GT/s, Width x1, ASPM L1, Exit Latency L1 <4us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk-
00:08.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 14eb (prog-if 00 [Normal decode])
pcilib: Error reading /sys/bus/pci/devices/0000:00:08.3/label: Operation not permitted
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
00:08.2 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 14eb (prog-if 00 [Normal decode])
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
00:08.3 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 14eb (prog-if 00 [Normal decode])
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
01:00.0 Network controller: MEDIATEK Corp. MT7922 802.11ax PCI Express Wireless Network Adapter
		LnkCap:	Port #1, Speed 5GT/s, Width x1, ASPM L0s L1, Exit Latency L0s <2us, L1 <8us
		LnkCtl:	ASPM L1 Enabled; RCB 64 bytes, LnkDisable- CommClk+
02:00.0 Non-Volatile memory controller: Samsung Electronics Co Ltd NVMe SSD Controller PM9A1/PM9A3/980PRO (prog-if 02 [NVM Express])
		LnkCap:	Port #0, Speed 16GT/s, Width x4, ASPM L1, Exit Latency L1 <64us
		LnkCtl:	ASPM L1 Enabled; RCB 64 bytes, LnkDisable- CommClk+
c1:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Phoenix1 (rev c4) (prog-if 00 [VGA controller])
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c1:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Rembrandt Radeon High Definition Audio Controller
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c1:00.2 Encryption controller: Advanced Micro Devices, Inc. [AMD] Family 19h (Model 74h) CCP/PSP 3.0 Device
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c1:00.3 USB controller: Advanced Micro Devices, Inc. [AMD] Device 15b9 (prog-if 30 [XHCI])
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c1:00.4 USB controller: Advanced Micro Devices, Inc. [AMD] Device 15ba (prog-if 30 [XHCI])
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c1:00.5 Multimedia controller: Advanced Micro Devices, Inc. [AMD] ACP/ACP3X/ACP6x Audio Coprocessor (rev 63)
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c1:00.6 Audio device: Advanced Micro Devices, Inc. [AMD] Family 17h/19h HD Audio Controller
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c2:00.0 Non-Essential Instrumentation [1300]: Advanced Micro Devices, Inc. [AMD] Device 14ec
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c2:00.1 Signal processing controller: Advanced Micro Devices, Inc. [AMD] AMD IPU Device
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c3:00.0 Non-Essential Instrumentation [1300]: Advanced Micro Devices, Inc. [AMD] Device 14ec
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c3:00.3 USB controller: Advanced Micro Devices, Inc. [AMD] Device 15c0 (prog-if 30 [XHCI])
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c3:00.4 USB controller: Advanced Micro Devices, Inc. [AMD] Device 15c1 (prog-if 30 [XHCI])
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c3:00.5 USB controller: Advanced Micro Devices, Inc. [AMD] Pink Sardine USB4/Thunderbolt NHI controller #1 (prog-if 40 [USB4 Host Interface])
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
		LnkCtl:	ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk+
c3:00.6 USB controller: Advanced Micro Devices, Inc. [AMD] Pink Sardine USB4/Thunderbolt NHI controller #2 (prog-if 40 [USB4 Host Interface])
		LnkCap:	Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us

I used powertop --auto-tune and pcie_aspm=force and did experience better idle consumption ~3.25w and slightly better suspend power consumption 10% over 10 hours.

I don’t think the intention is to need to force aspm so I suspect the firmware is reporting the hardware incapable for a good reason.

However amd/drm appeared to crash when I started using the computer the next day and I let the screen blank when idle.

[ 7139.117896] amdgpu 0000:c1:00.0: [drm] *ERROR* dc_dmub_srv_log_diagnostic_data: DMCUB error - collecting diagnostic data
[ 7139.218469] usb 1-4: reset full-speed USB device number 2 using xhci_hcd
[ 7139.404653] amdgpu 0000:c1:00.0: [drm] *ERROR* dc_dmub_srv_log_diagnostic_data: DMCUB error - collecting diagnostic data
[ 7139.693252] amdgpu 0000:c1:00.0: [drm] *ERROR* dc_dmub_srv_log_diagnostic_data: DMCUB error - collecting diagnostic data

This triggers the 1fps framebuffer so I had to reboot.

At the time I was charging the computer with the cable in the back left slot.

Is it possible the firmware is not allowing aspm because the port is awake from charging? Could be causing the crash? Or are the usb errors, aspm, and the graphics driver unrelated?

Is anyone else successful with aspm on the 7840u boards?
Are the 7840u boards expected to be capable of aspm on 6.10 kernels?

Heads up: I tried nvme.noacpi=1 on my F-13 AMD, running Linux Mint Cinnamon with a 6.8 kernel and, for the first time, the machine would not resume from suspend.

Don’t use this. It breaks AMD suspend.

4 Likes

Thanks Limonciello.

It is hard to tune battery life under Linux when the computer does not even report its own battery status reliably (or, rather, draws power from the battery when it should not).