Skip to contentSkip to conversation

xen/arm: arm32: Enable smpboot on Arm32 based systems

RFC PATCH In review Ayan Kumar Halder 4 participants 11 messages May 2, 2023 – May 10, 2023

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 xen/arm: arm32: Enable smpboot on Arm32 based systems

On some of the Arm32 based systems (eg Cortex-R52), smpboot is supported. In these systems PSCI may not always be supported. In case of Cortex-R52, there is no EL3 or secure mode. Thus, PSCI is not supported as it requires EL3.

Thus, we use 'spin-table' mechanism to boot the secondary cpus. The primary cpu provides the startup address of the secondary cores. This address is provided using the 'cpu-release-addr' property.

To support smpboot, we have copied the code from xen/arch/arm/arm64/smpboot.c with the following changes :-

1. 'enable-method' is an optional property. Refer to the comment in
https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/cpus.yaml
" # On ARM 32-bit systems this property is optional"

2. psci is not currently supported as a value for 'enable-method'.

3. update_identity_mapping() is not invoked as we are not sure if it is required.

---

The dts snippet with which this has been validated is :-

    cpus {
        #address-cells = <0x02>;
        #size-cells = <0x00>;

        cpu-map {

            cluster0 {

                core0 {

                    thread0 {
                        cpu = <0x02>;
                    };
                };
                core1 {

                    thread0 {
                        cpu = <0x03>;
                    };
                };
            };
        };

        cpu@0 {
            device_type = "cpu";
            compatible = "arm,armv8";
            reg = <0x00 0x00>;
            phandle = <0x02>;
        };

        cpu@1 {
            device_type = "cpu";
            compatible = "arm,armv8";
            reg = <0x00 0x01>;
            enable-method = "spin-table";
            cpu-release-addr = <0xEB58C010>;
            phandle = <0x03>;
        };
    };

Although currently I have tested this on Cortex-R52, I feel this may be helpful to enable smp on other Arm32 based systems as well. Happy to hear opinions.

 xen/arch/arm/arm32/smpboot.c | 84 ++++++++++++++++++++++++++++++++++--
 1 file changed, 80 insertions(+), 4 deletions(-)
xen/arch/arm/arm32/smpboot.c +80 -4
index 518e9f9c7e..feb249d3f8 100644
@@ -1,24 +1,100 @@
 #include <xen/device_tree.h>
 #include <xen/init.h>
 #include <xen/smp.h>
+#include <xen/vmap.h>
+#include <asm/io.h>
 #include <asm/platform.h>
 
+struct smp_enable_ops {
+        int             (*prepare_cpu)(int);
+};
+
+static uint32_t cpu_release_addr[NR_CPUS];
+static struct smp_enable_ops smp_enable_ops[NR_CPUS];
+
 int __init arch_smp_init(void)
 {
     return platform_smp_init();
 }
 
-int __init arch_cpu_init(int cpu, struct dt_device_node *dn)
+static int __init smp_spin_table_cpu_up(int cpu)
+{
+    uint32_t __iomem *release;
+
+    if (!cpu_release_addr[cpu])
+    {
+        printk("CPU%d: No release addr\n", cpu);
+        return -ENODEV;
+    }
+
+    release = ioremap_nocache(cpu_release_addr[cpu], 4);
+    if ( !release )
+    {
+        dprintk(XENLOG_ERR, "CPU%d: Unable to map release address\n", cpu);
+        return -EFAULT;
+    }
+
+    writel(__pa(init_secondary), release);
+
+    iounmap(release);
+
+    sev();
+
+    return 0;
+}
+
+static void __init smp_spin_table_init(int cpu, struct dt_device_node *dn)
 {
-    /* Not needed on ARM32, as there is no relevant information in
-     * the CPU device tree node for ARMv7 CPUs.
+    if ( !dt_property_read_u32(dn, "cpu-release-addr", &cpu_release_addr[cpu]) )
+    {
+        printk("CPU%d has no cpu-release-addr\n", cpu);
+        return;
+    }
+
+    smp_enable_ops[cpu].prepare_cpu = smp_spin_table_cpu_up;
+}
+
+static int __init dt_arch_cpu_init(int cpu, struct dt_device_node *dn)
+{
+    const char *enable_method;
+
+    /*
+     * Refer Documentation/devicetree/bindings/arm/cpus.yaml, it says on
+     * ARM 32-bit systems this property is optional.
      */
+    enable_method = dt_get_property(dn, "enable-method", NULL);
+    if (!enable_method)
+    {
+        return 0;
+    }
+
+    if ( !strcmp(enable_method, "spin-table") )
+        smp_spin_table_init(cpu, dn);
+    else
+    {
+        printk("CPU%d has unknown enable method \"%s\"\n", cpu, enable_method);
+        return -EINVAL;
+    }
+
     return 0;
 }
 
