Hi,
On 3/26/25 5:38 PM, Eugenio Perez Martin wrote:
On Mon, Mar 24, 2025 at 3:00 PM Sahil Siddiq <icegambi...@gmail.com> wrote:
[...]
Link: https://lists.nongnu.org/archive/html/qemu-devel/2024-10/msg05106.html
Link: https://lore.kernel.org/r/20210602021536.39525-4-jasow...@redhat.com
Link: 1225c216d954 ("vp_vdpa: allow set vq state to initial state after reset")
Signed-off-by: Sahil Siddiq <sahil...@proton.me>
Acked-by: Eugenio Pérez <epere...@redhat.com>
---
Changes from v4 -> v5:
- Initially commit #5 in v4.
- Fix coding style of commit block as stated by checkpatch.pl.
hw/virtio/vhost-vdpa.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 58c8931d89..0625e349b3 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -1265,6 +1265,21 @@ static bool vhost_vdpa_svq_setup(struct vhost_dev *dev,
};
int r;
+ /*
+ * In Linux, the upper 16 bits of s.num is encoded as
+ * the last used idx while the lower 16 bits is encoded
+ * as the last avail idx when using packed vqs. The most
+ * significant bit for each idx represents the counter
+ * and should be set in both cases while the remaining
+ * bits are cleared.
+ */
+ if (virtio_vdev_has_feature(dev->vdev, VIRTIO_F_RING_PACKED)) {
+ uint32_t last_avail_idx = 0 | (1 << VRING_PACKED_EVENT_F_WRAP_CTR);
+ uint32_t last_used_idx = 0 | (1 << VRING_PACKED_EVENT_F_WRAP_CTR);
+
+ s.num = (last_used_idx << 16) | last_avail_idx;
+ }
+
This should be added before 6/7 so we don't declare we support packed
without this.
Sure, I'll change the ordering in the next patch series.
Thanks,
Sahil