Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions daemon/clearpowerd/charge_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ def _write_thresholds(self, start, end):
order = order[::-1]
try:
for path, value in order:
write_str(path, value)
if os.path.exists(path):
write_str(path, value)
except OSError:
# firmware quirk: try the other order once before giving up
for path, value in order[::-1]:
write_str(path, value)
if os.path.exists(path):
write_str(path, value)

def _write_behaviour(self, b):
if not self.behaviour_supported:
Expand Down
2 changes: 1 addition & 1 deletion daemon/clearpowerd/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def sample(self, hot=True):
# ---- whole-machine draw ----
if not on_ac and bat_w < -0.05:
sys_w, sys_source = -bat_w, "battery" # physical truth incl. all losses
elif psys > 0:
elif psys > 0 and (package <= 0 or psys >= package * 0.7):
sys_w, sys_source = psys, "psys"
elif package > 0:
sys_w, sys_source = package + 3.0, "estimate"
Expand Down
2 changes: 2 additions & 0 deletions daemon/clearpowerd/sources/rapl.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def __init__(self):
if not name:
continue
key = name.split("-")[0] # package-0 -> package
if key == "psys" and read_int(os.path.join(d, "enabled")) == 0:
continue
self.domains[key] = d
self._wrap = {k: read_int(os.path.join(p, "max_energy_range_uj")) or (1 << 32)
for k, p in self.domains.items()}
Expand Down