mirror of https://github.com/xemu-project/xemu.git
spapr: Rework spapr_fixup_cpu_dt()
In PPC code we usually use the "cs" name for a CPUState* variables and "cpu" for PowerPCCPU. So let's change spapr_fixup_cpu_dt() to use same rules as spapr_create_fdt_skel() does. This adds missing nodes creation if they do not already exist in the current device tree, this is going to be used from the client-architecture-support handler. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
parent
2a6593cb6a
commit
82677ed2f5
|
@ -239,32 +239,43 @@ static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu,
|
||||||
|
|
||||||
static int spapr_fixup_cpu_dt(void *fdt, sPAPREnvironment *spapr)
|
static int spapr_fixup_cpu_dt(void *fdt, sPAPREnvironment *spapr)
|
||||||
{
|
{
|
||||||
int ret = 0, offset;
|
int ret = 0, offset, cpus_offset;
|
||||||
CPUState *cpu;
|
CPUState *cs;
|
||||||
char cpu_model[32];
|
char cpu_model[32];
|
||||||
int smt = kvmppc_smt_threads();
|
int smt = kvmppc_smt_threads();
|
||||||
uint32_t pft_size_prop[] = {0, cpu_to_be32(spapr->htab_shift)};
|
uint32_t pft_size_prop[] = {0, cpu_to_be32(spapr->htab_shift)};
|
||||||
|
|
||||||
CPU_FOREACH(cpu) {
|
CPU_FOREACH(cs) {
|
||||||
DeviceClass *dc = DEVICE_GET_CLASS(cpu);
|
PowerPCCPU *cpu = POWERPC_CPU(cs);
|
||||||
int index = ppc_get_vcpu_dt_id(POWERPC_CPU(cpu));
|
DeviceClass *dc = DEVICE_GET_CLASS(cs);
|
||||||
|
int index = ppc_get_vcpu_dt_id(cpu);
|
||||||
uint32_t associativity[] = {cpu_to_be32(0x5),
|
uint32_t associativity[] = {cpu_to_be32(0x5),
|
||||||
cpu_to_be32(0x0),
|
cpu_to_be32(0x0),
|
||||||
cpu_to_be32(0x0),
|
cpu_to_be32(0x0),
|
||||||
cpu_to_be32(0x0),
|
cpu_to_be32(0x0),
|
||||||
cpu_to_be32(cpu->numa_node),
|
cpu_to_be32(cs->numa_node),
|
||||||
cpu_to_be32(index)};
|
cpu_to_be32(index)};
|
||||||
|
|
||||||
if ((index % smt) != 0) {
|
if ((index % smt) != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(cpu_model, 32, "/cpus/%s@%x", dc->fw_name,
|
snprintf(cpu_model, 32, "%s@%x", dc->fw_name, index);
|
||||||
index);
|
|
||||||
|
|
||||||
offset = fdt_path_offset(fdt, cpu_model);
|
cpus_offset = fdt_path_offset(fdt, "/cpus");
|
||||||
|
if (cpus_offset < 0) {
|
||||||
|
cpus_offset = fdt_add_subnode(fdt, fdt_path_offset(fdt, "/"),
|
||||||
|
"cpus");
|
||||||
|
if (cpus_offset < 0) {
|
||||||
|
return cpus_offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
offset = fdt_subnode_offset(fdt, cpus_offset, cpu_model);
|
||||||
if (offset < 0) {
|
if (offset < 0) {
|
||||||
return offset;
|
offset = fdt_add_subnode(fdt, cpus_offset, cpu_model);
|
||||||
|
if (offset < 0) {
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nb_numa_nodes > 1) {
|
if (nb_numa_nodes > 1) {
|
||||||
|
@ -281,7 +292,7 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPREnvironment *spapr)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = spapr_fixup_cpu_smt_dt(fdt, offset, POWERPC_CPU(cpu),
|
ret = spapr_fixup_cpu_smt_dt(fdt, offset, cpu,
|
||||||
smp_threads);
|
smp_threads);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue