Commit Graph

85 Commits

Author SHA1 Message Date
chao an 93ff6f9703 drivers/rptun: check the status before stop remote proc
Race condition if the remote proc is stoped during initialization phase

| #0  0x0249f959 in rpmsg_destroy_ept (ept=0xffffffc0) at open-amp/lib/rpmsg/rpmsg.c:376
| #1  0x024a938c in rpmsg_deinit_vdev (rvdev=0xf2303a48) at open-amp/lib/rpmsg/rpmsg_virtio.c:971
| #2  0x02117e33 in rptun_dev_stop (rproc=0xf2303a04, stop_ns=true) at rptun/rptun.c:891
| #3  0x021181d8 in rptun_do_ioctl (priv=0xf2303a00, cmd=11010, arg=0) at rptun/rptun.c:922
| #4  0x02119722 in rptun_ioctl_foreach (cpuname=0x0, cmd=11010, value=0) at rptun/rptun.c:1086
| #5  0x0211b9df in rptun_poweroff (cpuname=0x0) at rptun/rptun.c:1378
| #6  0x02053aa6 in board_power_off (status=0) at sim/sim_head.c:206
| #7  0x0253d65c in boardctl (cmd=65283, arg=0) at boardctl.c:400
| #8  0x021eb497 in cmd_poweroff (vtbl=0xef606280, argc=1, argv=0xef9b73e0) at nsh_syscmds.c:356
| #9  0x021cdb4d in nsh_command (vtbl=0xef606280, argc=1, argv=0xef9b73e0) at nsh_command.c:1164
| #10 0x021baa72 in nsh_execute (vtbl=0xef606280, argc=1, argv=0xef9b73e0, redirfile=0x0, oflags=0) at nsh_parse.c:845
| #11 0x021c6b0a in nsh_parse_command (vtbl=0xef606280, cmdline=0xef606708 "poweroff") at nsh_parse.c:2744
| #12 0x021c7166 in nsh_parse (vtbl=0xef606280, cmdline=0xef606708 "poweroff") at nsh_parse.c:2828
| #13 0x0221fa2f in nsh_session (pstate=0xef606280, login=1, argc=1, argv=0xef7a7860) at nsh_session.c:245
| #14 0x021f8c04 in nsh_consolemain (argc=1, argv=0xef7a7860) at nsh_consolemain.c:75
| #15 0x021b77eb in nsh_main (argc=1, argv=0xef7a7860) at nsh_main.c:74
| #16 0x02166ddf in nxtask_startup (entrypt=0x21b76ca <nsh_main>, argc=1, argv=0xef7a7860) at sched/task_startup.c:70
| #17 0x020b363c in nxtask_start () at task/task_start.c:134

Signed-off-by: chao an <anchao@xiaomi.com>
2023-11-07 18:27:05 +08:00
raiden00pl b565e28da3 Kconfigs: rename {Rpmsg|rpmsg} to RPMGS 2023-10-28 13:58:56 +08:00
chao an 3cadf6642a kernel: replace all usleep to nxsig_usleep in kernel space
syscall cannot be called from kernel space

Signed-off-by: chao an <anchao@xiaomi.com>
2023-10-25 15:46:03 +08:00
yinshengkai ddb87d3b86 clock: replace all up_perf_xx with perf_xx
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-02 16:11:43 +02:00
wanggang26 e930476b4b enable O_CLOEXEC explicit
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2023-09-22 13:51:00 +08:00
yintao f3c9a8643b nuttx: change RPTUNIOC_START and RPTUNIOC_STOP to synchronous
Support quit remote when server poweroff

Signed-off-by: yintao <yintao@xiaomi.com>
2023-09-20 00:42:02 +08:00
ligd 1f9fb5fce2 rptun: add rptun_update_rx() when device_created()
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-09-20 00:42:02 +08:00
ligd 378470f611 add remote poweroff support
Signed-off-by: yintao <yintao@xiaomi.com>
2023-09-20 00:42:02 +08:00
ligd 83a3b969a3 rptun: fix use after free caused by API wrong order
remove list delete from rptun_dev_stop

Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-08-03 10:53:49 -07:00
ligd 2fae0af914 rptun: metal_init only call once
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-08-03 10:53:49 -07:00
Xiang Xiao fc5e85da1b drivers: Format pointer through "%p" for kthread_create
to remove the unnecessary cast and unify the usage

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-07-30 23:40:59 +03:00
chao an 6ee9ec7656 build: add initial cmake build system
1. Update all CMakeLists.txt to adapt to new layout
2. Fix cmake build break
3. Update all new file license
4. Fully compatible with current compilation environment(use configure.sh or cmake as you choose)

------------------

How to test

From within nuttx/. Configure:

cmake -B build -DBOARD_CONFIG=sim/nsh -GNinja
cmake -B build -DBOARD_CONFIG=sim:nsh -GNinja
cmake -B build -DBOARD_CONFIG=sabre-6quad/smp -GNinja
cmake -B build -DBOARD_CONFIG=lm3s6965-ek/qemu-flat -GNinja

