diff mbox

[RFC,v3,08/24] ppc: Prepare CPU socket/core abstraction

Message ID 1429858066-12088-9-git-send-email-bharata@linux.vnet.ibm.com
State New
Headers show

Commit Message

Bharata B Rao April 24, 2015, 6:47 a.m. UTC
Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 hw/ppc/Makefile.objs        |  1 +
 hw/ppc/cpu-core.c           | 46 ++++++++++++++++++++++++++++++++++++++++++++
 hw/ppc/cpu-socket.c         | 47 +++++++++++++++++++++++++++++++++++++++++++++
 include/hw/ppc/cpu-core.h   | 32 ++++++++++++++++++++++++++++++
 include/hw/ppc/cpu-socket.h | 32 ++++++++++++++++++++++++++++++
 5 files changed, 158 insertions(+)
 create mode 100644 hw/ppc/cpu-core.c
 create mode 100644 hw/ppc/cpu-socket.c
 create mode 100644 include/hw/ppc/cpu-core.h
 create mode 100644 include/hw/ppc/cpu-socket.h

Comments

Thomas Huth May 4, 2015, 3:15 p.m. UTC | #1
On Fri, 24 Apr 2015 12:17:30 +0530
Bharata B Rao <bharata@linux.vnet.ibm.com> wrote:

> Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
> Signed-off-by: Andreas Färber <afaerber@suse.de>

Not sure if QEMU is fully following the kernel Sob-process, but if
that's the case, I think your Sob should be below the one of Andreas in
case you're the last person who touched the patch (and I think that's
the case here since you've sent it out)?

Also a short patch description would be really nice.

 Thomas
David Gibson May 5, 2015, 6:46 a.m. UTC | #2
On Fri, Apr 24, 2015 at 12:17:30PM +0530, Bharata B Rao wrote:

As Thomas says, this really needs a commit message.

I also think building this infrastructure is a bit premature when the
discussion is ongoing about how to do this geerically.

What I'd suggest is just have the minimal set you need, which can be
reworked into the new generic scheme once it solidifies.

So, I'd suggest just implement a specific POWER8 core device, which
instantiates up to 8 POWER8 vcpu threads.  We know we'll need some
kind of handle for that, regardless of where it fits in the eventual
overall scheme of sockets and cores and whatever.

> Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
>  hw/ppc/Makefile.objs        |  1 +
>  hw/ppc/cpu-core.c           | 46 ++++++++++++++++++++++++++++++++++++++++++++
>  hw/ppc/cpu-socket.c         | 47 +++++++++++++++++++++++++++++++++++++++++++++
>  include/hw/ppc/cpu-core.h   | 32 ++++++++++++++++++++++++++++++
>  include/hw/ppc/cpu-socket.h | 32 ++++++++++++++++++++++++++++++
>  5 files changed, 158 insertions(+)
>  create mode 100644 hw/ppc/cpu-core.c
>  create mode 100644 hw/ppc/cpu-socket.c
>  create mode 100644 include/hw/ppc/cpu-core.h
>  create mode 100644 include/hw/ppc/cpu-socket.h
> 
> diff --git a/hw/ppc/Makefile.objs b/hw/ppc/Makefile.objs
> index c8ab06e..a35cac5 100644
> --- a/hw/ppc/Makefile.objs
> +++ b/hw/ppc/Makefile.objs
> @@ -1,5 +1,6 @@
>  # shared objects
>  obj-y += ppc.o ppc_booke.o
> +obj-y += cpu-socket.o cpu-core.o
>  # IBM pSeries (sPAPR)
>  obj-$(CONFIG_PSERIES) += spapr.o spapr_vio.o spapr_events.o
>  obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o
> diff --git a/hw/ppc/cpu-core.c b/hw/ppc/cpu-core.c
> new file mode 100644
> index 0000000..ed0481f
> --- /dev/null
> +++ b/hw/ppc/cpu-core.c
> @@ -0,0 +1,46 @@
> +/*
> + * ppc CPU core abstraction
> + *
> + * Copyright (c) 2015 SUSE Linux GmbH
> + * Copyright (C) 2015 Bharata B Rao <bharata@linux.vnet.ibm.com>
> + */
> +
> +#include "hw/qdev.h"
> +#include "hw/ppc/cpu-core.h"
> +
> +static int ppc_cpu_core_realize_child(Object *child, void *opaque)
> +{
> +    Error **errp = opaque;
> +
> +    object_property_set_bool(child, true, "realized", errp);
> +    if (*errp) {
> +        return 1;
> +    }
> +
> +    return 0;
> +}
> +
> +static void ppc_cpu_core_realize(DeviceState *dev, Error **errp)
> +{
> +    object_child_foreach(OBJECT(dev), ppc_cpu_core_realize_child, errp);
> +}
> +
> +static void ppc_cpu_core_class_init(ObjectClass *oc, void *data)
> +{
> +    DeviceClass *dc = DEVICE_CLASS(oc);
> +
> +    dc->realize = ppc_cpu_core_realize;
> +}
> +
> +static const TypeInfo ppc_cpu_core_type_info = {
> +    .name = TYPE_POWERPC_CPU_CORE,
> +    .parent = TYPE_DEVICE,
> +    .class_init = ppc_cpu_core_class_init,
> +};
> +
> +static void ppc_cpu_core_register_types(void)
> +{
> +    type_register_static(&ppc_cpu_core_type_info);
> +}
> +
> +type_init(ppc_cpu_core_register_types)
> diff --git a/hw/ppc/cpu-socket.c b/hw/ppc/cpu-socket.c
> new file mode 100644
> index 0000000..602a060
> --- /dev/null
> +++ b/hw/ppc/cpu-socket.c
> @@ -0,0 +1,47 @@
> +/*
> + * PPC CPU socket abstraction
> + *
> + * Copyright (c) 2015 SUSE Linux GmbH
> + * Copyright (C) 2015 Bharata B Rao <bharata@linux.vnet.ibm.com>
> + */
> +
> +#include "hw/qdev.h"
> +#include "hw/ppc/cpu-socket.h"
> +#include "sysemu/cpus.h"
> +
> +static int ppc_cpu_socket_realize_child(Object *child, void *opaque)
> +{
> +    Error **errp = opaque;
> +
> +    object_property_set_bool(child, true, "realized", errp);
> +    if (*errp) {
> +        return 1;
> +    } else {
> +        return 0;
> +    }
> +}
> +
> +static void ppc_cpu_socket_realize(DeviceState *dev, Error **errp)
> +{
> +    object_child_foreach(OBJECT(dev), ppc_cpu_socket_realize_child, errp);
> +}
> +
> +static void ppc_cpu_socket_class_init(ObjectClass *oc, void *data)
> +{
> +    DeviceClass *dc = DEVICE_CLASS(oc);
> +
> +    dc->realize = ppc_cpu_socket_realize;
> +}
> +
> +static const TypeInfo ppc_cpu_socket_type_info = {
> +    .name = TYPE_POWERPC_CPU_SOCKET,
> +    .parent = TYPE_CPU_SOCKET,
> +    .class_init = ppc_cpu_socket_class_init,
> +};
> +
> +static void ppc_cpu_socket_register_types(void)
> +{
> +    type_register_static(&ppc_cpu_socket_type_info);
> +}
> +
> +type_init(ppc_cpu_socket_register_types)
> diff --git a/include/hw/ppc/cpu-core.h b/include/hw/ppc/cpu-core.h
> new file mode 100644
> index 0000000..95f1c28
> --- /dev/null
> +++ b/include/hw/ppc/cpu-core.h
> @@ -0,0 +1,32 @@
> +/*
> + * PowerPC CPU core abstraction
> + *
> + * Copyright (c) 2015 SUSE Linux GmbH
> + * Copyright (C) 2015 Bharata B Rao <bharata@linux.vnet.ibm.com>
> + */
> +#ifndef HW_PPC_CPU_CORE_H
> +#define HW_PPC_CPU_CORE_H
> +
> +#include "hw/qdev.h"
> +#include "cpu.h"
> +
> +#ifdef TARGET_PPC64
> +#define TYPE_POWERPC_CPU_CORE "powerpc64-cpu-core"
> +#elif defined(TARGET_PPCEMB)
> +#define TYPE_POWERPC_CPU_CORE "embedded-powerpc-cpu-core"
> +#else
> +#define TYPE_POWERPC_CPU_CORE "powerpc-cpu-core"
> +#endif
> +
> +#define POWERPC_CPU_CORE(obj) \
> +    OBJECT_CHECK(PowerPCCPUCore, (obj), TYPE_POWERPC_CPU_CORE)
> +
> +typedef struct PowerPCCPUCore {
> +    /*< private >*/
> +    DeviceState parent_obj;
> +    /*< public >*/
> +
> +    PowerPCCPU thread[0];
> +} PowerPCCPUCore;
> +
> +#endif
> diff --git a/include/hw/ppc/cpu-socket.h b/include/hw/ppc/cpu-socket.h
> new file mode 100644
> index 0000000..5ae19d0
> --- /dev/null
> +++ b/include/hw/ppc/cpu-socket.h
> @@ -0,0 +1,32 @@
> +/*
> + * PowerPC CPU socket abstraction
> + *
> + * Copyright (c) 2015 SUSE Linux GmbH
> + * Copyright (C) 2015 Bharata B Rao <bharata@linux.vnet.ibm.com>
> + */
> +#ifndef HW_PPC_CPU_SOCKET_H
> +#define HW_PPC_CPU_SOCKET_H
> +
> +#include "hw/cpu/socket.h"
> +#include "cpu-core.h"
> +
> +#ifdef TARGET_PPC64
> +#define TYPE_POWERPC_CPU_SOCKET "powerpc64-cpu-socket"
> +#elif defined(TARGET_PPCEMB)
> +#define TYPE_POWERPC_CPU_SOCKET "embedded-powerpc-cpu-socket"
> +#else
> +#define TYPE_POWERPC_CPU_SOCKET "powerpc-cpu-socket"
> +#endif
> +
> +#define POWERPC_CPU_SOCKET(obj) \
> +    OBJECT_CHECK(PowerPCCPUSocket, (obj), TYPE_POWERPC_CPU_SOCKET)
> +
> +typedef struct PowerPCCPUSocket {
> +    /*< private >*/
> +    DeviceState parent_obj;
> +    /*< public >*/
> +
> +    PowerPCCPUCore core[0];
> +} PowerPCCPUSocket;
> +
> +#endif
Bharata B Rao May 6, 2015, 4:40 a.m. UTC | #3
On Mon, May 04, 2015 at 05:15:04PM +0200, Thomas Huth wrote:
> On Fri, 24 Apr 2015 12:17:30 +0530
> Bharata B Rao <bharata@linux.vnet.ibm.com> wrote:
> 
> > Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
> > Signed-off-by: Andreas Färber <afaerber@suse.de>
> 
> Not sure if QEMU is fully following the kernel Sob-process, but if
> that's the case, I think your Sob should be below the one of Andreas in
> case you're the last person who touched the patch (and I think that's
> the case here since you've sent it out)?

