Commit Graph

154 Commits

Author SHA1 Message Date
Tomasz Lauda 20acc16791 edf_schedule: implement the new version of EDF scheduler
This patch implements the new version of EDF scheduler.
This is the first basic implementation, which can be easily extended
in the future.

Previous implementation had two major flaws:
- Tasks could only be preempted based on the interrupt level on which
they have been scheduled, so it was limited based on the hardware.
- This led to the system not fully utilized, so we could never achieve
full EDF functionality.

The new implementation uses only one software interrupt and allows for
dynamic context switching between different tasks based on the deadline.
Also for some cases priority is taken into consideration e.g. for idle
and almost idle tasks, which don't have deadline at all and should be
executed only if the system is free. All other normal tasks should have
the same priority. Task chosen to be run is executed on passive level,
so automatically can be preempted by every interrupt. Every task has
its own private stack on which current context is saved and restored
if needed. Note that main firmware loop is task scheduled with
idle priority, so it will be executed only after every other task
is completed.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2019-09-06 15:51:02 +01:00
Tomasz Lauda d1ede217e8 test: alloc: remove tests which don't test anything
Removes two tests which don't really test anything
and are based on magic numbers. Changing memory map
can easily break them.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2019-09-06 15:51:02 +01:00
Jaska Uimonen ebf406d084 unit tests: fix cmocka test for pipeline connect
cmocka pipeline connect unit test is checking the successful
connection from frames count set in components. However the frames
are not set in pipeline complete if we set the frames from stream
parameters. So check now that the pipeline pointer has been set
and matches the pipeline in high level test function.

Signed-off-by: Jaska Uimonen <jaska.uimonen@intel.com>
2019-08-15 14:29:22 +02:00
Tomasz Lauda 9a6616a89b spinlock: replace spin_lock_* with irq_local_*
Replaces spin_lock_* macros with irq_local_* macros
in many places. Most of the code doesn't need to keep
synchronization between cores. Setting critical section
by disabling local interrupts is enough. Spinlocks should
be used only in the places, where both cores have access.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2019-08-07 14:22:52 +02:00
Tomasz Lauda ec9d1cad94 schedule: make some functions static inline
Transforms some of the short functions to static inline.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2019-08-06 18:51:20 +01:00
Tomasz Lauda 4100fa0ac3 schedule: make schedule functions return task state
Instead of returning next period, schedule functions should return
state of the executed task. Period of the tasks is set during
initialization and doesn't change dynamically, so it doesn't make
sense to return it. With the new added SOF_TASK_STATE_RESCHEDULE
we can easily decide if the task is completed or maybe need to
be run once again.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2019-08-06 18:51:20 +01:00
Tomasz Lauda 99005e21bc schedule: extract flags to generic task data
Extracts flags to generic task data, so there is no need
for ll_schedule to keep them privately. Also changes the
way they are passed. From now on flags should be set only
during task initialization and not when starting scheduling.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2019-08-06 18:51:20 +01:00
Tomasz Lauda 2d16db19de ll_schedule: keep task period in private data
Adds new period field to task private data to keep
period set during schedule. Tasks shouldn't change
their period dynamically and in fact there is no
such task.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2019-08-06 18:51:20 +01:00
Janusz Jankowski f837e57b6e test: mux calc_sample_s16le
Unit tests for calc_sample_s16le with up to 8 channels.

Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
2019-08-02 13:31:44 +02:00
Janusz Jankowski 1bf779eef7 test: mux calc_sample_s24le
Unit tests for calc_sample_s24le with up to 8 channels.

Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
2019-08-02 13:31:44 +02:00
Janusz Jankowski 21375d45a2 test: mux calc_sample_s32le
Unit tests for calc_sample_s32le with up to 8 channels.

Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
2019-08-02 13:31:44 +02:00
Janusz Jankowski cfa339fece test: mux_prepare
Unit tests for mux prepare with valid and invalid formats.

Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
2019-08-02 13:31:44 +02:00
Janusz Jankowski b5654b851f test: demux_copy
Unit tests for demux copy with 1 source, 4 sinks and 8 channels.

Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
2019-08-02 13:31:44 +02:00
Janusz Jankowski a4dcabcfc6 test: mux_copy
Unit tests for mux copy with 4 sources, 1 sink and 8 channels.

Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
2019-08-02 13:31:44 +02:00
Marcin Rajwa 5e3b739043 kpb: disable sys_agent before draining
Draining task can take a long time depending
on various params. This patch disables system
agent which raises DSP PANIC in case firmware
is hanged. However draining task can look to
system agent in exactly the same manner thus
we disable it right before draining task and
reenable after draining is done.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2019-07-30 21:49:58 +02:00
Marcin Rajwa 0b279e06bc kpb: move history buffer allocation to prepare
This change moves history buffer allocation
from kpb_new() to kpb_prepare(). This is to
folow the calling convention with kernel.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2019-07-30 21:49:58 +02:00
Marcin Rajwa d180cd343f memory: set LPSRAM related defines to zero if LP not configured
This patch sets all LPSRAM related memory defines to
zero if CONFIG_LP_MEMORY_BANKS is not defined.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2019-07-30 19:29:59 +02:00
Bartosz Kokoszko f3d79e7398 component: add comp_set_sink_buffer() function
Component in comp_prepare() should change sink buffer
only when sink component is not connected to dma.
comp_set_sink_buffer() checks whether sink component
is not connected to dma and in that case it try to
resize sink buffer.

Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
2019-07-27 13:30:18 +02:00
Tomasz Lauda 5449dc2a30 panic: keep interrupts disabled after panic
This patch fixes the issue, where we've reenabled
the interrupts for the DSP, which sometimes caused
immediate DSP exception and overwrite of our dump.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2019-07-27 12:55:41 +02:00
Tomasz Lauda 418ddec569 panic: move panic related functions to new panic.h
Moves panic related functions from arch/sof.h to newly created
arch/debug/panic.h. Also change definition of arch_dump_regs
function to take dump buffer from caller. It decreases the
number of included headers in arch/debug/panic.h.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2019-07-27 12:55:41 +02:00
Tomasz Lauda 14b23ba5d3 task: move task structure and defines to the right header
Moves task structure and defines to the sof/task.h,
where they should be from the beginning. sof/schedule.h is
just for scheduler related things.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2019-07-19 15:50:35 +02:00
Tomasz Lauda 54d4d01d64 sof: move c files to dedicated directories
Moves c files to dedicated directories.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2019-07-18 16:00:24 +02:00
Tomasz Lauda 4ee9e1159c sof: move headers to dedicated directories
Moves headers to dedicated directories in sof/include,
arch/include and platform/include. File tree was too flat,
so some of the files has been moved.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2019-07-18 16:00:24 +02:00
Tomasz Lauda 1944052617 drivers: include: platform: cleanup includes
Cleanups includes in all drivers, include and
platform files. Unused headers has been removed
and needed has beed added.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2019-07-16 15:02:06 +02:00
Tomasz Lauda a990c611c4 sof: change approach to including arch headers
Further work, but now it's done for remaining arch headers.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2019-07-15 13:29:29 +02:00
Tomasz Lauda 2eb5857c77 arch: xtensa: merge UP and SMP architectures
Merges xtensa UP and SMP architectures.
The amount of code which were duplicated by creating
SMP architecture as separate instance is too big
to maintain. I've decided to merge both architectures,
change explicit selection of SMP to be dependent on
configured number of cores (> 1) and add branching in
xtos based on currently used processor configuration.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2019-07-12 15:05:57 +02:00
Seppo Ingalsuo 34d0db94be Cmocka: Volume: Increase test coverage for S24_LE output format
This patch adds check for sample to not exceed S24_LE range that
could happen in int32_t type storage. The existing check for
abs(delta) > 1 does not cover such case if e.g. the reference
volume code would output e.g. INT24_MAX and the FW component
INT24_MAX + 1.

Similar check is added for every reference volume function that
outputs S24_LE format.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2019-07-09 15:15:15 +02:00
Janusz Jankowski 084e7d6e79 test: add realloc stubs
Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
2019-07-03 13:55:30 +02:00
Tomasz Lauda 25bbc9f5cd schedule: extract schedulers to separate directory
Extracts schedule related implementations to the separate
directory to make it easier to locate and implement new
schedulers in the future.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2019-06-24 17:24:59 +01:00
Marcin Rajwa afbb2a6f53 memcpy: fix bug in memcpy_s for cmocka
memcpy_s has wrong check condition for
overlapping sections. The copy from adjacent memory
bloks will result in dsp panic while it should be
allowed. This patch fixes the issue for cmocka
tests.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2019-06-18 23:16:21 +02:00
Adrian Bonislawski f1fe78367a memory: new memory layout for APL, ICL, CNL and SUE
This will optimize memory usage and introduces two significant optimizations:

> Separate the memory (heaps, stack) by cores so if we will turn off a specific core we can also turn off all memory of this core.
> Remove fixed defines and gaps, previously stack was at fixed position: end of memory and buffer heap was everything between stack and fw. Now everything will be packed at sof_fw memory segment and takes only this memory which is really needed, everything else we can turn off.

Changelog:
BSS section now includes heaps and stack
Removed many heap fixed position defines
Removed gap before fw text section
memmap init is using real linker positions for heaps
Temporary stack for boot_ldr placed in heap_hp_buffer (safe)
sof fw max_size and segment limited to memory configured by memory banks count

Using new macro to stack init per core
Stack is no longer a one big block for all cores (core_count*stack_size)
System_runtime_heap and system_heap are no longer a one big block for all cores

For suecreek memory it will also introduce similar changes previously introduced
in other platforms
(One shared memory block SOF_FW for SOF_TEXT, SOF_DATA and SOF_BSS sections
Moved fw_ready near to .rodata and .data)

Memory layout for every slave core aligned to hw memory bank:
--align to memory bank--
system_heap
system_runtime_heap
stack
--align to memory bank--
next slave core..

Similar layout applies to master core

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@linux.intel.com>
2019-06-11 13:49:37 +02:00
Marcin Rajwa fb111cdebe cmocka: update KPB tests for new dependencies
KPB source code started to use timer related features
therefore cmocka tests need to include these
dependencies.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2019-06-11 13:25:16 +02:00
Marcin Rajwa b33574ce65 cmocka: update kpb test case
KPB_MAX_BUFFER_SIZE has changed therefore cmocka test
which uses this macro needs to be changed accordingly.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2019-06-06 09:47:33 +01:00
Tomasz Lauda 4d22a98f6c idc: change waiting code to be ms based
Changes waiting code in arch_idc_send_msg to be
milliseconds based instead of DSP cycles based.
This aligns nicely with the rest of waiting functions.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2019-06-05 21:22:50 +01:00
Janusz Jankowski 5dd9aaccb4 cmake: xtensa: use absolute paths for tools
CMake has convention of changing relative paths to absolute
for CMAKE_* variables. It does it automatically f.e. CMAKE_C_COMPILER.
However for our tools like objcopy we have to do it manually.
It also helps with integration of CMake in some IDEs.

Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
2019-06-05 11:38:23 +02:00
Janusz Jankowski c6064624f6 cmake: add spdx license identifier
Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
2019-06-02 16:38:17 +01:00
Janusz Jankowski ecd506e16d license: use spdx in .c, .h and .S files with BSD3
Use SPDX License identifier in files that already
contain BSD-3-Clause license.

Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
2019-06-02 16:38:17 +01:00
Janusz Jankowski 02ffbea1a1 test: kpb: add license
Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
2019-06-02 16:38:17 +01:00
Janusz Jankowski d59cedbe61 test: include: add license
Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
2019-06-02 16:38:17 +01:00
Janusz Jankowski e39ed5ebf4 include: split uapi headers into more directories
Some of interface headers are not needed by kernel,
but are needed by user-space applications, so we can split them
into multiple directories that indicate their purpose.

Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
2019-05-31 20:10:45 +01:00
Daniel Bogdzia 17eba5b190 test: add rballoc tests
Rballoc tests check if the current heap is full
the succeeding one would be taken

Signed-off-by: Daniel Bogdzia <danielx.bogdzia@linux.intel.com>
2019-05-30 12:02:05 +02:00
Tomasz Lauda ca45bc8303 audio: put multifile components to directories
This patch moves multifile components to separate
directories. All component headers are also moved to
include/sof/audio.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2019-05-17 17:39:45 +02:00
Jakub Dabek 3020d4aba4 memory: changed memcpy_s error handling
Failing to copy will result in FW panic

Signed-off-by: Jakub Dabek <jakub.dabek@intel.com>
2019-05-11 09:08:31 +02:00
Keyon Jie 72360bd42f kpb: fix kpb reset issue to make the consequent iteration work
We need reset kpb->state to KPB_STATE_BUFFERING, and unregister notifier
in .reset() as we will register it again at next .prepare(), otherwise,
the consequent record won't work.

Add definition of notifier_unregister() into cmoka fix the link error to
avoid breaking UT at the same time.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2019-05-07 12:26:56 +02:00
Janusz Jankowski 3a65b78f5f host: replace CONFIG_HOST and CONFIG_LIB with CONFIG_LIBRARY
We don't need 3 symbols - they all are used in the same case.

Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
2019-05-07 08:49:48 +02:00
Seppo Ingalsuo adf8d66caf Volume: Improve coverage of cmocka tests
To help catching overflows this patch exercises the volume
component test with larger absolute value test data, both
positive and negative numbers. A test generator is added for
S24_4LE format.

Since the reference float arithmetic sometimes calculates the
sample with less accuracy than fixed point firmware code the
error is asserted when delta of reference and firmware is larger
than one LSB. The float code is off by one sometimes with negative
samples. To not complicate the test code this simple relaxation is
proposed.

The table of test inputs is commented with numbers to help to quickly
find a failing test case function if such happens from printed output
from cmocka test run.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2019-04-29 09:57:16 -07:00
Keyon Jie cbf2be22ed component: refine state change for xrun handling
When trigger xrun arrives, we will reset the component state to be
READY, which means prepare will needed before we can recover.

Update state machine diagram and cmoka unit test cases also.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2019-04-24 22:38:26 +01:00
Marcin Rajwa 304336ba60 CMOCKA-KPB: test and verify internal buffering
Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2019-04-19 17:52:45 +02:00
Marcin Rajwa e39d0729e7 CMOCKA-KPB: perform copy test and its verification
Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2019-04-19 17:52:45 +02:00
Marcin Rajwa e6967498c1 CMOCKA-KPB: connect sink and source to KPB device
Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2019-04-19 17:52:45 +02:00