Re: [PATCH v2 1/6] MIPS: CM: Make cm_core_lock raw spinlocks
From: sashiko-bot
Date: Thu Nov 12 2026 - 07:48:45 EST
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] mips: cm: invalid wait context in mips_cpc_lock_other() under
cm_core_lock
--
commit 4e39a6ca6a7f0be5ae6999f6aa8d3e3e05b7551d
Author: Paul Burton <paulburton@xxxxxxxxxx>
MIPS: CM: Make cm_core_lock raw spinlocks
This commit converts the per-CPU cm_core_lock from spinlock_t to
raw_spinlock_t so that preemption remains disabled while accessing the
core-other CM register block on PREEMPT_RT kernels.
> diff --git a/arch/mips/kernel/mips-cm.c b/arch/mips/kernel/mips-cm.c
> index 7c9c5dc38823f..3bfe85e86a9a5 100644
> --- a/arch/mips/kernel/mips-cm.c
> +++ b/arch/mips/kernel/mips-cm.c
[ ... ]
> @@ -359,8 +359,8 @@ void mips_cm_lock_other(unsigned int cluster, unsigned int core,
> * race with us.
> */
> curr_core = cpu_core(¤t_cpu_data);
> - spin_lock_irqsave(&per_cpu(cm_core_lock, curr_core),
> - per_cpu(cm_core_lock_flags, curr_core));
> + raw_spin_lock_irqsave(&per_cpu(cm_core_lock, curr_core),
> + per_cpu(cm_core_lock_flags, curr_core));
>
> val = FIELD_PREP(CM_GCR_Cx_OTHER_CORENUM, core);
> }
[Severity: High]
Does converting cm_core_lock to raw_spinlock_t without also converting
cpc_core_lock cause an invalid wait context in mips_cpc_lock_other() on
systems with CM < 3?
mips_cpc_lock_other() is always called inside a mips_cm_lock_other() /
mips_cm_unlock_other() section (for example in boot_core() and
mips_smp_send_ipi_mask()). On CM < 3 systems, mips_cpc_lock_other()
acquires cpc_core_lock, which is still a spinlock_t:
arch/mips/kernel/mips-cpc.c:mips_cpc_lock_other() {
if (mips_cm_revision() >= CM_REV_CM3)
/* Systems with CM >= 3 lock the CPC via mips_cm_lock_other */
return;
preempt_disable();
curr_core = cpu_core(¤t_cpu_data);
spin_lock_irqsave(&per_cpu(cpc_core_lock, curr_core),
per_cpu(cpc_core_lock_flags, curr_core));
...
}
Taking spinlock_t cpc_core_lock while holding raw_spinlock_t cm_core_lock
triggers a lockdep invalid wait context warning and sleeps in atomic
context on PREEMPT_RT kernels.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261112-i6500-cm3-pmu-v2-0-cd2569571819@xxxxxxxxxxxx?part=1