From 6cdf717c8535bf63ab0d5942644676c4ca9ea46d Mon Sep 17 00:00:00 2001 From: Marcin Szkudlinski Date: Wed, 3 Jul 2024 13:47:16 +0200 Subject: [PATCH] kconfig: add PIPELINE_2_0 flag This flag enables changes to new pipeline structure, known as pipeline2_0 It is required for certain new features, like DP_SCHEDULER. The changes are incremental and at the moment pipeline 2.0 is fully backward compatible with legacy platforms, however it generates some overhead in data and code, so it is useful to turn if off if not needed Signed-off-by: Marcin Szkudlinski # Conflicts: # src/include/sof/audio/audio_stream.h # src/ipc/ipc4/helper.c --- app/boards/intel_adsp_ace15_mtpm.conf | 1 + app/boards/intel_adsp_ace20_lnl.conf | 1 + app/boards/intel_adsp_ace30_ptl.conf | 1 + src/audio/audio_stream.c | 6 +++--- src/audio/buffer.c | 8 ++++---- src/audio/module_adapter/module_adapter.c | 6 +++--- src/include/sof/audio/audio_stream.h | 4 ++-- src/include/sof/audio/buffer.h | 4 ++-- zephyr/CMakeLists.txt | 2 +- zephyr/Kconfig | 9 +++++++++ 10 files changed, 27 insertions(+), 15 deletions(-) diff --git a/app/boards/intel_adsp_ace15_mtpm.conf b/app/boards/intel_adsp_ace15_mtpm.conf index 8fd7888ad442..377f920e5800 100644 --- a/app/boards/intel_adsp_ace15_mtpm.conf +++ b/app/boards/intel_adsp_ace15_mtpm.conf @@ -33,6 +33,7 @@ CONFIG_DAI_INTEL_DMIC_NHLT=y CONFIG_DAI_DMIC_HAS_OWNERSHIP=y CONFIG_DAI_DMIC_HAS_MULTIPLE_LINE_SYNC=y CONFIG_DAI_INTEL_SSP=y +CONFIG_PIPELINE_2_0=y CONFIG_ZEPHYR_DP_SCHEDULER=y CONFIG_DMA=y CONFIG_DMA_INTEL_ADSP_GPDMA=y diff --git a/app/boards/intel_adsp_ace20_lnl.conf b/app/boards/intel_adsp_ace20_lnl.conf index 42dea6d096ee..7c27b451efcf 100644 --- a/app/boards/intel_adsp_ace20_lnl.conf +++ b/app/boards/intel_adsp_ace20_lnl.conf @@ -29,6 +29,7 @@ CONFIG_DAI_INTEL_DMIC_NHLT=y CONFIG_DAI_DMIC_HAS_OWNERSHIP=n CONFIG_DAI_DMIC_HAS_MULTIPLE_LINE_SYNC=y CONFIG_DAI_INTEL_SSP=y +CONFIG_PIPELINE_2_0=y CONFIG_ZEPHYR_DP_SCHEDULER=y CONFIG_DMA=y CONFIG_DMA_INTEL_ADSP_GPDMA=n diff --git a/app/boards/intel_adsp_ace30_ptl.conf b/app/boards/intel_adsp_ace30_ptl.conf index 57d85f75ef44..887eee10dbff 100644 --- a/app/boards/intel_adsp_ace30_ptl.conf +++ b/app/boards/intel_adsp_ace30_ptl.conf @@ -27,6 +27,7 @@ CONFIG_DAI_INTEL_DMIC_NHLT=y CONFIG_DAI_DMIC_HAS_OWNERSHIP=n CONFIG_DAI_DMIC_HAS_MULTIPLE_LINE_SYNC=y CONFIG_DAI_INTEL_SSP=y +CONFIG_PIPELINE_2_0=y CONFIG_ZEPHYR_DP_SCHEDULER=y CONFIG_DMA=y CONFIG_DMA_INTEL_ADSP_GPDMA=n diff --git a/src/audio/audio_stream.c b/src/audio/audio_stream.c index 35ffc243c180..855a67ae3b04 100644 --- a/src/audio/audio_stream.c +++ b/src/audio/audio_stream.c @@ -207,7 +207,7 @@ void audio_stream_init(struct audio_stream *audio_stream, void *buff_addr, uint3 } /* get a handler to source API */ -#if CONFIG_ZEPHYR_DP_SCHEDULER +#if CONFIG_PIPELINE_2_0 struct sof_source *audio_stream_get_source(struct audio_stream *audio_stream) { return audio_stream->secondary_buffer_source ? @@ -222,7 +222,7 @@ struct sof_sink *audio_stream_get_sink(struct audio_stream *audio_stream) &audio_stream->_sink_api; } -#else /* CONFIG_ZEPHYR_DP_SCHEDULER */ +#else /* CONFIG_PIPELINE_2_0 */ struct sof_source *audio_stream_get_source(struct audio_stream *audio_stream) { @@ -233,4 +233,4 @@ struct sof_sink *audio_stream_get_sink(struct audio_stream *audio_stream) { return &audio_stream->_sink_api; } -#endif /* CONFIG_ZEPHYR_DP_SCHEDULER */ +#endif /* CONFIG_PIPELINE_2_0 */ diff --git a/src/audio/buffer.c b/src/audio/buffer.c index 00b5f2251835..41434f51f8f9 100644 --- a/src/audio/buffer.c +++ b/src/audio/buffer.c @@ -81,7 +81,7 @@ struct comp_buffer *buffer_alloc(uint32_t size, uint32_t caps, uint32_t flags, u return buffer; } -#if CONFIG_ZEPHYR_DP_SCHEDULER +#if CONFIG_PIPELINE_2_0 int buffer_attach_secondary_buffer(struct comp_buffer *buffer, bool at_input, struct sof_audio_buffer *secondary_buffer) { @@ -140,7 +140,7 @@ int buffer_sync_secondary_buffer(struct comp_buffer *buffer, size_t limit) err = source_to_sink_copy(data_src, data_dst, true, to_copy); return err; } -#endif /* CONFIG_ZEPHYR_DP_SCHEDULER */ +#endif /* CONFIG_PIPELINE_2_0 */ void buffer_zero(struct comp_buffer *buffer) { @@ -264,10 +264,10 @@ void buffer_free(struct comp_buffer *buffer) /* In case some listeners didn't unregister from buffer's callbacks */ notifier_unregister_all(NULL, buffer); -#if CONFIG_ZEPHYR_DP_SCHEDULER +#if CONFIG_PIPELINE_2_0 audio_buffer_free(buffer->stream.secondary_buffer_sink); audio_buffer_free(buffer->stream.secondary_buffer_source); -#endif /* CONFIG_ZEPHYR_DP_SCHEDULER */ +#endif /* CONFIG_PIPELINE_2_0 */ rfree(buffer->stream.addr); rfree(buffer); } diff --git a/src/audio/module_adapter/module_adapter.c b/src/audio/module_adapter/module_adapter.c index c4fe874b9cfb..149bc04400b2 100644 --- a/src/audio/module_adapter/module_adapter.c +++ b/src/audio/module_adapter/module_adapter.c @@ -902,7 +902,7 @@ static int module_adapter_audio_stream_type_copy(struct comp_dev *dev) return ret; } -#if CONFIG_ZEPHYR_DP_SCHEDULER +#if CONFIG_PIPELINE_2_0 static int module_adapter_copy_ring_buffers(struct comp_dev *dev) { /* @@ -960,12 +960,12 @@ static int module_adapter_copy_ring_buffers(struct comp_dev *dev) } return 0; } -#else +#else /* CONFIG_PIPELINE_2_0 */ static inline int module_adapter_copy_ring_buffers(struct comp_dev *dev) { return -ENOTSUP; } -#endif /* CONFIG_ZEPHYR_DP_SCHEDULER */ +#endif /* CONFIG_PIPELINE_2_0 */ static int module_adapter_sink_source_copy(struct comp_dev *dev) { diff --git a/src/include/sof/audio/audio_stream.h b/src/include/sof/audio/audio_stream.h index f899cb3ab65b..651a0b00f632 100644 --- a/src/include/sof/audio/audio_stream.h +++ b/src/include/sof/audio/audio_stream.h @@ -63,14 +63,14 @@ struct audio_stream { void *end_addr; /**< Buffer end address */ uint8_t byte_align_req; uint8_t frame_align_req; -#if CONFIG_ZEPHYR_DP_SCHEDULER +#if CONFIG_PIPELINE_2_0 struct sof_audio_buffer *secondary_buffer_sink; /**< sink API of an additional buffer * of any type at data input */ struct sof_audio_buffer *secondary_buffer_source; /**< source API of an additional buffer * at data output */ -#endif /* CONFIG_ZEPHYR_DP_SCHEDULER */ +#endif /* CONFIG_PIPELINE_2_0 */ /* runtime stream params */ struct sof_audio_stream_params runtime_stream_params; diff --git a/src/include/sof/audio/buffer.h b/src/include/sof/audio/buffer.h index a4e5fa4c318b..f1a0841b1ea0 100644 --- a/src/include/sof/audio/buffer.h +++ b/src/include/sof/audio/buffer.h @@ -188,7 +188,7 @@ struct buffer_cb_free { struct comp_buffer *buffer_alloc(uint32_t size, uint32_t caps, uint32_t flags, uint32_t align, bool is_shared); struct comp_buffer *buffer_new(const struct sof_ipc_buffer *desc, bool is_shared); -#if CONFIG_ZEPHYR_DP_SCHEDULER +#if CONFIG_PIPELINE_2_0 /* * attach a secondary buffer (any type) before buffer (when at_input == true) or behind a buffer * @@ -226,7 +226,7 @@ int buffer_attach_secondary_buffer(struct comp_buffer *buffer, bool at_input, * secondary buffer in an operation */ int buffer_sync_secondary_buffer(struct comp_buffer *buffer, size_t limit); -#endif /* CONFIG_ZEPHYR_DP_SCHEDULER */ +#endif /* CONFIG_PIPELINE_2_0 */ int buffer_set_size(struct comp_buffer *buffer, uint32_t size, uint32_t alignment); void buffer_free(struct comp_buffer *buffer); void buffer_zero(struct comp_buffer *buffer); diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 995a1bcd492d..bfa7fe54500f 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -474,7 +474,7 @@ zephyr_library_sources_ifdef(CONFIG_MATH_LUT_SINE_FIXED # SOF module interface functions add_subdirectory(../src/module module_unused_install/) -if(CONFIG_ZEPHYR_DP_SCHEDULER) +if(CONFIG_PIPELINE_2_0) zephyr_library_sources(${SOF_AUDIO_PATH}/buffers/ring_buffer.c) endif() if(CONFIG_SCHEDULE_DMA_SINGLE_CHANNEL AND NOT(CONFIG_DMA_DOMAIN)) diff --git a/zephyr/Kconfig b/zephyr/Kconfig index 4112a2b19f50..b8915b69d8ee 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -43,6 +43,14 @@ config DMA_DOMAIN_SEM_LIMIT that SEM_LIMIT covers the maximum number of tasks your system will be executing at some point (worst case). +config PIPELINE_2_0 + bool "Enable pipeline 2.0 changes" + depends on IPC_MAJOR_4 + default y if ACE + help + This flag enables changes to new pipeline structure, known as pipeline2_0 + It is required for certain new features, like DP_SCHEDULER. + config ZEPHYR_DP_SCHEDULER bool "use Zephyr thread based DP scheduler" default y if ACE @@ -50,6 +58,7 @@ config ZEPHYR_DP_SCHEDULER depends on IPC_MAJOR_4 depends on ZEPHYR_SOF_MODULE depends on ACE + depends on PIPELINE_2_0 help Enable Data Processing preemptive scheduler based on Zephyr preemptive threads.