From fe6aea87b88048530448c25ab2c3b093fcce8697 Mon Sep 17 00:00:00 2001 From: Lef Date: Wed, 25 Nov 2026 13:02:03 +0200 Subject: [PATCH 1/5] omamobile-device-husky 0.1.22: start the charge limit unit on add only The charge limit rule wanted omamobile-charge-limit-apply.service on every power_supply event of max77759-charger. On 2026-11-25 the charger's CHGIN input bounced near the end of a charge from a desktop port and the unit started 6968 times in one boot, up to about 10 a second; the SoC went from 53-54 C to 57-59 C over the same 11 minutes (a timing match, not measured per process). The systemd tag stays on every event (with the whole rule on add only the unit did not start at boot on 2026-11-16, most likely from the lost tag), and SYSTEMD_WANTS is now set on add only. The unit drops StartLimitIntervalSec=0, so systemd's default start limit caps any future storm. test/all checks both lines of the rule and the unit. Not run on the phone yet: the check is one boot (the unit runs once) and a plug/unplug (it does not run). --- packages/omamobile-device-husky/test/all | 9 +++++++++ .../systemd/system/omamobile-charge-limit-apply.service | 1 - .../vendor/udev/rules.d/75-omamobile-charge-limit.rules | 8 +++++--- packages/omamobile-device-husky/version | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/omamobile-device-husky/test/all b/packages/omamobile-device-husky/test/all index 55bc53d92..4dce8ae41 100755 --- a/packages/omamobile-device-husky/test/all +++ b/packages/omamobile-device-husky/test/all @@ -207,6 +207,15 @@ grep -qx 'supply=max77759-charger' "$tmp/root/usr/share/omamobile/charge-limit.c [[ ! -e $tmp/root/usr/lib/systemd/system/multi-user.target.wants/omamobile-charge-limit-apply.service ]] \ || fail "the apply unit is pulled in by udev, not enabled" pass "the charge limit declaration, its udev rule and the apply unit are staged; the unit is not enabled" +rule=vendor/udev/rules.d/75-omamobile-charge-limit.rules +grep -qx 'SUBSYSTEM=="power_supply", KERNEL=="max77759-charger", TAG+="systemd"' "$rule" \ + || fail "the charger keeps its systemd tag on every event" +grep -qx 'SUBSYSTEM=="power_supply", KERNEL=="max77759-charger", ACTION=="add", ENV{SYSTEMD_WANTS}+="omamobile-charge-limit-apply.service"' "$rule" \ + || fail "the apply unit is wanted on add only" +[[ $(grep -c 'SYSTEMD_WANTS' "$rule") -eq 1 ]] || fail "one SYSTEMD_WANTS line, the add one" +! grep -q '^StartLimitIntervalSec=0' vendor/systemd/system/omamobile-charge-limit-apply.service \ + || fail "systemd's start limit stays on for the apply unit" +pass "the charge limit unit is wanted on add only, the tag stays on every event, and its start limit is on" # --- the AoC start: hang marker, nothing without the node ------------------ diff --git a/packages/omamobile-device-husky/vendor/systemd/system/omamobile-charge-limit-apply.service b/packages/omamobile-device-husky/vendor/systemd/system/omamobile-charge-limit-apply.service index 9b68fd111..3a37f1255 100644 --- a/packages/omamobile-device-husky/vendor/systemd/system/omamobile-charge-limit-apply.service +++ b/packages/omamobile-device-husky/vendor/systemd/system/omamobile-charge-limit-apply.service @@ -5,7 +5,6 @@ # Not enabled. [Unit] Description=Apply the saved charge limit -StartLimitIntervalSec=0 After=local-fs.target ConditionFileIsExecutable=/usr/lib/omamobile-settings/charge-limit diff --git a/packages/omamobile-device-husky/vendor/udev/rules.d/75-omamobile-charge-limit.rules b/packages/omamobile-device-husky/vendor/udev/rules.d/75-omamobile-charge-limit.rules index 2555686e8..935fc703f 100644 --- a/packages/omamobile-device-husky/vendor/udev/rules.d/75-omamobile-charge-limit.rules +++ b/packages/omamobile-device-husky/vendor/udev/rules.d/75-omamobile-charge-limit.rules @@ -2,6 +2,8 @@ # Apply the saved charge limit (/etc/omamobile/charge-limit) when the MAX77759 charger appears, at every boot, # through omamobile-charge-limit-apply.service rather than inside the udev worker. The helper acts only on the # supply this package declares in /usr/share/omamobile/charge-limit.conf; no saved file: nothing is touched. -# No ACTION filter: with ACTION=="add" the device loses its systemd tag on the charger's next change event, and -# the unit did not start at boot on husky (2026-11-16); without it, it does. -SUBSYSTEM=="power_supply", KERNEL=="max77759-charger", TAG+="systemd", ENV{SYSTEMD_WANTS}+="omamobile-charge-limit-apply.service" +# The systemd tag goes on every event: with the whole rule on add only, the unit did not start at boot on husky +# (2026-11-16), most likely as the device lost the tag on the next change event. The unit is wanted on add only: wanted on every +# change, a bouncing charger input started it 6968 times in one boot (2026-11-25). +SUBSYSTEM=="power_supply", KERNEL=="max77759-charger", TAG+="systemd" +SUBSYSTEM=="power_supply", KERNEL=="max77759-charger", ACTION=="add", ENV{SYSTEMD_WANTS}+="omamobile-charge-limit-apply.service" diff --git a/packages/omamobile-device-husky/version b/packages/omamobile-device-husky/version index 790629964..7e72641b4 100644 --- a/packages/omamobile-device-husky/version +++ b/packages/omamobile-device-husky/version @@ -1 +1 @@ -0.1.21 +0.1.22 From d9eaee2502ec6f8242540ec00b74b51bba194afe Mon Sep 17 00:00:00 2001 From: Lef Date: Wed, 25 Nov 2026 22:50:19 +0200 Subject: [PATCH 2/5] omamobile-device-husky: charge limit unit runs once per charger add Wanting the unit on add only left it unstarted at boot on 2026-11-25: systemd drops a device's udev Wants= and rebuilds them from SYSTEMD_WANTS on every uevent (src/core/device.c, device_setup_unit and device_add_udev_wants), so after the charger's first change event Wants= was empty. The same code starts every wanted unit again on each event unless it is already active, which is what turned the old every-event rule into 6968 starts of a oneshot that went inactive after each run. So the rule is back to one line with SYSTEMD_WANTS on every event, and the unit gets RemainAfterExit=yes (stays active, change events skip it) and StopWhenUnneeded=yes (stops when the charger device goes away, so a real add runs it again). The default start limit stays on. test/all checks the rule and both settings; omamobile-settings' charge-backend test now checks RemainAfterExit instead of the dropped StartLimitIntervalSec=0. Not run on the phone yet: check one start after boot, the saved limit in charge_control_end_threshold, and no new start on plug/unplug. Signed-off-by: Lef --- packages/omamobile-device-husky/test/all | 17 +++++++++-------- .../system/omamobile-charge-limit-apply.service | 6 +++++- .../rules.d/75-omamobile-charge-limit.rules | 9 ++++----- .../omamobile-settings/test/charge-backend.sh | 2 +- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/packages/omamobile-device-husky/test/all b/packages/omamobile-device-husky/test/all index 4dce8ae41..485275433 100755 --- a/packages/omamobile-device-husky/test/all +++ b/packages/omamobile-device-husky/test/all @@ -208,14 +208,15 @@ grep -qx 'supply=max77759-charger' "$tmp/root/usr/share/omamobile/charge-limit.c || fail "the apply unit is pulled in by udev, not enabled" pass "the charge limit declaration, its udev rule and the apply unit are staged; the unit is not enabled" rule=vendor/udev/rules.d/75-omamobile-charge-limit.rules -grep -qx 'SUBSYSTEM=="power_supply", KERNEL=="max77759-charger", TAG+="systemd"' "$rule" \ - || fail "the charger keeps its systemd tag on every event" -grep -qx 'SUBSYSTEM=="power_supply", KERNEL=="max77759-charger", ACTION=="add", ENV{SYSTEMD_WANTS}+="omamobile-charge-limit-apply.service"' "$rule" \ - || fail "the apply unit is wanted on add only" -[[ $(grep -c 'SYSTEMD_WANTS' "$rule") -eq 1 ]] || fail "one SYSTEMD_WANTS line, the add one" -! grep -q '^StartLimitIntervalSec=0' vendor/systemd/system/omamobile-charge-limit-apply.service \ - || fail "systemd's start limit stays on for the apply unit" -pass "the charge limit unit is wanted on add only, the tag stays on every event, and its start limit is on" +unit=vendor/systemd/system/omamobile-charge-limit-apply.service +[[ $(grep -v '^#' "$rule" | grep -c .) -eq 1 ]] \ + && grep -qx 'SUBSYSTEM=="power_supply", KERNEL=="max77759-charger", TAG+="systemd", ENV{SYSTEMD_WANTS}+="omamobile-charge-limit-apply.service"' "$rule" \ + && ! grep -v '^#' "$rule" | grep -c ACTION >/dev/null \ + || fail "one rule, tag and SYSTEMD_WANTS on every event (Wants= is rebuilt per uevent)" +grep -qx 'RemainAfterExit=yes' "$unit" && grep -qx 'StopWhenUnneeded=yes' "$unit" \ + || fail "the apply unit stays active after its run (no restart per change event) and stops with the charger" +! grep -q '^StartLimitIntervalSec=0' "$unit" || fail "systemd's start limit stays on for the apply unit" +pass "the charge limit rule wants the unit on every event; the unit runs once per charger add" # --- the AoC start: hang marker, nothing without the node ------------------ diff --git a/packages/omamobile-device-husky/vendor/systemd/system/omamobile-charge-limit-apply.service b/packages/omamobile-device-husky/vendor/systemd/system/omamobile-charge-limit-apply.service index 3a37f1255..398bc719e 100644 --- a/packages/omamobile-device-husky/vendor/systemd/system/omamobile-charge-limit-apply.service +++ b/packages/omamobile-device-husky/vendor/systemd/system/omamobile-charge-limit-apply.service @@ -2,13 +2,17 @@ # Applies the saved charge limit (/etc/omamobile/charge-limit) to the charger this package declares # (/usr/share/omamobile/charge-limit.conf). Pulled in by udev when the charger appears # (75-omamobile-charge-limit.rules); without a saved file the helper does nothing. The helper is omamobile-settings'. -# Not enabled. +# Not enabled. RemainAfterExit= keeps it active after one run, so the charger's change events (each one +# re-wants it) do not start it again (6968 starts in one boot on 2026-11-25 without it). StopWhenUnneeded= stops +# it when the charger device goes away, so a real replug (add) runs it again. [Unit] Description=Apply the saved charge limit After=local-fs.target ConditionFileIsExecutable=/usr/lib/omamobile-settings/charge-limit +StopWhenUnneeded=yes [Service] Type=oneshot +RemainAfterExit=yes ExecStart=/usr/lib/omamobile-settings/charge-limit TimeoutStartSec=15 diff --git a/packages/omamobile-device-husky/vendor/udev/rules.d/75-omamobile-charge-limit.rules b/packages/omamobile-device-husky/vendor/udev/rules.d/75-omamobile-charge-limit.rules index 935fc703f..5a6c1042f 100644 --- a/packages/omamobile-device-husky/vendor/udev/rules.d/75-omamobile-charge-limit.rules +++ b/packages/omamobile-device-husky/vendor/udev/rules.d/75-omamobile-charge-limit.rules @@ -2,8 +2,7 @@ # Apply the saved charge limit (/etc/omamobile/charge-limit) when the MAX77759 charger appears, at every boot, # through omamobile-charge-limit-apply.service rather than inside the udev worker. The helper acts only on the # supply this package declares in /usr/share/omamobile/charge-limit.conf; no saved file: nothing is touched. -# The systemd tag goes on every event: with the whole rule on add only, the unit did not start at boot on husky -# (2026-11-16), most likely as the device lost the tag on the next change event. The unit is wanted on add only: wanted on every -# change, a bouncing charger input started it 6968 times in one boot (2026-11-25). -SUBSYSTEM=="power_supply", KERNEL=="max77759-charger", TAG+="systemd" -SUBSYSTEM=="power_supply", KERNEL=="max77759-charger", ACTION=="add", ENV{SYSTEMD_WANTS}+="omamobile-charge-limit-apply.service" +# No ACTION filter: systemd rebuilds a device's Wants= from SYSTEMD_WANTS on every uevent, so a rule on add +# only leaves Wants= empty after the charger's next change event. The unit keeps itself from storming on change +# events (RemainAfterExit=, StopWhenUnneeded=; see the unit). +SUBSYSTEM=="power_supply", KERNEL=="max77759-charger", TAG+="systemd", ENV{SYSTEMD_WANTS}+="omamobile-charge-limit-apply.service" diff --git a/packages/omamobile-settings/test/charge-backend.sh b/packages/omamobile-settings/test/charge-backend.sh index 4ba8f4e93..5990f76f2 100755 --- a/packages/omamobile-settings/test/charge-backend.sh +++ b/packages/omamobile-settings/test/charge-backend.sh @@ -106,7 +106,7 @@ if [[ -d $h ]]; then { echo "FAIL: udev: one rule, no ACTION filter, pulls in the apply unit" >&2; exit 1; } a=$h/vendor/systemd/system/omamobile-charge-limit-apply.service grep -qx 'ExecStart=/usr/lib/omamobile-settings/charge-limit' "$a" && grep -qx 'Type=oneshot' "$a" && - grep -qx 'StartLimitIntervalSec=0' "$a" && ! grep -q '^\[Install\]' "$a" || + grep -qx 'RemainAfterExit=yes' "$a" && ! grep -q '^\[Install\]' "$a" || { echo "FAIL: apply unit: oneshot helper with no argument, not enabled" >&2; exit 1; } grep -qx 'supply=max77759-charger' "$h/charge-limit.conf" || { echo "FAIL: husky declares max77759-charger" >&2; exit 1; } fi From 2f4da3c18d73684919067b9173683b1170e0926d Mon Sep 17 00:00:00 2001 From: Lef Date: Wed, 25 Nov 2026 22:54:35 +0200 Subject: [PATCH 3/5] omamobile-device-husky: say when StopWhenUnneeded re-runs the charge limit Signed-off-by: Lef --- .../vendor/systemd/system/omamobile-charge-limit-apply.service | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/omamobile-device-husky/vendor/systemd/system/omamobile-charge-limit-apply.service b/packages/omamobile-device-husky/vendor/systemd/system/omamobile-charge-limit-apply.service index 398bc719e..bc3034b07 100644 --- a/packages/omamobile-device-husky/vendor/systemd/system/omamobile-charge-limit-apply.service +++ b/packages/omamobile-device-husky/vendor/systemd/system/omamobile-charge-limit-apply.service @@ -4,7 +4,8 @@ # (75-omamobile-charge-limit.rules); without a saved file the helper does nothing. The helper is omamobile-settings'. # Not enabled. RemainAfterExit= keeps it active after one run, so the charger's change events (each one # re-wants it) do not start it again (6968 starts in one boot on 2026-11-25 without it). StopWhenUnneeded= stops -# it when the charger device goes away, so a real replug (add) runs it again. +# it when the charger device goes away (driver unbind or module reload), so the next add runs it again. A cable +# replug does not remove the device; the driver keeps the limit across it (checked 2026-11-25). [Unit] Description=Apply the saved charge limit After=local-fs.target From 0c801c187ba503a6d8179218ee5d7f40bf2ddd0e Mon Sep 17 00:00:00 2001 From: Lef Date: Fri, 27 Nov 2026 07:48:24 +0200 Subject: [PATCH 4/5] omamobile-device-husky: say in the charge limit unit what a failed first run does The boot journal on 2026-11-27 shows systemd marking the charger active on its first change event, not the add, and starting the unit once there. Say that, and that a failed first run is retried on the next change event within systemd's default start limit. Signed-off-by: Lef --- .../systemd/system/omamobile-charge-limit-apply.service | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/omamobile-device-husky/vendor/systemd/system/omamobile-charge-limit-apply.service b/packages/omamobile-device-husky/vendor/systemd/system/omamobile-charge-limit-apply.service index bc3034b07..bb822eaf1 100644 --- a/packages/omamobile-device-husky/vendor/systemd/system/omamobile-charge-limit-apply.service +++ b/packages/omamobile-device-husky/vendor/systemd/system/omamobile-charge-limit-apply.service @@ -6,6 +6,10 @@ # re-wants it) do not start it again (6968 starts in one boot on 2026-11-25 without it). StopWhenUnneeded= stops # it when the charger device goes away (driver unbind or module reload), so the next add runs it again. A cable # replug does not remove the device; the driver keeps the limit across it (checked 2026-11-25). +# systemd marks the charger active on its first change event, not the add (boot journal 2026-11-27), so +# that is the start. If that first run fails the unit is left failed, and the next change event wants it +# again: it is retried, within systemd's default start limit (5 starts in 10 s), not left failed until the +# next boot. (Read from systemd's behaviour and the 2026-11-25 count; a failing first run is not tested.) [Unit] Description=Apply the saved charge limit After=local-fs.target From 28bdaeeee8c63b849f3ec7ce1e38ffe2317296f6 Mon Sep 17 00:00:00 2001 From: Lef Date: Fri, 27 Nov 2026 07:50:27 +0200 Subject: [PATCH 5/5] omamobile-device-husky: tie the charge limit unit's note to the boot it came from Signed-off-by: Lef --- .../systemd/system/omamobile-charge-limit-apply.service | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/omamobile-device-husky/vendor/systemd/system/omamobile-charge-limit-apply.service b/packages/omamobile-device-husky/vendor/systemd/system/omamobile-charge-limit-apply.service index bb822eaf1..53afcf92d 100644 --- a/packages/omamobile-device-husky/vendor/systemd/system/omamobile-charge-limit-apply.service +++ b/packages/omamobile-device-husky/vendor/systemd/system/omamobile-charge-limit-apply.service @@ -6,8 +6,8 @@ # re-wants it) do not start it again (6968 starts in one boot on 2026-11-25 without it). StopWhenUnneeded= stops # it when the charger device goes away (driver unbind or module reload), so the next add runs it again. A cable # replug does not remove the device; the driver keeps the limit across it (checked 2026-11-25). -# systemd marks the charger active on its first change event, not the add (boot journal 2026-11-27), so -# that is the start. If that first run fails the unit is left failed, and the next change event wants it +# On the 2026-11-27 boot systemd marked the charger active on its first change event, not the add, so +# that was the start. If that first run fails the unit is left failed, and the next change event wants it # again: it is retried, within systemd's default start limit (5 starts in 10 s), not left failed until the # next boot. (Read from systemd's behaviour and the 2026-11-25 count; a failing first run is not tested.) [Unit]