Skip to content
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
47 changes: 44 additions & 3 deletions src/arch/xtensa/include/arch/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,26 +171,67 @@ static inline void arch_allocate_tasks(void)
{
/* irq low */
struct irq_task **low = task_irq_low_get();
*low = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(**low));
*low = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(**low));
list_init(&((*low)->list));
spinlock_init(&((*low)->lock));
(*low)->irq = PLATFORM_IRQ_TASK_LOW;

/* irq medium */
struct irq_task **med = task_irq_med_get();
*med = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(**med));
*med = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(**med));
list_init(&((*med)->list));
spinlock_init(&((*med)->lock));
(*med)->irq = PLATFORM_IRQ_TASK_MED;

/* irq high */
struct irq_task **high = task_irq_high_get();
*high = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(**high));
*high = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(**high));
list_init(&((*high)->list));
spinlock_init(&((*high)->lock));
(*high)->irq = PLATFORM_IRQ_TASK_HIGH;
}

/**
* \brief Frees IRQ tasks.
*/
static inline void arch_free_tasks(void)
{
uint32_t flags;

/* free IRQ low task */
struct irq_task **low = task_irq_low_get();

spin_lock_irq(&(*low)->lock, flags);
interrupt_disable(PLATFORM_IRQ_TASK_LOW);
interrupt_unregister(PLATFORM_IRQ_TASK_LOW);
list_item_del(&(*low)->list);
spin_unlock_irq(&(*low)->lock, flags);

rfree(*low);

/* free IRQ medium task */
struct irq_task **med = task_irq_med_get();

spin_lock_irq(&(*med)->lock, flags);
interrupt_disable(PLATFORM_IRQ_TASK_MED);
interrupt_unregister(PLATFORM_IRQ_TASK_MED);
list_item_del(&(*med)->list);
spin_unlock_irq(&(*med)->lock, flags);

rfree(*med);

/* free IRQ high task */
struct irq_task **high = task_irq_high_get();

spin_lock_irq(&(*high)->lock, flags);
interrupt_disable(PLATFORM_IRQ_TASK_HIGH);
interrupt_unregister(PLATFORM_IRQ_TASK_HIGH);
list_item_del(&(*high)->list);
spin_unlock_irq(&(*high)->lock, flags);

rfree(*high);
}

/**
* \brief Assigns IRQ tasks to interrupts.
*/
Expand Down
27 changes: 26 additions & 1 deletion src/arch/xtensa/smp/include/arch/idc.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ static inline void arch_idc_init(void)

/* initialize idc data */
struct idc **idc = idc_get();
*idc = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(**idc));
*idc = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(**idc));
spinlock_init(&((*idc)->lock));
(*idc)->busy_bit_mask = idc_get_busy_bit_mask(core);
(*idc)->done_bit_mask = idc_get_done_bit_mask(core);
Expand All @@ -274,4 +274,29 @@ static inline void arch_idc_init(void)
(*idc)->busy_bit_mask | (*idc)->done_bit_mask);
}

/**
* \brief Frees IDC data and unregisters interrupt.
*/
static inline void idc_free(void)
{
int core = arch_cpu_get_id();
int i = 0;
uint32_t idctfc;

trace_idc("IDF");

/* disable and unregister interrupt */
interrupt_disable(PLATFORM_IDC_INTERRUPT(core));
interrupt_unregister(PLATFORM_IDC_INTERRUPT(core));

/* clear BUSY bits */
for (i = 0; i < PLATFORM_CORE_COUNT; i++) {
idctfc = idc_read(IPC_IDCTFC(i), core);
if (idctfc & IPC_IDCTFC_BUSY)
idc_write(IPC_IDCTFC(i), core, idctfc);
}

rfree(*idc_get());
}

#endif
2 changes: 2 additions & 0 deletions src/include/sof/schedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,6 @@ static inline void schedule_task_config(struct task *task, uint16_t priority,

int scheduler_init(struct sof *sof);

void scheduler_free(void);

#endif
25 changes: 24 additions & 1 deletion src/lib/schedule.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ int scheduler_init(struct sof *sof)
trace_pipe("ScI");

struct schedule_data **sch = arch_schedule_get();
*sch = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(**sch));
*sch = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(**sch));
list_init(&((*sch)->list));
spinlock_init(&((*sch)->lock));
(*sch)->clock = PLATFORM_SCHED_CLOCK;
Expand All @@ -389,3 +389,26 @@ int scheduler_init(struct sof *sof)

return 0;
}

/* Frees scheduler */
void scheduler_free(void)
{
struct schedule_data **sch = arch_schedule_get();
uint32_t flags;

spin_lock_irq(&(*sch)->lock, flags);

/* disable and unregister scheduler interrupt */
interrupt_disable(PLATFORM_SCHEDULE_IRQ);
interrupt_unregister(PLATFORM_SCHEDULE_IRQ);

/* free arch tasks */
arch_free_tasks();

work_cancel_default(&(*sch)->work);
list_item_del(&(*sch)->list);

spin_unlock_irq(&(*sch)->lock, flags);

rfree(*sch);
}