diff mbox series

hw/virtio: enable ioeventfd configuring for mmio

Message ID 161417359262.2250859.14712052392728549075.stgit@pasha-ThinkPad-X280 (mailing list archive)
State New, archived
Headers show
Series hw/virtio: enable ioeventfd configuring for mmio | expand

Commit Message

Pavel Dovgalyuk Feb. 24, 2021, 1:33 p.m. UTC
This patch adds ioeventfd flag for virtio-mmio configuration.
It allows switching ioeventfd on and off.

Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru>
---
 hw/virtio/virtio-mmio.c         |   11 ++++++++++-
 include/hw/virtio/virtio-mmio.h |    5 +++++
 2 files changed, 15 insertions(+), 1 deletion(-)

Comments

Pavel Dovgalyuk March 2, 2021, 8:14 a.m. UTC | #1
ping

On 24.02.2021 16:33, Pavel Dovgalyuk wrote:
> This patch adds ioeventfd flag for virtio-mmio configuration.
> It allows switching ioeventfd on and off.
> 
> Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru>
> ---
>   hw/virtio/virtio-mmio.c         |   11 ++++++++++-
>   include/hw/virtio/virtio-mmio.h |    5 +++++
>   2 files changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c
> index 610661d6a5..551f831562 100644
> --- a/hw/virtio/virtio-mmio.c
> +++ b/hw/virtio/virtio-mmio.c
> @@ -36,7 +36,9 @@
>   
>   static bool virtio_mmio_ioeventfd_enabled(DeviceState *d)
>   {
> -    return kvm_eventfds_enabled();
> +    VirtIOMMIOProxy *proxy = VIRTIO_MMIO(d);
> +
> +    return (proxy->flags & VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD) != 0;
>   }
>   
>   static int virtio_mmio_ioeventfd_assign(DeviceState *d,
> @@ -690,6 +692,8 @@ static Property virtio_mmio_properties[] = {
>       DEFINE_PROP_BOOL("format_transport_address", VirtIOMMIOProxy,
>                        format_transport_address, true),
>       DEFINE_PROP_BOOL("force-legacy", VirtIOMMIOProxy, legacy, true),
> +    DEFINE_PROP_BIT("ioeventfd", VirtIOMMIOProxy, flags,
> +                    VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD_BIT, true),
>       DEFINE_PROP_END_OF_LIST(),
>   };
>   
> @@ -701,6 +705,11 @@ static void virtio_mmio_realizefn(DeviceState *d, Error **errp)
>       qbus_create_inplace(&proxy->bus, sizeof(proxy->bus), TYPE_VIRTIO_MMIO_BUS,
>                           d, NULL);
>       sysbus_init_irq(sbd, &proxy->irq);
> +
> +    if (!kvm_eventfds_enabled()) {
> +        proxy->flags &= ~VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD;
> +    }
> +
>       if (proxy->legacy) {
>           memory_region_init_io(&proxy->iomem, OBJECT(d),
>                                 &virtio_legacy_mem_ops, proxy,
> diff --git a/include/hw/virtio/virtio-mmio.h b/include/hw/virtio/virtio-mmio.h
> index d4c4c386ab..090f7730e7 100644
> --- a/include/hw/virtio/virtio-mmio.h
> +++ b/include/hw/virtio/virtio-mmio.h
> @@ -49,12 +49,17 @@ typedef struct VirtIOMMIOQueue {
>       uint32_t used[2];
>   } VirtIOMMIOQueue;
>   
> +#define VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD_BIT 1
> +#define VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD \
> +        (1 << VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD_BIT)
> +
>   struct VirtIOMMIOProxy {
>       /* Generic */
>       SysBusDevice parent_obj;
>       MemoryRegion iomem;
>       qemu_irq irq;
>       bool legacy;
> +    uint32_t flags;
>       /* Guest accessible state needing migration and reset */
>       uint32_t host_features_sel;
>       uint32_t guest_features_sel;
>
Pavel Dovgalyuk March 15, 2021, 6 a.m. UTC | #2
ping

On 24.02.2021 16:33, Pavel Dovgalyuk wrote:
> This patch adds ioeventfd flag for virtio-mmio configuration.
> It allows switching ioeventfd on and off.
> 
> Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru>
> ---
>   hw/virtio/virtio-mmio.c         |   11 ++++++++++-
>   include/hw/virtio/virtio-mmio.h |    5 +++++
>   2 files changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c
> index 610661d6a5..551f831562 100644
> --- a/hw/virtio/virtio-mmio.c
> +++ b/hw/virtio/virtio-mmio.c
> @@ -36,7 +36,9 @@
>   
>   static bool virtio_mmio_ioeventfd_enabled(DeviceState *d)
>   {
> -    return kvm_eventfds_enabled();
> +    VirtIOMMIOProxy *proxy = VIRTIO_MMIO(d);
> +
> +    return (proxy->flags & VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD) != 0;
>   }
>   
>   static int virtio_mmio_ioeventfd_assign(DeviceState *d,
> @@ -690,6 +692,8 @@ static Property virtio_mmio_properties[] = {
>       DEFINE_PROP_BOOL("format_transport_address", VirtIOMMIOProxy,
>                        format_transport_address, true),
>       DEFINE_PROP_BOOL("force-legacy", VirtIOMMIOProxy, legacy, true),
> +    DEFINE_PROP_BIT("ioeventfd", VirtIOMMIOProxy, flags,
> +                    VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD_BIT, true),
>       DEFINE_PROP_END_OF_LIST(),
>   };
>   
> @@ -701,6 +705,11 @@ static void virtio_mmio_realizefn(DeviceState *d, Error **errp)
>       qbus_create_inplace(&proxy->bus, sizeof(proxy->bus), TYPE_VIRTIO_MMIO_BUS,
>                           d, NULL);
>       sysbus_init_irq(sbd, &proxy->irq);
> +
> +    if (!kvm_eventfds_enabled()) {
> +        proxy->flags &= ~VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD;
> +    }
> +
>       if (proxy->legacy) {
>           memory_region_init_io(&proxy->iomem, OBJECT(d),
>                                 &virtio_legacy_mem_ops, proxy,
> diff --git a/include/hw/virtio/virtio-mmio.h b/include/hw/virtio/virtio-mmio.h
> index d4c4c386ab..090f7730e7 100644
> --- a/include/hw/virtio/virtio-mmio.h
> +++ b/include/hw/virtio/virtio-mmio.h
> @@ -49,12 +49,17 @@ typedef struct VirtIOMMIOQueue {
>       uint32_t used[2];
>   } VirtIOMMIOQueue;
>   
> +#define VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD_BIT 1
> +#define VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD \
> +        (1 << VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD_BIT)
> +
>   struct VirtIOMMIOProxy {
>       /* Generic */
>       SysBusDevice parent_obj;
>       MemoryRegion iomem;
>       qemu_irq irq;
>       bool legacy;
> +    uint32_t flags;
>       /* Guest accessible state needing migration and reset */
>       uint32_t host_features_sel;
>       uint32_t guest_features_sel;
>
diff mbox series

Patch

diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c
index 610661d6a5..551f831562 100644
--- a/hw/virtio/virtio-mmio.c
+++ b/hw/virtio/virtio-mmio.c
@@ -36,7 +36,9 @@ 
 
 static bool virtio_mmio_ioeventfd_enabled(DeviceState *d)
 {
-    return kvm_eventfds_enabled();
+    VirtIOMMIOProxy *proxy = VIRTIO_MMIO(d);
+
+    return (proxy->flags & VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD) != 0;
 }
 
 static int virtio_mmio_ioeventfd_assign(DeviceState *d,
@@ -690,6 +692,8 @@  static Property virtio_mmio_properties[] = {
     DEFINE_PROP_BOOL("format_transport_address", VirtIOMMIOProxy,
                      format_transport_address, true),
     DEFINE_PROP_BOOL("force-legacy", VirtIOMMIOProxy, legacy, true),
+    DEFINE_PROP_BIT("ioeventfd", VirtIOMMIOProxy, flags,
+                    VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD_BIT, true),
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -701,6 +705,11 @@  static void virtio_mmio_realizefn(DeviceState *d, Error **errp)
     qbus_create_inplace(&proxy->bus, sizeof(proxy->bus), TYPE_VIRTIO_MMIO_BUS,
                         d, NULL);
     sysbus_init_irq(sbd, &proxy->irq);
+
+    if (!kvm_eventfds_enabled()) {
+        proxy->flags &= ~VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD;
+    }
+
     if (proxy->legacy) {
         memory_region_init_io(&proxy->iomem, OBJECT(d),
                               &virtio_legacy_mem_ops, proxy,
diff --git a/include/hw/virtio/virtio-mmio.h b/include/hw/virtio/virtio-mmio.h
index d4c4c386ab..090f7730e7 100644
--- a/include/hw/virtio/virtio-mmio.h
+++ b/include/hw/virtio/virtio-mmio.h
@@ -49,12 +49,17 @@  typedef struct VirtIOMMIOQueue {
     uint32_t used[2];
 } VirtIOMMIOQueue;
 
+#define VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD_BIT 1
+#define VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD \
+        (1 << VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD_BIT)
+
 struct VirtIOMMIOProxy {
     /* Generic */
     SysBusDevice parent_obj;
     MemoryRegion iomem;
     qemu_irq irq;
     bool legacy;
+    uint32_t flags;
     /* Guest accessible state needing migration and reset */
     uint32_t host_features_sel;
     uint32_t guest_features_sel;