Changes implementation of notifications allocation.
Instead of using common empty list of messages let's
switch to allocating message per source of notification.
This way we won't have problem with memory and lack of
empty messages and also we will be able to optimize memory.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
This commit moves fetching mux/demux processing functions from
mux_prepare() to mux_set_values(). It insures us against
situation when we fetch proc_func in mux_prepare() and
after that comes mux_set_values() with new mux config.
Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
Implements remote operations for params, prepare, trigger
and reset calls. If the target component is running on
different core, we should send IDC in order to execute
appropriate operation.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Implements locking and cache synchronization for buffers,
which are connecting components running on different cores.
We need to explicitly use cache here (if platform supports it),
so the shared API cannot be used in this particular case.
Shared is going through uncached area on cAVS platforms,
but it's too slow in the case of frequent buffer accesses.
Also loop in pipeline_set_params has been changed to avoid
unnecessary cache accesses after unlocking the buffer.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Adds separate task to components, which are supposed to be scheduled
on different core than the rest of the pipeline. These are so called
shared components. This way components requiring huge processing power
can be offloaded to slave cores.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Implements component reallocation in shared memory. This way
cores can share components, which are part of one core's pipeline,
but runs on other core.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Back pointer must be initialized before any instance
level logging is performed by the new() operation since
the instance identification requires access to the uuid
that will be implemented on the component driver level.
Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
Static inline getters provides better control of use
component properties as L- and R-values.
They also make changes to the common component data defs
easier and transparent for clients (no code changes, just
recompilation required).
Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
Implements comp_verify_params() function, which can be used in order
to set and update some of sink (playback) or source (capture) buffer
parameters with pcm parameters. There is a possibility to specify
which of parameters won't be overwritten (e.g. SRC component should
not overwrite rate parameter, because it is able to change it).
Commit also adds macros to buffer.h, which can be used in order
to specify which parameter of source/sink buffer should not be
updated.
Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
This patch refactor KPBs macros:
KPB_SAMPLING_WIDTH to KPB_SAMPLES_PER_MS as this is
exactly what this macro stands for - the amount of
samples we take each milisecond.
KPB_NR_OF_CHANNELS to KPB_NUM_OF_CHANNELS as the later
is more meaningful
Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
When new component will need to process audio data in two steps,
then temporary circular buffer will be needed. Also extra information
about data stream may be needed to choose right algorithm or assert data
compatibility.
Currently only 'comp_buffer' has such a possibility but it is component
defined in topology - with much wider capabilities - and shouldn't be
created inside component just to hold temporary data stream.
Use introduced structure in processing functions, move api responsible
for data processing from buffer to audio_stream module.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Link common_mock to each test by default.
Removed duplicated mocks in component specific folders.
Keep old mocks where implementation differs from
implementation in common_moks.c
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
In unit tests there are a lot of mocks duplication for mocks related
with memory management and panic routine.
As long as implementation doesn't have any module specific routines
and may be reused, it should be mocked in common mock space.
Marked each mock as WEAK to make it possible to overwrite this
implementation in specific test.
To use assert_false in __panic function, added dependence of
universal_mock from cmock.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
SHARED_DATA macros doesn't put shared data into separate section
when unit tests are built and uncached memory region is not used.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Changes component driver registration to use comp_driver_info
as an element to be put into the drivers list. This way
comp_driver can be constant and comp_driver_info can be
marked as shared in the future.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Adds component drivers list to sof context, so it can be
accessed globally. Also adds global getter.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Passes sof context pointer to sys_comp_init() function.
It will be needed in order to add comp_driver_list to
sof context.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
This patch reverts explicit spinlock allocation in shared
memory. From now on we assume every spinlock is already part
of the shared memory. This helps us avoid unnecessary cache
evictions, when accessing spinlock's data. Also some of the
spinlock API functions require interrupt header, so they were
extracted in order to avoid circular dependency.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
This patch adds dedicated section for shared data
on cAVS platforms. This section will be used to store
static data, which can be accessed by multiple cores.
Access to this data will go through uncached memory region.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Performance ts macros use both the platform timer and cpu timer
in case the latter is not always-running-timer.
Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
Adds memory map to sof main context. Also implements
getter to easily retrieve it through one point of access.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Changes platform_init_memmap function's argument list to take
sof context. It will be needed to add memory map pointer into
sof context.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Changes accesses across the code to use platform_timer saved
in sof context instead of using externed global variable.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Creates new mem_zone enum type for heap zones.
We don't want to leave them as flags and allow
zone combinations.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Removes zone argument from balloc related functions.
They always use RZONE_BUFFER, so passing something else
is very misleading, especially it changes nothing.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Extracts flags from zone to use them as a separate argument
during allocations. It allows for addition of new zones and
also is more clear this way.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Lower power state must be disabled before host wakes up and
sends 'quit D0ix' to make sure the draining goes at full speed.
Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
Removes need to pass EDF task priority during initialization.
Also removes priority definitions, which were only used by
EDF scheduler. Priorities of EDF tasks are now deprecated.
We are scheduling based only on deadline.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Extracts task operations to separate struct. This way we can
add additional ops without need to endlessly adding parameters
to schedule_edf_task_init function.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Separates task init functions for all currently supported schedulers.
Some of the parameters are not common, so there is no need to
artificially extend function signatures.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
This patch refactor KPBs macros:
KPB_SAMPLING_WIDTH to KPB_SAMPLES_PER_MS as this is
exactly what this macro stands for - the amount of
samples we take each milisecond.
KPB_NR_OF_CHANNELS to KPB_NUM_OF_CHANNELS as the later
is more meaningful
Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
This patch changes usage of notifier, passing control over callbacks
allocation, allows nested callbacks processing and prepares interface
for future extenting.
This also optimizes unnecessary cache writeback/invalidation when
evaluating callback on the same core it was dispatched.
Signed-off-by: ArturX Kloniecki <arturx.kloniecki@linux.intel.com>
Moving pcm params from component to buffer is the first
step to improve parameter propagation within pipelines. This commit
moves several pcm paremeters (framet_fmt, buffer_fmt, rate,
channels, chmap, except direction) to comp_buffer struct.
Some of specific parameters are moved to private host and
kpb data.
Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
Changes processing flow and moves pcm frame format conversion
from volume to dai component. This way we'll no longer need to
artificially add volume into the pipelines, where it's not really
needed but frame format change is e.g. KPD topology. Dai is the perfect
place for conversion, since it's format is pretty much predefined and
comes from topology. Rest of the pipeline is configured from the host.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Use RELATIVE_FILE because __FILE__ makes binary output
dependent on project location.
Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
Do not run unit tests on unsupported by configuration
data types. See CONFIG_FORMAT_* macro.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
It will be helpful during next step - conditional code
compilation depending on configuration
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Do not include data type test when it is not supported by
some platform or firmware version.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Change flow of components to not resize sink buffers.
We should just check the size of the allocated buffers
and let the topology define the maximum sizes.
Components can easily work with non aligned buffer sizes.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Adds and initializes id, pipeline_id and caps fields in buffer struct.
This is the only data needed after buffer creation. It allows us to
remove the whole sof_ipc_buffer struct from the buffers.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
When new pipeline is created we need to also verify whether
given pipeline id is already taken.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Add alignment option for memory requests.
Fix alloc definitions for UT.
Function definitions were using defines in their body
which blocked usage of const values in said defines.
Signed-off-by: Jakub Dabek <jakub.dabek@intel.com>
Changes implementation of pipe_task allocation and initialization
to happen in prepare call instead of during pipeline creations.
It might be that the pipeline will never be used.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Adds complete callback to task. Some EDF tasks will need to have
additional callback on task completion, which will be executed
in critical section along the setting task state to complete.
Doing it during regular execution is not enough, because it's done
on passive level and we want to avoid any race condition.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Moves idc implementation to cavs drivers instead of keeping
it in generic xtensa arch directory. IDC is specific for
SMP cAVS platforms.
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
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>