Commit Graph

13234 Commits

Author SHA1 Message Date
wangjianyu3 be60298185 drivers/lcd/st7789: Add option for RGB data endian
Big endian by default.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-04-27 09:58:49 +08:00
wangjianyu3 7b5891aaf7 drivers/ioexpander: Add support for PCA9557
Datasheet: https://www.ti.com/lit/ds/symlink/pca9557.pdf

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-04-27 09:57:59 +08:00
cuiziwei 879db5f817 drivers/binder: Rename BIOC_FLUSH to BINDER_FLUSH to avoid conflict with system flush.
1. revert 4946904, This patch is to solve the crash problem caused by reboot operation. The phenomenon is: when reboot operation is executed, the system will call binder_flush, which will cause the use after free to be called when proc is destroyed.

2. Now, we can rename BIOC_FLUSH to BINDER_FLUSH to avoid system call binder_flush.

3. why revert 4946904, because when we set looper_need_return in advance, it will cause the child thread of the binder thread pool to be unable to exit when it really wants to exit.

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2026-04-27 09:57:15 +08:00
wangjianyu3 3223004520 drivers/sensors/gnss: Macro `UINT8_MAX` for maximum value of `uint8_t crefs`
libs/libc/gnssutils/minmea/minmea.h:17:#include <stdint.h>

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-04-27 09:50:15 +08:00
cuiziwei ca86cd9a4c drivers/binder: Set thread->looper_need_return false after wake up thread.
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2026-04-27 09:50:11 +08:00
chenzihan1 9ff743f4cb drivers/rptun/ivshmem: fix g_rsc_table host/remote name
Signed-off-by: chenzihan1 <chenzihan1@xiaomi.com>
2026-04-21 01:36:10 +08:00
jingfei 917c1f302d syslog_chardev: syslog_chardev_ioctl return -ENOTTY if not supported
Signed-off-by: jingfei <jingfei@xiaomi.com>
2026-04-21 01:36:08 +08:00
yezhonghui 2d9e9b3cf1 perf: add noinstrument_function to up_perf_gettime and related functions
Add noinstrument_function attribute to up_perf_gettime and its helper
functions (like cp15_pmu_rdccr) across all architectures. These functions
are called by perf_gettime which is used in the instrument callback path,
and must not be instrumented to avoid infinite recursion when
CONFIG_ARCH_INSTRUMENT_ALL is enabled.

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2026-04-21 01:36:08 +08:00
yezhonghui d3b2b256b4 note: disable instrument for note driver to avoid infinite recursion
When CONFIG_ARCH_INSTRUMENT_ALL is enabled, the note driver functions
get instrumented, which causes infinite recursion because
sched_note_event_ip is called by __cyg_profile_func_enter/exit callbacks.

Use nuttx_add_aux_library to create a separate object library with
-fno-instrument-functions flag to prevent this recursion.

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2026-04-21 01:36:07 +08:00
likun17 78dc31cdc8 drivers/sensors/sensor_rpmsg: Fixed an issue where recursion in rpmsg_get_tx_payload_buffer caused the stub node to be prematurely released.
e.g.:
  core0:
    -> sensor_rpmsg_advsub(SENSOR_RPMSG_SUBSCRIBE)
    -> sensor_rpmsg_advsub(SENSOR_RPMSG_UNSUBSCRIBE)

  core1:
    -> rpmsg_virtio_rx_callback
    -> sensor_rpmsg_ept_cb
    -> sensor_rpmsg_sub_handler
       ......
    -> rpmsg_get_tx_payload_buffer
       ...... -> switch to another handler(e.g.:unsub handler)
    -> rpmsg_virtio_notify_wait
    -> rptun_notify_wait
    -> rptun_worker
       ...... -> stub was freed
    -> sensor_rpmsg_ept_cb
    -> sensor_rpmsg_sub_handler

Signed-off-by: likun17 <likun17@xiaomi.com>
2026-04-21 01:36:07 +08:00
chenzihan1 fe93115dcc drivers/goldfish/battery: The goldfish_battery work queue is started during driver initialization
Add a work queue call in goldfish_battery_register() to trigger an initial
battery state update immediately after driver initialization.

Previously, the battery state was only updated when a interrupt occurred.
This could cause the battery_state uORB topic to have no data
available during early boot, leading to failures when applications tried
to read battery information via orb_copy().

Signed-off-by: chenzihan1 <chenzihan1@xiaomi.com>
2026-04-21 01:36:06 +08:00
wangjianyu3 d7a5179729 fix(drivers/sensors): fix format string and resource leaks in GNSS uORB driver
Fix two issues:
1. gnss_close: Fix missing '%' before PRIu8 in sminfo format string
2. gnss_unregister: Add missing nxmutex_destroy for upper->lock
   and upper->bufferlock to prevent mutex resource leaks

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-04-21 01:36:05 +08:00
xuxingliang 25faebd347 syslog: set default channel to disabled state when PANIC_ONLY enabled
Commit 29d1b2a342b removed the compile-time static disable of
g_default_channel sc_state, expecting DFX to handle it at runtime
via SYSLOGIOC_SETFILTER. However, before DFX initializes, the
channel remains enabled (sc_state = 0), violating the PANIC_ONLY
semantic that the default channel should only output during panic.

Restore the initial SYSLOG_CHANNEL_DISABLE in g_default_channel
when CONFIG_SYSLOG_DEFAULT_PANIC_ONLY is enabled, using the proper
bitmask instead of the previous bare `true`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2026-04-21 01:36:05 +08:00
zhangyu117 e2a99f096e Revert "drivers/serial/uart_gsmmux: fix atomic print type not match"
This reverts commit a14f0514f3bf930cdf9f6a4b63d60ec8e0d5ddeb.

Reason for revert: revert type warning process

Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
2026-04-21 01:36:04 +08:00
xuxingliang d302910b5e syslog: switch default channel disable from compile-time to runtime
Remove the compile-time static disable of the default syslog channel
(sc_state = true) since DFX now handles disabling dynamically at
runtime via SYSLOGIOC_SETFILTER ioctl. Fix the panic notifier to use
proper bitmask operation instead of clearing all state bits. Update
Kconfig help text to reflect the new runtime behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2026-04-21 01:36:03 +08:00
guanyi3 7a7f18cf1f serial/pl011: fix pl011_putc SMP race on IMSC causing RX input loss
The original pl011_putc() busy-waits for the TX FIFO to drain
without any lock protection.  On SMP this allows two CPUs to race
past the TXFF check simultaneously and write DR into a full FIFO,
losing characters.

More critically, because pl011_putc holds no lock while other paths
(pl011_txint, pl011_rxint) do hold sport->lock when they
read-modify-write the IMSC register, the unprotected pl011_putc
creates a window where concurrent IMSC updates from the interrupt
call-back chain can clobber each other, resulting in IMSC being
zeroed.  Once IMSC == 0 the UART stops generating interrupts and
RX input is lost while TX (polled via putc) continues to work.

Fix by using a try-lock loop in pl011_putc: take sport->lock,
check TXFF, if not full write DR and release; if full release
immediately and retry.  This ensures the TXFF check and DR write
are atomic while never busy-waiting with the lock held, so the
interrupt path and other CPUs can always make progress.

Signed-off-by: guanyi3 <guanyi3@xiaomi.com>
2026-04-21 01:36:01 +08:00
ligd c65eb240e2 serial/cmsdk: fix RX lockup caused by up_putc disabling RX interrupts
up_putc() uses disableuartint/restoreuartint to temporarily suppress
all UART interrupts while doing polled TX output.  This includes
clearing CTRL.RX_INT_ENABLE.

On the CMSDK APB UART, the hardware only sets INTSTATUS_RX when a
character is received AND RX_INT_ENABLE is asserted at that moment.
If a character arrives during the window where up_putc() has cleared
RX_INT_ENABLE, the UART latches RX_BUF_FULL in STATE but does NOT
set INTSTATUS_RX.  When restoreuartint() re-enables RX_INT_ENABLE
the interrupt is never generated, so the byte stays in the single-
entry holding register forever.  Because RX_BUF_FULL blocks further
reception, the UART is permanently stalled — no more RX interrupts
fire, and if the console reader task blocks on input the TX path
stalls as well.

