In case when we overwrite "old" data in buffer
(when buffer is full) we should align r_ptr
with w_ptr.
Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
Refactors schedule code in order to allow dynamic scheduler
creation. We don't want to add every new scheduler to the static
array of scheduler_ops and also we don't want to have every
scheduler created on every platform. Maybe some of the platforms
won't need some of the future scheduler types.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>