Skip to content

Commit 9ed0985

Browse files
committed
x86: intel_epb: Take CONFIG_PM into account
Commit b9c273b ("PM / arch: x86: MSR_IA32_ENERGY_PERF_BIAS sysfs interface") caused kernels built with CONFIG_PM unset to crash on systems supporting the Performance and Energy Bias Hint (EPB), because it attempts to add files to sysfs directories that don't exist on those systems. Prevent that from happening by taking CONFIG_PM into account so that the code depending on it is not compiled at all when it is not set. Fixes: b9c273b ("PM / arch: x86: MSR_IA32_ENERGY_PERF_BIAS sysfs interface") Reported-by: Ido Schimmel <[email protected]> Tested-by: Ido Schimmel <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]> Acked-by: Ingo Molnar <[email protected]>
1 parent 8f5e823 commit 9ed0985

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

arch/x86/kernel/cpu/intel_epb.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ static void intel_epb_restore(void)
9797
wrmsrl(MSR_IA32_ENERGY_PERF_BIAS, (epb & ~EPB_MASK) | val);
9898
}
9999

100+
#ifdef CONFIG_PM
100101
static struct syscore_ops intel_epb_syscore_ops = {
101102
.suspend = intel_epb_save,
102103
.resume = intel_epb_restore,
@@ -193,6 +194,25 @@ static int intel_epb_offline(unsigned int cpu)
193194
return 0;
194195
}
195196

197+
static inline void register_intel_ebp_syscore_ops(void)
198+
{
199+
register_syscore_ops(&intel_epb_syscore_ops);
200+
}
201+
#else /* !CONFIG_PM */
202+
static int intel_epb_online(unsigned int cpu)
203+
{
204+
intel_epb_restore();
205+
return 0;
206+
}
207+
208+
static int intel_epb_offline(unsigned int cpu)
209+
{
210+
return intel_epb_save();
211+
}
212+
213+
static inline void register_intel_ebp_syscore_ops(void) {}
214+
#endif
215+
196216
static __init int intel_epb_init(void)
197217
{
198218
int ret;
@@ -206,7 +226,7 @@ static __init int intel_epb_init(void)
206226
if (ret < 0)
207227
goto err_out_online;
208228

209-
register_syscore_ops(&intel_epb_syscore_ops);
229+
register_intel_ebp_syscore_ops();
210230
return 0;
211231

212232
err_out_online:

0 commit comments

Comments
 (0)