Commit Graph

7300 Commits

Author SHA1 Message Date
yukangzhi bcddaa59a9 drivers/pipe: fix POLLHUP handling in poll()
For POLICY_0, when a pipe only has a reader and no writer,
if the pipe is empty, set POLLHUP.

For POLICY_1, when a pipe only has a reader but no writer,
if the pipe is empty, POLLHUP will not be set.

This change corrects poll() behavior to match the two pipe policies.
No API changes.

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-01-22 22:09:01 +08:00
Bowen Wang ccf660ce10 drivers/rpmsg: use explicit NULL comparisons for pointer checks
Replace implicit pointer checks (!ptr and ptr) with explicit
NULL comparisons (ptr == NULL and ptr != NULL) to follow
NuttX coding style guidelines.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-22 22:08:32 +08:00
yintao 6a4feb4fc4 drivers/rpmsg_router: rename dst_ept to peer_ept
peer_ept is a better name than dst_ept

Signed-off-by: yintao <yintao@xiaomi.com>
2026-01-22 22:08:32 +08:00
yintao 7d61b7c43f drivers/rpmsg_router: fix race condition lead to use-after-fre
Should only destroy one side endpoint when receive one side
NS destroy message.

Before:
edge1           hub                  edge2
destroy -->     edge1 destroy
                edge2 destroy
                (used-after-free)
                edge2 destroy    <-- destroy
                edge1 destory

After
edge1           hub                  edge2
destroy -->     edge1 destroy
                edge2 destroy    <-- destroy

Signed-off-by: yintao <yintao@xiaomi.com>
2026-01-22 22:08:32 +08:00
yintao 31664023f9 drivers/rpmsg_router: avoid rpmsg:cpu failed to bind dest
nxsig_clockwait
/home/work/data/miui_codes/build_home_rom/nuttx/sched/signal/sig_timedwait.c:329 (discriminator 1)
nxsig_clockwait
/home/work/data/miui_codes/build_home_rom/nuttx/sched/signal/sig_timedwait.c:320
nxsig_nanosleep
/home/work/data/miui_codes/build_home_rom/nuttx/sched/signal/sig_nanosleep.c:96
nxsig_usleep
/home/work/data/miui_codes/build_home_rom/nuttx/sched/signal/sig_usleep.c:84
__metal_sleep_usec
/home/work/data/miui_codes/build_home_rom/nuttx/drivers/../include/metal/system/nuttx/sleep.h:27
rpmsg_device_destory
/home/work/data/miui_codes/build_home_rom/nuttx/drivers/rpmsg/rpmsg.c:473
rpmsg_port_unregister
/home/work/data/miui_codes/build_home_rom/nuttx/drivers/rpmsg/rpmsg_port.c:751
rpmsg_port_spi_process_packet
/home/work/data/miui_codes/build_home_rom/nuttx/drivers/rpmsg/rpmsg_port_spi.c:572
nxtask_start
/home/work/data/miui_codes/build_home_rom/nuttx/sched/task/task_start.c:111

Signed-off-by: yintao <yintao@xiaomi.com>
2026-01-22 22:08:32 +08:00
yintao 28e2ca5d23 drivers/rpmsg_router: Distinguish NS_CREATE or NS_ACK for rpmsg_router_edge
If ns_msg->flags == RPMSG_NS_CREATE_ACK, means already know peer's address
so direclty use usr_ept->dest_addr

Signed-off-by: yintao <yintao@xiaomi.com>
2026-01-22 22:08:32 +08:00
yintao 6e3f0b0a53 drivers/rpmsg_router: fix double free at rpmsg_router_hub_unbind
fist free when rpmsg_port_unregister at rpmsg spi thread
<free+12>
<rpmsg_router_hub_ept_release+6>
<rpmsg_ept_decref+28>
<rpmsg_unregister_endpoint+120>
<rpmsg_destroy_ept+40>
<rpmsg_router_hub_unbind+22>
<rpmsg_device_destory+172>
<rpmsg_port_unregister+26>

this thread will free r:droid and r:audio at last;
But in this process,
rpmsg_destroy_ept "r:droid" will send NS_destroy to audio;
audio will response NS_destroy to ap; if r:droid has not been
removed from the ept list yet, the rptun_audio thread on ap will
occur as follows:

3  0x103016fa in kasan_check_report
4  0x103018b6 in __asan_store4_noabort
5  0x106ca352 in metal_list_del
6             in rpmsg_unregister_endpoint
7  0x106ca77a in rpmsg_destroy_ept
8  0x102db232 in rpmsg_router_hub_unbind
9  0x106cabb2 in rpmsg_virtio_ns_callback
10 0x106cad5c in rpmsg_virtio_rx_callback
11 0x106cc190 in virtqueue_notification
12 0x106ca064 in rproc_virtio_notified
13 0x106c9ad0 in remoteproc_get_notification
14 0x102dd4ba in rptun_worker at rptun/rptun.c:334
15 rptun_worker (arg=<optimized out>) at rptun/rptun.c:328
16 0x102dd974 in rptun_thread  rptun/rptun.c:353
17 0x102cd558 in nxtask_start () at task/task_start.c:1

this will lead to r:audio be freed again.

Signed-off-by: yintao <yintao@xiaomi.com>
2026-01-22 22:08:32 +08:00
yintao e2e5827c88 drivers/rpmsg_router: Use rpmsg_send_offchannel_raw to fix stuck issue
Use rpmsg_send_offchannel_raw to fix stuck issue avoid getting stuck
when remote destroy ept.

When send messages from ap to android in Rptun thread, Android may
have sent NS_DESTROY through rpmsg_port and changed ept->dst to
RPMSG_ADDR_ANY in rpmsg_port_ns_callback; So rptun thread may be
stuck at this time because rpmsg_send detected dst_ept's dst_addr
is RPMSG_ADDR_ANY.

rpmsg_virtio_thread(rptun audio):
rpmsg_virtio_rx_callback -> rpmsg_router_cb -> rpmsg_send(dst_ept)
send to android

rpmsg_port_thread (android send NS_DESTROY):
rpmsg_port_ns_callback -> dst_ept->dest_addr = RPMSG_ADDR_ANY

Signed-off-by: yintao <yintao@xiaomi.com>
2026-01-22 22:08:32 +08:00
yintao f568f6b0bc drivers/rpmsg_router: user_ept's dst_addr should set to RPMSG_ADDR_ANY
when edge_ept received NS_DESTROY message to sync the behavior with
other rpmsg transport

if (ns_msg.flags == RPMSG_NS_DESTROY) {
	if (_ept)
		_ept->dest_addr = RPMSG_ADDR_ANY;
		...

Signed-off-by: yintao <yintao@xiaomi.com>
2026-01-22 22:08:32 +08:00
ligd 0a5940d9ab drivers/rpmsg_router: check hub ept ready before rpmsg_send pm msg
to avoid rpmsg_send() blocked when rpmsg channel is not ready

Signed-off-by: ligd <liguiding1@xiaomi.com>
2026-01-22 22:08:32 +08:00
yintao dc9c7e9d63 drivers/rpmsg_router: Modify return value when receive DESTROY cmd
It should return 0 if there are edge that have not been established
or have been destroyed at unbind

Signed-off-by: yintao <yintao@xiaomi.com>
2026-01-22 22:08:32 +08:00
guohao15 0af8d03d88 mtd/nvs: add nvs cache buffer
improve the speed of finding the target ate

Signed-off-by: guohao15 <guohao15@xiaomi.com>
2026-01-22 19:56:28 +08:00
likun17 d9aaaaf1c7 drivers/sensors: Waiting time optimized.
wait proxy timeout changed to 1 second.

Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-22 17:17:51 +08:00
likun17 19b3d66759 drivers/sensors: wait proxy logic optimization.
The interface for asynchronously calling sensor_rpmsg_ioctl
not waits for the proxy.

Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-22 17:17:51 +08:00
dongjiuzhu1 636264a7d6 drivers/sensors: wait proxy created when send ioctl message to remote.
since creating resources on the remote core takes time,
we need to wait for the remote core to return ack.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-01-22 17:17:51 +08:00
dongjiuzhu1 d61661e4c2 timers/rtc: check ioctl null pointer and return -ENOTTY
Add null pointer check for ioctl operations in RTC driver.
Return -ENOTTY when ioctl function pointer is NULL to prevent crashes.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-01-22 14:07:59 +08:00
dongjiuzhu1 9a0b42d4f0 drivers/rpmsgrtc: fix crash because list_node is not in server list
Fix potential crash when removing client from server list.
Add proper list initialization check before deletion operation.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-01-22 14:07:59 +08:00
dongjiuzhu1 1a87094e35 drivers/rpmsg_rtc: don't rpmsg send for some core
without rpmsg rtc client driver

Avoid sending rpmsg messages to cores that don't have RTC client driver.
Check endpoint availability before attempting to send messages.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-01-22 14:07:59 +08:00
dongjiuzhu1 37729ecb51 drivers/timer/rpmsg_rtc: export ept about rtc to remote cpu
Export rpmsg endpoint to allow remote CPU to access RTC services.
Simplify the initialization flow and remove unnecessary Kconfig options.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-01-22 14:07:59 +08:00
Bowen Wang e238804119 rpmsg/rpmsg_virtio: add rpmsg virtio common pm support
implement the pm feature in rpmsg virtio common part, now the rpmsg
virtio can use in the low power case.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-22 03:45:55 +08:00
Lars Kruse 21c19b7824 drivers/analog/mcp47x6: fix configuration command
Previously the ioctl-based configuration was not encoded properly.
It lacked the three command bits selecting the "set volatile
configuration" mode.
Thus, configuration the reference, power-down or gain resulted in no
change.

Now the configuration is properly applied.

The DAC value to be send is now combined with the proper command prefix
bits, too.
But this operation was already working, since the command prefix is zero.

Signed-off-by: Lars Kruse <devel@sumpfralle.de>
2026-01-22 00:12:37 +08:00
Côme VINCENT 34d3b06955 drivers/timers/capture: fix typo in capture.h
This commit fixes a typo in the capture.h header file. This is a
breaking change, but the fix is trivial (replace macro with new one).

Signed-off-by: Côme VINCENT <44554692+comejv@users.noreply.github.com>
2026-01-22 00:06:45 +08:00
hujun5 bb8d16f422 sched: add spinlock to sched_note_preemption and nxsched_critmon_preemption
Add spinlock protection to sched_note_preemption and nxsched_critmon_preemption.
Ensures thread-safe access to global state in preemption notification and critical
monitoring, preventing race conditions in SMP and interrupt contexts.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-21 20:29:55 +08:00
wangchengdong 303bc7411f sched/sched: add hrtimer support to drive the scheduler
Add hrtimer support to drive the scheduler.

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-20 06:55:15 +08:00
yangao1 9903b11656 drivers/rpmsg: remove unnecessary header files, revise make.def and cmake
Already copy the rpmsg_internal.h from openamp to the nuttx/include,
so do not need add the include patch for .c files.

Signed-off-by: yangao1 <yangao1@xiaomi.com>
Signed-off-by: wangshaoxin <wangshaoxin@xiaomi.com>
2026-01-19 23:14:53 +08:00
raiden00pl 1f8bb966c3 drivers/serial/Kconfig-16550: fix non-existent option
there is no SERIAL_DMA option, it was removed long time ago in:
0d203fd535

It should be SERIAL_TXDMA and SERIAL_RXDMA

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-01-19 16:12:25 +01:00
Bowen Wang 143c5715c0 drivers/rptun: it's not error when no carveout for virtio device
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>
2026-01-19 14:18:27 +08:00
Yongrong Wang 67ba360344 rptun.c: fix the problem of blocking the creation of virtio devices
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>
2026-01-19 14:18:27 +08:00
pangzhen1 42bf54b24c rptun: add configuring the stack of rptun as static
Support use the drivers provided stack to initialize the rptun
kthread.

Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
2026-01-19 14:18:27 +08:00
Bowen Wang e369bce787 drivers/rptun: add panic and reset method for new rptun framework
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>
2026-01-19 14:18:27 +08:00
Bowen Wang ffb18cd25a drivers/rptun: should free the image buffer if open failed
Memleak Bug fix, when file_read() failed in rptun_store_open(),
memleak occur.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-19 14:18:27 +08:00
Bowen Wang c724618705 drivers/rptun: should use KRN_HEAP to intialize the carveout heap
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>
2026-01-19 14:18:27 +08:00
Bowen Wang 239130c1fd mm/mm_heap: add nokasan flag in mm_heap_config_s structure
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>
2026-01-19 14:18:27 +08:00
Bowen Wang e686a3ac42 mm/mm_heap: use struct mm_heap_config_s to init the memory heap
To avoid add new parameters to the mm_initialize_heap() and
mm_initialize_pool()

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-19 14:18:27 +08:00
Bowen Wnag f456e0b637 drivers/rptun: move the heap out of the share memory
Because heap->lock will use atomic operation and may can't use in
share memory.

Signed-off-by: Bowen Wnag <wangbowen6@xiaomi.com>
2026-01-19 14:18:27 +08:00
Bowen Wang 2eaf5de3d9 drivers/vhost-rng: fix the vhost-rng compile error
1. Include the <nuttx/spinlock.h> beacause vhost-rng used spinlock
2. Remove the unused ret;

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-19 14:18:27 +08:00
Yanfeng Liu 01b308a146 drivers/vhost: fix cmake typos
This fixes filename typos in drivers/vhost/CMakeLists.txt

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2026-01-19 14:18:27 +08:00
Bowen Wang 4ded8df3d5 virtio and vhost-rpmsg: add virtio and vhost rpmsg device support
virtio and vhost rpmsg device as standalone device registered to
the virtio and vhost bus.

virtio-rpmsg and vhost-rpmsg use the common virtio_rpmsg_common.c
implementation in rpmsg dir.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-19 14:18:27 +08:00
Bowen Wang 6003369ceb rptun/rptun_ivshmem: use dynamic local and remote cpu name in rsc table
the local cpuname and remote cpuname for rpmsg virtio device should
not be fixed.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-19 14:18:27 +08:00
Bowen Wang 4326a8520d rptun/rptun_ivshmem: compaliable with linux remoteproc framework
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>
2026-01-19 14:18:27 +08:00
Bowen Wang ab8b6311ac drivers/rptun_ivshmem: port rptun_ivshmem to the new rptun framework
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>
2026-01-19 14:18:27 +08:00
Yongrong Wang 911ab7c55b drivers/rptun and rpmsg_virtio: remove cmd initialize
don't need initialize in sim

Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
2026-01-19 14:18:27 +08:00
Bowen Wang 728a61437a drivers/rptun_bmp: port rptun_bmp to the new rptun framework
rptun_bmp can work with the new rptun framework

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-19 14:18:27 +08:00
wangshaoxin c962bb0f5d drivers/rptun: call rpmsg_virtio_probe() in rptun to save code size
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>
2026-01-19 14:18:27 +08:00
Xiang Xiao d7f3e41b13 Revert "rptun/rptun_ivshmem:add restart cmd to reboot slave"
This reverts commit 4fa1c460d3.
to reducing the complexity of rptun driver.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-01-19 14:18:27 +08:00
Bowen Wang 109a3a090c drivers/rptun: do not reserve memory for vring when vring->da is specified
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>
2026-01-19 14:18:27 +08:00
Bowen Wang 7ba6425933 drivers/rptun: remove rpmsg virtio deivce in rptun
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>
2026-01-19 14:18:27 +08:00
Bowen Wang 7c840bc405 drivers/rptun: remove the power managerment code in rptun
Preparation for the rptun framework refacator

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-19 14:18:27 +08:00
Bowen Wang a98dc94f93 rpmsg/rpmsg_virtio: add rpmsg virtio common implementation
This is the virtio-rpmsg and vhost-rpmsg common implementation for
VirtIO-Rpmsg: drivers/virtio/virtio-rpmsg.c
Vhost-Rpmsg: drivers/vhost/vhost-rpmsg.c

Later we will seperate the rpmsg virtio from the rptun framework to
make the rpmsg virtio can work with all the virtio transport layer.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-19 14:18:27 +08:00
likun17 28661273a3 drivers/sensors: Added virtual sensor flag to prioritize reading
of driver information.

When the local core is a virtual sensor, attempt to retrieve
information from a remote core.

Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-19 12:22:46 +08:00