Blame SOURCES/kvm-s390x-ap-base-Adjunct-Processor-AP-object-model.patch

ae23c9
From 375c8f51c7c5489f81cfd21cb289e44b4965d75d Mon Sep 17 00:00:00 2001
ae23c9
From: Thomas Huth <thuth@redhat.com>
ae23c9
Date: Mon, 15 Oct 2018 10:19:29 +0100
ae23c9
Subject: [PATCH 4/6] s390x/ap: base Adjunct Processor (AP) object model
ae23c9
ae23c9
RH-Author: Thomas Huth <thuth@redhat.com>
ae23c9
Message-id: <1539598771-16223-5-git-send-email-thuth@redhat.com>
ae23c9
Patchwork-id: 82695
ae23c9
O-Subject: [RHEL-8 qemu-kvm PATCH 4/6] s390x/ap: base Adjunct Processor (AP) object model
ae23c9
Bugzilla: 1508142
ae23c9
RH-Acked-by: David Hildenbrand <david@redhat.com>
ae23c9
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
ae23c9
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
ae23c9
ae23c9
From: Tony Krowiak <akrowiak@linux.ibm.com>
ae23c9
ae23c9
Introduces the base object model for virtualizing AP devices.
ae23c9
ae23c9
Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com>
ae23c9
Tested-by: Pierre Morel <pmorel@linux.ibm.com>
ae23c9
Acked-by: David Hildenbrand <david@redhat.com>
ae23c9
Reviewed-by: Thomas Huth <thuth@redhat.com>
ae23c9
Reviewed-by: Halil Pasic <pasic@linux.ibm.com>
ae23c9
Tested-by: Christian Borntraeger <borntraeger@de.ibm.com>
ae23c9
Message-Id: <20181010170309.12045-5-akrowiak@linux.ibm.com>
ae23c9
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
ae23c9
(cherry picked from commit a51b31535a8ec13997de29b357f7cc1dcd8a7f9c)
ae23c9
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ae23c9
---
ae23c9
 MAINTAINERS                  | 12 +++++++
ae23c9
 hw/s390x/Makefile.objs       |  2 ++
ae23c9
 hw/s390x/ap-bridge.c         | 78 ++++++++++++++++++++++++++++++++++++++++++++
ae23c9
 hw/s390x/ap-device.c         | 38 +++++++++++++++++++++
ae23c9
 hw/s390x/s390-virtio-ccw.c   |  4 +++
ae23c9
 include/hw/s390x/ap-bridge.h | 19 +++++++++++
ae23c9
 include/hw/s390x/ap-device.h | 22 +++++++++++++
ae23c9
 7 files changed, 175 insertions(+)
ae23c9
 create mode 100644 hw/s390x/ap-bridge.c
ae23c9
 create mode 100644 hw/s390x/ap-device.c
ae23c9
 create mode 100644 include/hw/s390x/ap-bridge.h
ae23c9
 create mode 100644 include/hw/s390x/ap-device.h
ae23c9
ae23c9
diff --git a/MAINTAINERS b/MAINTAINERS
ae23c9
index 1e32116..31cf6ff 100644
ae23c9
--- a/MAINTAINERS
ae23c9
+++ b/MAINTAINERS
ae23c9
@@ -1152,6 +1152,18 @@ F: include/hw/s390x/s390-ccw.h
ae23c9
 T: git git://github.com/cohuck/qemu.git s390-next
ae23c9
 L: qemu-s390x@nongnu.org
ae23c9
 
ae23c9
+vfio-ap
ae23c9
+M: Christian Borntraeger <borntraeger@de.ibm.com>
ae23c9
+M: Tony Krowiak <akrowiak@linux.ibm.com>
ae23c9
+M: Halil Pasic <pasic@linux.ibm.com>
ae23c9
+M: Pierre Morel <pmorel@linux.ibm.com>
ae23c9
+S: Supported
ae23c9
+F: hw/s390x/ap-device.c
ae23c9
+F: hw/s390x/ap-bridge.c
ae23c9
+F: include/hw/s390x/ap-device.h
ae23c9
+F: include/hw/s390x/ap-bridge.h
ae23c9
+L: qemu-s390x@nongnu.org
ae23c9
+
ae23c9
 vhost
ae23c9
 M: Michael S. Tsirkin <mst@redhat.com>
ae23c9
 S: Supported
ae23c9
diff --git a/hw/s390x/Makefile.objs b/hw/s390x/Makefile.objs
ae23c9
index dc704b5..655d1ac 100644
ae23c9
--- a/hw/s390x/Makefile.objs
ae23c9
+++ b/hw/s390x/Makefile.objs
ae23c9
@@ -17,3 +17,5 @@ obj-y += s390-stattrib.o
ae23c9
 obj-$(CONFIG_KVM) += s390-skeys-kvm.o
ae23c9
 obj-$(CONFIG_KVM) += s390-stattrib-kvm.o
ae23c9
 obj-y += s390-ccw.o
ae23c9
+obj-y += ap-device.o
ae23c9
+obj-y += ap-bridge.o
ae23c9
diff --git a/hw/s390x/ap-bridge.c b/hw/s390x/ap-bridge.c
ae23c9
new file mode 100644
ae23c9
index 0000000..3795d30
ae23c9
--- /dev/null
ae23c9
+++ b/hw/s390x/ap-bridge.c
ae23c9
@@ -0,0 +1,78 @@
ae23c9
+/*
ae23c9
+ * ap bridge
ae23c9
+ *
ae23c9
+ * Copyright 2018 IBM Corp.
ae23c9
+ *
ae23c9
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
ae23c9
+ * your option) any later version. See the COPYING file in the top-level
ae23c9
+ * directory.
ae23c9
+ */
ae23c9
+#include "qemu/osdep.h"
ae23c9
+#include "qapi/error.h"
ae23c9
+#include "hw/sysbus.h"
ae23c9
+#include "qemu/bitops.h"
ae23c9
+#include "hw/s390x/ap-bridge.h"
ae23c9
+#include "cpu.h"
ae23c9
+
ae23c9
+static char *ap_bus_get_dev_path(DeviceState *dev)
ae23c9
+{
ae23c9
+    /* at most one */
ae23c9
+    return g_strdup_printf("/1");
ae23c9
+}
ae23c9
+
ae23c9
+static void ap_bus_class_init(ObjectClass *oc, void *data)
ae23c9
+{
ae23c9
+    BusClass *k = BUS_CLASS(oc);
ae23c9
+
ae23c9
+    k->get_dev_path = ap_bus_get_dev_path;
ae23c9
+    /* More than one ap device does not make sense */
ae23c9
+    k->max_dev = 1;
ae23c9
+}
ae23c9
+
ae23c9
+static const TypeInfo ap_bus_info = {
ae23c9
+    .name = TYPE_AP_BUS,
ae23c9
+    .parent = TYPE_BUS,
ae23c9
+    .instance_size = 0,
ae23c9
+    .class_init = ap_bus_class_init,
ae23c9
+};
ae23c9
+
ae23c9
+void s390_init_ap(void)
ae23c9
+{
ae23c9
+    DeviceState *dev;
ae23c9
+
ae23c9
+    /* If no AP instructions then no need for AP bridge */
ae23c9
+    if (!s390_has_feat(S390_FEAT_AP)) {
ae23c9
+        return;
ae23c9
+    }
ae23c9
+
ae23c9
+    /* Create bridge device */
ae23c9
+    dev = qdev_create(NULL, TYPE_AP_BRIDGE);
ae23c9
+    object_property_add_child(qdev_get_machine(), TYPE_AP_BRIDGE,
ae23c9
+                              OBJECT(dev), NULL);
ae23c9
+    qdev_init_nofail(dev);
ae23c9
+
ae23c9
+    /* Create bus on bridge device */
ae23c9
+    qbus_create(TYPE_AP_BUS, dev, TYPE_AP_BUS);
ae23c9
+ }
ae23c9
+
ae23c9
+static void ap_bridge_class_init(ObjectClass *oc, void *data)
ae23c9
+{
ae23c9
+    DeviceClass *dc = DEVICE_CLASS(oc);
ae23c9
+
ae23c9
+    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
ae23c9
+}
ae23c9
+
ae23c9
+static const TypeInfo ap_bridge_info = {
ae23c9
+    .name          = TYPE_AP_BRIDGE,
ae23c9
+    .parent        = TYPE_SYS_BUS_DEVICE,
ae23c9
+    .instance_size = 0,
ae23c9
+    .class_init    = ap_bridge_class_init,
ae23c9
+};
ae23c9
+
ae23c9
+static void ap_register(void)
ae23c9
+{
ae23c9
+    type_register_static(&ap_bridge_info);
ae23c9
+    type_register_static(&ap_bus_info);
ae23c9
+}
ae23c9
+
ae23c9
+type_init(ap_register)
ae23c9
diff --git a/hw/s390x/ap-device.c b/hw/s390x/ap-device.c
ae23c9
new file mode 100644
ae23c9
index 0000000..f5ac8db
ae23c9
--- /dev/null
ae23c9
+++ b/hw/s390x/ap-device.c
ae23c9
@@ -0,0 +1,38 @@
ae23c9
+/*
ae23c9
+ * Adjunct Processor (AP) matrix device
ae23c9
+ *
ae23c9
+ * Copyright 2018 IBM Corp.
ae23c9
+ *
ae23c9
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
ae23c9
+ * your option) any later version. See the COPYING file in the top-level
ae23c9
+ * directory.
ae23c9
+ */
ae23c9
+#include "qemu/osdep.h"
ae23c9
+#include "qemu/module.h"
ae23c9
+#include "qapi/error.h"
ae23c9
+#include "hw/qdev.h"
ae23c9
+#include "hw/s390x/ap-device.h"
ae23c9
+
ae23c9
+static void ap_class_init(ObjectClass *klass, void *data)
ae23c9
+{
ae23c9
+    DeviceClass *dc = DEVICE_CLASS(klass);
ae23c9
+
ae23c9
+    dc->desc = "AP device class";
ae23c9
+    dc->hotpluggable = false;
ae23c9
+}
ae23c9
+
ae23c9
+static const TypeInfo ap_device_info = {
ae23c9
+    .name = AP_DEVICE_TYPE,
ae23c9
+    .parent = TYPE_DEVICE,
ae23c9
+    .instance_size = sizeof(APDevice),
ae23c9
+    .class_size = sizeof(DeviceClass),
ae23c9
+    .class_init = ap_class_init,
ae23c9
+    .abstract = true,
ae23c9
+};
ae23c9
+
ae23c9
+static void ap_device_register(void)
ae23c9
+{
ae23c9
+    type_register_static(&ap_device_info);
ae23c9
+}
ae23c9
+
ae23c9
+type_init(ap_device_register)
ae23c9
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
ae23c9
index bf039a1..43a8213 100644
ae23c9
--- a/hw/s390x/s390-virtio-ccw.c
ae23c9
+++ b/hw/s390x/s390-virtio-ccw.c
ae23c9
@@ -32,6 +32,7 @@
ae23c9
 #include "ipl.h"
