diff mbox

[qom-cpu,47/59] spapr: Abstract spapr_fix_cpu_dt() with qemu_for_each_cpu()

Message ID 1370805206-26574-48-git-send-email-afaerber@suse.de
State New
Headers show

Commit Message

Andreas Färber June 9, 2013, 7:13 p.m. UTC
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 hw/ppc/spapr.c | 91 ++++++++++++++++++++++++++++++++++------------------------
 1 file changed, 53 insertions(+), 38 deletions(-)

Comments

David Gibson June 11, 2013, 2:43 a.m. UTC | #1
On Sun, Jun 09, 2013 at 09:13:14PM +0200, Andreas Färber wrote:
> Signed-off-by: Andreas Färber <afaerber@suse.de>

These days, spapr patches should be CCed to Alexey, instead of me.
Though, fwiw,

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Andreas Färber June 11, 2013, 10:12 a.m. UTC | #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 11.06.2013 04:43, schrieb David Gibson:
> On Sun, Jun 09, 2013 at 09:13:14PM +0200, Andreas F¦rber wrote:
>> Signed-off-by: Andreas F¦rber <afaerber@suse.de>
> 
> These days, spapr patches should be CCed to Alexey, instead of me.

Please update MAINTAINERS then, I use scripts/get_maintainer.pl. :)

> Though, fwiw,
> 
> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

Thanks, however there's been a sentiment that qemu_for_each_cpu()
should be reverted, so I'll need to respin. Patches 55-56 are not
affected though and hopefully a straightforward cleanup.

Andreas

- -- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nrnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imend￶rffer; HRB 16746 AG Nrnberg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)

iQIcBAEBAgAGBQJRtvf1AAoJEPou0S0+fgE/LDkQAKdi0S6WdOK9Otc5716tqCqq
p1KSjmCWSsA9qFfKZjY3vm6mhadA+GT7h+3Ec2L0DMUqOGsTihaT8xb7qcmRT9NO
KehexTXtD77n81Ssai86rDnOcHsK07yv5xiWXCgeaSkAKKYcVVljOOZBZB3EA3zM
ga4zHbsugf8HWgzHlf17GQDwKTEnxyZQQ1ObNlLmKFHS9qG9KjpvJ5REXVrROAUt
nDb430/x2GICU6KZ1X01LVnBvlTFsvnUl1/g5GdtXqR5ebhtoanJRaY+Yf2dz1Dc
7TIArTyJp4SOJVzg3q1PoFhkv0fOTm1z6N7d7m7O5unQVPX85d46i3efHC9v7taR
EiMrs6waEG0k3Vn5ce3yvBMx6Y9T0wkitbT3hQ4F8QKaLQroyz4NZWZs+YETYeck
KOrCQq1av/rEw4Dos6lgUPgg5WOfClnphd8o7qetfECuqwFEQOXYcfjgM4RZ/vsv
KO4BFAAA7MW7gR0LuZqeczIY0YeMlY9ydeEpXVedB2JvMKSesGMMtv5cH+05nvcS
6NfP7jIGPZmG+YOt2Bid0gnVF54OzJ9s8QoX80t5IL20Wi6VveY5I9JoXTP1ihKJ
vyjLHg1NoCsMSGWwS1U6PO1tV2oozVSiyjZeqYrlwIoeTusicuW3TXeRm+iPQ2Mv
qj4gmxNBeMzt7SpdKXUJ
=VWxz
-----END PGP SIGNATURE-----
Alexey Kardashevskiy June 12, 2013, 2:28 p.m. UTC | #3
On 06/11/2013 08:12 PM, Andreas Färber wrote:
> Am 11.06.2013 04:43, schrieb David Gibson:
>> On Sun, Jun 09, 2013 at 09:13:14PM +0200, Andreas F¦rber wrote:
>>> Signed-off-by: Andreas F¦rber <afaerber@suse.de>
> 
>> These days, spapr patches should be CCed to Alexey, instead of me.
> 
> Please update MAINTAINERS then, I use scripts/get_maintainer.pl. :)

Posted a patch for that. Not sure what I should have put in the commit
message though :)


>> Though, fwiw,
> 
>> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> 
> Thanks, however there's been a sentiment that qemu_for_each_cpu()
> should be reverted, so I'll need to respin. Patches 55-56 are not
> affected though and hopefully a straightforward cleanup.
> 
> Andreas
> 
>
diff mbox

Patch

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;
 }