All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH vhost 0/2] virtio: set broken when re-enable vq fails
@ 2023-10-24  3:48 Xuan Zhuo
  2023-10-24  3:49 ` [PATCH vhost 1/2] virtio_ring: remove unused code Xuan Zhuo
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Xuan Zhuo @ 2023-10-24  3:48 UTC (permalink / raw)
  To: virtualization; +Cc: Xuan Zhuo, Michael S. Tsirkin

In vp_modern_enable_vq_after_reset, we will do some check to ensure
that the vq is in reset status. If that fails, the vq is good.

If the vq_active_vp() fails, that means the vq is broken.
The driver will can not use that vq, this commit sets
the vq to broken.

Xuan Zhuo (2):
  virtio_ring: remove unused code
  virtio: set broken when re-enabling vq fails

 drivers/virtio/virtio_pci_modern.c |  6 +++---
 drivers/virtio/virtio_ring.c       | 15 ++++++++++-----
 include/linux/virtio_config.h      |  2 ++
 3 files changed, 15 insertions(+), 8 deletions(-)

--
2.32.0.3.g01195cf9f

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH vhost 1/2] virtio_ring: remove unused code
  2023-10-24  3:48 [PATCH vhost 0/2] virtio: set broken when re-enable vq fails Xuan Zhuo
@ 2023-10-24  3:49 ` Xuan Zhuo
  2023-10-24  3:49 ` [PATCH vhost 2/2] virtio: set broken when re-enabling vq fails Xuan Zhuo
  2024-01-24  6:55 ` [PATCH vhost 0/2] virtio: set broken when re-enable " Xuan Zhuo
  2 siblings, 0 replies; 4+ messages in thread
From: Xuan Zhuo @ 2023-10-24  3:49 UTC (permalink / raw)
  To: virtualization; +Cc: Xuan Zhuo, Michael S. Tsirkin

Remove the ignored return values;

Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
---
 drivers/virtio/virtio_ring.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 51d8f3299c10..af310418e66e 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -2755,9 +2755,9 @@ int virtqueue_resize(struct virtqueue *_vq, u32 num,
 		return err;
 
 	if (vq->packed_ring)
-		err = virtqueue_resize_packed(_vq, num);
+		virtqueue_resize_packed(_vq, num);
 	else
-		err = virtqueue_resize_split(_vq, num);
+		virtqueue_resize_split(_vq, num);
 
 	return virtqueue_enable_after_reset(_vq);
 }
