virtio_poll_done(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ virtio_poll_done β€” like, the Kernel API Manual page, but make it make sense ✨

okay so bestie, this is virtio_poll_done(9) from the Kernel API Manual and honestly it's giving "the poller finally found its buffer" energy and I'm obsessed πŸ’…


🌸 NAME 🌸

virtio_poll_done β€” bestie, it's literally providing polling support for the VirtIO transport ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

bool virtio_poll_done (struct scmi_chan_info *cinfo , struct scmi_xfer
*xfer );

yes, that's the whole signature, no cap 🫢


πŸŽ€ ARGUMENTS πŸŽ€

  • cinfo β€” the SCMI channel info, iconic, necessary, we stan πŸ’–
  • xfer β€” a reference to the transfer we're polling for. like, the one we're waiting on. the main character of this whole operation πŸ‘‘

πŸ”₯ DESCRIPTION πŸ”₯

Okay so here's the tea, bestie β˜•

The VirtIO core ships a polling mechanism that works based only on last used indexes β€” that's the whole vibe. Which means: yes, you can poll the virtqueues waiting for something new to arrive from the host side, slay. BUT β€” and this is the important part β€” the only way to check whether that freshly arrived buffer is actually the one we were waiting for is to compare the newly arrived message descriptor with the one we're polling on. Literally the only way. No shortcuts πŸ™ˆ

As a consequence (fancy word, ate πŸ’…) it can happen that we dequeue something different from the buffer we were poll-waiting for. And if that's the case? Those early fetched buffers get added to a pending_cmds_list list for later processing by a dedicated deferred worker. She's organized, she's got a plan ✨

So basically: once something new is spotted, we proceed to de-queue all the freshly received used buffers until we find the one we were polling on β€” or until we have 'seemingly' emptied the virtqueue (note the air quotes, they're doing heavy lifting πŸ‘€). And if some buffers are still pending in the vqueue at the end of the polling loop β€” which is possible due to inherent races in virtqueues handling mechanisms, not her fault, it's giving unavoidable 😭 β€” we similarly kick the deferred worker and let it process those, so we don't indefinitely loop in the .poll_done busy-waiting helper. No infinite loops on my watch πŸ’€

Finally, we also delegate to the deferred worker the final free of any timed-out reply to a polled message that we should dequeue. She handles cleanup too, queen behavior πŸ‘‘

⚠️ Note, and this is a big one: since we do NOT have a per-message suppress notification mechanism (read it again, bestie, NO), the message we're polling for could alternatively be delivered via usual IRQs callbacks on another core which happened to have IRQs enabled while we are actively polling for it here. In such a case it will be handled as such by rx_callback and the polling loop in the SCMI Core TX path will be transparently terminated anyway. So like, it works out. Periodt 🌈

πŸ’œ RETURN πŸ’œ

Returns True once polling has successfully completed. That's it. That's the return. Successful poll = true = happy πŸŽ‰


🧚 SEE ALSO 🧚

  • Kernel file ./drivers/firmware/arm_scmi/transports/virtio.c
  • Theory of Operation(9)
  • struct scmi_vio_channel(9)
  • struct scmi_vio_msg(9)
  • virtio_mark_txdone(9)

and that's the whole page bestie, you're now officially educated on virtio polling πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«Ά

this masterpiece of a manpage came from ./drivers/firmware/arm_scmi/tr... and is dated October 2026 β€” the footer said so, and I would never gatekeep that from you πŸ“β­πŸ‘‘

πŸ“¦ where this page comes from