qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: QEMU-devel Developers <qemu-devel@nongnu.org>
Cc: Scott Wood <scottwood@freescale.com>, Elie Richa <richa@adacore.com>
Subject: [Qemu-devel] [PATCH 27/28] MPC8544DS: Generate CPU nodes on init
Date: Sat, 23 Jul 2011 12:50:11 +0200	[thread overview]
Message-ID: <1311418212-13356-28-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1311418212-13356-1-git-send-email-agraf@suse.de>

With this patch, we generate CPU nodes in the machine initialization, giving
us the freedom to generate as many nodes as we want and as the machine supports,
but only those.

This is a first step towards a much cleaner device tree generation
infrastructure, where we would not require precompiled dtb blobs anymore.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 hw/ppce500_mpc8544ds.c |   46 +++++++++++++++++++++++++++++++++-------------
 1 files changed, 33 insertions(+), 13 deletions(-)

diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c
index b48e95b..9c82044 100644
--- a/hw/ppce500_mpc8544ds.c
+++ b/hw/ppce500_mpc8544ds.c
@@ -123,23 +123,43 @@ static int mpc8544_load_device_tree(CPUState *env,
                              hypercall, sizeof(hypercall));
     }
 
-    for (i = 0; i < smp_cpus; i++) {
+    /* We need to generate the cpu nodes in reverse order, so Linux can pick
+       the first node as boot node and be happy */
+    for (i = smp_cpus - 1; i >= 0; i--) {
         char cpu_name[128];
-        uint64_t cpu_release_addr[] = {
-            cpu_to_be64(MPC8544_SPIN_BASE + (i * 0x20))
-        };
+        uint64_t cpu_release_addr = cpu_to_be64(MPC8544_SPIN_BASE + (i * 0x20));
+
+        for (env = first_cpu; env != NULL; env = env->next_cpu) {
+            if (env->cpu_index == i) {
+                break;
+            }
+        }
+
+        if (!env) {
+            continue;
+        }
 
-        snprintf(cpu_name, sizeof(cpu_name), "/cpus/PowerPC,8544@%x", i);
+        snprintf(cpu_name, sizeof(cpu_name), "/cpus/PowerPC,8544@%x", env->cpu_index);
+        qemu_devtree_add_subnode(fdt, cpu_name);
         qemu_devtree_setprop_cell(fdt, cpu_name, "clock-frequency", clock_freq);
         qemu_devtree_setprop_cell(fdt, cpu_name, "timebase-frequency", tb_freq);
-        qemu_devtree_setprop(fdt, cpu_name, "cpu-release-addr",
-                             cpu_release_addr, sizeof(cpu_release_addr));
-    }
-
-    for (i = smp_cpus; i < 32; i++) {
-        char cpu_name[128];
-        snprintf(cpu_name, sizeof(cpu_name), "/cpus/PowerPC,8544@%x", i);
-        qemu_devtree_nop_node(fdt, cpu_name);
+        qemu_devtree_setprop_string(fdt, cpu_name, "device_type", "cpu");
+        qemu_devtree_setprop_cell(fdt, cpu_name, "reg", env->cpu_index);
+        qemu_devtree_setprop_cell(fdt, cpu_name, "d-cache-line-size",
+                                  env->dcache_line_size);
+        qemu_devtree_setprop_cell(fdt, cpu_name, "i-cache-line-size",
+                                  env->icache_line_size);
+        qemu_devtree_setprop_cell(fdt, cpu_name, "d-cache-size", 0x8000);
+        qemu_devtree_setprop_cell(fdt, cpu_name, "i-cache-size", 0x8000);
+        qemu_devtree_setprop_cell(fdt, cpu_name, "bus-frequency", 0);
+        if (env->cpu_index) {
+            qemu_devtree_setprop_string(fdt, cpu_name, "status", "disabled");
+            qemu_devtree_setprop_string(fdt, cpu_name, "enable-method", "spin-table");
+            qemu_devtree_setprop(fdt, cpu_name, "cpu-release-addr",
+                                 &cpu_release_addr, sizeof(cpu_release_addr));
+        } else {
+            qemu_devtree_setprop_string(fdt, cpu_name, "status", "okay");
+        }
     }
 
     ret = rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr);
-- 
1.6.0.2

  parent reply	other threads:[~2011-07-23 10:50 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-23 10:49 [Qemu-devel] [PATCH 00/28] SMP support for MPC8544DS Alexander Graf
2011-07-23 10:49 ` [Qemu-devel] [PATCH 01/28] PPC: Move openpic to target specific code compilation Alexander Graf
2011-07-23 10:49 ` [Qemu-devel] [PATCH 02/28] PPC: Add CPU local MMIO regions to MPIC Alexander Graf
2011-07-23 10:49 ` [Qemu-devel] [PATCH 03/28] PPC: Extend MPIC MMIO range Alexander Graf
2011-07-23 10:49 ` [Qemu-devel] [PATCH 04/28] PPC: Fix IPI support in MPIC Alexander Graf
2011-07-23 10:49 ` [Qemu-devel] [PATCH 05/28] PPC: Set MPIC IDE for IPI to 0 Alexander Graf
2011-07-25  8:46   ` Elie Richa
2011-07-25  8:50     ` Alexander Graf
2011-07-23 10:49 ` [Qemu-devel] [PATCH 06/28] PPC: MPIC: Remove read functionality for WO registers Alexander Graf
2011-07-23 10:49 ` [Qemu-devel] [PATCH 07/28] PPC: MPIC: Fix CI bit definitions Alexander Graf
2011-07-23 10:49 ` [Qemu-devel] [PATCH 08/28] PPC: Bump MPIC up to 32 supported CPUs Alexander Graf
2011-07-23 10:49 ` [Qemu-devel] [PATCH 09/28] PPC: E500: create multiple envs Alexander Graf
2011-07-23 10:49 ` [Qemu-devel] [PATCH 10/28] PPC: E500: Generate IRQ lines for many CPUs Alexander Graf
2011-07-23 10:49 ` [Qemu-devel] [PATCH 11/28] device tree: add nop_node Alexander Graf
2011-07-23 10:49 ` [Qemu-devel] [PATCH 12/28] PPC: bamboo: Move host fdt copy to target Alexander Graf
2011-07-23 10:49 ` [Qemu-devel] [PATCH 13/28] PPC: KVM: Add generic function to read host clockfreq Alexander Graf
2011-07-23 10:49 ` [Qemu-devel] [PATCH 14/28] PPC: E500: Use generic kvm function for freq Alexander Graf
2011-07-23 10:49 ` [Qemu-devel] [PATCH 15/28] PPC: E500: Remove mpc8544_copy_soc_cell Alexander Graf
2011-07-23 10:50 ` [Qemu-devel] [PATCH 16/28] PPC: bamboo: Use kvm api for freq and clock frequencies Alexander Graf
2011-07-23 10:50 ` [Qemu-devel] [PATCH 17/28] PPC: KVM: Remove kvmppc_read_host_property Alexander Graf
2011-07-23 10:50 ` [Qemu-devel] [PATCH 18/28] PPC: KVM: Add stubs for kvm helper functions Alexander Graf
2011-07-23 10:50 ` [Qemu-devel] [PATCH 19/28] PPC: E500: Update freqs for all CPUs Alexander Graf
2011-07-23 10:50 ` [Qemu-devel] [PATCH 20/28] PPC: E500: Remove unneeded CPU nodes Alexander Graf
2011-07-23 10:50 ` [Qemu-devel] [PATCH 21/28] PPC: E500: Add PV spinning code Alexander Graf
2011-07-25 20:40   ` Scott Wood
2011-07-27 13:34     ` Alexander Graf
2011-07-27 16:18       ` Scott Wood
2011-07-23 10:50 ` [Qemu-devel] [PATCH 22/28] PPC: E500: Update cpu-release-addr property in cpu nodes Alexander Graf
2011-07-23 10:50 ` [Qemu-devel] [PATCH 23/28] device tree: add add_subnode command Alexander Graf
2011-07-23 10:50 ` [Qemu-devel] [PATCH 24/28] device tree: dont fail operations Alexander Graf
2011-07-23 10:50 ` [Qemu-devel] [PATCH 25/28] device tree: give dt more size Alexander Graf
2011-07-23 10:50 ` [Qemu-devel] [PATCH 26/28] MPC8544DS: Remove CPU nodes Alexander Graf
2011-07-23 10:50 ` Alexander Graf [this message]
2011-07-23 10:50 ` [Qemu-devel] [PATCH 28/28] PPC: E500: Bump CPU count to 15 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=1311418212-13356-28-git-send-email-agraf@suse.de \
    --to=agraf@suse.de \
    --cc=qemu-devel@nongnu.org \
    --cc=richa@adacore.com \
    --cc=scottwood@freescale.com \
    /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).