Signed-off-by: Andreas Färber <afaer...@suse.de> --- hw/ppc/spapr.c | 91 ++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 53 insertions(+), 38 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 218ea23..53b603d 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -128,53 +128,68 @@ int spapr_allocate_irq_block(int num, bool lsi) return first; } -static int spapr_fixup_cpu_dt(void *fdt, sPAPREnvironment *spapr) +typedef struct SPAPRFixupCPUDT { + void *fdt; + sPAPREnvironment *spapr; + int smt; + int ret; +} SPAPRFixupCPUDT; + +static void spapr_fixup_one_cpu_dt(CPUState *cs, void *data) { - int ret = 0, offset; - CPUPPCState *env; - CPUState *cpu; + SPAPRFixupCPUDT *s = data; char cpu_model[32]; - int smt = kvmppc_smt_threads(); - uint32_t pft_size_prop[] = {0, cpu_to_be32(spapr->htab_shift)}; - - assert(spapr->cpu_model); + int offset; + uint32_t associativity[] = { cpu_to_be32(0x5), + cpu_to_be32(0x0), + cpu_to_be32(0x0), + cpu_to_be32(0x0), + cpu_to_be32(cs->numa_node), + cpu_to_be32(cs->cpu_index) }; + uint32_t pft_size_prop[] = { 0, cpu_to_be32(s->spapr->htab_shift) }; - for (env = first_cpu; env != NULL; env = env->next_cpu) { - cpu = CPU(ppc_env_get_cpu(env)); - uint32_t associativity[] = {cpu_to_be32(0x5), - cpu_to_be32(0x0), - cpu_to_be32(0x0), - cpu_to_be32(0x0), - cpu_to_be32(cpu->numa_node), - cpu_to_be32(cpu->cpu_index)}; - - if ((cpu->cpu_index % smt) != 0) { - continue; - } + if (s->ret) { + return; + } - snprintf(cpu_model, 32, "/cpus/%s@%x", spapr->cpu_model, - cpu->cpu_index); + if ((cs->cpu_index % s->smt) != 0) { + return; + } - offset = fdt_path_offset(fdt, cpu_model); - if (offset < 0) { - return offset; - } + snprintf(cpu_model, 32, "/cpus/%s@%x", s->spapr->cpu_model, + cs->cpu_index); - if (nb_numa_nodes > 1) { - ret = fdt_setprop(fdt, offset, "ibm,associativity", associativity, - sizeof(associativity)); - if (ret < 0) { - return ret; - } - } + offset = fdt_path_offset(s->fdt, cpu_model); + if (offset < 0) { + s->ret = offset; + return; + } - ret = fdt_setprop(fdt, offset, "ibm,pft-size", - pft_size_prop, sizeof(pft_size_prop)); - if (ret < 0) { - return ret; + if (nb_numa_nodes > 1) { + s->ret = fdt_setprop(s->fdt, offset, "ibm,associativity", + associativity, sizeof(associativity)); + if (s->ret < 0) { + return; } } - return ret; + + s->ret = fdt_setprop(s->fdt, offset, "ibm,pft-size", + pft_size_prop, sizeof(pft_size_prop)); +} + +static int spapr_fixup_cpu_dt(void *fdt, sPAPREnvironment *spapr) +{ + SPAPRFixupCPUDT s = { + .fdt = fdt, + .spapr = spapr, + .smt = kvmppc_smt_threads(), + .ret = 0, + }; + + assert(spapr->cpu_model); + + qemu_for_each_cpu(spapr_fixup_one_cpu_dt, &s); + return s.ret; } -- 1.8.1.4