Fix this by having up_putc() only disable/restore the TX-side
interrupt enables (TX_INT_ENABLE and TX_OVERRUN_INT_ENABLE).  Polled
character transmission has no need to suppress RX interrupts, so
leaving them enabled closes the race window entirely.

Signed-off-by: ligd <liguiding1@xiaomi.com>
2026-04-21 01:36:00 +08:00
guanyi3 ecf9eae4c2 drivers/rpmsg: init pm_wakelock before rpmsg_queue_work
Problem:
The pm_wakelock_init() was called after rpmsg_queue_work() in rpmsg_virtio_probe(), which creates a race condition. The worker thread (rpmsg_virtio_start_worker) may start executing and access priv->wakelock through rpmsg_virtio_pm_action() before the wakelock is properly initialized.

This race leads to anomalous wakelock behavior where:
- The wakelock count becomes inconsistent (e.g., count=0 when it should be non-zero)
- The wakelock node remains in the PM domain queue (dq) even when count=0, violating the invariant that count=0 implies removal from the queue

Root Cause:
Call chain when worker starts before wakelock init:
  rpmsg_virtio_start_worker()
    -> rpmsg_init_vdev_with_config()
      -> rpmsg_virtio_rx_dispatch()
        -> rpmsg_virtio_tx_notify()  (via callback)
          -> rpmsg_virtio_pm_action()
            -> pm_wakelock_stay(&priv->wakelock)  // UNINITIALIZED!

Solution:
Move pm_wakelock_init() before rpmsg_queue_work() to ensure the wakelock is fully initialized before the worker thread can access it.

Impact:
Fixes PM wakelock corruption that prevented proper power management state transitions and could lead to system staying awake unnecessarily or entering low-power states prematurely.

Signed-off-by: guanyi3 <guanyi3@xiaomi.com>
2026-04-21 01:36:00 +08:00
Bowen Wang b87a649384 drivers/rpmsg/dump: optimize the dump log to save log buffer
To avoid the carsh log is too large to casue part of the crash log
is missed when flush the rpmsg syslog buffer.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-04-21 01:35:59 +08:00
ligd abbd6bd94f serial/cmsdk: drain stale rx data when enabling rx interrupt
The CMSDK UART has only a 1-byte receive buffer with no FIFO.
During boot, uart_cmsdk_setup() enables RX (CTRL.RX_EN) but the
RX interrupt (CTRL.RX_INTEN) is not enabled until later when
uart_cmsdk_rxint(enable=true) is called.

If a character arrives in this window, the hardware sets RXFULL
but does not set INTSTATUS.RX (because RX_INTEN is still off).
Once RXFULL is stuck at 1, the UART refuses to accept any new
characters and RX is permanently stalled. Enabling RX_INTEN
afterwards does not retroactively generate the missed interrupt.

Fix this by checking rxavailable() right after enabling the RX
interrupt. If data is already present, call uart_recvchars() to
drain it immediately, clearing RXFULL so the UART can receive
new characters again.

Also add proper spinlock protection that was missing from rxint().

Signed-off-by: ligd <liguiding1@xiaomi.com>
2026-04-21 01:35:59 +08:00
buxiasen 8f2bce7696 drivers/serial/uart_gsmmux: fix atomic print type not match
nuttx/drivers/serial/uart_gsmmux.c:369:15: error: format '%ld' expects argument of type 'long int', but argument 4 has type 'int' [-Werror=format=]
nuttx/drivers/serial/uart_gsmmux.c:406:15: error: format '%ld' expects argument of type 'long int', but argument 4 has type 'int' [-Werror=format=]

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2026-04-21 01:35:58 +08:00
dongjiuzhu1 9fe9eedc6d serial/16550: add sched_lock to avoid txint happen context switch
switch backtrace:
uart_write
  uart_enabletxinit
    u16550_txint
      uart_spinlock false
      uart_xmitchars
        uart_spinlock true
          uart_datasent
            poll_notify
        uart_spinunlock true
                      <--------- context switch, change cpu id
      uart_spinunlock false
        rspin_unlock
          DEBUGASSERT(lock->owner == this_cpu() + 1);  trigger crash

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-04-21 01:35:56 +08:00
buxiasen 769b4f75a0 drivers/pipes: change rmutex to rspinlock
Fix signal write break the mutex.
Need nopreempt as there is post and cause possible recursive in diff
threads.
Avoid the circbuf_uninit/free cause lock/sched_switch, unlock before
free should prefer.
The resize possible do malloc/free cause break rspinlock, need do
malloc/free with pipe unlocked.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2026-04-21 01:35:56 +08:00
yangsong8 b9452b4dcf drivers/xhci: fix build error
usbhost/usbhost_xhci_pci.c:4438:16: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2026-04-21 01:35:55 +08:00
Bowen Wang 7dc2c1a7b4 drivers/rptun: enhance logging for remote core reset and panic events
Add detailed logging to improve debugging of rptun reset scenarios:
- Log reset reason when remote core triggers a reset
- Log reset reason in both driver-specific and default reset paths
- Minor formatting cleanup for existing panic log

