Skip to content
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

remove idelay use and move to k_busy_wait in SOF Zephyr code #9656

Merged
merged 4 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/idc/idc.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ int idc_wait_in_blocking_mode(uint32_t target_core, bool (*cond)(int))

while (!cond(target_core)) {
/* spin here so other core can access IO and timers freely */
idelay(8192);
wait_delay(8192);

if (deadline < sof_cycle_get_64())
break;
Expand Down
2 changes: 1 addition & 1 deletion src/samples/audio/detect_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ static void default_detect_test(struct comp_dev *dev,
/* assuming count is a processing frame size in samples */
cycles_per_frame = (cd->config.load_mips * 1000000 * count)
/ audio_stream_get_rate(source);
idelay(cycles_per_frame);
wait_delay(cycles_per_frame);
}

/* perform detection within current period */
Expand Down
22 changes: 5 additions & 17 deletions zephyr/include/rtos/wait.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,22 @@
#include <stdint.h>
#include <stdbool.h>
#include <zephyr/kernel.h>
#include <zephyr/sys/time_units.h>
#include <rtos/timer.h>

/* TODO: use equivalent Zephyr */
static inline void idelay(int n)
static inline void wait_delay_us(uint64_t us)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick - having this function at the bottom of this patch, where it was before, would both make this patch smaller (probably) and easier to read and keep the grouping of all wait_delay*() functions as now. Not a show-stopper of course, only if you need to update

{
while (n--)
__asm__ volatile("nop");
k_busy_wait(us);
}

/* DSP default delay in cycles - all platforms use this today */
#define PLATFORM_DEFAULT_DELAY 12

static inline void wait_delay(uint64_t number_of_clks)
{
uint64_t timeout = sof_cycle_get_64() + number_of_clks;

while (sof_cycle_get_64() < timeout)
idelay(PLATFORM_DEFAULT_DELAY);
k_busy_wait(k_cyc_to_us_floor64(number_of_clks));
}

static inline void wait_delay_ms(uint64_t ms)
{
wait_delay(k_ms_to_cyc_ceil64(ms));
}

static inline void wait_delay_us(uint64_t us)
{
wait_delay(k_us_to_cyc_ceil64(us));
k_busy_wait(ms * 1000);
}

int poll_for_register_delay(uint32_t reg, uint32_t mask,
Expand Down
2 changes: 1 addition & 1 deletion zephyr/lib/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void cpu_disable_core(int id)

/* Waiting for secondary core to enter idle state */
while (arch_cpu_active(id) && (k_cycle_get_64() < timeout))
idelay(PLATFORM_DEFAULT_DELAY);
k_busy_wait(1);

if (arch_cpu_active(id)) {
tr_err(&zephyr_tr, "core %d did not enter idle state", id);
Expand Down
Loading