-
Notifications
You must be signed in to change notification settings - Fork 293
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
rpmsg_virtio: configuration option to set buffer sizes per instance #328
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
@@ -145,6 +157,36 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev, | |||
struct metal_io_region *shm_io, | |||
struct rpmsg_virtio_shm_pool *shpool); | |||
|
|||
/** | |||
* rpmsg_init_vdev_with_config - initialize rpmsg virtio device |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if anyone needs it, it could be implemented in other patch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
few minor remarks but LGTM
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would need some code to handle config == NULL
. What do you suggest? Return RPMSG_ERR_PARAM
?
55e9a34
to
56f38cf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -145,6 +164,39 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev, | |||
struct metal_io_region *shm_io, | |||
struct rpmsg_virtio_shm_pool *shpool); | |||
|
|||
/** | |||
* rpmsg_init_vdev_with_config - initialize rpmsg virtio device with config | |||
* Master side: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@config: structure containing virtio configuration
5e3c365
to
92a1aac
Compare
{ | ||
struct rpmsg_device *rdev; | ||
const char *vq_names[RPMSG_NUM_VRINGS]; | ||
vq_callback callback[RPMSG_NUM_VRINGS]; | ||
int status; | ||
unsigned int i, role; | ||
|
||
role = rpmsg_virtio_get_role(rvdev); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this 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.
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