From d4e58dec377da89f42a1589352050fb251005bec Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Tue, 26 Nov 2024 18:54:00 +0200 Subject: [PATCH 1/4] west.yml: update zephyr to a14ae39e74473 Total of 327 commits. Changes include: a14ae39e7447 driver: ssp: remove use of out-of-tree CONFIG_INTEL_MN 3d3ffa2c059d soc: intel_adsp/ace30: do not map 0x0 58df2533bbbf drivers: dma: intel-adsp-hda: coding style fix 1bafbf4f1d11 drivers: dma: intel-adsp-hda: optimize L1 exit handling in ISR Signed-off-by: Kai Vehmanen --- west.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/west.yml b/west.yml index abe21291c4da..f7b669fc8fff 100644 --- a/west.yml +++ b/west.yml @@ -43,7 +43,7 @@ manifest: - name: zephyr repo-path: zephyr - revision: cbb6199e679c50c75d3ed090852b4993e8b06a8a + revision: a14ae39e7447321db35d8fd84b282fef4b098c49 remote: zephyrproject # Import some projects listed in zephyr/west.yml@revision From 867a52704ab9d2455eab043c31a7c169e621488a Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Tue, 26 Nov 2024 18:52:40 +0200 Subject: [PATCH 2/4] drivers: intel: remove remaining references to MN driver The Zephyr SSP driver has had dependency to CONFIG_INTEL_NM defined in SOF, so this has not been removed before. This is now cleaned up on Zephyr side, so we can proceed to remove the remaining bits of the Intel MN driver on SOF side. Signed-off-by: Kai Vehmanen --- src/drivers/Kconfig | 2 - src/drivers/intel/Kconfig | 10 ----- src/include/sof/drivers/mn.h | 87 ------------------------------------ src/platform/Kconfig | 1 - 4 files changed, 100 deletions(-) delete mode 100644 src/drivers/intel/Kconfig delete mode 100644 src/include/sof/drivers/mn.h diff --git a/src/drivers/Kconfig b/src/drivers/Kconfig index ad3be8d1a564..43fdc40023cd 100644 --- a/src/drivers/Kconfig +++ b/src/drivers/Kconfig @@ -2,8 +2,6 @@ menu "Drivers" -rsource "intel/Kconfig" - rsource "dw/Kconfig" rsource "imx/Kconfig" diff --git a/src/drivers/intel/Kconfig b/src/drivers/intel/Kconfig deleted file mode 100644 index b7e465758ec2..000000000000 --- a/src/drivers/intel/Kconfig +++ /dev/null @@ -1,10 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause - -# TODO: to be removed once Zephyr SSP driver has been updated -# not to depend on this -config INTEL_MN - bool - depends on CAVS - default n - help - Select this if the platform supports M/N dividers. diff --git a/src/include/sof/drivers/mn.h b/src/include/sof/drivers/mn.h deleted file mode 100644 index 004d907bfad9..000000000000 --- a/src/include/sof/drivers/mn.h +++ /dev/null @@ -1,87 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * - * Copyright(c) 2020 Intel Corporation. All rights reserved. - * - * Author: Janusz Jankowski - */ - -#ifndef __SOF_DRIVERS_MN_H__ -#define __SOF_DRIVERS_MN_H__ - -#include -#include - -#include -#include - -/** - * \brief Initializes MN driver. - */ -void mn_init(struct sof *sof); - -/** - * \brief Finds and sets valid combination of MCLK source and divider to - * achieve requested MCLK rate. - * User should release clock when it is no longer needed to allow - * driver to change MCLK M/N source when user count drops to 0. - * M value of M/N is not supported for MCLK, only divider can be used. - * \param[in] mclk_id id of main clock for which rate should be set. - * \param[in] mclk_rate main clock frequency. - * \return 0 on success otherwise a negative error code. - */ -int mn_set_mclk(uint16_t mclk_id, uint32_t mclk_rate); - -/** - * \brief set mclk according to blob setting - * \param[in] mdivc mclk control setting. - * \param[in] mdivr mclk divider setting. - * \return 0 on success otherwise a negative error code. - */ -int mn_set_mclk_blob(uint32_t mdivc, uint32_t mdivr); - -/** - * \brief Release previously requested MCLK for given MCLK ID. - * \param[in] mclk_id id of main clock. - */ -void mn_release_mclk(uint32_t mclk_id); - -#if CONFIG_INTEL_MN -/** - * \brief Finds and sets valid combination of BCLK source and M/N to - * achieve requested BCLK rate. - * User should release clock when it is no longer needed to allow - * driver to change M/N source when user count drops to 0. - * \param[in] dai_index DAI index (SSP port). - * \param[in] bclk_rate Bit clock frequency. - * \param[out] out_scr_div SCR divisor that should be set by caller to achieve - * requested BCLK rate. - * \param[out] out_need_ecs If set to true, the caller should configure ECS. - * \return 0 on success otherwise a negative error code. - * \see mn_release_bclk() - */ -int mn_set_bclk(uint32_t dai_index, uint32_t bclk_rate, - uint32_t *out_scr_div, bool *out_need_ecs); - -/** - * \brief Release previously requested BCLK for given DAI. - * \param[in] dai_index DAI index (SSP port). - */ -void mn_release_bclk(uint32_t dai_index); - -/** - * \brief Resets M & N values of M/N divider for given DAI index. - * \param[in] dai_index DAI index (SSP port). - */ -void mn_reset_bclk_divider(uint32_t dai_index); -#endif - -/** - * \brief Retrieves M/N dividers structure. - * \return Pointer to M/N dividers structure. - */ -static inline struct mn *mn_get(void) -{ - return sof_get()->mn; -} - -#endif /* __SOF_DRIVERS_MN_H__ */ diff --git a/src/platform/Kconfig b/src/platform/Kconfig index c558d371806e..684f775049aa 100644 --- a/src/platform/Kconfig +++ b/src/platform/Kconfig @@ -339,7 +339,6 @@ config CAVS bool default n select INTEL - select INTEL_MN select SOF_ZEPHYR_NO_SOF_CLOCK config CAVS_VERSION_2_5 From cae0d0a281aadd73c3906fade5018f0c0b40f808 Mon Sep 17 00:00:00 2001 From: Tomasz Leman Date: Thu, 28 Nov 2024 11:47:00 +0100 Subject: [PATCH 3/4] fix: comp_dev: initialize buffer lists to prevent NULL dereference This patch addresses a NULL dereference issue in the SOF firmware that was exposed by a recent change in Zephyr's MMU mapping for Intel ADSP ACE30. The change prevents mapping of the 0x0 address, which helps catch NULL pointer accesses. The issue was identified during testing, where an exception occurred due to uninitialized buffer lists in the `comp_dev` structure. The `list_init` function is called in `comp_new()` (for both IPC3 and IPC4), but a NULL dereference can happen in the component `ops->create()` function, which is called before the list is initialized. One affected component is IPC4 `copier_ipcgtw`. To fix this, the `bsink_list` and `bsource_list` are now initialized in the `comp_alloc` function. This ensures that the lists point to themselves before any use, preventing NULL dereference and subsequent exceptions. Link: https://github.com/thesofproject/sof/issues/9687 Signed-off-by: Tomasz Leman (cherry picked from commit 5f5588c655087086c7003be2a139971c6acf34fa) --- src/include/sof/audio/component.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/include/sof/audio/component.h b/src/include/sof/audio/component.h index e429e9cbe07d..03f37ac884ad 100644 --- a/src/include/sof/audio/component.h +++ b/src/include/sof/audio/component.h @@ -764,6 +764,8 @@ static inline struct comp_dev *comp_alloc(const struct comp_driver *drv, dev->size = bytes; dev->drv = drv; dev->state = COMP_STATE_INIT; + list_init(&dev->bsink_list); + list_init(&dev->bsource_list); memcpy_s(&dev->tctx, sizeof(struct tr_ctx), trace_comp_drv_get_tr_ctx(dev->drv), sizeof(struct tr_ctx)); From bb33a1741f9b2d573a2a79e7802339e45982ce70 Mon Sep 17 00:00:00 2001 From: Tomasz Leman Date: Thu, 28 Nov 2024 14:51:14 +0100 Subject: [PATCH 4/4] audio: kpb: fix potential NULL pointer dereference in device list reset This patch addresses a potential NULL pointer dereference issue in the `devicelist_reset` function within the Key Phrase Buffer (KPB) component. The issue was exposed by a recent change in Zephyr's MMU mapping for Intel ADSP ACE30, which now catches NULL pointer accesses. The `devicelist_reset` function previously iterated over the entire `DEVICE_LIST_SIZE` when clearing items and zeroing pointers, which could lead to dereferencing NULL pointers. The fix involves iterating only up to `devlist->count` to ensure that only valid pointers are accessed. This change prevents potential NULL pointer dereference and ensures the stability of the KPB component. Link: https://github.com/thesofproject/sof/issues/9687 Signed-off-by: Tomasz Leman --- src/audio/kpb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/kpb.c b/src/audio/kpb.c index 2141cc8ac1d5..064b3acddb45 100644 --- a/src/audio/kpb.c +++ b/src/audio/kpb.c @@ -2405,11 +2405,11 @@ static void devicelist_reset(struct device_list *devlist, bool remove_items) { /* clear items */ if (remove_items) { - for (int i = 0; i < DEVICE_LIST_SIZE; i++) + for (int i = 0; i < devlist->count; i++) *devlist->devs[i] = NULL; } /* zero the pointers */ - for (int i = 0; i < DEVICE_LIST_SIZE; i++) + for (int i = 0; i < devlist->count; i++) devlist->devs[i] = NULL; devlist->count = 0;