The patch is from me, but I included Andreas' sob and copyrights since
the code was derived from his equivalent x86 implementation.

> 
> Also a short patch description would be really nice.

Guess I will get rid of this whole socket abstraction for now as noted
in an earlier thread.

Regards,
Bharata.


Guess I will get rid of this whole socket abstraction for now as noted
in an earlier thread.

Regards,
Bharata.
Thomas Huth May 6, 2015, 6:52 a.m. UTC | #4
On Wed, 6 May 2015 10:10:15 +0530
Bharata B Rao <bharata@linux.vnet.ibm.com> wrote:

> On Mon, May 04, 2015 at 05:15:04PM +0200, Thomas Huth wrote:
> > On Fri, 24 Apr 2015 12:17:30 +0530
> > Bharata B Rao <bharata@linux.vnet.ibm.com> wrote:
> > 
> > > Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
> > > Signed-off-by: Andreas Färber <afaerber@suse.de>
> > 
> > Not sure if QEMU is fully following the kernel Sob-process, but if
> > that's the case, I think your Sob should be below the one of Andreas in
> > case you're the last person who touched the patch (and I think that's
> > the case here since you've sent it out)?
> 
> The patch is from me, but I included Andreas' sob and copyrights since
> the code was derived from his equivalent x86 implementation.

