forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/arch/powerpc/platforms/powermac/smp.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * SMP support for power macintosh.
34 *
....@@ -15,11 +16,6 @@
1516 *
1617 * Support for DayStar quad CPU cards
1718 * Copyright (C) XLR8, Inc. 1994-2000
18
- *
19
- * This program is free software; you can redistribute it and/or
20
- * modify it under the terms of the GNU General Public License
21
- * as published by the Free Software Foundation; either version
22
- * 2 of the License, or (at your option) any later version.
2319 */
2420 #include <linux/kernel.h>
2521 #include <linux/sched.h>
....@@ -34,13 +30,13 @@
3430 #include <linux/hardirq.h>
3531 #include <linux/cpu.h>
3632 #include <linux/compiler.h>
33
+#include <linux/pgtable.h>
3734
3835 #include <asm/ptrace.h>
3936 #include <linux/atomic.h>
4037 #include <asm/code-patching.h>
4138 #include <asm/irq.h>
4239 #include <asm/page.h>
43
-#include <asm/pgtable.h>
4440 #include <asm/sections.h>
4541 #include <asm/io.h>
4642 #include <asm/prom.h>
....@@ -53,6 +49,7 @@
5349 #include <asm/keylargo.h>
5450 #include <asm/pmac_low_i2c.h>
5551 #include <asm/pmac_pfunc.h>
52
+#include <asm/inst.h>
5653
5754 #include "pmac.h"
5855
....@@ -273,10 +270,6 @@
273270 int i, ncpus;
274271 struct device_node *dn;
275272
276
- /* We don't do SMP on the PPC601 -- paulus */
277
- if (PVR_VER(mfspr(SPRN_PVR)) == 1)
278
- return;
279
-
280273 /*
281274 * The powersurge cpu board can be used in the generation
282275 * of powermacs that have a socket for an upgradeable cpu card,
....@@ -403,21 +396,19 @@
403396 return 0;
404397 }
405398
406
-static struct irqaction psurge_irqaction = {
407
- .handler = psurge_ipi_intr,
408
- .flags = IRQF_PERCPU | IRQF_NO_THREAD,
409
- .name = "primary IPI",
410
-};
411
-
412399 static void __init smp_psurge_setup_cpu(int cpu_nr)
413400 {
401
+ unsigned long flags = IRQF_PERCPU | IRQF_NO_THREAD;
402
+ int irq;
403
+
414404 if (cpu_nr != 0 || !psurge_start)
415405 return;
416406
417407 /* reset the entry point so if we get another intr we won't
418408 * try to startup again */
419409 out_be32(psurge_start, 0x100);
420
- if (setup_irq(irq_create_mapping(NULL, 30), &psurge_irqaction))
410
+ irq = irq_create_mapping(NULL, 30);
411
+ if (request_irq(irq, psurge_ipi_intr, flags, "primary IPI", NULL))
421412 printk(KERN_ERR "Couldn't get primary IPI interrupt");
422413 }
423414
....@@ -664,13 +655,13 @@
664655
665656 #endif /* !CONFIG_PPC64 */
666657
667
-/* L2 and L3 cache settings to pass from CPU0 to CPU1 on G4 cpus */
668
-volatile static long int core99_l2_cache;
669
-volatile static long int core99_l3_cache;
670
-
671658 static void core99_init_caches(int cpu)
672659 {
673660 #ifndef CONFIG_PPC64
661
+ /* L2 and L3 cache settings to pass from CPU0 to CPU1 on G4 cpus */
662
+ static long int core99_l2_cache;
663
+ static long int core99_l3_cache;
664
+
674665 if (!cpu_has_feature(CPU_FTR_L2CR))
675666 return;
676667
....@@ -819,7 +810,7 @@
819810 * b __secondary_start_pmac_0 + nr*8
820811 */
821812 target = (unsigned long) __secondary_start_pmac_0 + nr * 8;
822
- patch_branch(vector, target, BRANCH_SET_LINK);
813
+ patch_branch((struct ppc_inst *)vector, target, BRANCH_SET_LINK);
823814
824815 /* Put some life in our friend */
825816 pmac_call_feature(PMAC_FTR_RESET_CPU, NULL, nr, 0);
....@@ -832,8 +823,7 @@
832823 mdelay(1);
833824
834825 /* Restore our exception vector */
835
- *vector = save_vector;
836
- flush_icache_range((unsigned long) vector, (unsigned long) vector + 4);
826
+ patch_instruction((struct ppc_inst *)vector, ppc_inst(save_vector));
837827
838828 local_irq_restore(flags);
839829 if (ppc_md.progress) ppc_md.progress("smp_core99_kick_cpu done", 0x347);
....@@ -921,12 +911,14 @@
921911
922912 mpic_cpu_set_priority(0xf);
923913
914
+ cleanup_cpu_mmu_context();
915
+
924916 return 0;
925917 }
926918
927919 #ifdef CONFIG_PPC32
928920
929
-static void pmac_cpu_die(void)
921
+static void pmac_cpu_offline_self(void)
930922 {
931923 int cpu = smp_processor_id();
932924
....@@ -936,12 +928,12 @@
936928 generic_set_cpu_dead(cpu);
937929 smp_wmb();
938930 mb();
939
- low_cpu_die();
931
+ low_cpu_offline_self();
940932 }
941933
942934 #else /* CONFIG_PPC32 */
943935
944
-static void pmac_cpu_die(void)
936
+static void pmac_cpu_offline_self(void)
945937 {
946938 int cpu = smp_processor_id();
947939
....@@ -1026,7 +1018,7 @@
10261018 #endif /* CONFIG_PPC_PMAC32_PSURGE */
10271019
10281020 #ifdef CONFIG_HOTPLUG_CPU
1029
- ppc_md.cpu_die = pmac_cpu_die;
1021
+ smp_ops->cpu_offline_self = pmac_cpu_offline_self;
10301022 #endif
10311023 }
10321024