+int __init arch_cpu_init(int cpu, struct dt_device_node *dn)
+{
+    return dt_arch_cpu_init(cpu, dn);
+}
+
 int arch_cpu_up(int cpu)
 {
-    return platform_cpu_up(cpu);
+    int ret = 0;
+
+    if ( smp_enable_ops[cpu].prepare_cpu )
+        ret = smp_enable_ops[cpu].prepare_cpu(cpu);
+
+    if ( !ret )
+        return platform_cpu_up(cpu);
+
+    return ret;
 }
 
 void arch_cpu_up_finish(void)
Signature · 1 line
2.17.1
#1 lore raw
Quoted 65 lines · Ayan Kumar Halder

On some of the Arm32 based systems (eg Cortex-R52), smpboot is supported. In these systems PSCI may not always be supported. In case of Cortex-R52, there is no EL3 or secure mode. Thus, PSCI is not supported as it requires EL3.

Thus, we use 'spin-table' mechanism to boot the secondary cpus. The primary cpu provides the startup address of the secondary cores. This address is provided using the 'cpu-release-addr' property.

To support smpboot, we have copied the code from xen/arch/arm/arm64/smpboot.c with the following changes :-

1. 'enable-method' is an optional property. Refer to the comment in
https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/cpus.yaml
" # On ARM 32-bit systems this property is optional"

2. psci is not currently supported as a value for 'enable-method'.

3. update_identity_mapping() is not invoked as we are not sure if it is required.

---

The dts snippet with which this has been validated is :-

    cpus {
        #address-cells = <0x02>;
        #size-cells = <0x00>;

        cpu-map {

            cluster0 {

                core0 {

                    thread0 {
                        cpu = <0x02>;
                    };
                };
                core1 {

                    thread0 {
                        cpu = <0x03>;
                    };
                };
            };
        };

        cpu@0 {
            device_type = "cpu";
            compatible = "arm,armv8";
            reg = <0x00 0x00>;
            phandle = <0x02>;
        };

        cpu@1 {
            device_type = "cpu";
            compatible = "arm,armv8";
            reg = <0x00 0x01>;
            enable-method = "spin-table";
            cpu-release-addr = <0xEB58C010>;
            phandle = <0x03>;
        };
    };
Quoted 2 lines

Although currently I have tested this on Cortex-R52, I feel this may be helpful to enable smp on other Arm32 based systems as well. Happy to hear opinions.

I think you are right

Quoted 8 lines
 xen/arch/arm/arm32/smpboot.c | 84 ++++++++++++++++++++++++++++++++++--
 1 file changed, 80 insertions(+), 4 deletions(-)
xen/arch/arm/arm32/smpboot.c +0 -0
index 518e9f9c7e..feb249d3f8 100644

xen/arch/arm/arm32/smpboot.c line 10

Quoted 10 lines
xen/arch/arm/arm32/smpboot.c +5 -0
@@ -1,24 +1,100 @@
 #include <xen/device_tree.h>
 #include <xen/init.h>
 #include <xen/smp.h>
+#include <xen/vmap.h>
+#include <asm/io.h>
 #include <asm/platform.h>
 
+struct smp_enable_ops {
+        int             (*prepare_cpu)(int);
+};

coding style

xen/arch/arm/arm32/smpboot.c line 13

Quoted 2 lines
xen/arch/arm/arm32/smpboot.c +2 -0
+static uint32_t cpu_release_addr[NR_CPUS];
+static struct smp_enable_ops smp_enable_ops[NR_CPUS];

they could be __initdata

xen/arch/arm/arm32/smpboot.c line 24

Quoted 11 lines
xen/arch/arm/arm32/smpboot.c +5 -1
 int __init arch_smp_init(void)
 {
     return platform_smp_init();
 }
 