ae23c9
 #include "hw/s390x/s390-virtio-ccw.h"
ae23c9
 #include "hw/s390x/css-bridge.h"
ae23c9
+#include "hw/s390x/ap-bridge.h"
ae23c9
 #include "migration/register.h"
ae23c9
 #include "cpu_models.h"
ae23c9
 #include "hw/nmi.h"
ae23c9
@@ -305,6 +306,9 @@ static void ccw_init(MachineState *machine)
ae23c9
     /* init the SIGP facility */
ae23c9
     s390_init_sigp();
ae23c9
 
ae23c9
+    /* create AP bridge and bus(es) */
ae23c9
+    s390_init_ap();
ae23c9
+
ae23c9
     /* get a BUS */
ae23c9
     css_bus = virtual_css_bus_init();
ae23c9
     s390_init_ipl_dev(machine->kernel_filename, machine->kernel_cmdline,
ae23c9
diff --git a/include/hw/s390x/ap-bridge.h b/include/hw/s390x/ap-bridge.h
ae23c9
new file mode 100644
ae23c9
index 0000000..470e439
ae23c9
--- /dev/null
ae23c9
+++ b/include/hw/s390x/ap-bridge.h
ae23c9
@@ -0,0 +1,19 @@
ae23c9
+/*
ae23c9
+ * ap bridge
ae23c9
+ *
ae23c9
+ * Copyright 2018 IBM Corp.
ae23c9
+ *
ae23c9
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
ae23c9
+ * your option) any later version. See the COPYING file in the top-level
ae23c9
+ * directory.
ae23c9
+ */
ae23c9
+
ae23c9
+#ifndef HW_S390X_AP_BRIDGE_H
ae23c9
+#define HW_S390X_AP_BRIDGE_H
ae23c9
+
ae23c9
+#define TYPE_AP_BRIDGE "ap-bridge"
ae23c9
+#define TYPE_AP_BUS "ap-bus"
ae23c9
+
ae23c9
+void s390_init_ap(void);
ae23c9
+
ae23c9
+#endif
ae23c9
diff --git a/include/hw/s390x/ap-device.h b/include/hw/s390x/ap-device.h
ae23c9
new file mode 100644
ae23c9
index 0000000..765e908
ae23c9
--- /dev/null
ae23c9
+++ b/include/hw/s390x/ap-device.h
ae23c9
@@ -0,0 +1,22 @@
ae23c9
+/*
ae23c9
+ * Adjunct Processor (AP) matrix device interfaces
ae23c9
+ *
ae23c9
+ * Copyright 2018 IBM Corp.
ae23c9
+ *
ae23c9
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
ae23c9
+ * your option) any later version. See the COPYING file in the top-level
ae23c9
+ * directory.
ae23c9
+ */
ae23c9
+#ifndef HW_S390X_AP_DEVICE_H
ae23c9
+#define HW_S390X_AP_DEVICE_H
ae23c9
+
ae23c9
+#define AP_DEVICE_TYPE       "ap-device"
ae23c9
+
ae23c9
+typedef struct APDevice {
ae23c9
+    DeviceState parent_obj;
ae23c9
+} APDevice;
ae23c9
+
ae23c9
+#define AP_DEVICE(obj) \
ae23c9
+    OBJECT_CHECK(APDevice, (obj), AP_DEVICE_TYPE)
ae23c9
+
ae23c9
+#endif /* HW_S390X_AP_DEVICE_H */
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9