ASoC: SOF: IPC path handling and fallback support
Subsystems (3)
Peter Ujfalusi
maintainercover ASoC: SOF: IPC path handling and fallback support
Hi,
The main aim of the series is to provide a mechanism to fallback to 'older' IPC versions in case the desired one is missing either a firmware or topology file. It is going to make the life of users and distributions if we are going to start transition existing IPC3 platforms to IPC4 (CAVS2.5) and we might have missed some topology file to convert for example.
In that case the kernel will fallback to IPC3 without audio regression.
To be able to support this we needed to change the probe sequence to know the topology filename earlier and check if it is present in the filesystem.
No functional changes for now, the default IPC versions have not been changed.
Regards,
Peter
---
Peter Ujfalusi (13):
ASoC: SOF: Move sof_of_machine_select() to sof-of-dev.c from
sof-audio.c
ASoC: SOF: Move sof_machine_* functions from sof-audio.c to core.c
ASoC: SOF: Add placeholder for platform IPC type and path overrides
ASoC: SOF: sof-acpi-dev: Save the default IPC type and path overrides
ASoC: SOF: sof-of-dev: Save the default IPC type and path overrides
ASoC: SOF: sof-pci-dev: Save the default IPC type and path overrides
ASoC: SOF: core: Implement firmware, topology path setup in core
ASoC: SOF: sof-acpi-dev: Rely on core to create the file paths
ASoC: SOF: sof-of-dev: Rely on core to create the file paths
ASoC: SOF: sof-pci-dev: Rely on core to create the file paths
ASoC: SOF: core: Add helper for initialization of paths, ops
ASoC: SOF: Intel: Do not use resource managed allocation for ipc4_data
ASoC: SOF: core: Implement IPC version fallback if firmware files are
missing
include/sound/sof.h | 15 ++ sound/soc/sof/Kconfig | 11 ++ sound/soc/sof/Makefile | 3 +- sound/soc/sof/core.c | 289 +++++++++++++++++++++++----- sound/soc/sof/fw-file-profile.c | 322 ++++++++++++++++++++++++++++++++ sound/soc/sof/intel/apl.c | 2 +- sound/soc/sof/intel/cnl.c | 2 +- sound/soc/sof/intel/hda-dai.c | 3 + sound/soc/sof/intel/icl.c | 2 +- sound/soc/sof/intel/lnl.c | 2 +- sound/soc/sof/intel/mtl.c | 2 +- sound/soc/sof/intel/skl.c | 2 +- sound/soc/sof/intel/tgl.c | 2 +- sound/soc/sof/sof-acpi-dev.c | 16 +- sound/soc/sof/sof-audio.c | 120 ------------ sound/soc/sof/sof-of-dev.c | 36 +++- sound/soc/sof/sof-of-dev.h | 9 + sound/soc/sof/sof-pci-dev.c | 102 ++-------- sound/soc/sof/sof-priv.h | 9 +- 19 files changed, 671 insertions(+), 278 deletions(-) create mode 100644 sound/soc/sof/fw-file-profile.c
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 1/13 ASoC: SOF: Move sof_of_machine_select() to sof-of-dev.c from sof-audio.c
Move the sof_of_machine_select() function to sof-of-dev.c file and provide an inline stub in case of non OF builds.
--- sound/soc/sof/sof-audio.c | 22 ---------------------- sound/soc/sof/sof-of-dev.c | 23 +++++++++++++++++++++++ sound/soc/sof/sof-of-dev.h | 9 +++++++++ 3 files changed, 32 insertions(+), 22 deletions(-)
sound/soc/sof/sof-audio.c +0 -22
@@ -1007,28 +1007,6 @@ int sof_dai_get_bclk(struct snd_soc_pcm_runtime *rtd) }EXPORT_SYMBOL (sof_dai_get_bclk); -static struct snd_sof_of_mach *sof_of_machine_select (struct snd_sof_dev *sdev) -{ -struct snd_sof_pdata *sof_pdata = sdev->pdata; -const struct sof_dev_desc *desc = sof_pdata->desc; -struct snd_sof_of_mach *mach = desc->of_machines; - -if (!mach) -return NULL ; - -for (; mach->compatible; mach++) { -if (of_machine_is_compatible (mach->compatible)) { - sof_pdata->tplg_filename = mach->sof_tplg_filename; -if (mach->fw_filename) - sof_pdata->fw_filename = mach->fw_filename; - -return mach; - } - } - -return NULL ; -} -/* * SOF Driver enumeration. */
sound/soc/sof/sof-of-dev.c +23 -0
@@ -41,6 +41,29 @@ static void sof_of_probe_complete(struct device *dev)pm_runtime_enable (dev); } +struct snd_sof_of_mach *sof_of_machine_select (struct snd_sof_dev *sdev) +{ +struct snd_sof_pdata *sof_pdata = sdev->pdata; +const struct sof_dev_desc *desc = sof_pdata->desc; +struct snd_sof_of_mach *mach = desc->of_machines; + +if (!mach) +return NULL ; + +for (; mach->compatible; mach++) { +if (of_machine_is_compatible (mach->compatible)) { + sof_pdata->tplg_filename = mach->sof_tplg_filename; +if (mach->fw_filename) + sof_pdata->fw_filename = mach->fw_filename; + +return mach; + } + } + +return NULL ; +} +EXPORT_SYMBOL (sof_of_machine_select); +int sof_of_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
sound/soc/sof/sof-of-dev.h +9 -0
@@ -16,6 +16,15 @@ struct snd_sof_of_mach {const char *sof_tplg_filename; }; +#if IS_ENABLED (CONFIG_SND_SOC_SOF_OF_DEV ) +struct snd_sof_of_mach *sof_of_machine_select (struct snd_sof_dev *sdev); +#else +static inline struct snd_sof_of_mach *sof_of_machine_select (struct snd_sof_dev *sdev) +{ +return NULL ; +} +#endif +extern const struct dev_pm_ops sof_of_pm;int sof_of_probe (struct platform_device *pdev);
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 2/13 ASoC: SOF: Move sof_machine_* functions from sof-audio.c to core.c
In reply to Peter UjfalusiRelocate the machine handling functions from sof-audio.c to core.c to maintain code separation.
While doing the move, drop the redundantIS_ERR_OR_NULL(plat_data->pdev_mach) check fromsof_machine_unregister()
--- sound/soc/sof/core.c | 95 +++++++++++++++++++++++++++++++++++++ sound/soc/sof/sof-audio.c | 98 --------------------------------------- sound/soc/sof/sof-priv.h | 2 - 3 files changed, 95 insertions(+), 100 deletions(-)
sound/soc/sof/core.c +95 -0
@@ -13,6 +13,7 @@#include <sound/soc.h> #include <sound/sof.h> #include "sof-priv.h" +#include "sof-of-dev.h" #include "ops.h" #define CREATE_TRACE_POINTS
@@ -143,6 +144,66 @@ void sof_set_fw_state(struct snd_sof_dev *sdev, enum sof_fw_state new_state) }EXPORT_SYMBOL (sof_set_fw_state); +/* SOF Driver enumeration */ +static int sof_machine_check (struct snd_sof_dev *sdev) +{ +struct snd_sof_pdata *sof_pdata = sdev->pdata; +const struct sof_dev_desc *desc = sof_pdata->desc; +struct snd_soc_acpi_mach *mach; + +if (!IS_ENABLED (CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE )) { +const struct snd_sof_of_mach *of_mach; + +if (IS_ENABLED (CONFIG_SND_SOC_SOF_NOCODEC_DEBUG_SUPPORT ) && +sof_debug_check_flag (SOF_DBG_FORCE_NOCODEC )) + goto nocodec; + +/* find machine */ + mach =snd_sof_machine_select (sdev); +if (mach) { + sof_pdata->machine = mach; + +if (sof_pdata->subsystem_id_set) { + mach->mach_params.subsystem_vendor = sof_pdata->subsystem_vendor; + mach->mach_params.subsystem_device = sof_pdata->subsystem_device; + mach->mach_params.subsystem_id_set = true; + } + +snd_sof_set_mach_params (mach, sdev); +return 0 ; + } + + of_mach =sof_of_machine_select (sdev); +if (of_mach) { + sof_pdata->of_machine = of_mach; +return 0 ; + } + +if (!IS_ENABLED (CONFIG_SND_SOC_SOF_NOCODEC )) { +dev_err (sdev->dev,"error: no matching ASoC machine driver found - aborting probe\n" ); +return -ENODEV ; + } + }else { +dev_warn (sdev->dev,"Force to use nocodec mode\n" ); + } + +nocodec: +/* select nocodec mode */ +dev_warn (sdev->dev,"Using nocodec machine driver\n" ); + mach =devm_kzalloc (sdev->dev,sizeof (*mach),GFP_KERNEL ); +if (!mach) +return -ENOMEM ; + + mach->drv_name ="sof-nocodec" ; +if (!sof_pdata->tplg_filename) + sof_pdata->tplg_filename = desc->nocodec_tplg_filename; + + sof_pdata->machine = mach; +snd_sof_set_mach_params (mach, sdev); + +return 0 ; +} +/* * FW Boot State Transition Diagram *
@@ -527,6 +588,40 @@ int snd_sof_device_shutdown(struct device *dev) }EXPORT_SYMBOL (snd_sof_device_shutdown); +/* Machine driver registering and unregistering */ +int sof_machine_register (struct snd_sof_dev *sdev,void *pdata) +{ +struct snd_sof_pdata *plat_data = pdata; +const char *drv_name; +const void *mach; +int size; + + drv_name = plat_data->machine->drv_name; + mach = plat_data->machine; + size =sizeof (*plat_data->machine); + +/* register machine driver, pass machine info as pdata */ + plat_data->pdev_mach = +platform_device_register_data (sdev->dev, drv_name, +PLATFORM_DEVID_NONE , mach, size); +if (IS_ERR (plat_data->pdev_mach)) +return PTR_ERR (plat_data->pdev_mach); + +dev_dbg (sdev->dev,"created machine %s\n" , +dev_name (&plat_data->pdev_mach->dev)); + +return 0 ; +} +EXPORT_SYMBOL (sof_machine_register); + +void sof_machine_unregister (struct snd_sof_dev *sdev,void *pdata) +{ +struct snd_sof_pdata *plat_data = pdata; + +platform_device_unregister (plat_data->pdev_mach); +} +EXPORT_SYMBOL (sof_machine_unregister); +MODULE_AUTHOR ("Liam Girdwood" );MODULE_DESCRIPTION ("Sound Open Firmware (SOF) Core" );MODULE_LICENSE ("Dual BSD/GPL" );
sound/soc/sof/sof-audio.c +0 -98
107 lines not on this page · raw message
sound/soc/sof/sof-priv.h +0 -2
@@ -814,8 +814,6 @@ int sof_stream_pcm_open(struct snd_sof_dev *sdev,int sof_stream_pcm_close (struct snd_sof_dev *sdev,struct snd_pcm_substream *substream); -int sof_machine_check (struct snd_sof_dev *sdev); -/* SOF client support */ #if IS_ENABLED (CONFIG_SND_SOC_SOF_CLIENT ) int sof_client_dev_register(struct snd_sof_dev *sdev, const char *name, u32 id,
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 3/13 ASoC: SOF: Add placeholder for platform IPC type and path overrides
In reply to Peter UjfalusiAdd a struct sof_loadable_file_profile which can be filled by platforms (sof-acpi-dev.c, sof-of-dev.c and sof-acpi-dev.c) to be able to use common, generic code to handle path customization.
--- include/sound/sof.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
include/sound/sof.h +15 -0
@@ -57,6 +57,18 @@ enum sof_ipc_type { SOF_IPC_TYPE_COUNT }; +struct sof_loadable_file_profile { +enum sof_ipc_type ipc_type; + +const char *fw_path; +const char *fw_path_postfix; +const char *fw_name; +const char *fw_lib_path; +const char *fw_lib_path_postfix; +const char *tplg_path; +const char *tplg_name; +}; +/* * SOF Platform data. */
@@ -86,6 +98,9 @@ struct snd_sof_pdata {/* descriptor */ const struct sof_dev_desc *desc; +/* platform's preferred IPC type and path overrides */ +struct sof_loadable_file_profile ipc_file_profile_base; +/* firmware and topology filenames */ const char *fw_filename_prefix;const char *fw_filename;
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 4/13 ASoC: SOF: sof-acpi-dev: Save the default IPC type and path overrides
In reply to Peter UjfalusiStore the default IPC type and the firmware and topology path overrides to ipc_file_profile_base
--- sound/soc/sof/sof-acpi-dev.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/soc/sof/sof-acpi-dev.c +4 -0
@@ -87,6 +87,10 @@ int sof_acpi_probe(struct platform_device *pdev, const struct sof_dev_desc *descelse sof_pdata->tplg_filename_prefix = desc->default_tplg_path[SOF_IPC_TYPE_3 ]; + sof_pdata->ipc_file_profile_base.ipc_type = desc->ipc_default; + sof_pdata->ipc_file_profile_base.fw_path = fw_path; + sof_pdata->ipc_file_profile_base.tplg_path = tplg_path; +/* set callback to be called on successful device probe to enable runtime_pm */ sof_pdata->sof_probe_complete = sof_acpi_probe_complete;
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 5/13 ASoC: SOF: sof-of-dev: Save the default IPC type and path overrides
In reply to Peter UjfalusiStore the default IPC type and the firmware and topology path overrides to ipc_file_profile_base
--- sound/soc/sof/sof-of-dev.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/soc/sof/sof-of-dev.c +4 -0
@@ -99,6 +99,10 @@ int sof_of_probe(struct platform_device *pdev)else sof_pdata->tplg_filename_prefix = desc->default_tplg_path[SOF_IPC_TYPE_3 ]; + sof_pdata->ipc_file_profile_base.ipc_type = desc->ipc_default; + sof_pdata->ipc_file_profile_base.fw_path = fw_path; + sof_pdata->ipc_file_profile_base.tplg_path = tplg_path; +/* set callback to be called on successful device probe to enable runtime_pm */ sof_pdata->sof_probe_complete = sof_of_probe_complete;
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 6/13 ASoC: SOF: sof-pci-dev: Save the default IPC type and path overrides
In reply to Peter UjfalusiStore the default IPC type and the overrides to ipc_file_profile_base
--- sound/soc/sof/sof-pci-dev.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
sound/soc/sof/sof-pci-dev.c +15 -0
@@ -190,6 +190,7 @@ static void sof_pci_probe_complete(struct device *dev)int sof_pci_probe (struct pci_dev *pci,const struct pci_device_id *pci_id) { +struct sof_loadable_file_profile *path_override;struct device *dev = &pci->dev;const struct sof_dev_desc *desc = (const struct sof_dev_desc *)pci_id->driver_data;
@@ -334,6 +335,20 @@ int sof_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) sof_pdata->tplg_filename = sof_dmi_override_tplg_name; } + path_override = &sof_pdata->ipc_file_profile_base; + path_override->ipc_type = sof_pdata->ipc_type; + path_override->fw_path = fw_path; + path_override->fw_name = fw_filename; + path_override->fw_lib_path = lib_path; + path_override->tplg_path = tplg_path; + path_override->tplg_name = sof_pdata->tplg_filename; + +if (dmi_check_system (community_key_platforms) && + sof_dmi_use_community_key) { + path_override->fw_path_postfix ="community" ; + path_override->fw_lib_path_postfix ="community" ; + } +/* set callback to be called on successful device probe to enable runtime_pm */ sof_pdata->sof_probe_complete = sof_pci_probe_complete;
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 7/13 ASoC: SOF: core: Implement firmware, topology path setup in core
In reply to Peter UjfalusiUse the information stored in ipc_file_profile_base by platforms to construct the paths, filenames that are going to be used to load the firmware and topology files.
--- sound/soc/sof/Makefile | 3 +- sound/soc/sof/core.c | 70 +++++++++++++++-- sound/soc/sof/fw-file-profile.c | 130 ++++++++++++++++++++++++++++++++ sound/soc/sof/sof-priv.h | 7 ++ 4 files changed, 203 insertions(+), 7 deletions(-) create mode 100644 sound/soc/sof/fw-file-profile.c
sound/soc/sof/Makefile +2 -1
@@ -1,7 +1,8 @@ # SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) snd-sof-objs := core.o ops.o loader.o ipc.o pcm.o pm.o debug.o topology.o\ - control.o trace.o iomem-utils.o sof-audio.o stream-ipc.o + control.o trace.o iomem-utils.o sof-audio.o stream-ipc.o\ + fw-file-profile.o # IPC implementations ifneq ($(CONFIG_SND_SOC_SOF_IPC3),)
sound/soc/sof/core.c +64 -6
82 lines not on this page · raw message
sound/soc/sof/fw-file-profile.c new file +130 -0
130 lines not on this page · raw message
sound/soc/sof/sof-priv.h +7 -0
@@ -695,6 +695,13 @@ void snd_sof_new_platform_drv(struct snd_sof_dev *sdev);*/ extern struct snd_compress_ops sof_compressed_ops; +/* +* Firmware (firmware, libraries, topologies) file location +*/ +int sof_create_ipc_file_profile (struct snd_sof_dev *sdev, +struct sof_loadable_file_profile *base_profile, +struct sof_loadable_file_profile *out_profile); +/* * Firmware loading. */
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 8/13 ASoC: SOF: sof-acpi-dev: Rely on core to create the file paths
In reply to Peter UjfalusiThe core is now using the information from ipc_file_profile_base to create the paths for the loadable files, no need to set it in here anymore.
--- sound/soc/sof/sof-acpi-dev.c | 12 ------------ 1 file changed, 12 deletions(-)
sound/soc/sof/sof-acpi-dev.c +0 -12
@@ -74,18 +74,6 @@ int sof_acpi_probe(struct platform_device *pdev, const struct sof_dev_desc *desc sof_pdata->desc = desc; sof_pdata->dev = &pdev->dev; - sof_pdata->fw_filename = desc->default_fw_filename[SOF_IPC_TYPE_3 ]; - -/* alternate fw and tplg filenames ? */ -if (fw_path) - sof_pdata->fw_filename_prefix = fw_path; -else - sof_pdata->fw_filename_prefix = desc->default_fw_path[SOF_IPC_TYPE_3 ]; - -if (tplg_path) - sof_pdata->tplg_filename_prefix = tplg_path; -else - sof_pdata->tplg_filename_prefix = desc->default_tplg_path[SOF_IPC_TYPE_3 ]; sof_pdata->ipc_file_profile_base.ipc_type = desc->ipc_default; sof_pdata->ipc_file_profile_base.fw_path = fw_path;
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 9/13 ASoC: SOF: sof-of-dev: Rely on core to create the file paths
In reply to Peter UjfalusiThe core is now using the information from ipc_file_profile_base to create the paths for the loadable files, no need to set it in here anymore.
--- sound/soc/sof/sof-of-dev.c | 11 ----------- 1 file changed, 11 deletions(-)
sound/soc/sof/sof-of-dev.c +0 -11
@@ -87,17 +87,6 @@ int sof_of_probe(struct platform_device *pdev) sof_pdata->desc = desc; sof_pdata->dev = &pdev->dev; - sof_pdata->fw_filename = desc->default_fw_filename[SOF_IPC_TYPE_3 ]; - -if (fw_path) - sof_pdata->fw_filename_prefix = fw_path; -else - sof_pdata->fw_filename_prefix = desc->default_fw_path[SOF_IPC_TYPE_3 ]; - -if (tplg_path) - sof_pdata->tplg_filename_prefix = tplg_path; -else - sof_pdata->tplg_filename_prefix = desc->default_tplg_path[SOF_IPC_TYPE_3 ]; sof_pdata->ipc_file_profile_base.ipc_type = desc->ipc_default; sof_pdata->ipc_file_profile_base.fw_path = fw_path;
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 10/13 ASoC: SOF: sof-pci-dev: Rely on core to create the file paths
In reply to Peter UjfalusiThe core is now using the information from ipc_file_profile_base to create the paths for the loadable files, no need to set it in here anymore.
--- sound/soc/sof/sof-pci-dev.c | 115 ++++++------------------------------ 1 file changed, 17 insertions(+), 98 deletions(-)
sound/soc/sof/sof-pci-dev.c +17 -98
@@ -233,120 +233,39 @@ int sof_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) sof_pdata->desc = desc; sof_pdata->dev = dev; - sof_pdata->ipc_type = desc->ipc_default; + path_override = &sof_pdata->ipc_file_profile_base;if (sof_pci_ipc_type <0 ) { - sof_pdata->ipc_type = desc->ipc_default; - }else { -dev_info (dev,"overriding default IPC %d to requested %d\n" , - desc->ipc_default, sof_pci_ipc_type); -if (sof_pci_ipc_type >=SOF_IPC_TYPE_COUNT ) { -dev_err (dev,"invalid request value %d\n" , sof_pci_ipc_type); - ret = -EINVAL ; - goto out; - } -if (!(BIT (sof_pci_ipc_type) & desc->ipc_supported_mask)) { -dev_err (dev,"invalid request value %d, supported mask is %#x\n" , - sof_pci_ipc_type, desc->ipc_supported_mask); - ret = -EINVAL ; - goto out; - } - sof_pdata->ipc_type = sof_pci_ipc_type; - } - -if (fw_filename) { - sof_pdata->fw_filename = fw_filename; - -dev_dbg (dev,"Module parameter used, changed fw filename to %s\n" , - sof_pdata->fw_filename); + path_override->ipc_type = desc->ipc_default; + }else if (sof_pci_ipc_type <SOF_IPC_TYPE_COUNT ) { + path_override->ipc_type = sof_pci_ipc_type; }else { - sof_pdata->fw_filename = desc->default_fw_filename[sof_pdata->ipc_type]; +dev_err (dev,"Invalid IPC type requested: %d\n" , sof_pci_ipc_type); + ret = -EINVAL ; + goto out; } -/* -* for platforms using the SOF community key, change the -* default path automatically to pick the right files from the -* linux-firmware tree. This can be overridden with the -* fw_path kernel parameter, e.g. for developers. -*/ - -/* alternate fw and tplg filenames ? */ -if (fw_path) { - sof_pdata->fw_filename_prefix = fw_path; - -dev_dbg (dev, -"Module parameter used, changed fw path to %s\n" , - sof_pdata->fw_filename_prefix); - - }else if (dmi_check_system (community_key_platforms) && sof_dmi_use_community_key) { - sof_pdata->fw_filename_prefix = -devm_kasprintf (dev,GFP_KERNEL ,"%s/%s" , - sof_pdata->desc->default_fw_path[sof_pdata->ipc_type], -"community" ); - -dev_dbg (dev, -"Platform uses community key, changed fw path to %s\n" , - sof_pdata->fw_filename_prefix); - }else { - sof_pdata->fw_filename_prefix = - sof_pdata->desc->default_fw_path[sof_pdata->ipc_type]; - } + path_override->fw_path = fw_path; + path_override->fw_name = fw_filename; + path_override->fw_lib_path = lib_path; + path_override->tplg_path = tplg_path; -if (lib_path) { - sof_pdata->fw_lib_prefix = lib_path; - -dev_dbg (dev,"Module parameter used, changed fw_lib path to %s\n" , - sof_pdata->fw_lib_prefix); - - }else if (sof_pdata->desc->default_lib_path[sof_pdata->ipc_type]) { -if (dmi_check_system (community_key_platforms) && sof_dmi_use_community_key) { - sof_pdata->fw_lib_prefix = -devm_kasprintf (dev,GFP_KERNEL ,"%s/%s" , - sof_pdata->desc->default_lib_path[sof_pdata->ipc_type], -"community" ); - -dev_dbg (dev, -"Platform uses community key, changed fw_lib path to %s\n" , - sof_pdata->fw_lib_prefix); - }else { - sof_pdata->fw_lib_prefix = - sof_pdata->desc->default_lib_path[sof_pdata->ipc_type]; - } +if (dmi_check_system (community_key_platforms) && + sof_dmi_use_community_key) { + path_override->fw_path_postfix ="community" ; + path_override->fw_lib_path_postfix ="community" ; } -if (tplg_path) - sof_pdata->tplg_filename_prefix = tplg_path; -else - sof_pdata->tplg_filename_prefix = - sof_pdata->desc->default_tplg_path[sof_pdata->ipc_type]; -/* * the topology filename will be provided in the machine descriptor, unless * it is overridden by a module parameter or DMI quirk. */ if (tplg_filename) { - sof_pdata->tplg_filename = tplg_filename; - -dev_dbg (dev,"Module parameter used, changed tplg filename to %s\n" , - sof_pdata->tplg_filename); + path_override->tplg_name = tplg_filename; }else {dmi_check_system (sof_tplg_table);if (sof_dmi_override_tplg_name) - sof_pdata->tplg_filename = sof_dmi_override_tplg_name; - } - - path_override = &sof_pdata->ipc_file_profile_base; - path_override->ipc_type = sof_pdata->ipc_type; - path_override->fw_path = fw_path; - path_override->fw_name = fw_filename; - path_override->fw_lib_path = lib_path; - path_override->tplg_path = tplg_path; - path_override->tplg_name = sof_pdata->tplg_filename; - -if (dmi_check_system (community_key_platforms) && - sof_dmi_use_community_key) { - path_override->fw_path_postfix ="community" ; - path_override->fw_lib_path_postfix ="community" ; + path_override->tplg_name = sof_dmi_override_tplg_name; }/* set callback to be called on successful device probe to enable runtime_pm */
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 11/13 ASoC: SOF: core: Add helper for initialization of paths, ops
In reply to Peter UjfalusiAdd sof_init_environment() as a helper function to contain path and ops initialization.
--- sound/soc/sof/core.c | 56 +++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 22 deletions(-)
sound/soc/sof/core.c +34 -22
@@ -265,6 +265,38 @@ static int sof_select_ipc_and_paths(struct snd_sof_dev *sdev)return 0 ; } +static int sof_init_environment (struct snd_sof_dev *sdev) +{ +int ret; + + ret =sof_select_ipc_and_paths (sdev); +if (ret) +return ret; + +/* init ops, if necessary */ + ret =sof_ops_init (sdev); +if (ret <0 ) +return ret; + +/* check all mandatory ops */ +if (!sof_ops (sdev) || !sof_ops (sdev)->probe) { +dev_err (sdev->dev,"missing mandatory ops\n" ); +sof_ops_free (sdev); +return -EINVAL ; + } + +if (!sdev->dspless_mode_selected && + (!sof_ops (sdev)->run || !sof_ops (sdev)->block_read || + !sof_ops (sdev)->block_write || !sof_ops (sdev)->send_msg || + !sof_ops (sdev)->load_firmware || !sof_ops (sdev)->ipc_msg_data)) { +dev_err (sdev->dev,"missing mandatory DSP ops\n" ); +sof_ops_free (sdev); +return -EINVAL ; + } + +return 0 ; +} +/* * FW Boot State Transition Diagram *
@@ -503,31 +535,11 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data) } } - ret =sof_select_ipc_and_paths (sdev); +/* Initialize loadable file paths and check the environment validity */ + ret =sof_init_environment (sdev);if (ret)return ret; -/* init ops, if necessary */ - ret =sof_ops_init (sdev); -if (ret <0 ) -return ret; - -/* check all mandatory ops */ -if (!sof_ops (sdev) || !sof_ops (sdev)->probe) { -sof_ops_free (sdev); -dev_err (dev,"missing mandatory ops\n" ); -return -EINVAL ; - } - -if (!sdev->dspless_mode_selected && - (!sof_ops (sdev)->run || !sof_ops (sdev)->block_read || - !sof_ops (sdev)->block_write || !sof_ops (sdev)->send_msg || - !sof_ops (sdev)->load_firmware || !sof_ops (sdev)->ipc_msg_data)) { -sof_ops_free (sdev); -dev_err (dev,"missing mandatory DSP ops\n" ); -return -EINVAL ; - } -INIT_LIST_HEAD (&sdev->pcm_list);INIT_LIST_HEAD (&sdev->kcontrol_list);INIT_LIST_HEAD (&sdev->widget_list);
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 12/13 ASoC: SOF: Intel: Do not use resource managed allocation for ipc4_data
In reply to Peter UjfalusiManage the ipc4_data allocation in code instead of devm since the ops_init might be called more than once due to IPC type fallback.
--- sound/soc/sof/intel/apl.c | 2 +- sound/soc/sof/intel/cnl.c | 2 +- sound/soc/sof/intel/hda-dai.c | 3 +++ sound/soc/sof/intel/icl.c | 2 +- sound/soc/sof/intel/lnl.c | 2 +- sound/soc/sof/intel/mtl.c | 2 +- sound/soc/sof/intel/skl.c | 2 +- sound/soc/sof/intel/tgl.c | 2 +- 8 files changed, 10 insertions(+), 7 deletions(-)
sound/soc/sof/intel/apl.c +1 -1
@@ -55,7 +55,7 @@ int sof_apl_ops_init(struct snd_sof_dev *sdev)if (sdev->pdata->ipc_type ==SOF_IPC_TYPE_4 ) {struct sof_ipc4_fw_data *ipc4_data; - sdev->private =devm_kzalloc (sdev->dev,sizeof (*ipc4_data),GFP_KERNEL ); + sdev->private =kzalloc (sizeof (*ipc4_data),GFP_KERNEL );if (!sdev->private)return -ENOMEM ;
sound/soc/sof/intel/cnl.c +1 -1
@@ -402,7 +402,7 @@ int sof_cnl_ops_init(struct snd_sof_dev *sdev)if (sdev->pdata->ipc_type ==SOF_IPC_TYPE_4 ) {struct sof_ipc4_fw_data *ipc4_data; - sdev->private =devm_kzalloc (sdev->dev,sizeof (*ipc4_data),GFP_KERNEL ); + sdev->private =kzalloc (sizeof (*ipc4_data),GFP_KERNEL );if (!sdev->private)return -ENOMEM ;
sound/soc/sof/intel/hda-dai.c +3 -0
@@ -621,6 +621,9 @@ void hda_ops_free(struct snd_sof_dev *sdev)if (!hda_use_tplg_nhlt)intel_nhlt_free (ipc4_data->nhlt); + +kfree (sdev->private); + sdev->private =NULL ; } }EXPORT_SYMBOL_NS (hda_ops_free,SND_SOC_SOF_INTEL_HDA_COMMON );
sound/soc/sof/intel/icl.c +1 -1
@@ -123,7 +123,7 @@ int sof_icl_ops_init(struct snd_sof_dev *sdev)if (sdev->pdata->ipc_type ==SOF_IPC_TYPE_4 ) {struct sof_ipc4_fw_data *ipc4_data; - sdev->private =devm_kzalloc (sdev->dev,sizeof (*ipc4_data),GFP_KERNEL ); + sdev->private =kzalloc (sizeof (*ipc4_data),GFP_KERNEL );if (!sdev->private)return -ENOMEM ;
sound/soc/sof/intel/lnl.c +1 -1
@@ -120,7 +120,7 @@ int sof_lnl_ops_init(struct snd_sof_dev *sdev) sof_lnl_ops.get_stream_position = mtl_dsp_get_stream_hda_link_position; - sdev->private =devm_kzalloc (sdev->dev,sizeof (struct sof_ipc4_fw_data ),GFP_KERNEL ); + sdev->private =kzalloc (sizeof (struct sof_ipc4_fw_data ),GFP_KERNEL );if (!sdev->private)return -ENOMEM ;
sound/soc/sof/intel/mtl.c +1 -1
@@ -709,7 +709,7 @@ int sof_mtl_ops_init(struct snd_sof_dev *sdev) sof_mtl_ops.get_stream_position = mtl_dsp_get_stream_hda_link_position; - sdev->private =devm_kzalloc (sdev->dev,sizeof (struct sof_ipc4_fw_data ),GFP_KERNEL ); + sdev->private =kzalloc (sizeof (struct sof_ipc4_fw_data ),GFP_KERNEL );if (!sdev->private)return -ENOMEM ;
sound/soc/sof/intel/skl.c +1 -1
@@ -62,7 +62,7 @@ int sof_skl_ops_init(struct snd_sof_dev *sdev)/* probe/remove/shutdown */ sof_skl_ops.shutdown = hda_dsp_shutdown; - sdev->private =devm_kzalloc (sdev->dev,sizeof (*ipc4_data),GFP_KERNEL ); + sdev->private =kzalloc (sizeof (*ipc4_data),GFP_KERNEL );if (!sdev->private)return -ENOMEM ;
sound/soc/sof/intel/tgl.c +1 -1
@@ -82,7 +82,7 @@ int sof_tgl_ops_init(struct snd_sof_dev *sdev)if (sdev->pdata->ipc_type ==SOF_IPC_TYPE_4 ) {struct sof_ipc4_fw_data *ipc4_data; - sdev->private =devm_kzalloc (sdev->dev,sizeof (*ipc4_data),GFP_KERNEL ); + sdev->private =kzalloc (sizeof (*ipc4_data),GFP_KERNEL );if (!sdev->private)return -ENOMEM ;
Signature · 1 line
2.43.0
Peter Ujfalusi
maintainerPATCH 13/13 ASoC: SOF: core: Implement IPC version fallback if firmware files are missing
In reply to Peter UjfalusiIf a firmware file is missing for the selected IPC type then try to switch to other supported IPC type and check if that one can be used instead.
If for example a platform is changed to IPC4 as default version but the given machine does not yet have the needed topology file created then we will fall back to IPC3 which should have all the needed files.
Relocate the sof_init_environment() to be done at a later phase, in sof_probe_continue().
This will only have changes in behavior if CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE is enabled (Intel HDA platforms) by not failing the module probe, but it is not going to be different case compared to for example failed firmware booting or topology loading error.
--- sound/soc/sof/Kconfig | 11 ++ sound/soc/sof/core.c | 104 ++++++++++----- sound/soc/sof/fw-file-profile.c | 226 +++++++++++++++++++++++++++++--- 3 files changed, 292 insertions(+), 49 deletions(-)
sound/soc/sof/Kconfig +11 -0
@@ -126,6 +126,17 @@ config SND_SOC_SOF_STRICT_ABI_CHECKS If you are not involved in SOF releases and CI development, select "N". +config SND_SOC_SOF_ALLOW_FALLBACK_TO_NEWER_IPC_VERSION + bool "SOF allow fallback to newer IPC version" + help + This option will allow the kernel to try to 'fallback' to a newer IPC + version if there are missing firmware files to satisfy the default IPC + version. + IPC version fallback to older versions is not affected by this option, + it is always available. + Say Y if you are involved in SOF development and need this option. + If not, select N. + config SND_SOC_SOF_DEBUG bool "SOF debugging features" help
sound/soc/sof/core.c +72 -32
151 lines not on this page · raw message
sound/soc/sof/fw-file-profile.c +209 -17
279 lines not on this page · raw message
Signature · 1 line
2.43.0
Mark Brown
maintainerQuoted 8 lines · Peter Ujfalusi
The main aim of the series is to provide a mechanism to fallback to 'older' IPC versions in case the desired one is missing either a firmware or topology file. It is going to make the life of users and distributions if we are going to start transition existing IPC3 platforms to IPC4 (CAVS2.5) and we might have missed some topology file to convert for example.
In that case the kernel will fallback to IPC3 without audio regression.[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[01/13] ASoC: SOF: Move sof_of_machine_select() to sof-of-dev.c from sof-audio.c
commit: 014fdeb0d747304111cfecf93df4407c1a0c80db
[02/13] ASoC: SOF: Move sof_machine_* functions from sof-audio.c to core.c
commit: 3bc3477915587440035f192c89a1bf9a4360abb3
[03/13] ASoC: SOF: Add placeholder for platform IPC type and path overrides
commit: 1162d267eabd6392d0d07bc88b75056e88042fc0
[04/13] ASoC: SOF: sof-acpi-dev: Save the default IPC type and path overrides
commit: a07625dcaf994ab3c5a6a456624719df05ed8ad6
[05/13] ASoC: SOF: sof-of-dev: Save the default IPC type and path overrides
commit: 396016d56da4ad30fe9ff736e44d9e1457484805
[06/13] ASoC: SOF: sof-pci-dev: Save the default IPC type and path overrides
commit: 59ddeae037b81303063bcf62b70fb33841b3f89e
[07/13] ASoC: SOF: core: Implement firmware, topology path setup in core
commit: b1a4ee9fd5a2dfb0f23abe58377f816915ec14ba
[08/13] ASoC: SOF: sof-acpi-dev: Rely on core to create the file paths
commit: b2b0bba36f0a81743e7143a8801ca75d2238bdac
[09/13] ASoC: SOF: sof-of-dev: Rely on core to create the file paths
commit: 8616168928f278723fdc3f4d7cd3d611dcdae8f8
[10/13] ASoC: SOF: sof-pci-dev: Rely on core to create the file paths
commit: 8a83f180abb5b95f524fc9b5eb2291f0e39bed30
[11/13] ASoC: SOF: core: Add helper for initialization of paths, ops
commit: a5a65437b02df8b842c4620b0b776bcd91ce200a
[12/13] ASoC: SOF: Intel: Do not use resource managed allocation for ipc4_data
commit: 9b6896538ea71b7c24da1ecb38738a311176f6a8
[13/13] ASoC: SOF: core: Implement IPC version fallback if firmware files are missing
commit: 6c393ebbd74ad341bcfb4e2d0091b2655fad45d0All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark