Implement Linux-compatible TFD_TIMER_CANCEL_ON_SET flag for timerfd to
allow applications to detect discontinuous changes to CLOCK_REALTIME.
Background:
According to Linux timerfd_create(2) man page, when a timerfd is created
with CLOCK_REALTIME and TFD_TIMER_CANCEL_ON_SET flag is specified, the
read() operation should fail with ECANCELED if the real-time clock
undergoes a discontinuous change. This allows applications to detect
and respond to system time changes.
Implementation:
1. Add clock notifier infrastructure (clock_notifier.h/c) to notify
interested parties when system time changes
2. Implement TFD_TIMER_CANCEL_ON_SET flag support in timerfd
3. Register timerfd with clock notifier when flag is set
4. Cancel timer and return ECANCELED when clock change is detected
5. Notify clock changes in:
- clock_settime()
- clock_initialize()
- clock_timekeeping_set_wall_time()
- rpmsg_rtc time synchronization
Changes include:
- New files: include/nuttx/clock_notifier.h, sched/clock/clock_notifier.c
- Modified: fs/vfs/fs_timerfd.c to handle TFD_TIMER_CANCEL_ON_SET
- Modified: clock subsystem to call notifier chain on time changes
- Modified: rpmsg_rtc to notify time changes during sync
Use case example:
Applications using timerfd with absolute time can now detect when
system time is adjusted (e.g., NTP sync, manual time change) and
take appropriate action such as recalculating timeouts or updating
scheduled events.
Reference: https://man7.org/linux/man-pages/man2/timerfd_create.2.html
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
Add sensor monitor logs to analyze issues related to driver activation.
This commit adds comprehensive sensor monitoring logs to the GNSS uORB driver
to facilitate debugging and analysis of driver activation issues.
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Now we can release the rx buffer in ept->cb, ept->cb should copy
the rx buffer it's private buffer and then return
RPMSG_SUCCESS_BUFFER_RETURNED.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Invalid data is cleared during garbage collection rather than
deleted during initialization, thus accelerating the
initialization speed.
Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
When key string found corrupted during garbage collection,
then remove key-value pair from the flash.
Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
On 64-bit platforms, the capability flags use PCI_RESOURCE_MEM_64
instead of PCI_RESOURCE_MEM. Add support to find both flag types.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Fall back to INTX interrupt mode when MSI/MSI-X is not supported
or MSI-X IRQ connection fails. This improves compatibility with
more virtio-pci devices.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
When the receive buffer is full and the driver only implements recvbuf
operation without receive operation, the code would crash due to calling
a NULL function pointer. This patch fixes the issue by:
1. Check if recvbuf is available before calling it
2. When buffer is full, use a temporary buffer to drain hardware FIFO
to prevent data accumulation in hardware
3. Add proper NULL check for receive operation to avoid crash
4. Initialize pbuf to NULL to prevent uninitialized variable usage
This ensures the serial driver works correctly even when only recvbuf
is implemented and the receive buffer is full.
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@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>
Add NOTE_DUMP_BINARY to the note_type_e enum and implement its handling
in noteram_dump_one. This enables the recording and dumping of binary
logs in hexadecimal format, improving traceability for binary event data.
Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
Move rpmsg internal APIs from public header include/nuttx/rpmsg/rpmsg.h
to private header drivers/rpmsg/rpmsg.h. These APIs are only used within
the rpmsg driver implementation and should not be exposed to external
modules.
Moved APIs:
- rpmsg_modify_signals()
- rpmsg_ns_bind() / rpmsg_ns_unbind()
- rpmsg_device_created() / rpmsg_device_destory()
- rpmsg_register() / rpmsg_unregister()
Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>