Skip to content

virtqueue: add writable buffer helper - #699

Open
WallaceIT wants to merge 1 commit into
OpenAMP:mainfrom
WallaceIT:writable-buffer-helper
Open

WallaceIT wants to merge 1 commit into
OpenAMP:mainfrom
WallaceIT:writable-buffer-helper

Conversation

@WallaceIT

Copy link
Copy Markdown

An application, specially at device side, might need to know if a buffer has been marked as writable by the communication partner. An example is the virtio SPI protocol, in which the direction of an half-duplex communication can be determined only by checking if the buffer containing the data is writable or not.

Add a simple helper to test if a buffer is writable, that is, if the VRING_DESC_F_WRITE is present on it.

Comment thread lib/include/openamp/virtqueue.h Outdated
*
* @return true if the buffer is marked as writable, false otherwise
*/
bool virtqueue_is_buffer_writable(struct virtqueue *vq, uint16_t idx);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This virtqueue layer is not expected to be used by application/firmware directly, instead via rpmsg_virtio layer. I am not sure if we ever need this API for rpmsg_virito.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am using open-amp for generic virtio over remoteproc experimentation in Zephyr, and accessing internal flags details is inappropriate. I proposed this new API because I saw that (at least) another has been integrated with the same usecase in mind (9c4ad74).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me if needed for another virtio device than rpmsg

Comment thread lib/include/openamp/virtqueue.h Outdated
Comment thread lib/include/openamp/virtqueue.h Outdated
Comment thread lib/include/openamp/virtqueue.h Outdated
@WallaceIT
WallaceIT force-pushed the writable-buffer-helper branch from ee8caf8 to b404bcd Compare September 9, 2026 17:40
An application at device side might need to know if a buffer has been
marked as device-writable by the driver.
An example is the virtio SPI protocol, in which the direction of an
half-duplex communication can be determined by the device only by
checking if the buffer containing the data is writable or not.

Add a simple helper to test if a buffer is device-writable, that is,
if the VRING_DESC_F_WRITE flag is present on it.

Signed-off-by: Francesco Valla <francesco@valla.it>
@WallaceIT
WallaceIT force-pushed the writable-buffer-helper branch from b404bcd to 7f8af31 Compare September 9, 2026 17:42

@arnopo arnopo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

3 participants