Commit Graph

6693 Commits

Author SHA1 Message Date
Marc Herbert f6c71c21d0 zephyr/CMakeLists.txt: build smex and sof-logger
Temporary solution until we switch to the Zephyr logger.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-07-13 15:56:49 +01:00
Marc Herbert 6c9bbd6fef zephyr/CMakeLists.txt: explain why we need if(CONFIG_SOF)
Not obvious plus many SOF developers are new to west.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-07-13 15:56:49 +01:00
Marc Herbert 58e7028346 zephyr/module.yml: add URL, name: and comment out default values
Add URL to documentation for convenience.

Our module name should not depend on the folder name.

Comment out default values to show that we use the defaults.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-07-13 15:56:49 +01:00
Marc Herbert 236dc0d74a smex: change usage() to exit with an error
It is admittedly not an error to use '-h' but who uses '-h' and cares
about the exit code?

Conversely, it is _very_ important to return an error when a bug in a
script passes wrong arguments to smex.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-07-13 15:56:49 +01:00
Marc Herbert 27fd46f69f .github/installer.yml: remove cp -a /usr/bin/tree hack
The docker image has it now thanks to Fred.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-07-13 15:34:45 +01:00
Guennadi Liakhovetski 871f1825c3 zephyr: fix memory allocation coherency
Commit 34bb9b7282 ("zephyr: wrapper: build SOF with Zephyr for imx")
broke coherent memory allocations on Intel DSP platforms. Restore the
original code.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-07-13 12:20:48 +03:00
Chao Song 5374da8c89 topology2: Add cavs nocodec topology
Only a playback pipeline and a capture pipeline
on SSP0 are added.

Signed-off-by: Chao Song <chao.song@linux.intel.com>
2021-07-09 12:02:01 +01:00
Chao Song 95cc4613ce topology2: Add cavs passthrough-capture pipeline
Add class definition for cavs passthrough-capture
pipeline, and it can be instantiated as:

    Object.Pipeline.passthrough-capture."N" {
	format		"s16le"
	period		1000
	time_domain	"timer"
	channels	2
	rate		48000
    }

Signed-off-by: Chao Song <chao.song@linux.intel.com>
2021-07-09 12:02:01 +01:00
Chao Song e8c71e458d topology2: Add cavs passthrough-playback pipeline
Add class definition for cavs passthrough-playback
pipeline, and it can be instantiated as:

    Object.Pipeline.passthrough-playback."N" {
	format		"s16le"
	period		1000
	time_domain	"timer"
	channels	2
	rate		48000
    }

Signed-off-by: Chao Song <chao.song@linux.intel.com>
2021-07-09 12:02:01 +01:00
Chao Song 2e1d2ecabb topology2: Add HW Config class
Add class definition for HW Config, HW Config object
can be instantiated as:

  Object.Base.hw_config."NAME" {
	id		0
	mclk_freq	24000000
	bclk_freq	4800000
	tdm_slot_width	25
    }

where NAME is the unique instance name for the hw_config
object within the same alsaconf node, for example, SSP0.

Signed-off-by: Ranjani Sridharan <ranjani.sidharan@linux.intel.com>
Signed-off-by: Chao Song <chao.song@linux.intel.com>
2021-07-09 12:02:01 +01:00
Chao Song 17902fcbf0 topology2: Add SSP DAI class
Add SSP DAI class definition, SSP DAI objects can be
instantiated as:

Object.Dai.SSP."N" {
    direction		"duplex"
    dai_name		"NoCodec-0"
    id 			0
    quirks		"lbm_mode"
    sample_bits		24
    Object.hw_config."0" {
	    mclk_freq	24000000
	    bclk_freq	4800000
	    tdm_slot_width	25
    }
    Object.dai."playback" {
	    period_source_count	2
	    period_sink_count	0
    }
    Object.dai."capture" {
	    period_source_count	0
	    period_sink_count	2
    }
}

Signed-off-by: Ranjani Sridharan <ranjani.sidharan@linux.intel.com>
Signed-off-by: Chao Song <chao.song@linux.intel.com>
2021-07-09 12:02:01 +01:00
Chao Song 3d184df6bf topology2: Add manifest class
Add class definition for manifest.

Signed-off-by: Ranjani Sridharan <ranjani.sidharan@linux.intel.com>
Signed-off-by: Chao Song <chao.song@linux.intel.com>
2021-07-09 12:02:01 +01:00
Chao Song 4be5a29275 topology2: Add FE DAI class
Add FE DAI class definition, the FE DAI object can be
instantiated as:

    Object.Base.fe_dai."NAME" {
	id  0
    }

Signed-off-by: Ranjani Sridharan <ranjani.sidharan@linux.intel.com>
Signed-off-by: Chao Song <chao.song@linux.intel.com>
2021-07-09 12:02:01 +01:00
Chao Song 256bc69f31 topology2: Add pcm capabilities class
Add pcm capabilities class definition, pcm
capabilities object can be instantiated as:

    Object.PCM.pcm_caps."DIRECTION" {
	name	    "Headset"
	direction   "playback"
	formats	    "S32_LE,S24_LE,S16_LE"
	rate_min	48000
	rate_max	48000
	channels_min	2
	channels_max	2
	periods_min	2
    }

Signed-off-by: Ranjani Sridharan <ranjani.sidharan@linux.intel.com>
Signed-off-by: Chao Song <chao.song@linux.intel.com>
2021-07-09 12:02:01 +01:00
Chao Song ae80d3b8af topology2: add PCM class
Add class definition for pcm, pcm object
can be instantiated as:
    Object.PCM.pcm."N" {
	id		2
	pcm_name	"Headset"
	direction	"playback"
    }

Signed-off-by: Ranjani Sridharan <ranjani.sidharan@linux.intel.com>
Signed-off-by: Chao Song <chao.song@linux.intel.com>
2021-07-09 12:02:01 +01:00
Chao Song 6053a4ffef topology2: add copier class
Add class definition for copier widget, it can be
instantiated as:
    Object.Widget.copier."N" {
	copier_type	"host"
	cpc	100000
    }

Signed-off-by: Chao Song <chao.song@linux.intel.com>
2021-07-09 12:02:01 +01:00
Iris Wu be3dff2780 topology1: sof-tgl-nocodec-ci: use volume capture for PCM0
capture

S32_LE without PGA is not supported in alsabat, switch to use
pipe-volume-capture and unblock the CI alsabat test case.

Signed-off-by: Iris Wu <xiaoyun.wu@intel.com>
2021-07-08 22:28:44 +01:00
Marc Herbert 4a59133b3d dma: add some NULL pointer checks
These proved useful when debugging Zephyr but they're not Zephyr specific.

Use mtrace_printf() because if we're having DMA issues we probably want
to avoid the DMA trace

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-07-08 21:34:42 +01:00
Keyon Jie 4176f56ff3 alloc: add more coverage to log all details of the allocation
Add coverage to log out details during memory allocation, including
successful allocation, and all zone types heap.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2021-07-08 21:10:56 +01:00
Ranjani Sridharan fc73578be7 drivers: Intel: SSP: ignore config when SSP is already configured
When two streams are started one after the other, 2 DAI_CONFIG
IPC's will be sent before the START trigger. This ends up
configuring the SSP when the first one has already just
configured it and ends up with xruns.

The root cause is that the ssp_set_config() function configures
a set of variables, writes those variables into SSP registers,
and later on does a read-modify-write operation on the TSRE,
RSRE and SSE bits.

If the ssp_set_config is executed more than once, this will
temporarily clear all three bitfields, and temporarily disable
DMA transfers and SSP clocks. Avoid this by checking if the
current state is > COMP_STATE_READY before configuring the
SSP, so that the ssp_set_config() function only modifies SSP
registers once.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
2021-07-08 13:35:18 -05:00
Keyon Jie 690481ae69 ll_schedule: refine to remove the dependency among DSP COREs
We don't need to wait until tasks on all DSP COREs finished, before we
can configure the next interrupt to trigger the next scheduling. Imagine
scenarios that one of the CORE is taking long time to finish a high MCPS
task, we should keep tasks on other COREs freed to be scheduled during
that period.

