feat(virtio): add Queue::enable_notification
Add a method to unconditionally arm `avail_event` at the driver's
current `avail.idx`, so the next driver publish to the avail ring is
guaranteed to produce a notification when EVENT_IDX is negotiated.
This complements the existing `try_enable_notification`, which is
designed for the drain-then-arm pattern used by descriptor-consuming
queues: it only arms when the queue is empty, so it can pair with a
subsequent pop of any descriptors the driver added concurrently.
Some queues are not normally drained by the device — the vsock event
virtqueue is the motivating case: the device only writes to it, and
the driver replenishes descriptors as the device consumes them. There
the next driver publish, not the next-after-drain one, is what the
device must learn about. `try_enable_notification` does not fit:
* it returns early when `len() != 0`, leaving `avail_event`
unchanged, and
* it sets `avail_event = next_avail`, which on a partially-popped
queue is behind `avail.idx` and would suppress the upcoming
publish anyway.
The new method skips the drain check and writes the current
`avail.idx` directly. A Release fence orders the avail_event store
before any subsequent used-ring update or interrupt the caller
delivers; the caller is responsible for ensuring the driver does not
add to the avail ring until it has observed that update, since this
path does not recheck `avail.idx`.
Signed-off-by: Jack Thomson <jackabt@amazon.com> J
Jack Thomson committed
4d692d1b36f7bbb98917893cf183fde47aad8a73
Parent: e1d356b
Committed by Jack Thomson <jackathomson@outlook.com>
on 5/28/2026, 2:41:53 PM