Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtio native support for lib openamp #494

Merged
merged 1 commit into from
Aug 17, 2023
Merged

Conversation

danmilea
Copy link
Collaborator

@danmilea danmilea commented Jun 8, 2023

This patch-set introduces "native" virtio MMIO driver support in lib open-amp. The framework currently supports entropy, console and network virtio devices.

lib/virtio_mmio/virtio_mmio_drv.c Outdated Show resolved Hide resolved
lib/virtio_mmio/virtio_mmio_drv.c Outdated Show resolved Hide resolved
cmake/options.cmake Show resolved Hide resolved
lib/include/openamp/virtio.h Show resolved Hide resolved
lib/virtio_mmio/virtio_mmio_drv.c Show resolved Hide resolved
lib/virtio_mmio/virtio_serial_drv.c Outdated Show resolved Hide resolved
lib/virtio_mmio/virtio_net_drv.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@arnopo arnopo left a comment

Choose a reason for hiding this comment

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

Please find some comments. The main points is to properly define the interface for the virtqueue creation/release

* @param[in] dev Pointer to device structure.
* @param[in] status Value to be set as device status.
*
* @return N/A.
Copy link
Collaborator

Choose a reason for hiding this comment

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

just remove the line as no return (same for others functions returning void)

lib/virtio_mmio/CMakeLists.txt Show resolved Hide resolved
lib/include/openamp/virtio.h Outdated Show resolved Hide resolved
lib/include/openamp/virtio_drv.h Outdated Show resolved Hide resolved
lib/include/openamp/virtio_drv.h Outdated Show resolved Hide resolved
lib/include/openamp/virtqueue.h Outdated Show resolved Hide resolved
lib/virtio_mmio/virtio_mmio_drv.c Show resolved Hide resolved
lib/virtio_mmio/virtio_mmio_drv.c Outdated Show resolved Hide resolved
lib/virtio_mmio/virtio_mmio_drv.c Outdated Show resolved Hide resolved
lib/virtio_mmio/virtio_mmio_drv.c Outdated Show resolved Hide resolved
@danmilea danmilea force-pushed the virtio-native branch 2 times, most recently from e23eafa to 194fea5 Compare June 20, 2023 13:39
Copy link
Collaborator

@arnopo arnopo left a comment

Choose a reason for hiding this comment

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

  • New comments on the code ( I take more time to review also the Virtio drivers)

  • Please also run ./script/checkpatch.pl on your commits. Even if no error is returned some coding rule would need to be fixed.

  • Concerning your proposal to integrate this first, then to integrate remoteproc_virtio: optimize the remoteproc virtio transport layer #489, and finally update virtio MMIO, I'm not fan as we would create temporary API. I will create an Issue to describe what I would expect interm of integration steps, probably by splitting current PRs

lib/virtio_mmio/virtio_mmio_drv.c Show resolved Hide resolved
lib/include/openamp/virtio_drv.h Outdated Show resolved Hide resolved
lib/virtio_mmio/virtio_mmio_drv.c Show resolved Hide resolved

offset = 0;

if (!vqueue) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

if (!vq)

lib/virtio_mmio/virtio_mmio_drv.c Outdated Show resolved Hide resolved
lib/virtio_mmio/virtio_net_drv.c Outdated Show resolved Hide resolved
lib/virtio_mmio/virtio_net_drv.c Outdated Show resolved Hide resolved
lib/include/openamp/virtio_net_drv.h Outdated Show resolved Hide resolved
lib/include/openamp/virtio.h Outdated Show resolved Hide resolved
return ret;
}

void virtio_serial_poll_out(const struct virtio_device *vdev, unsigned char out_char)
Copy link
Collaborator

Choose a reason for hiding this comment

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

any reason to not return a status?

Copy link
Collaborator

@arnopo arnopo left a comment

Choose a reason for hiding this comment

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

few remarks, else with that look good to go from my point of view.

lib/include/openamp/virtio.h Outdated Show resolved Hide resolved
lib/virtio/virtio.c Show resolved Hide resolved
#define VIRTIO_ASSERT(_exp, _msg) metal_assert(_exp)
#endif /* VIRTIO_DEBUG */

#define VRING_ALIGNMENT 4096
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is something that should become configurable. it is not not blocking for this step, can be done later.

*
* @param vq Pointer to VirtIO queue control block
*
* @return 1 if virtqueue is full
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

*
* @param vq Pointer to VirtIO queue control block
*
* @return 1 if virtqueue is empty
Copy link
Collaborator

Choose a reason for hiding this comment

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

the result of your test is a boolean , so could be different from 1
Whould better to have something like taht:
"return a non null value if empty else 0"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The spec states that == returns either 1 or 0.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for the spec reference, I copy it here.
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf
6.5.9 Equality operators

Just a concerns if the spec cover 100% of builds. Regarding posts seems not the case. that why specifying 0 or not-0 seems to me more reliable

lib/virtio_mmio/virtio_mmio_drv.c Outdated Show resolved Hide resolved
vring_info->info.num_descs = virtio_mmio_get_max_elem(vdev, idx);
vring_info->info.align = VRING_ALIGNMENT;

/* Preallocated virtqueues; vrings can be already declared via VIRTQUEUE_DECLARE */
Copy link
Collaborator

Choose a reason for hiding this comment

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

VIRTQUEUE_DECLARE or VIRTIO_MMIO_VQ_DECLARE?

Do we need to support the preallocated virtqueue in a first step? This part is not cristal clear for me, and would need more review...
I would be in favor of removing them from this PR and introduce them in a separate PR with more details on the usage...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry not enough clear... I was also speaking about the VIRTIO_MMIO_VQ_DECLARE and VIRTIO_MMIO_VQ_PTR macro. I would cremove them from this PR

@danmilea danmilea force-pushed the virtio-native branch 3 times, most recently from 105eb7e to bbd278d Compare July 20, 2023 13:30
@arnopo arnopo self-requested a review July 20, 2023 15:33
@danmilea danmilea force-pushed the virtio-native branch 2 times, most recently from 52a619f to d3763b5 Compare July 21, 2023 07:28
@danmilea danmilea requested a review from arnopo July 21, 2023 07:33
Copy link
Collaborator

@arnopo arnopo left a comment

Choose a reason for hiding this comment

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

LGTM , I just expect more review before merging
Thanks for work!

lib/include/openamp/virtio.h Show resolved Hide resolved
Copy link
Contributor

@edmooring edmooring left a comment

Choose a reason for hiding this comment

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

Looks good to go.

Copy link
Collaborator

@tnmysh tnmysh left a comment

Choose a reason for hiding this comment

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

No major concern from me. Few minor suggestions but nothing blocking. LGTM.

VIRTIO MMIO transport for OpenAMP.

Signed-off-by: Dan Milea <dan.milea@windriver.com>
@arnopo arnopo added this to the Release V2023.10 milestone Aug 17, 2023
@arnopo arnopo merged commit e63d07d into OpenAMP:main Aug 17, 2023
1 of 2 checks passed
@arnopo
Copy link
Collaborator

arnopo commented Oct 2, 2023

@danmilea
Regression found in Zephyr here: zephyrproject-rtos/open-amp#17 (comment)
For the coming release I propose to remove VRING_ALIGNMENT and VRING_DECLARE that are unused yet.

@danmilea
Copy link
Collaborator Author

danmilea commented Oct 2, 2023

@arnopo I created a pull request to rename the offending macro.

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.

what's plan to support the service/driver at the virtio level?
5 participants