提交 1500501f 编写于 作者: E Eugenio Pérez 提交者: Zheng Zengkai

vdpasim: allow to enable a vq repeatedly

stable inclusion
from stable-v5.10.121
commit 19e5aac38abca5213bab8b9a1dab25b9adf1ff68
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5L6CQ

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=19e5aac38abca5213bab8b9a1dab25b9adf1ff68

--------------------------------

commit 24243697 upstream.

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: 2c53d0f6 ("vdpasim: vDPA device simulator")
Cc: stable@vger.kernel.org
Signed-off-by: NEugenio Pérez <eperezma@redhat.com>
Message-Id: <20220519145919.772896-1-eperezma@redhat.com>
Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
Reviewed-by: NStefano Garzarella <sgarzare@redhat.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 dafecf59
...@@ -473,11 +473,14 @@ static void vdpasim_set_vq_ready(struct vdpa_device *vdpa, u16 idx, bool ready) ...@@ -473,11 +473,14 @@ static void vdpasim_set_vq_ready(struct vdpa_device *vdpa, u16 idx, bool ready)
{ {
struct vdpasim *vdpasim = vdpa_to_sim(vdpa); struct vdpasim *vdpasim = vdpa_to_sim(vdpa);
struct vdpasim_virtqueue *vq = &vdpasim->vqs[idx]; struct vdpasim_virtqueue *vq = &vdpasim->vqs[idx];
bool old_ready;
spin_lock(&vdpasim->lock); spin_lock(&vdpasim->lock);
old_ready = vq->ready;
vq->ready = ready; vq->ready = ready;
if (vq->ready) if (vq->ready && !old_ready) {
vdpasim_queue_ready(vdpasim, idx); vdpasim_queue_ready(vdpasim, idx);
}
spin_unlock(&vdpasim->lock); spin_unlock(&vdpasim->lock);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册