]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
powerpc: Add optional smp_ops->prepare_cpu SMP callback
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Mon, 29 May 2017 14:54:35 +0000 (11:54 -0300)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 20 Jun 2017 08:49:48 +0000 (10:49 +0200)
BugLink: http://bugs.launchpad.net/bugs/1691973
Some platforms (will) need to perform allocations before bringing
a new CPU online. Doing it from smp_ops->setup_cpu is the wrong
thing to do:

 - It has no useful failure path (too late)
 - Calling any allocator will enable interrupts prematurely
   causing problems with large decrementer among others

Instead, add a new callback that is called from __cpu_up (so from
the context trying to online the new CPU) at a point where we
can safely allocate and handle failures.

This will be used by XIVE support.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit 14d4ae5c4cb89c05262fe41cb7a26f6ba949d8df)
Signed-off-by: Gustavo Walbon <gwalbon@linux.vnet.ibm.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
arch/powerpc/include/asm/smp.h
arch/powerpc/kernel/smp.c

index edd939e76d528aad0ba27b1e03e47389a2d82756..56ba9daefaa6d154409b7f31f4f48c2840af31c0 100644 (file)
@@ -45,6 +45,7 @@ struct smp_ops_t {
 #endif
        void  (*probe)(void);
        int   (*kick_cpu)(int nr);
+       int   (*prepare_cpu)(int nr);
        void  (*setup_cpu)(int nr);
        void  (*bringup_done)(void);
        void  (*take_timebase)(void);
index 95eefa00abb3eeccdc82fd025d5fd028ca475d55..84f7ac4b9a3332b48c0c41beb5e013e8467c650a 100644 (file)
@@ -519,6 +519,16 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle)
 
        cpu_idle_thread_init(cpu, tidle);
 
+       /*
+        * The platform might need to allocate resources prior to bringing
+        * up the CPU
+        */
+       if (smp_ops->prepare_cpu) {
+               rc = smp_ops->prepare_cpu(cpu);
+               if (rc)
+                       return rc;
+       }
+
        /* Make sure callin-map entry is 0 (can be leftover a CPU
         * hotplug
         */