rpmsg_virtio: configuration option to set buffer sizes per instance#328
Conversation
807d53b to
30fc4ff
Compare
|
I've tested this implementation with a Zephyr sample. Looks to work as expected |
lib/include/openamp/rpmsg_virtio.h
Outdated
| struct rpmsg_virtio_shm_pool *shpool); | ||
|
|
||
| /** | ||
| * rpmsg_init_vdev_with_config - initialize rpmsg virtio device |
There was a problem hiding this comment.
initialize rpmsg virtio device with config ?
lib/include/openamp/rpmsg_virtio.h
Outdated
| * Initialize RPMsg virtio queues and shared buffers, the address of shm can be | ||
| * ANY. In this case, function will get shared memory from system shared memory | ||
| * pools. If the vdev has RPMsg name service feature, this API will create an | ||
| * name service endpoint. | ||
| * | ||
| * Slave side: | ||
| * This API will not return until the driver ready is set by the master side. |
There was a problem hiding this comment.
Can we add here what config is?
lib/rpmsg/rpmsg_virtio.c
Outdated
| rvdev->config.txbuf_size = RPMSG_BUFFER_SIZE; | ||
| rvdev->config.rxbuf_size = RPMSG_BUFFER_SIZE; |
There was a problem hiding this comment.
Probably not but should we think about adding RPMSG_BUFFER_RX_SIZE and RPMSG_BUFFER_TX_SIZE as compile-time defines since we are now decoupling TX and RX?
There was a problem hiding this comment.
I think if anyone needs it, it could be implemented in other patch
lib/include/openamp/rpmsg_virtio.h
Outdated
| * @param shpool - pointer to shared memory pool. rpmsg_virtio_init_shm_pool has | ||
| * to be called first to fill this structure. | ||
| * @param config - pointer to configuration structure, if NULL default | ||
| * configuration is used like in @ref rpmsg_init_vdev |
There was a problem hiding this comment.
confusing, proposal:
pointer to configuration structure, if NULL (like in @ref rpmsg_init_vdev) default configuration is used
30fc4ff to
55e9a34
Compare
lib/rpmsg/rpmsg_virtio.c
Outdated
| if (config) { | ||
| rvdev->config = *config; | ||
| } else { | ||
| rvdev->config = RPMSG_VIRTIO_DEFAULT_CONFIG; |
There was a problem hiding this comment.
What about just past RPMSG_VIRTIO_DEFAULT_CONFIG as argument in rpmsg_init_vdev function and suppress this condition?
There was a problem hiding this comment.
We would need some code to handle config == NULL. What do you suggest? Return RPMSG_ERR_PARAM?
55e9a34 to
56f38cf
Compare
edmooring
left a comment
There was a problem hiding this comment.
The substance of this looks good to go. Regarding the terminology changes, if they don't go in, I can pick them up in a subsequent push to #323, since I think this will probably go in first.
This pull request could serve as a model of how to do them right.
lib/include/openamp/rpmsg_virtio.h
Outdated
|
|
||
| /** | ||
| * rpmsg_init_vdev_with_config - initialize rpmsg virtio device with config | ||
| * Master side: |
There was a problem hiding this comment.
In keeping with the effort to remove potentially objectionable terminology, I suggest replacing "Master" and "Slave" with "Driver" and "Device" as in PR #323.
There was a problem hiding this comment.
I'm changing Master and Slave here to Host and Remote. It seems this header should use RPMsg terminology (host/remote), not virtio (driver/device), because it operates on rpmsg instances.
lib/include/openamp/rpmsg_virtio.h
Outdated
| * Sizes of virtio data buffers used by initialized RPMsg instance are set to | ||
| * values read from the passed configuration structure. | ||
| * | ||
| * Slave side: |
There was a problem hiding this comment.
As above, replace "Slave" with "Device". Check throughout the PR.
lib/include/openamp/rpmsg_virtio.h
Outdated
| * Master side: | ||
| * Initialize RPMsg virtio queues and shared buffers, the address of shm can be | ||
| * ANY. In this case, function will get shared memory from system shared memory | ||
| * pools. If the vdev has RPMsg name service feature, this API will create an |
There was a problem hiding this comment.
Minor English fixups:
s/has RPMsg name service/has the RPMsg name service/
s/an$/a/
lib/include/openamp/rpmsg_virtio.h
Outdated
| * ANY. In this case, function will get shared memory from system shared memory | ||
| * pools. If the vdev has RPMsg name service feature, this API will create an | ||
| * name service endpoint. | ||
| * Sizes of virtio data buffers used by initialized RPMsg instance are set to |
There was a problem hiding this comment.
s/initialized/the initialized/
56f38cf to
19782c5
Compare
19782c5 to
935ab1c
Compare
lib/include/openamp/rpmsg_virtio.h
Outdated
| /** | ||
| * struct rpmsg_virtio_config - configuration of rpmsg device based on virtio | ||
| * @txbuf_size: the tx buffer size, used to send data from host to remote | ||
| * @rxbuf_size: the rx buffer size, used to send data from remote to host |
There was a problem hiding this comment.
Deeply reviewing your patch, look to me that, for an unfamiliar user, it is not easy to understand this structure.
My apologize for that because I should see it before... only the host use the config structure.
Another point is the notion of RX TX which is ambiguous. If only the host defines it, the remote gets the corresponding values from the vrings.
Here is a proposal to rework the structure
* struct rpmsg_virtio_config - configuration of rpmsg device based on virtio
*
* This structure is use by the rpmsg virtio host to configure the virtiio layer.
*
* @h2r_buf_size: the buffer size, used to send data from host to remote
* @r2h_buf_size: the uffer size, used to send data from remote to host
struct rpmsg_virtio_config {
uint32_t h2r_buf_size;
uint32_t r2h_buf_size;
}
lib/include/openamp/rpmsg_virtio.h
Outdated
| /** | ||
| * struct rpmsg_virtio_device - representation of a rpmsg device based on virtio | ||
| * @rdev: rpmsg device, first property in the struct | ||
| * @config: structure containing device configuration |
There was a problem hiding this comment.
@config: structure containing virtio configuration
5e3c365 to
92a1aac
Compare
| int status; | ||
| unsigned int i, role; | ||
|
|
||
| role = rpmsg_virtio_get_role(rvdev); |
There was a problem hiding this comment.
Segmentation fault during my non-reg tests because the rvdev->vdev->role is not yet set.
The block should be move after rdev = &rvdev->rdev;
92a1aac to
73f61d0
Compare
Enable user of rpmsg_virtio to set sizes of TX and RX buffers per created rpmsg_virtio instance. Each instance can use other buffer sizes. Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
Replacing potentially objectionable terms from the function description. Language fixes. Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
73f61d0 to
409ab20
Compare
|
One more update: I've silenced "unused config parameter" warning when building SLAVE_ONLY configuration. |
Fixes #322
Enable user of rpmsg_virtio to set sizes of TX and RX buffers per
created rpmsg_virtio instance. Each instance can use other buffer sizes.
Signed-off-by: Hubert Miś hubert.mis@nordicsemi.no