Repository navigation
power: reset: gpio-poweroff: Support GPIOs that can sleep - #7767
Merged
Merged
Conversation
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>
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. |
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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