Commit Graph

60657 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
Bartosz Wawrzynek 64d2b822f8 arch/arm/src/nrf: Remove return status from void functions
Remove return status from void tickless_rtc functions in nrf52, nrf53,
and nrf91 boards. Also add missing newline at end of nrf91_modem_os.c.

Signed-off-by: Bartosz <bartol2205@gmail.com>
2026-01-22 22:07:53 +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
pangzhen1 9d471f353d sched/irq: declare the object in scope
An object should be declared in block scope if its identifier is only referenced within one function(MISRA C-2012 Rule 8.9)

Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
2026-01-22 08:50:30 -03:00
yukangzhi dd307ab82c libc/pthread: Avoid compiler optimizations for once_control->done
Prevent compiler reordering that may read stale value of once_control->done.
Use volatile to ensure visibility across threads and prevent incorrect once initialization.

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-01-22 19:47:45 +08:00
pangzhen1 f766dc6c08 arch/arm: Add arm memmanage fault skip operation
In some scenarios (e.g. testing, debugging, etc.) where we want to trigger a memmanage fault without panic the system, we can use this Memory Management Fault skip operation.

Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
2026-01-22 19:43:22 +08:00
ouyangxiangzhen 702e1d95f3 sched/wdog: Simplify the wd_timer_start.
This commit simplified the wd_timer_start.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-22 19:31:28 +08:00
ouyangxiangzhen 4280e69a1c sched/sched: Avoid getting tick in the nxsched_process_event.
During the expiration, the g_wdexpired has already updated, so only nxsched_reassess_timer requires getting current tick again.
This commit avoided getting tick again in the nxsched_process_event.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-22 19:31:28 +08:00
ouyangxiangzhen 6901864210 sched/sched: Simplify the sched_timerexpiration.
This commit simplified the sched_timerexpiration by removing the
interval.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-22 19:31:28 +08:00
ouyangxiangzhen 4cbc56eec5 sched/wdog: Add wd_adjust_next_tick.
This commit added wd_adjust_next_tick to simplify the scheduler.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-22 19:31:28 +08:00
wangchengdong f36a090aa9 boards/smartl-c906: enable hrtimer
Enable hrtimer support on the smartl-c906 board so that CI can build
  and exercise the hrtimer subsystem.

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-22 18:05:34 +08:00
pangzhen1 652b90f899 sched/irq: avoid casting from signed int to unsigned int
casting from signed int to unsigned int is not safe and should not be allowed

Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
2026-01-22 17:19:12 +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
yukangzhi 53e8c008f5 fs: Fix the incorrect return value of the lseek interface.
The lseek interface needs to return the new offset in file.

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-01-22 17:15:16 +08:00
pangzhen1 14efe537bd arch/tricore: add tricore mpu driver
tricore mpu driver code

Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
2026-01-22 16:45:58 +08:00
hujun5 b0cb4e5968 arm64: add MPU-based address environment support and refactor MMU variant
Rename arm64_addrenv.c to arm64_addrenv_mmu.c to separate MMU-specific logic.
Add new arm64_addrenv_mpu.c with stub implementations of address environment
functions for MPU-based systems. Enable address environment support in FVP ARMv8-R
Kconfig to support kernel stacks in protected mode. Conditionally build MPU or
MMU address environment code based on CONFIG_ARCH_USE_MMU/CONFIG_ARCH_USE_MPU.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-22 15:39:34 +08:00
hujun5 14e5d8a995 arm64: fix mpu_freeregion
The limit register contains the enable/disable bit for the MPU region,
so it must be written first before writing the base register to ensure
proper region disable operation.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-22 15:39:00 +08:00
hujun5 223230a9ed spinlock: add rspin_lock_count
spinlock: add rspin_lock_count query interface

Add rspin_lock_count() function to query the current recursion count of a
recursive spinlock. This allows callers to inspect the lock state without
modifying it, useful for debugging and diagnostics.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-22 15:38:37 +08:00
hujun5 4c43efafa5 spinlock: optimize the implementation of rspinlock in a single-core
Add CONFIG_SPINLOCK conditional compilation to optimize rspinlock functions
for systems without spinlock support. Provide simple macro implementations
that bypass recursive lock logic when spinlock is not configured.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-22 15:38:37 +08:00
hujun5 bb69f77164 spinlock: add rspinlock interface for recursive spinlock support
Add new recursive spinlock (rspinlock) interface functions to support nested
spinlock acquisitions by the same CPU. Includes rspin_lock, rspin_unlock,
rspin_breaklock, and rspin_restorelock for proper recursive lock management.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-22 15:38:37 +08:00
hujun5 6f03601169 arch: rename STACK_ALIGNMENT to STACKFRAME_ALIGN across all architectures
Rename STACK_ALIGNMENT macro to STACKFRAME_ALIGN throughout the codebase
to provide clearer naming semantics. The new name better reflects the macro's
purpose of frame alignment rather than general stack alignment.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-22 15:37:24 +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
wangzhi16 a73ff585f1 sched/signal: fix the occasional issue where SIGCONT was not executed
Build Documentation / build-html (push) Has been cancelled
In multi-core scenarios, a problem occurs: the target thread receives SIGCONT but does not execute them.

Further analysis reveals that in the sig_dispatch function, the target thread is placed in the readytorun queue only if the SIGCONT signal is sent and the target thread is in the TSTATE_TASK_STOPPED state. However, if the following conditions occur:

CPU0				CPU1
dispatch SIGSTOP
dispatch SIGCONT(check state)
				sched_suspend(set task_state = TSTATE_TASK_STOPPED)

This causes the target thread on CPU 1 to receive SIGCONT but not be placed in the readytorun queue, remaining in the stopped state.
Therefore, A flag is needed to indicate whether the SIGCONT action has been executed. At the same time, the critical section protection range of nxsig_stop_task needs to be expanded to prevent another thread from executing the SIGCONT logic during the execution of this function.

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2026-01-22 03:58:12 +08:00
pangzhen1 d11307b236 sched/irq: Avoid same static function name in different files
In irq_attach_thread.c and irq_attach_wqueue.c, there are static functions named irq_default_handler with the same name, which can be easily misunderstood. Therefore, they have been renamed to different functions.

Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
2026-01-22 03:51:00 +08:00
Jean THOMAS 6581e312f5 stm32: disable UART up_putc when semihosting
Do not compile up_putc functions in stm32_serial.c to avoid conflicts
with implementation from arm_semi_syslog.c when semihosting is enabled.

Signed-off-by: Jean THOMAS <jean@lambdaconcept.com>
2026-01-22 03:49:05 +08:00
Jiri Vlasak 4710b2f632 doc/apps: Add BARE 2026-01-22 03:48:35 +08:00
Bowen Wang baba361bb1 Documentation/rpmsg: add RPMsg core concepts document
Add a concise RPMsg documentation covering:
- Overview of RPMsg framework for AMP systems
- Application scenarios (heterogeneous/homogeneous AMP)
- Layered architecture (Services/Framework/Transport/Physical)
- Message encapsulation process
- Workflow: channel establishment, sending and receiving
- Key design considerations (FIFO order, callback blocking)
- Transport layer comparison

All diagrams use ASCII art for portability.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-22 03:45:55 +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
fangxinyong cd958831d8 sched/init: use enum type for g_nx_initstate
Change g_nx_initstate type from uint8_t to enum nx_initstate_e.
Avoid enum/integer base-type mismatch in init state comparisons.
Satisfies MISRA C:2012 Rule 10.4 without behavior change.

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2026-01-21 20:31:35 +08:00
fangxinyong d38078b778 libs/libc: posix_spawnattr_init zero-initialize attr
Zero-initialize posix_spawnattr_t in posix_spawnattr_init().
Prevent use of uninitialized fields reported by Coverity.
Preserve existing default flag initialization.

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2026-01-21 20:31:35 +08:00
fangxinyong ef6278b0ff arch/arm: armv8-r irq type-safe bit ops
Use 1u/~1u constants for TPIDRPRW bit operations.
Avoid implicit conversion to a different underlying type (MISRA Rule 10.3).
No functional change to task pointer tagging logic.

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2026-01-21 20:31:35 +08:00
fangxinyong a7b7630fd3 sched/task: task_setup return path cleanup
Refactor nxtask_setup_stackargs() to use a single ret exit path.
Avoid partially-initialized state on error paths and improve readability.
Addresses Coverity HIS_metric_violation: RETURN.

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2026-01-21 20:31:35 +08:00
fangxinyong 31901573ba sched/task: task_spawnparms return path cleanup
Initialize ret and propagate scheduler/param errors via a single return.
Make spawn_file_is_duplicateable() decision explicit using a dup state.
Addresses Coverity HIS_metric_violation: RETURN.

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2026-01-21 20:31:35 +08:00