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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Fix potential crash when removing client from server list.
Add proper list initialization check before deletion operation.
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>