Skip to content

Commit 064231e

Browse files
paulburtonralfbaechle
authored andcommitted
MIPS: pm-cps: Prevent use of mips_cps_* without CPS SMP
These symbols will not be defined when CONFIG_MIPS_CPS=n, but although the CPS_PM_POWER_GATED state will never be used in that case the compiler doesn't have enough information to figure that out. Add checks which evaluate to a constant false for CONFIG_MIPS_CPS=n cases in order to help the compiler out & eliminate the symbol references. Signed-off-by: Paul Burton <paul.burton@imgtec.com> Reviewed-by: Markos Chandras <markos.chandras@imgtec.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/7278/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent 250dc03 commit 064231e

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

‎arch/mips/include/asm/smp-cps.h‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,19 @@ extern void mips_cps_core_init(void);
3131

3232
extern struct vpe_boot_config *mips_cps_boot_vpes(void);
3333

34-
extern bool mips_cps_smp_in_use(void);
35-
3634
extern void mips_cps_pm_save(void);
3735
extern void mips_cps_pm_restore(void);
3836

37+
#ifdef CONFIG_MIPS_CPS
38+
39+
extern bool mips_cps_smp_in_use(void);
40+
41+
#else /* !CONFIG_MIPS_CPS */
42+
43+
static inline bool mips_cps_smp_in_use(void) { return false; }
44+
45+
#endif /* !CONFIG_MIPS_CPS */
46+
3947
#else /* __ASSEMBLY__ */
4048

4149
.extern mips_cps_bootcfg;

‎arch/mips/kernel/pm-cps.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ int cps_pm_enter_state(enum cps_pm_state state)
149149

150150
/* Setup the VPE to run mips_cps_pm_restore when started again */
151151
if (config_enabled(CONFIG_CPU_PM) && state == CPS_PM_POWER_GATED) {
152+
/* Power gating relies upon CPS SMP */
153+
if (!mips_cps_smp_in_use())
154+
return -EINVAL;
155+
152156
core_cfg = &mips_cps_core_bootcfg[core];
153157
vpe_cfg = &core_cfg->vpe_config[current_cpu_data.vpe_id];
154158
vpe_cfg->pc = (unsigned long)mips_cps_pm_restore;
@@ -376,6 +380,10 @@ static void * __init cps_gen_entry_code(unsigned cpu, enum cps_pm_state state)
376380
memset(relocs, 0, sizeof(relocs));
377381

378382
if (config_enabled(CONFIG_CPU_PM) && state == CPS_PM_POWER_GATED) {
383+
/* Power gating relies upon CPS SMP */
384+
if (!mips_cps_smp_in_use())
385+
goto out_err;
386+
379387
/*
380388
* Save CPU state. Note the non-standard calling convention
381389
* with the return address placed in v0 to avoid clobbering

0 commit comments

Comments
 (0)