Skip to content

Commit d720f98

Browse files
Qais YousefKAGA-KOKO
authored andcommitted
cpu/hotplug: Provide bringup_hibernate_cpu()
arm64 uses cpu_up() in the resume from hibernation code to ensure that the CPU on which the system hibernated is online. Provide a core function for this. [ tglx: Split out from the combo arm64 patch ] Signed-off-by: Qais Yousef <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Catalin Marinas <[email protected]> Cc: Will Deacon <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 5efbe6a commit d720f98

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

include/linux/cpu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ int add_cpu(unsigned int cpu);
9393
void notify_cpu_starting(unsigned int cpu);
9494
extern void cpu_maps_update_begin(void);
9595
extern void cpu_maps_update_done(void);
96+
int bringup_hibernate_cpu(unsigned int sleep_cpu);
9697

9798
#else /* CONFIG_SMP */
9899
#define cpuhp_tasks_frozen 0

kernel/cpu.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,6 +1275,29 @@ int add_cpu(unsigned int cpu)
12751275
}
12761276
EXPORT_SYMBOL_GPL(add_cpu);
12771277

1278+
/**
1279+
* bringup_hibernate_cpu - Bring up the CPU that we hibernated on
1280+
* @sleep_cpu: The cpu we hibernated on and should be brought up.
1281+
*
1282+
* On some architectures like arm64, we can hibernate on any CPU, but on
1283+
* wake up the CPU we hibernated on might be offline as a side effect of
1284+
* using maxcpus= for example.
1285+
*/
1286+
int bringup_hibernate_cpu(unsigned int sleep_cpu)
1287+
{
1288+
int ret;
1289+
1290+
if (!cpu_online(sleep_cpu)) {
1291+
pr_info("Hibernated on a CPU that is offline! Bringing CPU up.\n");
1292+
ret = cpu_up(sleep_cpu);
1293+
if (ret) {
1294+
pr_err("Failed to bring hibernate-CPU up!\n");
1295+
return ret;
1296+
}
1297+
}
1298+
return 0;
1299+
}
1300+
12781301
#ifdef CONFIG_PM_SLEEP_SMP
12791302
static cpumask_var_t frozen_cpus;
12801303

0 commit comments

Comments
 (0)