All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] hw/virtio: Add boilerplate for vhost-user-scmi device
  2023-05-30 19:59 [PATCH 0/4] Add SCMI vhost-user VIRTIO device Milan Zamazal
@ 2023-05-23  8:02 ` Milan Zamazal
  2023-05-23  8:19 ` [PATCH 2/4] hw/virtio: Add vhost-user-scmi-pci boilerplate Milan Zamazal
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Milan Zamazal @ 2023-05-23  8:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, stefanha, alex.bennee

This creates the QEMU side of the vhost-user-scmi device which connects to
the remote daemon.  It is based on code of similar vhost-user devices.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
---
 MAINTAINERS                         |   6 +
 hw/virtio/Kconfig                   |   5 +
 hw/virtio/meson.build               |   1 +
 hw/virtio/vhost-user-scmi.c         | 306 ++++++++++++++++++++++++++++
 include/hw/virtio/vhost-user-scmi.h |  30 +++
 5 files changed, 348 insertions(+)
 create mode 100644 hw/virtio/vhost-user-scmi.c
 create mode 100644 include/hw/virtio/vhost-user-scmi.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 4b025a7b63..1ce2f3dabe 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2202,6 +2202,12 @@ F: hw/virtio/vhost-user-gpio*
 F: include/hw/virtio/vhost-user-gpio.h
 F: tests/qtest/libqos/virtio-gpio.*
 
+vhost-user-scmi
+R: mzamazal@redhat.com
+S: Supported
+F: hw/virtio/vhost-user-scmi*
+F: include/hw/virtio/vhost-user-scmi.h
+
 virtio-crypto
 M: Gonglei <arei.gonglei@huawei.com>
 S: Supported
diff --git a/hw/virtio/Kconfig b/hw/virtio/Kconfig
index 89e9e426d8..2515d4ff68 100644
--- a/hw/virtio/Kconfig
+++ b/hw/virtio/Kconfig
@@ -90,3 +90,8 @@ config VHOST_VDPA_DEV
     bool
     default y
     depends on VIRTIO && VHOST_VDPA && LINUX
+
+config VHOST_USER_SCMI
+    bool
+    default y
+    depends on VIRTIO && VHOST_USER
diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build
index bdec78bfc6..c3eeb23942 100644
--- a/hw/virtio/meson.build
+++ b/hw/virtio/meson.build
@@ -32,6 +32,7 @@ specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user
 specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c'))
 specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c'))
 specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO'], if_true: files('vhost-user-gpio-pci.c'))
+specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_SCMI', if_true: files('vhost-user-scmi.c'))
 specific_virtio_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa-dev.c'))
 
 virtio_pci_ss = ss.source_set()
