forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/arch/powerpc/platforms/85xx/smp.c
....@@ -1,13 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Author: Andy Fleming <afleming@freescale.com>
34 * Kumar Gala <galak@kernel.crashing.org>
45 *
56 * Copyright 2006-2008, 2011-2012, 2015 Freescale Semiconductor Inc.
6
- *
7
- * This program is free software; you can redistribute it and/or modify it
8
- * under the terms of the GNU General Public License as published by the
9
- * Free Software Foundation; either version 2 of the License, or (at your
10
- * option) any later version.
117 */
128
139 #include <linux/stddef.h>
....@@ -20,9 +16,9 @@
2016 #include <linux/highmem.h>
2117 #include <linux/cpu.h>
2218 #include <linux/fsl/guts.h>
19
+#include <linux/pgtable.h>
2320
2421 #include <asm/machdep.h>
25
-#include <asm/pgtable.h>
2622 #include <asm/page.h>
2723 #include <asm/mpic.h>
2824 #include <asm/cacheflush.h>
....@@ -44,7 +40,6 @@
4440 u32 pir;
4541 };
4642
47
-#ifdef CONFIG_HOTPLUG_CPU
4843 static u64 timebase;
4944 static int tb_req;
5045 static int tb_valid;
....@@ -116,7 +111,8 @@
116111 local_irq_restore(flags);
117112 }
118113
119
-static void smp_85xx_mach_cpu_die(void)
114
+#ifdef CONFIG_HOTPLUG_CPU
115
+static void smp_85xx_cpu_offline_self(void)
120116 {
121117 unsigned int cpu = smp_processor_id();
122118
....@@ -216,15 +212,15 @@
216212
217213 /* Map the spin table */
218214 if (ioremappable)
219
- spin_table = ioremap_prot(*cpu_rel_addr,
220
- sizeof(struct epapr_spin_table), _PAGE_COHERENT);
215
+ spin_table = ioremap_coherent(*cpu_rel_addr,
216
+ sizeof(struct epapr_spin_table));
221217 else
222218 spin_table = phys_to_virt(*cpu_rel_addr);
223219
224220 local_irq_save(flags);
225221 hard_irq_disable();
226222
227
- if (qoriq_pm_ops)
223
+ if (qoriq_pm_ops && qoriq_pm_ops->cpu_up_prepare)
228224 qoriq_pm_ops->cpu_up_prepare(cpu);
229225
230226 /* if cpu is not spinning, reset it */
....@@ -256,6 +252,15 @@
256252 out_be64((u64 *)(&spin_table->addr_h),
257253 __pa(ppc_function_entry(generic_secondary_smp_init)));
258254 #else
255
+#ifdef CONFIG_PHYS_ADDR_T_64BIT
256
+ /*
257
+ * We need also to write addr_h to spin table for systems
258
+ * in which their physical memory start address was configured
259
+ * to above 4G, otherwise the secondary core can not get
260
+ * correct entry to start from.
261
+ */
262
+ out_be32(&spin_table->addr_h, __pa(__early_start) >> 32);
263
+#endif
259264 out_be32(&spin_table->addr_l, __pa(__early_start));
260265 #endif
261266 flush_spin_table(spin_table);
....@@ -287,7 +292,7 @@
287292 booting_thread_hwid = cpu_thread_in_core(nr);
288293 primary = cpu_first_thread_sibling(nr);
289294
290
- if (qoriq_pm_ops)
295
+ if (qoriq_pm_ops && qoriq_pm_ops->cpu_up_prepare)
291296 qoriq_pm_ops->cpu_up_prepare(nr);
292297
293298 /*
....@@ -490,21 +495,21 @@
490495 smp_85xx_ops.probe = NULL;
491496 }
492497
493
-#ifdef CONFIG_HOTPLUG_CPU
494498 #ifdef CONFIG_FSL_CORENET_RCPM
499
+ /* Assign a value to qoriq_pm_ops on PPC_E500MC */
495500 fsl_rcpm_init();
496
-#endif
497
-
498
-#ifdef CONFIG_FSL_PMC
501
+#else
502
+ /* Assign a value to qoriq_pm_ops on !PPC_E500MC */
499503 mpc85xx_setup_pmc();
500504 #endif
501505 if (qoriq_pm_ops) {
502506 smp_85xx_ops.give_timebase = mpc85xx_give_timebase;
503507 smp_85xx_ops.take_timebase = mpc85xx_take_timebase;
504
- ppc_md.cpu_die = smp_85xx_mach_cpu_die;
508
+#ifdef CONFIG_HOTPLUG_CPU
509
+ smp_85xx_ops.cpu_offline_self = smp_85xx_cpu_offline_self;
505510 smp_85xx_ops.cpu_die = qoriq_cpu_kill;
506
- }
507511 #endif
512
+ }
508513 smp_ops = &smp_85xx_ops;
509514
510515 #ifdef CONFIG_KEXEC_CORE