qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] virtio: rng: Check notifier helpers for VIRTIO_CONFIG_IRQ_IDX
@ 2023-10-25 17:18 Mathieu Poirier
  2023-10-26  5:06 ` Leo Yan
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Mathieu Poirier @ 2023-10-25 17:18 UTC (permalink / raw)
  To: mst; +Cc: viresh.kumar, lulu, qemu-devel

Since the driver doesn't support interrupts, we must return early when
index is set to VIRTIO_CONFIG_IRQ_IDX.  Basically the same thing Viresh
did for "91208dd297f2 virtio: i2c: Check notifier helpers for
VIRTIO_CONFIG_IRQ_IDX".

Fixes: 544f0278afca ("virtio: introduce macro VIRTIO_CONFIG_IRQ_IDX")
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 hw/virtio/vhost-user-rng.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c
index 201a39e220c5..62142b717f73 100644
--- a/hw/virtio/vhost-user-rng.c
+++ b/hw/virtio/vhost-user-rng.c
@@ -129,6 +129,14 @@ static void vu_rng_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask)
 {
     VHostUserRNG *rng = VHOST_USER_RNG(vdev);
 
+    /*
+     * We don't support interrupts, return early if index is set to
+     * VIRTIO_CONFIG_IRQ_IDX.
+     */
+    if (idx == VIRTIO_CONFIG_IRQ_IDX) {
+        return;
+    }
+
     vhost_virtqueue_mask(&rng->vhost_dev, vdev, idx, mask);
 }
 
@@ -136,6 +144,14 @@ static bool vu_rng_guest_notifier_pending(VirtIODevice *vdev, int idx)
 {
     VHostUserRNG *rng = VHOST_USER_RNG(vdev);
 
+    /*
+     * We don't support interrupts, return early if index is set to
+     * VIRTIO_CONFIG_IRQ_IDX.
+     */
+    if (idx == VIRTIO_CONFIG_IRQ_IDX) {
+        return false;
+    }
+
     return vhost_virtqueue_pending(&rng->vhost_dev, idx);
 }
 
-- 
2.34.1



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

* Re: [PATCH] virtio: rng: Check notifier helpers for VIRTIO_CONFIG_IRQ_IDX
  2023-10-25 17:18 [PATCH] virtio: rng: Check notifier helpers for VIRTIO_CONFIG_IRQ_IDX Mathieu Poirier
@ 2023-10-26  5:06 ` Leo Yan
  2023-10-26  6:08   ` Leo Yan
  2023-10-26  6:47 ` Philippe Mathieu-Daudé
  2023-11-06 17:34 ` Michael S. Tsirkin
  2 siblings, 1 reply; 5+ messages in thread
From: Leo Yan @ 2023-10-26  5:06 UTC (permalink / raw)
  To: Mathieu Poirier; +Cc: mst, viresh.kumar, lulu, qemu-devel

On Wed, Oct 25, 2023 at 11:18:41AM -0600, Mathieu Poirier wrote:
> Since the driver doesn't support interrupts, we must return early when
> index is set to VIRTIO_CONFIG_IRQ_IDX.  Basically the same thing Viresh
> did for "91208dd297f2 virtio: i2c: Check notifier helpers for
> VIRTIO_CONFIG_IRQ_IDX".
> 
> Fixes: 544f0278afca ("virtio: introduce macro VIRTIO_CONFIG_IRQ_IDX")
> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>

Tested this patch and the vhost-user-i2c device works with it:

Tested-by: Leo Yan <leo.yan@linaro.org>


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

* Re: [PATCH] virtio: rng: Check notifier helpers for VIRTIO_CONFIG_IRQ_IDX
  2023-10-26  5:06 ` Leo Yan
@ 2023-10-26  6:08   ` Leo Yan
  0 siblings, 0 replies; 5+ messages in thread
From: Leo Yan @ 2023-10-26  6:08 UTC (permalink / raw)
  To: Mathieu Poirier; +Cc: mst, viresh.kumar, lulu, qemu-devel

On Thu, Oct 26, 2023 at 01:06:21PM +0800, Leo Yan wrote:
> On Wed, Oct 25, 2023 at 11:18:41AM -0600, Mathieu Poirier wrote:
> > Since the driver doesn't support interrupts, we must return early when
> > index is set to VIRTIO_CONFIG_IRQ_IDX.  Basically the same thing Viresh
> > did for "91208dd297f2 virtio: i2c: Check notifier helpers for
> > VIRTIO_CONFIG_IRQ_IDX".
> > 
> > Fixes: 544f0278afca ("virtio: introduce macro VIRTIO_CONFIG_IRQ_IDX")
> > Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> 
> Tested this patch and the vhost-user-i2c device works with it:

Sorry for typo.  Here I am meaning the vhost-device-rng device.

> Tested-by: Leo Yan <leo.yan@linaro.org>


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

* Re: [PATCH] virtio: rng: Check notifier helpers for VIRTIO_CONFIG_IRQ_IDX
  2023-10-25 17:18 [PATCH] virtio: rng: Check notifier helpers for VIRTIO_CONFIG_IRQ_IDX Mathieu Poirier
  2023-10-26  5:06 ` Leo Yan
@ 2023-10-26  6:47 ` Philippe Mathieu-Daudé
  2023-11-06 17:34 ` Michael S. Tsirkin
  2 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-26  6:47 UTC (permalink / raw)
  To: Mathieu Poirier, mst; +Cc: viresh.kumar, lulu, qemu-devel, Alex Bennée