diff --git a/hw/virtio/vhost-user-scmi.c b/hw/virtio/vhost-user-scmi.c
new file mode 100644
index 0000000000..d386fb2df9
--- /dev/null
+++ b/hw/virtio/vhost-user-scmi.c
@@ -0,0 +1,306 @@
+/*
+ * Vhost-user SCMI virtio device
+ *
+ * SPDX-FileCopyrightText: Red Hat, Inc.
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * Implementation based on other vhost-user devices in QEMU.
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "qemu/error-report.h"
+#include "hw/virtio/virtio-bus.h"
+#include "hw/virtio/vhost-user-scmi.h"
+#include "standard-headers/linux/virtio_ids.h"
+#include "standard-headers/linux/virtio_scmi.h"
+#include "trace.h"
+
+/*
+ * In this version, we don't support VIRTIO_SCMI_F_SHARED_MEMORY.
+ * Note that VIRTIO_SCMI_F_SHARED_MEMORY is currently not supported in
+ * Linux VirtIO SCMI guest driver.
+ */
+static const int feature_bits[] = {
+    VIRTIO_F_VERSION_1,
+    VIRTIO_F_NOTIFY_ON_EMPTY,
+    VIRTIO_RING_F_INDIRECT_DESC,
+    VIRTIO_RING_F_EVENT_IDX,
+    VIRTIO_F_RING_RESET,
+    VIRTIO_SCMI_F_P2A_CHANNELS,
+    VHOST_INVALID_FEATURE_BIT
+};
+
+static int vu_scmi_start(VirtIODevice *vdev)
+{
+    VHostUserSCMI *scmi = VHOST_USER_SCMI(vdev);
+    BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
+    VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
+    struct vhost_dev *vhost_dev = &scmi->vhost_dev;
+    int ret, i;
+
+    if (!k->set_guest_notifiers) {
+        error_report("binding does not support guest notifiers");
+        return -ENOSYS;
+    }
+
+    ret = vhost_dev_enable_notifiers(vhost_dev, vdev);
+    if (ret < 0) {
+        error_report("Error enabling host notifiers: %d", ret);
+        return ret;
+    }
+
+    ret = k->set_guest_notifiers(qbus->parent, vhost_dev->nvqs, true);
+    if (ret < 0) {
+        error_report("Error binding guest notifier: %d", ret);
+        goto err_host_notifiers;
+    }
+
+    vhost_ack_features(&scmi->vhost_dev, feature_bits, vdev->guest_features);
+
+    ret = vhost_dev_start(&scmi->vhost_dev, vdev, true);
+    if (ret < 0) {
+        error_report("Error starting vhost-user-scmi: %d", ret);
+        goto err_guest_notifiers;
+    }
+
+    /*
+     * guest_notifier_mask/pending not used yet, so just unmask
+     * everything here. virtio-pci will do the right thing by
+     * enabling/disabling irqfd.
+     */
+    for (i = 0; i < scmi->vhost_dev.nvqs; i++) {
+        vhost_virtqueue_mask(&scmi->vhost_dev, vdev, i, false);
+    }
+    return 0;
+
+err_guest_notifiers:
+    k->set_guest_notifiers(qbus->parent, vhost_dev->nvqs, false);
+err_host_notifiers:
+    vhost_dev_disable_notifiers(vhost_dev, vdev);
+
+    return ret;
+}
+
+static void vu_scmi_stop(VirtIODevice *vdev)
+{
+    VHostUserSCMI *scmi = VHOST_USER_SCMI(vdev);
+    BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
+    VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
+    struct vhost_dev *vhost_dev = &scmi->vhost_dev;
+    int ret;
+
+    if (!k->set_guest_notifiers) {
+        return;
+    }
+
+    vhost_dev_stop(vhost_dev, vdev, true);
+
+    ret = k->set_guest_notifiers(qbus->parent, vhost_dev->nvqs, false);
+    if (ret < 0) {
+        error_report("vhost guest notifier cleanup failed: %d", ret);
+        return;
+    }
+    vhost_dev_disable_notifiers(vhost_dev, vdev);
+}
+
+static void vu_scmi_set_status(VirtIODevice *vdev, uint8_t status)
+{
+    VHostUserSCMI *scmi = VHOST_USER_SCMI(vdev);
+    bool should_start = virtio_device_should_start(vdev, status);
+
+    if (!scmi->connected) {
+        return;
+    }
+    if (vhost_dev_is_started(&scmi->vhost_dev) == should_start) {
+        return;
+    }
+
+    if (should_start) {
+        vu_scmi_start(vdev);
+    } else {
+        vu_scmi_stop(vdev);
+    }
+}
+
+static uint64_t vu_scmi_get_features(VirtIODevice *vdev, uint64_t features,
+                                     Error **errp)
+{
+    VHostUserSCMI *scmi = VHOST_USER_SCMI(vdev);
+
+    return vhost_get_features(&scmi->vhost_dev, feature_bits, features);
+}
+
+static void vu_scmi_handle_output(VirtIODevice *vdev, VirtQueue *vq)
+{
+    /*
+     * Not normally called; it's the daemon that handles the queue;
+     * however virtio's cleanup path can call this.
+     */
+}
+
+static void vu_scmi_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask)
+{
+    VHostUserSCMI *scmi = VHOST_USER_SCMI(vdev);
+
+    if (idx == VIRTIO_CONFIG_IRQ_IDX) {
+        return;
+    }
+
+    vhost_virtqueue_mask(&scmi->vhost_dev, vdev, idx, mask);
+}
+
+static bool vu_scmi_guest_notifier_pending(VirtIODevice *vdev, int idx)
+{
+    VHostUserSCMI *scmi = VHOST_USER_SCMI(vdev);
+
+    return vhost_virtqueue_pending(&scmi->vhost_dev, idx);
+}
+
+static void vu_scmi_connect(DeviceState *dev)
+{
+    VirtIODevice *vdev = VIRTIO_DEVICE(dev);
+    VHostUserSCMI *scmi = VHOST_USER_SCMI(vdev);
+
+    if (scmi->connected) {
+        return;
+    }
+    scmi->connected = true;
+
+    /* restore vhost state */
+    if (virtio_device_started(vdev, vdev->status)) {
+        vu_scmi_start(vdev);
+    }
+}
+
+static void vu_scmi_disconnect(DeviceState *dev)
+{
+    VirtIODevice *vdev = VIRTIO_DEVICE(dev);
+    VHostUserSCMI *scmi = VHOST_USER_SCMI(vdev);
+
+    if (!scmi->connected) {
+        return;
+    }
+    scmi->connected = false;
+
+    if (vhost_dev_is_started(&scmi->vhost_dev)) {
+        vu_scmi_stop(vdev);
+    }
+}
+
+static void vu_scmi_event(void *opaque, QEMUChrEvent event)
+{
+    DeviceState *dev = opaque;
+
+    switch (event) {
+    case CHR_EVENT_OPENED:
+        vu_scmi_connect(dev);
+        break;
+    case CHR_EVENT_CLOSED:
+        vu_scmi_disconnect(dev);
+        break;
+    case CHR_EVENT_BREAK:
+    case CHR_EVENT_MUX_IN:
+    case CHR_EVENT_MUX_OUT:
+        /* Ignore */
+        break;
+    }
+}
+
+static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserSCMI *scmi)
+{
+    virtio_delete_queue(scmi->cmd_vq);
+    virtio_delete_queue(scmi->event_vq);
+    g_free(scmi->vhost_dev.vqs);
+    virtio_cleanup(vdev);
+    vhost_user_cleanup(&scmi->vhost_user);
+}
+
+static void vu_scmi_device_realize(DeviceState *dev, Error **errp)
+{
+    VirtIODevice *vdev = VIRTIO_DEVICE(dev);
+    VHostUserSCMI *scmi = VHOST_USER_SCMI(dev);
+    int ret;
+
+    if (!scmi->chardev.chr) {
+        error_setg(errp, "vhost-user-scmi: chardev is mandatory");
+        return;
+    }
+
+    vdev->host_features |= (1ULL << VIRTIO_SCMI_F_P2A_CHANNELS);
+
+    if (!vhost_user_init(&scmi->vhost_user, &scmi->chardev, errp)) {
+        return;
+    }
+
+    virtio_init(vdev, VIRTIO_ID_SCMI, 0);
+
+    scmi->cmd_vq = virtio_add_queue(vdev, 256, vu_scmi_handle_output);
+    scmi->event_vq = virtio_add_queue(vdev, 256, vu_scmi_handle_output);
+    scmi->vhost_dev.nvqs = 2;
+    scmi->vhost_dev.vqs = g_new0(struct vhost_virtqueue, scmi->vhost_dev.nvqs);
+
+    ret = vhost_dev_init(&scmi->vhost_dev, &scmi->vhost_user,
+                         VHOST_BACKEND_TYPE_USER, 0, errp);
+    if (ret < 0) {
+        error_setg_errno(errp, -ret,
+                         "vhost-user-scmi: vhost_dev_init() failed");
+        do_vhost_user_cleanup(vdev, scmi);
+        return;
+    }
+
+    qemu_chr_fe_set_handlers(&scmi->chardev, NULL, NULL, vu_scmi_event, NULL,
+                             dev, NULL, true);
+
+    return;
+}
+
+static void vu_scmi_device_unrealize(DeviceState *dev)
+{
+    VirtIODevice *vdev = VIRTIO_DEVICE(dev);
+    VHostUserSCMI *scmi = VHOST_USER_SCMI(dev);
+
+    vu_scmi_set_status(vdev, 0);
+    vhost_dev_cleanup(&scmi->vhost_dev);
+    do_vhost_user_cleanup(vdev, scmi);
+}
+
+static const VMStateDescription vu_scmi_vmstate = {
+    .name = "vhost-user-scmi",
+    .unmigratable = 1,
+};
+
+static Property vu_scmi_properties[] = {
+    DEFINE_PROP_CHR("chardev", VHostUserSCMI, chardev),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
+static void vu_scmi_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
+
+    device_class_set_props(dc, vu_scmi_properties);
+    dc->vmsd = &vu_scmi_vmstate;
+    set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
+    vdc->realize = vu_scmi_device_realize;
+    vdc->unrealize = vu_scmi_device_unrealize;
+    vdc->get_features = vu_scmi_get_features;
+    vdc->set_status = vu_scmi_set_status;
+    vdc->guest_notifier_mask = vu_scmi_guest_notifier_mask;
+    vdc->guest_notifier_pending = vu_scmi_guest_notifier_pending;
+}
+
+static const TypeInfo vu_scmi_info = {
+    .name = TYPE_VHOST_USER_SCMI,
+    .parent = TYPE_VIRTIO_DEVICE,
+    .instance_size = sizeof(VHostUserSCMI),
+    .class_init = vu_scmi_class_init,
+};
+
+static void vu_scmi_register_types(void)
+{
+    type_register_static(&vu_scmi_info);
+}
+
+type_init(vu_scmi_register_types)
diff --git a/include/hw/virtio/vhost-user-scmi.h b/include/hw/virtio/vhost-user-scmi.h
new file mode 100644
index 0000000000..6175a74ebd
--- /dev/null
+++ b/include/hw/virtio/vhost-user-scmi.h
@@ -0,0 +1,30 @@
+/*
+ * Vhost-user SCMI virtio device
+ *
+ * Copyright (c) 2023 Red Hat, Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef _QEMU_VHOST_USER_SCMI_H
+#define _QEMU_VHOST_USER_SCMI_H
+
+#include "hw/virtio/virtio.h"
+#include "hw/virtio/vhost.h"
+#include "hw/virtio/vhost-user.h"
+
+#define TYPE_VHOST_USER_SCMI "vhost-user-scmi"
+OBJECT_DECLARE_SIMPLE_TYPE(VHostUserSCMI, VHOST_USER_SCMI);
+
+struct VHostUserSCMI {
+    VirtIODevice parent;
+    CharBackend chardev;
+    struct vhost_virtqueue *vhost_vqs;
+    struct vhost_dev vhost_dev;
+    VhostUserState vhost_user;
+    VirtQueue *cmd_vq;
+    VirtQueue *event_vq;
+    bool connected;
+};
+
+#endif /* _QEMU_VHOST_USER_SCMI_H */
-- 
2.38.5



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

* [PATCH 2/4] hw/virtio: Add vhost-user-scmi-pci boilerplate
  2023-05-30 19:59 [PATCH 0/4] Add SCMI vhost-user VIRTIO device Milan Zamazal
  2023-05-23  8:02 ` [PATCH 1/4] hw/virtio: Add boilerplate for vhost-user-scmi device Milan Zamazal
@ 2023-05-23  8:19 ` Milan Zamazal
  2023-05-23 14:38 ` [PATCH 4/4] tests/qtest: enable tests for virtio-scmi Milan Zamazal
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Milan Zamazal @ 2023-05-23  8:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, stefanha, alex.bennee

This allows is to instantiate a vhost-user-scmi device as part of a PCI bus.
It is mostly boilerplate similar to the other vhost-user-*-pci boilerplates
of similar devices.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
---
 hw/virtio/meson.build           |  1 +
 hw/virtio/vhost-user-scmi-pci.c | 68 +++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+)
 create mode 100644 hw/virtio/vhost-user-scmi-pci.c

diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build
index c3eeb23942..bdea57b2ef 100644
--- a/hw/virtio/meson.build
+++ b/hw/virtio/meson.build
@@ -33,6 +33,7 @@ specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user
 specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c'))
 specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO'], if_true: files('vhost-user-gpio-pci.c'))
 specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_SCMI', if_true: files('vhost-user-scmi.c'))
+specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_SCMI'], if_true: files('vhost-user-scmi-pci.c'))
 specific_virtio_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa-dev.c'))
 
 virtio_pci_ss = ss.source_set()
diff --git a/hw/virtio/vhost-user-scmi-pci.c b/hw/virtio/vhost-user-scmi-pci.c
new file mode 100644
index 0000000000..7f53af7fce
--- /dev/null
+++ b/hw/virtio/vhost-user-scmi-pci.c
@@ -0,0 +1,68 @@
+/*
+ * Vhost-user SCMI virtio device PCI glue
+ *
+ * SPDX-FileCopyrightText: Red Hat, Inc.
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/qdev-properties.h"
+#include "hw/virtio/vhost-user-scmi.h"
+#include "hw/virtio/virtio-pci.h"
+
+struct VHostUserSCMIPCI {
+    VirtIOPCIProxy parent_obj;
+    VHostUserSCMI vdev;
+};
+
+typedef struct VHostUserSCMIPCI VHostUserSCMIPCI;
+
+#define TYPE_VHOST_USER_SCMI_PCI "vhost-user-scmi-pci-base"
+
+DECLARE_INSTANCE_CHECKER(VHostUserSCMIPCI, VHOST_USER_SCMI_PCI,
+                         TYPE_VHOST_USER_SCMI_PCI)
+
+static void vhost_user_scmi_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
+{
+    VHostUserSCMIPCI *dev = VHOST_USER_SCMI_PCI(vpci_dev);
+    DeviceState *vdev = DEVICE(&dev->vdev);
+
+    vpci_dev->nvectors = 1;
+    qdev_realize(vdev, BUS(&vpci_dev->bus), errp);
+}
+
+static void vhost_user_scmi_pci_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass);
+    PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass);
+    k->realize = vhost_user_scmi_pci_realize;
+    set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
+    pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
+    pcidev_k->device_id = 0; /* Set by virtio-pci based on virtio id */
+    pcidev_k->revision = 0x00;
+    pcidev_k->class_id = PCI_CLASS_COMMUNICATION_OTHER;
+}
+
+static void vhost_user_scmi_pci_instance_init(Object *obj)
+{
+    VHostUserSCMIPCI *dev = VHOST_USER_SCMI_PCI(obj);
+
+    virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
+                                TYPE_VHOST_USER_SCMI);
+}
+
+static const VirtioPCIDeviceTypeInfo vhost_user_scmi_pci_info = {
+    .base_name = TYPE_VHOST_USER_SCMI_PCI,
+    .non_transitional_name = "vhost-user-scmi-pci",
+    .instance_size = sizeof(VHostUserSCMIPCI),
+    .instance_init = vhost_user_scmi_pci_instance_init,
+    .class_init = vhost_user_scmi_pci_class_init,
+};
+
+static void vhost_user_scmi_pci_register(void)
+{
+    virtio_pci_types_register(&vhost_user_scmi_pci_info);
+}
+
+type_init(vhost_user_scmi_pci_register);
-- 
2.38.5



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

* [PATCH 4/4] tests/qtest: enable tests for virtio-scmi
  2023-05-30 19:59 [PATCH 0/4] Add SCMI vhost-user VIRTIO device Milan Zamazal
  2023-05-23  8:02 ` [PATCH 1/4] hw/virtio: Add boilerplate for vhost-user-scmi device Milan Zamazal
  2023-05-23  8:19 ` [PATCH 2/4] hw/virtio: Add vhost-user-scmi-pci boilerplate Milan Zamazal
@ 2023-05-23 14:38 ` Milan Zamazal
  2023-05-31  5:05   ` Thomas Huth
  2023-05-24 13:34 ` [PATCH 3/4] tests/qtest: Fix a comment typo in vhost-user-test.c Milan Zamazal
  2023-05-31 11:19 ` [PATCH 0/4] Add SCMI vhost-user VIRTIO device Alex Bennée
  4 siblings, 1 reply; 11+ messages in thread
From: Milan Zamazal @ 2023-05-23 14:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, stefanha, alex.bennee

We don't have a virtio-scmi implementation in QEMU and only support a
vhost-user backend.  This is very similar to virtio-gpio and we add the same
set of tests, just passing some vhost-user messages over the control socket.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
---
 MAINTAINERS                      |   1 +
 tests/qtest/libqos/meson.build   |   1 +
 tests/qtest/libqos/virtio-scmi.c | 174 +++++++++++++++++++++++++++++++
 tests/qtest/libqos/virtio-scmi.h |  34 ++++++
 tests/qtest/vhost-user-test.c    |  44 ++++++++
 5 files changed, 254 insertions(+)
 create mode 100644 tests/qtest/libqos/virtio-scmi.c
 create mode 100644 tests/qtest/libqos/virtio-scmi.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 1ce2f3dabe..26a5bad736 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2207,6 +2207,7 @@ R: mzamazal@redhat.com
 S: Supported
 F: hw/virtio/vhost-user-scmi*
 F: include/hw/virtio/vhost-user-scmi.h
+F: tests/qtest/libqos/virtio-scmi.*
 
 virtio-crypto
 M: Gonglei <arei.gonglei@huawei.com>
diff --git a/tests/qtest/libqos/meson.build b/tests/qtest/libqos/meson.build
index cc209a8de5..90aae42a22 100644
--- a/tests/qtest/libqos/meson.build
+++ b/tests/qtest/libqos/meson.build
@@ -46,6 +46,7 @@ libqos_srcs = files(
         'virtio-serial.c',
         'virtio-iommu.c',
         'virtio-gpio.c',
+        'virtio-scmi.c',
         'generic-pcihost.c',
 
         # qgraph machines:
diff --git a/tests/qtest/libqos/virtio-scmi.c b/tests/qtest/libqos/virtio-scmi.c
new file mode 100644
index 0000000000..ce8f4d5c06
--- /dev/null
+++ b/tests/qtest/libqos/virtio-scmi.c
@@ -0,0 +1,174 @@
+/*
+ * virtio-scmi nodes for testing
+ *
+ * SPDX-FileCopyrightText: Linaro Ltd
+ * SPDX-FileCopyrightText: Red Hat, Inc.
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * Based on virtio-gpio.c, doing basically the same thing.
+ */
+
+#include "qemu/osdep.h"
+#include "standard-headers/linux/virtio_config.h"
+#include "../libqtest.h"
+#include "qemu/module.h"
+#include "qgraph.h"
+#include "virtio-scmi.h"
+
+static QGuestAllocator *alloc;
+
+static void virtio_scmi_cleanup(QVhostUserSCMI *scmi)
+{
+    QVirtioDevice *vdev = scmi->vdev;
+    int i;
+
+    for (i = 0; i < 2; i++) {
+        qvirtqueue_cleanup(vdev->bus, scmi->queues[i], alloc);
+    }
+    g_free(scmi->queues);
+}
+
+/*
+ * This handles the VirtIO setup from the point of view of the driver
+ * frontend and therefore doesn't present any vhost specific features
+ * and in fact masks of the re-used bit.
+ */
+static void virtio_scmi_setup(QVhostUserSCMI *scmi)
+{
+    QVirtioDevice *vdev = scmi->vdev;
+    uint64_t features;
+    int i;
+
+    features = qvirtio_get_features(vdev);
+    features &= ~QVIRTIO_F_BAD_FEATURE;
+    qvirtio_set_features(vdev, features);
+
+    scmi->queues = g_new(QVirtQueue *, 2);
+    for (i = 0; i < 2; i++) {
+        scmi->queues[i] = qvirtqueue_setup(vdev, alloc, i);
+    }
+    qvirtio_set_driver_ok(vdev);
+}
+
+static void *qvirtio_scmi_get_driver(QVhostUserSCMI *v_scmi,
+                                     const char *interface)
+{
+    if (!g_strcmp0(interface, "vhost-user-scmi")) {
+        return v_scmi;
+    }
+    if (!g_strcmp0(interface, "virtio")) {
+        return v_scmi->vdev;
+    }
+
+    g_assert_not_reached();
+}
+
+static void *qvirtio_scmi_device_get_driver(void *object,
+                                            const char *interface)
+{
+    QVhostUserSCMIDevice *v_scmi = object;
+    return qvirtio_scmi_get_driver(&v_scmi->scmi, interface);
+}
+
+/* virtio-scmi (mmio) */
+static void qvirtio_scmi_device_destructor(QOSGraphObject *obj)
+{
+    QVhostUserSCMIDevice *scmi_dev = (QVhostUserSCMIDevice *) obj;
+    virtio_scmi_cleanup(&scmi_dev->scmi);
+}
+
+static void qvirtio_scmi_device_start_hw(QOSGraphObject *obj)
+{
+    QVhostUserSCMIDevice *scmi_dev = (QVhostUserSCMIDevice *) obj;
+    virtio_scmi_setup(&scmi_dev->scmi);
+}
+
+static void *virtio_scmi_device_create(void *virtio_dev,
+                                       QGuestAllocator *t_alloc,
+                                       void *addr)
+{
+    QVhostUserSCMIDevice *virtio_device = g_new0(QVhostUserSCMIDevice, 1);
+    QVhostUserSCMI *interface = &virtio_device->scmi;
+
+    interface->vdev = virtio_dev;
+    alloc = t_alloc;
+
+    virtio_device->obj.get_driver = qvirtio_scmi_device_get_driver;
+    virtio_device->obj.start_hw = qvirtio_scmi_device_start_hw;
+    virtio_device->obj.destructor = qvirtio_scmi_device_destructor;
+
+    return &virtio_device->obj;
+}
+
+/* virtio-scmi-pci */
+static void qvirtio_scmi_pci_destructor(QOSGraphObject *obj)
+{
+    QVhostUserSCMIPCI *scmi_pci = (QVhostUserSCMIPCI *) obj;
+    QOSGraphObject *pci_vobj =  &scmi_pci->pci_vdev.obj;
+
+    virtio_scmi_cleanup(&scmi_pci->scmi);
+    qvirtio_pci_destructor(pci_vobj);
+}
+
+static void qvirtio_scmi_pci_start_hw(QOSGraphObject *obj)
+{
+    QVhostUserSCMIPCI *scmi_pci = (QVhostUserSCMIPCI *) obj;
+    QOSGraphObject *pci_vobj =  &scmi_pci->pci_vdev.obj;
+
+    qvirtio_pci_start_hw(pci_vobj);
+    virtio_scmi_setup(&scmi_pci->scmi);
+}
+
+static void *qvirtio_scmi_pci_get_driver(void *object, const char *interface)
+{
+    QVhostUserSCMIPCI *v_scmi = object;
+
+    if (!g_strcmp0(interface, "pci-device")) {
+        return v_scmi->pci_vdev.pdev;
+    }
+    return qvirtio_scmi_get_driver(&v_scmi->scmi, interface);
+}
+
+static void *virtio_scmi_pci_create(void *pci_bus, QGuestAllocator *t_alloc,
+                                    void *addr)
+{
+    QVhostUserSCMIPCI *virtio_spci = g_new0(QVhostUserSCMIPCI, 1);
+    QVhostUserSCMI *interface = &virtio_spci->scmi;
+    QOSGraphObject *obj = &virtio_spci->pci_vdev.obj;
+
+    virtio_pci_init(&virtio_spci->pci_vdev, pci_bus, addr);
+    interface->vdev = &virtio_spci->pci_vdev.vdev;
+    alloc = t_alloc;
+
+    obj->get_driver = qvirtio_scmi_pci_get_driver;
+    obj->start_hw = qvirtio_scmi_pci_start_hw;
+    obj->destructor = qvirtio_scmi_pci_destructor;
+
+    return obj;
+}
+
+static void virtio_scmi_register_nodes(void)
+{
+    QPCIAddress addr = {
+        .devfn = QPCI_DEVFN(4, 0),
+    };
+
+    QOSGraphEdgeOptions edge_opts = { };
+
+    /* vhost-user-scmi-device */
+    edge_opts.extra_device_opts = "id=scmi,chardev=chr-vhost-user-test "
+        "-global virtio-mmio.force-legacy=false";
+    qos_node_create_driver("vhost-user-scmi-device",
+                            virtio_scmi_device_create);
+    qos_node_consumes("vhost-user-scmi-device", "virtio-bus", &edge_opts);
+    qos_node_produces("vhost-user-scmi-device", "vhost-user-scmi");
+
+    /* virtio-scmi-pci */
+    edge_opts.extra_device_opts = "id=scmi,addr=04.0,chardev=chr-vhost-user-test";
+    add_qpci_address(&edge_opts, &addr);
+    qos_node_create_driver("vhost-user-scmi-pci", virtio_scmi_pci_create);
+    qos_node_consumes("vhost-user-scmi-pci", "pci-bus", &edge_opts);
+    qos_node_produces("vhost-user-scmi-pci", "vhost-user-scmi");
+}
+
+libqos_init(virtio_scmi_register_nodes);
diff --git a/tests/qtest/libqos/virtio-scmi.h b/tests/qtest/libqos/virtio-scmi.h
new file mode 100644
index 0000000000..cb5670da6e
--- /dev/null
+++ b/tests/qtest/libqos/virtio-scmi.h
@@ -0,0 +1,34 @@
+/*
+ * virtio-scmi structures
+ *
+ * SPDX-FileCopyrightText: Red Hat, Inc.
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef TESTS_LIBQOS_VIRTIO_SCMI_H
+#define TESTS_LIBQOS_VIRTIO_SCMI_H
+
+#include "qgraph.h"
+#include "virtio.h"
+#include "virtio-pci.h"
+
+typedef struct QVhostUserSCMI QVhostUserSCMI;
+typedef struct QVhostUserSCMIPCI QVhostUserSCMIPCI;
+typedef struct QVhostUserSCMIDevice QVhostUserSCMIDevice;
+
+struct QVhostUserSCMI {
+    QVirtioDevice *vdev;
+    QVirtQueue **queues;
+};
+
+struct QVhostUserSCMIPCI {
+    QVirtioPCIDevice pci_vdev;
+    QVhostUserSCMI scmi;
+};
+
+struct QVhostUserSCMIDevice {
+    QOSGraphObject obj;
+    QVhostUserSCMI scmi;
+};
+
+#endif
diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c
index 8ab10732f8..2377780fb0 100644
--- a/tests/qtest/vhost-user-test.c
+++ b/tests/qtest/vhost-user-test.c
@@ -33,6 +33,7 @@
 #include "standard-headers/linux/virtio_ids.h"
 #include "standard-headers/linux/virtio_net.h"
 #include "standard-headers/linux/virtio_gpio.h"
+#include "standard-headers/linux/virtio_scmi.h"
 
 #ifdef CONFIG_LINUX
 #include <sys/vfs.h>
@@ -145,6 +146,7 @@ enum {
 enum {
     VHOST_USER_NET,
     VHOST_USER_GPIO,
+    VHOST_USER_SCMI,
 };
 
 typedef struct TestServer {
@@ -1157,3 +1159,45 @@ static void register_vhost_gpio_test(void)
                  "vhost-user-gpio", test_read_guest_mem, &opts);
 }
 libqos_init(register_vhost_gpio_test);
+
+static uint64_t vu_scmi_get_features(TestServer *s)
+{
+    return 0x1ULL << VIRTIO_F_VERSION_1 |
+        0x1ULL << VIRTIO_SCMI_F_P2A_CHANNELS |
+        0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES;
+}
+
+static void vu_scmi_get_protocol_features(TestServer *s, CharBackend *chr,
+                                          VhostUserMsg *msg)
+{
+    msg->flags |= VHOST_USER_REPLY_MASK;
+    msg->size = sizeof(m.payload.u64);
+    msg->payload.u64 = 1ULL << VHOST_USER_PROTOCOL_F_MQ;
+
+    qemu_chr_fe_write_all(chr, (uint8_t *)msg, VHOST_USER_HDR_SIZE + msg->size);
+}
+
+static struct vhost_user_ops g_vu_scmi_ops = {
+    .type = VHOST_USER_SCMI,
+
+    .append_opts = append_vhost_gpio_opts,
+
+    .get_features = vu_scmi_get_features,
+    .set_features = vu_net_set_features,
+    .get_protocol_features = vu_scmi_get_protocol_features,
+};
+
+static void register_vhost_scmi_test(void)
+{
+    QOSGraphTestOptions opts = {
+        .before = vhost_user_test_setup,
+        .subprocess = true,
+        .arg = &g_vu_scmi_ops,
+    };
+
+    qemu_add_opts(&qemu_chardev_opts);
+
+    qos_add_test("scmi/read-guest-mem/memfile",
+                 "vhost-user-scmi", test_read_guest_mem, &opts);
+}
+libqos_init(register_vhost_scmi_test);
-- 
2.38.5



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

* [PATCH 3/4] tests/qtest: Fix a comment typo in vhost-user-test.c
  2023-05-30 19:59 [PATCH 0/4] Add SCMI vhost-user VIRTIO device Milan Zamazal
                   ` (2 preceding siblings ...)
  2023-05-23 14:38 ` [PATCH 4/4] tests/qtest: enable tests for virtio-scmi Milan Zamazal
@ 2023-05-24 13:34 ` Milan Zamazal
  2023-05-31  5:02   ` Thomas Huth
  2023-05-31 11:19 ` [PATCH 0/4] Add SCMI vhost-user VIRTIO device Alex Bennée
  4 siblings, 1 reply; 11+ messages in thread
