Commit
1ec9dd80bedc ("MIPS: CPS: Detect CPUs in secondary clusters")
added a check in cps_boot_secondary() that the secondary being booted is
in the same cluster as the CPU running this code. This check is
performed using current_cpu_data without disabling preemption. As such
when CONFIG_PREEMPT=y, a BUG is triggered:
[ 57.991693] BUG: using smp_processor_id() in preemptible [
00000000] code: hotplug/1749
<snip>
[ 58.063077] Call Trace:
[ 58.065842] [<
8040cdb4>] show_stack+0x84/0x114
[ 58.070830] [<
80b11b38>] dump_stack+0xf8/0x140
[ 58.075796] [<
8079b12c>] check_preemption_disabled+0xec/0x118
[ 58.082204] [<
80415110>] cps_boot_secondary+0x84/0x44c
[ 58.087935] [<
80413a14>] __cpu_up+0x34/0x98
[ 58.092624] [<
80434240>] bringup_cpu+0x38/0x114
[ 58.097680] [<
80434af0>] cpuhp_invoke_callback+0x168/0x8f0
[ 58.103801] [<
804362d0>] _cpu_up+0x154/0x1c8
[ 58.108565] [<
804363dc>] do_cpu_up+0x98/0xa8
[ 58.113333] [<
808261f8>] device_online+0x84/0xc0
[ 58.118481] [<
80826294>] online_store+0x60/0x98
[ 58.123562] [<
8062261c>] kernfs_fop_write+0x158/0x1d4
[ 58.129196] [<
805a2ae4>] __vfs_write+0x4c/0x168
[ 58.134247] [<
805a2dc8>] vfs_write+0xe0/0x190
[ 58.139095] [<
805a2fe0>] SyS_write+0x68/0xc4
[ 58.143854] [<
80415d58>] syscall_common+0x34/0x58
In reality we don't currently support running the kernel on CPUs not in
cluster 0, so the answer to cpu_cluster(¤t_cpu_data) will always
be 0, even if this task being preempted and continues running on a
different CPU. Regardless, the BUG should not be triggered, so fix this
by switching to raw_current_cpu_data. When multicluster support lands
upstream this check will need removing or changing anyway.
Fixes: 1ec9dd80bedc ("MIPS: CPS: Detect CPUs in secondary clusters")
Signed-off-by: Matt Redfearn <matt.redfearn@mips.com>
Reviewed-by: Paul Burton <paul.burton@mips.com>
CC: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/17563/
Signed-off-by: James Hogan <jhogan@kernel.org>