-int __init arch_cpu_init(int cpu, struct dt_device_node *dn)
+static int __init smp_spin_table_cpu_up(int cpu)
+{
+    uint32_t __iomem *release;
+
+    if (!cpu_release_addr[cpu])

code style

Quoted 5 lines
xen/arch/arm/arm32/smpboot.c +5 -0
+    {
+        printk("CPU%d: No release addr\n", cpu);
+        return -ENODEV;
+    }
+

xen/arch/arm/arm32/smpboot.c line 39

Quoted 10 lines
xen/arch/arm/arm32/smpboot.c +10 -0
+    release = ioremap_nocache(cpu_release_addr[cpu], 4);
+    if ( !release )
+    {
+        dprintk(XENLOG_ERR, "CPU%d: Unable to map release address\n", cpu);
+        return -EFAULT;
+    }
+
+    writel(__pa(init_secondary), release);
+
+    iounmap(release);

I think we need a wmb() ?

xen/arch/arm/arm32/smpboot.c line 48

Quoted 10 lines
xen/arch/arm/arm32/smpboot.c +7 -2
+    sev();
+
+    return 0;
+}
+
+static void __init smp_spin_table_init(int cpu, struct dt_device_node *dn)
 {
-    /* Not needed on ARM32, as there is no relevant information in
-     * the CPU device tree node for ARMv7 CPUs.
+    if ( !dt_property_read_u32(dn, "cpu-release-addr", &cpu_release_addr[cpu]) )

It looks like cpu-release-addr could be u64 or u32. Can we detect the size of the property and act accordingly? If the address is u64 and above 4GB it is fine to abort.

Quoted 8 lines
xen/arch/arm/arm32/smpboot.c +8 -0
+    {
+        printk("CPU%d has no cpu-release-addr\n", cpu);
+        return;
+    }
+
+    smp_enable_ops[cpu].prepare_cpu = smp_spin_table_cpu_up;
+}
+

xen/arch/arm/arm32/smpboot.c line 66

Quoted 10 lines
xen/arch/arm/arm32/smpboot.c +9 -0
+static int __init dt_arch_cpu_init(int cpu, struct dt_device_node *dn)
+{
+    const char *enable_method;
+
+    /*
+     * Refer Documentation/devicetree/bindings/arm/cpus.yaml, it says on
+     * ARM 32-bit systems this property is optional.
      */
+    enable_method = dt_get_property(dn, "enable-method", NULL);
+    if (!enable_method)

coding style

Quoted 20 lines
xen/arch/arm/arm32/smpboot.c +17 -0
+    {
+        return 0;
+    }
+
+    if ( !strcmp(enable_method, "spin-table") )
+        smp_spin_table_init(cpu, dn);
+    else
+    {
+        printk("CPU%d has unknown enable method \"%s\"\n", cpu, enable_method);
+        return -EINVAL;
+    }
+
     return 0;
 }
 
+int __init arch_cpu_init(int cpu, struct dt_device_node *dn)
+{
+    return dt_arch_cpu_init(cpu, dn);
+}
+

xen/arch/arm/arm32/smpboot.c line 95

Quoted 10 lines
xen/arch/arm/arm32/smpboot.c +7 -1
 int arch_cpu_up(int cpu)
 {
-    return platform_cpu_up(cpu);
+    int ret = 0;
+
+    if ( smp_enable_ops[cpu].prepare_cpu )
+        ret = smp_enable_ops[cpu].prepare_cpu(cpu);
+
+    if ( !ret )
+        return platform_cpu_up(cpu);

I think this should be:

    if ( smp_enable_ops[cpu].prepare_cpu )
        ret = smp_enable_ops[cpu].prepare_cpu(cpu);
    else
        ret = platform_cpu_up(cpu);
Quoted 8 lines
xen/arch/arm/arm32/smpboot.c +1 -0
+    return ret;
 }
 
 void arch_cpu_up_finish(void)
Signature · 1 line
2.17.1
#2 lore raw

Hi Stefano,

Quoted 9 lines · Stefano Stabellini
Quoted 9 lines
xen/arch/arm/arm32/smpboot.c +9 -0
+    {
+        printk("CPU%d: No release addr\n", cpu);
+        return -ENODEV;
+    }
+
+    release = ioremap_nocache(cpu_release_addr[cpu], 4);
+    if ( !release )
+    {
+        dprintk(XENLOG_ERR, "CPU%d: Unable to map release address\n", cpu);
Quoted 8 lines

xen/arch/arm/arm32/smpboot.c line 39

Quoted 6 lines
xen/arch/arm/arm32/smpboot.c +6 -0
+        return -EFAULT;
+    }
+
+    writel(__pa(init_secondary), release);
+
+    iounmap(release);

I think we need a wmb() ?

I am not sure why we would need a wmb() here. Instead, looking at the Linux version, I think we are missing a cache flush (so does on arm64) which would be necessary if the CPU waiting for the release doesn't have cache enabled.

Cheers,

Signature · 1 line
Julien Grall
#3 lore raw
Quoted 22 lines · Julien Grall

Hi Stefano,

Quoted 10 lines · Stefano Stabellini
Quoted 10 lines
xen/arch/arm/arm32/smpboot.c +9 -0
+    {
+        printk("CPU%d: No release addr\n", cpu);
+        return -ENODEV;
+    }
+
+    release = ioremap_nocache(cpu_release_addr[cpu], 4);
+    if ( !release )
+    {
+        dprintk(XENLOG_ERR, "CPU%d: Unable to map release address\n",

cpu);

Quoted 8 lines

xen/arch/arm/arm32/smpboot.c line 39

Quoted 6 lines
xen/arch/arm/arm32/smpboot.c +6 -0
+        return -EFAULT;
+    }
+
+    writel(__pa(init_secondary), release);
+
+    iounmap(release);

I think we need a wmb() ?

Quoted 1 line

I am not sure why we would need a wmb() here.

The code does:

writel(__pa(init_secondary), release);
iounmap
sev();

I was thinking of trying to make sure the write is completed before issuing a sev(). Technically it is possible for the CPU to reorder the sev() before the write as there is no explicit dependency between the two?

Quoted 3 lines

Instead, looking at the Linux
version, I think we are missing a cache flush (so does on arm64) which would be necessary if the CPU waiting for the release doesn't have cache enabled.

I thought about it as well but here the patch is calling ioremap_nocache(), so cache flushes should not be needed?

#4 lore raw

Hi Stefano,

Quoted 27 lines · Stefano Stabellini
Quoted 22 lines · Julien Grall

Hi Stefano,

Quoted 10 lines · Stefano Stabellini
Quoted 10 lines
xen/arch/arm/arm32/smpboot.c +9 -0
+    {
+        printk("CPU%d: No release addr\n", cpu);
+        return -ENODEV;
+    }
+
+    release = ioremap_nocache(cpu_release_addr[cpu], 4);
+    if ( !release )
+    {
+        dprintk(XENLOG_ERR, "CPU%d: Unable to map release address\n",

cpu);

Quoted 8 lines

xen/arch/arm/arm32/smpboot.c line 39

Quoted 6 lines
xen/arch/arm/arm32/smpboot.c +6 -0
+        return -EFAULT;
+    }
+
+    writel(__pa(init_secondary), release);
+
+    iounmap(release);

I think we need a wmb() ?

Quoted 1 line

I am not sure why we would need a wmb() here.

The code does:

Quoted 8 lines

writel(__pa(init_secondary), release);
iounmap
sev();

I was thinking of trying to make sure the write is completed before issuing a sev(). Technically it is possible for the CPU to reorder the sev() before the write as there is no explicit dependency between the two?

I would assume that iounmap() would contain an wmb(). But I guess this is not something we should rely on.

Quoted 7 lines
Quoted 4 lines

Instead, looking at the Linux
version, I think we are missing a cache flush (so does on arm64) which would be necessary if the CPU waiting for the release doesn't have cache enabled.

I thought about it as well but here the patch is calling ioremap_nocache(), so cache flushes should not be needed?

Hmmm... You are right, we are using ioremap_nocache(). I got confused because Linux is using ioremap_cache(). I am now wondering whether we are using the correct helper.

AFAIU, spin table is part of the reserved memory section in the Device-Tree. From section 5.3 in [1], the memory could be mapped cacheable by the other end. So for correctness, it seems to me that we would need to use ioremap_cache() + cache flush.

BTW, writel_relaxed() should be sufficient here as there is no ordering necessary with any previous write.

Cheers,

[1] https://github.com/devicetree-org/devicetree-specification/releases/tag/v0.3

Signature · 1 line
Julien Grall
#5 lore raw
Quoted 52 lines · Julien Grall

Hi Stefano,

Quoted 27 lines · Stefano Stabellini
Quoted 22 lines · Julien Grall

Hi Stefano,

Quoted 10 lines · Stefano Stabellini
Quoted 10 lines
xen/arch/arm/arm32/smpboot.c +9 -0
+    {
+        printk("CPU%d: No release addr\n", cpu);
+        return -ENODEV;
+    }
+
+    release = ioremap_nocache(cpu_release_addr[cpu], 4);
+    if ( !release )
+    {
+        dprintk(XENLOG_ERR, "CPU%d: Unable to map release address\n",

cpu);

Quoted 8 lines

xen/arch/arm/arm32/smpboot.c line 39

Quoted 6 lines
xen/arch/arm/arm32/smpboot.c +6 -0
+        return -EFAULT;
+    }
+
+    writel(__pa(init_secondary), release);
+
+    iounmap(release);

I think we need a wmb() ?

Quoted 1 line

