nuttx/drivers/rpmsg
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
..
CMakeLists.txt rpmsg: Remove rpmsg_lite transport support 2026-04-21 01:33:20 +08:00
Kconfig rpmsgdev.c: use shmem buf to replace local variables 2026-04-21 01:35:11 +08:00
Make.defs rpmsg: Remove rpmsg_lite transport support 2026-04-21 01:33:20 +08:00
rpmsg.c drivers/rpmsg/dump: optimize the dump log to save log buffer 2026-04-21 01:35:59 +08:00
rpmsg.h rpmsg.c: support config the rpmsg work queue priority 2026-04-21 01:34:54 +08:00
rpmsg_char.c drivers/rpmsg_char: fix the rpmsg char poll bug 2026-04-21 01:33:36 +08:00
rpmsg_char.h rpmsg/rpmsg_char: add rpmsg char support 2026-04-21 01:29:32 +08:00
rpmsg_ping.c drivers/rpmsg_ping: add remote core name in ping info 2026-04-21 01:34:50 +08:00
rpmsg_ping.h rpmsg/rpmsg_ping: remove the nuttx/rpmsg/rpmsg_ping.h header 2026-04-21 01:28:27 +08:00
rpmsg_port.c nuttx/atomic: replace atomic_fetch_xxx with atomic_xxx just like zephyr 2026-04-21 01:35:40 +08:00
rpmsg_port.h rpmsg_port.c: add log to identify the startup process 2026-04-21 01:32:19 +08:00
rpmsg_port_spi.c nuttx/atomic: replace atomic_fetch_xxx with atomic_xxx just like zephyr 2026-04-21 01:35:40 +08:00
rpmsg_port_spi_slave.c nuttx/atomic: replace atomic_fetch_xxx with atomic_xxx just like zephyr 2026-04-21 01:35:40 +08:00
rpmsg_port_uart.c rpsmg_port_uart.c: fix complier warning 2026-04-21 01:32:58 +08:00
rpmsg_procfs.c drivers/rpmsg: Modify global variable/list for BMP 2026-04-21 01:32:08 +08:00
rpmsg_procfs.h note->trace:Change the name of the rpmsg note to rpmsg trace 2026-04-21 01:29:05 +08:00
rpmsg_router.h rpmsg: move the api only for rpmsg transport to drivers/rpmsg/rpmsg.h 2026-04-21 01:20:26 +08:00
rpmsg_router_edge.c drivers/rpmsg: remove metal_xx API 2026-04-21 01:33:31 +08:00
rpmsg_router_hub.c drivers/rpmsg: peer_ept should decref when hub_unbind 2026-04-21 01:34:50 +08:00
rpmsg_test.c rpmsg API:add rpmsg API test suite 2026-04-21 01:26:29 +08:00
rpmsg_test.h rpmsg:add rpmsg_test to test rpmsg hold/release rx buffer 2026-04-21 01:15:29 +08:00
rpmsg_trace.c drivers/rpmsg: Modify global variable/list for BMP 2026-04-21 01:32:08 +08:00
rpmsg_trace.h note->trace:Change the name of the rpmsg note to rpmsg trace 2026-04-21 01:29:05 +08:00
rpmsg_virtio.c drivers/rpmsg: init pm_wakelock before rpmsg_queue_work 2026-04-21 01:36:00 +08:00
rpmsg_wakelock.c rpmsg-wakelock: Remove wakelock if count decreased to zero 2026-04-21 01:25:43 +08:00
rpmsg_wakelock.h rpmsg-wakelock: Add rpmsg-wakelock driver 2026-04-21 01:25:43 +08:00