Commit Graph

5732 Commits

Author SHA1 Message Date
Curtis Malainey 6cd9f6a251 abi: fix macro size overflow
ubsan found the following bug via oss-fuzz

/src/sof/src/ipc/handler.c:1385:9: runtime error: left shift of 15 by 28 places cannot be represented in type 'int'

This is caused by SOF_GLB_TYPE_MASK which has an implicit length of 15
(int16_t)

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2020-10-23 10:15:10 +01:00
Karol Trzcinski ed21921878 gitignore: Add checkpatch temporary file to gitignore
Any generated file should be tracked by git to keep repositiry clean.
Such an file should be added to .gitignore to reduce possibility of
accidentally pushig this file to remote branches, eg. after typing
`git add *` before pushing changes.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-22 13:05:23 +01:00
Karol Trzcinski 15092530ba sof: Remove temporary .checkpatch-camelcase.git. file from git
This file is generate by checkpatch run, any temporary file shouldn't
be tracked by git. It was added to git by:
538eb6a: ("host: stub about required functions")

Moreover file is problematic for developers working on Windows,
now try to pull changes from remote repository ends up with:
  $ git pull
  error: invalid path '.checkpatch-camelcase.git.'
  Updating 6e85152..7709924`

cloning repository ends up with:
   $ git clone https://github.com/thesofproject/sof.git
   Cloning into 'sof'...
   remote: Enumerating objects: 97, done.
   remote: Counting objects: 100% (97/97), done.
   remote: Compressing objects: 100% (96/96), done.
   remote: Total 67251 (delta 49), reused 4 (delta 1), pack-reused 67154
   Receiving objects: 100% (67251/67251), 13.41 MiB | 2.62 MiB/s, done.
   Resolving deltas: 100% (49768/49768), done.
   error: invalid path '.checkpatch-camelcase.git.'
   fatal: unable to checkout working tree
   You can inspect what was checked out with 'git status'
   and retry with 'git restore --source=HEAD :/'

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-22 13:05:23 +01:00
Karol Trzcinski e04610b197 alloc: Print information about runtime shared zone in heap_trace_all()
Runtime shared zone should share this functionality with others
runtime zones.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-21 14:57:09 +01:00
Karol Trzcinski 1f596beb3e alloc: Remove SOF_MEM_FLAG_SHARED
It should be replaced with new SOF_MEM_ZONE_RUNTIME_SHARED
for memory which will need free and SOF_MEM_ZONE_SYS_SHARED
elsewhere.
This commit removes old way of defining allocating shared
memory region and in new way, platform_rfree_prepare()
doesn't need to translate address for cavs platform,
because runtime shared heap is defined on uncashed memory
region internally.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-21 14:57:09 +01:00
Karol Trzcinski 489bff14e1 alloc: Handle operations on shared heap
New memory zone needs dedicated heap routines.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-21 14:57:09 +01:00
Karol Trzcinski 43124daf39 alloc: Define new memory zone, shared
Shared memory shouldn't be connected with any cpu core,
because in general such an resource may be shared between
any number of arbitrary chosen cores.

Connecting it with with core 0 heap, leads to unbalanced
heap usage between core 0 and secondary cores.

Moreover operations like alloc and free may be called from
two different cores, what's not possible in current implementation.
Such an situation is especially possibly during handling resources
describing hardware components, eg. DAI or DMA, from two different
cores.

Moving shared memory management to dedicated heap, allows to easily
use another memory region, what may be needed to fulfill platform
specific demands.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-21 14:57:09 +01:00
Karol Trzcinski 901e7b4945 alloc: Refactor get_heap_from_ptr()
Extract common part to internal function, to allow easily add
new heap in future and remove code duplication.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-21 14:57:09 +01:00
Karol Trzcinski 760f504eef alloc: Refactor rmalloc_sys, use mm_heap* instead core id as input
This allows to reuse this functions for another heaps.
Moreover it helps to omit double memmap committing,
because each client of this function already use memmap,
so is oblidged to call platform_shared_commit().

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-21 14:57:09 +01:00
Ryan Lee 7270988c71 smart amp:fix for the volatile parameter range
DSM_API_ADAPTIVE_PARAM_END was not included.

Signed-off-by: Ryan Lee <ryans.lee@maximintegrated.com>
2020-10-21 12:21:17 +01:00
Ryan Lee ec536c8cea smart amp:allow set parameters at runtime
This modification allows parameter write at runtime.
Same modificatino was added to smart_amp_test.c

Signed-off-by: Ryan Lee <ryans.lee@maximintegrated.com>
2020-10-21 12:21:17 +01:00
Ryan Lee 3e849c59c6 smart amp:apply fix for handling buffer data invalidation and writeback
Propley handle buffer data invalidation and writeback.
This is importnat to keep data synchronized.
Took modification from smart_amp_test.c

Signed-off-by: Ryan Lee <ryans.lee@maximintegrated.com>
2020-10-21 12:21:17 +01:00
Ryan Lee 7f315a7185 smart amp: set rate in feedback channel
Update sampling rate for feedback channel

Signed-off-by: Ryan Lee <ryans.lee@maximintegrated.com>
2020-10-21 12:21:17 +01:00
Ryan Lee 75dfdb53dd smart amp:removed hardcoded frame_fmt value
frame_fmt for feedback was hardcoded to S32_LE format.
This workarround code is no longer needed.

Signed-off-by: Ryan Lee <ryans.lee@maximintegrated.com>
2020-10-21 12:21:17 +01:00
Ryan Lee 95ee7a8df4 smart amp:use comp_get_state
Use 'comp_get_state' function to read state instead of
doing directly access to state member viariable.

Signed-off-by: Ryan Lee <ryans.lee@maximintegrated.com>
2020-10-21 12:21:17 +01:00
Ryan Lee 4f1bb0c1ae smart amp:removed references to .avail members of audio_stream
Use 'audio_stream_get_avail_frames' instead of directly accessing .avail

Signed-off-by: Ryan Lee <ryans.lee@maximintegrated.com>
2020-10-21 12:21:17 +01:00
Karol Trzcinski 9e131360fc logger: Check for unused arguments
There is no place for unused arguments, their are consequence of invalid
argument list as usual.
Such an situation is highly possible especially during defining trace
filters, eg `-Fv=mux 4.1` instead `-F"v=mux 4.1"` or `-Fv=mux4.1`.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-21 11:48:19 +01:00
Daniel Baluta 7709924f16 drivers: imx: sai: Make sure Tx/Rx is disabled at stop
TE/RE bit will remain set until the end of current frame. So,
for example, even if we set TE to 0 the transmitter will still be
enabled until the end of current frame.

This can have unexpected results when quickly restarting a channel.
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2020-10-20 15:57:49 +01:00
Pan Xiuli 2fe7c89489 logger: change the usage string for filter
Change the misleading usage info for filter.
Add format as tips for filter string.

Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
2020-10-20 11:08:20 +01:00
Pan Xiuli b804e1df7e logger: fix opt for filter parameter
The -F filter option has argument, we should use
F: instead of F in the optstring.

Fixes: #3530

Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
2020-10-20 11:08:20 +01:00
Karol Trzcinski 1ad0269f5d logger: Fix log_err usage at early stages of sof-logger run
This function could fail when called before convert()

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-20 10:41:17 +01:00
Yong Zhi 2de506025f topology: sdw: Update echo ref channel number on max98373
The topology has two speaker amp configured, with voltage info
feedback-ed to host for each channel in the EchoRef, so update
SMART_REF_CH_NUM accordingly.

Signed-off-by: Yong Zhi <yong.zhi@intel.com>
2020-10-20 10:38:06 +01:00
Curtis Malainey 955201897d oss-fuzz: add ipc fuzzer
Add shim to fuzz the full ipc space with

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2020-10-20 09:28:28 +01:00
Curtis Malainey 8b680d5338 host: enable ipc handler module
The handler is the primary entry point for the fuzzer and therefore
needs to be added to the build.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2020-10-20 09:28:28 +01:00
Curtis Malainey 3ce2279520 ipc: stub out mailbox write
In a library build we don't care about replies, so lets just no-op this
function

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2020-10-20 09:28:28 +01:00
Curtis Malainey 54b3245b25 host: add dai to build
this is needed to expose the ipc handler

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2020-10-20 09:28:28 +01:00
Curtis Malainey c5a0cf0d27 host: move edf_schedule to platform
move to allow other programs to use the scheduler

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2020-10-20 09:28:28 +01:00
Curtis Malainey fa317ffca9 host: disable memory usage scan
don't need initially, will be supported later

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2020-10-20 09:28:28 +01:00
Curtis Malainey 9b9264d03b host: move sof_get to platform
Move out of testbench so whole system can use as needed

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2020-10-20 09:28:28 +01:00
Curtis Malainey 538eb6ab34 host: stub about required functions
Many functions are needed for building that are not relevant to the
platform. Stub these out so the system can be fuzzed correctly.

Also fix up a misisng header

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2020-10-20 09:28:28 +01:00
Curtis Malainey 716206bcd9 host: add DMA definitions
Add dummy definitions to satisfy build requirements

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2020-10-20 09:28:28 +01:00
Curtis Malainey 177473c386 host: conditionally build trace module
Only build trace when its needed

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2020-10-20 09:28:28 +01:00
Curtis Malainey aee69115ba build: allow host build to be static
oss-fuzz does not support dynamic linking, therefore we need to add
support for static builds

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2020-10-20 09:28:28 +01:00
Curtis Malainey 149addaef6 host: remove Wl flag as it upsets clang
remove this flag as clang-12 considers it unused

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2020-10-20 09:28:28 +01:00
Bartosz Kokoszko 06cfb2921b perf_cnt: cast timer value to uint32_t type
In order to get proper perf counters peaks values
we should cast arch timer value to uint32_t.

Arch timers API allows user to get uint64_t value.
In fact arch timer consits two parts. 32 bits (MSB)
software part and 32 bits (LSB) hardware timer.
The 32 bits (MSB) software part is incremented only
during hardware timer rollover when timer interrupts
are enabled. If interrupts are not enabled (perf_cnt
case), incrementation will never appear.

Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
2020-10-19 16:27:41 +01:00
Marc Herbert ec3ccab1b0 xtensa-build-all: document PRIVATE_KEY_OPTION and deprecate -k
Following commit 88b69cc2e5 ("scripts: xtensa-build-all: Add support
for building TGL and signing with MEU") we now have an unified and
flexible PRIVATE_KEY_OPTION that can do anything with very little code.

The -k option was never a good idea in the first place because it
already required an environment variable anyway (RIMAGE_PRIVATE_KEY)
instead of a command line argument so the code should have just checked
whether RIMAGE_PRIVATE_KEY was defined, that would have been
enough. Requiring the user to "double-confirm" with -k has been adding
extra complication for both the user interface and the implementation.

xtensa-build-all is effectively a "CMake configuration convenience"
script, however it shouldn't become an additional layer of indirection
and complexity and its interface should expose CMake (which is already a
layer of indirection!) as directly as possible.

See longer discussion in PR #3187

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-10-19 15:15:52 +01:00
Bartosz Kokoszko 53202aaf18 arch_timer: check for rollover in arch_timer_set
In case when new timeout requires timer rollover
we should set ccompare value to 1 in order to
increment timer->hitime properly in timer_64_handler().

Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
2020-10-19 14:36:07 +01:00
Karol Trzcinski efc6f2312c trace: Compare pointer with NULL before use
Possible null pointer dereference was possible here.
There is no need to log error message here, it's done
from trace_filter_ipc_comp_context() and ipc_trace_filter_update().

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-19 14:35:46 +01:00
Curtis Malainey 1512a49bfa component: initialize new devices to INIT state
As per component graph we start devices in INIT state. Since most
components don't use this state anyways lets just init the struct to
this state and remove it where it is used correctly.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2020-10-19 14:34:31 +01:00
Guennadi Liakhovetski 8a5059a8c0 xtensa: global default core count
Instead of specifying the default core count for each Xtensa DSP
architecture set it globally to the available maximum core count.
The user can still reduce the number to save power.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2020-10-14 22:14:01 +01:00
Karol Trzcinski 6e8515216d trace: dai: Make dai type and index more descriptive in traces
Form %d.%d may be easily paired with pipeline and component id,
whats not correct.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-12 19:19:28 +01:00
Karol Trzcinski b1d0fd7e64 trace: ipc: pipeline: Make error logs more detailed in ipc_pipeline_new()
It's not obvious that icd refers to pipeline scheduling component,
so added this information to log message. By the way, scheduling
component id has been printed.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-12 19:19:28 +01:00
Jaska Uimonen 0ed7023861 topology: add dmic channel maps for different channel counts
Volume and switch controls in the dmic pipeline need different channel
maps based on dmic channel count. This will enable the control of all
channel volumes and mutes from user space.

Signed-off-by: Jaska Uimonen <jaska.uimonen@intel.com>
2020-10-12 16:09:44 +01:00
Guennadi Liakhovetski 256c934375 smp: make MAX_CORE_COUNT an automatic Kconfig parameter
Add a new CONFIG_MAX_CORE_COUNT, set it automatically, depending on
the platform and use it to limit CONFIG_CORE_COUNT.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2020-10-12 11:42:51 +01:00
Guennadi Liakhovetski 265fb6ce0f smp: replace PLATFORM_CORE_COUNT with CONFIG_CORE_COUNT
PLATFORM_CORE_COUNT is always defined to be equal to
CONFIG_CORE_COUNT except when CONFIG_LIBRARY is set. This patch
removes this redundancy, uses CONFIG_CORE_COUNT directly everywhere
and limits it to 1 for CONFIG_LIBRARY and for Zephyr builds.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2020-10-12 11:42:51 +01:00
Karol Trzcinski f97e9f0de6 ipc: Remove user_abi_version from mailbox
This information is already provided by extended manifest,
so there is no need to double it in runtime code.
It allows to save 16 bytes from .DATA and 128 bytes from .TEXT
for cnl platform.
`data_structs` library from src/ipc/CMakeLists.txt is no longer
needed. Moreover empty library may lead to cmake fail.
SMEX needs little update, to read DBG_ABI from .fw_metadata section
instead of .fw_ready.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-12 11:41:11 +01:00
Karol Trzcinski c037800d7a ipc: Remove sram_window from mailbox
This information is already provided by extended manifest,
so there is no need to double it in runtime code.
It allows to save 400 bytes from data .DATA and 64 bytes from .TEXT
for cnl platform.
EXT_MAP_PORT() macro is no longer needed.
Created __unused macro in compiler_attributes.h as compiler
attributes shouldn't be used directly, to allow easy compiler change.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-12 11:41:11 +01:00
Karol Trzcinski 095e3ac8ae ipc: Remove probe_support from mailbox
This information is already provided by extended manifest,
so there is no need to double it in runtime code.
It allows to save 28 bytes from .DATA and  128 bytes from .TEXT
for cnl platform.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-12 11:41:11 +01:00
Karol Trzcinski 737bdb877f ipc: Remove cc_version from mailbox
This information is already provided by extended manifest,
so there is no need to double it in runtime code.
It allows to save 92 bytes from .DATA and 128 bytes from .TEXT
for cnl platform.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-12 11:41:11 +01:00
Yong Zhi e5d17f3c10 Topology: intel-generic-dmic-kwd Add DMIC PROC option
Add DMICPROC option so that DMIC01 can use EQ IIR etc.

Signed-off-by: Yong Zhi <yong.zhi@intel.com>
2020-10-08 11:53:24 +01:00