Skip to contentSkip to conversation

xen/arm: midway: implement SMP

PATCH In review Julien Grall 4 participants 5 messages Nov 18, 2013 – Nov 19, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/arm: midway: implement SMP

---
 xen/arch/arm/platforms/midway.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
xen/arch/arm/platforms/midway.c +22 -0
index 399056b..3b9fcfc 100644
@@ -47,6 +47,27 @@ static uint32_t midway_quirks(void)
     return PLATFORM_QUIRK_DOM0_MAPPING_11;
 }
 
+static int __init midway_cpu_up(int cpu)
+{
+    void __iomem *pens;
+
+    pens = ioremap_nocache(0, PAGE_SIZE);
+    if ( !pens )
+    {
+        dprintk(XENLOG_ERR, "Unable to map midway pens MMIO\n");
+        return -EFAULT;
+    }
+
+    printk("Set cpu pen %u to %"PRIpaddr" (%p)\n",
+           cpu, __pa(init_secondary), init_secondary);
+
+    writel(__pa(init_secondary), pens + 0x40 + cpu * 0x10);
+
+    iounmap(pens);
+
+    return 0;
+}
+
 static const char * const midway_dt_compat[] __initconst =
 {
     "calxeda,ecx-2000",
@@ -57,6 +78,7 @@ PLATFORM_START(midway, "CALXEDA MIDWAY")
     .compatible = midway_dt_compat,
     .reset = midway_reset,
     .quirks = midway_quirks,
+    .cpu_up = midway_cpu_up,
 PLATFORM_END
 
 /*
Signature · 1 line
1.8.3.1
Acked-by on v1 1/1
#1 lore raw
Quoted 1 line · Julien Grall
Quoted 46 lines
 xen/arch/arm/platforms/midway.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
xen/arch/arm/platforms/midway.c +22 -0
index 399056b..3b9fcfc 100644
@@ -47,6 +47,27 @@ static uint32_t midway_quirks(void)
     return PLATFORM_QUIRK_DOM0_MAPPING_11;
 }
 
+static int __init midway_cpu_up(int cpu)
+{
+    void __iomem *pens;
+
+    pens = ioremap_nocache(0, PAGE_SIZE);
+    if ( !pens )
+    {
+        dprintk(XENLOG_ERR, "Unable to map midway pens MMIO\n");
+        return -EFAULT;
+    }
+
+    printk("Set cpu pen %u to %"PRIpaddr" (%p)\n",
+           cpu, __pa(init_secondary), init_secondary);
+
+    writel(__pa(init_secondary), pens + 0x40 + cpu * 0x10);
+
+    iounmap(pens);
+
+    return 0;
+}
+
 static const char * const midway_dt_compat[] __initconst =
 {
     "calxeda,ecx-2000",
@@ -57,6 +78,7 @@ PLATFORM_START(midway, "CALXEDA MIDWAY")
     .compatible = midway_dt_compat,
     .reset = midway_reset,
     .quirks = midway_quirks,
+    .cpu_up = midway_cpu_up,
 PLATFORM_END
 
 /*
Signature · 1 line
1.8.3.1
Acked-by on v1 1/1
#2 lore raw
In reply to Julien Grall
Quoted 1 line · Julien Grall

I'd very much like to see Andre's Ack too.

Is anyone thinking of implementing host PSCI in the near future?

Quoted 44 lines
---
 xen/arch/arm/platforms/midway.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
xen/arch/arm/platforms/midway.c +22 -0
index 399056b..3b9fcfc 100644
@@ -47,6 +47,27 @@ static uint32_t midway_quirks(void)
     return PLATFORM_QUIRK_DOM0_MAPPING_11;
 }
 
+static int __init midway_cpu_up(int cpu)
+{
+    void __iomem *pens;
+
+    pens = ioremap_nocache(0, PAGE_SIZE);
+    if ( !pens )
+    {
+        dprintk(XENLOG_ERR, "Unable to map midway pens MMIO\n");
+        return -EFAULT;
+    }
+
+    printk("Set cpu pen %u to %"PRIpaddr" (%p)\n",
+           cpu, __pa(init_secondary), init_secondary);
+
+    writel(__pa(init_secondary), pens + 0x40 + cpu * 0x10);
+
+    iounmap(pens);
+
+    return 0;
+}
+
 static const char * const midway_dt_compat[] __initconst =
 {
     "calxeda,ecx-2000",
@@ -57,6 +78,7 @@ PLATFORM_START(midway, "CALXEDA MIDWAY")
     .compatible = midway_dt_compat,
     .reset = midway_reset,
     .quirks = midway_quirks,
+    .cpu_up = midway_cpu_up,
 PLATFORM_END
 
 /*
#3 lore raw
In reply to Julien Grall
Quoted 10 lines · Julien Grall
---
  xen/arch/arm/platforms/midway.c | 22 ++++++++++++++++++++++
  1 file changed, 22 insertions(+)
xen/arch/arm/platforms/midway.c +0 -0
index 399056b..3b9fcfc 100644

xen/arch/arm/platforms/midway.c static uint32_t midway_quirks(void) · line 50

Quoted 4 lines
xen/arch/arm/platforms/midway.c +1 -0
@@ -47,6 +47,27 @@ static uint32_t midway_quirks(void)
      return PLATFORM_QUIRK_DOM0_MAPPING_11;
  }
 
+static int __init midway_cpu_up(int cpu)

Wouldn't it make more sense to do this initialization in smp_init() instead of here per CPU? init_secondary() is fixed and thus we will not write different values for each core. I guess it does not really matter, I was just wondering whether this would be a saner approach (and I think your first version was this way, right?)

Thanks,
Andre.

P.S. BTW: Any reason we instantiate cpu_up() for all platforms where they are actually NOPs? I think the platform code only calls a function if it is non-NULL, so we could just skip all of this: cpu_up() {return 0;} definition.

Quoted 32 lines
xen/arch/arm/platforms/midway.c +21 -0
+{
+    void __iomem *pens;
+
+    pens = ioremap_nocache(0, PAGE_SIZE);
+    if ( !pens )
+    {
+        dprintk(XENLOG_ERR, "Unable to map midway pens MMIO\n");
+        return -EFAULT;
+    }
+
+    printk("Set cpu pen %u to %"PRIpaddr" (%p)\n",
+           cpu, __pa(init_secondary), init_secondary);
+
+    writel(__pa(init_secondary), pens + 0x40 + cpu * 0x10);
+
+    iounmap(pens);
+
+    return 0;
+}
+
  static const char * const midway_dt_compat[] __initconst =
  {
      "calxeda,ecx-2000",
@@ -57,6 +78,7 @@ PLATFORM_START(midway, "CALXEDA MIDWAY")
      .compatible = midway_dt_compat,
      .reset = midway_reset,
      .quirks = midway_quirks,
+    .cpu_up = midway_cpu_up,
  PLATFORM_END
 
  /*
#4 lore raw
Quoted 14 lines · Andre Przywara
Quoted 13 lines · Julien Grall
---
  xen/arch/arm/platforms/midway.c | 22 ++++++++++++++++++++++
  1 file changed, 22 insertions(+)
xen/arch/arm/platforms/midway.c +0 -0
index 399056b..3b9fcfc 100644
@@ -47,6 +47,27 @@ static uint32_t midway_quirks(void)
      return PLATFORM_QUIRK_DOM0_MAPPING_11;
  }
 
Quoted 8 lines

xen/arch/arm/platforms/midway.c static uint32_t midway_quirks(void) · line 50

Quoted 1 line
xen/arch/arm/platforms/midway.c +1 -0
+static int __init midway_cpu_up(int cpu)

Wouldn't it make more sense to do this initialization in smp_init() instead of here per CPU? init_secondary() is fixed and thus we will not write different values for each core.
I guess it does not really matter, I was just wondering whether this would be a saner approach (and I think your first version was this way, right?)

This means that we use the core codes CPU enumeration and don't need to repeat it in smp_init.

Quoted 2 lines

P.S. BTW: Any reason we instantiate cpu_up() for all platforms where they are actually NOPs?

When I initially started building this infrastructure there was stuff there, but it went away during development and so far it seems to have turned out to be unnecessary. This is largely because on all the platforms we supported so far the generic sev suffices to kick acpu out of either the firmware or Xen's holding pen.

This hook will be needed for PSCI, hopefully sooner rather than later.

Quoted 3 lines

I think the platform code only calls a function
if it is non-NULL, so we could just skip all of this: cpu_up() {return 0;} definition.

Could do.

Quoted 34 lines
Quoted 33 lines
xen/arch/arm/platforms/midway.c +21 -0
+{
+    void __iomem *pens;
+
+    pens = ioremap_nocache(0, PAGE_SIZE);
+    if ( !pens )
+    {
+        dprintk(XENLOG_ERR, "Unable to map midway pens MMIO\n");
+        return -EFAULT;
+    }
+
+    printk("Set cpu pen %u to %"PRIpaddr" (%p)\n",
+           cpu, __pa(init_secondary), init_secondary);
+
+    writel(__pa(init_secondary), pens + 0x40 + cpu * 0x10);
+
+    iounmap(pens);
+
+    return 0;
+}
+
  static const char * const midway_dt_compat[] __initconst =
  {
      "calxeda,ecx-2000",
@@ -57,6 +78,7 @@ PLATFORM_START(midway, "CALXEDA MIDWAY")
      .compatible = midway_dt_compat,
      .reset = midway_reset,
      .quirks = midway_quirks,
+    .cpu_up = midway_cpu_up,
  PLATFORM_END
 
  /*