Skip to content

Conversation

@julek-wolfssl
Copy link

The device is not able to place the entropy into stack or heap allocated buffers. This uses a bounce buffer to be able to use any buffer with virtio entropy.

The device is not able to place the entropy into stack or heap allocated buffers. This uses a bounce buffer to be able to use any buffer with virtio entropy.

Signed-off-by: Juliusz Sosinowicz <[email protected]>
@github-actions
Copy link

Hello @julek-wolfssl, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

@sonarqubecloud
Copy link

Copy link
Contributor

@tomi-font tomi-font left a comment

Choose a reason for hiding this comment

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

Please fix the commit message line length and make the commit title more explicit (drivers: entropy: virtio: <short summary>).

Comment on lines +60 to +85
while (length > 0) {
struct virtq_buf buf[] = {{.addr = data->buf, .len = MIN(length, ENTROPY_BUFFER_MAX_LEN)}};

data->received_len = 0;
k_mutex_lock(&data->buf_mutex, K_FOREVER);
ret = virtq_add_buffer_chain(vq, buf, 1, 0, entropy_virtio_virtq_recv_cb, data, K_FOREVER);
if (ret) {
LOG_ERR("virtq_add_buffer_chain failed: %d", ret);
k_mutex_unlock(&data->buf_mutex);
return -EIO;
}

virtio_notify_virtqueue(cfg->vdev, VIRTIO_ENTROPY_QUEUE_IDX);

k_sem_take(&data->sem, K_FOREVER);

if (data->received_len != buf[0].len) {
LOG_ERR("insufficient number of values: %d/%d", data->received_len, buf[0].len);
k_mutex_unlock(&data->buf_mutex);
return -EIO;
}

memcpy(buffer, data->buf, data->received_len);
k_mutex_unlock(&data->buf_mutex);
buffer += data->received_len;
length -= data->received_len;
Copy link
Contributor

@tomi-font tomi-font Dec 17, 2025

Choose a reason for hiding this comment

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

indentation is wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants