Skip to content

Commit b4ef8db

Browse files
committed
Revert "schedule: zephyr_ll: convert pdata->sem into sys_sem"
This reverts commit 48cdc4d. struct sys_sem cannot be on heap and we can have many LL tasks so using a statically allocated pool of them doesn't look like a good idea either. Using k_sem is slower, but so far there don't seem to be good alternatives to that. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 331b378 commit b4ef8db

2 files changed

Lines changed: 4 additions & 26 deletions

File tree

posix/include/rtos/mutex.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -62,25 +62,4 @@ static inline int sys_mutex_unlock(struct sys_mutex *mutex)
6262
return 0;
6363
}
6464

65-
/* provide a no-op implementation for zephyr/sys/sem.h */
66-
67-
struct sys_sem {
68-
};
69-
70-
static inline int sys_sem_init(struct sys_sem *sem, unsigned int initial_count,
71-
unsigned int limit)
72-
{
73-
return 0;
74-
}
75-
76-
static inline int sys_sem_give(struct sys_sem *sem)
77-
{
78-
return 0;
79-
}
80-
81-
static inline int sys_sem_take(struct sys_sem *sem, k_timeout_t timeout)
82-
{
83-
return 0;
84-
}
85-
8665
#endif

src/schedule/zephyr_ll.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <rtos/task.h>
1717
#include <sof/lib/perf_cnt.h>
1818
#include <zephyr/kernel.h>
19-
#include <zephyr/sys/sem.h>
2019
#include <ipc4/base_fw.h>
2120
#include <sof/debug/telemetry/telemetry.h>
2221

@@ -42,7 +41,7 @@ struct zephyr_ll {
4241
struct zephyr_ll_pdata {
4342
bool run;
4443
bool freeing;
45-
struct sys_sem sem;
44+
struct k_sem sem;
4645
};
4746

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

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

507506
if (must_wait)
508507
/* Wait for up to 100 periods */
509-
sys_sem_take(&pdata->sem, K_USEC(LL_TIMER_PERIOD_US * 100));
508+
k_sem_take(&pdata->sem, K_USEC(LL_TIMER_PERIOD_US * 100));
510509

511510
/* Protect against racing with schedule_task() */
512511
zephyr_ll_lock(sch, &flags);
@@ -699,7 +698,7 @@ int zephyr_ll_task_init(struct task *task,
699698

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

702-
sys_sem_init(&pdata->sem, 0, 1);
701+
k_sem_init(&pdata->sem, 0, 1);
703702

704703
task->priv_data = pdata;
705704

0 commit comments

Comments
 (0)