I am not sure why we would need a wmb() here.

The code does:

Quoted 8 lines

writel(__pa(init_secondary), release);
iounmap
sev();

I was thinking of trying to make sure the write is completed before issuing a sev(). Technically it is possible for the CPU to reorder the sev() before the write as there is no explicit dependency between the two?

I would assume that iounmap() would contain an wmb(). But I guess this is not something we should rely on.

Quoted 9 lines
Quoted 6 lines

Instead, looking at the Linux
version, I think we are missing a cache flush (so does on arm64) which would
be necessary if the CPU waiting for the release doesn't have cache enabled.

I thought about it as well but here the patch is calling ioremap_nocache(), so cache flushes should not be needed?

Quoted 8 lines

Hmmm... You are right, we are using ioremap_nocache(). I got confused because Linux is using ioremap_cache(). I am now wondering whether we are using the correct helper.

AFAIU, spin table is part of the reserved memory section in the Device-Tree. From section 5.3 in [1], the memory could be mapped cacheable by the other end. So for correctness, it seems to me that we would need to use ioremap_cache() + cache flush.

Good point

Quoted 2 lines

BTW, writel_relaxed() should be sufficient here as there is no ordering necessary with any previous write.

#6 lore raw
In reply to Ayan Kumar Halder

Hi,

Title: Did you mean "Enable spin table"?

Quoted 1 line · Ayan Kumar Halder

On some of the Arm32 based systems (eg Cortex-R52), smpboot is supported.

Same here.

Quoted 8 lines

In these systems PSCI may not always be supported. In case of Cortex-R52, there is no EL3 or secure mode. Thus, PSCI is not supported as it requires EL3.

Thus, we use 'spin-table' mechanism to boot the secondary cpus. The primary cpu provides the startup address of the secondary cores. This address is provided using the 'cpu-release-addr' property.

To support smpboot, we have copied the code from xen/arch/arm/arm64/smpboot.c

I would rather prefer if we don't duplicate the code but instead move the logic in common code.

Quoted 5 lines

with the following changes :-

1. 'enable-method' is an optional property. Refer to the comment in
https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/cpus.yaml
" # On ARM 32-bit systems this property is optional"

Looking at this list, "spin-table" doesn't seem to be supported
for 32-bit systems. Can you point me to the discussion/patch where this would be added?

Quoted 5 lines

2. psci is not currently supported as a value for 'enable-method'.

3. update_identity_mapping() is not invoked as we are not sure if it is required.

This is not necessary at the moment for 32-bit. This may change in the future as we make the 32-bit boot code more compliant. For now, I would not add it.

Cheers,

Signature · 1 line
Julien Grall
#7 lore raw
Quoted 1 line · Julien Grall

Hi,

Hi Julien,

Quoted 2 lines

Title: Did you mean "Enable spin table"?

Yes, that would be more concrete.

Quoted 5 lines · Ayan Kumar Halder
Quoted 1 line

On some of the Arm32 based systems (eg Cortex-R52), smpboot is supported.

Same here.

Yes

Quoted 11 lines
Quoted 9 lines

In these systems PSCI may not always be supported. In case of Cortex-R52, there is no EL3 or secure mode. Thus, PSCI is not supported as it requires EL3.

Thus, we use 'spin-table' mechanism to boot the secondary cpus. The primary cpu provides the startup address of the secondary cores. This address is provided using the 'cpu-release-addr' property.

To support smpboot, we have copied the code from xen/arch/arm/arm64/smpboot.c

I would rather prefer if we don't duplicate the code but instead move the logic in common code.

Ack

Quoted 10 lines
Quoted 7 lines

with the following changes :-

1. 'enable-method' is an optional property. Refer to the comment in
https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/cpus.yaml

"      # On ARM 32-bit systems this property is optional"

Looking at this list, "spin-table" doesn't seem to be supported for 32-bit systems.

However, looking at https://developer.arm.com/documentation/den0013/d/Multi-core-processors/Booting-SMP-systems/SMP-boot-in-Linux , it seems "spin-table" is a valid boot mechanism for Armv7 cpus.

Quoted 1 line

Can you point me to the discussion/patch where this would be added?

Actually, this is the first discussion I am having with regards to adding a "spin-table" support on Arm32.

The logic that we will use for secondary cpu booting is similar to the "spin-table" mechanism used in arm64/smpboot.c.

This is :-

1. Write the address of init_secondary() to cpu-release-address register of the secondary cpu. (In my current patch, I attempt to achieve this.)

2. Write to the configuration register of the secondary cpu to bring it out of reset.

