Commit Graph

77 Commits

Author SHA1 Message Date
Rafal Redzimski e7120ce2a1 platform: ace: define a dedicated heap section
Define a dedicated .heap section in case of zephyr build.
Such explicit section is required to allow for unmapping
of unused physical pages which can be later used for
loadable library/modules support.

Signed-off-by: Rafal Redzimski <rafal.f.redzimski@intel.com>
2022-09-21 15:15:26 +02:00
Kai Vehmanen 38d92effc4 ipc4: use delayed work queue for IPC resends
Continue changes in commit c194125b83 ("zephyr: add
notifier_register(ipc_send_queued_msg) in task_main_start()") and
implement the delayed IPC msg sending in Zephyr work queue.

The old implementation did not cover cases where IPC needed to be resent
when no active LL scheduler tasks were active.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2022-09-12 16:50:29 +01:00
Liam Girdwood 4843516ab8 header: rtos: use rtos specific version of alloc.h
Code can now include <rtos/alloc.h> and uses thinly wrapped Zephyr
native for most uses. Wrapping can be removed over time.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2022-09-12 11:44:27 +01:00
Liam Girdwood e7d1b7bbf9 header: rtos: use rtos specific version of interrupt.h
Code can now include <rtos/interrupt.h> and uses native Zephyr IRQ API
for most uses. Some wrapping still exists which can be removed over
time. IMX is missing IRQ driver in Zephyr so falls back to xtos IRQ
driver.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2022-09-12 11:44:27 +01:00
Adrian Bonislawski dac5759fe6 probes: add IPC4 support
Add IPC4 support for extraction & injection probes
IPC4 header changes, checksum calculation
moved checksum from header to the end of data packet

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
2022-09-07 21:54:47 +01:00
Liam Girdwood c3c94fc515 header: rtos: use rtos specific version of wait.h
Code can now include <rtos/wait.h> and uses native Zephyr 64
cycle API instead of SOF version.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2022-09-06 15:37:21 +01:00
Rander Wang 141efbd7b0 ipc4: convert selector to use the new module interface
Now both ipc4 and ipc3 path will switch to module interface
with this patch.

Signed-off-by: Rander Wang <rander.wang@intel.com>
2022-08-24 13:28:02 +01:00
Daniel Baluta 1c018d517f timer: Introduce sof_cycle_get_64
With Zephyr, SOF uses k_cycle_get_64() API in order to
count clock cycles.

Not all platforms have a 64bit counter (e.g i.MX dsp integration
only has xtensa timer which is limited to 32 bits).

So, instead of using k_cycle_get_64 introduce new API sof_cycle_get_64
which keeps the existing behavior for platforms which define
CONFIG_TIMER_HAS_64BIT_CYCLE_COUNTER, otherwise use k_uptime_ticks().

See comments from @andyross at
https://github.com/zephyrproject-rtos/zephyr/pull/48318

Suggested-by: Andy Ross <andrew.j.ross@intel.com>
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2022-08-01 11:09:39 +01:00
Ranjani Sridharan 4af7082ad0 Revert "eq_iir: Use the new module interface"
This reverts commit 9d9ba739b3.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
2022-07-19 15:33:29 -05:00
Ranjani Sridharan 9d9ba739b3 eq_iir: Use the new module interface
Use the module interface instead of the comp drv interface for the
EQ IIR component.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
2022-07-18 16:56:40 +01:00
Anas Nashif 33112b74e8 zephyr: use zephyr prefix for includes
Zephyr includes are now under a zephyr namespace, so use this.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-18 14:22:01 +01:00
Guennadi Liakhovetski 162dafc288 zephyr: add third-party components
Add multiple third-party and optional audio processing components to
the Zephyr cmake and initialisation lists.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2022-07-01 11:11:23 +01:00
Ranjani Sridharan f7663de1f4 volume: use the new module interface
Move the volume component inside the module_adapter folder and use the
module interface API instead of the component driver interface. Also fix
the volume cmocka tests to use the modified scale_vol function.

Also, add kconfig option for keeping the legacy comp_drv interface for platforms
that are limited in text region memory size, such as
BYT/CHT/APL/JSL/ICL.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
2022-06-10 09:50:08 +01:00
Guennadi Liakhovetski 8397711d64 heap: heap_alloc_aligned_cached() returns a cached address
heap_alloc_aligned_cached() is a helper function used to allocate
memory with a cached alias. Therefore its returned pointer should
use the __sparse_cache annotation.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2022-05-11 14:30:11 +01:00
Ranjani Sridharan d779624a9b codec_adapter: rename DECLARE_CODEC_ADAPTER and comp_driver
to DECLARE_MODULE_ADAPTER and comp_driver to comp_module_adapter.
Also rename SOF_COMP_MODULE_ADAPTER to SOF_COM_MODULE_ADAPTER.
No functional changes.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
2022-05-04 16:01:23 +01:00
Chao Song f4f9e6541e sof: replace log calls with zephyr logging api
The log context in zephyr is per file or module.

To use zephyr logging api, LOG_MODULE_REGISTER is used
to register a log context, LOG_MODULE_DECLARE is used
to refer to the registered context.

For function in header file, LOG_MODULE_DECLARE should
be used within that function to avoid context collapse,
a condition one source file have multiple context
registered or declared.

Signed-off-by: Chao Song <chao.song@linux.intel.com>
2022-04-27 15:05:24 +01:00
Kai Vehmanen 020c9f3fa5 zephyr: track SOF app calls to enable/disable cores separately
Add a static variable w_core_enable_mask in Zephyr wrapper.c to
track requests to enable and disable cores, and use this to
implement arch_cpu_enabled_cores().

We don't yet have a implementation to power off secondary cores.
This creates issues to SOF application code that may rely on
disabling of cores to be reflected in cpu_enabled_cores(). Instead
of adding ifdefs in application code, manage this within wrapper.c.
Once the secondary core power-off is implemented, this static
variable can be removed.

BugLink: https://github.com/thesofproject/sof/issues/5701
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2022-04-25 16:24:39 +01:00
Adrian Warecki cc24c9cf77 zephyr: wrapper: rballoc_align: Support for the SOF_MEM_FLAG_COHERENT flag
The function rballoc_align did not take into account the passed flags, so
it always incorrectly allocated a cached memory. Added support for the
SOF_MEM_FLAG_COHERENT flag.

Signed-off-by: Adrian Warecki <adrianx.warecki@intel.com>
2022-04-19 16:51:49 +01:00
Ederson de Souza 9e18603636 zephyr: Use type compatible with Zephyr linker declarations
`_end` and `_heap_sentry` linker symbols are used to infer heap size. In
Zephyr, `_end` is referenced as `char []` while in SOF as `uint8_t`.
This may "conflicting types", should those declarations be built
together.

This patch changes the Zephyr wrapper to also use `char []`, thus
avoiding this issue.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2022-04-13 16:45:34 +01:00
Guennadi Liakhovetski e1ca6f6252 dw-dma: allocate uncached memory for LLI always
Multi-core configurations already use uncached memory for LLI. This
also makes sense to avoid having to manually synchronise cache. Force
LLI objects uncached.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2022-03-21 15:35:54 +00:00
Adrian Warecki c1e75603b2 timer: Use Zephyr timer API
Replaced sof timer related functions with Zephyr alternative.

Signed-off-by: Adrian Warecki <adrianx.warecki@intel.com>
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2022-03-16 12:02:29 +00:00
Rander Wang 0b537cba4d ipc4: init gain & mixin components for zephyr
Fix issue of ipc4 pipeline initialization with zephyr enabled.
Need to initialize these two components. Gain module is another
type of volume without peak volume support and mixin has subset
function of mixer.

Signed-off-by: Rander Wang <rander.wang@intel.com>
2022-03-01 22:50:17 +00:00
Kai Vehmanen f1e3c934f0 zephyr: use z_init_cpu() if Zephyr 3.0.99 or newer
Use the new interface to initialize non-primary cores before
enabling them with arch_start_cpu(). This interface is not
available in Zephyr 3.0.0, but is mandatory in later release.

Depends on Zephyr commit 2b210cb3db05 ("kernel: Refactor SMP cpu
initialization a bit").

BugLink: https://github.com/thesofproject/sof/issues/5456
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2022-03-01 22:47:01 +00:00
Kai Vehmanen 760f5ddea2 zephyr: fix race in secondary core power-up
z_wrapper_cpu_enable_secondary_core() may be called
repeatedly on a core that is already running. Add a check
to ensure we do not try to restart a core that is already
running.

Also add a check for ready_flag as done in upstream Zephyr
kernel/smp.c to ensure z_wrapper_cpu_enable_secondary_core()
does not return until the target core has finished its
startup and arch_cpu_active() returns true.

BugLink: https://github.com/thesofproject/sof/issues/5446
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2022-03-01 22:47:01 +00:00
Daniel Baluta b06f2cfe23 zephyr: add codec adapter components
This enables codec_adapter and cadence/passhtrough codecs
with SOF on Zephyr.

passthrough codec can be used as it is, but cadence codec
will also need codec libraries from cadence.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2022-02-18 21:12:24 +00:00
Chao Song 487363fb1b zephyr: add copier and base_fw components
The two components copier and base_fw are
essential to IPC4 support on SOF on Zephyr.

This patch integrates the build of the two
components to SOF build with zephyr RTOS.

Signed-off-by: Chao Song <chao.song@linux.intel.com>
2022-02-11 11:02:19 +00:00
Kai Vehmanen 6363a86309 zephyr: add missing call to smp_timer_init to secondary core init
To align with Zephyr smp.c:smp_init_top(), add the missing call to
smp_timer_init() in secondary_init() of the SOF wrapper. Also
add inline documentation why we are open-coding the function on
SOF side.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2022-02-04 09:33:56 +00:00
Kai Vehmanen 10f4669ccc Revert "zephyr: implement arch_cpu_disable_core()"
This reverts commit 414089aa44.

Failures hit with 4core cAVS2.5 configuraions, so this has
to be reverted. We need an implementation that keeps both
Zephyr (and SOF runtime-DSP if still used) in the loop.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2022-02-02 15:48:30 +00:00
Kai Vehmanen 378d7b7822 zephyr: always use Zephyr interface to power up secondary cores
Currently there is code to power up secondary cores both
in Zephyr architecture hooks in wrapper.c, as well as in
SOF runtime-PM driver.

Some of this is necessary overlap until full replacement of
SOF runtime-PM is available. But for secondary core power up,
we can already clean up the flow and hook the Zephyr core
enable code to runtime-PM driver directly. This fixes startup
issues seen on Intel cAvS2.5 platforms.

Core power-down is left intentionally for runtime-PM driver
to handle as the related interface in Zephyr is not ready
for use yet.

BugLink: https://github.com/thesofproject/sof/issues/5018
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2022-02-02 10:40:42 +00:00
Kai Vehmanen 414089aa44 zephyr: implement arch_cpu_disable_core()
Add implementation of secondary core disable with a call
to SOF runtime-PM framework.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2022-02-01 15:25:48 +00:00
Marc Herbert f30892d966 Revert "zephyr: (cosmetic) make a needlessly global variable static"
This reverts commit 079ce95b98.

As explained in the comment that it modified, predicted in the #5159
discussion and reproduced in test #5290 /
https://github.com/thesofproject/sof/runs/4988844402, this commit broke
'CONFIG_TRACE=n'. Simple reproduction steps:

 $ rm -rf zephyrproject/build-apl

 $ echo 'CONFIG_TRACE=n' >> \
    boards/xtensa/intel_adsp_cavs15/intel_adsp_cavs15_defconfig

 $ sof/scripts/xtensa-build-zephyr.sh [ -p /path/to/zephyrproject ]  apl

fw abi main version:	3.20.1
fw abi dbg version:	5.3.0
warning: can't find section .static_log_entries in zephyr/zephyr.elf
error: section .static_log_entries can't be found
error: unable to write dictionaries, -22

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-01-31 11:02:23 +00:00
Guennadi Liakhovetski 079ce95b98 zephyr: (cosmetic) make a needlessly global variable static
_smex_placeholder dowsn't have to be global, make it static.
Also no need to explicitly specify smex_placeholder_f() as inline,
the compiler will decide by itself.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2022-01-20 17:05:10 +00:00
Guennadi Liakhovetski 1c6ae93d92 platform/zephyr: use an OS call for time stamps
On generic Zephyr platform case, use an OS timer call to get a time
stamp.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2022-01-20 17:05:10 +00:00
Guennadi Liakhovetski e0ff1b16d8 zephyr: add a generic Zephyr platform
When built with Zephyr, SOF ideally should be a fully platform-
agnostic application. All platform-specific code should reside in
Zephyr itself, including core architecture and platform
infrastructures and drivers. To prepare for this transition we add a
generic SOF-Zephyr platform. It is based on the current Tiger Lake
architecture and should be usable for cAVS 2.5 and newer systems.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-12-31 08:06:24 +00:00
Bartosz Kokoszko ec63f3a70e pm_runtime: prepare secondary cores for power down in d0->d0ix flow
Primary core during going to D0i3 state disables all another cores
in platform_pg_int_handler() function. Before it secondary cores
should be prepared (disable interrupts, perform writeback) in order
to make proper restore flow after D0i3->D0 transition.

This commit adds cpu_secondary_cores_prepare_d0ix() function in
ipc_pm_gate() handler, which sends idc to secondary cores
with information that they should perform preparation for power down
in the next platform_wait_for_interrupt() invocation. In
platform_wait_for_interrupt() there is cpu_power_down_core()
invocation with CPU_POWER_DOWN_MEMORY_ON (performs writeback/invalidate,
disables interrupts), when proper flag is set.

Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
2021-11-08 13:25:44 +00:00
Adrian Bonislawski e62855935d lps: restore secondary cores on wake up
This will add missing secondary cores restore on wake up,
simple pm_runtime_get(PM_RUNTIME_DSP, PLATFORM_PRIMARY_CORE_ID)
in lps is not enough in multicore scenario

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
2021-11-08 13:25:44 +00:00
Guennadi Liakhovetski 0a3342f5d3 zephyr: (cosmetic) simplify a preprocessor conditional
Simplify a preprocessor conditional compilation in zone_is_cached().

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-10-27 14:09:39 +01:00
Guennadi Liakhovetski a1392bb0de zephyr: use all available memory for the heap
Instead of hard-coding a guessed heap size, obtain remaining free
SRAM from the linker and use it completely for the heap.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-10-27 14:09:39 +01:00
Guennadi Liakhovetski 1ef769dd87 zephyr: apl: further reduce heap size
Recent changes increased the size of various sections, breaking
linkage again. We need to make the linker calculate the heap size
automatically but until that is ready, reduce the heap size further
to fix the current breakage.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-10-21 15:59:13 +01:00
Kai Vehmanen de408a2349 zephyr: trigger system panic if MEM_ZONE_SYS alloc fails
As per documentation in include/sof/lib/alloc.h, rmalloc from
MEM_ZONE_SYS will always succeed. In the unlikely case the alloc
fails, trigger a system panic in rmalloc().

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2021-10-18 15:58:42 +01:00
Kai Vehmanen 15885b76e1 zephyr: make SYS and RUNTIME zones cached
Add caching to more heap zones. With addition of SYS, SYS_RUNTIME
and RUNTIME the mapping is now aligned with XTOS allocator.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2021-10-18 15:43:16 +01:00
Kai Vehmanen ba4406e2b7 zephyr: align non-cached allocs to PLATFORM_DCACHE_ALIGN
The XTOS allocator aligns non-cachec allocations to the platform
cacheline size. Test results indicate some SOF application code
relies on this behaviour, so align Zephyr's rmalloc implementation
to match the behaviour.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2021-10-15 09:28:28 +01:00
Kai Vehmanen 956a587663 zephyr: reimplement cached heap zone on single Zephyr sys_heap
Implement the cached SOF heap zones using a single sys_heap
object.

Compared to old implementation which used two separate sys_heaps,
this implementation enables dynamic cached/uncached partitioning
of the heap.

To ensure coherency of the Zephyr heap operation, if cached heap
is enabled, all allocations must be aligned to dcache linesize.

Add a Kconfig option CONFIG_SOF_ZEPHYR_HEAP_CACHED to turn on/off
the cached heap logic, with default set to no for all platforms.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2021-10-15 09:28:28 +01:00
Andy Ross f0415135ea zephyr: Correct heap cache management
The heap code was invalidating blocks on allocation, but that's the
wrong side of the pipe.  By definition, new heap memory
will/should/must be written before being used (because the memory is
undefined), so any cached contents are irrelevant as they'll be
overwritten.

But when the user is finished with the block and frees it, there may
still be live dirty cache lines in the region on the current CPU.
Those must be invalidated, otherwise they will be evicted from the
cache at some point in the future, on top of the memory region now
being used for different purposes on another CPU.

Remove the invalidate on allocation.  Add it back in free.  Leverage a
new Zephyr sys_heap_usable_size() routine to get the size so we don't
have to store it in an extra header.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-10-15 09:28:28 +01:00
Guennadi Liakhovetski 4337831643 zephyr: further reduce the size of heap on APL with XCC
Building SOF with Zephyr for Apollolake with XCC fails because of
insufficient RAM. Reduce the heap size to fix the problem.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-10-14 14:01:57 +01:00
Keyon Jie 1e2d574356 zephyr: wrapper: hardcode SIZEs to unblock building
We have change the size of runtime_shared zone to be decided at link
stage, here hardcode HEAP_RUNTIME_SHARED_SIZE to unblock the Zephyr
building.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2021-09-09 09:36:31 +01:00
Iuliana Prodan b531898f6d zephyr: wrapper: make sof_heap global again
sof_heap variable is used by all platform, with or
without ENABLE_CACHED_HEAP.

Without this fix, on i.MX with Zephyr we get:
error: 'sof_heap' undeclared (first use in this function);

Fixes: fed69b6a34 ("zephyr: wrapper: disable cached heap on Intel platforms")
Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
2021-08-27 14:00:10 +01:00
Kai Vehmanen fed69b6a34 zephyr: wrapper: disable cached heap on Intel platforms
Tests with dynamic-pipeline topologies increase the complexity
of alloc/free patterns for heap and these tests have uncovered
new issues with heap corruption. Tests are reporting failed
allocs although heap still has free space. Running same test
with cached heap disabled shows no failures.

The cached heap is already disabled for IMX targets, so build on
this code and add a local ENABLE_CACHED_HEAP define to toggle
the cached heap.

BugLink: https://github.com/thesofproject/sof/issues/4494
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2021-08-24 20:31:10 +01:00
Kai Vehmanen 63eda919d3 zephyr: unify CTX_SAVE handling for Zephyr
Clean up the ifdefs for ipc_pm_context_save(). By implementing
platform_timer_stop() in the Zephyr wrapper, the original context
save sequence can be used also for Zephyr builds.

By doing this, we can fix issues with IPC timeout on CTX_SAVE.
Disabling all interrupts before the IPC reply is needed also on
Zephyr.

BugLink: https://github.com/thesofproject/sof/issues/4507
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2021-08-12 19:48:09 +01:00
Iuliana Prodan 214518edea zephyr: wrapper: add notifier_register(ipc_send_queued_msg) for SOF_SCHEDULE_LL_DMA
In XTOS SOF, ipc_send_queued_msg() is run by task_main_primary_core().
In Zephyr we need to schedule ipc_send_queued_msg() using a notifier
triggered by the periodic ll_scheduler.
This is similar to commit c194125b83 ("zephyr:
add notifier_register(ipc_send_queued_msg) in task_main_start()")

For i.MX we need to use this temporary fix for SOF_SCHEDULE_LL_DMA, also.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
2021-07-27 14:43:44 +01:00