ARM: sunxi: mc-smp: Use DT enable-method for sun9i A80 SMP
authorChen-Yu Tsai <wens@csie.org>
Thu, 8 Mar 2018 15:00:10 +0000 (23:00 +0800)
committerChen-Yu Tsai <wens@csie.org>
Sat, 10 Mar 2018 08:14:46 +0000 (16:14 +0800)
Instead of having an early init function check the machine compatible
and installing multi-cluster SMP support for the A80 if it matches,
use a new cpu enable-method string. This makes the platform support
future proof in case anyone manages to add PSCI support.

The original init code for the SMP support is changed into the
.prepare_cpus callback in the smp_operations structure. Instead of
panicing when resources are missing like on some platforms, our code
merely guards against engaging SMP or CPU hotplug and returns an error.

Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Documentation/devicetree/bindings/arm/cpus.txt
arch/arm/mach-sunxi/mc_smp.c

index f4a777039f03f3a1b899a05fa181db0952c3df17..76655d0d67c2ca6fa01109660e7cdd402139ad81 100644 (file)
@@ -198,6 +198,7 @@ described below.
                            "actions,s500-smp"
                            "allwinner,sun6i-a31"
                            "allwinner,sun8i-a23"
+                           "allwinner,sun9i-a80-smp"
                            "amlogic,meson8-smp"
                            "amlogic,meson8b-smp"
                            "arm,realview-smp"
index 9db6c4ed5861bdf8988e882023e3c324db8f5d25..86e90b0385554a3556cb8753a995f11ce3232cfa 100644 (file)
@@ -690,7 +690,26 @@ static int __init sunxi_mc_smp_init(void)
        struct resource res;
        int ret;
 
-       if (!of_machine_is_compatible("allwinner,sun9i-a80"))
+       /*
+        * Don't bother checking the "cpus" node, as an enable-method
+        * property in that node is undocumented.
+        */
+       node = of_cpu_device_node_get(0);
+       if (!node)
+               return -ENODEV;
+
+       /*
+        * We can't actually use the enable-method magic in the kernel.
+        * Our loopback / trampoline code uses the CPU suspend framework,
+        * which requires the identity mapping be available. It would not
+        * yet be available if we used the .init_cpus or .prepare_cpus
+        * callbacks in smp_operations, which we would use if we were to
+        * use CPU_METHOD_OF_DECLARE
+        */
+       ret = of_property_match_string(node, "enable-method",
+                                      "allwinner,sun9i-a80-smp");
+       of_node_put(node);
+       if (ret)
                return -ENODEV;
 
        if (!sunxi_mc_smp_cpu_table_init())