(or full path in custom board) :
cmake -B build -DBOARD_CONFIG=$PWD/boards/sim/sim/sim/configs/nsh -GNinja

This uses ninja generator (install with sudo apt install ninja-build). To build:

$ cmake --build build

menuconfig:

$ cmake --build build -t menuconfig

--------------------------

2. cmake/build: reformat the cmake style by cmake-format

https://github.com/cheshirekow/cmake_format

$ pip install cmakelang

$ for i in `find -name CMakeLists.txt`;do cmake-format $i -o $i;done
$ for i in `find -name *\.cmake`;do cmake-format $i -o $i;done

Co-authored-by: Matias N <matias@protobits.dev>
Signed-off-by: chao an <anchao@xiaomi.com>
2023-07-08 13:50:48 +08:00
Bowen Wang 69756f277e rptun_dump: do not acquire the lock when has hold the lock
Otherwise, system will crash again when call rptun_dump_all()
after has acquired the lock.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2023-06-17 19:38:39 +08:00
wangbowen6 41e399aa43 rptun: init the semtx before the thread/workqueue created
If the rptun driver set auto start, the smetx may has been used
in rptun_notify_wait() but not inited.

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2023-06-17 19:38:39 +08:00
wangming9 a7fc26124d arch/arm64: the arm64 perf interface supports pmu
Summary:
- Support arm64 pmu api, Currently only the cycle counter function is supported.
- Using ARM64 PMU hardware capability to implement perf interface, modify all
  perf interface related code.
- Support for pmu init under smp.

Signed-off-by: wangming9 <wangming9@xiaomi.com>
2023-04-10 16:23:49 -03:00
ligd 8b078d261f rptun: fix rptun_start() failed
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-02-23 22:49:47 +08:00
chao an 4c8d244fae sched/getpid: replace syscall getpid/tid/ppid() to kernel version
NuttX kernel should not use the syscall functions, especially after
enabling CONFIG_SCHED_INSTRUMENTATION_SYSCALL, all system functions
will be traced to backend, which will impact system performance.

Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-02 10:33:01 +08:00
Gustavo Henrique Nihei e6b204f438 nuttx: Use MIN/MAX definitions from "sys/param.h"
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2023-02-01 23:47:44 +08:00
ligd 5b22eba0bd rptun ping: fix warning when open CONFIG_SYSTEM_TIME64
rptun/rptun_ping.c: In function 'rptun_ping':
rptun/rptun_ping.c:171:20: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'time_t' {aka 'long long int'} [-Werror=format=]
  171 |   syslog(LOG_INFO, "avg: s %" PRIu32 ", ns %ld\n", ts.tv_sec, ts.tv_nsec);
      |                    ^~~~~~~~~~                      ~~~~~~~~~
      |                                                      |
      |

Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-01-17 10:59:59 +08:00
Xiang Xiao 779a610ca3 Remove the unnecessary NULL fields in global instance definition of file_operations
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-04 00:32:13 +02:00
ligd 8aa5145273 rptun: fix race-condition on g_rptun_cb & g_rptun_priv
both rptun_dev_start() & rpmsg_register_callback() will use
these two lists

Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-11-11 20:04:33 +08:00
ligd f599527e1e rptun: fix rptun sem post too much
_assert
/media/liangchaozhong/ssd/86v1ap/nuttx/libs/libc/assert/lib_assert.c:36
nxsem_post
/media/liangchaozhong/ssd/86v1ap/nuttx/sched/semaphore/sem_post.c:91 (discriminator 1)
rptun_wakeup_rx
/media/liangchaozhong/ssd/86v1ap/nuttx/drivers/rptun/rptun.c:374
rpmsg_virtio_rx_callback
/media/liangchaozhong/ssd/86v1ap/nuttx/openamp/open-amp/lib/rpmsg/rpmsg_virtio.c:377
rproc_virtio_notified
/media/liangchaozhong/ssd/86v1ap/nuttx/openamp/open-amp/lib/remoteproc/remoteproc_virtio.c:342
remoteproc_get_notification
/media/liangchaozhong/ssd/86v1ap/nuttx/openamp/open-amp/lib/remoteproc/remoteproc.c:998
nxtask_start
/media/liangchaozhong/ssd/86v1ap/nuttx/sched/task/task_start.c:129

Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-11-11 20:04:33 +08:00
yinshengkai 85f727f232 tools: replace INCDIR to Makefile variable
In the past, header file paths were generated by the incdir command
Now they are generated by concatenating environment variables

In this way, when executing makefile, no shell command will be executed,
it will improve the speed of executing makfile
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2022-11-03 19:59:55 +08:00
anjiahao 5724c6b2e4 sem:remove sem default protocl
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-10-22 14:50:48 +08:00
ligd 8c1fd1df81 rptun: update rptun to openamp 2022.04.0
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-08-03 01:22:53 +08:00
ligd c2c1358fc7 rptun: handle uint16_t overflow
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-08-03 01:22:53 +08:00
ligd e368ce6c07 rptun: add buffer check in RX IRQ
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-08-03 01:22:53 +08:00
ligd cf22dd8688 rptun: divide notify msg
For notify callback has two conditions:
1. new data coming
2. return buffer coming

