Commit 4c529a4a authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

x86/smp: PM/hibernate: Split arch_resume_nosmt()



Move the inner part of the arch_resume_nosmt() code into a separate
function called arch_cpu_rescan_dead_smt_siblings(), so it can be
used in other places where "dead" SMT siblings may need to be taken
online and offline again in order to get into deep idle states.

No intentional functional impact.

Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
Tested-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Link: https://patch.msgid.link/3361688.44csPzL39Z@rjwysocki.net


[ rjw: Prevent build issues with CONFIG_SMP unset ]
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent c0f69138
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -299,3 +299,27 @@ struct smp_ops smp_ops = {
	.send_call_func_single_ipi = native_send_call_func_single_ipi,
};
EXPORT_SYMBOL_GPL(smp_ops);

int arch_cpu_rescan_dead_smt_siblings(void)
{
	enum cpuhp_smt_control old = cpu_smt_control;
	int ret;

	/*
	 * If SMT has been disabled and SMT siblings are in HLT, bring them back
	 * online and offline them again so that they end up in MWAIT proper.
	 *
	 * Called with hotplug enabled.
	 */
	if (old != CPU_SMT_DISABLED && old != CPU_SMT_FORCE_DISABLED)
		return 0;

	ret = cpuhp_smt_enable();
	if (ret)
		return ret;

	ret = cpuhp_smt_disable(old);

	return ret;
}
EXPORT_SYMBOL_GPL(arch_cpu_rescan_dead_smt_siblings);
+6 −13
Original line number Diff line number Diff line
@@ -192,7 +192,8 @@ int relocate_restore_code(void)

int arch_resume_nosmt(void)
{
	int ret = 0;
	int ret;

	/*
	 * We reached this while coming out of hibernation. This means
	 * that SMT siblings are sleeping in hlt, as mwait is not safe
@@ -206,18 +207,10 @@ int arch_resume_nosmt(void)
	 * Called with hotplug disabled.
	 */
	cpu_hotplug_enable();
	if (cpu_smt_control == CPU_SMT_DISABLED ||
			cpu_smt_control == CPU_SMT_FORCE_DISABLED) {
		enum cpuhp_smt_control old = cpu_smt_control;

		ret = cpuhp_smt_enable();
		if (ret)
			goto out;
		ret = cpuhp_smt_disable(old);
		if (ret)
			goto out;
	}
out:
	ret = arch_cpu_rescan_dead_smt_siblings();

	cpu_hotplug_disable();

	return ret;
}
+3 −0
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ extern void cpu_maps_update_begin(void);
extern void cpu_maps_update_done(void);
int bringup_hibernate_cpu(unsigned int sleep_cpu);
void bringup_nonboot_cpus(unsigned int max_cpus);
int arch_cpu_rescan_dead_smt_siblings(void);

#else	/* CONFIG_SMP */
#define cpuhp_tasks_frozen	0
@@ -134,6 +135,8 @@ static inline void cpu_maps_update_done(void)

static inline int add_cpu(unsigned int cpu) { return 0;}

static inline int arch_cpu_rescan_dead_smt_siblings(void) { return 0; }

#endif /* CONFIG_SMP */
extern const struct bus_type cpu_subsys;