Skip to content

Serialize hardware plans on a host device lock#136

Merged
timkpaine merged 1 commit into
mainfrom
tkp/hw-device-lock
Jul 24, 2026
Merged

Serialize hardware plans on a host device lock#136
timkpaine merged 1 commit into
mainfrom
tkp/hw-device-lock

Conversation

@timkpaine

Copy link
Copy Markdown
Member

Executed hardware plans (execute=true) now take a per-device advisory lock keyed on the endpoint BDF, so two overlapping runs cannot remove/reset/program the same board at once.

The lock lives in the user-private runtime dir ($XDG_RUNTIME_DIR/dau, else ~/.dau/locks), opened with O_NOFOLLOW — no world-writable /tmp attack surface. Serializes the operator's own processes; a bench is single-operator. The BDF is lower-cased before keying so equivalent spellings map to one lock.

execute_plan_steps takes an endpoint_bdf: when set, the whole plan run is
held under a host-global advisory flock keyed on that device
(device_lock_path: a FIXED /var/lock-or-/tmp path, never TMPDIR-sensitive
gettempdir). A board is one exclusive resource, so no two hardware plans —
from any process, session, or a direct CLI flash — remove/reset/program
the same endpoint at once. The hardware-plan task passes the composed
endpoint BDF; a device-less plan runs unserialized. Proven by an
interleave test.

Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
@timkpaine
timkpaine merged commit 3c4460c into main Jul 24, 2026
1 check failed
@timkpaine
timkpaine deleted the tkp/hw-device-lock branch July 24, 2026 01:18
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