From: "Cédric Le Goater" <clg@kaod.org>
To: qemu-ppc@nongnu.org
Cc: David Gibson <david@gibson.dropbear.id.au>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
qemu-devel@nongnu.org, Alexander Graf <agraf@suse.de>,
Cedric Le Goater <clg@kaod.org>
Subject: [Qemu-devel] [PATCH v5 12/17] ppc/pnv: add a XICS native to each PowerNV chip
Date: Sat, 22 Oct 2016 11:46:45 +0200 [thread overview]
Message-ID: <1477129610-31353-13-git-send-email-clg@kaod.org> (raw)
In-Reply-To: <1477129610-31353-1-git-send-email-clg@kaod.org>
It also links the XICS object to each core as it is needed to do the
CPU setup and the ICP MMIO windows are memory mapped for each thread.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
Changes since v4:
- changed the calculation of the number of ICPs to use smp_threads
- added the mapping of the ICP subregions per thread
hw/ppc/pnv.c | 27 +++++++++++++++++++++++++++
hw/ppc/pnv_core.c | 24 ++++++++++++++++++++----
include/hw/ppc/pnv.h | 2 ++
3 files changed, 49 insertions(+), 4 deletions(-)
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index c6dc7ca895b6..16d7baf0da71 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -33,6 +33,7 @@
#include "qemu/cutils.h"
#include "qapi/visitor.h"
+#include "hw/ppc/xics.h"
#include "hw/ppc/pnv_xscom.h"
#include "hw/isa/isa.h"
@@ -231,6 +232,9 @@ static void powernv_populate_chip(PnvChip *chip, void *fdt)
PnvCore *pnv_core = PNV_CORE(chip->cores + i * typesize);
powernv_create_core_node(chip, pnv_core, fdt);
+
+ /* Interrupt presentation controllers (ICP). One per thread. */
+ xics_native_populate_icp(chip, fdt, 0, pnv_core->pir, smp_threads);
}
if (chip->ram_size) {
@@ -637,6 +641,9 @@ static void pnv_chip_init(Object *obj)
object_initialize(&chip->lpc, sizeof(chip->lpc), TYPE_PNV_LPC);
object_property_add_child(obj, "lpc", OBJECT(&chip->lpc), NULL);
+
+ object_initialize(&chip->xics, sizeof(chip->xics), TYPE_XICS_NATIVE);
+ object_property_add_child(obj, "xics", OBJECT(&chip->xics), NULL);
}
static void pnv_chip_realize(DeviceState *dev, Error **errp)
@@ -668,12 +675,23 @@ static void pnv_chip_realize(DeviceState *dev, Error **errp)
return;
}
+ /*
+ * Interrupt Controller. To be created before the cores because
+ * each thread will fetch its ICP in the XICS
+ */
+ object_property_set_int(OBJECT(&chip->xics), chip->nr_cores * smp_threads,
+ "nr_servers", &error_fatal);
+ object_property_set_bool(OBJECT(&chip->xics), true, "realized",
+ &error_fatal);
+ sysbus_mmio_map(SYS_BUS_DEVICE(&chip->xics), 0, PNV_XICS_BASE);
+
chip->cores = g_malloc0(typesize * chip->nr_cores);
for (i = 0, core_hwid = 0; (core_hwid < sizeof(chip->cores_mask) * 8)
&& (i < chip->nr_cores); core_hwid++) {
char core_name[32];
void *pnv_core = chip->cores + i * typesize;
+ int j;
if (!(chip->cores_mask & (1ull << core_hwid))) {
continue;
@@ -690,6 +708,8 @@ static void pnv_chip_realize(DeviceState *dev, Error **errp)
object_property_set_int(OBJECT(pnv_core),
pcc->core_pir(chip, core_hwid),
"pir", &error_fatal);
+ object_property_add_const_link(OBJECT(pnv_core), "xics",
+ OBJECT(&chip->xics), &error_fatal);
object_property_set_bool(OBJECT(pnv_core), true, "realized",
&error_fatal);
object_unref(OBJECT(pnv_core));
@@ -697,6 +717,13 @@ static void pnv_chip_realize(DeviceState *dev, Error **errp)
/* Each core has an XSCOM MMIO region */
pnv_xscom_add_subregion(chip, PNV_XSCOM_EX_CORE_BASE(core_hwid),
&PNV_CORE(pnv_core)->xscom_regs);
+
+ /* Each thread as region for its ICP */
+ for (j = 0; j < smp_threads; j++) {
+ memory_region_add_subregion(&chip->xics.icp_mmio,
+ pcc->core_pir(chip, core_hwid) << 12,
+ &chip->xics.icp_mmios[i]);
+ }
i++;
}
g_free(typename);
diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c
index 2acda9637db5..e15c76163759 100644
--- a/hw/ppc/pnv_core.c
+++ b/hw/ppc/pnv_core.c
@@ -24,6 +24,7 @@
#include "hw/ppc/ppc.h"
#include "hw/ppc/pnv.h"
#include "hw/ppc/pnv_core.h"
+#include "hw/ppc/xics.h"
static void powernv_cpu_reset(void *opaque)
{
@@ -42,7 +43,7 @@ static void powernv_cpu_reset(void *opaque)
env->msr |= MSR_HVB; /* Hypervisor mode */
}
-static void powernv_cpu_init(PowerPCCPU *cpu, Error **errp)
+static void powernv_cpu_init(PowerPCCPU *cpu, XICSState *xics, Error **errp)
{
CPUPPCState *env = &cpu->env;
int core_pir;
@@ -62,6 +63,11 @@ static void powernv_cpu_init(PowerPCCPU *cpu, Error **errp)
cpu_ppc_tb_init(env, PNV_TIMEBASE_FREQ);
qemu_register_reset(powernv_cpu_reset, cpu);
+
+ /*
+ * xics_cpu_setup() assigns the CPU to the ICP in XICS
+ */
+ xics_cpu_setup(xics, cpu);
}
/*
@@ -109,7 +115,7 @@ static const MemoryRegionOps pnv_core_xscom_ops = {
.endianness = DEVICE_BIG_ENDIAN,
};
-static void pnv_core_realize_child(Object *child, Error **errp)
+static void pnv_core_realize_child(Object *child, XICSState *xics, Error **errp)
{
Error *local_err = NULL;
CPUState *cs = CPU(child);
@@ -121,7 +127,7 @@ static void pnv_core_realize_child(Object *child, Error **errp)
return;
}
- powernv_cpu_init(cpu, &local_err);
+ powernv_cpu_init(cpu, xics, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
@@ -139,6 +145,7 @@ static void pnv_core_realize(DeviceState *dev, Error **errp)
void *obj;
int i, j;
char name[32];
+ XICSState *xics;
pc->threads = g_malloc0(size * cc->nr_threads);
for (i = 0; i < cc->nr_threads; i++) {
@@ -156,10 +163,19 @@ static void pnv_core_realize(DeviceState *dev, Error **errp)
object_unref(obj);
}
+ /* get XICS object from chip */
+ obj = object_property_get_link(OBJECT(dev), "xics", &local_err);
+ if (!obj) {
+ error_setg(errp, "%s: required link 'xics' not found: %s",
+ __func__, error_get_pretty(local_err));
+ return;
+ }
+ xics = XICS_COMMON(obj);
+
for (j = 0; j < cc->nr_threads; j++) {
obj = pc->threads + j * size;
- pnv_core_realize_child(obj, &local_err);
+ pnv_core_realize_child(obj, xics, &local_err);
if (local_err) {
goto err;
}
diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h
index c08ed1c72b17..e11618b05f1d 100644
--- a/include/hw/ppc/pnv.h
+++ b/include/hw/ppc/pnv.h
@@ -23,6 +23,7 @@
#include "hw/sysbus.h"
#include "hw/ppc/pnv_xscom.h"
#include "hw/ppc/pnv_lpc.h"
+#include "hw/ppc/xics.h"
#define TYPE_PNV_CHIP "powernv-chip"
#define PNV_CHIP(obj) OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP)
@@ -57,6 +58,7 @@ typedef struct PnvChip {
AddressSpace xscom_as;
PnvLpcController lpc;
+ XICSNative xics;
} PnvChip;
typedef struct PnvChipClass {
--
2.7.4
next prev parent reply other threads:[~2016-10-22 9:49 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-22 9:46 [Qemu-devel] [PATCH v5 00/17] ppc/pnv: booting the kernel and reaching user space Cédric Le Goater
2016-10-22 9:46 ` [Qemu-devel] [PATCH v5 01/17] ppc: add skiboot firmware for the pnv platform Cédric Le Goater
2016-10-22 9:46 ` [Qemu-devel] [PATCH v5 02/17] ppc/pnv: add skeleton PowerNV platform Cédric Le Goater
2016-10-22 9:46 ` [Qemu-devel] [PATCH v5 03/17] ppc/pnv: add a PnvChip object Cédric Le Goater
2016-10-22 9:46 ` [Qemu-devel] [PATCH v5 04/17] ppc/pnv: add a core mask to PnvChip Cédric Le Goater
2016-10-22 9:46 ` [Qemu-devel] [PATCH v5 05/17] ppc/pnv: add a PIR handler " Cédric Le Goater
2016-10-22 9:46 ` [Qemu-devel] [PATCH v5 06/17] ppc/pnv: add a PnvCore object Cédric Le Goater
2016-10-22 9:46 ` [Qemu-devel] [PATCH v5 07/17] ppc/pnv: add XSCOM infrastructure Cédric Le Goater
2016-10-25 1:13 ` David Gibson
2016-10-25 6:24 ` Cédric Le Goater
2016-10-22 9:46 ` [Qemu-devel] [PATCH v5 08/17] ppc/pnv: add XSCOM handlers to PnvCore Cédric Le Goater
2016-10-25 1:14 ` David Gibson
2016-10-22 9:46 ` [Qemu-devel] [PATCH v5 09/17] ppc/pnv: add a LPC controller Cédric Le Goater
2016-10-22 9:46 ` [Qemu-devel] [PATCH v5 10/17] ppc/pnv: add a ISA bus Cédric Le Goater
2016-10-22 9:46 ` [Qemu-devel] [PATCH v5 11/17] ppc/xics: Add "native" XICS subclass Cédric Le Goater
2016-10-25 5:08 ` David Gibson
2016-10-26 7:13 ` Cédric Le Goater
2016-10-27 3:09 ` David Gibson
2016-10-27 17:43 ` Cédric Le Goater
2016-10-28 1:00 ` David Gibson
2016-11-02 10:48 ` Cédric Le Goater
2016-11-08 1:44 ` David Gibson
2016-10-22 9:46 ` Cédric Le Goater [this message]
2016-10-24 15:42 ` [Qemu-devel] [PATCH v5 12/17] ppc/pnv: add a XICS native to each PowerNV chip Cédric Le Goater
2016-10-25 5:11 ` David Gibson
2016-10-22 9:46 ` [Qemu-devel] [PATCH v5 13/17] ppc/xics: add a xics_get_cpu_index_by_pir helper Cédric Le Goater
2016-10-25 5:36 ` David Gibson
2016-10-25 10:58 ` Cédric Le Goater
2016-10-27 3:12 ` David Gibson
2016-10-27 18:05 ` Cédric Le Goater
2016-10-28 1:03 ` David Gibson
2016-10-22 9:46 ` [Qemu-devel] [PATCH v5 14/17] ppc/xics: introduce a helper to insert a new ics Cédric Le Goater
2016-10-25 5:12 ` David Gibson
2016-10-22 9:46 ` [Qemu-devel] [PATCH v5 15/17] ppc/pnv: Add cut down PSI bridge model and hookup external interrupt Cédric Le Goater
2016-10-25 5:30 ` David Gibson
2016-10-25 7:58 ` Cédric Le Goater
2016-10-26 0:05 ` David Gibson
2016-10-25 11:00 ` Cédric Le Goater
2016-10-22 9:46 ` [Qemu-devel] [PATCH v5 16/17] ppc/pnv: Add OCC model stub with interrupt support Cédric Le Goater
2016-10-22 9:46 ` [Qemu-devel] [PATCH v5 17/17] ppc/pnv: Add Naples chip support for LPC interrupts Cédric Le Goater
2016-10-25 5:35 ` David Gibson
2016-10-24 5:33 ` [Qemu-devel] [PATCH v5 00/17] ppc/pnv: booting the kernel and reaching user space David Gibson
2016-10-25 1:38 ` David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1477129610-31353-13-git-send-email-clg@kaod.org \
--to=clg@kaod.org \
--cc=agraf@suse.de \
--cc=benh@kernel.crashing.org \
--cc=david@gibson.dropbear.id.au \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).