Skip to content

Commit b98c794

Browse files
erwangocarlescufi
authored andcommitted
pm: console: Use async runtime put to minimize resumption/suspension
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 <[email protected]>
1 parent 9569e44 commit b98c794

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

drivers/console/uart_console.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,11 @@ static int console_out(int c)
9999
}
100100
uart_poll_out(uart_console_dev, c);
101101

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

105108
return c;
106109
}

subsys/logging/backends/log_backend_uart.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,11 @@ static int char_out(uint8_t *data, size_t length, void *ctx)
114114

115115
(void)err;
116116
cleanup:
117-
/* As errors cannot be returned, ignore the return value */
118-
(void)pm_device_runtime_put(uart_dev);
117+
/* Use async put to avoid useless device suspension/resumption
118+
* when tranmiting chain of chars.
119+
* As errors cannot be returned, ignore the return value
120+
*/
121+
(void)pm_device_runtime_put_async(uart_dev, K_MSEC(1));
119122

120123
return length;
121124
}

0 commit comments

Comments
 (0)