Skip to contentSkip to conversation

vdpa/mlx5: Fix wrong use of bit numbers

PATCH In review Eli Cohen 3 participants 5 messages Mar 1, 2021 – Mar 2, 2021

Subsystems (4)
lore
Share & tools
lore

Eli Cohen

author
#0 lore raw

PATCH 1/1 vdpa/mlx5: Fix wrong use of bit numbers

VIRTIO_F_VERSION_1 is a bit number. Use BIT_ULL() with mask conditionals.

Also, in mlx5_vdpa_is_little_endian() use BIT_ULL for consistency with the rest of the code.

Fixes 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")
---
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +2 -2
index dc7031132fff..7d21b857a94a 100644
@@ -821,7 +821,7 @@ static int create_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtque
 	MLX5_SET(virtio_q, vq_ctx, event_qpn_or_msix, mvq->fwqp.mqp.qpn);
 	MLX5_SET(virtio_q, vq_ctx, queue_size, mvq->num_ent);
 	MLX5_SET(virtio_q, vq_ctx, virtio_version_1_0,
-		 !!(ndev->mvdev.actual_features & VIRTIO_F_VERSION_1));
+		 !!(ndev->mvdev.actual_features & BIT_ULL(VIRTIO_F_VERSION_1)));
 	MLX5_SET64(virtio_q, vq_ctx, desc_addr, mvq->desc_addr);
 	MLX5_SET64(virtio_q, vq_ctx, used_addr, mvq->device_addr);
 	MLX5_SET64(virtio_q, vq_ctx, available_addr, mvq->driver_addr);
@@ -1578,7 +1578,7 @@ static void teardown_virtqueues(struct mlx5_vdpa_net *ndev)
 static inline bool mlx5_vdpa_is_little_endian(struct mlx5_vdpa_dev *mvdev)
 {
 	return virtio_legacy_is_little_endian() ||
-		(mvdev->actual_features & (1ULL << VIRTIO_F_VERSION_1));
+		(mvdev->actual_features & BIT_ULL(VIRTIO_F_VERSION_1));
 }
 
 static __virtio16 cpu_to_mlx5vdpa16(struct mlx5_vdpa_dev *mvdev, u16 val)
Signature · 1 line
2.30.1
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Eli Cohen

VIRTIO_F_VERSION_1 is a bit number. Use BIT_ULL() with mask conditionals.

Also, in mlx5_vdpa_is_little_endian() use BIT_ULL for consistency with the rest of the code.

Fixes 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")
Quoted 18 lines
---
  drivers/vdpa/mlx5/net/mlx5_vnet.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +1 -1
index dc7031132fff..7d21b857a94a 100644
@@ -821,7 +821,7 @@ static int create_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtque
  	MLX5_SET(virtio_q, vq_ctx, event_qpn_or_msix, mvq->fwqp.mqp.qpn);
  	MLX5_SET(virtio_q, vq_ctx, queue_size, mvq->num_ent);
  	MLX5_SET(virtio_q, vq_ctx, virtio_version_1_0,
-		 !!(ndev->mvdev.actual_features & VIRTIO_F_VERSION_1));
+		 !!(ndev->mvdev.actual_features & BIT_ULL(VIRTIO_F_VERSION_1)));
  	MLX5_SET64(virtio_q, vq_ctx, desc_addr, mvq->desc_addr);
  	MLX5_SET64(virtio_q, vq_ctx, used_addr, mvq->device_addr);
  	MLX5_SET64(virtio_q, vq_ctx, available_addr, mvq->driver_addr);

drivers/vdpa/mlx5/net/mlx5_vnet.c static void teardown_virtqueues(struct mlx5_vdpa_net *ndev) · line 1584

Quoted 8 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1 -1
@@ -1578,7 +1578,7 @@ static void teardown_virtqueues(struct mlx5_vdpa_net *ndev)
  static inline bool mlx5_vdpa_is_little_endian(struct mlx5_vdpa_dev *mvdev)
  {
  	return virtio_legacy_is_little_endian() ||
-		(mvdev->actual_features & (1ULL << VIRTIO_F_VERSION_1));
+		(mvdev->actual_features & BIT_ULL(VIRTIO_F_VERSION_1));
  }
 
  static __virtio16 cpu_to_mlx5vdpa16(struct mlx5_vdpa_dev *mvdev, u16 val)

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#2 lore raw
Quoted 5 lines · Jason Wang
Quoted 3 lines · Eli Cohen

VIRTIO_F_VERSION_1 is a bit number. Use BIT_ULL() with mask conditionals.

Quoted 8 lines
Quoted 5 lines

Also, in mlx5_vdpa_is_little_endian() use BIT_ULL for consistency with the rest of the code.

Fixes 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")

And CC stable I guess?

Quoted 18 lines
Quoted 18 lines
---
  drivers/vdpa/mlx5/net/mlx5_vnet.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +1 -1
index dc7031132fff..7d21b857a94a 100644
@@ -821,7 +821,7 @@ static int create_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtque
  	MLX5_SET(virtio_q, vq_ctx, event_qpn_or_msix, mvq->fwqp.mqp.qpn);
  	MLX5_SET(virtio_q, vq_ctx, queue_size, mvq->num_ent);
  	MLX5_SET(virtio_q, vq_ctx, virtio_version_1_0,
-		 !!(ndev->mvdev.actual_features & VIRTIO_F_VERSION_1));
+		 !!(ndev->mvdev.actual_features & BIT_ULL(VIRTIO_F_VERSION_1)));
  	MLX5_SET64(virtio_q, vq_ctx, desc_addr, mvq->desc_addr);
  	MLX5_SET64(virtio_q, vq_ctx, used_addr, mvq->device_addr);
  	MLX5_SET64(virtio_q, vq_ctx, available_addr, mvq->driver_addr);