From: Milan Zamazal @ 2023-05-24 13:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, stefanha, alex.bennee

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
---
 tests/qtest/vhost-user-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c
index e4f95b2858..8ab10732f8 100644
--- a/tests/qtest/vhost-user-test.c
+++ b/tests/qtest/vhost-user-test.c
@@ -281,7 +281,7 @@ static void read_guest_mem_server(QTestState *qts, TestServer *s)
     /* iterate all regions */
     for (i = 0; i < s->fds_num; i++) {
 
-        /* We'll check only the region statring at 0x0*/
+        /* We'll check only the region starting at 0x0*/
         if (s->memory.regions[i].guest_phys_addr != 0x0) {
             continue;
         }
-- 
2.38.5



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

* [PATCH 0/4] Add SCMI vhost-user VIRTIO device
@ 2023-05-30 19:59 Milan Zamazal
  2023-05-23  8:02 ` [PATCH 1/4] hw/virtio: Add boilerplate for vhost-user-scmi device Milan Zamazal
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Milan Zamazal @ 2023-05-30 19:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, stefanha, alex.bennee

This patch series adds a vhost-user VIRTIO device for SCMI.
It's similar to other similar vhost-user VIRTIO devices.

I'm aware of the work in progress by Alex Bennée to simplify similar devices
and avoid excessive code duplication.  I think the SCMI device support
doesn't bring anything special and it can be rebased on the given work
if/once it is merged.

Milan Zamazal (4):
  hw/virtio: Add boilerplate for vhost-user-scmi device
  hw/virtio: Add vhost-user-scmi-pci boilerplate
  tests/qtest: Fix a comment typo in vhost-user-test.c
  tests/qtest: enable tests for virtio-scmi

 MAINTAINERS                         |   7 +
 hw/virtio/Kconfig                   |   5 +
 hw/virtio/meson.build               |   2 +
 hw/virtio/vhost-user-scmi-pci.c     |  68 +++++++
 hw/virtio/vhost-user-scmi.c         | 306 ++++++++++++++++++++++++++++
 include/hw/virtio/vhost-user-scmi.h |  30 +++
 tests/qtest/libqos/meson.build      |   1 +
 tests/qtest/libqos/virtio-scmi.c    | 174 ++++++++++++++++
 tests/qtest/libqos/virtio-scmi.h    |  34 ++++
 tests/qtest/vhost-user-test.c       |  46 ++++-
 10 files changed, 672 insertions(+), 1 deletion(-)
 create mode 100644 hw/virtio/vhost-user-scmi-pci.c
 create mode 100644 hw/virtio/vhost-user-scmi.c
 create mode 100644 include/hw/virtio/vhost-user-scmi.h
 create mode 100644 tests/qtest/libqos/virtio-scmi.c
 create mode 100644 tests/qtest/libqos/virtio-scmi.h

-- 
2.38.5



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

* Re: [PATCH 3/4] tests/qtest: Fix a comment typo in vhost-user-test.c
  2023-05-24 13:34 ` [PATCH 3/4] tests/qtest: Fix a comment typo in vhost-user-test.c Milan Zamazal
@ 2023-05-31  5:02   ` Thomas Huth
  2023-05-31 11:06     ` Milan Zamazal
  0 siblings, 1 reply; 11+ messages in thread
From: Thomas Huth @ 2023-05-31  5:02 UTC (permalink / raw)
  To: Milan Zamazal, qemu-devel; +Cc: mst, stefanha, alex.bennee

On 24/05/2023 15.34, Milan Zamazal wrote:
> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
> ---
>   tests/qtest/vhost-user-test.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c
> index e4f95b2858..8ab10732f8 100644
> --- a/tests/qtest/vhost-user-test.c
> +++ b/tests/qtest/vhost-user-test.c
> @@ -281,7 +281,7 @@ static void read_guest_mem_server(QTestState *qts, TestServer *s)
>       /* iterate all regions */
>       for (i = 0; i < s->fds_num; i++) {
>   
> -        /* We'll check only the region statring at 0x0*/
> +        /* We'll check only the region starting at 0x0*/

While you're at it, I'd also add a space between the "0x0" and the "*/".

Anyway:
Reviewed-by: Thomas Huth <thuth@redhat.com>

>           if (s->memory.regions[i].guest_phys_addr != 0x0) {
>               continue;
>           }



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

* Re: [PATCH 4/4] tests/qtest: enable tests for virtio-scmi
  2023-05-23 14:38 ` [PATCH 4/4] tests/qtest: enable tests for virtio-scmi Milan Zamazal
@ 2023-05-31  5:05   ` Thomas Huth
  0 siblings, 0 replies; 11+ messages in thread
From: Thomas Huth @ 2023-05-31  5:05 UTC (permalink / raw)
  To: Milan Zamazal, qemu-devel; +Cc: mst, stefanha, alex.bennee

On 23/05/2023 16.38, Milan Zamazal wrote:
> We don't have a virtio-scmi implementation in QEMU and only support a
> vhost-user backend.  This is very similar to virtio-gpio and we add the same
> set of tests, just passing some vhost-user messages over the control socket.
> 
> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
> ---
>   MAINTAINERS                      |   1 +
>   tests/qtest/libqos/meson.build   |   1 +
>   tests/qtest/libqos/virtio-scmi.c | 174 +++++++++++++++++++++++++++++++
>   tests/qtest/libqos/virtio-scmi.h |  34 ++++++
>   tests/qtest/vhost-user-test.c    |  44 ++++++++
>   5 files changed, 254 insertions(+)
>   create mode 100644 tests/qtest/libqos/virtio-scmi.c
>   create mode 100644 tests/qtest/libqos/virtio-scmi.h


Acked-by: Thomas Huth <thuth@redhat.com>



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

* Re: [PATCH 3/4] tests/qtest: Fix a comment typo in vhost-user-test.c
  2023-05-31  5:02   ` Thomas Huth
@ 2023-05-31 11:06     ` Milan Zamazal
  0 siblings, 0 replies; 11+ messages in thread
From: Milan Zamazal @ 2023-05-31 11:06 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel; +Cc: mst, stefanha, alex.bennee

Thomas Huth <thuth@redhat.com> writes:

> On 24/05/2023 15.34, Milan Zamazal wrote:
>> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
>> ---
>
>>   tests/qtest/vhost-user-test.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>> diff --git a/tests/qtest/vhost-user-test.c
>> b/tests/qtest/vhost-user-test.c
>> index e4f95b2858..8ab10732f8 100644
>> --- a/tests/qtest/vhost-user-test.c
>> +++ b/tests/qtest/vhost-user-test.c
>> @@ -281,7 +281,7 @@ static void read_guest_mem_server(QTestState *qts, TestServer *s)
>>       /* iterate all regions */
>>       for (i = 0; i < s->fds_num; i++) {
>>   -        /* We'll check only the region statring at 0x0*/
>> +        /* We'll check only the region starting at 0x0*/
>
> While you're at it, I'd also add a space between the "0x0" and the "*/".

I'll add it in the next patch iteration, thanks for pointing this out.

> Anyway:
> Reviewed-by: Thomas Huth <thuth@redhat.com>
>
>>           if (s->memory.regions[i].guest_phys_addr != 0x0) {
>>               continue;
>>           }



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

* Re: [PATCH 0/4] Add SCMI vhost-user VIRTIO device
  2023-05-30 19:59 [PATCH 0/4] Add SCMI vhost-user VIRTIO device Milan Zamazal
                   ` (3 preceding siblings ...)
  2023-05-24 13:34 ` [PATCH 3/4] tests/qtest: Fix a comment typo in vhost-user-test.c Milan Zamazal
@ 2023-05-31 11:19 ` Alex Bennée
  2023-05-31 11:57   ` Milan Zamazal
  4 siblings, 1 reply; 11+ messages in thread
From: Alex Bennée @ 2023-05-31 11:19 UTC (permalink / raw)
  To: Milan Zamazal; +Cc: qemu-devel, mst, stefanha, Vincent Guittot


Milan Zamazal <mzamazal@redhat.com> writes:

> This patch series adds a vhost-user VIRTIO device for SCMI.
> It's similar to other similar vhost-user VIRTIO devices.
>
> I'm aware of the work in progress by Alex Bennée to simplify similar devices
> and avoid excessive code duplication.  I think the SCMI device support
> doesn't bring anything special and it can be rebased on the given work
> if/once it is merged.

\o/ - I'll try and get the next iteration done in the next few weeks.
Out of interest have you tested your scmi backend with those patches? Oh
and also which backend are you using?

Vincent did a bunch of work over the last year or so on SCMI although in
his case the backend was a RTOS running in a separate domain using some
shared memory between the SCMI domain and a couple of guests.

> Milan Zamazal (4):
>   hw/virtio: Add boilerplate for vhost-user-scmi device
>   hw/virtio: Add vhost-user-scmi-pci boilerplate
>   tests/qtest: Fix a comment typo in vhost-user-test.c
>   tests/qtest: enable tests for virtio-scmi
>
>  MAINTAINERS                         |   7 +
>  hw/virtio/Kconfig                   |   5 +
>  hw/virtio/meson.build               |   2 +
>  hw/virtio/vhost-user-scmi-pci.c     |  68 +++++++
>  hw/virtio/vhost-user-scmi.c         | 306 ++++++++++++++++++++++++++++
>  include/hw/virtio/vhost-user-scmi.h |  30 +++
>  tests/qtest/libqos/meson.build      |   1 +
>  tests/qtest/libqos/virtio-scmi.c    | 174 ++++++++++++++++
>  tests/qtest/libqos/virtio-scmi.h    |  34 ++++
>  tests/qtest/vhost-user-test.c       |  46 ++++-
>  10 files changed, 672 insertions(+), 1 deletion(-)
>  create mode 100644 hw/virtio/vhost-user-scmi-pci.c
>  create mode 100644 hw/virtio/vhost-user-scmi.c
>  create mode 100644 include/hw/virtio/vhost-user-scmi.h
>  create mode 100644 tests/qtest/libqos/virtio-scmi.c
>  create mode 100644 tests/qtest/libqos/virtio-scmi.h


-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


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

* Re: [PATCH 0/4] Add SCMI vhost-user VIRTIO device
  2023-05-31 11:19 ` [PATCH 0/4] Add SCMI vhost-user VIRTIO device Alex Bennée
@ 2023-05-31 11:57   ` Milan Zamazal
  2023-05-31 12:48     ` Vincent Guittot
  0 siblings, 1 reply; 11+ messages in thread
From: Milan Zamazal @ 2023-05-31 11:57 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-devel, mst, stefanha, Vincent Guittot

Alex Bennée <alex.bennee@linaro.org> writes:

> Milan Zamazal <mzamazal@redhat.com> writes:
>
>> This patch series adds a vhost-user VIRTIO device for SCMI.
>> It's similar to other similar vhost-user VIRTIO devices.
>>
>> I'm aware of the work in progress by Alex Bennée to simplify similar devices
>> and avoid excessive code duplication.  I think the SCMI device support
>> doesn't bring anything special and it can be rebased on the given work
>> if/once it is merged.
>
> \o/ - I'll try and get the next iteration done in the next few weeks.

Great, looking forward.

> Out of interest have you tested your scmi backend with those patches? Oh
> and also which backend are you using?

I have tested the patches with my proof-of-concept SCMI backend
(emulating a fake sensor) based on rust-vmm and a Linux guest OS.  I
plan to change the prototype into something publishable in the next
weeks and to post patches to rust-vmm/vhost-device.

> Vincent did a bunch of work over the last year or so on SCMI although in
> his case the backend was a RTOS running in a separate domain using some
> shared memory between the SCMI domain and a couple of guests.

I have seen recordings of some related presentations.  The work is
primarily based on crosvm, right?  I'd be interested in what kind of
SCMI interface the domain provides and whether it would make sense to be
able to connect it with the QEMU SCMI device via some vhost-user daemon,
an already existing one, if any, and/or the one I work on.

>> Milan Zamazal (4):
>>   hw/virtio: Add boilerplate for vhost-user-scmi device
>>   hw/virtio: Add vhost-user-scmi-pci boilerplate
>>   tests/qtest: Fix a comment typo in vhost-user-test.c
>>   tests/qtest: enable tests for virtio-scmi
>>
>>  MAINTAINERS                         |   7 +
>>  hw/virtio/Kconfig                   |   5 +
>>  hw/virtio/meson.build               |   2 +
>>  hw/virtio/vhost-user-scmi-pci.c     |  68 +++++++
>>  hw/virtio/vhost-user-scmi.c         | 306 ++++++++++++++++++++++++++++
>>  include/hw/virtio/vhost-user-scmi.h |  30 +++
>>  tests/qtest/libqos/meson.build      |   1 +
>>  tests/qtest/libqos/virtio-scmi.c    | 174 ++++++++++++++++
>>  tests/qtest/libqos/virtio-scmi.h    |  34 ++++
>>  tests/qtest/vhost-user-test.c       |  46 ++++-
>>  10 files changed, 672 insertions(+), 1 deletion(-)
>>  create mode 100644 hw/virtio/vhost-user-scmi-pci.c
>>  create mode 100644 hw/virtio/vhost-user-scmi.c
>>  create mode 100644 include/hw/virtio/vhost-user-scmi.h
>>  create mode 100644 tests/qtest/libqos/virtio-scmi.c
>>  create mode 100644 tests/qtest/libqos/virtio-scmi.h



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

* Re: [PATCH 0/4] Add SCMI vhost-user VIRTIO device
  2023-05-31 11:57   ` Milan Zamazal
@ 2023-05-31 12:48     ` Vincent Guittot
  0 siblings, 0 replies; 11+ messages in thread
From: Vincent Guittot @ 2023-05-31 12:48 UTC (permalink / raw)
  To: Milan Zamazal; +Cc: Alex Bennée, qemu-devel, mst, stefanha

On Wed, 31 May 2023 at 13:57, Milan Zamazal <mzamazal@redhat.com> wrote:
>
> Alex Bennée <alex.bennee@linaro.org> writes:
>
> > Milan Zamazal <mzamazal@redhat.com> writes:
> >
> >> This patch series adds a vhost-user VIRTIO device for SCMI.
> >> It's similar to other similar vhost-user VIRTIO devices.
> >>
> >> I'm aware of the work in progress by Alex Bennée to simplify similar devices
> >> and avoid excessive code duplication.  I think the SCMI device support
> >> doesn't bring anything special and it can be rebased on the given work
> >> if/once it is merged.
> >
> > \o/ - I'll try and get the next iteration done in the next few weeks.
>
> Great, looking forward.
>
> > Out of interest have you tested your scmi backend with those patches? Oh
> > and also which backend are you using?
>
> I have tested the patches with my proof-of-concept SCMI backend
> (emulating a fake sensor) based on rust-vmm and a Linux guest OS.  I
> plan to change the prototype into something publishable in the next
> weeks and to post patches to rust-vmm/vhost-device.
>
> > Vincent did a bunch of work over the last year or so on SCMI although in
> > his case the backend was a RTOS running in a separate domain using some
> > shared memory between the SCMI domain and a couple of guests.
>
> I have seen recordings of some related presentations.  The work is
> primarily based on crosvm, right?  I'd be interested in what kind of

I have used qemu for my tests

> SCMI interface the domain provides and whether it would make sense to be
> able to connect it with the QEMU SCMI device via some vhost-user daemon,
> an already existing one, if any, and/or the one I work on.

My PoC is based on the SCP-firmware that is usually running on a
dedicated power coprocessor. We have extended it to run in several
env. The PoC runs the SCP firmware in a VM and uses a vhost user scmi
bridge to connect the guest vm with this virtual power coprocessor.
One reason for using SCP-firmware is that It follows SCMI specs and
its updates so I don't have to re-implement it myself and can leverage
on their devs

For test purpose I also have enabled it as a simple linux vhost user daemon

>
> >> Milan Zamazal (4):
> >>   hw/virtio: Add boilerplate for vhost-user-scmi device
> >>   hw/virtio: Add vhost-user-scmi-pci boilerplate
> >>   tests/qtest: Fix a comment typo in vhost-user-test.c
> >>   tests/qtest: enable tests for virtio-scmi
> >>
> >>  MAINTAINERS                         |   7 +
> >>  hw/virtio/Kconfig                   |   5 +
> >>  hw/virtio/meson.build               |   2 +
> >>  hw/virtio/vhost-user-scmi-pci.c     |  68 +++++++
> >>  hw/virtio/vhost-user-scmi.c         | 306 ++++++++++++++++++++++++++++
> >>  include/hw/virtio/vhost-user-scmi.h |  30 +++
> >>  tests/qtest/libqos/meson.build      |   1 +
> >>  tests/qtest/libqos/virtio-scmi.c    | 174 ++++++++++++++++
> >>  tests/qtest/libqos/virtio-scmi.h    |  34 ++++
> >>  tests/qtest/vhost-user-test.c       |  46 ++++-
> >>  10 files changed, 672 insertions(+), 1 deletion(-)
> >>  create mode 100644 hw/virtio/vhost-user-scmi-pci.c
> >>  create mode 100644 hw/virtio/vhost-user-scmi.c
> >>  create mode 100644 include/hw/virtio/vhost-user-scmi.h
> >>  create mode 100644 tests/qtest/libqos/virtio-scmi.c
> >>  create mode 100644 tests/qtest/libqos/virtio-scmi.h
>


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

end of thread, other threads:[~2023-05-31 13:23 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-30 19:59 [PATCH 0/4] Add SCMI vhost-user VIRTIO device Milan Zamazal
2023-05-23  8:02 ` [PATCH 1/4] hw/virtio: Add boilerplate for vhost-user-scmi device Milan Zamazal
2023-05-23  8:19 ` [PATCH 2/4] hw/virtio: Add vhost-user-scmi-pci boilerplate Milan Zamazal
2023-05-23 14:38 ` [PATCH 4/4] tests/qtest: enable tests for virtio-scmi Milan Zamazal
2023-05-31  5:05   ` Thomas Huth
2023-05-24 13:34 ` [PATCH 3/4] tests/qtest: Fix a comment typo in vhost-user-test.c Milan Zamazal
2023-05-31  5:02   ` Thomas Huth
2023-05-31 11:06     ` Milan Zamazal
2023-05-31 11:19 ` [PATCH 0/4] Add SCMI vhost-user VIRTIO device Alex Bennée
2023-05-31 11:57   ` Milan Zamazal
2023-05-31 12:48     ` Vincent Guittot

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.