Repository navigation
fix(daemon): support single-threshold charging and reject invalid psys - #2
Closed
Lightmarey wants to merge 1 commit into
Closed
Lightmarey wants to merge 1 commit into
Lightmarey wants to merge 1 commit into
Conversation
- charge_control: on ASUS and other laptops that expose only charge_control_end_threshold without start_threshold, writing to p_start raised FileNotFoundError, causing set_limit to roll back to 100% and startup initialization to fail. Check path existence before writing. - rapl: on machines where intel-rapl:1 (psys) is disabled in hardware (enabled == 0), the counter drifts with negligible idle noise (~0.3 W). Filter out disabled psys zones and validate psys against package power to prevent crushing real CPU wattage into fractions of a watt.
Lightmarey
force-pushed
the
fix-asus-charge-and-psys
branch
from
October 3, 2026 12:59
07cdd61 to
b17251e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
摘要
此 PR 修复了华硕(及类似厂商)笔记本电脑上的两个硬件兼容性问题:
charge_control_start_threshold缺失时,防止因FileNotFoundError导致的回滚。psys处理:拒绝处理已禁用(enabled: 0)的intel-raplpsys域;这些域报告的空闲计数器漂移微乎其微,却会导致实际 CPU 功耗读数被强制压低至 0.5 W 以下。根本原因与修复方案
1. 单阈值充电控制(例如
asus-wmi)/sys/class/power_supply/BAT0/charge_control_end_threshold,而没有相应的charge_control_start_threshold。_write_thresholds()方法在执行时无条件尝试写入这两个阈值,从而引发FileNotFoundError(OSError的子类)。这导致set_limit()将self.limit回滚至 100%,并使apply_startup()失败。2. 已禁用/异常的
psys能量域/sys/class/powercap/intel-rapl:1(psys) 虽存在但其enabled状态为0,且能量计数器仅有约 0.3 W 的漂移。由于满足了psys > 0的条件,Sampler将psys视为权威的平台总功耗数据。由于存在measured > sys_w的情况(例如 CPU 封装功耗约为 22 W,而psys仅约 0.3 W),归一化因子k = 0.3 / 22 ≈ 0.014导致 CPU 显示功耗被强制压低至 0.2 W,同时屏幕及其他节点的功耗读数被归零。 * 修复:Rapl中,若enabled == 0,则跳过名为psys的域。Sampler中,将psys采纳为整机功耗源之前,先验证其是否满足psys >= package * 0.7。验证
python3 -m unittest discover -s daemon/tests -v测试顺利通过。charge_control_end_threshold正确显示为 80%,且未发生回退。