Skip to content
Open
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
21 changes: 21 additions & 0 deletions posix/include/rtos/mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,25 @@ static inline int sys_mutex_unlock(struct sys_mutex *mutex)
return 0;
}

/* provide a no-op implementation for zephyr/sys/sem.h */

struct sys_sem {
};

static inline int sys_sem_init(struct sys_sem *sem, unsigned int initial_count,
unsigned int limit)
{
return 0;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

our testbench flows don't do any multiprocessing for now, right? No threads, no forks or clones. Wondering if recreating a thread model similar to the real one in it to test any deadlocks would be useful, but maybe it would be too different from the reality anyway.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ack @lyakh . The concurrency primitives are all no-ops now. OTOH, I think for any actual multiprocessing, we'd probably be better off using Zephyr posix target (like the fuzzer is using) and then we get proper mapping to posix interfaces via Zephyr. Not sure doing this wrapping (e.g. to POSIX pthreads) once more on SOF side seems is worth the effort...


static inline int sys_sem_give(struct sys_sem *sem)
{
return 0;
}

static inline int sys_sem_take(struct sys_sem *sem, k_timeout_t timeout)
{
return 0;
}

Comment on lines +65 to +85

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is ok, this is adding a stub for other users. zephyr_ll.c doesn't need this.

#endif
9 changes: 5 additions & 4 deletions src/schedule/zephyr_ll.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <rtos/task.h>
#include <sof/lib/perf_cnt.h>
#include <zephyr/kernel.h>
#include <zephyr/sys/sem.h>
#include <ipc4/base_fw.h>
#include <sof/debug/telemetry/telemetry.h>

Expand All @@ -41,7 +42,7 @@ struct zephyr_ll {
struct zephyr_ll_pdata {
bool run;
bool freeing;
struct k_sem sem;
struct sys_sem sem;
};

#if CONFIG_SOF_USERSPACE_LL
Expand Down Expand Up @@ -136,7 +137,7 @@ static void zephyr_ll_task_done(struct zephyr_ll *sch,
* zephyr_ll_task_free() is trying to free this task. Complete
* it and signal the semaphore to let the function proceed
*/
k_sem_give(&pdata->sem);
sys_sem_give(&pdata->sem);

tr_info(&ll_tr, "task complete %p %pU", task, task->uid);
tr_info(&ll_tr, "num_tasks %d total_num_tasks %ld",
Expand Down Expand Up @@ -505,7 +506,7 @@ static int zephyr_ll_task_free(void *data, struct task *task)

if (must_wait)
/* Wait for up to 100 periods */
k_sem_take(&pdata->sem, K_USEC(LL_TIMER_PERIOD_US * 100));
sys_sem_take(&pdata->sem, K_USEC(LL_TIMER_PERIOD_US * 100));

/* Protect against racing with schedule_task() */
zephyr_ll_lock(sch, &flags);
Expand Down Expand Up @@ -691,7 +692,7 @@ int zephyr_ll_task_init(struct task *task,

memset(pdata, 0, sizeof(*pdata));

k_sem_init(&pdata->sem, 0, 1);
sys_sem_init(&pdata->sem, 0, 1);

task->priv_data = pdata;

Expand Down
Loading