Enable CONFIG_SCHED_EVENTS for the sim:rpproxy_uart,rpserver_uart and
qemu-armv7a:rpproxy,rpserver configurations because rpmsg port uart
depends on the SCHED_EVENTS now.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Add documentation for RPMsg Port UART, a transport layer that enables
RPMsg communication between SoCs via UART when shared memory is not
available.
The documentation covers:
- Hardware requirements (UART with flow control)
- Software architecture
- Escape coding protocol for command/data separation
- Connection establishment protocol
- Data frame format
- Low power support with ping-pong wake mechanism
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Add comprehensive documentation for the RPMsg Port abstract transport
layer, which supports cross-SoC communication via physical backends
like SPI and UART.
The documentation covers:
- Architecture overview and layer diagram
- Buffer management with TX/RX free and ready lists
- Buffer layout with header reservation
- Data transmission and reception flow
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
When recv peer poweroff command, should clear the connected status
first to avoid there is data to send when call the rpmsg_unregister(),
then tx thread hang at the data send process but peer has power
off.
When clear the connected status first, rpmsg_port_uart_tx_ready()
will drop the tx packet to avoid tx thread is waked up to send useless
data.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
rpmsg_port_unreigster() should be called after rpmsg_port_reigster(),
so add the connected condition when receive poweroff command.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
To debug the tx buffer get failed issue, the rpmsg port uart/spi
can use this mechanism to dump more debug informations.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Fix the case that tx thread want to send data to peer and try to
wakeup peer, but rx thread blocked on the tx buffer got procees and
so rx thread can't process the commands includes the wakeup ack
command, then the tx thread will hang at the wakeup process forever.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
When no free buffers, notify the lower transport, so the lower
transports can know this thing and do some work, such as continue
to process the rx data to avoid the rx thread is blocked that
even can't process the commands.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Signed-off-by: liaoao <liaoao@xiaomi.com>
Orignal issue: the new wakeup process may be waked by the last Ack
command from peer, and lead the data is lost because peer may have
enter into the sleep mode.
W = Wake, A = WakeAck, R = Relax, D = Data
TX: [0]W-[1]R--------[4]W----[6]DDDDDDDDDDDD-------
RX: ------------[3]A----[5]Enter Sleep-------------
In this figure, Ack command [3] wakeup the wakeup process [4] because
[3] may be received with a delay.
Now use the ping-pong wake/ack command to fix this issue because
the different wake/ack command can block the last Ack command
wake the wrong wakeup process.
W1 = Wake1, A1 = WakeAck1, W2 = Wake2, A2 = WakeAck2, R = Relax, D = Data
TX: [0]W1-[1]R-------[4]W2----------[6]DDDDDDDDDDD--
RX: ------------[3]A1---------[5]A2-----------------
With this patch, the Ack comamnd [3] can't wakeup the wakeup process [4]
because [3] is Ack1 but [4] is Wake2, and local will not send data until
peer response a [5]Ack2.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Try to dump more error log to catch the uart trasmission issue.
1. dump the received error char when received the non start char
at the wait start state;
2. dump the dbg buffer and received buffer when received the
duplicate end char at the wait start state;
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Peer will receive the power off command and unregister the rpmsg
connections to avoid the rpmsg services stuck at the rpmsg operations.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Support wakeup by peer core (Linux)
1. Add 3 commands: STAYWAKE/RELAXWAKE/STAYWAKEACK
Local will stay the wakeup source when received the STAYWAKE command
and relax the pm wake soucre when received the RELAXWAKE.
And local should response the STAYWAKEACK to peer to notify local has
been waked up.
Local core must send the RELAXWAKE command to peer when there is nothing
to do (send/receive data) otherwise peer can't enter into sleep mode.
So we wakeup the tx thread to send the RELAXWAKE command at the time
that may blocked in the file_read() in rx thread.
NOTE:
Local core should relax the pm wakelock when received POWEROFF
command to allow enter into sleep mode when peer core SHUTDOWN.
2. Change all the flags to event, use event is more convinent
to reprsent all the flags. But the tx sem must be kept because we need
support notify the tx is ready event the tx thread is running to avoid
miss any tx ready event.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Use the TIOCVHANGUP to notify the driver to switch the uart io
to gpio mode to avoid the current leak caused by the uart io because
peer core may already poweroff so the io can be in high voltage
state.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
To maintain compatibility in future update, the data transfer is
still valid even can't process the new added command.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
1. Dump the error log and continue process the next packet when
received error happened instead direclty panic to allow use adb
to update peer core's firmeware;
2. Add more error log to debug the receive error;
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Enable high-resolution timer (hrtimer) using the list
implementation in the CITEST configuration on fvp-armv8r:citest.
Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
Enable the default high-resolution timer (hrtimer) using the RB-tree
implementation in the CITEST configuration on rv-virt:citest64.
Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
The code currently checks CONFIG_ARCH_CHIP_MPS2_AN524, but
the corresponding Kconfig option is ARCH_CHIP_MPS3_AN524(i.e.
CONFIG_ARCH_CHIP_MPS3_AN524) in arch/arm/src/mps/Kconfig
Signed-off-by: zhenwei fang <fangzhenwei@bytedance.com>
Previously, IRQ bounds checking (irq >= 0 && irq < NR_IRQS) was duplicated
across multiple IRQ subsystem functions before calling IRQ_TO_NDX(). This
led to code duplication and inconsistency.
This patch consolidates all IRQ bounds checking into the IRQ_TO_NDX() macro
itself, which now returns -EINVAL for out-of-bounds IRQ numbers. This approach:
1. Eliminates duplicated bounds checking code
2. Ensures consistent error handling across all IRQ functions
3. Simplifies caller code - just check if IRQ_TO_NDX() returns negative
4. Makes the macro behavior more predictable and self-contained
Changes:
- Modified IRQ_TO_NDX() to check (irq < 0 || irq >= NR_IRQS) and return -EINVAL
- Removed redundant IRQ range checks in irq_attach(), irq_attach_thread(),
irq_attach_wqueue(), and irqchain_detach()
- Simplified error handling to check ndx < 0 after IRQ_TO_NDX() call
This consolidation reduces code size and improves maintainability while
preserving all existing error checking functionality.
Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
When a key is successfully exported, the return value should reflect the actual length of the exported key data.
Signed-off-by: makejian <makejian@xiaomi.com>
Add support for generating AES keys (128/192/256 bits) using the software key management backend.
The generated keys are random numbers produced by the system PRNG.
Signed-off-by: makejian <makejian@xiaomi.com>
This patch adds support for managing cryptographic keys using MTD storage.
It enables the persistence of keys across reboots using a software-based key management system.
Includes fixes for compilation warnings and validation logic.
Signed-off-by: makejian <makejian@xiaomi.com>
For re-enter case, the inode information may unlock with not filled,
and get by other user. that lead to the error behavior.
Especially SMP scene.
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
For re-enter case, the inode information may unlock with not filled,
and get by other user. that lead to the error behavior.
Especially SMP scene.
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
For re-enter case, the inode information may unlock with not filled,
and get by other user. that lead to the error behavior.
Especially SMP scene.
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
Export the sched_note_event_ip function as a syscall under
CONFIG_SCHED_INSTRUMENTATION_DUMP. This allows user-space or
other kernel components to trigger event-type logs via the
instrumentation dump mechanism.
Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
Refactor sem_trywait.c to replace goto statements with structured control
flow to comply with MISRA HIS coding standards. This improves code clarity
and maintainability while preserving all functional behavior and performance
characteristics.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Consolidate CONFIG_PRIORITY_PROTECT checks by moving macro definitions to
their actual usage locations and removing duplicate/dead code in semaphore
implementation. This reduces code duplication and improves maintainability
across sem_wait, sem_trywait, and sem_post functions.
Signed-off-by: p-gaoxiang43 <p-gaoxiang43@xiaomi.com>
Consolidate multiple return statements in sched_get_stackinfo() to comply
with MISRA HIS coding standards for safety-critical systems. This refactoring
maintains functional equivalence while improving code verifiability and
reducing cyclomatic complexity for better maintainability.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Add proper null pointer validation and fix potential dereference after null
check in scheduler critical sections. This addresses Coverity FORWARD_NULL
defect by ensuring pointers are checked before use and maintaining defensive
coding practices throughout the scheduler implementation.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Consolidate multiple return statements in sched_rrgetinterval() to reduce
function complexity and comply with MISRA HIS coding standards. This refactoring
maintains functional equivalence while improving code maintainability for
safety-critical embedded systems applications.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
IRQ_TO_NDX() returns int (can be negative on error), but was assigned
to unsigned int variable 'ndx', violating MISRA C-2012 Rule 10.3.
This also improves the condition check: instead of checking 'irq >= 0 && irq < NR_IRQS',
we now check 'ndx >= 0' which properly handles the error case where IRQ_TO_NDX()
returns a negative error code.
Changes:
- Change 'ndx' type from unsigned int to int
- Simplify condition from 'irq >= 0 && irq < NR_IRQS' to 'ndx >= 0'
This ensures type correctness and proper error handling.
Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
Allow SCHED_CRITMONITOR to be enabled without requiring FS_PROCFS,
so it can be used in scenarios like calculating CPU load via
SCHED_CPULOAD_CRITMONITOR where procfs is not available.
Signed-off-by: chao an <anchao.archer@bytedance.com>
Since the busy-wait time statistics for entering the critical section have been added, the critmon information in the document has been updated accordingly.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
Because enter_critical_section() changes from calling spin_lock() to calling spin_lock_wo_note(), it is necessary to count the busywait time in enter_critical_section() additionally.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>