-- 
2.32.0.3.g01195cf9f

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH vhost 2/2] virtio: set broken when re-enabling vq fails
  2023-10-24  3:48 [PATCH vhost 0/2] virtio: set broken when re-enable vq fails Xuan Zhuo
  2023-10-24  3:49 ` [PATCH vhost 1/2] virtio_ring: remove unused code Xuan Zhuo
@ 2023-10-24  3:49 ` Xuan Zhuo
  2024-01-24  6:55 ` [PATCH vhost 0/2] virtio: set broken when re-enable " Xuan Zhuo
  2 siblings, 0 replies; 4+ messages in thread
From: Xuan Zhuo @ 2023-10-24  3:49 UTC (permalink / raw)
  To: virtualization; +Cc: Xuan Zhuo, Michael S. Tsirkin

In vp_modern_enable_vq_after_reset, we will do some checks to ensure
that the vq is ready to re-enable. If that fails, the vq is good.

If the vq_active_vp() fails, that means the vq is broken.
The driver can not use that vq, this commit sets the vq to broken.

Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
---
 drivers/virtio/virtio_pci_modern.c |  6 +++---
 drivers/virtio/virtio_ring.c       | 11 ++++++++---
 include/linux/virtio_config.h      |  2 ++
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c
index ee6a386d250b..56a4075ca5fb 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -286,16 +286,16 @@ static int vp_modern_enable_vq_after_reset(struct virtqueue *vq)
 	int err;
 
 	if (!vq->reset)
-		return -EBUSY;
+		return -EINVAL;
 
 	index = vq->index;
 	info = vp_dev->vqs[index];
 
 	if (vp_modern_get_queue_reset(mdev, index))
-		return -EBUSY;
+		return -EINVAL;
 
 	if (vp_modern_get_queue_enable(mdev, index))
-		return -EBUSY;
+		return -EINVAL;
 
 	err = vp_active_vq(vq, info->msix_vector);
 	if (err)
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index af310418e66e..91e63c57c112 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -2183,11 +2183,16 @@ static int virtqueue_enable_after_reset(struct virtqueue *_vq)
 {
 	struct vring_virtqueue *vq = to_vvq(_vq);
 	struct virtio_device *vdev = vq->vq.vdev;
+	int err;
+
+	err = vdev->config->enable_vq_after_reset(_vq);
+	if (err == -EINVAL || !err)
+		return err;
 
-	if (vdev->config->enable_vq_after_reset(_vq))
-		return -EBUSY;
+	dev_warn(&vdev->dev, "Fail to re-enable the vq.%u error:%d\n", _vq->index, err);
+	__virtqueue_unbreak(_vq);
 
-	return 0;
+	return err;
 }
 
 /*
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index 2b3438de2c4d..f96bebf9b632 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -91,6 +91,8 @@ typedef void vq_callback_t(struct virtqueue *);
  * @enable_vq_after_reset: enable a reset queue
  *	vq: the virtqueue
  *	Returns 0 on success or error status
+ *	-EINVAL: the vq is not in the reset status or is not ready to enable.
+ *	Other error: enabling vq fails. The vq is in broken status.
  *	If disable_vq_and_reset is set, then enable_vq_after_reset must also be
  *	set.
  */
-- 
2.32.0.3.g01195cf9f

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH vhost 0/2] virtio: set broken when re-enable vq fails
  2023-10-24  3:48 [PATCH vhost 0/2] virtio: set broken when re-enable vq fails Xuan Zhuo
  2023-10-24  3:49 ` [PATCH vhost 1/2] virtio_ring: remove unused code Xuan Zhuo
  2023-10-24  3:49 ` [PATCH vhost 2/2] virtio: set broken when re-enabling vq fails Xuan Zhuo
@ 2024-01-24  6:55 ` Xuan Zhuo
  2 siblings, 0 replies; 4+ messages in thread
From: Xuan Zhuo @ 2024-01-24  6:55 UTC (permalink / raw)
  To: Xuan Zhuo; +Cc: Michael S. Tsirkin, Jason Wang, virtualization

On Tue, 24 Oct 2023 11:48:59 +0800, Xuan Zhuo <xuanzhuo@linux.alibaba.com> wrote:
> In vp_modern_enable_vq_after_reset, we will do some check to ensure
> that the vq is in reset status. If that fails, the vq is good.
>
> If the vq_active_vp() fails, that means the vq is broken.
> The driver will can not use that vq, this commit sets
> the vq to broken.


Hi Michael,

Is this in your list?

Thanks


>
> Xuan Zhuo (2):
>   virtio_ring: remove unused code
>   virtio: set broken when re-enabling vq fails
>
>  drivers/virtio/virtio_pci_modern.c |  6 +++---
>  drivers/virtio/virtio_ring.c       | 15 ++++++++++-----
>  include/linux/virtio_config.h      |  2 ++
>  3 files changed, 15 insertions(+), 8 deletions(-)
>
> --
> 2.32.0.3.g01195cf9f
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-01-24  6:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-24  3:48 [PATCH vhost 0/2] virtio: set broken when re-enable vq fails Xuan Zhuo
2023-10-24  3:49 ` [PATCH vhost 1/2] virtio_ring: remove unused code Xuan Zhuo
2023-10-24  3:49 ` [PATCH vhost 2/2] virtio: set broken when re-enabling vq fails Xuan Zhuo
2024-01-24  6:55 ` [PATCH vhost 0/2] virtio: set broken when re-enable " Xuan Zhuo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.