* [Qemu-devel] [0/8] Pending pseries patches
@ 2012-10-11 11:47 David Gibson
2012-10-11 11:47 ` [Qemu-devel] [PATCH 1/8] target-ppc: Extend FPU state for newer POWER CPUs David Gibson
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: David Gibson @ 2012-10-11 11:47 UTC (permalink / raw)
To: agraf; +Cc: qemu-ppc, qemu-devel
Hi Alex,
Here's another patch of pending pseries patches. 1/8 is what I hope
is finally a correct version of the patch to extend FPU state for
recent CPUs. The rest is basically preliminary cleanups before adding
support for in-kernel XICS emulation. The actual support for the
in-kernel XICS is waiting for that support to go into the kernel
upstream of course.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 1/8] target-ppc: Extend FPU state for newer POWER CPUs
2012-10-11 11:47 [Qemu-devel] [0/8] Pending pseries patches David Gibson
@ 2012-10-11 11:47 ` David Gibson
2012-10-11 11:47 ` [Qemu-devel] [PATCH 2/8] pseries: Clean up inconsistent variable name in xics.c David Gibson
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: David Gibson @ 2012-10-11 11:47 UTC (permalink / raw)
To: agraf; +Cc: qemu-ppc, qemu-devel, David Gibson
This patch adds some extra FPU state to CPUPPCState. Specifically,
fpscr is extended to a target_ulong bits, since some recent (64 bit)
CPUs now have more status bits than fit inside 32 bits. Also, we add
the 32 VSR registers present on CPUs with VSX (these extend the
standard FP regs, which together with the Altivec/VMX registers form a
64 x 128bit register file for VSX).
We don't actually support the instructions using these extra registers
in TCG yet, but we still need a place to store the state so we can
sync it with KVM and savevm/loadvm it. This patch updates the savevm
code to not fail on the extended state, but also does not actually
save it - that's a project for another patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
v2:
* Used target_ulong instead of uint64_t, since the extended state is used
only on ppc64 targets.
* Fixed the TCG mapping of fpscr to match the new type.
---
target-ppc/cpu.h | 4 +++-
target-ppc/machine.c | 8 ++++++--
target-ppc/translate.c | 29 ++++++++++++++++++-----------
3 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
index eb2f43d..cde6da0 100644
--- a/target-ppc/cpu.h
+++ b/target-ppc/cpu.h
@@ -963,7 +963,7 @@ struct CPUPPCState {
/* floating point registers */
float64 fpr[32];
/* floating point status and control register */
- uint32_t fpscr;
+ target_ulong fpscr;
/* Next instruction pointer */
target_ulong nip;
@@ -1014,6 +1014,8 @@ struct CPUPPCState {
/* Altivec registers */
ppc_avr_t avr[32];
uint32_t vscr;
+ /* VSX registers */
+ uint64_t vsr[32];
/* SPE registers */
uint64_t spe_acc;
uint32_t spe_fscr;
diff --git a/target-ppc/machine.c b/target-ppc/machine.c
index 21ce757..5e7bc00 100644
--- a/target-ppc/machine.c
+++ b/target-ppc/machine.c
@@ -6,6 +6,7 @@ void cpu_save(QEMUFile *f, void *opaque)
{
CPUPPCState *env = (CPUPPCState *)opaque;
unsigned int i, j;
+ uint32_t fpscr;
for (i = 0; i < 32; i++)
qemu_put_betls(f, &env->gpr[i]);
@@ -30,7 +31,8 @@ void cpu_save(QEMUFile *f, void *opaque)
u.d = env->fpr[i];
qemu_put_be64(f, u.l);
}
- qemu_put_be32s(f, &env->fpscr);
+ fpscr = env->fpscr;
+ qemu_put_be32s(f, &fpscr);
qemu_put_sbe32s(f, &env->access_type);
#if defined(TARGET_PPC64)
qemu_put_betls(f, &env->asr);
@@ -90,6 +92,7 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id)
CPUPPCState *env = (CPUPPCState *)opaque;
unsigned int i, j;
target_ulong sdr1;
+ uint32_t fpscr;
for (i = 0; i < 32; i++)
qemu_get_betls(f, &env->gpr[i]);
@@ -114,7 +117,8 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id)
u.l = qemu_get_be64(f);
env->fpr[i] = u.d;
}
- qemu_get_be32s(f, &env->fpscr);
+ qemu_get_be32s(f, &fpscr);
+ env->fpscr = fpscr;
qemu_get_sbe32s(f, &env->access_type);
#if defined(TARGET_PPC64)
qemu_get_betls(f, &env->asr);
diff --git a/target-ppc/translate.c b/target-ppc/translate.c
index 1042268..56725e6 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -68,7 +68,7 @@ static TCGv cpu_cfar;
#endif
static TCGv cpu_xer;
static TCGv cpu_reserve;
-static TCGv_i32 cpu_fpscr;
+static TCGv cpu_fpscr;
static TCGv_i32 cpu_access_type;
#include "gen-icount.h"
@@ -163,8 +163,8 @@ void ppc_translate_init(void)
offsetof(CPUPPCState, reserve_addr),
"reserve_addr");
- cpu_fpscr = tcg_global_mem_new_i32(TCG_AREG0,
- offsetof(CPUPPCState, fpscr), "fpscr");
+ cpu_fpscr = tcg_global_mem_new(TCG_AREG0,
+ offsetof(CPUPPCState, fpscr), "fpscr");
cpu_access_type = tcg_global_mem_new_i32(TCG_AREG0,
offsetof(CPUPPCState, access_type), "access_type");
@@ -2302,6 +2302,7 @@ GEN_FLOAT_B(neg, 0x08, 0x01, 0, PPC_FLOAT);
/* mcrfs */
static void gen_mcrfs(DisasContext *ctx)
{
+ TCGv tmp = tcg_temp_new();
int bfa;
if (unlikely(!ctx->fpu_enabled)) {
@@ -2309,9 +2310,11 @@ static void gen_mcrfs(DisasContext *ctx)
return;
}
bfa = 4 * (7 - crfS(ctx->opcode));
- tcg_gen_shri_i32(cpu_crf[crfD(ctx->opcode)], cpu_fpscr, bfa);
+ tcg_gen_shri_tl(tmp, cpu_fpscr, bfa);
+ tcg_gen_trunc_tl_i32(cpu_crf[crfD(ctx->opcode)], tmp);
+ tcg_temp_free(tmp);
tcg_gen_andi_i32(cpu_crf[crfD(ctx->opcode)], cpu_crf[crfD(ctx->opcode)], 0xf);
- tcg_gen_andi_i32(cpu_fpscr, cpu_fpscr, ~(0xF << bfa));
+ tcg_gen_andi_tl(cpu_fpscr, cpu_fpscr, ~(0xF << bfa));
}
/* mffs */
@@ -2322,7 +2325,7 @@ static void gen_mffs(DisasContext *ctx)
return;
}
gen_reset_fpstatus();
- tcg_gen_extu_i32_i64(cpu_fpr[rD(ctx->opcode)], cpu_fpscr);
+ tcg_gen_extu_tl_i64(cpu_fpr[rD(ctx->opcode)], cpu_fpscr);
gen_compute_fprf(cpu_fpr[rD(ctx->opcode)], 0, Rc(ctx->opcode) != 0);
}
@@ -2346,7 +2349,8 @@ static void gen_mtfsb0(DisasContext *ctx)
tcg_temp_free_i32(t0);
}
if (unlikely(Rc(ctx->opcode) != 0)) {
- tcg_gen_shri_i32(cpu_crf[1], cpu_fpscr, FPSCR_OX);
+ tcg_gen_trunc_tl_i32(cpu_crf[1], cpu_fpscr);
+ tcg_gen_shri_i32(cpu_crf[1], cpu_crf[1], FPSCR_OX);
}
}
@@ -2371,7 +2375,8 @@ static void gen_mtfsb1(DisasContext *ctx)
tcg_temp_free_i32(t0);
}
if (unlikely(Rc(ctx->opcode) != 0)) {
- tcg_gen_shri_i32(cpu_crf[1], cpu_fpscr, FPSCR_OX);
+ tcg_gen_trunc_tl_i32(cpu_crf[1], cpu_fpscr);
+ tcg_gen_shri_i32(cpu_crf[1], cpu_crf[1], FPSCR_OX);
}
/* We can raise a differed exception */
gen_helper_float_check_status(cpu_env);
@@ -2397,7 +2402,8 @@ static void gen_mtfsf(DisasContext *ctx)
gen_helper_store_fpscr(cpu_env, cpu_fpr[rB(ctx->opcode)], t0);
tcg_temp_free_i32(t0);
if (unlikely(Rc(ctx->opcode) != 0)) {
- tcg_gen_shri_i32(cpu_crf[1], cpu_fpscr, FPSCR_OX);
+ tcg_gen_trunc_tl_i32(cpu_crf[1], cpu_fpscr);
+ tcg_gen_shri_i32(cpu_crf[1], cpu_crf[1], FPSCR_OX);
}
/* We can raise a differed exception */
gen_helper_float_check_status(cpu_env);
@@ -2425,7 +2431,8 @@ static void gen_mtfsfi(DisasContext *ctx)
tcg_temp_free_i64(t0);
tcg_temp_free_i32(t1);
if (unlikely(Rc(ctx->opcode) != 0)) {
- tcg_gen_shri_i32(cpu_crf[1], cpu_fpscr, FPSCR_OX);
+ tcg_gen_trunc_tl_i32(cpu_crf[1], cpu_fpscr);
+ tcg_gen_shri_i32(cpu_crf[1], cpu_crf[1], FPSCR_OX);
}
/* We can raise a differed exception */
gen_helper_float_check_status(cpu_env);
@@ -9463,7 +9470,7 @@ void cpu_dump_state (CPUPPCState *env, FILE *f, fprintf_function cpu_fprintf,
if ((i & (RFPL - 1)) == (RFPL - 1))
cpu_fprintf(f, "\n");
}
- cpu_fprintf(f, "FPSCR %08x\n", env->fpscr);
+ cpu_fprintf(f, "FPSCR " TARGET_FMT_lx "\n", env->fpscr);
#if !defined(CONFIG_USER_ONLY)
cpu_fprintf(f, " SRR0 " TARGET_FMT_lx " SRR1 " TARGET_FMT_lx
" PVR " TARGET_FMT_lx " VRSAVE " TARGET_FMT_lx "\n",
--
1.7.10.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 2/8] pseries: Clean up inconsistent variable name in xics.c
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 ` David Gibson
2012-10-11 11:47 ` [Qemu-devel] [PATCH 3/8] pseries: Use #define for XICS base irq number David Gibson
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: David Gibson @ 2012-10-11 11:47 UTC (permalink / raw)
To: agraf; +Cc: qemu-ppc, qemu-devel, David Gibson
Throughout xics.c 'nr' is used to refer to a global interrupt number, and
'server' is used to refer to an interrupt server number (i.e. CPU number).
Except in icp_set_mfrr(), where 'nr' is used as a server number. Fix this
confusing inconsistency.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
hw/xics.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/xics.c b/hw/xics.c
index ce88aa7..7a899dd 100644
--- a/hw/xics.c
+++ b/hw/xics.c
@@ -108,13 +108,13 @@ static void icp_set_cppr(struct icp_state *icp, int server, uint8_t cppr)
}
}
-static void icp_set_mfrr(struct icp_state *icp, int nr, uint8_t mfrr)
+static void icp_set_mfrr(struct icp_state *icp, int server, uint8_t mfrr)
{
- struct icp_server_state *ss = icp->ss + nr;
+ struct icp_server_state *ss = icp->ss + server;
ss->mfrr = mfrr;
if (mfrr < CPPR(ss)) {
- icp_check_ipi(icp, nr);
+ icp_check_ipi(icp, server);
}
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 3/8] pseries: Use #define for XICS base irq number
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 ` David Gibson
2012-10-11 11:47 ` [Qemu-devel] [PATCH 4/8] pseries: Cleanup duplications of ics_valid_irq() code David Gibson
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: David Gibson @ 2012-10-11 11:47 UTC (permalink / raw)
To: agraf; +Cc: Michael Ellerman, qemu-ppc, qemu-devel, David Gibson
From: Ben Herrenschmidt <benh@kernel.crashing.org>
Currently the lowest "real" irq number for the XICS irq controller (as
opposed to numbers reserved for IPIs and other special purposes) is
hard coded as 16 in two places - in xics_system_init() and in spapr.c.
As well as being generally bad practice, we're going to need to change this
number soon to fit in with the in-kernel XICS implementation. This patch
adds a #define for this number to avoid future breakage.
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 | 2 +-
hw/xics.c | 2 +-
hw/xics.h | 1 +
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/spapr.c b/hw/spapr.c
index 64c35a8..789c941 100644
--- a/hw/spapr.c
+++ b/hw/spapr.c
@@ -798,7 +798,7 @@ static void ppc_spapr_init(ram_addr_t ram_size,
/* Set up Interrupt Controller */
spapr->icp = xics_system_init(XICS_IRQS);
- spapr->next_irq = 16;
+ 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 7a899dd..db01fe3 100644
--- a/hw/xics.c
+++ b/hw/xics.c
@@ -548,7 +548,7 @@ struct icp_state *xics_system_init(int nr_irqs)
ics = g_malloc0(sizeof(*ics));
ics->nr_irqs = nr_irqs;
- ics->offset = 16;
+ ics->offset = XICS_IRQ_BASE;
ics->irqs = g_malloc0(nr_irqs * sizeof(struct ics_irq_state));
icp->ics = ics;
diff --git a/hw/xics.h b/hw/xics.h
index 6817268..c3bf008 100644
--- a/hw/xics.h
+++ b/hw/xics.h
@@ -28,6 +28,7 @@
#define __XICS_H__
#define XICS_IPI 0x2
+#define XICS_IRQ_BASE 0x10
struct icp_state;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 4/8] pseries: Cleanup duplications of ics_valid_irq() code
2012-10-11 11:47 [Qemu-devel] [0/8] Pending pseries patches David Gibson
` (2 preceding siblings ...)
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 ` David Gibson
2012-10-11 11:47 ` [Qemu-devel] [PATCH 5/8] pseries: Move XICS initialization before cpu initialization David Gibson
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: David Gibson @ 2012-10-11 11:47 UTC (permalink / raw)
To: agraf; +Cc: qemu-ppc, qemu-devel, David Gibson
A couple of places in xics.c open-coded the same logic as is already
implemented in ics_valid_irq(). This patch fixes the code duplication.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
hw/xics.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/hw/xics.c b/hw/xics.c
index db01fe3..6b08430 100644
--- a/hw/xics.c
+++ b/hw/xics.c
@@ -326,8 +326,7 @@ static void ics_eoi(struct ics_state *ics, int nr)
qemu_irq xics_get_qirq(struct icp_state *icp, int irq)
{
- if ((irq < icp->ics->offset)
- || (irq >= (icp->ics->offset + icp->ics->nr_irqs))) {
+ if (!ics_valid_irq(icp->ics, irq)) {
return NULL;
}
@@ -336,8 +335,7 @@ qemu_irq xics_get_qirq(struct icp_state *icp, int irq)
void xics_set_irq_type(struct icp_state *icp, int irq, bool lsi)
{
- assert((irq >= icp->ics->offset)
- && (irq < (icp->ics->offset + icp->ics->nr_irqs)));
+ assert(ics_valid_irq(icp->ics, irq));
icp->ics->irqs[irq - icp->ics->offset].lsi = lsi;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 5/8] pseries: Move XICS initialization before cpu initialization
2012-10-11 11:47 [Qemu-devel] [0/8] Pending pseries patches David Gibson
` (3 preceding siblings ...)
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
2012-10-11 11:47 ` [Qemu-devel] [PATCH 6/8] pseries: Return the token when we register an RTAS call David Gibson
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: David Gibson @ 2012-10-11 11:47 UTC (permalink / raw)
To: agraf; +Cc: Michael Ellerman, qemu-ppc, qemu-devel, David Gibson
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
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 6/8] pseries: Return the token when we register an RTAS call
2012-10-11 11:47 [Qemu-devel] [0/8] Pending pseries patches David Gibson
` (4 preceding siblings ...)
2012-10-11 11:47 ` [Qemu-devel] [PATCH 5/8] pseries: Move XICS initialization before cpu initialization David Gibson
@ 2012-10-11 11:47 ` 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
7 siblings, 0 replies; 9+ messages in thread
From: David Gibson @ 2012-10-11 11:47 UTC (permalink / raw)
To: agraf; +Cc: Michael Ellerman, qemu-ppc, qemu-devel, David Gibson
From: Michael Ellerman <michael@ellerman.id.au>
The kernel will soon be able to service some RTAS calls. However the
choice of tokens will still be up to userspace. To support this have
spapr_rtas_register() return the token that is allocated for an
RTAS call, that allows the calling code to tell the kernel what the
token value is.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
hw/spapr.h | 2 +-
hw/spapr_rtas.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/spapr.h b/hw/spapr.h
index 54960f3..f6864da 100644
--- a/hw/spapr.h
+++ b/hw/spapr.h
@@ -320,7 +320,7 @@ static inline void rtas_st(target_ulong phys, int n, uint32_t val)
typedef void (*spapr_rtas_fn)(sPAPREnvironment *spapr, uint32_t token,
uint32_t nargs, target_ulong args,
uint32_t nret, target_ulong rets);
-void spapr_rtas_register(const char *name, spapr_rtas_fn fn);
+int spapr_rtas_register(const char *name, spapr_rtas_fn fn);
target_ulong spapr_rtas_call(sPAPREnvironment *spapr,
uint32_t token, uint32_t nargs, target_ulong args,
uint32_t nret, target_ulong rets);
diff --git a/hw/spapr_rtas.c b/hw/spapr_rtas.c
index b96078b..38c105f 100644
--- a/hw/spapr_rtas.c
+++ b/hw/spapr_rtas.c
@@ -239,7 +239,7 @@ target_ulong spapr_rtas_call(sPAPREnvironment *spapr,
return H_PARAMETER;
}
-void spapr_rtas_register(const char *name, spapr_rtas_fn fn)
+int spapr_rtas_register(const char *name, spapr_rtas_fn fn)
{
int i;
@@ -255,7 +255,7 @@ void spapr_rtas_register(const char *name, spapr_rtas_fn fn)
rtas_next->name = name;
rtas_next->fn = fn;
- rtas_next++;
+ return (rtas_next++ - rtas_table) + TOKEN_BASE;
}
int spapr_rtas_device_tree_setup(void *fdt, target_phys_addr_t rtas_addr,
--
1.7.10.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 7/8] pseries: Allow RTAS tokens without a qemu handler
2012-10-11 11:47 [Qemu-devel] [0/8] Pending pseries patches David Gibson
` (5 preceding siblings ...)
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 ` David Gibson
2012-10-11 11:47 ` [Qemu-devel] [PATCH 8/8] pseries: Add tracepoints to the XICS interrupt controller David Gibson
7 siblings, 0 replies; 9+ messages in thread
From: David Gibson @ 2012-10-11 11:47 UTC (permalink / raw)
To: agraf; +Cc: qemu-ppc, qemu-devel, David Gibson
From: Ben Herrenschmidt <benh@kernel.crashing.org>
Kernel-based RTAS calls will not have a qemu handler, but will
still be registered in qemu in order to be assigned a token
number and appear in the device-tree.
Let's test for the name being NULL rather than the handler
when deciding to skip an entry while building the device-tree
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
hw/spapr_rtas.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/spapr_rtas.c b/hw/spapr_rtas.c
index 38c105f..72cad53 100644
--- a/hw/spapr_rtas.c
+++ b/hw/spapr_rtas.c
@@ -298,7 +298,7 @@ int spapr_rtas_device_tree_setup(void *fdt, target_phys_addr_t rtas_addr,
for (i = 0; i < TOKEN_MAX; i++) {
struct rtas_call *call = &rtas_table[i];
- if (!call->fn) {
+ if (!call->name) {
continue;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 8/8] pseries: Add tracepoints to the XICS interrupt controller
2012-10-11 11:47 [Qemu-devel] [0/8] Pending pseries patches David Gibson
` (6 preceding siblings ...)
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 ` David Gibson
7 siblings, 0 replies; 9+ messages in thread
From: David Gibson @ 2012-10-11 11:47 UTC (permalink / raw)
To: agraf; +Cc: qemu-ppc, qemu-devel, David Gibson
This patch adds tracing / debugging calls to the XICS interrupt controller
implementation used on the pseries machine.
Signed-off-by: Ben Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
hw/xics.c | 23 ++++++++++++++++++++---
trace-events | 13 +++++++++++++
2 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/hw/xics.c b/hw/xics.c
index 8860355..403afdb 100644
--- a/hw/xics.c
+++ b/hw/xics.c
@@ -26,6 +26,7 @@
*/
#include "hw.h"
+#include "trace.h"
#include "hw/spapr.h"
#include "hw/xics.h"
@@ -66,6 +67,8 @@ static void icp_check_ipi(struct icp_state *icp, int server)
return;
}
+ trace_xics_icp_check_ipi(server, ss->mfrr);
+
if (XISR(ss)) {
ics_reject(icp->ics, XISR(ss));
}
@@ -120,11 +123,13 @@ static void icp_set_mfrr(struct icp_state *icp, int server, uint8_t mfrr)
static uint32_t icp_accept(struct icp_server_state *ss)
{
- uint32_t xirr;
+ uint32_t xirr = ss->xirr;
qemu_irq_lower(ss->output);
- xirr = ss->xirr;
ss->xirr = ss->pending_priority << 24;
+
+ trace_xics_icp_accept(xirr, ss->xirr);
+
return xirr;
}
@@ -134,6 +139,7 @@ static void icp_eoi(struct icp_state *icp, int server, uint32_t xirr)
/* Send EOI -> ICS */
ss->xirr = (ss->xirr & ~CPPR_MASK) | (xirr & CPPR_MASK);
+ trace_xics_icp_eoi(server, xirr, ss->xirr);
ics_eoi(icp->ics, xirr & XISR_MASK);
if (!XISR(ss)) {
icp_resend(icp, server);
@@ -144,6 +150,8 @@ static void icp_irq(struct icp_state *icp, int server, int nr, uint8_t priority)
{
struct icp_server_state *ss = icp->ss + server;
+ trace_xics_icp_irq(server, nr, priority);
+
if ((priority >= CPPR(ss))
|| (XISR(ss) && (ss->pending_priority <= priority))) {
ics_reject(icp->ics, nr);
@@ -153,6 +161,7 @@ static void icp_irq(struct icp_state *icp, int server, int nr, uint8_t priority)
}
ss->xirr = (ss->xirr & ~XISR_MASK) | (nr & XISR_MASK);
ss->pending_priority = priority;
+ trace_xics_icp_raise(ss->xirr, ss->pending_priority);
qemu_irq_raise(ss->output);
}
}
@@ -217,10 +226,12 @@ static void set_irq_msi(struct ics_state *ics, int srcno, int val)
{
struct ics_irq_state *irq = ics->irqs + srcno;
+ trace_xics_set_irq_msi(srcno, srcno + ics->offset);
+
if (val) {
if (irq->priority == 0xff) {
irq->status |= XICS_STATUS_MASKED_PENDING;
- /* masked pending */ ;
+ trace_xics_masked_pending();
} else {
icp_irq(ics->icp, irq->server, srcno + ics->offset, irq->priority);
}
@@ -231,6 +242,7 @@ static void set_irq_lsi(struct ics_state *ics, int srcno, int val)
{
struct ics_irq_state *irq = ics->irqs + srcno;
+ trace_xics_set_irq_lsi(srcno, srcno + ics->offset);
if (val) {
irq->status |= XICS_STATUS_ASSERTED;
} else {
@@ -279,6 +291,8 @@ static void ics_write_xive(struct ics_state *ics, int nr, int server,
irq->priority = priority;
irq->saved_priority = saved_priority;
+ trace_xics_ics_write_xive(nr, srcno, server, priority);
+
if (irq->lsi) {
write_xive_lsi(ics, srcno);
} else {
@@ -290,6 +304,7 @@ static void ics_reject(struct ics_state *ics, int nr)
{
struct ics_irq_state *irq = ics->irqs + nr - ics->offset;
+ trace_xics_ics_reject(nr, nr - ics->offset);
irq->status |= XICS_STATUS_REJECTED; /* Irrelevant but harmless for LSI */
irq->status &= ~XICS_STATUS_SENT; /* Irrelevant but harmless for MSI */
}
@@ -315,6 +330,8 @@ static void ics_eoi(struct ics_state *ics, int nr)
int srcno = nr - ics->offset;
struct ics_irq_state *irq = ics->irqs + srcno;
+ trace_xics_ics_eoi(nr);
+
if (irq->lsi) {
irq->status &= ~XICS_STATUS_SENT;
}
diff --git a/trace-events b/trace-events
index 42b66f1..6ac9c46 100644
--- a/trace-events
+++ b/trace-events
@@ -1001,3 +1001,16 @@ spapr_pci_rtas_ibm_change_msi(unsigned func, unsigned req) "func %u, requested %
spapr_pci_rtas_ibm_query_interrupt_source_number(unsigned ioa, unsigned intr) "queries for #%u, IRQ%u"
spapr_pci_msi_write(uint64_t addr, uint64_t data, uint32_t dt_irq) "@%"PRIx64"<=%"PRIx64" IRQ %u"
spapr_pci_lsi_set(const char *busname, int pin, uint32_t irq) "%s PIN%d IRQ %u"
+
+# hw/xics.c
+xics_icp_check_ipi(int server, uint8_t mfrr) "CPU %d can take IPI mfrr=%#x"
+xics_icp_accept(uint32_t old_xirr, uint32_t new_xirr) "icp_accept: XIRR %#"PRIx32"->%#"PRIx32
+xics_icp_eoi(int server, uint32_t xirr, uint32_t new_xirr) "icp_eoi: server %d given XIRR %#"PRIx32" new XIRR %#"PRIx32
+xics_icp_irq(int server, int nr, uint8_t priority) "cpu %d trying to deliver irq %#"PRIx32" priority %#x"
+xics_icp_raise(uint32_t xirr, uint8_t pending_priority) "raising IRQ new XIRR=%#x new pending priority=%#x"
+xics_set_irq_msi(int srcno, int nr) "set_irq_msi: srcno %d [irq %#x]"
+xics_masked_pending(void) "set_irq_msi: masked pending"
+xics_set_irq_lsi(int srcno, int nr) "set_irq_lsi: srcno %d [irq %#x]"
+xics_ics_write_xive(int nr, int srcno, int server, uint8_t priority) "ics_write_xive: irq %#x [src %d] server %#x prio %#x"
+xics_ics_reject(int nr, int srcno) "reject irq %#x [src %d]"
+xics_ics_eoi(int nr) "ics_eoi: irq %#x"
\ No newline at end of file
--
1.7.10.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-10-11 11:47 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [Qemu-devel] [PATCH 5/8] pseries: Move XICS initialization before cpu initialization David Gibson
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
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).