divide these two msgs

Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-08-03 01:22:53 +08:00
ligd 886e10ba3c rptun: unify name
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-08-03 01:22:53 +08:00
Xiang Xiao a9171c77ac drivers/rptun: Add const to image_store_ops and remoteproc_ops
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-08-03 01:22:53 +08:00
ligd 5dcc905f27 rptun: change lock to recursive lock
[ap] [ 6] [<0x2c351a18>] arm_switchcontext+0xc/0x10
[ap] [ 6] [<0x2c321b36>] sem_wait+0x5a/0xbc
[ap] [ 6] [<0x2c333d68>] rptun_ns_bind+0x2c/0x128
[ap] [ 6] [<0x2c5f863c>] rpmsg_virtio_ns_callback+0x9c/0x140
[ap] [ 6] [<0x2c5f84a6>] rpmsg_virtio_rx_callback+0xba/0x1b4
[ap] [ 6] [<0x2c5f7b38>] rproc_virtio_notified+0x44/0x5c
[ap] [ 6] [<0x2c5f7504>] remoteproc_get_notification+0x1c/0x2c
[ap] [ 6] [<0x2c33432c>] rptun_wait_tx+0x11c/0x160
[ap] [ 6] [<0x2c5f8734>] rpmsg_virtio_get_tx_payload_buffer+0x54/0x100
[ap] [ 6] [<0x2c5f87f2>] rpmsg_virtio_send_offchannel_raw+0x12/0x6c
[ap] [ 6] [<0x2c321b4c>] sem_wait+0x70/0xbc
[ap] [ 6] [<0x2c5f8166>] rpmsg_create_ept+0x102/0x1a4
[ap] [ 6] [<0x2c5eafcc>] rpmsgfs_device_created+0x44/0x5c
[ap] [ 6] [<0x2c33407c>] rptun_dev_start.isra.0+0x218/0x3ac
[ap] [ 6] [<0x2c3343f4>] rptun_thread+0x84/0x164
[ap] [ 6] [<0x2c323762>] nxtask_start+0x3a/0x60

Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-27 20:36:51 +08:00
ligd 8a3683fb9f rptun: add ns_match callback to resolve rptun deadlock
thread A: accept -> net_lock -> socket_rpmsg_accept
          -> rpmsg_register_callabck -> rptun_lock
thread B: ns_bind -> rpmsg_socket_ns_bind -> get_tx_payload_buffer
          -> rptun_wait_tx -> usrsock_rpmsg_ept_cb -> usrsockdev_write
          -> net_lock -> deadlock

fix:
add ns_match callback

Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-27 20:36:51 +08:00
ligd 033cd4d7df rptun: use seperated lock
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-27 20:36:51 +08:00
ligd 0017758fc1 rptun: add dump vring info support
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-27 20:36:51 +08:00
ligd a014a19f0e rptun_ping: add sleep param to rptun_ping
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-27 20:36:51 +08:00
anjiahao f9bcf1d645 drivers:rptun use strlcpy inside of strcpy
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-07-27 20:36:51 +08:00
ligd 434c49f282 rptun_dump: use METAL_LOG_EMERGENCY log level
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-26 09:36:05 +08:00
ligd 4a9bd26317 rptun: merge rptun_ioctl & rptun_ops to one
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-26 09:36:05 +08:00
ligd 631eb516c9 rptun_dump: don't get lock in IRQ handler
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-26 09:36:05 +08:00
anjiahao b88a8cf39f use rmutex inside of all repeated implementation
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-05-30 19:43:48 +08:00
ligd 86a496d6ff rptun: forward panic/reset to lowerhalf
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-03-30 10:00:07 +03:00
ligd 759898c090 rptun: add ping rpmsg support
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-03-30 10:00:07 +03:00
ligd a19aef4d36 rptun: enable rx interrupts for virtq
use wait_tx_buffer method need enable rx interrupts

Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-03-30 10:00:07 +03:00
ligd 1c7e59eafa rptun: pm_stay when send msg & pm_relax when all tx buffer returned
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-03-30 10:00:07 +03:00
ligd f0ba2f0286 rptun: add rptun dump support
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-03-30 10:00:07 +03:00
ligd 5599f4e24a rptun: divide shram to TX & RX
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-03-30 10:00:07 +03:00
ligd be49f6b87c rptun: add rpmsg_wait/post support for recursive dispatch
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-03-30 10:00:07 +03:00
ligd 7471d096cc rptun: add rptun_panic for both master & salve
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-03-30 10:00:07 +03:00
ligd c9404e2705 rptun: use HPWORK instead of thread
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-03-30 10:00:07 +03:00
ligd 3ab7ade4ba rptun: add rptun_reset support
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-03-30 10:00:07 +03:00