Re: [PATCH v5] riscv: disable local interrupts and stop other CPUs before reboot/shutdown

From: Frédéric Mahé

Date: Mon Nov 09 2026 - 06:02:38 EST


On Wed, Nov 04, 2026 at 07:05:40AM +0000, Troy Mitchell wrote:
> Specifically, under CONFIG_PREEMPT_RCU, rcu_read_lock() does not increment
> the preempt_count. If local interrupts remain enabled, the environment
> is not guaranteed to be atomic. This can lead to a context misidentification
> within generic kernel teardown code, causing it to incorrectly enter
> non-atomic paths (such as attempting to acquire sleeping locks), which
> results in fatal "scheduling while atomic" splats or system hangs.

On Banana Pi BPI-F3 (SpacemiT K1), v7.4-rc1 defconfig, every reboot warns:

WARNING: kernel/rcu/tree_plugin.h:330 at rcu_note_context_switch+0x46a/0x48a
...
spacemit_i2c_xfer_common+0x342/0x5f6
...
spacemit_p1_restart_handler+0x24/0x5a
do_kernel_restart+0x1e/0x26

With this patch the warning is gone (2/2 clean reboots, 2/2 warnings
without it). Testing done with the help of Claude (AI assistant).

Tested-by: Frédéric Mahé <frederic.mahe@xxxxxxxx>