virtio/vdpa: Clear the available index during probe
PATCH 3/3 virtio/vdpa: Clear the available index during probe
Clear the available index as part of the initialization process to clear and values that might be left from previous usage of the device. For example, if the device was previously used by vhost_vdpa and now probed by vhost_vdpa, you want to start with indices.
--- drivers/virtio/virtio_vdpa.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/virtio/virtio_vdpa.c +6 -0
@@ -142,6 +142,7 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index,struct vdpa_callback cb;struct virtqueue *vq;u64 desc_addr, driver_addr, device_addr; +struct vdpa_vq_state state = {0 };unsigned long flags;u32 align, num;int err;
@@ -191,6 +192,11 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index, goto err_vq; } +/* reset available index */ + err = ops->set_vq_state (vdpa, index, &state); +if (err) + goto err_vq; + ops->set_vq_ready (vdpa, index,1 ); vq->priv = info;
Signature · 1 line
2.31.1
Quoted 8 lines · Eli Cohen
Clear the available index as part of the initialization process to clear and values that might be left from previous usage of the device. For example, if the device was previously used by
vhost_vdpaand now probed byvhost_vdpa, you want to start with indices.Fixes c043b4a8cf3b ("virtio: introduce a vDPA based transport")Signed-off-by Eli Cohen <[email protected]>---
Note that we probably need a follow-up fixes for vp_vdpa driver.
I will post it soon.
Thanks
Quoted 27 lines
drivers/virtio/virtio_vdpa.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/virtio/virtio_vdpa.c +6
-0@@ -142,6 +142,7 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index,struct vdpa_callback cb;struct virtqueue *vq;u64 desc_addr, driver_addr, device_addr; +struct vdpa_vq_state state = {0 };unsigned long flags;u32 align, num;int err;@@ -191,6 +192,11 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index, goto err_vq; } +/* reset available index */ + err = ops->set_vq_state (vdpa, index, &state); +if (err) + goto err_vq; + ops->set_vq_ready (vdpa, index,1 ); vq->priv = info;
Quoted 12 lines · Jason Wang
Quoted 8 lines · Eli Cohen
Clear the available index as part of the initialization process to clear and values that might be left from previous usage of the device. For example, if the device was previously used by
vhost_vdpaand now probed byvhost_vdpa, you want to start with indices.Fixes c043b4a8cf3b ("virtio: introduce a vDPA based transport")Signed-off-by Eli Cohen <[email protected]>---
Quoted 7 lines
Acked-by Jason Wang <[email protected]>Note that we probably need a follow-up fixes for
vp_vdpadriver.I will post it soon.
Thanks
Hi Eli:
Rethink about this, it only works for the case of split virtqueue.
I will post a series that makes it work for both packed and split virtqueue (with some tweak on this patch).
Does this work for you?
Thanks
Quoted 21 lines
Quoted 21 lines
drivers/virtio/virtio_vdpa.c| 6 ++++++1 file changed, 6 insertions(+)drivers/virtio/virtio_vdpa.c +1
-0@@ -142,6 +142,7 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index, struct vdpa_callback cb; struct virtqueue *vq; u64 desc_addr, driver_addr, device_addr; + struct vdpa_vq_state state = {0}; unsigned long flags; u32 align, num;int err;
drivers/virtio/virtio_vdpa.c +0
-0@@ -191,6 +192,11 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev,unsigned int index, goto err_vq;
Quoted 8 lines
Quoted 8 lines
drivers/virtio/virtio_vdpa.c +0
-0}+ /* reset available index */
+ err =ops->set_vq_state(vdpa, index, &state); + if (err)
+ gotoerr_vq;
+
ops->set_vq_ready(vdpa, index, 1);vq->priv= info;
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization