Commit Graph

17 Commits

Author SHA1 Message Date
lilei19
38f64f559d change strcpy to strlcpy
Signed-off-by: lilei19 <lilei19@xiaomi.com>
2023-02-24 12:15:40 +08:00
Jiuzhu Dong
5bd448825b driver/sensor: sync set buffer number to remote proc
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2023-01-27 00:37:49 +02:00
Jiuzhu Dong
c9c5940382 driver/sensor: using recursive lock to fix deadlock beacuse rptun reentrancy
nxsem_wait
/home/neo/projects/monkey/nuttx/arch/arm/src/../../../sched/semaphore/sem_wait.c:155 (discriminator 2)
sem_wait
/home/neo/projects/monkey/nuttx/arch/arm/src/../../../sched/semaphore/sem_wait.c:273
nxmutex_lock
/home/neo/projects/monkey/nuttx/include/nuttx/mutex.h:161
nxrmutex_lock.isra.0
/home/neo/projects/monkey/nuttx/include/nuttx/mutex.h:348
sensor_rpmsg_unsub_handler
/home/neo/projects/monkey/nuttx/arch/arm/src/../../../drivers/sensors/sensor_rpmsg.c:1048
rpmsg_virtio_rx_callback
/home/neo/projects/monkey/nuttx/arch/arm/src/../../../openamp/open-amp/lib/rpmsg/rpmsg_virtio.c:334
virtqueue_notification
/home/neo/projects/monkey/nuttx/arch/arm/src/../../../openamp/open-amp/lib/virtio/virtqueue.c:623
up_block_task
/home/neo/projects/monkey/nuttx/arch/arm/src/common/arm_blocktask.c:82 (discriminator 2)
nxsem_tickwait
/home/neo/projects/monkey/nuttx/arch/arm/src/../../../sched/semaphore/sem_tickwait.c:116
rptun_wait_tx
/home/neo/projects/monkey/nuttx/arch/arm/src/../../../drivers/rptun/rptun.c:522
rpmsg_virtio_wait_tx_buffer
/home/neo/projects/monkey/nuttx/include/openamp/rpmsg_virtio.h:120
sensor_rpmsg_push_event_one
/home/neo/projects/monkey/nuttx/arch/arm/src/../../../drivers/sensors/sensor_rpmsg.c:778
sensor_rpmsg_alloc_stub
/home/neo/projects/monkey/nuttx/arch/arm/src/../../../drivers/sensors/sensor_rpmsg.c:547
sensor_rpmsg_sub_handler
/home/neo/projects/monkey/nuttx/arch/arm/src/../../../drivers/sensors/sensor_rpmsg.c:991
rpmsg_virtio_rx_callback
/home/neo/projects/monkey/nuttx/arch/arm/src/../../../openamp/open-amp/lib/rpmsg/rpmsg_virtio.c:334

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2023-01-27 00:37:49 +02:00
anjiahao
5724c6b2e4 sem:remove sem default protocl
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-10-22 14:50:48 +08:00
Jiuzhu Dong
c4bed9eae9 driver/sensor: rename /dev/sensor -> /dev/uorb
because this directory contains all topics by uorb using, not just sensors.

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-08-08 19:45:52 +08:00
Xiang Xiao
bb16886568 Fix error: too few arguments to function 'rpmsg_register_callback'
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-08-01 20:23:11 -03:00
Xiang Xiao
9ffd09b1fb sensor/rpmsg: Swap "struct file *" and "struct sensor_lowerhalf_s *"
follow the change of sensor_ops_s

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-08-01 20:23:11 -03:00
Jiuzhu Dong
78381f9fc4 driver/sensor: fix deadlock about sensor_rpmsg
task1:
nuttx/arch/arm/src/common/arm_blocktask.c:151
nxsem_wait
nuttx/arch/arm/src/../../../sched/semaphore/sem_wait.c:155 (discriminator 2)
sem_wait
nuttx/arch/arm/src/../../../sched/semaphore/sem_wait.c:273
nxmutex_lock.lto_priv.2
nuttx/include/nuttx/mutex.h:161
sensor_rpmsg_push_event_one
nuttx/arch/arm/src/../../../drivers/sensors/sensor_rpmsg.c:748
up_unblock_task
nuttx/arch/arm/src/common/arm_unblocktask.c:75 (discriminator 2)
sensor_rpmsg_push_event
nuttx/arch/arm/src/../../../drivers/sensors/sensor_rpmsg.c:858
write
orb_publish_multi
nuttx/arch/arm/src/../../../../apps/system/uorb/uORB/uORB.c:188

task2:
nxrmutex_lock.isra.0
sensor_read
nuttx/arch/arm/src/../../../drivers/sensors/sensor.c:753
sem_post
nuttx/arch/arm/src/../../../sched/semaphore/sem_post.c:224
nxmutex_unlock.lto_priv.1
nuttx/include/nuttx/mutex.h:259
sensor_rpmsg_push_event_one
nuttx/arch/arm/src/../../../drivers/sensors/sensor_rpmsg.c:787
nxmutex_unlock.lto_priv.1
nuttx/include/nuttx/mutex.h:259
nuttx/arch/arm/src/../../../drivers/sensors/sensor.c:969
sensor_rpmsg_alloc_stub
nuttx/arch/arm/src/../../../drivers/sensors/sensor_rpmsg.c:549
sensor_rpmsg_advack_handler

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-08-02 01:28:56 +08:00
Jiuzhu Dong
ad20bd4bb3 driver/sensor: fix rpmsg send failed when buffer is NULL
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-08-02 01:28:56 +08:00
Jiuzhu Dong
5b91641a09 driver/sensor: add cmd SNIOC_UPDATED and remove readlast
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-08-02 01:28:56 +08:00
Jiuzhu Dong
fe1d83c41b driver/sensor: solve the deadlock problem caused by sensor_close
note: replace dev lock by upper driver lock

rptun:
sem_wait
sched/semaphore/sem_wait.c:273
nxmutex_lock
/home/neo/projects/monkey/nuttx/include/nuttx/mutex.h:161
sensor_close (wait upper driver lock)
drivers/sensors/sensor.c:509
sensor_rpmsg_free_stub (get dev lock)
drivers/sensors/sensor_rpmsg.c:546
sensor_rpmsg_unsub_handler
drivers/sensors/sensor_rpmsg.c:1025
rptun_thread

apps:
sem_wait
sched/semaphore/sem_wait.c:273
sensor_rpmsg_close (wait dev lock)
drivers/sensors/sensor_rpmsg.c:613
sensor_close (get upper driver lock)
drivers/sensors/sensor.c:512

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-08-02 01:28:56 +08:00
Jiuzhu Dong
48b4667318 driver/sensor: slove deadlock issue because ept/devlist using same lock
CHAMPION-6418
rptun sensor:
[ap] [ 5] [<0x2c352c68>] arm_switchcontext+0xc/0x10
[ap] [ 5] [<0x2c322eae>] sem_wait+0x5a/0xbc
[ap] [ 5] [<0x2c3376cc>] sensor_rpmsg_find_dev+0x8/0x78 (wait g_lock)
[ap] [ 5] [<0x2c338d96>] sensor_rpmsg_suback_handler+0xa/0x4c
[ap] [ 5] [<0x2c7630f6>] rpmsg_virtio_rx_callback+0xba/0x1b4
[ap] [ 5] [<0x2c762788>] rproc_virtio_notified+0x44/0x5c
[ap] [ 5] [<0x2c762154>] remoteproc_get_notification+0x1c/0x2c
[ap] [ 5] [<0x2c335576>] rptun_thread+0x6e/0x164
[ap] [ 5] [<0x2c324aba>] nxtask_start+0x3a/0x60

apps:(note: ipc buffer is busy, it's not enough for dual core.)
[ap] [26] [<0x2c323a5e>] nxsig_timedwait+0x8a/0x184
[ap] [26] [<0x2c324344>] nxsig_nanosleep+0x34/0xa4
[ap] [26] [<0x2c324446>] nxsig_usleep+0x26/0x38
[ap] [26] [<0x2c76338e>] rpmsg_virtio_get_tx_payload_buffer+0x5e/0x100 (wait ipc buffer)
[ap] [26] [<0x2c33775a>] sensor_rpmsg_advsub_one+0x1e/0xdc (get g_lock)
[ap] [26] [<0x2c338312>] sensor_rpmsg_open+0xee/0x178
[ap] [26] [<0x2c3365bc>] sensor_open+0x50/0x234
[ap] [26] [<0x2c749cb8>] open+0xc8/0x194
[ap] [26] [<0x2c375324>] orb_subscribe_multi+0x1c/0x94

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-08-02 01:28:56 +08:00
Jiuzhu Dong
bf6063cc04 driver/sensor/rpmsg: fix deadlock case: push event in ioctl_ack handler
using recursive mutex to fix this issue.

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-08-02 01:28:56 +08:00
Jiuzhu Dong
67f156c2f7 driver/sensor: add cpuname info about failed case
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-08-02 01:28:56 +08:00
Jiuzhu Dong
fa4cebce32 driver/sensor: support sensor data persist
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-08-02 01:28:56 +08:00
Jiuzhu Dong
2f5727b102 driver/sensor: add _SNIOCVALID check to command
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-08-02 01:28:56 +08:00
Jiuzhu Dong
c5f87bb5c6 driver/sensor: support access remote sensor by rpmsg
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-08-02 01:28:56 +08:00