Skip to content

power: reset: gpio-poweroff: Support GPIOs that can sleep - #7767

Merged
pelwell merged 1 commit into
raspberrypi:rpi-6.18.yfrom
pelwell:pi400
Nov 18, 2026
Merged

pelwell merged 1 commit into
raspberrypi:rpi-6.18.yfrom
pelwell:pi400

Conversation

@pelwell

@pelwell pelwell commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

SYS_OFF_MODE_POWER_OFF handlers are called from an atomic notifier chain under rcu_read_lock(), so driving a GPIO that can sleep (e.g. on an I2C expander or behind the firmware mailbox) from there triggers a "Voluntary context switch within RCU read-side critical section!" warning. This is seen on Pi 400, where the power-off GPIO is on the firmware-controlled expander.

If the GPIO can sleep, run the power-off sequence from the blocking SYS_OFF_MODE_POWER_OFF_PREPARE chain instead. A no-op POWER_OFF handler is also registered so that kernel_can_power_off() still returns true and a power-off request isn't turned into a halt.

Assisted-by: Claude Opus 5.5

@pelwell

pelwell commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

This PR squashes a kernel WARN when shutting down a Pi 400.

SYS_OFF_MODE_POWER_OFF handlers are called from an atomic notifier
chain under rcu_read_lock(), so driving a GPIO that can sleep (e.g. on
an I2C expander or behind the firmware mailbox) from there triggers a
"Voluntary context switch within RCU read-side critical section!"
warning. This is seen on Pi 400, where the power-off GPIO is on the
firmware-controlled expander.

If the GPIO can sleep, run the power-off sequence from the blocking
SYS_OFF_MODE_POWER_OFF_PREPARE chain instead. A no-op POWER_OFF
handler is also registered so that kernel_can_power_off() still
returns true and a power-off request isn't turned into a halt.

The downstream machine_halt() powers off rather than spinning, so make
kernel_halt() run the power-off prepare chain too; without it, a halt
on Pi 400 returns from machine_halt() and panics on exiting init.

Assisted-by: Claude Opus 5.5
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
@pelwell

pelwell commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Updated to include the same call in the halt code, otherwise the kernel panics and the unit needs a power-cycle - the power button is not sufficient.

@pelwell
pelwell merged commit 9d1f375 into raspberrypi:rpi-6.18.y Nov 18, 2026
11 of 12 checks passed
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Nov 23, 2026
kernel: power: reset: gpio-poweroff: Support GPIOs that can sleep
See: raspberrypi/linux#7767

kernel: IMX708 ccs and link frequency changes
See: raspberrypi/linux#7605

kernel: rp1-pio security audit
See: raspberrypi/linux#7771

kernel: wifi: brcmfmac: Enable WPA3 on Z2W
See: raspberrypi/linux#7762

kernel: staging: vchiq_core: Store a msg_queue entry before publishing it
See: raspberrypi/linux#7761

kernel: Workflow improvements
See: raspberrypi/linux#7779

kernel: Two patches supporting a soft AP running on a virtual interface
See: raspberrypi/linux#7778

kernel: Revert downstream commits made redundant upstream
See: raspberrypi/linux#7781

kernel: dt-bindings: Fix dt_binding_check errors in downstream bindings
See: raspberrypi/linux#7783
popcornmix added a commit to raspberrypi/rpi-firmware that referenced this pull request Nov 23, 2026
kernel: power: reset: gpio-poweroff: Support GPIOs that can sleep
See: raspberrypi/linux#7767

kernel: IMX708 ccs and link frequency changes
See: raspberrypi/linux#7605

kernel: rp1-pio security audit
See: raspberrypi/linux#7771

kernel: wifi: brcmfmac: Enable WPA3 on Z2W
See: raspberrypi/linux#7762

kernel: staging: vchiq_core: Store a msg_queue entry before publishing it
See: raspberrypi/linux#7761

kernel: Workflow improvements
See: raspberrypi/linux#7779

kernel: Two patches supporting a soft AP running on a virtual interface
See: raspberrypi/linux#7778

kernel: Revert downstream commits made redundant upstream
See: raspberrypi/linux#7781

kernel: dt-bindings: Fix dt_binding_check errors in downstream bindings
See: raspberrypi/linux#7783
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant