Skip to content

drivers/rpmsg/rpmsg_virtio: return RPMSG_EOPNOTSUPP from notify_wait - #21582

Merged
GUIDINGLI merged 1 commit into
apache:masterfrom
CV-Bowen:up/P60-rpmsg-virtio-eopnotsupp
Nov 11, 2026
Merged

GUIDINGLI merged 1 commit into
apache:masterfrom
CV-Bowen:up/P60-rpmsg-virtio-eopnotsupp

Conversation

@CV-Bowen

@CV-Bowen CV-Bowen commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Summary

rpmsg_virtio_notify_wait() returns -EAGAIN when it cannot wait in
place (not in the recursive rx context). openamp's
rpmsg_virtio_get_tx_payload_buffer() sleeps and retries only when
notify_wait_cb() returns RPMSG_EOPNOTSUPP; any other value breaks
the loop. So a thread that asks for a tx buffer with wait = true
while the peer holds all of them fails at once and hits

metal_assert(!wait || rp_hdr != NULL)

in openamp/open-amp/lib/rpmsg/rpmsg_virtio.c. Return
RPMSG_EOPNOTSUPP so the caller waits for a buffer as intended.

Impact

Only the case where all tx buffers are in use changes: a waiting caller
now waits (up to openamp's RPMSG_TICK_COUNT) instead of asserting.
No API or Kconfig change.

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

Reproducer: sim:rpserver + sim:rpproxy with an out-of-tree
extension of drivers/rpmsg/rpmsg_test.c (not part of this PR). Its
existing hold-rx case leaves the peer holding every tx buffer; the added
case then calls rpmsg_get_tx_payload_buffer(ept, &space, true) and
round-trips the buffer with rpmsg_send_nocopy(). nsh on each side:
rpmsg test all.

tree server proxy
master + reproducer assert in rpmsg_virtio.c:303 assert in rpmsg_virtio.c:303
this PR + reproducer pass pass
before (server)
[   19.180252] [server] Rpmsg Test: start send

[   19.180283] [server] Rpmsg Test: tx buffer num=8 space=1520

[   19.180301] [server] Rpmsg Test: send finish

[   19.180342] [server] dump_assert_info: Assertion failed : at file: /openamp/open-amp/lib/rpmsg/rpmsg_virtio.c:303 task: sh

after (server)
[   19.180247] [server] Rpmsg Test: start send

[   19.180282] [server] Rpmsg Test: tx buffer num=8 space=1520

[   19.180301] [server] Rpmsg Test: send finish

[   19.230095] [server] Rpmsg Test: Test rpmsg send nocopy success!

[   19.240097] [server] Rpmsg Test: Test rpmsg send success!

[   19.240122] [server] Rpmsg Test: tx buffer num=8

[   19.240137] [server] Rpmsg Test: release buffer success!

No regression on the fixed rpmsg cases:

results.md

Baseline (test.sh, cases: baseline.yaml):

  • 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
  • tested: nuttx 18b578f apps 19a303645
  • qemu-armv8a:rpserver qemu-armv8a:rpproxy built with test-only overlay: disabled LIBC_ENVPATH BINFMT_CHECKEXEC
  • sim:rpserver + sim:rpproxy: PASS
    • uname -a (server)
    • rpmsg dump all (server)
    • rpmsg ping all 10 1024 3 0 (server)
    • uname -a (proxy)
    • rpmsg ping all 10 1024 3 0 (proxy)
    • mount -t rpmsgfs -o cpu=server,fs=/proc /sp (proxy)
    • cat /sp/version (proxy)
    • rpmsg dump all (proxy)
  • qemu-armv8a:rpserver + qemu-armv8a:rpproxy: PASS
    • uname -a (server)
    • uname -a (proxy)
    • rpmsg dump all (server)
    • rpmsg ping all 10 1024 3 0 (server)
    • rpmsg ping all 10 1024 3 0 (proxy)
    • mount -t rpmsgfs -o cpu=server,fs=/proc /sp (proxy)
    • cat /sp/version (proxy)

rpmsg_virtio_get_tx_payload_buffer() in openamp sleeps and retries only
when notify_wait_cb() returns RPMSG_EOPNOTSUPP. rpmsg_virtio_notify_wait()
returns -EAGAIN outside the recursive case, so the loop breaks at once
and a waiting caller hits

  metal_assert(!wait || rp_hdr != NULL)

whenever all tx buffers are in use. Return RPMSG_EOPNOTSUPP so the
caller waits for a buffer as intended.

Signed-off-by: Yongrong Wang <[email protected]>
Signed-off-by: Bowen Wang <[email protected]>
@github-actions github-actions Bot added Area: Drivers Drivers issues Size: XS The size of the change in this PR is very small labels Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

@GUIDINGLI
GUIDINGLI merged commit 6088a3d into apache:master Nov 11, 2026
53 checks passed
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Drivers Drivers issues Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants