Repository navigation
drivers/rptun: replace the command mailbox with a status bitmap - #21542
Merged
Merged
Conversation
CV-Bowen
requested review from
GUIDINGLI,
anchao,
jerpelea,
raiden00pl and
xiaoxiang781216
as code owners
November 7, 2026 17:59
acassis
previously approved these changes
Nov 7, 2026
|
CV-Bowen
force-pushed
the
up/P57-rptun-status
branch
from
November 7, 2026 20:03
9b7bb9d to
ef71d8c
Compare
Add the blank line after declarations that tools/nxstyle requires, so later changes to these files pass checkpatch. No functional change. Signed-off-by: Bowen Wang <[email protected]>
enum boardioc_reset_cause_e and enum boardioc_softreset_subreason_e were only defined with CONFIG_BOARDCTL and CONFIG_BOARDCTL_RESET or CONFIG_BOARDCTL_RESET_CAUSE. rptun uses BOARDIOC_SOFTRESETCAUSE_* as the reset reason it exchanges with the peer, also on configurations without those options (e.g. sim:rpserver, icicle:rpmsg-ch1), so define them outside both guards. Signed-off-by: Bowen Wang <[email protected]>
A panic is one reason to reset the peer, so fold RPTUNIOC_PANIC, RPTUN_CMD_PANIC and ops->panic into RPTUNIOC_RESET, RPTUN_CMD_RESET and ops->reset, with BOARDIOC_SOFTRESETCAUSE_PANIC as the value. ops->reset and rptun_reset() take an unsigned long reason; the stm32h7 and nrf53 drivers signal their panic channel for that value. Signed-off-by: Bowen Wang <[email protected]>
Each rptun device registered its own panic notifier that reset only that peer. Register one notifier and reset all peers through rptun_ioctl_foreach(), as the reboot notifier added next does. Signed-off-by: Bowen Wang <[email protected]>
Register a reboot notifier, called last, that stops all peers on SYS_RESTART and SYS_POWER_OFF, so they shut down with this core. Signed-off-by: Bowen Wang <[email protected]>
The rptun ioctls have their own _RPTUNBASE now, so they no longer need to start at 100 to stay clear of the rpmsg ones. Signed-off-by: Bowen Wang <[email protected]>
The slave signalled that its resource table was ready with RPTUN_CMD_READY in the command words, which the status bitmap replaces. Write hdr.ver last instead, and have the master poll it. Signed-off-by: wangshaoxin <[email protected]> Signed-off-by: Bowen Wang <[email protected]>
sim_rptun stopped the peer with RPTUN_CMD_STOP in the command words, which the status bitmap replaces; the peer is stopped through the regular rptun stop path. Signed-off-by: wangshaoxin <[email protected]> Signed-off-by: Bowen Wang <[email protected]>
The master and slave command words in the resource table carried one command at a time and needed an ack, so a command could be lost and a core could not tell which state its peer was in. Replace them with a status bitmap per side: each core sets the bit of its reset reason (BOARDIOC_SOFTRESETCAUSE_*) and notifies the peer, which panics or resets accordingly. Signed-off-by: wangshaoxin <[email protected]>
ops->reset returns int, so rptun can tell whether the driver handled the reset. The stm32h7 and nrf53 drivers return OK. Signed-off-by: wangshaoxin <[email protected]> Signed-off-by: Bowen Wang <[email protected]>
Use ops->reset when the driver has one; if it returns -ENOTSUP, or there is none, set the reason in the status bitmap. Any other error is returned as is. Signed-off-by: wangshaoxin <[email protected]> Signed-off-by: Bowen Wang <[email protected]>
rptun_dev_reset() and rptun_check_peer_status() can run before the resource table is loaded; return instead of dereferencing a NULL rsc_table. Signed-off-by: wangshaoxin <[email protected]> Signed-off-by: Bowen Wang <[email protected]>
Return -EINVAL when the resource table is not ready and the result of ops->reset otherwise, instead of always reporting success. Signed-off-by: Bowen Wang <[email protected]>
The status bitmap lives in the resource table, which may be cacheable. Flush it after setting a bit and invalidate it before reading the peer's, with RPTUN_FLUSH()/RPTUN_INVALIDATE() (no-ops without CONFIG_OPENAMP_CACHE). Signed-off-by: Bowen Wang <[email protected]>
CV-Bowen
force-pushed
the
up/P57-rptun-status
branch
from
November 9, 2026 14:26
ef71d8c to
a5e8982
Compare
xiaoxiang781216
approved these changes
Nov 10, 2026
GUIDINGLI
approved these changes
Nov 11, 2026
xiaoxiang781216
pushed a commit
that referenced
this pull request
Nov 12, 2026
verdin-mx8mp:rpmsg runs from the 128 KB ITCM. After #21582 and #21542 the image does not fit (CI): arm-none-eabi-ld: region `flash' overflowed by 112 bytes The rpmsg configuration has CONFIG_LIBC_LOCALE from the nsh configuration of the board, where the C++ library needs it. The rpmsg configuration has no C++ and nothing in it uses locale support. Disable it: this saves 352 bytes. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]>
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.
Summary
Replace the rptun command mailbox in the resource table with a status
bitmap, and fold the panic API into reset.
include/sys/boardctl.h: define the reset cause typesunconditionally; rptun exchanges
BOARDIOC_SOFTRESETCAUSE_*with thepeer also without
CONFIG_BOARDCTL_RESET.RPTUNIOC_PANIC,RPTUN_CMD_PANICandops->panicinto resetwith
BOARDIOC_SOFTRESETCAUSE_PANICas the value;ops->resetandrptun_reset()take anunsigned longreason andops->resetreturns
int. stm32h7 and nrf53 are converted.restart/poweroff) for all rptun devices.
RPTUNIOC_*from 1 now that rptun has its own ioctl base.a core sets the bit of its reset reason, flushes it and notifies the
peer, which panics or resets. ivshmem uses
hdr.veras its readyflag and sim drops its stop command, both of which used the command
words.
ops->resetreturning-ENOTSUPfalls back to the bitmap.RPTUN_CMD_TIMEOUT_MSbecomesRPTUN_STATUS_TIMEOUT_MS.table is loaded, and return the reset result from
RPTUNIOC_RESET.arch rptun drivers.
Impact
API/ABI break for rptun users:
rptun_panic(),RPTUN_PANIC(),ops->panicandRPTUNIOC_PANICare removed (userptun_reset()with
BOARDIOC_SOFTRESETCAUSE_PANIC);ops->resetis nowint (*)(dev, unsigned long);RPTUNIOC_*values change. Both coresof a link must run this version, since the resource table words change
meaning. Kconfig:
RPTUN_CMD_TIMEOUT_MSis renamedRPTUN_STATUS_TIMEOUT_MS. nsh'srptuncommand and nxinit only need arebuild.
Testing
Host: Ubuntu 22.04.5 LTS x86_64, QEMU version 10.2.1, sim: cc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0, qemu-armv8a: aarch64-none-elf-gcc (Arm GNU Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205
Every commit builds without warnings on sim:rpserver,
qemu-armv8a:rpserver, qemu-armv7a:rpserver, nucleo-h745zi:nsh_cm7_rptun,
nucleo-h745zi:nsh_cm4_rptun, nrf5340-dk:rptun_cpuapp and
nrf5340-dk:rptun_cpunet.
Reset reasons over the status bitmap, qemu-armv8a:rpserver +
qemu-armv8a:rpproxy (ivshmem rptun), booted as in their README; from
the server:
reset ... 2(panic)FATAL: Panic by remote core: serverand panicsrptun reset /dev/rptun/proxy 0(user reboot) asserts on the proxy onmaster and with this PR alike: the peer runs
boardctl(BOARDIOC_RESET)from its rx notification in interrupt context, and the reboot notifier
of rpmsg_port_uart then waits on an event:
Deferring that
boardctl()to a work queue is left to a follow-up PR.Not run: stm32h7 and nrf53 on hardware (build only).
Baseline: No regression in rpmsg: sim:rpserver/rpproxy and qemu-armv8a:rpserver/rpproxy boot and pass the fixed rpmsg cases (dump, ping, rpmsgfs; 15/15). qemu-armv8a was built with LIBC_ENVPATH and BINFMT_CHECKEXEC disabled, which current master needs for nxinit to start nsh there; unrelated to this change.