diff mbox series

[v5,1/3] qdev: Add a granule_mode property

Message ID 20240226181337.24148-2-eric.auger@redhat.com
State New
Headers show
Series VIRTIO-IOMMU: Set default granule to host page size | expand

Commit Message

Eric Auger Feb. 26, 2024, 6:11 p.m. UTC
Introduce a new enum type property allowing to set an
IOMMU granule. Values are 4k, 8k, 16k, 64k and host.
This latter indicates the vIOMMU granule will match
the host page size.

A subsequent patch will add such a property to the
virtio-iommu device.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

---
v4 -> v5
- remove code that can be automatically generated
  and add the new enum in qapi/virtio.json (Philippe).
  Added Phild's SOB. low case needs to be used due to
  the Jason generation.

v3 -> v4:
- Add 8K
---
 qapi/virtio.json                    | 18 ++++++++++++++++++
 include/hw/qdev-properties-system.h |  3 +++
 hw/core/qdev-properties-system.c    | 15 +++++++++++++++
 3 files changed, 36 insertions(+)

Comments

Duan, Zhenzhong Feb. 27, 2024, 3:48 a.m. UTC | #1
>-----Original Message-----
>From: Eric Auger <eric.auger@redhat.com>
>Subject: [PATCH v5 1/3] qdev: Add a granule_mode property
>
>Introduce a new enum type property allowing to set an
>IOMMU granule. Values are 4k, 8k, 16k, 64k and host.
>This latter indicates the vIOMMU granule will match
>the host page size.
>
>A subsequent patch will add such a property to the
>virtio-iommu device.
>
>Signed-off-by: Eric Auger <eric.auger@redhat.com>
>Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>
>---
>v4 -> v5
>- remove code that can be automatically generated
>  and add the new enum in qapi/virtio.json (Philippe).
>  Added Phild's SOB. low case needs to be used due to
>  the Jason generation.
>
>v3 -> v4:
>- Add 8K
>---
> qapi/virtio.json                    | 18 ++++++++++++++++++
> include/hw/qdev-properties-system.h |  3 +++
> hw/core/qdev-properties-system.c    | 15 +++++++++++++++
> 3 files changed, 36 insertions(+)
>
>diff --git a/qapi/virtio.json b/qapi/virtio.json
>index a79013fe89..95745fdfd7 100644
>--- a/qapi/virtio.json
>+++ b/qapi/virtio.json
>@@ -957,3 +957,21 @@
>
> { 'struct': 'DummyVirtioForceArrays',
>   'data': { 'unused-iothread-vq-mapping': ['IOThreadVirtQueueMapping'] } }
>+
>+##
>+# @GranuleMode:
>+#
>+# @4k: granule page size of 4KiB
>+#
>+# @8k: granule page size of 8KiB
>+#
>+# @16k: granule page size of 16KiB
>+#
>+# @64k: granule page size of 64KiB
>+#
>+# @host: granule matches the host page size
>+#
>+# Since: 9.0
>+##
>+{ 'enum': 'GranuleMode',
>+  'data': [ '4k', '8k', '16k', '64k', 'host' ] }
>diff --git a/include/hw/qdev-properties-system.h b/include/hw/qdev-
>properties-system.h
>index 06c359c190..626be87dd3 100644
>--- a/include/hw/qdev-properties-system.h
>+++ b/include/hw/qdev-properties-system.h
>@@ -8,6 +8,7 @@ extern const PropertyInfo qdev_prop_macaddr;
> extern const PropertyInfo qdev_prop_reserved_region;
> extern const PropertyInfo qdev_prop_multifd_compression;
> extern const PropertyInfo qdev_prop_mig_mode;
>+extern const PropertyInfo qdev_prop_granule_mode;
> extern const PropertyInfo qdev_prop_losttickpolicy;
> extern const PropertyInfo qdev_prop_blockdev_on_error;
> extern const PropertyInfo qdev_prop_bios_chs_trans;
>@@ -47,6 +48,8 @@ extern const PropertyInfo
>qdev_prop_iothread_vq_mapping_list;
> #define DEFINE_PROP_MIG_MODE(_n, _s, _f, _d) \
>     DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_mig_mode, \
>                        MigMode)
>+#define DEFINE_PROP_GRANULE_MODE(_n, _s, _f, _d) \
>+    DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_granule_mode,
>GranuleMode)
> #define DEFINE_PROP_LOSTTICKPOLICY(_n, _s, _f, _d) \
>     DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_losttickpolicy, \
>                         LostTickPolicy)
>diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-
>system.c
>index 1a396521d5..685cffd064 100644
>--- a/hw/core/qdev-properties-system.c
>+++ b/hw/core/qdev-properties-system.c
>@@ -34,6 +34,7 @@
> #include "net/net.h"
> #include "hw/pci/pci.h"
> #include "hw/pci/pcie.h"
>+#include "hw/virtio/virtio-iommu.h"

This is unnecessary, otherwise,

Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>

Thanks
Zhenzhong

> #include "hw/i386/x86.h"
> #include "util/block-helpers.h"
>
>@@ -679,6 +680,20 @@ const PropertyInfo qdev_prop_mig_mode = {
>     .set_default_value = qdev_propinfo_set_default_value_enum,
> };
>
>+/* --- GranuleMode --- */
>+
>+QEMU_BUILD_BUG_ON(sizeof(GranuleMode) != sizeof(int));
>+
>+const PropertyInfo qdev_prop_granule_mode = {
>+    .name = "GranuleMode",
>+    .description = "granule_mode values, "
>+                   "4k, 8k, 16k, 64k, host",
>+    .enum_table = &GranuleMode_lookup,
>+    .get = qdev_propinfo_get_enum,
>+    .set = qdev_propinfo_set_enum,
>+    .set_default_value = qdev_propinfo_set_default_value_enum,
>+};
>+
> /* --- Reserved Region --- */
>
> /*
>--
>2.41.0
diff mbox series

Patch

diff --git a/qapi/virtio.json b/qapi/virtio.json
index a79013fe89..95745fdfd7 100644
--- a/qapi/virtio.json
+++ b/qapi/virtio.json
@@ -957,3 +957,21 @@ 
 
 { 'struct': 'DummyVirtioForceArrays',
   'data': { 'unused-iothread-vq-mapping': ['IOThreadVirtQueueMapping'] } }
+
+##
+# @GranuleMode:
+#
+# @4k: granule page size of 4KiB
+#
+# @8k: granule page size of 8KiB
+#
+# @16k: granule page size of 16KiB
+#
+# @64k: granule page size of 64KiB
+#
+# @host: granule matches the host page size
+#
+# Since: 9.0
+##
+{ 'enum': 'GranuleMode',
+  'data': [ '4k', '8k', '16k', '64k', 'host' ] }
diff --git a/include/hw/qdev-properties-system.h b/include/hw/qdev-properties-system.h
index 06c359c190..626be87dd3 100644
--- a/include/hw/qdev-properties-system.h
+++ b/include/hw/qdev-properties-system.h
@@ -8,6 +8,7 @@  extern const PropertyInfo qdev_prop_macaddr;
 extern const PropertyInfo qdev_prop_reserved_region;
 extern const PropertyInfo qdev_prop_multifd_compression;
 extern const PropertyInfo qdev_prop_mig_mode;
+extern const PropertyInfo qdev_prop_granule_mode;
 extern const PropertyInfo qdev_prop_losttickpolicy;
 extern const PropertyInfo qdev_prop_blockdev_on_error;
 extern const PropertyInfo qdev_prop_bios_chs_trans;
@@ -47,6 +48,8 @@  extern const PropertyInfo qdev_prop_iothread_vq_mapping_list;
 #define DEFINE_PROP_MIG_MODE(_n, _s, _f, _d) \
     DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_mig_mode, \
                        MigMode)
+#define DEFINE_PROP_GRANULE_MODE(_n, _s, _f, _d) \
+    DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_granule_mode, GranuleMode)
 #define DEFINE_PROP_LOSTTICKPOLICY(_n, _s, _f, _d) \
     DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_losttickpolicy, \
                         LostTickPolicy)
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 1a396521d5..685cffd064 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -34,6 +34,7 @@ 
 #include "net/net.h"
 #include "hw/pci/pci.h"
 #include "hw/pci/pcie.h"
+#include "hw/virtio/virtio-iommu.h"
 #include "hw/i386/x86.h"
 #include "util/block-helpers.h"
 
@@ -679,6 +680,20 @@  const PropertyInfo qdev_prop_mig_mode = {
     .set_default_value = qdev_propinfo_set_default_value_enum,
 };
 
+/* --- GranuleMode --- */
+
+QEMU_BUILD_BUG_ON(sizeof(GranuleMode) != sizeof(int));
+
+const PropertyInfo qdev_prop_granule_mode = {
+    .name = "GranuleMode",
+    .description = "granule_mode values, "
+                   "4k, 8k, 16k, 64k, host",
+    .enum_table = &GranuleMode_lookup,
+    .get = qdev_propinfo_get_enum,
+    .set = qdev_propinfo_set_enum,
+    .set_default_value = qdev_propinfo_set_default_value_enum,
+};
+
 /* --- Reserved Region --- */
 
 /*