drivers/rptun: refactor rptun to decoupling the rptun and rpmsg virtio, make rptun can work with any virtio devices#17816
Conversation
3b248c2
ec51629 to
3b248c2
Compare
bb33a34 to
62ff879
Compare
62ff879 to
16532d5
Compare
…work Now the sim, qemu-armv7a, qemu-armv8a can work with the new rptun framework. Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Support user pass it own heap struct to the mm_initialize_heap() to avoid the heap struct is reserved from the heap range Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Because heap->lock will use atomic operation and may can't use in share memory. Signed-off-by: Bowen Wnag <wangbowen6@xiaomi.com>
Because fs always need malloc the small memory for inode or filep, so enable the mempool by default to optimize the memory fragmentation issue. Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
To avoid add new parameters to the mm_initialize_heap() and mm_initialize_pool() Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Support enable/disable the kasan when initialize the heap. This requirement is from rptun, because rptun use share memory init the heap and share memory is precious, so we need disable the kasan feature for rptun's heap to save the share memory. Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com> Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
Previous patch is not corrected: 5518135: mm/mm_heap: add nokasan flag in mm_heap_config_s structure | https://gerrit.pt.mioffice.cn/c/vela/nuttx/+/5518135 Because rptun do not want part of the share memory is used by the struct mm_heap_s to: 1. Save the share memory; 2. Some platfrom can't use atomic operation at the share memory, and struct mm_heap_s contains a mutex. Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Memleak Bug fix, when file_read() failed in rptun_store_open(), memleak occur. Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Use share memory to send PANIC and RESET command to peer if the rptun driver do not support panic() and reset ops. Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com> Signed-off-by: ligd <liguiding1@xiaomi.com>
so we can mix rptun and rpmsg_virtio_lite in the same system. Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Support use the drivers provided stack to initialize the rptun kthread. Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
If there are multiple virtio devices in rsc, it must wait for the previous device to be created before creating the next one. In this case, if the driver configuration of a device is not be set Y, the subsequent virtio devices cannot be created. Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
Because virtio device do not need manager the share memory heap for now. But later we will make the virtio device be able to manager a standalone heap, so let this logic can be easily to extend. Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
1. call virtqueue_notification() only when buffer exist to avoid unnecessary calls to virtqueue callback. 2. call virtqueue_notification() only when vq != NULL, because rproc_virtio_notified() may be called when the virtqueues is not created: virtqueue created in the virtio/vhost driver but the virtio devices has been added to the remoteproc virtio devices list after the remoteproc transport layer create the virtio devices. Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
15a3a8c to
57810d0
Compare
57810d0 to
67d1dab
Compare
Rmove the old rptun document and add new folder to add the new rptun frameworks documents. Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
67d1dab to
da9da30
Compare
|
@acassis Of course, done. |
|
@acassis @jerpelea @raiden00pl Could you help review this PR? |
|
@GUIDINGLI @CV-Bowen this PR broke HCI over rpmsg on nrf53 on app core: |
|
@raiden00pl Could you enable |
|
@CV-Bowen there is nothing in debug messages.
on netcore it's not possible to run this command, because NSH with network stack doesn't fit on FLASH. One IPC interrupt happens on the netcore and appcore and rptun callback is executed, so IPC works. But for some reason nothing else happens |
|
@raiden00pl Seems rpmsg is initialized success but there are only the rpmsg name service and rpsmg ping services in this channel.
|
|
@CV-Bowen I found the issue with rptun: cpu names doesn't match for nrf53. But unfortunately the BLE net stack is broken on master and I can't check if this fix all issues |
Summary
This PR represents a comprehensive refactoring and modernization of the NuttX RPTUN (Remote Processor Tunnel) and RPMSG framework, introducing a clean separation between remoteproc, virtio, and RPMSG layers while adding virtio/vhost device support and improving cross-platform compatibility.
Bofore this PR
And the virtio drivers can only work with the virtio mmio/pci transport layer so it can only work in the virtualization environment.
After this PR
Based on this PR, we implemented cross-core communication for VirtIO Devices and can achieve better performance in cross-core communication compared with the rpmsg based communication.
Major Architectural Changes:
RPTUN Framework Refactoring (~935 lines refactored, net -143 lines):
Removed RPMSG virtio device from RPTUN core, positioning RPTUN purely as remoteproc and remoteproc_virtio transport layer
Removed power management code to simplify architecture (-139 lines)
Added debug configuration macros and Kconfig options (+50 lines)
Optimized code size by calling rpmsg_virtio_probe() directly in RPTUN
RPMSG Virtio Common Implementation (+701 lines):
Added standalone rpmsg_virtio.c providing common RPMSG virtio implementation
New public API in include/nuttx/rpmsg/rpmsg_virtio.h
Enables RPMSG virtio devices to exist as independent virtio/vhost drivers
Virtio/Vhost RPMSG Device Support (+272 lines):
Added virtio-rpmsg and vhost-rpmsg device drivers
Enables RPMSG communication over standard virtio bus
Fixed vhost-rng compile errors and CMake typos
OpenAMP Integration Enhancements:
Added mm_priv field to struct virtio_device for memory management
Enhanced remoteproc virtio to support multiple virtio device types
Added virtio_alloc_buf() for shared memory allocation in RPMSG virtio
Synchronized virtio RPMSG config with Linux standards
Improved CMake support for OpenAMP header inclusion
Multi-Architecture RPTUN Port (+89 insertions, -26 deletions):
Ported all chip-specific RPTUN drivers to new framework:
ARM: mx8mp, nrf53, stm32h7
RISC-V: k230, qemu-rv
Simulator: sim_rptun, sim_rpmsg_virtio
Other: rptun_ivshmem, rptun_bmp
Updated resource tables to use fw_rsc_carveout for shared memory
Simulator Reliability Improvements:
Fixed shared memory initialization race condition
Added host_kill() API to properly terminate proxy cores
Moved rptun_boot() to work queue to prevent deadlocks
Removed unnecessary command initialization
Configuration Updates (+16 lines):
Refreshed sim/qemu RPMSG configs for new framework:
boards/sim/sim/sim/configs/{rpproxy,rpserver}
boards/arm/qemu/qemu-armv7a/configs/{rpproxy,rpserver}
boards/arm64/qemu/qemu-armv8a/configs/{rpproxy,rpserver}
Benefits:
Clear separation between remoteproc, virtio, and RPMSG layers
Impact
All boards that use the rptun framework
Testing
qemu-armv7a:rpserver and rpproxy
qemu-armv8a:rpserver and rpproxy
sim:rpserver and rpproxy
nucleo-h745zi:nsh_cm7_rptun and nsh_cm4_rptun
qemu-armv8a test log:
qemu-armv7a test log:
nucleo-h745zi test log: