diff mbox series

[v5,4/9] vringh: define the stride used for translation

Message ID 20230404131326.44403-5-sgarzare@redhat.com (mailing list archive)
State Not Applicable
Headers show
Series vdpa_sim: add support for user VA | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Stefano Garzarella April 4, 2023, 1:13 p.m. UTC
Define a macro to be reused in the different parts of the code.

Useful for the next patches where we add more arrays to manage also
translations with user VA.

Suggested-by: Eugenio Perez Martin <eperezma@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
---

Notes:
    v4:
    - added this patch with the changes extracted from the next patch [Eugenio]
    - used _STRIDE instead of _SIZE [Eugenio]

 drivers/vhost/vringh.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Jason Wang April 11, 2023, 5:40 a.m. UTC | #1
On Tue, Apr 4, 2023 at 9:14 PM Stefano Garzarella <sgarzare@redhat.com> wrote:
>
> Define a macro to be reused in the different parts of the code.
>
> Useful for the next patches where we add more arrays to manage also
> translations with user VA.
>
> Suggested-by: Eugenio Perez Martin <eperezma@redhat.com>
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>

Acked-by: Jason Wang <jasowang@redhat.com>

Thanks

> ---
>
> Notes:
>     v4:
>     - added this patch with the changes extracted from the next patch [Eugenio]
>     - used _STRIDE instead of _SIZE [Eugenio]
>
>  drivers/vhost/vringh.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
> index 0ba3ef809e48..4aee230f7622 100644
> --- a/drivers/vhost/vringh.c
> +++ b/drivers/vhost/vringh.c
> @@ -1141,13 +1141,15 @@ static int iotlb_translate(const struct vringh *vrh,
>         return ret;
>  }
>
> +#define IOTLB_IOV_STRIDE 16
> +
>  static inline int copy_from_iotlb(const struct vringh *vrh, void *dst,
>                                   void *src, size_t len)
>  {
>         u64 total_translated = 0;
>
>         while (total_translated < len) {
> -               struct bio_vec iov[16];
> +               struct bio_vec iov[IOTLB_IOV_STRIDE];
>                 struct iov_iter iter;
>                 u64 translated;
>                 int ret;
> @@ -1180,7 +1182,7 @@ static inline int copy_to_iotlb(const struct vringh *vrh, void *dst,
>         u64 total_translated = 0;
>
>         while (total_translated < len) {
> -               struct bio_vec iov[16];
> +               struct bio_vec iov[IOTLB_IOV_STRIDE];
>                 struct iov_iter iter;
>                 u64 translated;
>                 int ret;
> --
> 2.39.2
>
diff mbox series

Patch

diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
index 0ba3ef809e48..4aee230f7622 100644
--- a/drivers/vhost/vringh.c
+++ b/drivers/vhost/vringh.c
@@ -1141,13 +1141,15 @@  static int iotlb_translate(const struct vringh *vrh,
 	return ret;
 }
 
+#define IOTLB_IOV_STRIDE 16
+
 static inline int copy_from_iotlb(const struct vringh *vrh, void *dst,
 				  void *src, size_t len)
 {
 	u64 total_translated = 0;
 
 	while (total_translated < len) {
-		struct bio_vec iov[16];
+		struct bio_vec iov[IOTLB_IOV_STRIDE];
 		struct iov_iter iter;
 		u64 translated;
 		int ret;
@@ -1180,7 +1182,7 @@  static inline int copy_to_iotlb(const struct vringh *vrh, void *dst,
 	u64 total_translated = 0;
 
 	while (total_translated < len) {
-		struct bio_vec iov[16];
+		struct bio_vec iov[IOTLB_IOV_STRIDE];
 		struct iov_iter iter;
 		u64 translated;
 		int ret;