Skip to content

Commit 2f1a6fb

Browse files
npigginIngo Molnar
authored andcommitted
power/suspend: Add function to disable secondaries for suspend
This adds a function to disable secondary CPUs for suspend that are not necessarily non-zero / non-boot CPUs. Platforms will be able to use this to suspend using non-zero CPUs. Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rafael J . Wysocki <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 77a5352 commit 2f1a6fb

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

include/linux/cpu.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,21 @@ static inline int disable_nonboot_cpus(void)
137137
return freeze_secondary_cpus(0);
138138
}
139139
extern void enable_nonboot_cpus(void);
140+
141+
static inline int suspend_disable_secondary_cpus(void)
142+
{
143+
return freeze_secondary_cpus(0);
144+
}
145+
static inline void suspend_enable_secondary_cpus(void)
146+
{
147+
return enable_nonboot_cpus();
148+
}
149+
140150
#else /* !CONFIG_PM_SLEEP_SMP */
141151
static inline int disable_nonboot_cpus(void) { return 0; }
142152
static inline void enable_nonboot_cpus(void) {}
153+
static inline int suspend_disable_secondary_cpus(void) { return 0; }
154+
static inline void suspend_enable_secondary_cpus(void) { }
143155
#endif /* !CONFIG_PM_SLEEP_SMP */
144156

145157
void cpu_startup_entry(enum cpuhp_state state);

kernel/kexec_core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ int kernel_kexec(void)
11501150
error = dpm_suspend_end(PMSG_FREEZE);
11511151
if (error)
11521152
goto Resume_devices;
1153-
error = disable_nonboot_cpus();
1153+
error = suspend_disable_secondary_cpus();
11541154
if (error)
11551155
goto Enable_cpus;
11561156
local_irq_disable();
@@ -1183,7 +1183,7 @@ int kernel_kexec(void)
11831183
Enable_irqs:
11841184
local_irq_enable();
11851185
Enable_cpus:
1186-
enable_nonboot_cpus();
1186+
suspend_enable_secondary_cpus();
11871187
dpm_resume_start(PMSG_RESTORE);
11881188
Resume_devices:
11891189
dpm_resume_end(PMSG_RESTORE);

kernel/power/hibernate.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ static int create_image(int platform_mode)
281281
if (error || hibernation_test(TEST_PLATFORM))
282282
goto Platform_finish;
283283

284-
error = disable_nonboot_cpus();
284+
error = suspend_disable_secondary_cpus();
285285
if (error || hibernation_test(TEST_CPUS))
286286
goto Enable_cpus;
287287

@@ -323,7 +323,7 @@ static int create_image(int platform_mode)
323323
local_irq_enable();
324324

325325
Enable_cpus:
326-
enable_nonboot_cpus();
326+
suspend_enable_secondary_cpus();
327327

328328
Platform_finish:
329329
platform_finish(platform_mode);
@@ -417,7 +417,7 @@ int hibernation_snapshot(int platform_mode)
417417

418418
int __weak hibernate_resume_nonboot_cpu_disable(void)
419419
{
420-
return disable_nonboot_cpus();
420+
return suspend_disable_secondary_cpus();
421421
}
422422

423423
/**
@@ -486,7 +486,7 @@ static int resume_target_kernel(bool platform_mode)
486486
local_irq_enable();
487487

488488
Enable_cpus:
489-
enable_nonboot_cpus();
489+
suspend_enable_secondary_cpus();
490490

491491
Cleanup:
492492
platform_restore_cleanup(platform_mode);
@@ -564,7 +564,7 @@ int hibernation_platform_enter(void)
564564
if (error)
565565
goto Platform_finish;
566566

567-
error = disable_nonboot_cpus();
567+
error = suspend_disable_secondary_cpus();
568568
if (error)
569569
goto Enable_cpus;
570570

@@ -586,7 +586,7 @@ int hibernation_platform_enter(void)
586586
local_irq_enable();
587587

588588
Enable_cpus:
589-
enable_nonboot_cpus();
589+
suspend_enable_secondary_cpus();
590590

591591
Platform_finish:
592592
hibernation_ops->finish();

kernel/power/suspend.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
428428
if (suspend_test(TEST_PLATFORM))
429429
goto Platform_wake;
430430

431-
error = disable_nonboot_cpus();
431+
error = suspend_disable_secondary_cpus();
432432
if (error || suspend_test(TEST_CPUS))
433433
goto Enable_cpus;
434434

@@ -458,7 +458,7 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
458458
BUG_ON(irqs_disabled());
459459

460460
Enable_cpus:
461-
enable_nonboot_cpus();
461+
suspend_enable_secondary_cpus();
462462

463463
Platform_wake:
464464
platform_resume_noirq(state);

0 commit comments

Comments
 (0)