This is an automated email from the ASF dual-hosted git repository.

GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 960459c65034374913f75bf339b1d79f4e88797f
Author: Bowen Wang <[email protected]>
AuthorDate: Thu Sep 10 22:26:45 2026 +0800

    drivers/rpmsg: scale recursion limit with work queue stack size
    
    RPMSG_RECURSIVE_LIMIT defaulted to a fixed 8 regardless of
    RPMSG_WQUEUE_STACKSIZE, so a board with a small work queue stack can
    nest the dispatch chain 8 levels deep and overflow it.
    
    One level of nesting, taken when the tx buffer pool is empty:
    
      work_queue_dispatch -> rpmsg_virtio_rx_worker -> ept->cb
        -> rpmsg_send_offchannel_raw -> rpmsg_get_tx_payload_buffer
          -> rpmsg_virtio_get_tx_payload_buffer
            -> rpmsg_virtio_notify_wait -> rpmsg_tickwait
              -> work_queue_dispatch
    
    Framework cost per level, measured from the disassembly of the seven
    frames above (TriCore also spends one 64-byte CSA per call, carved
    out of the same task stack allocation):
    
      TriCore   80 B data + 448 B CSA = 528 B
      AArch64  528 B data             = 528 B
      ARM32    336 B data             = 336 B
    
    Derive the depth from RPMSG_WQUEUE_STACKSIZE at 2KB per level, which
    leaves room for the endpoint callback on top of that floor.
    
    Signed-off-by: Bowen Wang <[email protected]>
---
 drivers/rpmsg/Kconfig | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/rpmsg/Kconfig b/drivers/rpmsg/Kconfig
index 501d0c21308..812f1892ef1 100644
--- a/drivers/rpmsg/Kconfig
+++ b/drivers/rpmsg/Kconfig
@@ -69,6 +69,12 @@ config RPMSG_WQUEUE_NUMBER
 
 config RPMSG_RECURSIVE_LIMIT
        int "rpmsg recursive limit"
+       default 2 if RPMSG_WQUEUE_STACKSIZE <= 4096
+       default 3 if RPMSG_WQUEUE_STACKSIZE <= 6144
+       default 4 if RPMSG_WQUEUE_STACKSIZE <= 8192
+       default 5 if RPMSG_WQUEUE_STACKSIZE <= 10240
+       default 6 if RPMSG_WQUEUE_STACKSIZE <= 12288
+       default 7 if RPMSG_WQUEUE_STACKSIZE <= 14336
        default 8
        ---help---
                This macro sets the maximum recursion depth allowed in the

Reply via email to