Skip to content

Add PM Runtime and Policy Lock support for MSPM0 UART - #117

Open
fcooperti wants to merge 13 commits into
TexasInstruments:v4.4.0-ti-nextfrom
fcooperti:v4.4.0-ti-next_uart_pm_test
Open

fcooperti wants to merge 13 commits into
TexasInstruments:v4.4.0-ti-nextfrom
fcooperti:v4.4.0-ti-next_uart_pm_test

Conversation

@fcooperti

Copy link
Copy Markdown

Commits are made up of ones pending upstream as well as a couple that are already merged.

nordic-krch and others added 13 commits October 21, 2026 06:44
…ont...

commit 46e5ba3 upstream.

Add early exist to the suspend function if suspending client is
not the last one. It fixes the case where user calls put function
from the thread context and it gets interrupted by the device
interrupt where another asynchronous put is called. In that case,
in the interrupt context the call will return error as semaphore
cannot be taken and reference counting gets broken. By adding
an early exit if context is not the last one, we ensure that only
last client executes suspending procedure.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
commit 8d6e134 upstream.

The get/put fast paths update pm->base.usage under the global runtime
PM spinlock, but the slow paths update the same non-atomic counter
while holding only the per-device semaphore. A pm_device_runtime_get()
call from an ISR can then interleave with the last-user
pm_device_runtime_put() read-modify-write running in a thread: the
fast path sees usage == 1 with the device active, increments the
counter and returns 0, and the interrupted thread overwrites the
counter with 0 and suspends the device. The ISR ends up holding a
runtime PM reference on a suspended device and the usage count is
permanently off by one.

Serialize all usage read-modify-write sequences of the non-ISR-safe
paths through the global spinlock: the unbalanced check, decrement and
last-user decision in runtime_suspend(), the suspend failure restores,
the slow-path get increment and the resume failure decrement. State
keeps being written under the per-device semaphore: every transition
away from the active state happens with usage == 0, which is now
visible under the spinlock, so the fast-path "usage > 0 and state
active" check cannot claim a reference on a device that is about to be
suspended. The ISR-safe paths already serialize everything under the
per-device spinlock and are unchanged. The counter updates are
factored into small runtime_usage_*() helpers so that every
read-modify-write visibly goes through the same lock.

The race window was confirmed on qemu_x86 by disassembly (the usage
load and store are split across a branch, so the timer IRQ can be
delivered in between) and reproduced deterministically with the stress
test added in the following commit, which fails without this fix and
passes with it.

Fixes the race left open by commit 46e5ba3 ("pm: device_runtime:
Fix managing the device from multiple contexts").

Signed-off-by: Holt Sun <holt.sun@nxp.com>
PR: 122748

Add missing copyright text to mspm0g110x.dtsi and
mspm0g310x.dtsi which were triggering check_compliance warnings.

Signed-off-by: Franklin Cooper Jr <fcooper@ti.com>
PR: 122748

Run clang-format on source file to avoid unexpected line changes
in future commits.

Signed-off-by: Franklin Cooper Jr <fcooper@ti.com>
PR: 122748

Add support for pm device runtime.

Signed-off-by: Franklin Cooper Jr <fcooper@ti.com>
…r UART

PR: 122748

Add disabling power states for uart peripheral. These low power
modes will disrupt uart operations.

This information came from the datasheets table called
"Operating Modes".

Signed-off-by: Franklin Cooper Jr <fcooper@ti.com>
PR: 122748

Add policy locks to prevent system from entering a low power
mode that would disrupt uart operations.

Signed-off-by: Franklin Cooper Jr <fcooper@ti.com>
PR: 122748

Disabling and reenabling FEN improperly causing the BUSY flag
to indicate the UART is still busy. Since we are always using
FIFO just keep it set.

Signed-off-by: Franklin Cooper Jr <fcooper@ti.com>
… it...

PR: 122748

Don't update configuration until we are certain its all valid.

Signed-off-by: Franklin Cooper Jr <fcooper@ti.com>
…rx ...

PR: 122748

If a uart peripheral driver doesn't support disable_rx then test
will fail with a compile error. Instead if disable_rx is not found
then default to 0/false. The test already handles when this property
is 1 or 0 so no need to prevent the entire test from working.

Signed-off-by: Franklin Cooper Jr <fcooper@ti.com>
…Lau...

PR: 122748

Add support for TI's lp_mspm0g3519 and lp_mspm0l2228 launchpad.

Signed-off-by: Franklin Cooper Jr <fcooper@ti.com>
…chpad

PR: 122748

Add support for TI's lp_mspm0g3519 and lp_mspm0l2228 board.

Signed-off-by: Franklin Cooper Jr <fcooper@ti.com>
… L2...

PR: 122748

Add support for TI's lp_mspm0g3519 and lp_mspm0l2228 board.

Signed-off-by: Franklin Cooper Jr <fcooper@ti.com>
@fcooperti
fcooperti force-pushed the v4.4.0-ti-next_uart_pm_test branch from 7217858 to 91887ea Compare October 21, 2026 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants