-
Notifications
You must be signed in to change notification settings - Fork 320
rpmsg_virtio: configuration option to set buffer sizes per instance #328
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
Merged
arnopo
merged 2 commits into
OpenAMP:main
from
hubertmis:pr/configurable-rpmsg-virio-buffer-size
Jan 4, 2022
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| * All rights reserved. | ||
| * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved. | ||
| * Copyright (c) 2018 Linaro, Inc. All rights reserved. | ||
| * Copyright (c) 2021 Nordic Semiconductor ASA | ||
| * | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| */ | ||
|
|
@@ -151,8 +152,8 @@ static void *rpmsg_virtio_get_tx_buffer(struct rpmsg_virtio_device *rvdev, | |
| data = virtqueue_get_buffer(rvdev->svq, len, idx); | ||
| if (!data && rvdev->svq->vq_free_cnt) { | ||
| data = rpmsg_virtio_shm_pool_get_buffer(rvdev->shpool, | ||
| RPMSG_BUFFER_SIZE); | ||
| *len = RPMSG_BUFFER_SIZE; | ||
| rvdev->config.h2r_buf_size); | ||
| *len = rvdev->config.h2r_buf_size; | ||
| *idx = 0; | ||
| } | ||
| } | ||
|
|
@@ -250,7 +251,7 @@ static int _rpmsg_virtio_get_buffer_size(struct rpmsg_virtio_device *rvdev) | |
| * If device role is Master then buffers are provided by us, | ||
| * so just provide the macro. | ||
| */ | ||
| length = RPMSG_BUFFER_SIZE - sizeof(struct rpmsg_hdr); | ||
| length = rvdev->config.h2r_buf_size - sizeof(struct rpmsg_hdr); | ||
| } | ||
| #endif /*!VIRTIO_SLAVE_ONLY*/ | ||
|
|
||
|
|
@@ -384,7 +385,7 @@ static int rpmsg_virtio_send_offchannel_nocopy(struct rpmsg_device *rdev, | |
|
|
||
| #ifndef VIRTIO_SLAVE_ONLY | ||
| if (rpmsg_virtio_get_role(rvdev) == RPMSG_MASTER) | ||
| buff_len = RPMSG_BUFFER_SIZE; | ||
| buff_len = rvdev->config.h2r_buf_size; | ||
| else | ||
| #endif /*!VIRTIO_SLAVE_ONLY*/ | ||
| buff_len = virtqueue_get_buffer_length(rvdev->svq, idx); | ||
|
|
@@ -610,6 +611,17 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev, | |
| rpmsg_ns_bind_cb ns_bind_cb, | ||
| struct metal_io_region *shm_io, | ||
| struct rpmsg_virtio_shm_pool *shpool) | ||
| { | ||
| return rpmsg_init_vdev_with_config(rvdev, vdev, ns_bind_cb, shm_io, | ||
| shpool, &RPMSG_VIRTIO_DEFAULT_CONFIG); | ||
| } | ||
|
|
||
| int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, | ||
| struct virtio_device *vdev, | ||
| rpmsg_ns_bind_cb ns_bind_cb, | ||
| struct metal_io_region *shm_io, | ||
| struct rpmsg_virtio_shm_pool *shpool, | ||
| const struct rpmsg_virtio_config *config) | ||
| { | ||
| struct rpmsg_device *rdev; | ||
| const char *vq_names[RPMSG_NUM_VRINGS]; | ||
|
|
@@ -630,6 +642,23 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev, | |
| rdev->ops.send_offchannel_nocopy = rpmsg_virtio_send_offchannel_nocopy; | ||
| role = rpmsg_virtio_get_role(rvdev); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Segmentation fault during my non-reg tests because the |
||
|
|
||
| #ifndef VIRTIO_SLAVE_ONLY | ||
| if (role == RPMSG_MASTER) { | ||
| /* | ||
| * The virtio configuration contains only options applicable to | ||
| * a virtio driver, implying rpmsg host role. | ||
| */ | ||
| if (config == NULL) { | ||
| return RPMSG_ERR_PARAM; | ||
| } | ||
| rvdev->config = *config; | ||
| } | ||
| #else /*!VIRTIO_SLAVE_ONLY*/ | ||
| /* Ignore passed config in the virtio-device-only configuration. */ | ||
| (void)config; | ||
| #endif /*!VIRTIO_SLAVE_ONLY*/ | ||
|
|
||
arnopo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| #ifndef VIRTIO_MASTER_ONLY | ||
| if (role == RPMSG_REMOTE) { | ||
| /* wait synchro with the master */ | ||
|
|
@@ -699,11 +728,11 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev, | |
| unsigned int idx; | ||
| void *buffer; | ||
|
|
||
| vqbuf.len = RPMSG_BUFFER_SIZE; | ||
| vqbuf.len = rvdev->config.r2h_buf_size; | ||
| for (idx = 0; idx < rvdev->rvq->vq_nentries; idx++) { | ||
| /* Initialize TX virtqueue buffers for remote device */ | ||
| buffer = rpmsg_virtio_shm_pool_get_buffer(shpool, | ||
| RPMSG_BUFFER_SIZE); | ||
| rvdev->config.r2h_buf_size); | ||
|
|
||
| if (!buffer) { | ||
| return RPMSG_ERR_NO_BUFF; | ||
|
|
@@ -714,7 +743,7 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev, | |
| metal_io_block_set(shm_io, | ||
| metal_io_virt_to_offset(shm_io, | ||
| buffer), | ||
| 0x00, RPMSG_BUFFER_SIZE); | ||
| 0x00, rvdev->config.r2h_buf_size); | ||
| status = | ||
| virtqueue_add_buffer(rvdev->rvq, &vqbuf, 0, 1, | ||
| buffer); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.