Skip to content

Commit 4708bc7

Browse files
committed
drivers: scmi: adjust the logic of sending messages
When the system enables PM and enters the idle task, to ensure that the system is not disturbed by interrupts from SM, it is necessary to disable global interrupts and SM interrupts. in this case, it need to use the pre_kernel polling logic instead of the post interrupt logic. Signed-off-by: Yongxu Wang <[email protected]>
1 parent 3f102be commit 4708bc7

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

drivers/firmware/scmi/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,9 @@ zephyr_library_sources_ifdef(CONFIG_ARM_SCMI_CLK_HELPERS clk.c)
1212
zephyr_library_sources_ifdef(CONFIG_ARM_SCMI_PINCTRL_HELPERS pinctrl.c)
1313
zephyr_library_sources_ifdef(CONFIG_ARM_SCMI_POWER_DOMAIN_HELPERS power.c)
1414

15+
zephyr_include_directories(
16+
${ZEPHYR_BASE}/kernel/include
17+
${ZEPHYR_BASE}/arch/${ARCH}/include
18+
)
19+
1520
add_subdirectory_ifdef(CONFIG_ARM_SCMI nxp)

drivers/firmware/scmi/core.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <zephyr/drivers/firmware/scmi/transport.h>
99
#include <zephyr/logging/log.h>
1010
#include <zephyr/device.h>
11+
#include <kthread.h>
1112

1213
LOG_MODULE_REGISTER(scmi_core);
1314

@@ -169,7 +170,15 @@ int scmi_send_message(struct scmi_protocol *proto, struct scmi_message *msg,
169170
return -EINVAL;
170171
}
171172

172-
if (k_is_pre_kernel()) {
173+
bool use_pre_kernel_path = k_is_pre_kernel();
174+
#ifdef CONFIG_PM
175+
/* When PM is enabled and the system manager is referenced in the idle task context,
176+
* the sm interrupt should be disabled in the soc low power phase.
177+
* In this case, the pre kernel is used instead of the post kernel.
178+
*/
179+
use_pre_kernel_path |= z_is_idle_thread_object(_current);
180+
#endif
181+
if (use_pre_kernel_path) {
173182
return scmi_send_message_pre_kernel(proto, msg, reply);
174183
} else {
175184
return scmi_send_message_post_kernel(proto, msg, reply);

0 commit comments

Comments
 (0)