Skip to content

Commit

Permalink
pm: console: Use async runtime put to minimize resumption/suspension
Browse files Browse the repository at this point in the history
When device runtime pm is enabled on console device, do not suspend
device synchronously on each char transmission, but rather use asynchronous
suspension request.
This will save useless and costly suspension/resumption procedure, which
can involve uart device clock suspension but also pin configuration
to sleep state (which itself involves gpio clock activation ...).

On STM32, using asynch device suspension allows to divide by 3 the
transmission time of a character chain.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
  • Loading branch information
erwango authored and carlescufi committed Jan 18, 2024
1 parent 9569e44 commit b98c794
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions drivers/console/uart_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,11 @@ static int console_out(int c)
}
uart_poll_out(uart_console_dev, c);

/* As errors cannot be returned, ignore the return value */
(void)pm_device_runtime_put(uart_console_dev);
/* Use async put to avoid useless device suspension/resumption
* when tranmiting chain of chars.
* As errors cannot be returned, ignore the return value
*/
(void)pm_device_runtime_put_async(uart_console_dev, K_MSEC(1));

return c;
}
Expand Down
7 changes: 5 additions & 2 deletions subsys/logging/backends/log_backend_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,11 @@ static int char_out(uint8_t *data, size_t length, void *ctx)

(void)err;
cleanup:
/* As errors cannot be returned, ignore the return value */
(void)pm_device_runtime_put(uart_dev);
/* Use async put to avoid useless device suspension/resumption
* when tranmiting chain of chars.
* As errors cannot be returned, ignore the return value
*/
(void)pm_device_runtime_put_async(uart_dev, K_MSEC(1));

return length;
}
Expand Down

0 comments on commit b98c794

Please sign in to comment.