Skip to contentSkip to conversation

vdpasim: allow to enable a vq repeatedly

PATCH In review Eugenio Pérez 2 participants 2 messages May 19, 2022

Subsystems (4)
lore
Share & tools
lore

Eugenio Pérez

author maintainer
#0 lore raw

PATCH v2 1/1 vdpasim: allow to enable a vq repeatedly

Code must be resilient to enable a queue many times.

At the moment the queue is resetting so it's definitely not the expected behavior.

v2: set vq->ready = 0 at disable.

Fixes 2c53d0f64c06 ("vdpasim: vDPA device simulator")
---
 drivers/vdpa/vdpa_sim/vdpa_sim.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/vdpa/vdpa_sim/vdpa_sim.c +4 -1
index ddbe142af09a..881f9864c437 100644
@@ -353,11 +353,14 @@ static void vdpasim_set_vq_ready(struct vdpa_device *vdpa, u16 idx, bool ready)
 {
 	struct vdpasim *vdpasim = vdpa_to_sim(vdpa);
 	struct vdpasim_virtqueue *vq = &vdpasim->vqs[idx];
+	bool old_ready;
 
 	spin_lock(&vdpasim->lock);
+	old_ready = vq->ready;
 	vq->ready = ready;
-	if (vq->ready)
+	if (vq->ready && !old_ready) {
 		vdpasim_queue_ready(vdpasim, idx);
+	}
 	spin_unlock(&vdpasim->lock);
 }
 
Signature · 1 line
2.27.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 5 lines · Eugenio Pérez

Code must be resilient to enable a queue many times.

At the moment the queue is resetting so it's definitely not the expected behavior.

Quoted 8 lines

v2: set vq->ready = 0 at disable.

Fixes 2c53d0f64c06 ("vdpasim: vDPA device simulator")

---
drivers/vdpa/vdpa_sim/vdpa_sim.c | 5 ++++-

1 file changed, 4 insertions(+), 1 deletion(-)

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