ASoC: Intel: Skylake: Add support for firmware manifest
Subsystems (3)
v2 cover ASoC: Intel: Skylake: Add support for firmware manifest
In the DSP firmware, module params like module_id and loadable flags can be modified. So, it is required to read these parameters in the driver from the firmware manifest.
Changes in v2:
- remove strings and use UUID in bin format
Shreyas NC (2):
ASoC: Intel: Skylake: Use UUID in binary format
ASoC: Intel: Skylake: Add DSP firmware manifest parsing
sound/soc/intel/skylake/Makefile | 2 +- sound/soc/intel/skylake/skl-dsp-parse.c | 105 ++++++++++++++++++++++++++ sound/soc/intel/skylake/skl-dsp-parse.h | 107 +++++++++++++++++++++++++++ sound/soc/intel/skylake/skl-sst-dsp.h | 2 +- sound/soc/intel/skylake/skl-sst-ipc.h | 4 + sound/soc/intel/skylake/skl-sst.c | 20 ++++- sound/soc/intel/skylake/skl-topology.c | 11 ++- sound/soc/intel/skylake/skl-topology.h | 2 +- sound/soc/intel/skylake/skl-tplg-interface.h | 2 +- 9 files changed, 243 insertions(+), 12 deletions(-) create mode 100644 sound/soc/intel/skylake/skl-dsp-parse.c create mode 100644 sound/soc/intel/skylake/skl-dsp-parse.h
Signature · 1 line
1.9.1
PATCH v2 1/2 ASoC: Intel: Skylake: Use UUID in binary format
From: Shreyas NC <[email protected]>
To avoid complex string manipulations with UUID in canonical form, use UUID in binary format.
--- sound/soc/intel/skylake/skl-sst-dsp.h | 2 +- sound/soc/intel/skylake/skl-sst.c | 9 ++++++--- sound/soc/intel/skylake/skl-topology.c | 6 ++---- sound/soc/intel/skylake/skl-topology.h | 2 +- sound/soc/intel/skylake/skl-tplg-interface.h | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-)
sound/soc/intel/skylake/skl-sst-dsp.h +1 -1
@@ -118,7 +118,7 @@ struct skl_dsp_fw_ops {int (*set_state_D0)(struct sst_dsp *ctx);int (*set_state_D3)(struct sst_dsp *ctx);unsigned int (*get_fw_errcode)(struct sst_dsp *ctx); -int (*load_mod)(struct sst_dsp *ctx,u16 mod_id,char *mod_name); +int (*load_mod)(struct sst_dsp *ctx,u16 mod_id,u8 *mod_name);int (*unload_mod)(struct sst_dsp *ctx,u16 mod_id); };
sound/soc/intel/skylake/skl-sst.c +6 -3
@@ -20,6 +20,7 @@#include <linux/delay.h> #include <linux/device.h> #include <linux/err.h> +#include <linux/uuid.h> #include "../common/sst-dsp.h" #include "../common/sst-dsp-priv.h" #include "../common/sst-ipc.h"
@@ -304,14 +305,16 @@ static int skl_transfer_module(struct sst_dsp *ctx,return ret; } -static int skl_load_module (struct sst_dsp *ctx,u16 mod_id,char *guid) +static int skl_load_module (struct sst_dsp *ctx,u16 mod_id,u8 *guid) {struct skl_module_table *module_entry =NULL ;int ret =0 ;char mod_name[64 ];/* guid str = 32 chars + 4 hyphens */ +uuid_le *uuid_mod; -snprintf (mod_name,sizeof (mod_name),"%s%s%s" , -"intel/dsp_fw_" , guid,".bin" ); + uuid_mod = (uuid_le *)guid; +snprintf (mod_name,sizeof (mod_name),"%s%pUL%s" , +"intel/dsp_fw_" , uuid_mod,".bin" ); module_entry =skl_module_get_from_id (ctx, mod_id);if (module_entry ==NULL ) {
sound/soc/intel/skylake/skl-topology.c +2 -4
@@ -1583,6 +1583,8 @@ static int skl_tplg_widget_load(struct snd_soc_component *cmpnt,return -ENOMEM ; w->priv = mconfig; +memcpy (&mconfig->guid, &dfw_config->uuid,16 ); + mconfig->id.module_id = dfw_config->module_id; mconfig->id.instance_id = dfw_config->instance_id; mconfig->mcps = dfw_config->max_mcps;
@@ -1612,10 +1614,6 @@ static int skl_tplg_widget_load(struct snd_soc_component *cmpnt, mconfig->time_slot = dfw_config->time_slot; mconfig->formats_config.caps_size = dfw_config->caps.caps_size; -if (dfw_config->is_loadable) -memcpy (mconfig->guid, dfw_config->uuid, -ARRAY_SIZE (dfw_config->uuid)); - mconfig->m_in_pin =devm_kzalloc (bus->dev, (mconfig->max_in_queue) *sizeof (*mconfig->m_in_pin),GFP_KERNEL );
sound/soc/intel/skylake/skl-topology.h +1 -1
@@ -281,7 +281,7 @@ enum skl_module_state { };struct skl_module_cfg { -char guid[SKL_UUID_STR_SZ ]; +u8 guid[16 ];struct skl_module_inst_id id;u8 domain;bool homogenous_inputs;
sound/soc/intel/skylake/skl-tplg-interface.h +1 -1
@@ -181,7 +181,7 @@ struct skl_dfw_pipe { } __packed;struct skl_dfw_module { -char uuid[SKL_UUID_STR_SZ ]; +u8 uuid[16 ];u16 module_id;u16 instance_id;
Signature · 1 line
1.9.1
Mark Brown
maintainerApplied "ASoC: Intel: Skylake: Use UUID in binary format" to the asoc tree
The patch
ASoC: Intel: Skylake: Use UUID in binary format
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All 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
Quoted 1 line
From
09305da97c7808b900985526aa9198233f32fb37Mon Sep 17 00:00:00 2001
From: Shreyas NC <[email protected]>
Date: Thu, 21 Apr 2016 11:45:22 +0530
Subject: [PATCH] ASoC: Intel: Skylake: Use UUID in binary format
To avoid complex string manipulations with UUID in canonical form, use UUID in binary format.
--- sound/soc/intel/skylake/skl-sst-dsp.h | 2 +- sound/soc/intel/skylake/skl-sst.c | 9 ++++++--- sound/soc/intel/skylake/skl-topology.c | 6 ++---- sound/soc/intel/skylake/skl-topology.h | 2 +- sound/soc/intel/skylake/skl-tplg-interface.h | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-)
sound/soc/intel/skylake/skl-sst-dsp.h +1 -1
@@ -118,7 +118,7 @@ struct skl_dsp_fw_ops {int (*set_state_D0)(struct sst_dsp *ctx);int (*set_state_D3)(struct sst_dsp *ctx);unsigned int (*get_fw_errcode)(struct sst_dsp *ctx); -int (*load_mod)(struct sst_dsp *ctx,u16 mod_id,char *mod_name); +int (*load_mod)(struct sst_dsp *ctx,u16 mod_id,u8 *mod_name);int (*unload_mod)(struct sst_dsp *ctx,u16 mod_id); };
sound/soc/intel/skylake/skl-sst.c +6 -3
@@ -20,6 +20,7 @@#include <linux/delay.h> #include <linux/device.h> #include <linux/err.h> +#include <linux/uuid.h> #include "../common/sst-dsp.h" #include "../common/sst-dsp-priv.h" #include "../common/sst-ipc.h"
@@ -304,14 +305,16 @@ static int skl_transfer_module(struct sst_dsp *ctx,return ret; } -static int skl_load_module (struct sst_dsp *ctx,u16 mod_id,char *guid) +static int skl_load_module (struct sst_dsp *ctx,u16 mod_id,u8 *guid) {struct skl_module_table *module_entry =NULL ;int ret =0 ;char mod_name[64 ];/* guid str = 32 chars + 4 hyphens */ +uuid_le *uuid_mod; -snprintf (mod_name,sizeof (mod_name),"%s%s%s" , -"intel/dsp_fw_" , guid,".bin" ); + uuid_mod = (uuid_le *)guid; +snprintf (mod_name,sizeof (mod_name),"%s%pUL%s" , +"intel/dsp_fw_" , uuid_mod,".bin" ); module_entry =skl_module_get_from_id (ctx, mod_id);if (module_entry ==NULL ) {
sound/soc/intel/skylake/skl-topology.c +2 -4
@@ -1550,6 +1550,8 @@ static int skl_tplg_widget_load(struct snd_soc_component *cmpnt,return -ENOMEM ; w->priv = mconfig; +memcpy (&mconfig->guid, &dfw_config->uuid,16 ); + mconfig->id.module_id = dfw_config->module_id; mconfig->id.instance_id = dfw_config->instance_id; mconfig->mcps = dfw_config->max_mcps;
@@ -1579,10 +1581,6 @@ static int skl_tplg_widget_load(struct snd_soc_component *cmpnt, mconfig->time_slot = dfw_config->time_slot; mconfig->formats_config.caps_size = dfw_config->caps.caps_size; -if (dfw_config->is_loadable) -memcpy (mconfig->guid, dfw_config->uuid, -ARRAY_SIZE (dfw_config->uuid)); - mconfig->m_in_pin =devm_kzalloc (bus->dev, (mconfig->max_in_queue) *sizeof (*mconfig->m_in_pin),GFP_KERNEL );
sound/soc/intel/skylake/skl-topology.h +1 -1
@@ -281,7 +281,7 @@ enum skl_module_state { };struct skl_module_cfg { -char guid[SKL_UUID_STR_SZ ]; +u8 guid[16 ];struct skl_module_inst_id id;u8 domain;bool homogenous_inputs;
sound/soc/intel/skylake/skl-tplg-interface.h +1 -1
@@ -181,7 +181,7 @@ struct skl_dfw_pipe { } __packed;struct skl_dfw_module { -char uuid[SKL_UUID_STR_SZ ]; +u8 uuid[16 ];u16 module_id;u16 instance_id;
Signature · 1 line
2.8.0.rc3
PATCH v2 2/2 ASoC: Intel: Skylake: Add DSP firmware manifest parsing
In reply to Vinod KoulFrom: Shreyas NC <[email protected]>
Module params like module_id and loadable flag can be changed in the DSP Firmware. These are kept in the firmware manifest and driver should read these values from this manifest.
So, add support to parse the DSP firmware manifest and read these module params.
--- sound/soc/intel/skylake/Makefile | 2 +- sound/soc/intel/skylake/skl-dsp-parse.c | 105 +++++++++++++++++++++++++++++++ sound/soc/intel/skylake/skl-dsp-parse.h | 107 ++++++++++++++++++++++++++++++++ sound/soc/intel/skylake/skl-sst-ipc.h | 4 ++ sound/soc/intel/skylake/skl-sst.c | 11 +++- sound/soc/intel/skylake/skl-topology.c | 7 ++- 6 files changed, 233 insertions(+), 3 deletions(-) create mode 100644 sound/soc/intel/skylake/skl-dsp-parse.c create mode 100644 sound/soc/intel/skylake/skl-dsp-parse.h
sound/soc/intel/skylake/Makefile +1 -1
@@ -5,6 +5,6 @@ obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl.o # Skylake IPC Support snd-soc-skl-ipc-objs := skl-sst-ipc.o skl-sst-dsp.o skl-sst-cldma.o \ - skl-sst.o bxt-sst.o + skl-sst.o skl-dsp-parse.o bxt-sst.o obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl-ipc.o
sound/soc/intel/skylake/skl-dsp-parse.c new file +105 -0
105 lines not on this page · raw message
sound/soc/intel/skylake/skl-dsp-parse.h new file +107 -0
107 lines not on this page · raw message
sound/soc/intel/skylake/skl-sst-ipc.h +4 -0
@@ -60,6 +60,10 @@ struct skl_sst {void (*enable_miscbdcge)(struct device *dev,bool enable);/*Is CGCTL.MISCBDCGE disabled*/ bool miscbdcg_disabled; + +/* Populate module information */ +struct uuid_tbl *tbl; +int num_modules; };struct skl_ipc_init_instance_msg {
sound/soc/intel/skylake/skl-sst.c +10 -1
@@ -25,6 +25,7 @@#include "../common/sst-dsp-priv.h" #include "../common/sst-ipc.h" #include "skl-sst-ipc.h" +#include "skl-dsp-parse.h" #define SKL_BASEFW_TIMEOUT 300#define SKL_INIT_TIMEOUT 1000
@@ -70,7 +71,7 @@ static int skl_transfer_firmware(struct sst_dsp *ctx,static int skl_load_base_firmware (struct sst_dsp *ctx) { -int ret =0 , i; +int ret =0 , i, err;struct skl_sst *skl = ctx->thread_context;u32 reg;
@@ -84,6 +85,14 @@ static int skl_load_base_firmware(struct sst_dsp *ctx)skl_dsp_disable_core (ctx);return -EIO ; } + + err =parse_fw_bin (ctx); +if (err <0 ) { +dev_err (ctx->dev, +"Firmware parsing err: %d\n" , ret); +release_firmware (ctx->fw); +return err; + } } ret =skl_dsp_boot (ctx);
sound/soc/intel/skylake/skl-topology.c +6 -1
@@ -28,6 +28,7 @@#include "skl-tplg-interface.h" #include "../common/sst-dsp.h" #include "../common/sst-dsp-priv.h" +#include "skl-dsp-parse.h" #define SKL_CH_FIXUP_MASK (1 << 0)#define SKL_RATE_FIXUP_MASK (1 << 1)
@@ -1583,7 +1584,11 @@ static int skl_tplg_widget_load(struct snd_soc_component *cmpnt,return -ENOMEM ; w->priv = mconfig; -memcpy (&mconfig->guid, &dfw_config->uuid,16 ); +memcpy (&mconfig->guid, &dfw_config->uuid,sizeof (mconfig->guid)); + + ret =snd_skl_get_module_info (skl->skl_sst, mconfig->guid, dfw_config); +if (ret <0 ) +return ret; mconfig->id.module_id = dfw_config->module_id; mconfig->id.instance_id = dfw_config->instance_id;
Signature · 1 line
1.9.1
Mark Brown
maintainerRe: [PATCH v2 2/2] ASoC: Intel: Skylake: Add DSP firmware manifest parsing
sound/soc/intel/skylake/skl-dsp-parse.c line 83
Quoted 7 lines · Vinod Koul
sound/soc/intel/skylake/skl-dsp-parse.c new file +7
-0+ num_entry = adsp_hdr->num_module_entries; + + tbl =devm_kzalloc (ctx->dev, + num_entry *sizeof (struct uuid_tbl ),GFP_KERNEL ); + +if (!tbl) +return -ENOMEM ;
I'm still not seeing any bounds checking to make sure we don't read beyond the end of the firmware file.
Re: [PATCH v2 2/2] ASoC: Intel: Skylake: Add DSP firmware manifest parsing
Quoted 12 lines · Mark Brown
sound/soc/intel/skylake/skl-dsp-parse.c line 83
Quoted 7 lines · Vinod Koul
sound/soc/intel/skylake/skl-dsp-parse.c new file +7
-0+ num_entry = adsp_hdr->num_module_entries; + + tbl =devm_kzalloc (ctx->dev, + num_entry *sizeof (struct uuid_tbl ),GFP_KERNEL ); + +if (!tbl) +return -ENOMEM ;I'm still not seeing any bounds checking to make sure we don't read beyond the end of the firmware file.
Since we are using adsp_hdr->num_module_entrie for parsing technically we should not go beyond.
But yes if the file goes bad then we might have an issue, we will add check for that
Thanks
Signature · 1 line
~Vinod