This helps diagnose remote processor failures by capturing the reset
cause and CPU name in emergency logs.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-04-21 01:35:54 +08:00
Zhe Weng c18535ba31 drivers/virtio-gpu: Avoid signal interrupt the sem wait
If user received signal when waiting command to complete, the driver
will quit the waiting and release the sem, then the complete callback
will post on a freed sem.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2026-04-21 01:35:54 +08:00
ligd f8de2ae091 mm: Change mm_initialize_heap/mm_initialize_pool to return int, heap via out param
- Change mm_initialize_heap and mm_initialize_pool to return int (0 on success, <0 on error),
    and return the heap pointer via the first argument (struct mm_heap_s **heap_out).
- Update all callers to use the new interface
- This improves error handling and avoids confusion with pointer return values.

Signed-off-by: ligd <liguiding1@xiaomi.com>
2026-04-21 01:35:53 +08:00
v-lichenxi7 ce9c2060f2 fakesensor: change priority of fakesensor_thread
Signed-off-by: v-lichenxi7 <v-lichenxi7@xiaomi.com>
2026-04-21 01:35:52 +08:00
husong1 a1c66d632a noteram: Resolve the deadlock caused by the lack of protection for shared variables during noteram initialization.
Signed-off-by: husong1 <husong1@xiaomi.com>
2026-04-21 01:35:51 +08:00
Bowen Wang 8a4b4a2829 drivers/virtio-snd: remove the debug sched_note_printf
Bug already fixed, do not need this anymore

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-04-21 01:35:50 +08:00
Bowen Wang 2eca4d2ed5 drivers/virtio-blk: remove the debug sched_note_printf
Bug already fixed, do not need this anymore

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-04-21 01:35:50 +08:00
ligd 81bd87d01f Revert "fix spinlock be accidentally unlocked and may lead double unlock"
This reverts commit 6967fd42d76148964ee2b95c301430d7b0bb3243.

Signed-off-by: ligd <liguiding1@xiaomi.com>
2026-04-21 01:35:49 +08:00
ligd 726c069c97 Revert "drivers/ramlog: add tryinit as we suppose to use noinit section"
This reverts commit 668cb19ea456faf6e036542b43c14a4fba38bb77.

Signed-off-by: ligd <liguiding1@xiaomi.com>
2026-04-21 01:35:49 +08:00
ligd 0a0c564cd1 thermal_dummy: Change THERMAL_CRITICAL to THERMAL_HOT to avoid aggressive strategy
The THERMAL_CRITICAL trip point can trigger aggressive thermal actions
like system shutdown. Change the 90 trip point from THERMAL_CRITICAL
to THERMAL_HOT to allow more graceful thermal management and avoid
unexpected system behavior.

Signed-off-by: ligd <liguiding1@xiaomi.com>
2026-04-21 01:35:48 +08:00
xuxingliang 4061fa2c7c Revert "drivers/ramlog: move spinlock to header"
This reverts commit baa011c429f7ef8e61316f06978e5604bb51c9ca.

Reason for revert: No longer needed.

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
2026-04-21 01:35:44 +08:00
xuxingliang 4760a04525 drivers/syslog: add O_DIRECT mode support for direct up_nputs output
When /dev/log is opened with O_DIRECT flag, writes bypass the syslog
stream and call up_nputs() directly for lower-latency console output.

This is useful for performance-critical logging scenarios where the
overhead of syslog stream processing is undesirable.

Implementation:
- Add open handler to detect O_DIRECT flag and store state in f_priv
- Modify write handler to route based on O_DIRECT mode:
  - O_DIRECT set: call up_nputs() directly
  - O_DIRECT not set: use lib_syslograwstream (existing behavior)

Backward compatibility is maintained - default behavior unchanged
when O_DIRECT is not used

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2026-04-21 01:35:44 +08:00
yangsong8 74736cbee6 driver/serial/pty: Fixed use-after-free issue when pty_register2 registration failed.
unregister_driver() will call pty_unlink(), which may call
pty_destroy() to free devpair if pp_nopen == 0. So we must return
here directly to avoid use-after-free
Adjust the order in which minor are released, unregistering the driver
first to avoid race conditions.

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2026-04-21 01:35:44 +08:00
v-dingxiaofu 7e07485a18 sim-vela: add AUDIOIOC_GETLATENCY in fake driver
Signed-off-by: v-dingxiaofu <v-dingxiaofu@xiaomi.com>
2026-04-21 01:35:43 +08:00
zhangyu117 34d854ea11 nuttx/atomic: replace atomic_fetch_xxx with atomic_xxx just like zephyr
Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
2026-04-21 01:35:40 +08:00
qiaohaijiao1 7c3636352e audio_fake: add error log
Signed-off-by: qiaohaijiao1 <qiaohaijiao1@xiaomi.com>
2026-04-21 01:35:38 +08:00
anpeiyun 858b99ae96 ramlog.c: spinlock dont't restore in some situation
in function ramlog_file_poll, the spinlock should restore if(!setup && !fds->oriv)

Signed-off-by: anpeiyun <anpeiyun@xiaomi.com>
2026-04-21 01:35:37 +08:00
jinxiuxu 36fa56d908 virtio-snd: mv dequeue out of spinlock
Signed-off-by: jinxiuxu <jinxiuxu@xiaomi.com>
2026-04-21 01:35:37 +08:00
yintao 4ffcb0b57b rpmsg/rpmsg_port_spi: modify atomic_load to atomic_read
Signed-off-by: yintao <yintao@xiaomi.com>
2026-04-21 01:35:37 +08:00
zhaoxingyu1 f8e6a7a749 mtdconfig/nvs2: improve flash space utilization
On devices with large program sizes, due to byte
alignment requirements, there may be insufficient
space utilization in the ate space

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-04-21 01:35:36 +08:00
hongfengchen 725178c9c7 noteram: check devpath befor use it
Check devpath before use it, to make sure the
devpath is legal.

Signed-off-by: hongfengchen <hongfengchen@xiaomi.com>
2026-04-21 01:35:35 +08:00
yangsong8 21203af6b4 gdbstub: move file_open into uart_gdbstub_attach
The USB CDCACM has not yet been successfully recognized at this
point, and executing `file_open` will return an error.

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2026-04-21 01:35:34 +08:00
huojianchao 4faf9be307 rptun compile error fix
Signed-off-by: huojianchao <huojianchao@xiaomi.com>
2026-04-21 01:35:33 +08:00
yintao 52015ebf90 drivers/video: fix compile warning
warning: implicit declaration of function 'nxmutex_lock';
  123 |   ret = nxmutex_lock(&priv->lock);
      |         ^~~~~~~~~~~~
      |         nxsched_lock

Signed-off-by: yintao <yintao@xiaomi.com>
2026-04-21 01:35:32 +08:00
yezhonghui 8de5938e6a nuttx: init note driver for mode and level
Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2026-04-21 01:35:30 +08:00
huojianchao 26b7644396 specific product: clock_gettime return wrong nsec value(>1000000000)
rootcause:
use stack mem to init rtc_time in up_rtc_getdatetime_with_subseconds without initialize to zero,
depends on rdtime function to init rtctime, may lead to same bug for different rdtime implement.
init local variable to zero to avoid this bug

Signed-off-by: huojianchao <huojianchao@xiaomi.com>
2026-04-21 01:35:21 +08:00