I am neither a lawyer nor an expert here, but I think in case the patch
itself never really passed through the hands of Andreas, it should not
include an Sob of him. An Sob is like a signature - you can/should not
put an Sob from somebody else into a file, everybody has to do that
personally.

So in case you copied code from another file, simply state that clearly
in the patch description and make sure that the original author is on
"CC:". You can also explicitly put a "Cc: Original Author <e@mail>"
line after your Sob in the patch description to make sure that the
"Cc:" information is retained in the patch description.

 Thomas
diff mbox

Patch

diff --git a/hw/ppc/Makefile.objs b/hw/ppc/Makefile.objs
index c8ab06e..a35cac5 100644
--- a/hw/ppc/Makefile.objs
+++ b/hw/ppc/Makefile.objs
@@ -1,5 +1,6 @@ 
 # shared objects
 obj-y += ppc.o ppc_booke.o
+obj-y += cpu-socket.o cpu-core.o
 # IBM pSeries (sPAPR)
 obj-$(CONFIG_PSERIES) += spapr.o spapr_vio.o spapr_events.o
 obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o
diff --git a/hw/ppc/cpu-core.c b/hw/ppc/cpu-core.c
new file mode 100644
index 0000000..ed0481f
--- /dev/null
+++ b/hw/ppc/cpu-core.c
@@ -0,0 +1,46 @@ 
+/*
+ * ppc CPU core abstraction
+ *
+ * Copyright (c) 2015 SUSE Linux GmbH
+ * Copyright (C) 2015 Bharata B Rao <bharata@linux.vnet.ibm.com>
+ */
+
+#include "hw/qdev.h"
+#include "hw/ppc/cpu-core.h"
+
+static int ppc_cpu_core_realize_child(Object *child, void *opaque)
+{
+    Error **errp = opaque;
+
+    object_property_set_bool(child, true, "realized", errp);
+    if (*errp) {
+        return 1;
+    }
+
+    return 0;
+}
+
+static void ppc_cpu_core_realize(DeviceState *dev, Error **errp)
+{
+    object_child_foreach(OBJECT(dev), ppc_cpu_core_realize_child, errp);
+}
+
+static void ppc_cpu_core_class_init(ObjectClass *oc, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(oc);
+
+    dc->realize = ppc_cpu_core_realize;
+}
+
+static const TypeInfo ppc_cpu_core_type_info = {
+    .name = TYPE_POWERPC_CPU_CORE,
+    .parent = TYPE_DEVICE,
+    .class_init = ppc_cpu_core_class_init,
+};
+
+static void ppc_cpu_core_register_types(void)
+{
+    type_register_static(&ppc_cpu_core_type_info);
+}
+
+type_init(ppc_cpu_core_register_types)
diff --git a/hw/ppc/cpu-socket.c b/hw/ppc/cpu-socket.c
new file mode 100644
index 0000000..602a060
--- /dev/null
+++ b/hw/ppc/cpu-socket.c
@@ -0,0 +1,47 @@ 
+/*
+ * PPC CPU socket abstraction
+ *
+ * Copyright (c) 2015 SUSE Linux GmbH
+ * Copyright (C) 2015 Bharata B Rao <bharata@linux.vnet.ibm.com>
+ */
+
+#include "hw/qdev.h"
+#include "hw/ppc/cpu-socket.h"
+#include "sysemu/cpus.h"
+
+static int ppc_cpu_socket_realize_child(Object *child, void *opaque)
+{
+    Error **errp = opaque;
+
+    object_property_set_bool(child, true, "realized", errp);
+    if (*errp) {
+        return 1;
+    } else {
+        return 0;
+    }
+}
+
+static void ppc_cpu_socket_realize(DeviceState *dev, Error **errp)
+{
+    object_child_foreach(OBJECT(dev), ppc_cpu_socket_realize_child, errp);
+}
+
+static void ppc_cpu_socket_class_init(ObjectClass *oc, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(oc);
+
+    dc->realize = ppc_cpu_socket_realize;
+}
+
+static const TypeInfo ppc_cpu_socket_type_info = {
+    .name = TYPE_POWERPC_CPU_SOCKET,
+    .parent = TYPE_CPU_SOCKET,
+    .class_init = ppc_cpu_socket_class_init,
+};
+
+static void ppc_cpu_socket_register_types(void)
+{
+    type_register_static(&ppc_cpu_socket_type_info);
+}
+
+type_init(ppc_cpu_socket_register_types)
diff --git a/include/hw/ppc/cpu-core.h b/include/hw/ppc/cpu-core.h
new file mode 100644
index 0000000..95f1c28
--- /dev/null
+++ b/include/hw/ppc/cpu-core.h
@@ -0,0 +1,32 @@ 
+/*
+ * PowerPC CPU core abstraction
+ *
+ * Copyright (c) 2015 SUSE Linux GmbH
+ * Copyright (C) 2015 Bharata B Rao <bharata@linux.vnet.ibm.com>
+ */
+#ifndef HW_PPC_CPU_CORE_H
+#define HW_PPC_CPU_CORE_H
+
+#include "hw/qdev.h"
+#include "cpu.h"
+
+#ifdef TARGET_PPC64
+#define TYPE_POWERPC_CPU_CORE "powerpc64-cpu-core"
+#elif defined(TARGET_PPCEMB)
+#define TYPE_POWERPC_CPU_CORE "embedded-powerpc-cpu-core"
+#else
+#define TYPE_POWERPC_CPU_CORE "powerpc-cpu-core"
+#endif
+
+#define POWERPC_CPU_CORE(obj) \
+    OBJECT_CHECK(PowerPCCPUCore, (obj), TYPE_POWERPC_CPU_CORE)
+
+typedef struct PowerPCCPUCore {
+    /*< private >*/
+    DeviceState parent_obj;
+    /*< public >*/
+
+    PowerPCCPU thread[0];
+} PowerPCCPUCore;
+
+#endif
diff --git a/include/hw/ppc/cpu-socket.h b/include/hw/ppc/cpu-socket.h
new file mode 100644
index 0000000..5ae19d0
--- /dev/null
+++ b/include/hw/ppc/cpu-socket.h
@@ -0,0 +1,32 @@ 
+/*
+ * PowerPC CPU socket abstraction
+ *
+ * Copyright (c) 2015 SUSE Linux GmbH
+ * Copyright (C) 2015 Bharata B Rao <bharata@linux.vnet.ibm.com>
+ */
+#ifndef HW_PPC_CPU_SOCKET_H
+#define HW_PPC_CPU_SOCKET_H
+
+#include "hw/cpu/socket.h"
+#include "cpu-core.h"
+
+#ifdef TARGET_PPC64
+#define TYPE_POWERPC_CPU_SOCKET "powerpc64-cpu-socket"
+#elif defined(TARGET_PPCEMB)
+#define TYPE_POWERPC_CPU_SOCKET "embedded-powerpc-cpu-socket"
+#else
+#define TYPE_POWERPC_CPU_SOCKET "powerpc-cpu-socket"
+#endif
+
+#define POWERPC_CPU_SOCKET(obj) \
+    OBJECT_CHECK(PowerPCCPUSocket, (obj), TYPE_POWERPC_CPU_SOCKET)
+
+typedef struct PowerPCCPUSocket {
+    /*< private >*/
+    DeviceState parent_obj;
+    /*< public >*/
+
+    PowerPCCPUCore core[0];
+} PowerPCCPUSocket;
+
+#endif