Skip to content

udev: Keep the systemd tag across change events - #224

Open
fildunsky wants to merge 1 commit into
linux-surface:masterfrom
fildunsky:udev-keep-systemd-tag-on-change
Open

fildunsky wants to merge 1 commit into
linux-surface:masterfrom
fildunsky:udev-keep-systemd-tag-on-change

Conversation

@fildunsky

Copy link
Copy Markdown

Fixes #163.

The udev rule only matches ACTION=="add". udev rebuilds a device's properties from the rules on every event, so a later change event on the hidraw node drops both TAG+="systemd" and SYSTEMD_WANTS. The device unit goes inactive and iptsd is stopped while /dev/hidrawN is still there. Nothing starts it again until the device is re-added.

This PR matches every action except remove instead, so both are re-applied on change. Real removal behaves as before.

How it shows up

Surface Pro 8 (ITHC, 045E:0C37), Ubuntu 26.04, iptsd 3.1.0. On Ubuntu, snapd reloads udev rules and triggers change on every device whenever a snap is installed. Three times in the journal, installing a snap (obs-studio, kf6-core24, inkscape) stopped iptsd within 1–2 seconds:

systemd-udevd[368]: Configuration file ... (rules reload)
boltd: udev: device changed: authorized -> authorized
systemd[1]: Stopping iptsd@dev-hidraw0.service - Intel Precise Touch & Stylus Daemon...
systemd[1]: iptsd@dev-hidraw0.service: Deactivated successfully.

Afterwards the node is present and ITHC is still bound, but:

$ udevadm info /dev/hidraw0 | grep -E 'CURRENT_TAGS|SYSTEMD_WANTS'
E: CURRENT_TAGS=:seat:
$ systemctl show dev-hidraw0.device -p ActiveState -p Wants
Wants=
ActiveState=inactive

Once, touch and pen stayed dead for over a day until a reboot.

Tested

With this rule as a local override in /etc/udev/rules.d/50-iptsd.rules:

$ sudo udevadm trigger --action=add /dev/hidraw0       # brings the stopped daemon back
$ sudo udevadm trigger --action=change /dev/hidraw0    # what snapd does
$ systemctl is-active iptsd@dev-hidraw0.service
active
$ udevadm info /dev/hidraw0 | grep -E 'CURRENT_TAGS|SYSTEMD_WANTS'
E: SYSTEMD_WANTS=iptsd@dev-hidraw0.service
E: CURRENT_TAGS=:systemd:seat:

The daemon keeps the same PID across the change event; nothing is restarted. iptsd-check-device does run again on each change, which is a read-only descriptor check.

I only reproduced the failure through snap installs, not with a bare udevadm trigger on the unfixed rule. The journal shows the same change event either way, though.

Relation to open PRs

🤖 Generated with Claude Code

https://claude.ai/code/session_01KLPZcjA8vscVEpwGEMZAmK

The rule only matches ACTION=="add". udev rebuilds a device's properties
from the rules on every event, so a later "change" event on the hidraw
node drops both TAG+="systemd" and SYSTEMD_WANTS. The device unit then
goes inactive, and iptsd is stopped while /dev/hidrawN is still present.
Nothing starts it again until the device is re-added.

A plain "udevadm trigger" is enough to hit this. On Ubuntu, snapd does
that whenever a snap is installed, so installing any snap silently kills
touch and pen.

Match every action except "remove" instead, so the tag and the wanted
unit are re-applied on "change". Real removal is unaffected.

Link: linux-surface#163
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KLPZcjA8vscVEpwGEMZAmK
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.

iptsd@.service unit file loses access to the ipts device unit service after a while

1 participant