powerpc/64: move default SPR recording
authorNicholas Piggin <npiggin@gmail.com>
Tue, 13 Feb 2018 15:08:17 +0000 (01:08 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 30 Mar 2018 12:34:26 +0000 (23:34 +1100)
Move this into the early setup code, and don't iterate over CPU masks.
We don't want to call into sysfs so early from setup, and a future patch
won't initialize CPU masks by the time this is called.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
[mpe: Fold in incremental fix from Nick for DSCR handling]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/kernel/setup.h
arch/powerpc/kernel/setup_64.c
arch/powerpc/kernel/sysfs.c

index 3fc11e30308fc2700658ba0bebf6142140a8705b..d144df54ad4087c441f02cb214bc22b081bfe81a 100644 (file)
@@ -45,14 +45,11 @@ void emergency_stack_init(void);
 static inline void emergency_stack_init(void) { };
 #endif
 
-#ifdef CONFIG_PPC64
-void record_spr_defaults(void);
-#else
-static inline void record_spr_defaults(void) { };
-#endif
-
 #ifdef CONFIG_PPC64
 u64 ppc64_bolted_size(void);
+
+/* Default SPR values from firmware/kexec */
+extern unsigned long spr_default_dscr;
 #endif
 
 /*
index 3ce12af4906f04ccf2c3758951a8b7f1492fabb0..dde34d35d1e73511f6102517c3acf8f36ced7f5f 100644 (file)
@@ -254,6 +254,14 @@ static void cpu_ready_for_interrupts(void)
        get_paca()->kernel_msr = MSR_KERNEL;
 }
 
+unsigned long spr_default_dscr = 0;
+
+void __init record_spr_defaults(void)
+{
+       if (early_cpu_has_feature(CPU_FTR_DSCR))
+               spr_default_dscr = mfspr(SPRN_DSCR);
+}
+
 /*
  * Early initialization entry point. This is called by head.S
  * with MMU translation disabled. We rely on the "feature" of
index 1f9d94dac3a6addd2c6924fd6efab6404b1c87e4..9f327483008c219d9dbc86f79f1662e2cb89edcf 100644 (file)
@@ -20,6 +20,7 @@
 #include <asm/firmware.h>
 
 #include "cacheinfo.h"
+#include "setup.h"
 
 #ifdef CONFIG_PPC64
 #include <asm/paca.h>
@@ -588,21 +589,18 @@ static DEVICE_ATTR(dscr_default, 0600,
 
 static void sysfs_create_dscr_default(void)
 {
-       int err = 0;
-       if (cpu_has_feature(CPU_FTR_DSCR))
-               err = device_create_file(cpu_subsys.dev_root, &dev_attr_dscr_default);
-}
-
-void __init record_spr_defaults(void)
-{
-       int cpu;
-
        if (cpu_has_feature(CPU_FTR_DSCR)) {
-               dscr_default = mfspr(SPRN_DSCR);
-               for (cpu = 0; cpu < nr_cpu_ids; cpu++)
+               int err = 0;
+               int cpu;
+
+               dscr_default = spr_default_dscr;
+               for_each_possible_cpu(cpu)
                        paca_ptrs[cpu]->dscr_default = dscr_default;
+
+               err = device_create_file(cpu_subsys.dev_root, &dev_attr_dscr_default);
        }
 }
+
 #endif /* CONFIG_PPC64 */
 
 #ifdef HAS_PPC_PMC_PA6T