#120142·zephyr

doc: drivers: uart: define and test uart_poll_out() context guarantees

Author: ifx-rmcsCreated Sep 23, 2026Updated Oct 1, 2026
Labelsarea: UARTarea: Documentation

Summary

Existing Solution

uart_poll_out() is the function call the fatal error handler, log_panic() and early boot all rely on, but its API documentation in uart.h does not state which contexts it must work in. Drivers therefore each invent an answer for:

  1. pre-kernel, before the scheduler and before device runtime PM is enabled
  2. ISR context
  3. a device that device runtime PM has suspended and clock-gated
  4. a fatal/panic print that interrupted the same driver while it was inside pm_device_runtime_get() / pm_device_runtime_put_async(), which hold a per-device spinlock that is not reentrant
  5. the interaction with PM_DEVICE_ACTION_SUSPEND returning -EBUSY for an in-flight transmission

The same gap exists for uart_poll_in() on a suspended device: return -1 or touch gated registers.

tests/drivers/uart/uart_pm covers idle, poll TX and interrupted poll TX, and every board overlay in it is Nordic, so these corners are neither specified nor exercised.

Describe the solution you'd like

Proposed change

  1. Document the context contract for uart_poll_out() and uart_poll_in() on a device runtime PM managed instance: whether the driver is required to resume the device, whether it may call PM APIs at all, and what a driver is expected to do when called reentrantly from a fatal context.
  2. If drivers are expected to detect that case themselves, provide the means. Today a driver has to keep a private flag around its own PM calls because there is no way to ask "is this a fatal/panic context" or "is this device's PM lock already held by this CPU".
  3. Extend uart_pm with the corresponding cases and make them portable rather than Nordic-specific: poll out while runtime suspended, poll out from an ISR, poll in while suspended, and a poll out issued from a context that interrupted the driver's own PM call.

Alternatives

No response

Additional Context

Concerns and Unresolved Questions

Whether the contract should require the driver to resume the device on poll_out, or to emit on the gated block and restore it without changing PM's view of the device. Existing drivers do both.

Source: zephyrproject-rtos/zephyr