"Average rate" calculation amd_s2idle.py appears incorrect.
Brief summary of the problem:
I think the 'Average rate' report by amd_s2idle is off by a factor of 10. Here's an example output:
Userspace suspended for 0:18:03.074130 In a hardware sleep state for 0:17:58.902801 (99.61%) Battery BAT0 lost 870000 µWh (2.03%) [Average rate 0.29W]
The 2% in 20 minutes and 870000 uWh both point to discharge rate close to 3W, not 0.3W.
Hardware description:
Lenovo Thinkpad X13 Gen 4 7840U. I believe the high s2idle current is because the I blew up the headphone jack by squirting 48v phantom power into it.
System information:
- 6.11.5-rt7+
- Debian Bookworm
How to reproduce the issue:
date ; cat /sys/class/power_supply/BAT0/energy_now
-
sudo ./amd_s2idle.py
(sleep for 10-20 minutes) date ; cat /sys/class/power_supply/BAT0/energy_now
Compare the average rate calculation from amd_s2idle with the sysfs values
cc @superm1
Possible Fix
(As a new user I can't fork yet)
diff --git a/scripts/amd_s2idle.py b/scripts/amd_s2idle.py
index 2d659a9..c436f1c 100755
--- a/scripts/amd_s2idle.py
+++ b/scripts/amd_s2idle.py
@@ -1099,8 +1099,8 @@ class S0i3Validator:
action = "lost"
avg = round(
diff
- / 1000000
- / (self.userspace_duration.total_seconds() / 360),
+ * 1e-6
+ / (self.userspace_duration.total_seconds() / 3600),
2,
)
print_color(