Skip to content

Commit 9ab89c6

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 08d9756 commit 9ab89c6

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

drivers/firmware/scmi/core.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ static int scmi_send_message_post_kernel(struct scmi_protocol *proto,
158158
return ret;
159159
}
160160

161+
bool scmi_is_current_thread_idle(void)
162+
{
163+
struct k_thread *current = k_current_get();
164+
165+
return strcmp(k_thread_name_get(current), "idle") == 0;
166+
}
167+
161168
int scmi_send_message(struct scmi_protocol *proto, struct scmi_message *msg,
162169
struct scmi_message *reply)
163170
{
@@ -169,7 +176,16 @@ int scmi_send_message(struct scmi_protocol *proto, struct scmi_message *msg,
169176
return -EINVAL;
170177
}
171178

172-
if (k_is_pre_kernel()) {
179+
bool use_pre_kernel_path = k_is_pre_kernel();
180+
#ifdef CONFIG_PM
181+
/* When PM is enabled and the system manager is referenced in the idle task context,
182+
* the sm interrupt should be disabled in the soc low power phase.
183+
* In this case, the pre kernel is used instead of the post kernel.
184+
*/
185+
use_pre_kernel_path = use_pre_kernel_path || scmi_is_current_thread_idle();
186+
#endif
187+
188+
if (use_pre_kernel_path) {
173189
return scmi_send_message_pre_kernel(proto, msg, reply);
174190
} else {
175191
return scmi_send_message_post_kernel(proto, msg, reply);

drivers/firmware/scmi/prj.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_THREAD_NAME=y

0 commit comments

Comments
 (0)