Skip to content
Draft
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
16 changes: 12 additions & 4 deletions src/audio/copier/copier_dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,21 @@ __cold void copier_dai_free(struct processing_module *mod)
assert_can_be_cold();

for (int i = 0; i < cd->endpoint_num; i++) {
dai_common_free(cd->dd[i]);
mod_free(mod, cd->dd[i]->gain_data);
mod_free(mod, cd->dd[i]);
if (cd->dd[i]) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this should be its own patch.

if (cd->dd[i]->gain_data) {
mod_free(mod, cd->dd[i]->gain_data);
cd->dd[i]->gain_data = NULL;
}
dai_common_free(cd->dd[i]);
mod_free(mod, cd->dd[i]);
cd->dd[i] = NULL;
}
}
/* only dai have multi endpoint case */
if (cd->multi_endpoint_buffer)
if (cd->multi_endpoint_buffer) {
buffer_free(cd->multi_endpoint_buffer);
cd->multi_endpoint_buffer = NULL;
}
}

int copier_dai_prepare(struct comp_dev *dev, struct copier_data *cd)
Expand Down
7 changes: 6 additions & 1 deletion src/audio/pipeline/pipeline-params.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,13 @@ static int pipeline_comp_prepare(struct comp_dev *current,
}

err = comp_prepare(current);
if (err < 0 || err == PPL_STATUS_PATH_STOP)
if (err < 0 || err == PPL_STATUS_PATH_STOP) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this looks like a separate patch

if (err < 0) {
pipe_err(current->pipeline, "comp_prepare for comp 0x%x failed %d",
dev_comp_id(current), err);
}
return err;
}

return pipeline_for_each_comp(current, ctx, dir);
}
Expand Down
7 changes: 7 additions & 0 deletions src/platform/intel/cavs/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <rtos/wait.h>
#include <sof/platform.h>
#include <sof/schedule/edf_schedule.h>
#include <sof/schedule/dp_schedule.h>
#include <sof/schedule/ll_schedule.h>
#include <sof/schedule/ll_schedule_domain.h>
#include <sof/trace/trace.h>
Expand Down Expand Up @@ -122,6 +123,12 @@ int platform_init(struct sof *sof)
sof->platform_timer_domain = timer_domain_init(sof->platform_timer, 0);
scheduler_init_ll(sof->platform_timer_domain);

#if CONFIG_ZEPHYR_DP_SCHEDULER
ret = scheduler_dp_init();
if (ret < 0)
return ret;
#endif

/* init the system agent */
trace_point(TRACE_BOOT_PLATFORM_AGENT);
sa_init(sof, CONFIG_SYSTICK_PERIOD);
Expand Down
9 changes: 5 additions & 4 deletions src/schedule/zephyr_dp_schedule.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,30 @@ SOF_DEFINE_REG_UUID(dp_sched);
/* unused with Zephyr, generates no output */
DECLARE_TR_CTX(dp_tr, SOF_UUID(dp_sched_uuid), LOG_LEVEL_INFO);

#define DP_LOCK_INIT(i, _) Z_SEM_INITIALIZER(dp_lock[i], 1, 1)
/* k_mutex, not k_sem: priority inheritance keeps a preempted DP holder from stalling LL */

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@kv2019i assuming this patch wont be compatible with userspace.
@ujfalusi I suspect this wont be needed with clang. We can revert test when time permits.

#define DP_LOCK_INIT(i, _) Z_MUTEX_INITIALIZER(dp_lock[i])
#define DP_LOCK_INIT_LIST LISTIFY(CONFIG_MP_MAX_NUM_CPUS, DP_LOCK_INIT, (,))

/* User threads don't need access to this array. Access is performed from
* the kernel space via a syscall. Array must be placed in special section
* to be qualified as initialized by the gen_kobject_list.py script.
*/
static
STRUCT_SECTION_ITERABLE_ARRAY(k_sem, dp_lock, CONFIG_MP_MAX_NUM_CPUS) = { DP_LOCK_INIT_LIST };
STRUCT_SECTION_ITERABLE_ARRAY(k_mutex, dp_lock, CONFIG_MP_MAX_NUM_CPUS) = { DP_LOCK_INIT_LIST };

/* Each per-core instance of DP scheduler has separate structures; hence, locks are per-core.
*
* TODO: consider using cpu_get_id() instead of supplying core as a parameter.
*/
unsigned int scheduler_dp_lock(uint16_t core)
{
k_sem_take(&dp_lock[core], K_FOREVER);
k_mutex_lock(&dp_lock[core], K_FOREVER);
return core;
}

void scheduler_dp_unlock(unsigned int key)
{
k_sem_give(&dp_lock[key]);
k_mutex_unlock(&dp_lock[key]);
}

void scheduler_dp_grant(k_tid_t thread_id, uint16_t core)
Expand Down
1 change: 1 addition & 0 deletions zephyr/edf_schedule.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ static int schedule_edf_task_running(void *data, struct task *task)

static int schedule_edf_task_free(void *data, struct task *task)
{
k_work_cancel_delayable(&task->z_delayed_work);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

unrelated to this patch

task->state = SOF_TASK_STATE_FREE;
task->ops.run = NULL;
task->data = NULL;
Expand Down
Loading