Quoted 8 lines

drivers/vdpa/mlx5/net/mlx5_vnet.c static void teardown_virtqueues(struct mlx5_vdpa_net *ndev) · line 1583

Quoted 8 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1 -1
@@ -1578,7 +1578,7 @@ static void teardown_virtqueues(struct mlx5_vdpa_net *ndev)
  static inline bool mlx5_vdpa_is_little_endian(struct mlx5_vdpa_dev *mvdev)
  {
  	return virtio_legacy_is_little_endian() ||
-		(mvdev->actual_features & (1ULL << VIRTIO_F_VERSION_1));
+		(mvdev->actual_features & BIT_ULL(VIRTIO_F_VERSION_1));
  }
  static __virtio16 cpu_to_mlx5vdpa16(struct mlx5_vdpa_dev *mvdev, u16 val)

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

author
#3 lore raw
Quoted 9 lines · Michael S. Tsirkin
Quoted 8 lines · Jason Wang
Quoted 6 lines · Eli Cohen

VIRTIO_F_VERSION_1 is a bit number. Use BIT_ULL() with mask conditionals.

Also, in mlx5_vdpa_is_little_endian() use BIT_ULL for consistency with the rest of the code.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Fixes 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")

And CC stable I guess?

Is this a question or a request? :-)

Quoted 28 lines
Quoted 27 lines
Quoted 27 lines

---
  drivers/vdpa/mlx5/net/mlx5_vnet.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +2 -2
index dc7031132fff..7d21b857a94a 100644
@@ -821,7 +821,7 @@ static int create_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtque
  	MLX5_SET(virtio_q, vq_ctx, event_qpn_or_msix, mvq->fwqp.mqp.qpn);
  	MLX5_SET(virtio_q, vq_ctx, queue_size, mvq->num_ent);
  	MLX5_SET(virtio_q, vq_ctx, virtio_version_1_0,
-		 !!(ndev->mvdev.actual_features & VIRTIO_F_VERSION_1));
+		 !!(ndev->mvdev.actual_features & BIT_ULL(VIRTIO_F_VERSION_1)));
  	MLX5_SET64(virtio_q, vq_ctx, desc_addr, mvq->desc_addr);
  	MLX5_SET64(virtio_q, vq_ctx, used_addr, mvq->device_addr);
  	MLX5_SET64(virtio_q, vq_ctx, available_addr, mvq->driver_addr);
@@ -1578,7 +1578,7 @@ static void teardown_virtqueues(struct mlx5_vdpa_net *ndev)
  static inline bool mlx5_vdpa_is_little_endian(struct mlx5_vdpa_dev *mvdev)
  {
  	return virtio_legacy_is_little_endian() ||
-		(mvdev->actual_features & (1ULL << VIRTIO_F_VERSION_1));
+		(mvdev->actual_features & BIT_ULL(VIRTIO_F_VERSION_1));
  }
  static __virtio16 cpu_to_mlx5vdpa16(struct mlx5_vdpa_dev *mvdev, u16 val)
#4 lore raw
Quoted 14 lines · Eli Cohen
Quoted 13 lines · Michael S. Tsirkin
Quoted 12 lines · Jason Wang
Quoted 8 lines · Eli Cohen

VIRTIO_F_VERSION_1 is a bit number. Use BIT_ULL() with mask conditionals.

Also, in mlx5_vdpa_is_little_endian() use BIT_ULL for consistency with the rest of the code.

Fixes 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

And CC stable I guess?

Is this a question or a request? :-)

A question. net patches are cc'd by net maintainer.

Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines

---
  drivers/vdpa/mlx5/net/mlx5_vnet.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +1 -1
index dc7031132fff..7d21b857a94a 100644
@@ -821,7 +821,7 @@ static int create_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtque
  	MLX5_SET(virtio_q, vq_ctx, event_qpn_or_msix, mvq->fwqp.mqp.qpn);
  	MLX5_SET(virtio_q, vq_ctx, queue_size, mvq->num_ent);
  	MLX5_SET(virtio_q, vq_ctx, virtio_version_1_0,
-		 !!(ndev->mvdev.actual_features & VIRTIO_F_VERSION_1));
+		 !!(ndev->mvdev.actual_features & BIT_ULL(VIRTIO_F_VERSION_1)));
  	MLX5_SET64(virtio_q, vq_ctx, desc_addr, mvq->desc_addr);
  	MLX5_SET64(virtio_q, vq_ctx, used_addr, mvq->device_addr);
  	MLX5_SET64(virtio_q, vq_ctx, available_addr, mvq->driver_addr);
@@ -1578,7 +1578,7 @@ static void teardown_virtqueues(struct mlx5_vdpa_net *ndev)
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

drivers/vdpa/mlx5/net/mlx5_vnet.c static void teardown_virtqueues(struct mlx5_vdpa_net *ndev) · line 1584

Quoted 7 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1 -1
  static inline bool mlx5_vdpa_is_little_endian(struct mlx5_vdpa_dev *mvdev)
  {
  	return virtio_legacy_is_little_endian() ||
-		(mvdev->actual_features & (1ULL << VIRTIO_F_VERSION_1));
+		(mvdev->actual_features & BIT_ULL(VIRTIO_F_VERSION_1));
  }
  static __virtio16 cpu_to_mlx5vdpa16(struct mlx5_vdpa_dev *mvdev, u16 val)

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization