Commit Graph

6424 Commits

Author SHA1 Message Date
Guennadi Liakhovetski 61c91be9fd scheduler: remove .scheduler_run
The .scheduler_run() operation is never used, remove it.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-05-04 16:10:49 +01:00
Guennadi Liakhovetski fad27f13d1 zephyr: remove LOG_* API left-over
Remove a log-module declaration to eliminate unused static
variables until we return to using the LOH_* Zephyr API.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-05-04 16:10:49 +01:00
Guennadi Liakhovetski e111252a5f zephyr: move library platform code to platform.c
Move logging code and static data to platform/library and
declare a LOG module properly.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-05-04 16:10:49 +01:00
Guennadi Liakhovetski 1e4ff1ed5b perf: (cosmetic) use a high level API function
Call timer_get_system() instead of arch_timer_get_system().

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-05-04 16:10:49 +01:00
Guennadi Liakhovetski 23fc4e5bc9 cavs: (cosmetic) add a comment to clarify function scope
Clarify, that platform_init() only runs on the primary core.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-05-04 16:10:49 +01:00
Guennadi Liakhovetski 369a59431a scheduler: make ops static
In both native and Zephyr builds schedule_edf_ops and
schedule_ll_ops are only used in one file each, make them
static.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-05-04 16:10:49 +01:00
Guennadi Liakhovetski 0c7e4c3255 init: (cosmetic) simplify a function
Simplify a function by removing a redundant variable.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-05-04 16:10:49 +01:00
Guennadi Liakhovetski ea1eda4faf xtensa: (cosmetic) fix a typo in a comment
Fix a typo: remove a duplicate "the."

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-05-04 16:10:49 +01:00
Marc Herbert ce52555173 numbers.h: simplify #ifndef ZEPHYR for MIN and MAX
Undefining and re-defining MIN/MAX when already defined is
convoluted. Simply define them if not __ZEPHYR__ instead.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-05-04 16:05:58 +01:00
Jaska Uimonen 301b98e5d2 dai: add check for NULL pcm converter function
If processing format is restricted from Kconfig there's a possibility of
pcm_converter not having proper conversion function. Thus check for NULL
in dai to avoid crashes.

Signed-off-by: Jaska Uimonen <jaska.uimonen@intel.com>
2021-05-04 16:05:36 +01:00
Brent Lu 1ccc16c27d topology: sof-glk-da7219: add support for cs42l42
Add support for cs42l42 running on GLK boards. We add a 10 ms BCLK
delay to the SSP_CONFIG_DATA of SSP2 since the codec PLL is locking on
BCLK. Without the delay, there could be noise on TX path.

Signed-off-by: Brent Lu <brent.lu@intel.com>
2021-05-03 22:17:13 +01:00
Curtis Malainey 7f604fb63f mux: conditionally compile format specific functions
we are building unused functions if we only enable specific formats,
lets put them with the functions that use them

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2021-05-03 22:11:33 +01:00
Marc Herbert cf85f21d08 numbers.h: downgrade MIN() and MAX() to unsafe versions
For compatibility with Zephyr, MIN and MAX macros are downgraded to the
basic, compile-time, standard compliant and unsafe implementation.

This means the code will now be the same whether it's compiled with Zephyr
versus not.

Fixes https://github.com/zephyrproject-rtos/zephyr/issues/33567 which
means it's now possible to use MIN() or MAX() in either Zephyr's
BUILD_ASSERT() or in SOF's equivalent STATIC_ASSERT() or in C11's
_Static_assert()

This implementation is unsafe because it can evaluate its arguments
twice which is obviously not desired when the argument has side-effects:

https://wiki.sei.cmu.edu/confluence/display/c/PRE31-C.+Avoid+side+effects+in+arguments+to+unsafe+macros

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-05-03 10:04:09 +01:00
Marc Herbert 9622079d2f Remove all function calls in arguments to MIN() and MAX() macros
For consistency with Zephyr, MIN and MAX macros are "downgraded" to the
basic, compile-time, standard compliant and unsafe implementation that
Zephyr uses. "Unsafe" because it can evaluate its arguments twice which
is obviously not desired when the argument has side-effects:
https://wiki.sei.cmu.edu/confluence/display/c/PRE31-C.+Avoid+side+effects+in+arguments+to+unsafe+macros

I reviewed every single invocation of MIN() and MAX() and found no
increment or assignment but I found a number of function calls in their
arguments. This commit removes them all. Note I did _not_ check for
volatile variables.

Most of these functions do not appear to have side-effects _but_ it's
much simpler and faster for the reader or static analyzer not to even
have to wonder about the possibility of side-effects and it's also more
future-proof; no risk of a function accidentally gaining side effects.

Note the following files are not compiled in the default configurations
and the changes in them were NOT compile-tested locally:

src/audio/codec_adapter/codec_adapter.c
src/audio/drc/drc_generic.c

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-05-03 10:04:09 +01:00
Marc Herbert e27cb45663 .github: add scant_fuzzer.yml build
This is NOT how to properly compile the fuzzer, this is only to detect
earlier and faster problems like
https://github.com/thesofproject/sof/pull/3824 (288e228) and
https://github.com/thesofproject/sof/pull/4118 (758e7be)

In other words, when reverting the oss-fuzz parts of either of these
commits this build fails as desired.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-05-03 09:31:00 +01:00
Daniel Baluta c2fe4ff10b codec_adapter: Add CONFIG options to select Cadence libraries
Each type of codec will have its own config option that will point
to the path in build filesystem where library binary is located.

This will make compiling Cadence libraries binaries more flexible.

The libraries will be statically linked with SOF firmware.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2021-04-30 16:31:46 +03:00
Marcin Rajwa 71bad3eef7 codec_adapter: state rework
This patch simplifies codec adapter state machine by removing
redundant state "ca_state" plus extending the other one with
new states like IDLE or PROCESSING.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2021-04-30 11:57:43 +01:00
Marcin Rajwa 65184ad300 codec_adapter: allow early config apply
This patch allows to apply runtime configuration as soon
as codec got created. This is too avoid high load spikes
which may happen when whole, large config blob is being
applied along side codec processing.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2021-04-30 11:57:43 +01:00
Marcin Rajwa 6c106e1567 cadence codecs: move reset of default values to init
Thanks to this change we reset all params to default values
on start, and reset only. The later is because on reset we
call init again due to lack of explicit reset API for cadence
codecs. Now we can apply runtime params earlier, during prepare or
as soon as codec has been instantiated and they won't be reset.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2021-04-30 11:57:43 +01:00
Marcin Rajwa 611f81e7a7 codec_adapter: Remove redundant state verification
The state has already been verified on the codec_adapter level.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2021-04-30 11:57:43 +01:00
Curtis Malainey 758e7be0c9 oss-fuzz: fix build
looks like with the new ipc mechanisms we changed the function signature
and moved casting the message from platform code to ipc code.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2021-04-30 11:50:16 +01:00
Marc Herbert 014a386dfb .github: add Zephyr build
Use the official image from the Zephyr project
https://github.com/zephyrproject-rtos/docker-image

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-04-30 11:12:29 +01:00
Marc Herbert 33c5f5d38e xtensa-build-zephyr: do not clone a second version of sof.git
This script lives in a sof.git/ clone yet it was systematically cloning
a second sof.git/. Besides the obvious confusion and risk of editing the
wrong files, this meant it was not possible to build code that has not
been merged yet! This was a problem for both CI and developers. Fixed by
using symbolic links to ourselves instead.

Note it is _still_ possible to build from another sof.git clone if
desired, however this script will never git re-clone a second sof.git
itself, that second clone has to be created (e.g.: by west) before this
script runs.

When cloning a brand new zephyrproject, use a shallow zephyr clone and
download only the two zephyr modules we actually use. This speeds up
automation considerably and makes it much faster for non-Zephyr
developers to reproduce Zephyr issues. Developers can always git
unshallow and west update once if they want to.

Rename the default west top to "zephyrproject" to not just match the
zephyr documentation but to also avoid creating a double zephyr/zephyr/
directory.

See the new print_usage() for a few more implementation details.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-04-30 11:12:29 +01:00
Marc Herbert 831bb3755b xtensa-build-zephyr: fix "die()" function
It still looks smart but the \n addition compared to the original
version in xtensa-build-all.sh broke it for more advanced cases:

die '%s %d' str 5
-bash ERROR: -bash: printf: 5\n: invalid number

As reported by shellcheck. shellcheck saves lives.

In scripts/xtensa-build-zephyr.sh line 22:
	>&2 printf "$@\n"
                       ^-- SC2145: Argument mixes string and array.
                        Use * or separate argument.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-04-30 11:12:29 +01:00
Marc Herbert 80c482815b xtensa-build-all.sh: replace "type xtensa-bxt-elf-gcc" with "command -v"
... because the latter does not print on stderr when not found; so IDEs
and CIs don't display this as a warning.

Also remove the "... and ignore set -e" comment that made sense at the
time of commit cad86dc340 ("scripts: xtensa-build: fix alias detection
for bxt/apl gcc") but not anymore.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-04-30 11:11:22 +01:00
Marc Herbert 7dbcd7ee33 logger: add ktime and date in header
Every log file should have a date.

ktime can be related to the TIMESTAMP column. It is especially useful to
spot logs delayed or stuck.

Some logs use ktime while others use a date and it can be sometimes
difficult to connect them with one another. This header can help.

Before:

TIMESTAMP (us) DELTA C# COMPONENT CONTENT

[  5120116529] (  0) c0 dma-trace ERROR FW ABI 0x3012001 ...

After:

TIMESTAMP (us) DELTA C# COMPONENT \
                   CONTENT ktime=5132.663s @ 2021-04-27 14:36:09 -0700 PDT

[  5120116529] (  0) c0 dma-trace ERROR FW ABI 0x3012001 ...

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-04-29 12:09:10 +01:00
Daniel Baluta 67fdbd2e16 installer: Fix installer test
After commit 5ca0e9bba3 ("topology: Use generic name for 8qxp/8qm")
installer test is broken as we also need to update the i.MX topology
with the new naming.

So, fix this by replacing imx8qxp naming with imx8. But while we are at
it choose a better (more relevant) random topology, sof-imx8-wm8960.tplg
instead of sof-imx8-nodec.tplg.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2021-04-29 11:55:25 +01:00
Daniel Baluta 5ca0e9bba3 topology: Use generic name for 8qxp/8qm
i.MX8QXP / i.MX8QM have the same configuration w.r.t topology.
But since we firstly added support for 8qxp all the names use
8qxp and then for 8qm we just borrow the files but using the 8qxp
naming.

This sometimes might cause confusion. So, we group under the
umbrella of imx8 naming both i.mx8qxp and i.mx8qm.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2021-04-28 20:11:19 +01:00
Seppo Ingalsuo 7522a7b6fc Audio: ASRC: Move DAI timestamping setup request to trigger start
The asrc_dai_configure_timestamp() caused a DSP panic when called from
asrc_prepare(). The reason is that DAI prepare now happens after ASRC
prepare. Call from trigger start is after pipeline prepare so it
avoids this problem.

Fixes: #4068

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2021-04-28 20:08:42 +01:00
Seppo Ingalsuo 634de25275 Audio: DAI: Error on attempt to use null pointer
This patch adds error handling for case where DAI data pointer
to DMA channel is not set. The situation can happen if ASRC tries
to set up timestamping before DAI has been prepared.

More specifically access to dd->chan->index with NULL in chan
caused a DSP panic.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2021-04-28 20:08:42 +01:00
Marc Herbert 158089ceb6 Add and fix many logger and dma-related comments. No code change.
Learned the hard way.  Will help refactoring or duplicated
"reverse-engineering" effort.

Zero code change, pure comments: no functional change.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-04-28 15:52:44 +01:00
Guennadi Liakhovetski b5b244f116 math: remove path.h dependency
math.h is an external header, provided by libc, whereas SOF
is a stand-alone executable, that must not depend on any system
headers. Particularly math.h isn't available when building with
Zephyr. The only inclusion of math.h in SOF currently is only
needed for the M_PI definition. Define it locally with a
slightly different name to eliminate the dependency and fix
Zephyr builds.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-04-27 13:50:38 +01:00
Marc Herbert d6f6a456c1 logger: fix column and header alignments
Increase default width from 10 to 12 to stop common misalignment,
especially in relative mode.

New timestamp_width() function to avoid duplication and
divergence.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-04-27 12:17:53 +01:00
Marc Herbert 37e87e54b1 logger: partial rewording of one log_err() and usage message
Cosmetic change that does not fit in any other commit.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-04-27 12:17:53 +01:00
Guennadi Liakhovetski b617910feb zephyr: fix logging build breakage
The use of Zephyr LOG_*() API in SOF is breaking compilation.
Replace it with with the native trace logging until a proper
fix is available.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-04-27 12:11:41 +01:00
Liam Girdwood 9836a62bd9 ipc: abstraction: add support for other ABI major versions
Add a generic header type and update the mailbox and command handler
logic to accept generic headers. Generic header type should also support
the existing compact message API and expand it to other platforms.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2021-04-27 11:05:00 +01:00
Liam Girdwood abb0015458 ipc3: remove uneeded casts
These casts are not needed so remove.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2021-04-27 11:05:00 +01:00
Liam Girdwood 971cdea4fb ipc: common: remove unused headers and type declarations.
Not needed here so remove.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2021-04-27 11:05:00 +01:00
Daniel Baluta ba6ba3cfc6 audio: codec_adapter: Make sure local_buff has enough room for processing
We need to make sure that the local buffer has enough room to hold
the output of the processing.

This means that for each type of decoding algorithm we need to know
the maximum possible output size and skip processing if local buffer
size is less than that.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2021-04-26 16:15:30 +01:00
Daniel Baluta dfb29d5227 codec_adapter: Introduce get_samples interface
This codec_adapter interface will return the number
of samples expected after decoding one compressed input frame.

This is optional. For codecs which do not care, this will return 0.
Do not care means that the number of input samples is equal with the
number of output samples after processing is done.

This will be used in the next patch to determine if the local output
buffer has enough space to copy the decoded samples.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2021-04-26 16:15:30 +01:00
Daniel Baluta da9a5ebe24 codec_adapter: Replace hardcoded codec api ids
Replace hardcoded codec api ids with meaningful enum names.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2021-04-26 16:15:30 +01:00
Yang XiaoHua 3500d0efef include:fix zephyr conflicting types and function
The atomic code is implemented in zephyr. When sof is used as
a zephyr module, there is no need to reimplement atomic.
The modification here is to solve the problem of repeated
definition of atomic related content.

Signed-off-by: Yang XiaoHua <yangxiaohuamail@gmail.com>
2021-04-26 15:19:44 +01:00
Slawomir Blauciak b500999477 scheduler: guard against subdivision underflow on domain clear
In some situations the domain clear routine might encounter
a case, when the number of clients is decremented and 0,
as such, a subsequent subdivision will result in an integer underflow.

Signed-off-by: Slawomir Blauciak <slawomir.blauciak@linux.intel.com>
2021-04-26 15:13:30 +01:00
Viorel Suman c9f442ba6b imx8m: remove SDMA2
With SDMA2 in place now it is shared by both A and HiFi core
- this breaks 8MP EVK + WM8960 topology. Remove SDMA2 so that
SDMA2 remains assigned to A core and SDMA3 assigned to HiFi core
as it was initially planned.

Suggested-by: Paul Olaru <paul.olaru@nxp.com>
Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
2021-04-26 12:00:05 +03:00
Ranjani Sridharan 71ac0f97e9 component: do not reset component status in the case of xrun
Do not reset component status in the case of xrun.
An irrecoverable xrun will lead to the pipeline being
stopped by the host and resetting the status will result
in an error stating invalid current state during the STOP
trigger.

Also update the unit test to retain the same state during an xrun.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
2021-04-23 14:54:50 +01:00
Marc Herbert 1a79de1c16 logger: warn user about wrapped logs and skipped garbage
Don't sweep logging issues under the rug.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-04-23 13:32:17 +01:00
Marc Herbert 73378e269f trace.c: don't split mbox events over the buffer's end and lose them
Don't try to pack the ring buffer to the very last byte so we don't
split (and lose!) trace events across the end and start of the
buffer. The logger on the receive side does not support such
re-assembly.

Note this was never noticed because the logger tends to silently (!)
discard garbage like this, addressed in other commit(s).

Also switch to memset() and memcpy_s()

Fixes commit 271c75aa71 ("debugability: Fix potential buffer overflow
in mbox traces")

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-04-23 13:31:02 +01:00
Marc Herbert d54a9281f8 logger: print a separator when the timestamp goes back in time
This makes the display of the mailbox ring buffer log much less
confusing. It should not happen with the DMA trace but will behave the
same in case something goes wrong.

Before this commit the only clue that wrapping had happened was a NaN in
the delta column (instead of the negative value).

The "other?" is because the start of the mailbox is sometimes corrupted,
or the timestamp goes sometimes back at boot for no obvious reason. In
other words this new separator is useful to highlight bugs too.

Absolute mode -e 0 with this commit:

    TIMESTAMP         DELTA C# COMPONENT          LOCATION

[22598174808] (        11) c0 ipc                  src/ipc/....
[22598174824] (        15) c0 ipc                  src/ipc/....
[22598443257] (    268433) c0 dma-trace             src/trace/....
[22598443271] (        14) c0 dma-trace             src/trace/....
[22598443286] (        14) c0 dma-trace             src/trace/....
[22598943257] (    499971) c0 dma-trace             src/trace/....

		 --- negative DELTA: wrap, IPC_TRACE, other? ---

[22430943257] (         0) c0 dma-trace             src/trace/....
[22530943257] ( 100000000) c0 dma-trace             src/trace/....
[22542943257] (  12000000) c0 dma-trace             src/trace/....
[22542943271] (        14) c0 dma-trace             src/trace/....
[22542943285] (        14) c0 dma-trace             src/trace/....

Relative mode -e 1 with this commit:

    TIMESTAMP         DELTA C# COMPONENT          LOCATION

[  3080783.6] (       11.4) c0 ipc                  src/ipc/....
[  3080799.1] (       15.5) c0 ipc                  src/ipc/....
[  3349232.5] (   268433.4) c0 dma-trace             src/trace/....
[  3349246.8] (       14.3) c0 dma-trace             src/trace/....
[  3349261.2] (       14.4) c0 dma-trace             src/trace/....
[  3849232.4] (   499971.2) c0 dma-trace             src/trace/....

		 --- negative DELTA: wrap, IPC_TRACE, other? ---

[22430943257.0] (      0.0) c0 dma-trace             src/trace/....
[100000000.0] (100000000.0) c0 dma-trace             src/trace/....
[111999999.5] ( 12000000.0) c0 dma-trace             src/trace/....
[112000013.9] (       14.4) c0 dma-trace             src/trace/....
[112000028.2] (       14.3) c0 dma-trace             src/trace/....

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-04-23 13:28:26 +01:00
Yang XiaoHua 825bf79871 pcm_converter: Fix architectures not supporting XT_ROUND_S
XT_ROUND_S is available only when you include option of
"Xtensa's single precision FPU option (scalar)".
IF current DSP includes optional vector FPU (single precision).
FIROUND.S (with appropriate RoundMode state set) followed by
TRUNC.S can be used to emulate Xtensa scalar FPU’s ROUND.S, CEIL.S and
FLOOR.S instructions."FIROUND.S", does round, but no scaling.Result
still in float format.Use TRUNC.S to scale it and truncate as necessary.

Signed-off-by: Yang XiaoHua <yangxiaohuamail@gmail.com>
2021-04-23 14:22:34 +03:00
Keyon Jie d5c779918c Revert "topology: sof-tgl-nocodec-ci: change to run smart_amp on core 1"
This reverts commit cd2444adbf.

Reverting this to unblock the CI runningon tgl-nocodec-ci platform.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2021-04-22 19:43:03 +01:00