From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: qemu-devel@nongnu.org
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
qemu-ppc@nongnu.org, Alexander Graf <agraf@suse.de>
Subject: [Qemu-devel] [PATCH v3 6/9] spapr: Rework spapr_fixup_cpu_dt()
Date: Fri, 23 May 2014 12:26:55 +1000 [thread overview]
Message-ID: <1400812018-23430-7-git-send-email-aik@ozlabs.ru> (raw)
In-Reply-To: <1400812018-23430-1-git-send-email-aik@ozlabs.ru>
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>
---
hw/ppc/spapr.c | 33 ++++++++++++++++++++++-----------
1 file changed, 22 insertions(+), 11 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 400d0c7..7082237 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -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)
{
- int ret = 0, offset;
- CPUState *cpu;
+ int ret = 0, offset, cpus_offset;
+ CPUState *cs;
char cpu_model[32];
int smt = kvmppc_smt_threads();
uint32_t pft_size_prop[] = {0, cpu_to_be32(spapr->htab_shift)};
- CPU_FOREACH(cpu) {
- DeviceClass *dc = DEVICE_GET_CLASS(cpu);
- int index = ppc_get_vcpu_dt_id(POWERPC_CPU(cpu));
+ CPU_FOREACH(cs) {
+ PowerPCCPU *cpu = POWERPC_CPU(cs);
+ DeviceClass *dc = DEVICE_GET_CLASS(cs);
+ int index = ppc_get_vcpu_dt_id(cpu);
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(cs->numa_node),
cpu_to_be32(index)};
if ((index % smt) != 0) {
continue;
}
- snprintf(cpu_model, 32, "/cpus/%s@%x", dc->fw_name,
- index);
+ snprintf(cpu_model, 32, "%s@%x", dc->fw_name, 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) {
- return offset;
+ offset = fdt_add_subnode(fdt, cpus_offset, cpu_model);
+ if (offset < 0) {
+ return offset;
+ }
}
if (nb_numa_nodes > 1) {
@@ -281,7 +292,7 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPREnvironment *spapr)
return ret;
}
- ret = spapr_fixup_cpu_smt_dt(fdt, offset, POWERPC_CPU(cpu),
+ ret = spapr_fixup_cpu_smt_dt(fdt, offset, cpu,
smp_threads);
if (ret < 0) {
return ret;
--
1.9.rc0
next prev parent reply other threads:[~2014-05-23 2:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-23 2:26 [Qemu-devel] [PATCH v3 0/9] spapr: Enable ibm, client-architecture-support Alexey Kardashevskiy
2014-05-23 2:26 ` [Qemu-devel] [PATCH v3 1/9] target-ppc: Add "compat" CPU option Alexey Kardashevskiy
2014-05-23 2:26 ` [Qemu-devel] [PATCH v3 2/9] spapr: Move SMT-related properties out of skeleton fdt Alexey Kardashevskiy
2014-05-23 2:26 ` [Qemu-devel] [PATCH v3 3/9] target-ppc: Implement "compat" CPU option Alexey Kardashevskiy
2014-05-23 2:26 ` [Qemu-devel] [PATCH v3 4/9] target-ppc: Define Processor Compatibility Masks Alexey Kardashevskiy
2014-05-23 2:26 ` [Qemu-devel] [PATCH v3 5/9] spapr: Add ibm, client-architecture-support call Alexey Kardashevskiy
2014-05-23 2:26 ` Alexey Kardashevskiy [this message]
2014-05-23 2:26 ` [Qemu-devel] [PATCH v3 7/9] spapr: Limit threads per core according to current compatibility mode Alexey Kardashevskiy
2014-05-23 2:26 ` [Qemu-devel] [PATCH v3 8/9] spapr: Implement processor compatibility in ibm, client-architecture-support Alexey Kardashevskiy
2014-05-23 2:26 ` [Qemu-devel] [PATCH v3 9/9] KVM: PPC: Enable compatibility mode Alexey Kardashevskiy
2014-05-23 12:34 ` Alexander Graf
2014-05-23 11:19 ` [Qemu-devel] [PATCH v3 0/9] spapr: Enable ibm, client-architecture-support Alexander Graf
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=1400812018-23430-7-git-send-email-aik@ozlabs.ru \
--to=aik@ozlabs.ru \
--cc=agraf@suse.de \
--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).