Skip to content

iptsd@.service stops itself ~6s after start on cold boot due to StopWhenUnneeded=yes - #219

Open
L0g0ff wants to merge 1 commit into
linux-surface:masterfrom
L0g0ff:fix/iptsd-service-stop-when-unneeded
Open

iptsd@.service stops itself ~6s after start on cold boot due to StopWhenUnneeded=yes#219
L0g0ff wants to merge 1 commit into
linux-surface:masterfrom
L0g0ff:fix/iptsd-service-stop-when-unneeded

Conversation

@L0g0ff

@L0g0ff L0g0ff commented Aug 20, 2026

Copy link
Copy Markdown

Problem

iptsd@.service sets StopWhenUnneeded=yes, but the unit is only ever
activated via udev's SYSTEMD_WANTS on the hidraw device unit - a
one-time job trigger, not a persistent Wants=. As a result, systemd
decides nothing "needs" the unit a few seconds after start and stops
it, even though the hidraw device is still present.

On cold boot this means: iptsd starts, connects to the IPTS device,
and is stopped by systemd itself ~6s later. Touch/pen then stop
working until the hidraw device is recreated (e.g. by suspend/resume,
which re-triggers the udev rule).

Evidence

  • StopWhenUnneeded=yes was added in bcb12c6 together with
    BindsTo=%I (later fixed to %i.device for escaping in 72afde5),
    with the stated goal "make sure the service stops when the device is
    removed."
  • Per systemd.unit(5), BindsTo= already fully covers that case:
    "...it also does so when a listed unit stops unexpectedly...the
    backing device of a device unit might be unplugged."
  • StopWhenUnneeded= is a different, unrelated mechanism: "a unit will
    be automatically cleaned up if no other active unit requires it" -
    which is exactly what breaks here, since nothing durably "requires"
    a udev-triggered instance.

Reproduction (Surface Pro 4, Fedora 44)

$ journalctl -u 'iptsd@dev-hidraw3.service' -b
Aug 20 06:08:33 surface iptsd[1339]: [info] Connected to device 045E:0984
Aug 20 06:08:33 surface iptsd[1339]: [info] Running in Touchscreen mode
Aug 20 06:08:39 surface systemd[1]: Stopping iptsd@dev-hidraw3.service...
Aug 20 06:08:39 surface systemd[1]: iptsd@dev-hidraw3.service: Deactivated successfully.

Manual workaround that confirms/fixes it: systemctl edit iptsd@.service
with StopWhenUnneeded=no - service stays active across cold boot,
touch/pen work normally. This has also been confirmed working on the
reporter's Surface Pro 4.

Fix

Remove StopWhenUnneeded= - BindsTo=%i.device already provides the
originally intended "stop on device removal" behavior.

Related KompassOS tracking issue: L0g0ff/KompassOS#85

StopWhenUnneeded=yes was added in bcb12c6 alongside BindsTo=%I to make
sure iptsd stops when its backing hidraw device is removed. BindsTo=
already covers that case on its own (see systemd.unit(5): a unit bound
to a device is stopped when the device is unplugged).

StopWhenUnneeded= instead ties the unit's lifetime to whether any other
active unit still "needs" it via a Wants=/Requires= dependency. Since
iptsd@.service is only ever started through udev's SYSTEMD_WANTS on the
hidraw device unit - a one-time job trigger, not a persistent Wants= -
no unit ever durably "needs" it, so systemd stops iptsd a few seconds
after every start, even while the device is still present. This breaks
touch/pen on cold boot until the device is recreated (e.g. by
suspend/resume, which re-triggers the udev rule).

Removing StopWhenUnneeded= keeps the intended "stop when device is
removed" behavior via BindsTo=, and fixes the premature-stop regression.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant