]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
x86/smpboot: Reference count on smpboot_setup_warm_reset_vector()
authorDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 1 Feb 2023 20:43:33 +0000 (20:43 +0000)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Thu, 2 Feb 2023 09:20:43 +0000 (09:20 +0000)
If we want to do parallel CPU bringup, we're going to need to set this up
and leave it until all CPUs are done. Might as well use the RTC spinlock
to protect the refcount, as we need to take it anyway.

[Usama Arif: fixed rebase conflict]
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: Usama Arif <usama.arif@bytedance.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
arch/x86/kernel/smpboot.c

index 55cad72715d991bd18bf0dfb7aa3bd757f4474f7..a19eddcdccc2c63fba335dda31a7de4854f32dd4 100644 (file)
@@ -121,17 +121,22 @@ int arch_update_cpu_topology(void)
        return retval;
 }
 
+
+static unsigned int smpboot_warm_reset_vector_count;
+
 static inline void smpboot_setup_warm_reset_vector(unsigned long start_eip)
 {
        unsigned long flags;
 
        spin_lock_irqsave(&rtc_lock, flags);
-       CMOS_WRITE(0xa, 0xf);
+       if (!smpboot_warm_reset_vector_count++) {
+               CMOS_WRITE(0xa, 0xf);
+               *((volatile unsigned short *)phys_to_virt(TRAMPOLINE_PHYS_HIGH)) =
+                       start_eip >> 4;
+               *((volatile unsigned short *)phys_to_virt(TRAMPOLINE_PHYS_LOW)) =
+                       start_eip & 0xf;
+       }
        spin_unlock_irqrestore(&rtc_lock, flags);
-       *((volatile unsigned short *)phys_to_virt(TRAMPOLINE_PHYS_HIGH)) =
-                                                       start_eip >> 4;
-       *((volatile unsigned short *)phys_to_virt(TRAMPOLINE_PHYS_LOW)) =
-                                                       start_eip & 0xf;
 }
 
 static inline void smpboot_restore_warm_reset_vector(void)
@@ -143,10 +148,12 @@ static inline void smpboot_restore_warm_reset_vector(void)
         * to default values.
         */
        spin_lock_irqsave(&rtc_lock, flags);
-       CMOS_WRITE(0, 0xf);
+       if (!--smpboot_warm_reset_vector_count) {
+               CMOS_WRITE(0, 0xf);
+               *((volatile u32 *)phys_to_virt(TRAMPOLINE_PHYS_LOW)) = 0;
+       }
        spin_unlock_irqrestore(&rtc_lock, flags);
 
-       *((volatile u32 *)phys_to_virt(TRAMPOLINE_PHYS_LOW)) = 0;
 }
 
 /*