forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 297b60346df8beafee954a0fd7c2d64f33f3b9bc
kernel/arch/x86/xen/smp_hvm.c
....@@ -1,4 +1,5 @@
11 // SPDX-License-Identifier: GPL-2.0
2
+#include <linux/thread_info.h>
23 #include <asm/smp.h>
34
45 #include <xen/events.h>
....@@ -19,6 +20,12 @@
1920 xen_vcpu_setup(0);
2021
2122 /*
23
+ * Called again in case the kernel boots on vcpu >= MAX_VIRT_CPUS.
24
+ * Refer to comments in xen_hvm_init_time_ops().
25
+ */
26
+ xen_hvm_init_time_ops();
27
+
28
+ /*
2229 * The alternative logic (which patches the unlock/lock) runs before
2330 * the smp bootup up code is activated. Hence we need to set this up
2431 * the core kernel is being patched. Otherwise we will have only
....@@ -32,9 +39,11 @@
3239 int cpu;
3340
3441 native_smp_prepare_cpus(max_cpus);
35
- WARN_ON(xen_smp_intr_init(0));
3642
37
- xen_init_lock_cpu(0);
43
+ if (xen_have_vector_callback) {
44
+ WARN_ON(xen_smp_intr_init(0));
45
+ xen_init_lock_cpu(0);
46
+ }
3847
3948 for_each_possible_cpu(cpu) {
4049 if (cpu == 0)
....@@ -49,9 +58,11 @@
4958 static void xen_hvm_cpu_die(unsigned int cpu)
5059 {
5160 if (common_cpu_die(cpu) == 0) {
52
- xen_smp_intr_free(cpu);
53
- xen_uninit_lock_cpu(cpu);
54
- xen_teardown_timer(cpu);
61
+ if (xen_have_vector_callback) {
62
+ xen_smp_intr_free(cpu);
63
+ xen_uninit_lock_cpu(cpu);
64
+ xen_teardown_timer(cpu);
65
+ }
5566 }
5667 }
5768 #else
....@@ -63,14 +74,19 @@
6374
6475 void __init xen_hvm_smp_init(void)
6576 {
66
- if (!xen_have_vector_callback)
67
- return;
68
-
77
+ smp_ops.smp_prepare_boot_cpu = xen_hvm_smp_prepare_boot_cpu;
6978 smp_ops.smp_prepare_cpus = xen_hvm_smp_prepare_cpus;
70
- smp_ops.smp_send_reschedule = xen_smp_send_reschedule;
79
+ smp_ops.smp_cpus_done = xen_smp_cpus_done;
7180 smp_ops.cpu_die = xen_hvm_cpu_die;
81
+
82
+ if (!xen_have_vector_callback) {
83
+#ifdef CONFIG_PARAVIRT_SPINLOCKS
84
+ nopvspin = true;
85
+#endif
86
+ return;
87
+ }
88
+
89
+ smp_ops.smp_send_reschedule = xen_smp_send_reschedule;
7290 smp_ops.send_call_func_ipi = xen_smp_send_call_function_ipi;
7391 smp_ops.send_call_func_single_ipi = xen_smp_send_call_function_single_ipi;
74
- smp_ops.smp_prepare_boot_cpu = xen_hvm_smp_prepare_boot_cpu;
75
- smp_ops.smp_cpus_done = xen_smp_cpus_done;
7692 }