Conversation
|
we can review this one after the release. |
7310369 to
3474c42
Compare
6ddcf11 to
7c0b658
Compare
| return status; | ||
|
|
||
| if (features & (1 << VIRTIO_RPMSG_F_BUFSZ)) | ||
| rvdev->config = *config; |
There was a problem hiding this comment.
Here you should use virtio_read_config to retrieve the config from the transport layer
Did you have a look to @xiaoxiang781216 work in #155 ?
Seems to me the good approach
8289cfd to
a361586
Compare
|
|
||
| if (features & (1 << VIRTIO_RPMSG_F_BUFSZ)) | ||
| virtio_write_config(rvdev->vdev, 0, (void *)config, | ||
| sizeof(*config)); |
There was a problem hiding this comment.
The config could be read by the virtio driver before this code is executed. For instance the Linux probes the rpmsg in parallel of the start of the remoteproc firmware based on the resource table that should contain the config.
For my here we should only read the config if VIRTIO_RPMSG_F_BUFSZ feature bit is set else we should rely on *config.
One question is: should we also mange the config write or should we consider that it is part of the resource table.
I propose to discuss this in next OpenAMP meeting
There was a problem hiding this comment.
7/1 OpenAMP System Reference call:
- Arnaud to confirm it is a standard pattern w/ MMIO
- Tanmay to confirm would work to have read instead of write for current use case & update accordingly.
Allow write only for use case when it is compiled as driver.
There was a problem hiding this comment.
Extracted from virtio spec 1 .4:
2.5.2 Device Requirements: Device Configuration Space
The device MUST allow reading of any device-specific configuration field before FEATURES_OK is set by the driver. This includes fields which are conditional on feature bits, as long as those feature bits are offered by the device.
3.2 Device Operation
When operating the device, each field in the device configuration space can be changed by either the driver or the device.
Whenever such a configuration change is triggered by the device, driver is notified. This makes it possible for drivers to cache device configuration, avoiding expensive configuration reads unless notified.
So it seems that having a static configuration as first step is quite simple and reliable
- the device provides a static configuration space (in the resource table).
- the driver can update it until FEATURES_OK is set
- the device read the configuration space when DRIVER_OK is set
| */ | ||
| METAL_PACKED_BEGIN | ||
| struct rpmsg_virtio_config { | ||
| /** version of this struct */ |
There was a problem hiding this comment.
This needs an update, right?
Because it doesn't match the Linux v5 header which dropped the reserved fields, so every field after version is now at a different offset.
There was a problem hiding this comment.
Yes. same as mentioned in: OpenAMP/openamp-system-reference#106
There was a problem hiding this comment.
Getting the whole picture with the Linux implementation. I wonder if updating this structure would not add confusion and extra management:
- split_shpool field
- updating rpmsg_virtio_config could break the API
what about introducing struct rpmsg_virtio_config_space structure?
There was a problem hiding this comment.
@arnopo It's better if we introduce new PR for that. This PR is only to modify the default buffer size via vdev config space. So, for now I prefer to keep it as it is.
There was a problem hiding this comment.
@arnopo It's better if we introduce new PR for that. This PR is only to modify the default buffer size via vdev config space. So, for now I prefer to keep it as it is.
As this also impacts the API, I would prefer not to implement it in two steps, especially if we introduce it in this release. In its current state, this would likely introduce regressions, for instance in NuttX:
https://github.com/apache/nuttx/blob/master/drivers/rpmsg/rpmsg_virtio_lite.c#L697
| */ | ||
| size = (int)virtqueue_get_desc_size(rvdev->rvq) - | ||
| sizeof(struct rpmsg_hdr); | ||
| features = 0; |
There was a problem hiding this comment.
Redundant, is already zero-initialized at declaration.
| return RPMSG_ERR_DEV_STATE; | ||
| } | ||
|
|
||
| if (features & (1 << VIRTIO_RPMSG_F_BUFSZ)) { |
There was a problem hiding this comment.
Nitpick: 1U << for feature masks (here and in rpmsg_init_vdev_with_config).
| return status; | ||
|
|
||
| if (features & (1 << VIRTIO_RPMSG_F_BUFSZ)) | ||
| virtio_write_config(rvdev->vdev, 0, (void *)config, |
There was a problem hiding this comment.
Return value ignored, the same happens for virtio_read_config above.
There was a problem hiding this comment.
Ack, I will fix in next rev.
| return status; | ||
|
|
||
| if (features & (1 << VIRTIO_RPMSG_F_BUFSZ)) | ||
| virtio_write_config(rvdev->vdev, 0, (void *)config, |
There was a problem hiding this comment.
sizeof(*config) writes the full struct including split_shpool, inconsistent with the advertised size field.
There was a problem hiding this comment.
Ack, I will fix in next rev.
|
2026-07-15 System Reference Call: |
a361586 to
8211ae2
Compare
|
8/26/26 System Reference call: |
|
9/8/26: Mathieu merged the Linux part. Tanmay will rebase, then it will be ready for OpenAMP review |
8211ae2 to
9a39a75
Compare
|
This PR is ready for review. @arnopo |
| if (ret) | ||
| return RPMSG_ERR_DEV_STATE; | ||
|
|
||
| if (config.size < RPMSG_VIRTIO_CONFIG_SIZE || |
There was a problem hiding this comment.
Check on the config version seems missing here and in rpmsg_virtio_write_config
There was a problem hiding this comment.
agree - check version == 1 like linux does and reject sizes <= sizeof(struct rpmsg_hdr)
|
|
||
| if (VIRTIO_ROLE_IS_DRIVER(vdev)) { | ||
| if (features & (1U << VIRTIO_RPMSG_F_BUFSZ)) { | ||
| status = rpmsg_virtio_write_config(rvdev); |
There was a problem hiding this comment.
This part seems to me not valid. The driver should only read the config. It must not update it.
it seems that something is also wrong in rproc_virtio_write_config
There was a problem hiding this comment.
Yeah, this part is redundant. I will remove it.
| if (status) | ||
| return status; | ||
| rdev->support_ns = !!(features & (1 << VIRTIO_RPMSG_F_NS)); | ||
| rdev->support_ns = !!(features & (1U << VIRTIO_RPMSG_F_NS)); |
There was a problem hiding this comment.
Please move this in a separate Commit
| uint16_t size; | ||
|
|
||
| /** The size of the buffer used to send data from host to remote */ | ||
| uint32_t h2r_buf_size; |
There was a problem hiding this comment.
The size fields are in the opposite order from the merged Linux abi https://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux.git/tree/include/linux/rpmsg/virtio_rpmsg.h?h=for-next
There was a problem hiding this comment.
This is expected, as it's parsed accordingly in the driver: https://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux.git/tree/drivers/rpmsg/virtio_rpmsg_bus.c?h=for-next#n846
There was a problem hiding this comment.
I wonder if it would be more obvious to talk about a driver and a device. What about drv2dev_buf_size?
There was a problem hiding this comment.
@arnopo If we want to rename the structures field, can we do it in a different commit?
This name exists before this change, and irrelevant to the functionality being introduced in the PR.
| if (ret) | ||
| return RPMSG_ERR_DEV_STATE; | ||
|
|
||
| if (config.size < RPMSG_VIRTIO_CONFIG_SIZE || |
There was a problem hiding this comment.
agree - check version == 1 like linux does and reject sizes <= sizeof(struct rpmsg_hdr)
9a39a75 to
c54c7e8
Compare
| rdev->support_ns = !!(features & (1 << VIRTIO_RPMSG_F_NS)); | ||
|
|
||
| if (VIRTIO_ROLE_IS_DRIVER(vdev)) { | ||
|
|
There was a problem hiding this comment.
To remove useless additional blank lines.
| */ | ||
| METAL_PACKED_BEGIN | ||
| struct rpmsg_virtio_config { | ||
| /** version of this struct */ |
There was a problem hiding this comment.
Getting the whole picture with the Linux implementation. I wonder if updating this structure would not add confusion and extra management:
- split_shpool field
- updating rpmsg_virtio_config could break the API
what about introducing struct rpmsg_virtio_config_space structure?
| } | ||
|
|
||
| if (VIRTIO_ROLE_IS_DEVICE(vdev)) { | ||
| if (features & (1U << VIRTIO_RPMSG_F_BUFSZ)) { |
There was a problem hiding this comment.
It seems to me that this commit needs more rework
Legacy code provides struct rpmsg_virtio_config as argument of rpmsg_init_vdev_with_config function. This APi should still work if VIRTIO_RPMSG_F_BUFSZ is not set.
What about following algorithms
- For the driver role:
if (features & (1U << VIRTIO_RPMSG_F_BUFSZ))
get the config from the rpmsg_virtio_config_space in shared memory
else
get the config from the rpmsg_virtio_config input argument
Notice that split_shpool should still be get from rpmsg_virtio_config
- For the device role:
Current implementation should work and seems to me more flexible.
if (VIRTIO_ROLE_IS_DEVICE(rvdev->vdev)) {
/*
* If other core is host then buffers are provided by it,
* so get the buffer size from the virtqueue.
*/
size = (int)virtqueue_get_desc_size(rvdev->rvq) -
sizeof(struct rpmsg_hdr);
}
There was a problem hiding this comment.
@arnopo, I prefer this algorithm:
For the driver role:
If input param is provided to the API, then use it to override the one in the resource table,
and then use resource table's parameters everywhere.
If the input param is not provided, then assume it is provided by the resource table
and use it directly from there.
Let me know your view.
There was a problem hiding this comment.
your proposal makes sense but will imply more update as the config argument is never null in our API regarding rpmsg_init_vdev function
Introduce new feature bit that allows rpmsg buffer size via virtio device config space. If the feature is available then, driver will set single rpmsg buffer size from virtio device config space in the resource table. Signed-off-by: Tanmay Shah <tanmay.shah@amd.com>
c54c7e8 to
46bfee4
Compare
|
@arnopo addressed all the comments. |
Corresponding Linux kernel patch series: https://lore.kernel.org/all/20251114184640.3020427-1-tanmay.shah@amd.com/