Calculate and re-configure the interrupt at finish of each CORE, and
re-enable domain on each CORE separately.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2021-07-07 15:59:08 +01:00
Keyon Jie dd0635c015 ll_schedule: refine the task->state update
Updates the task->state to reflect the real task status and only do
necessary check in schedule_ll_is_pending().

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2021-07-07 15:59:08 +01:00
Marc Herbert 9d84c1510c pm_runtime.c: explain the opposition between "enable" and "active"
Pure comments, no code change. Follow-up to commit 8633d5fd6d ("cavs:
pm: improve PM_RUNTIME_HOST_DMA_L1 documentation")

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-07-07 15:58:38 +01:00
Marc Herbert 259b8ce559 zephyr/wrapper.c: add "temporary fix" comment to ipc_send_queued_msg()
As requested in previous PR #4428

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-07-07 15:58:38 +01:00
Marc Herbert 4889faecb8 ipc_buffer_new: make buffer argument const
'const' documents APIs and catches bugs.

This came while discussing https://github.com/thesofproject/sof/pull/4408/

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-07-07 15:58:38 +01:00
Marc Herbert f108cfeafe Add alternative, more reliable STATIC_ASSERT() disabled by default
Does not silently succeeds when passed variables. Not enabled by default
in the unlikely case it wastes memory with some compiler and/or compiler
flags.

Issue found while testing tracing mismatch #4388

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-07-07 15:58:38 +01:00
Marc Herbert a7604433c2 imx/sdma.c: silence "may be uninitialized" warnings with gcc10.2 -O1
gcc10.2 does not see that config->elem_array.count is greater than zero
and complains. This happens only at the -O1 optimization level that is
rarely tested.

```
error: 'bd' may be used uninitialized in this function
                                  [-Werror=maybe-uninitialized]
  758 |  bd->config &= ~SDMA_BD_CONT;

error: 'width' may be used uninitialized in this function
                                  [-Werror=maybe-uninitialized]
  786 |  watermark = (config->burst_elems * width) / 8;
      |              ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
```

This is preferred over initialization at the top of the function
that hides _all_ warnings including valid ones.

Of course the even better fix would to BOTH declare and initialization
just before the loop, as late as possible just like in any other modern
and safer programming language. However C99 declarations are not allowed
yet; I've added this to the next TSC agenda:
github.com/orgs/thesofproject/teams/steering-committee/discussions/24

```
 -693,11 +698,9 @@ static int sdma_prep_desc(struct dma_chan_data *channel,
                          struct dma_sg_config *config)
 {
        int i;
-       int width;
        int watermark;
        uint32_t sdma_script_addr;
        struct sdma_chan *pdata = dma_chan_get_data(channel);
-       struct sdma_bd *bd;

        /* Validate requested configuration */
        if (config->elem_array.count > SDMA_MAX_BDS) {
 -713,6 +716,9 @@ static int sdma_prep_desc(struct dma_chan_data *channel,

        pdata->next_bd = 0;

+       struct sdma_bd *bd = &pdata->desc[0]; // or NULL
+       int width = 0;
+
        for (i = 0; i < config->elem_array.count; i++) {
                bd = &pdata->desc[i];
                /* For MEM2DEV and DEV2MEM, buf_addr holds the RAM address
```

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-07-06 19:10:45 +01:00
Pierre-Louis Bossart 019c1505b1 topology: cavs-nocodec: use s24le for DAIs for all platforms
The use of s32le did not expose any problems on APL, but alsa-bat was
previously reported as failing on JSL. Now that this test was extended
to CML_NOCODEC, we see the same issue. Manual tests with s24le show no
issues.

Let's just use s24le across the board and move on.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
2021-07-06 18:28:21 +01:00
Brent Lu ad7f0e52b8 topology: sof-glk-da7219/cs42l42: enable bclk control
Enable the bclk clock control for SSP2.

Note that this impacts existing GLK-based chromebooks as well as newer
hardware.

Signed-off-by: Brent Lu <brent.lu@intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
2021-07-06 17:12:30 +01:00
Bard Liao fffa38db2a topology: sof-cavs-nocodec: enable MCLK/BCLK early start
Set clks_control to (SOF_DAI_INTEL_SSP_CLKCTRL_MCLK_ES |
SOF_DAI_INTEL_SSP_CLKCTRL_BCLK_ES) to enable MCLK/BCLK early start
feature.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
2021-07-06 17:12:30 +01:00
Brent Lu 16878e387e topology: ssp: mclk/bclk clock control
Define the SSP_CC_MCLK/BCLK_ES bit to be used in SSP_CONFIG_DATA macro
to enable mclk/bclk on hw_params and disable malk/bclk on hw_free.

Signed-off-by: Brent Lu <brent.lu@intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
2021-07-06 17:12:30 +01:00
Pierre-Louis Bossart 441b438191 intel: ssp: handle TSRE and RSRE along with SSE
The current code does not follow recommended programming sequences:
TSRE and RSRE should be set before SSE and conversely cleared before
SSE.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
2021-07-06 17:12:30 +01:00
Bard Liao 0e913d217a intel: ssp: handle MCLK/BCLK early start
Some codecs need the SSP bit clock to start before data is provided,
and conversely the bit clock to remain active until the hw_free stage.

For backwards-compatibility with older kernels, the
SOF_DAI_INTEL_SSP_CLKCTRL_MCLK_ES and
SOF_DAI_INTEL_SSP_CLKCTRL_BCLK_ES bitfields are used to set an
internal state in the ssp->clk_active field. This helps deals with the
case where a topology sets these bits but the older kernel does not
make use of the modified IPC.

While we are at it, add clearer info traces for SSP configurations.

Note that the FSYNC only starts when DMA transfers are enabled in the
.trigger stage. This is by-design, the FSYNC will only start if the
FIFO is not empty. During the prepare stages the DMA transfers are not
enabled so the FIFOs are empty.

To enable the FSYNC at an earlier stage, we would need a major surgery
in the SOF architecture, or we would need to start zero-based DMA
transfers.

Co-developed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
2021-07-06 17:12:30 +01:00
Bard Liao 297b893dae intel: ssp: introduce ssp_set/release_mclk/bclk helpers to set/release mclk/bclk
MCLK and BCLK can be set/release separately. We can set/release mclk/bclk
more flexible with these helpers.

The helpers are defined after the Linux ones, 'prepare_enable' will
first select the relevant resources then enable the clock
output. Conversely 'disable_unprepare' will stop the clock output then
release the clock resources.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
2021-07-06 17:12:30 +01:00
Bard Liao bdd8881301 ipc: dai-intel: add SOF_DAI_INTEL_SSP_CLKCTRL_MCLK/BCLK_ES bits
Add two clks_control bits. MCLK and/or BCLK will start during hw_params
and stop during hw_free if the corresponding bit is set.

This is tagged as a ABI 3.19 change.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
2021-07-06 17:12:30 +01:00
Pierre-Louis Bossart 7ff5290554 ipc: dai: add flags for DAI_CONFIG IPC
The DAI_CONFIG IPC is currently used both for hw_params and
hw_free. For some DAIs, there are hacky ways with e.g. invalid DMA
channels to indicate a hw_free. Rather than adding a new IPC for
hw_params and hw_free, let's add a flag that indicates if the
DAI_CONFIG is really applied during a hw_params or hw_free stage.

This is tagged as a ABI 3.19 change.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
2021-07-06 17:12:30 +01:00
Pierre-Louis Bossart b4febf1779 intel: ssp: fix missing return code on bclk configuration issue
when the bclk is not based on the default source, we will thrown an
error message but return the result of the mclk configuration.

Fix by adding an explicit -EINVAL return value.

Reported-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
2021-07-06 17:12:30 +01:00
Guennadi Liakhovetski 5796bf7eeb zephyr: switch LL scheduler to native timing API
Use the native Zephyr timing API for LL scheduling.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-07-06 15:10:43 +01:00
Guennadi Liakhovetski 2ece18ff7e ll-scheduler: remove unused Zephyr code
SOF under Zephyr has switched over to a separate LL scheduler, this
code isn't used any longer, remove it.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-07-06 15:10:43 +01:00
Guennadi Liakhovetski 0ae3b13a48 Revert "pipeline: dont disable IRQs around pipeline scheduling."
This reverts commit af6655e7fa.
That commit removed disabling interrupts in
pipeline_schedule_triggered() which is usually fine, except if an
xrun happens during pipeline_schedule_copy() which then removes the
task from the scheduler list, it then leads to a DSP exception in
pipeline_schedule_copy() is called for the next pipeline in the list.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-07-06 15:10:43 +01:00
Marc Herbert 223c20acbe Fix !CONFIG_TRACE again, broken when adding mtrace_printf()
Fixes commit 50eb5c9ca2 ("trace.c: add mtrace_printf() low-level
shortcut")

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-07-06 13:34:10 +01:00
Marc Herbert ef03e727db smex: un-hardcode "-O2 -g", use CMAKE_BUILD_TYPE, default to Debug
Anyone having a performance issue can use the standard
-DCMAKE_BUILD_TYPE=Release. Crashes seem more common.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-07-06 13:18:46 +01:00
Marc Herbert 46ddb38159 smex: use strerror()
Before:

  error: unable to open sof.elf for reading: 2

After:

  error: unable to open sof.elf for reading: No such file or directory

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-07-06 13:18:46 +01:00
Marc Herbert 53ebd8abd0 smex: fix crash in elf_free_module() when input file not found
fclose() seems to require a valid argument.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-07-06 13:18:46 +01:00
Iuliana Prodan 4c06d00084 zephyr: wrapper: include arch/xtensa/cache.h if CONFIG_KERNEL_COHERENCE not set
When building SOF with Zephyr, for i.MX, we get the following
error: undefined reference to `z_xtensa_cache_inv'.

i.MX has only one DSP core, so CONFIG_KERNEL_COHERENCE is not set.

Therefore include arch/xtensa/cache.h, where z_xtensa_cache_inv
is defined and implemented, in cases when the kernel is not built in
a mode where all shared data is placed in uncached memory.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
2021-07-06 14:22:37 +03:00
Iuliana Prodan 34bb9b7282 zephyr: wrapper: build SOF with Zephyr for imx
When building SOF with Zephyr for i.MX the following
additional adjustments, to the wrapper, are required:
1. include heapmem variable in .heap_mem section,
otherwise the HEAP_SIZE is duplicated in two sections and
the sdram0 region overflows;
2. no need to split heap into shared and unshared since
we only have 1 DSP core; In this case, the kernel will
never be built in a mode where all shared data is placed
in multiprocessor-coherent (generally "uncached") memory.
3. use simple interrupt_get_irq() to get the Linux interrupt
and later pass it to irq_steer;
4. use Xtensa timer, as we do now with SOF and XTOS.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
2021-07-06 14:22:37 +03:00
Iuliana Prodan 7d2f621f36 zephyr: imx: use zephyr utilities when enabled
Use the Zephyr sys/util.h when Zephyr RTOS is used.

While here, remove sof/lib/cpu.h which is not used.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
2021-07-06 14:22:37 +03:00
Iuliana Prodan 4e8743f76f zephyr: imx: split initialization
Zephyr already uses main() and has already performed
a lot of initialization before entering SOF.
Split initialization, for i.MX platforms, to make sure
no operation is repeated.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
2021-07-06 14:22:37 +03:00
Iuliana Prodan 894f28fbda zephyr: build: add initial support for imx
Build SOF with Zephyr for i.MX platforms.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
2021-07-06 14:22:37 +03:00
Marcin Rajwa e05fbff7c6 codec_adapter: cadence: get init_done status on prepare
This patch adds init_done status check at the very end of
cadence_codec_prepare() function. This is needed to know if
codec is fully prepared for the processing or not. Note we don't
do anything with the value read at prepare, we postpone final
verification until copy/process time since some codec variants
require input in order to finish its initialization.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2021-07-06 11:17:51 +03:00