nxsched_waitpid is only available when CONFIG_SCHED_WAITPID is
enabled. Wrap the call with #ifdef to fix the build error when
this option is disabled.
Signed-off-by: huojianchao <huojianchao@xiaomi.com>
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
debug.h is a NuttX-specific, non-POSIX header. Placing it in the
top-level include/ directory creates naming conflicts with external
projects that define their own debug.h.
This commit moves the canonical header to include/nuttx/debug.h,
following the NuttX convention for non-POSIX/non-standard headers,
and updates all in-tree references.
A backward-compatibility shim is left at include/debug.h that
emits a deprecation #warning and re-includes <nuttx/debug.h>,
allowing out-of-tree code to continue building while migrating.
Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
When the VIRTIO_RPMSG_F_CPUNAME feature is not negotiated, the driver
previously would crash due to DEBUGASSERT. This commit adds support
for a fallback mechanism:
1. Add rpmsg_virtio_probe_cpuname() API that accepts an optional cpuname
parameter to be used when VIRTIO_RPMSG_F_CPUNAME is not available.
2. Modify rptun driver to pass the cpuname from rptun device config
to rpmsg_virtio_probe_cpuname().
3. Refactor rptun device register/unregister to prioritize RPMSG device
handling before other virtio device types.
This ensures the system works correctly in scenarios where the remote
side does not support the VIRTIO_RPMSG_F_CPUNAME feature.
Signed-off-by: Bowen Wang <wangbowen6@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>
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>
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>
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>
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>
1. modify the da to FW_RSC_U32_ADDR_ANY, linux support daynamic calculate
the da when da == FW_RSC_U32_ADDR_ANY;
2. modify the carveout name to vdev%dbuffer, linux remoteproc framework
use these fixed name to handle the craveout for virtio devices;
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
1. Use reserved[0] filed in struct fw_rsc_vdev and the driver
master/slave to judge the device role;
2. Use struct fw_rsc_carveout in resource table to provide the
share memory to virtio driver side;
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Call rpmsg_virtio_probe() directly if device is is rpmsg virtio
and config CONFIG_DRIVERS_VIRTIO/VHOST are not enabled, so the
virtio/vhost frameworks related code do not need be compiled and
used, and can save the code size if user only want to use rpmsg
virtio device.
Signed-off-by: wangshaoxin <wangshaoxin@xiaomi.com>
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
When vring->da is specified, do not need reserve the memory for the vring,
so do not need increase the shmbase and leave more share memory to the
carveout.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Now rptun only as remoteproc and remoteproc_virtio transport layer,
because the rpmsg virtio device should be a stand alone virtio/vhost
driver in the virtio bus
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
The rpmsg_ioctl() function will first obtain the read lock before
traversing g_rpmsg, then the rpmsg_dev_destory function will try
to obtain the write lock.
At this time, rpmsg_ioctl does not release the read lock, resulting
in a deadlock.
To solve this problem, add a standardalone list for the rptun instance
to avoid hold the rpmsg lock when execute rptun_poweroff()
Backtrace:
Thread 14 nsh_main
0 0x4412b9da in up_switch_context (tcb=0xeac03380, rtcb=0xe7f02480) at sim/sim_switchcontext.c:95
1 0x43fbe5e4 in nxsem_wait_slow (sem=0x5179d570 <g_rpmsg_lock+16>) at semaphore/sem_wait.c:170
2 0x43fbeacf in nxsem_wait (sem=0x5179d570 <g_rpmsg_lock+16>) at semaphore/sem_wait.c:272
3 0x44671a26 in down_write (rwsem=0x5179d560 <g_rpmsg_lock>) at semaphore/sem_rw.c:248
4 0x4401e255 in rpmsg_device_destory (rpmsg=0xe7b03280) at rpmsg/rpmsg.c:469
5 0x4402f5fe in rptun_dev_stop (rproc=0xe7b033e4, stop_ns=true) at rptun/rptun.c:973
6 0x4402aa28 in rptun_ioctl (rpmsg=0xe7b03280, cmd=11109, arg=0) at rptun/rptun.c:661
7 0x4401ba1e in rpmsg_dev_ioctl_ (rpmsg=0xe7b03280, cmd=11109, arg=0) at rpmsg/rpmsg.c:137
8 0x4401ee88 in rpmsg_ioctl (cpuname=0x0, cmd=11109, arg=0) at rpmsg/rpmsg.c:562
9 0x44030cb0 in rptun_poweroff (cpuname=0x0) at rptun/rptun.c:1183
10 0x43f27be2 in board_power_off (status=0) at sim/sim_head.c:211
11 0x446fd933 in boardctl (cmd=65283, arg=0) at boardctl.c:401
12 0x44313b95 in cmd_poweroff (vtbl=0xe7600e80, argc=1, argv=0xe7824350) at nsh_syscmds.c:368
13 0x442d148c in nsh_command (vtbl=0xe7600e80, argc=1, argv=0xe7824350) at nsh_command.c:1275
14 0x442f65f5 in nsh_execute (vtbl=0xe7600e80, argc=1, argv=0xe7824350, param=0xe78242b0) at nsh_parse.c:716
15 0x44304fb4 in nsh_parse_command (vtbl=0xe7600e80, cmdline=0xe7601338 "poweroff") at nsh_parse.c:2809
16 0x44305a50 in nsh_parse (vtbl=0xe7600e80, cmdline=0xe7601338 "poweroff") at nsh_parse.c:2919
17 0x442bdc91 in nsh_session (pstate=0xe7600e80, login=1, argc=1, argv=0xe7814870) at nsh_session.c:246
18 0x442bbbe5 in nsh_consolemain (argc=1, argv=0xe7814870) at nsh_consolemain.c:75
19 0x4422b4bb in nsh_main (argc=1, argv=0xe7814870) at nsh_main.c:74
20 0x440ee098 in nxtask_startup (entrypt=0x4422b39a <nsh_main>, argc=1, argv=0xe7814870) at sched/task_startup.c:72
21 0x43fa1d6e in nxtask_start () at task/task_start.c:116
22 0x4412982c in pre_start () at sim/sim_initialstate.c:53
23 0x00000000 in ?? ()
Signed-off-by: wangshaoxin <wangshaoxin@xiaomi.com>
When execute 'rptun stop /dev/rptun/proxy' in the nsh,
rpmsg_deinit_vdev(&priv->rvdev) will set rvdev->vdev = NULL,
then the remoteproc_remove_virtio(priv->rvdev.vdev) input is NULL,
which will cause crash, the backtrace as follow, so we save the
rvdev->vdev pointer on vdev to solve this problem.
(gdb) bt
0 _assert (filename=0x4002aecc <nxrmutex_destroy+8> "\005D\220\v", linenum=1038, msg=0x400a26a8 "tx_vq", regs=0x400a2768) at misc/assert.c:827
1 0x4002a1db in __assert (filename=0x400a2204 "open-amp/lib/remoteproc/remoteproc.c", linenum=1038, msg=0x0) at assert/lib_assert.c:38
2 0x4006fd83 in remoteproc_remove_virtio (rproc=0xf3ea1880, vdev=0x0) at open-amp/lib/remoteproc/remoteproc.c:1038
3 0x4001b01d in rptun_dev_stop (rproc=0xf3ea1880, stop_ns=true) at rptun/rptun.c:979
4 0x4001a45e in rptun_ioctl (rpmsg=0xf3ea16d0, cmd=11109, arg=0) at rptun/rptun.c:661
5 0x40017246 in rpmsg_dev_ioctl_ (rpmsg=0xf3ea16d0, cmd=11109, arg=0) at rpmsg/rpmsg.c:138
6 0x4001728e in rpmsg_dev_ioctl (filep=0xf3d70a14, cmd=11109, arg=0) at rpmsg/rpmsg.c:153
7 0x4005ef51 in file_vioctl (filep=0xf3d70a14, req=11109, ap=0xf3d80f2c "\352\r\004@F\023\004@\230\020\330\363\353;\354\363(7\354", <incomplete sequence \363>)
at vfs/fs_ioctl.c:70
8 0x4005f2ff in ioctl (fd=3, req=11109) at vfs/fs_ioctl.c:294
9 0x40041049 in cmd_rpmsg_once (vtbl=0xf3ec3728, path=0xf3ec3beb "/dev/rptun/proxy", argv=0xf3d81098, rpmsg_cb=0x40041346 <cmd_rptun_cb>) at nsh_syscmds.c:616
10 0x400415c8 in cmd_rptun (vtbl=0xf3ec3728, argc=3, argv=0xf3d81098) at nsh_syscmds.c:766
11 0x40036024 in nsh_command (vtbl=0xf3ec3728, argc=3, argv=0xf3d81098) at nsh_command.c:1275
12 0x4003d044 in nsh_execute (vtbl=0xf3ec3728, argc=3, argv=0xf3d81098, param=0xf3d81078) at nsh_parse.c:716
13 0x4003efcc in nsh_parse_command (vtbl=0xf3ec3728, cmdline=0xf3ec3be0 "rptun") at nsh_parse.c:2809
14 0x4003f129 in nsh_parse (vtbl=0xf3ec3728, cmdline=0xf3ec3be0 "rptun") at nsh_parse.c:2919
15 0x40033ca4 in nsh_session (pstate=0xf3ec3728, login=1, argc=1, argv=0xf3d70ae0) at nsh_session.c:246
16 0x400338ea in nsh_consolemain (argc=1, argv=0xf3d70ae0) at nsh_consolemain.c:75
17 0x40033845 in nsh_main (argc=1, argv=0xf3d70ae0) at nsh_main.c:74
18 0x4002bc9f in nxtask_startup (entrypt=0x400337d0 <nsh_main>, argc=1, argv=0xf3d70ae0) at sched/task_startup.c:72
19 0x400077cc in nxtask_start () at task/task_start.c:116
20 0x40031d2f in pre_start () at sim/sim_initialstate.c:53
21 0x00000000 in ?? ()
Signed-off-by: mazhuang <mazhuang@xiaomi.com>
return -EAGAIN will cause rpmsg_virtio_get_tx_payload_buffer() in
OpenAMP break immediately, but should return to the sleep() logic
to wait buffer is return.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
fix build break:
ld: drivers/libdrivers.a(rptun_ivshmem.c.obj): in function `rptun_ivshmem_get_resource':
nuttx/drivers/rptun/rptun_ivshmem.c:215:(.text.rptun_ivshmem_get_resource+0xfc): undefined reference to `simple_addrenv_initialize'
ld: openamp/libmetal/lib/libmetal.a(io.c.obj): in function `metal_io_phys_to_offset_':
nuttx/openamp/libmetal/lib/system/nuttx/io.c:112:(.text.metal_io_phys_to_offset_+0xc): undefined reference to `up_addrenv_pa_to_va'
Signed-off-by: chao an <anchao.archer@bytedance.com>
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
1. add IS_ALIGNED() definitions for NuttX;
2. replace all the ALIGN_UP() and ALIGN_DOWN() to use common
align implementation;
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
notify_wait has been remove in remoteproc ops and virtio_dispatch and
has been moved to the struct rpmsg_virtio_device in new OpenAMP,
so change the rptun too,
Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
1. Add cmake support for rptun_serure;
2. Move rptun_secure.c before rptun_ivshmem.c in Make.defs to follow
the order in Kconfig.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Because locate the command at the end the resource table is unfriendly
when we want to support multi virtio devices instead only one virtio
rpmsg device.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Add more common command for rptun and rpmsg_virtio frameworks,
also modify the rptun and rpmsg_virtio driver to use the common
commands.
Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
Move the panic logic in common places, later we can move more logic to
the framework instead of having the drivers implement it repeatedly.
Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
headrx is very convient to check weather current core miss interrupt
by comparing the headrx with the rx vring avail.idx for slave side or
rx vring used.idx for master side.
So move headrx out of the CONFIG_RPTUN_PM range.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>