Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 367
[DNM] Zephyr smp rework#8764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Uh oh!
There was an error while loading. Please reload this page.
Closed
[DNM] Zephyr smp rework #8764
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -19,6 +19,7 @@ | ||
| /* Zephyr includes */ | ||
| #include <version.h> | ||
| #include <zephyr/kernel.h> | ||
| #include <zephyr/kernel/smp.h> | ||
| #include <zephyr/device.h> | ||
| #include <zephyr/drivers/mm/mm_drv_intel_adsp_mtl_tlb.h> | ||
| @@ -27,37 +28,9 @@ | ||
| extern K_KERNEL_STACK_ARRAY_DEFINE(z_interrupt_stacks, CONFIG_MP_MAX_NUM_CPUS, | ||
| CONFIG_ISR_STACK_SIZE); | ||
| static atomic_t start_flag; | ||
| static atomic_t ready_flag; | ||
| /* Zephyr kernel_internal.h interface */ | ||
| extern void smp_timer_init(void); | ||
| static FUNC_NORETURN void secondary_init(void *arg) | ||
| static void secondary_init(void *arg) | ||
| { | ||
| struct k_thread dummy_thread; | ||
| /* | ||
| * This is an open-coded version of zephyr/kernel/smp.c | ||
| * smp_init_top(). We do this so that we can call SOF | ||
| * secondary_core_init() for each core. | ||
| */ | ||
| atomic_set(&ready_flag, 1); | ||
| z_smp_thread_init(arg, &dummy_thread); | ||
| smp_timer_init(); | ||
| secondary_core_init(sof_get()); | ||
| #ifdef CONFIG_THREAD_STACK_INFO | ||
| dummy_thread.stack_info.start = (uintptr_t)z_interrupt_stacks + | ||
| arch_curr_cpu()->id * Z_KERNEL_STACK_LEN(CONFIG_ISR_STACK_SIZE); | ||
| dummy_thread.stack_info.size = Z_KERNEL_STACK_LEN(CONFIG_ISR_STACK_SIZE); | ||
| #endif | ||
| z_smp_thread_swap(); | ||
| CODE_UNREACHABLE; /* LCOV_EXCL_LINE */ | ||
| } | ||
| #if CONFIG_ZEPHYR_NATIVE_DRIVERS | ||
| @@ -113,7 +86,6 @@ void cpu_notify_state_exit(enum pm_state state) | ||
| /* Notifying primary core that secondary core successfully exit the D3 | ||
| * state and is back in the Idle thread. | ||
| */ | ||
| atomic_set(&ready_flag, 1); | ||
| return; | ||
| } | ||
| #endif | ||
| @@ -142,26 +114,17 @@ int cpu_enable_core(int id) | ||
| if (arch_cpu_active(id)) | ||
| return 0; | ||
| #if ZEPHYR_VERSION(3, 0, 99) <= ZEPHYR_VERSION_CODE | ||
| /* During kernel initialization, the next pm state is set to ACTIVE. By checking this | ||
| * value, we determine if this is the first core boot, if not, we need to skip idle thread | ||
| * initialization. By reinitializing the idle thread, we would overwrite the kernel structs | ||
| * and the idle thread stack. | ||
| */ | ||
| if (pm_state_next_get(id)->state == PM_STATE_ACTIVE) | ||
| z_init_cpu(id); | ||
| #endif | ||
| atomic_clear(&start_flag); | ||
| atomic_clear(&ready_flag); | ||
| arch_start_cpu(id, z_interrupt_stacks[id], CONFIG_ISR_STACK_SIZE, | ||
| secondary_init, &start_flag); | ||
| while (!atomic_get(&ready_flag)) | ||
| k_busy_wait(100); | ||
| if (pm_state_next_get(id)->state == PM_STATE_ACTIVE) { | ||
| k_smp_cpu_start(id, secondary_init, NULL); | ||
| return 0; | ||
| } | ||
| atomic_set(&start_flag, 1); | ||
| k_smp_cpu_resume(id, secondary_init, NULL, true, false); | ||
| return 0; | ||
| } | ||
| @@ -239,29 +202,20 @@ int cpu_enable_core(int id) | ||
| int cpu_enable_secondary_core(int id) | ||
| { | ||
| /* | ||
| * This is an open-coded version of zephyr/kernel/smp.c | ||
| * z_smp_start_cpu(). We do this, so we can use a customized | ||
| * secondary_init() for SOF. | ||
| */ | ||
| if (arch_cpu_active(id)) | ||
| return 0; | ||
| #if ZEPHYR_VERSION(3, 0, 99) <= ZEPHYR_VERSION_CODE | ||
| z_init_cpu(id); | ||
| #endif | ||
| atomic_clear(&start_flag); | ||
| atomic_clear(&ready_flag); | ||
| arch_start_cpu(id, z_interrupt_stacks[id], CONFIG_ISR_STACK_SIZE, | ||
| secondary_init, &start_flag); | ||
| while (!atomic_get(&ready_flag)) | ||
| k_busy_wait(100); | ||
| /* During kernel initialization, the next pm state is set to ACTIVE. By checking this | ||
RanderWang marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| * value, we determine if this is the first core boot, if not, we need to skip idle thread | ||
| * initialization. By reinitializing the idle thread, we would overwrite the kernel structs | ||
| * and the idle thread stack. | ||
| */ | ||
| if (pm_state_next_get(id)->state == PM_STATE_ACTIVE) { | ||
| k_smp_cpu_start(id, secondary_init, NULL); | ||
| return 0; | ||
| } | ||
| atomic_set(&start_flag, 1); | ||
| k_smp_cpu_resume(id, secondary_init, NULL, true, false); | ||
| return 0; | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you make this a separate patch for bisect-ability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that if we separate the west update into a separate commit, then we'll lose the ability to bisect because these changes won't compile without updating Zephyr.
@RanderWang correct me if I'm wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lgirdwood west update needs to be in same commit, otherwise bisect is broken.