Skip to content

Commit

Permalink
vringh: explain more about cleaning riov and wiov
Browse files Browse the repository at this point in the history
riov and wiov can be reused with subsequent calls of vringh_getdesc_*().

Let's add a paragraph in the documentation of these functions to better
explain when riov and wiov need to be cleaned up.

Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://lore.kernel.org/r/20210315163450.254396-5-sgarzare@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
Stefano Garzarella authored and Michael S. Tsirkin committed May 3, 2021
1 parent bbc2c37 commit 69c13c5
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions drivers/vhost/vringh.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,10 @@ EXPORT_SYMBOL(vringh_init_user);
* *head will be vrh->vring.num. You may be able to ignore an invalid
* descriptor, but there's not much you can do with an invalid ring.
*
* Note that you may need to clean up riov and wiov, even on error!
* Note that you can reuse riov and wiov with subsequent calls. Content is
* overwritten and memory reallocated if more space is needed.
* When you don't have to use riov and wiov anymore, you should clean up them
* calling vringh_iov_cleanup() to release the memory, even on error!
*/
int vringh_getdesc_user(struct vringh *vrh,
struct vringh_iov *riov,
Expand Down Expand Up @@ -932,7 +935,10 @@ EXPORT_SYMBOL(vringh_init_kern);
* *head will be vrh->vring.num. You may be able to ignore an invalid
* descriptor, but there's not much you can do with an invalid ring.
*
* Note that you may need to clean up riov and wiov, even on error!
* Note that you can reuse riov and wiov with subsequent calls. Content is
* overwritten and memory reallocated if more space is needed.
* When you don't have to use riov and wiov anymore, you should clean up them
* calling vringh_kiov_cleanup() to release the memory, even on error!
*/
int vringh_getdesc_kern(struct vringh *vrh,
struct vringh_kiov *riov,
Expand Down Expand Up @@ -1292,7 +1298,10 @@ EXPORT_SYMBOL(vringh_set_iotlb);
* *head will be vrh->vring.num. You may be able to ignore an invalid
* descriptor, but there's not much you can do with an invalid ring.
*
* Note that you may need to clean up riov and wiov, even on error!
* Note that you can reuse riov and wiov with subsequent calls. Content is
* overwritten and memory reallocated if more space is needed.
* When you don't have to use riov and wiov anymore, you should clean up them
* calling vringh_kiov_cleanup() to release the memory, even on error!
*/
int vringh_getdesc_iotlb(struct vringh *vrh,
struct vringh_kiov *riov,
Expand Down

0 comments on commit 69c13c5

Please sign in to comment.