This is the corresponding patch (yet to be cleaned) which will be used to do step 2.

xen/arch/arm/platforms/amd-versal-net.c +0 -0
@@ -36,6 +36,47 @@ static int versal_net_init_time(void)

     return 0;
 }

+static __init void versal_net_populate_plat_regs(void)
+{
+    /* TODO :- Parse 0xEB58C000 ie CORE_1_CFG0 from dtb */
+}
+
+static __init int versal_net_init(void)
+{
+    versal_net_populate_plat_regs();
+
+    return 0;
+}
+
+static __init int versasl_net_smp_init(void)
+{
+    return 0;
+}
+
+static __init int versal_net_cpu_up(int cpu)
+{
+    uint32_t __iomem *cpu_rel_addr = ioremap_nocache(0xEB58C000, 4); +    uint32_t i = 0;
+
+    writel(1, cpu_rel_addr);
+
+    /* Delay has been added due to some platform nuance */
+    __iowmb();
+    for (i=0; i<0xF000000; i++)
+        __asm __volatile("nop");
+
+    writel(0, cpu_rel_addr);
+
+    /* Delay has been added due to some platform nuance */
+    __iowmb();
+    for (i=0; i<0xF000000; i++)
+        __asm __volatile("nop");
+
+    iounmap(cpu_rel_addr);
+
+    return 0;
+}
+
 static const char * const versal_net_dt_compat[] __initconst =
 {
     "xlnx,versal-net",
@@ -44,5 +85,8 @@ static const char * const versal_net_dt_compat[] __initconst =

 PLATFORM_START(versal_net, "XILINX VERSAL-NET")
     .compatible = versal_net_dt_compat,
+    .init = versal_net_init,
+    .smp_init = versasl_net_smp_init,
+    .cpu_up = versal_net_cpu_up,
     .init_time = versal_net_init_time,
 PLATFORM_END

Quoted 8 lines
Quoted 6 lines

2. psci is not currently supported as a value for 'enable-method'.

3. update_identity_mapping() is not invoked as we are not sure if it is required.

This is not necessary at the moment for 32-bit. This may change in the future as we make the 32-bit boot code more compliant. For now, I would not add it.

Ack.

- Ayan

Quoted 3 lines

Cheers,

#8 lore raw

Hi Ayan,

Quoted 28 lines · Ayan Kumar Halder
Quoted 1 line · Julien Grall

Hi,

Hi Julien,

Quoted 2 lines

Title: Did you mean "Enable spin table"?

Yes, that would be more concrete.

Quoted 5 lines · Ayan Kumar Halder
Quoted 1 line

On some of the Arm32 based systems (eg Cortex-R52), smpboot is supported.

Same here.

Yes

Quoted 11 lines
Quoted 9 lines

In these systems PSCI may not always be supported. In case of Cortex-R52, there is no EL3 or secure mode. Thus, PSCI is not supported as it requires EL3.

Thus, we use 'spin-table' mechanism to boot the secondary cpus. The primary cpu provides the startup address of the secondary cores. This address is provided using the 'cpu-release-addr' property.

To support smpboot, we have copied the code from xen/arch/arm/arm64/smpboot.c

I would rather prefer if we don't duplicate the code but instead move the logic in common code.

Ack

Quoted 3 lines
Quoted 3 lines

with the following changes :-

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

1. 'enable-method' is an optional property. Refer to the comment in
https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/cpus.yaml
"      # On ARM 32-bit systems this property is optional"

Looking at this list, "spin-table" doesn't seem to be supported for 32-bit systems.

However, looking at https://developer.arm.com/documentation/den0013/d/Multi-core-processors/Booting-SMP-systems/SMP-boot-in-Linux , it seems "spin-table" is a valid boot mechanism for Armv7 cpus.

I am not able to find the associated code in Linux 32-bit. Do you have any pointer?

Quoted 5 lines
Quoted 3 lines

Can you point me to the discussion/patch where this would be added?

Actually, this is the first discussion I am having with regards to adding a "spin-table" support on Arm32.

I was asking for the discussion on the Device-Tree/Linux ML or code.
I don't really want to do a "spin-table" support if this is not even supported in Linux.

Cheers,

Signature · 1 line
Julien Grall
#9 lore raw
Quoted 1 line · Julien Grall

Hi Ayan,

Hi Julien,

Quoted 33 lines · Ayan Kumar Halder
Quoted 31 lines · Julien Grall
Quoted 1 line

Hi,

Hi Julien,

Quoted 2 lines

Title: Did you mean "Enable spin table"?

Yes, that would be more concrete.

Quoted 5 lines · Ayan Kumar Halder
Quoted 1 line

On some of the Arm32 based systems (eg Cortex-R52), smpboot is supported.

Same here.

Yes

Quoted 11 lines
Quoted 9 lines

In these systems PSCI may not always be supported. In case of Cortex-R52, there is no EL3 or secure mode. Thus, PSCI is not supported as it requires EL3.

Thus, we use 'spin-table' mechanism to boot the secondary cpus. The primary cpu provides the startup address of the secondary cores. This address is provided using the 'cpu-release-addr' property.

To support smpboot, we have copied the code from xen/arch/arm/arm64/smpboot.c

I would rather prefer if we don't duplicate the code but instead move the logic in common code.

Ack

Quoted 6 lines
Quoted 6 lines

with the following changes :-

1. 'enable-method' is an optional property. Refer to the comment in
https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/cpus.yaml

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

"      # On ARM 32-bit systems this property is optional"

Looking at this list, "spin-table" doesn't seem to be supported for 32-bit systems.

However, looking at https://developer.arm.com/documentation/den0013/d/Multi-core-processors/Booting-SMP-systems/SMP-boot-in-Linux , it seems "spin-table" is a valid boot mechanism for Armv7 cpus.

I am not able to find the associated code in Linux 32-bit. Do you have any pointer?

Unfortunately, no.

I see that in linux, "spin-table" support is added in arch/arm64/kernel/smp_spin_table.c. So, there seems to be no Arm32 support for this.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

Can you point me to the discussion/patch where this would be added?

Actually, this is the first discussion I am having with regards to adding a "spin-table" support on Arm32.

I was asking for the discussion on the Device-Tree/Linux ML or code.
I don't really want to do a "spin-table" support if this is not even supported in Linux.

I see your point. But that brings me to my next question, how do I parse cpu node specific properties for Arm32 cpus.

In https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/cpus.yaml , I see some of the properties valid for Arm32 cpus.

For example:-

secondary-boot-reg
rockchip,pmu

Also, it says "additionalProperties: true" which means I can add platform specific properties under the cpu node. Please correct me if mistaken.

My cpu nodes will look like this :-

        cpu@1 {
            device_type = "cpu";
            compatible = "arm,armv8";
            reg = <0x00 0x01>;
            enable-method = "spin-table";
            amd-cpu-release-addr = <0xEB58C010>; /* might also use "secondary-boot-reg" */
            amd-cpu-reset-addr = <0xEB58C000>;
            amd-cpu-reset-delay = <0xF00000>;
            amd-cpu-re
            phandle = <0x03>;
        };

        cpu@2 {
            device_type = "cpu";
            compatible = "arm,armv8";
            reg = <0x00 0x02>;
            enable-method = "spin-table";
            amd-cpu-release-addr = <0xEB59C010>; /* might also use "secondary-boot-reg" */
            amd-cpu-reset-addr = <0xEB59C000>;
            amd-cpu-reset-delay = <0xF00000>;
            amd-cpu-re
            phandle = <0x03>;
        };

If the reasoning makes sense, then does the following proposed change looks sane ?

xen/arch/arm/arm32/smpboot.c +0 -0
index e7368665d5..0b281edb9d 100644
@@ -10,10 +10,7 @@ int __init arch_smp_init(void)
 

 int __init arch_cpu_init(int cpu, struct dt_device_node *dn) {
-    /* Not needed on ARM32, as there is no relevant information in -     * the CPU device tree node for ARMv7 CPUs.
-     */
-    return 0;
+    return platform_cpu_init(cpu, dn);
 }

 int arch_cpu_up(int cpu)

xen/arch/arm/include/asm/platform.h +0 -0
index d03b261ce8..5cd7af4d0e 100644
@@ -18,6 +18,7 @@ struct platform_desc {

     /* SMP */
     int (*smp_init)(void);
     int (*cpu_up)(int cpu);
+    int (*cpu_init)(int cpu, struct dt_device_node *dn); #endif
     /* Specific mapping for dom0 */
     int (*specific_mapping)(struct domain *d);

xen/arch/arm/platform.c +0 -0
index a820665020..ed54b68c20 100644
@@ -95,6 +95,14 @@ int __init platform_specific_mapping(struct domain *d)

 }

 #ifdef CONFIG_ARM_32
+int __init platform_cpu_init(int cpu, struct dt_device_node *dn)
+{
+    if ( platform && platform->cpu_init )
+        return platform_cpu_init(cpu, dn); /* parse platform specific cpu properties */ +
+    return 0;
+}
+
 int platform_cpu_up(int cpu)
 {
     if ( psci_ver )

Let me know your thoughts, please.

Kind regards,

Ayan

Quoted 3 lines

Cheers,

#10 lore raw

Hi Ayan,

Quoted 51 lines · Ayan Kumar Halder
Quoted 1 line · Julien Grall

Hi Ayan,

Hi Julien,

Quoted 34 lines · Ayan Kumar Halder
Quoted 32 lines · Julien Grall
Quoted 1 line

Hi,

Hi Julien,

Quoted 2 lines

Title: Did you mean "Enable spin table"?

Yes, that would be more concrete.

Quoted 5 lines · Ayan Kumar Halder
Quoted 1 line

On some of the Arm32 based systems (eg Cortex-R52), smpboot is supported.

Same here.

Yes

Quoted 11 lines
Quoted 9 lines

In these systems PSCI may not always be supported. In case of Cortex-R52, there is no EL3 or secure mode. Thus, PSCI is not supported as it requires EL3.

Thus, we use 'spin-table' mechanism to boot the secondary cpus. The primary cpu provides the startup address of the secondary cores. This address is provided using the 'cpu-release-addr' property.

To support smpboot, we have copied the code from xen/arch/arm/arm64/smpboot.c

I would rather prefer if we don't duplicate the code but instead move the logic in common code.

Ack

Quoted 7 lines
Quoted 6 lines

with the following changes :-

1. 'enable-method' is an optional property. Refer to the comment in
https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/cpus.yaml
"      # On ARM 32-bit systems this property is optional"

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Looking at this list, "spin-table" doesn't seem to be supported for 32-bit systems.

However, looking at https://developer.arm.com/documentation/den0013/d/Multi-core-processors/Booting-SMP-systems/SMP-boot-in-Linux , it seems "spin-table" is a valid boot mechanism for Armv7 cpus.

I am not able to find the associated code in Linux 32-bit. Do you have any pointer?

Unfortunately, no.

I see that in linux, "spin-table" support is added in arch/arm64/kernel/smp_spin_table.c. So, there seems to be no Arm32 support for this.

Quoted 3 lines
Quoted 3 lines
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Can you point me to the discussion/patch where this would be added?

Actually, this is the first discussion I am having with regards to adding a "spin-table" support on Arm32.

I was asking for the discussion on the Device-Tree/Linux ML or code.
I don't really want to do a "spin-table" support if this is not even supported in Linux.

I see your point. But that brings me to my next question, how do I parse cpu node specific properties for Arm32 cpus.

I was probably not very clear in my previous message. What I don't want is for Xen to use unofficial bindings.

IOW, if the existing binding doesn't allow the spin-table on arm32 (IMHO it is not clear) and it makes sense to use them, then we should first consider to send a patch against the documentation and merge it before Xen can use the properties.

Quoted 9 lines

In https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/cpus.yaml , I see some of the properties valid for Arm32 cpus.

For example:-

secondary-boot-reg
rockchip,pmu

Also, it says "additionalProperties: true" which means I can add platform specific properties under the cpu node.

For clarification, are you saying the bindings below is not yet official? If so, then this should be first discussed with the Device-Tree folks.

Quoted 9 lines

Please correct me if mistaken.

My cpu nodes will look like this :-

        cpu@1 {
            device_type = "cpu";
            compatible = "arm,armv8";
            reg = <0x00 0x01>;
            enable-method = "spin-table";

The enable-method "spin-table" is generic and expect property like cpu-release-addr. Yet...

Quoted 5 lines

            amd-cpu-release-addr = <0xEB58C010>; /* might also use
"secondary-boot-reg" */
            amd-cpu-reset-addr = <0xEB58C000>; amd-cpu-reset-delay = <0xF00000>; amd-cpu-re

... these are all AMD properties. What are the reasons to not use the generic "spin-table" bindings?

If you can't use it, then I think you should define a new type of enable-method.

Quoted 16 lines

            phandle = <0x03>;
        };

        cpu@2 {
            device_type = "cpu";
            compatible = "arm,armv8";
            reg = <0x00 0x02>;
            enable-method = "spin-table"; amd-cpu-release-addr = <0xEB59C010>; /* might also use
"secondary-boot-reg" */
            amd-cpu-reset-addr = <0xEB59C000>; amd-cpu-reset-delay = <0xF00000>; amd-cpu-re
            phandle = <0x03>;
        };

Quoted 1 line

If the reasoning makes sense, then does the following proposed change looks sane ?

I would first like to understand a bit more about how the bindings were created and whether this was discussed with the Device-Tree community.

Cheers,

Signature · 1 line
Julien Grall