Skip to content

STM32 UART driver hangs if trying to TX on a suspended instance when using device PM #97063

@kamnxt

Description

@kamnxt

Describe the bug

When trying to TX on a suspended UART device, instead of getting an error, the thread hangs, waiting for the transmission to finish or a timeout to end (which in case of for example the async uart modem iface, is forever).

For what it's worth, the nRF driver handles this, by checking the state: (https://github.com/zephyrproject-rtos/zephyr/blob/16f4d6c23e401eaa0664c3f3b606f988b6b9dada/drivers/serial/uart_nrfx_uarte.c#L843C1-L852C1)

#if defined(CONFIG_PM_DEVICE) && !defined(CONFIG_PM_DEVICE_RUNTIME)
	enum pm_device_state state;

	(void)pm_device_state_get(dev, &state);
	if (state != PM_DEVICE_STATE_ACTIVE) {
		return;
	}
#endif

But the STM32 driver isn't aware of the device PM state at all.

I wouldn't mind making a PR for fixing this if handling this is something we want to do (as opposed to just calling it "undefined behavior" or incorrect usage of the API), but not sure what a correct error code to return would be here (-EIO?).

Regression

  • This is a regression.

Steps to reproduce

  1. Enable device runtime PM
  2. Suspend a UART device with async API enabled
  3. Try to send some data using the device, with a long or infinite timeout

Relevant log output

Impact

Annoyance – Minor irritation; no significant impact on usability or functionality.

Environment

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: UARTUniversal Asynchronous Receiver-TransmitterbugThe issue is a bug, or the PR is fixing a bugplatform: STM32ST Micro STM32

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions