From: David Gibson <david@gibson.dropbear.id.au>
To: agraf@suse.de
Cc: Michael Ellerman <michael@ellerman.id.au>,
qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
David Gibson <david@gibson.dropbear.id.au>
Subject: [Qemu-devel] [PATCH 5/8] pseries: Move XICS initialization before cpu initialization
Date: Thu, 11 Oct 2012 21:47:41 +1000 [thread overview]
Message-ID: <1349956064-26709-6-git-send-email-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <1349956064-26709-1-git-send-email-david@gibson.dropbear.id.au>
From: Ben Herrenschmidt <benh@kernel.crashing.org>
Currently, the pseries machine initializes the cpus, then the XICS
interrupt controller. However, to support the upcoming in-kernel XICS
implementation we will need to initialize the irq controller before the
vcpus. This patch makes the necesssary rearrangement. This means the
xics init code can no longer auto-detect the number of cpus ("interrupt
servers" in XICS terminology) and so we must pass that in explicitly from
the platform code.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Ben Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
hw/spapr.c | 11 +++++++----
hw/xics.c | 52 +++++++++++++++++++++++-----------------------------
hw/xics.h | 3 ++-
3 files changed, 32 insertions(+), 34 deletions(-)
diff --git a/hw/spapr.c b/hw/spapr.c
index 789c941..e8dbd97 100644
--- a/hw/spapr.c
+++ b/hw/spapr.c
@@ -744,6 +744,11 @@ static void ppc_spapr_init(ram_addr_t ram_size,
spapr->htab_shift++;
}
+ /* Set up Interrupt Controller before we create the VCPUs */
+ spapr->icp = xics_system_init(smp_cpus * kvmppc_smt_threads() / smp_threads,
+ XICS_IRQS);
+ spapr->next_irq = XICS_IRQ_BASE;
+
/* init CPUs */
if (cpu_model == NULL) {
cpu_model = kvm_enabled() ? "host" : "POWER7";
@@ -756,6 +761,8 @@ static void ppc_spapr_init(ram_addr_t ram_size,
}
env = &cpu->env;
+ xics_cpu_setup(spapr->icp, env);
+
/* Set time-base frequency to 512 MHz */
cpu_ppc_tb_init(env, TIMEBASE_FREQ);
@@ -796,10 +803,6 @@ static void ppc_spapr_init(ram_addr_t ram_size,
g_free(filename);
- /* Set up Interrupt Controller */
- spapr->icp = xics_system_init(XICS_IRQS);
- spapr->next_irq = XICS_IRQ_BASE;
-
/* Set up EPOW events infrastructure */
spapr_events_init(spapr);
diff --git a/hw/xics.c b/hw/xics.c
index 6b08430..8860355 100644
--- a/hw/xics.c
+++ b/hw/xics.c
@@ -507,42 +507,36 @@ static void xics_reset(void *opaque)
}
}
-struct icp_state *xics_system_init(int nr_irqs)
+void xics_cpu_setup(struct icp_state *icp, CPUPPCState *env)
{
- CPUPPCState *env;
- int max_server_num;
- struct icp_state *icp;
- struct ics_state *ics;
+ struct icp_server_state *ss = &icp->ss[env->cpu_index];
- max_server_num = -1;
- for (env = first_cpu; env != NULL; env = env->next_cpu) {
- if (env->cpu_index > max_server_num) {
- max_server_num = env->cpu_index;
- }
- }
+ assert(env->cpu_index < icp->nr_servers);
- icp = g_malloc0(sizeof(*icp));
- icp->nr_servers = max_server_num + 1;
- icp->ss = g_malloc0(icp->nr_servers*sizeof(struct icp_server_state));
+ switch (PPC_INPUT(env)) {
+ case PPC_FLAGS_INPUT_POWER7:
+ ss->output = env->irq_inputs[POWER7_INPUT_INT];
+ break;
- for (env = first_cpu; env != NULL; env = env->next_cpu) {
- struct icp_server_state *ss = &icp->ss[env->cpu_index];
+ case PPC_FLAGS_INPUT_970:
+ ss->output = env->irq_inputs[PPC970_INPUT_INT];
+ break;
- switch (PPC_INPUT(env)) {
- case PPC_FLAGS_INPUT_POWER7:
- ss->output = env->irq_inputs[POWER7_INPUT_INT];
- break;
+ default:
+ fprintf(stderr, "XICS interrupt controller does not support this CPU "
+ "bus model\n");
+ abort();
+ }
+}
- case PPC_FLAGS_INPUT_970:
- ss->output = env->irq_inputs[PPC970_INPUT_INT];
- break;
+struct icp_state *xics_system_init(int nr_servers, int nr_irqs)
+{
+ struct icp_state *icp;
+ struct ics_state *ics;
- default:
- hw_error("XICS interrupt model does not support this CPU bus "
- "model\n");
- exit(1);
- }
- }
+ icp = g_malloc0(sizeof(*icp));
+ icp->nr_servers = nr_servers;
+ icp->ss = g_malloc0(icp->nr_servers*sizeof(struct icp_server_state));
ics = g_malloc0(sizeof(*ics));
ics->nr_irqs = nr_irqs;
diff --git a/hw/xics.h b/hw/xics.h
index c3bf008..b43678a 100644
--- a/hw/xics.h
+++ b/hw/xics.h
@@ -35,6 +35,7 @@ struct icp_state;
qemu_irq xics_get_qirq(struct icp_state *icp, int irq);
void xics_set_irq_type(struct icp_state *icp, int irq, bool lsi);
-struct icp_state *xics_system_init(int nr_irqs);
+struct icp_state *xics_system_init(int nr_servers, int nr_irqs);
+void xics_cpu_setup(struct icp_state *icp, CPUPPCState *env);
#endif /* __XICS_H__ */
--
1.7.10.4
next prev parent reply other threads:[~2012-10-11 11:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-11 11:47 [Qemu-devel] [0/8] Pending pseries patches David Gibson
2012-10-11 11:47 ` [Qemu-devel] [PATCH 1/8] target-ppc: Extend FPU state for newer POWER CPUs David Gibson
2012-10-11 11:47 ` [Qemu-devel] [PATCH 2/8] pseries: Clean up inconsistent variable name in xics.c David Gibson
2012-10-11 11:47 ` [Qemu-devel] [PATCH 3/8] pseries: Use #define for XICS base irq number David Gibson
2012-10-11 11:47 ` [Qemu-devel] [PATCH 4/8] pseries: Cleanup duplications of ics_valid_irq() code David Gibson
2012-10-11 11:47 ` David Gibson [this message]
2012-10-11 11:47 ` [Qemu-devel] [PATCH 6/8] pseries: Return the token when we register an RTAS call David Gibson
2012-10-11 11:47 ` [Qemu-devel] [PATCH 7/8] pseries: Allow RTAS tokens without a qemu handler David Gibson
2012-10-11 11:47 ` [Qemu-devel] [PATCH 8/8] pseries: Add tracepoints to the XICS interrupt controller 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=1349956064-26709-6-git-send-email-david@gibson.dropbear.id.au \
--to=david@gibson.dropbear.id.au \
--cc=agraf@suse.de \
--cc=michael@ellerman.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).