-
Notifications
You must be signed in to change notification settings - Fork 8.4k
drivers: entropy: virtio #101139
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
base: main
Are you sure you want to change the base?
drivers: entropy: virtio #101139
Conversation
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]>
|
Hello @julek-wolfssl, and thank you very much for your first pull request to the Zephyr project! |
|
tomi-font
left a comment
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.
Please fix the commit message line length and make the commit title more explicit (drivers: entropy: virtio: <short summary>).
| 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; |
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.
indentation is wrong



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.