Hi Mathieu,

On 25/10/23 19:18, Mathieu Poirier wrote:
> Since the driver doesn't support interrupts, we must return early when
> index is set to VIRTIO_CONFIG_IRQ_IDX.  Basically the same thing Viresh
> did for "91208dd297f2 virtio: i2c: Check notifier helpers for
> VIRTIO_CONFIG_IRQ_IDX".
> 
> Fixes: 544f0278afca ("virtio: introduce macro VIRTIO_CONFIG_IRQ_IDX")
> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> ---
>   hw/virtio/vhost-user-rng.c | 16 ++++++++++++++++
>   1 file changed, 16 insertions(+)
> 
> diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c
> index 201a39e220c5..62142b717f73 100644
> --- a/hw/virtio/vhost-user-rng.c
> +++ b/hw/virtio/vhost-user-rng.c
> @@ -129,6 +129,14 @@ static void vu_rng_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask)
>   {
>       VHostUserRNG *rng = VHOST_USER_RNG(vdev);
>   
> +    /*
> +     * We don't support interrupts, return early if index is set to
> +     * VIRTIO_CONFIG_IRQ_IDX.
> +     */
> +    if (idx == VIRTIO_CONFIG_IRQ_IDX) {
> +        return;
> +    }
> +
>       vhost_virtqueue_mask(&rng->vhost_dev, vdev, idx, mask);
>   }
>   
> @@ -136,6 +144,14 @@ static bool vu_rng_guest_notifier_pending(VirtIODevice *vdev, int idx)
>   {
>       VHostUserRNG *rng = VHOST_USER_RNG(vdev);
>   
> +    /*
> +     * We don't support interrupts, return early if index is set to
> +     * VIRTIO_CONFIG_IRQ_IDX.
> +     */
> +    if (idx == VIRTIO_CONFIG_IRQ_IDX) {
> +        return false;
> +    }
> +
>       return vhost_virtqueue_pending(&rng->vhost_dev, idx);
>   }

The patch looks fine, so:
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Now I wonder if we shouldn't add that check one layer above in the
caller, eventually checking a VirtioDeviceClass::irq_supported bool.
This is out of the scope of this patch.

Regards,

Phil.


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

* Re: [PATCH] virtio: rng: Check notifier helpers for VIRTIO_CONFIG_IRQ_IDX
  2023-10-25 17:18 [PATCH] virtio: rng: Check notifier helpers for VIRTIO_CONFIG_IRQ_IDX Mathieu Poirier
  2023-10-26  5:06 ` Leo Yan
  2023-10-26  6:47 ` Philippe Mathieu-Daudé
@ 2023-11-06 17:34 ` Michael S. Tsirkin
  2 siblings, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2023-11-06 17:34 UTC (permalink / raw)
  To: Mathieu Poirier; +Cc: viresh.kumar, lulu, qemu-devel, Alex Bennée

On Wed, Oct 25, 2023 at 11:18:41AM -0600, Mathieu Poirier wrote:
> Since the driver doesn't support interrupts, we must return early when
> index is set to VIRTIO_CONFIG_IRQ_IDX.  Basically the same thing Viresh
> did for "91208dd297f2 virtio: i2c: Check notifier helpers for
> VIRTIO_CONFIG_IRQ_IDX".
> 
> Fixes: 544f0278afca ("virtio: introduce macro VIRTIO_CONFIG_IRQ_IDX")
> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>

So vhost-user-rng is now switching to use the generic base device.
Alex could you help suggest how to rebase this on top of your series please?

> ---
>  hw/virtio/vhost-user-rng.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c
> index 201a39e220c5..62142b717f73 100644
> --- a/hw/virtio/vhost-user-rng.c
> +++ b/hw/virtio/vhost-user-rng.c
> @@ -129,6 +129,14 @@ static void vu_rng_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask)
>  {
>      VHostUserRNG *rng = VHOST_USER_RNG(vdev);
>  
> +    /*
> +     * We don't support interrupts, return early if index is set to
> +     * VIRTIO_CONFIG_IRQ_IDX.
> +     */
> +    if (idx == VIRTIO_CONFIG_IRQ_IDX) {
> +        return;
> +    }
> +
>      vhost_virtqueue_mask(&rng->vhost_dev, vdev, idx, mask);
>  }
>  
> @@ -136,6 +144,14 @@ static bool vu_rng_guest_notifier_pending(VirtIODevice *vdev, int idx)
>  {
>      VHostUserRNG *rng = VHOST_USER_RNG(vdev);
>  
> +    /*
> +     * We don't support interrupts, return early if index is set to
> +     * VIRTIO_CONFIG_IRQ_IDX.
> +     */
> +    if (idx == VIRTIO_CONFIG_IRQ_IDX) {
> +        return false;
> +    }
> +
>      return vhost_virtqueue_pending(&rng->vhost_dev, idx);
>  }
>  
> -- 
> 2.34.1



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

end of thread, other threads:[~2023-11-06 17:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-25 17:18 [PATCH] virtio: rng: Check notifier helpers for VIRTIO_CONFIG_IRQ_IDX Mathieu Poirier
2023-10-26  5:06 ` Leo Yan
2023-10-26  6:08   ` Leo Yan
2023-10-26  6:47 ` Philippe Mathieu-Daudé
2023-11-06 17:34 ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).