ASoC: wm_adsp: Correct algorithm list allocation size
Subsystems (3)
PATCH 1/5 ASoC: wm_adsp: Correct algorithm list allocation size
Commit 6396bb221514 ("treewide: kzalloc() -> kcalloc()") was overlooked when doing some refactoring to the algorithm list handling, which lead to twice as much buffer being allocated as required for reading the algorithm list. A kcalloc is no longer appropriate since the allocation size is now in bytes not registers, as such change back to kzalloc.
--- sound/soc/codecs/wm_adsp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm_adsp.c +1 -1
@@ -1906,7 +1906,7 @@ static void *wm_adsp_read_algs(struct wm_adsp *dsp, size_t n_algs,/* Convert length from DSP words to bytes */ len *=sizeof (u32); - alg =kcalloc (len,2 ,GFP_KERNEL |GFP_DMA ); + alg =kzalloc (len,GFP_KERNEL |GFP_DMA );if (!alg)return ERR_PTR (-ENOMEM );
Signature · 1 line
2.11.0
PATCH 2/5 ASoC: wm_adsp: Take prefix into account in control name length
Currently when creating ALSA control names for the DSP the length of any prefix applied to the CODEC is not taken into account. Whilst this is mostly harmless it does result in ALSA doing the truncation of the control names and printing a warning. It is better to have the driver do the truncation so it can truncate from the start of parameter name itself to give a greater chance of the result maintain a unique name.
--- sound/soc/codecs/wm_adsp.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/codecs/wm_adsp.c +3 -0
@@ -1343,6 +1343,9 @@ static int wm_adsp_create_control(struct wm_adsp *dsp,int avail =SNDRV_CTL_ELEM_ID_NAME_MAXLEN - ret -2 ;int skip =0 ; +if (dsp->component->name_prefix) + avail -=strlen (dsp->component->name_prefix) +1 ; +if (subname_len > avail) skip = subname_len - avail;
Signature · 1 line
2.11.0
Mark Brown
maintainerApplied "ASoC: wm_adsp: Take prefix into account in control name length" to the asoc tree
The patch
ASoC: wm_adsp: Take prefix into account in control name length
has been applied to the asoc tree at
https://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
b7ede5af62ab6bfad0980fad58e82d3fb56866dfMon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Thu, 19 Jul 2018 11:50:36 +0100
Subject: [PATCH] ASoC: wm_adsp: Take prefix into account in control name
length
Currently when creating ALSA control names for the DSP the length of any prefix applied to the CODEC is not taken into account. Whilst this is mostly harmless it does result in ALSA doing the truncation of the control names and printing a warning. It is better to have the driver do the truncation so it can truncate from the start of parameter name itself to give a greater chance of the result maintain a unique name.
--- sound/soc/codecs/wm_adsp.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/codecs/wm_adsp.c +3 -0
@@ -1343,6 +1343,9 @@ static int wm_adsp_create_control(struct wm_adsp *dsp,int avail =SNDRV_CTL_ELEM_ID_NAME_MAXLEN - ret -2 ;int skip =0 ; +if (dsp->component->name_prefix) + avail -=strlen (dsp->component->name_prefix) +1 ; +if (subname_len > avail) skip = subname_len - avail;
Signature · 1 line
2.18.0
PATCH 3/5 ASoC: wm_adsp: Ensure DSP boot work complete before preloader_put return
In reply to Charles KeepaxFrom: Stuart Henderson <[email protected]>
All controls derived from the loaded firmware should be created prior to returning from the preloader's put function, such that they are immediately available to user-space.
--- sound/soc/codecs/wm_adsp.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/codecs/wm_adsp.c +2 -0
@@ -2685,6 +2685,8 @@ int wm_adsp2_preloader_put(struct snd_kcontrol *kcontrol,snd_soc_dapm_sync (dapm); +flush_work (&dsp->boot_work); +return 0 ; }EXPORT_SYMBOL_GPL (wm_adsp2_preloader_put);
Signature · 1 line
2.11.0
Mark Brown
maintainerApplied "ASoC: wm_adsp: Ensure DSP boot work complete before preloader_put return" to the asoc tree
The patch
ASoC: wm_adsp: Ensure DSP boot work complete before preloader_put return
has been applied to the asoc tree at
https://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
868e49a4a00afaca07d2c450a02e49581eaece6cMon Sep 17 00:00:00 2001
From: Stuart Henderson <[email protected]>
Date: Thu, 19 Jul 2018 11:50:37 +0100
Subject: [PATCH] ASoC: wm_adsp: Ensure DSP boot work complete before
preloader_put return
All controls derived from the loaded firmware should be created prior to returning from the preloader's put function, such that they are immediately available to user-space.
--- sound/soc/codecs/wm_adsp.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/codecs/wm_adsp.c +2 -0
@@ -2672,6 +2672,8 @@ int wm_adsp2_preloader_put(struct snd_kcontrol *kcontrol,snd_soc_dapm_sync (dapm); +flush_work (&dsp->boot_work); +return 0 ; }EXPORT_SYMBOL_GPL (wm_adsp2_preloader_put);
Signature · 1 line
2.18.0
PATCH 4/5 ASoC: wm_adsp: Allow up to 8 channels for voice control
In reply to Charles KeepaxFrom: Richard Fitzgerald <[email protected]>
Newer voice control firmwares can capture multiple audio channels. Allow up to 8 channels for future-proofing.
--- sound/soc/codecs/wm_adsp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm_adsp.c +1 -1
@@ -418,7 +418,7 @@ static const struct wm_adsp_fw_caps ctrl_caps[] = { { .id = SND_AUDIOCODEC_BESPOKE, .desc = { - .max_ch = 1, + .max_ch = 8, .sample_rates = { 16000 }, .num_sample_rates = 1, .formats = SNDRV_PCM_FMTBIT_S16_LE,
Signature · 1 line
2.11.0
Mark Brown
maintainerApplied "ASoC: wm_adsp: Allow up to 8 channels for voice control" to the asoc tree
The patch
ASoC: wm_adsp: Allow up to 8 channels for voice control
has been applied to the asoc tree at
https://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
3bbc2705a3d132b9a86a0e4083f82a2b3c9bfdfdMon Sep 17 00:00:00 2001
From: Richard Fitzgerald <[email protected]>
Date: Thu, 19 Jul 2018 11:50:38 +0100
Subject: [PATCH] ASoC: wm_adsp: Allow up to 8 channels for voice control
Newer voice control firmwares can capture multiple audio channels. Allow up to 8 channels for future-proofing.
--- sound/soc/codecs/wm_adsp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm_adsp.c +1 -1
@@ -418,7 +418,7 @@ static const struct wm_adsp_fw_caps ctrl_caps[] = { { .id = SND_AUDIOCODEC_BESPOKE, .desc = { - .max_ch = 1, + .max_ch = 8, .sample_rates = { 16000 }, .num_sample_rates = 1, .formats = SNDRV_PCM_FMTBIT_S16_LE,
Signature · 1 line
2.18.0
PATCH 5/5 ASoC: wm_adsp: Parse HOST_BUFFER controls
In reply to Charles KeepaxFrom: Richard Fitzgerald <[email protected]>
Currently the compressed streams in DSP firmwares are identified essentially by looking at a fixed location inside the firmware. This is fragile and also limits things to a single compressed stream.
Here a new form of firmware parameter is added, the HOST_BUFFER which identifies a compressed stream from meta-data in the firmware file. This is more robust and allows for the possiblity of using multiple streams per core in the future. Currently the implementation is still limited to a single stream and will use the first HOST_BUFFER parameter encountered. If there aren't any HOST_BUFFER parameters it will fall back to the legacy way of finding the host buffer.
--- sound/soc/codecs/wm_adsp.c | 66 +++++++++++++++++++++++++++++++++++++++++++++- sound/soc/codecs/wmfw.h | 1 + 2 files changed, 66 insertions(+), 1 deletion(-)
sound/soc/codecs/wm_adsp.c +65 -1
@@ -1607,6 +1607,15 @@ static int wm_adsp_parse_coeff(struct wm_adsp *dsp,if (ret)return -EINVAL ;break ; +case WMFW_CTL_TYPE_HOST_BUFFER : + ret =wm_adsp_check_coeff_flags (dsp, &coeff_blk, +WMFW_CTL_FLAG_SYS | +WMFW_CTL_FLAG_VOLATILE | +WMFW_CTL_FLAG_READABLE , +0 ); +if (ret) +return -EINVAL ; +break ;default :adsp_err (dsp,"Unknown control type: %d\n" , coeff_blk.ctl_type);
@@ -3202,7 +3211,7 @@ static inline int wm_adsp_buffer_write(struct wm_adsp_compr_buf *buf, buf->host_buf_ptr + field_offset, data); } -static int wm_adsp_buffer_locate (struct wm_adsp_compr_buf *buf) +static int wm_adsp_legacy_host_buf_addr (struct wm_adsp_compr_buf *buf) {struct wm_adsp_alg_region *alg_region;struct wm_adsp *dsp = buf->dsp;
@@ -3241,6 +3250,61 @@ static int wm_adsp_buffer_locate(struct wm_adsp_compr_buf *buf)return 0 ; } +static struct wm_coeff_ctl * +wm_adsp_find_host_buffer_ctrl (struct wm_adsp_compr_buf *buf) +{ +struct wm_adsp *dsp = buf->dsp; +struct wm_coeff_ctl *ctl; + +list_for_each_entry (ctl, &dsp->ctl_list, list) { +if (ctl->type !=WMFW_CTL_TYPE_HOST_BUFFER ) +continue ; + +if (!ctl->enabled) +continue ; + +return ctl; + } + +return NULL ; +} + +static int wm_adsp_buffer_locate (struct wm_adsp_compr_buf *buf) +{ +struct wm_adsp *dsp = buf->dsp; +struct wm_coeff_ctl *ctl; +unsigned int reg; +u32 val; +int i, ret; + + ctl =wm_adsp_find_host_buffer_ctrl (buf); +if (!ctl) +return wm_adsp_legacy_host_buf_addr (buf); + + ret =wm_coeff_base_reg (ctl, ®); +if (ret) +return ret; + +for (i =0 ; i <5 ; ++i) { + ret =regmap_raw_read (dsp->regmap, reg, &val,sizeof (val)); +if (ret <0 ) +return ret; + +if (val) +break ; + +usleep_range (1000 ,2000 ); + } + +if (!val) +return -EIO ; + + buf->host_buf_ptr =be32_to_cpu (val); +adsp_dbg (dsp,"host_buf_ptr=%x\n" , buf->host_buf_ptr); + +return 0 ; +} +static int wm_adsp_buffer_populate (struct wm_adsp_compr_buf *buf) {const struct wm_adsp_fw_caps *caps = wm_adsp_fw[buf->dsp->fw].caps;
sound/soc/codecs/wmfw.h +1 -0
@@ -29,6 +29,7 @@/* Non-ALSA coefficient types start at 0x1000 */ #define WMFW_CTL_TYPE_ACKED 0x1000/* acked control */ #define WMFW_CTL_TYPE_HOSTEVENT 0x1001/* event control */ +#define WMFW_CTL_TYPE_HOST_BUFFER 0x1002/* host buffer pointer */ struct wmfw_header {char magic[4 ];
Signature · 1 line
2.11.0
Mark Brown
maintainerApplied "ASoC: wm_adsp: Parse HOST_BUFFER controls" to the asoc tree
The patch
ASoC: wm_adsp: Parse HOST_BUFFER controls
has been applied to the asoc tree at
https://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
d52ed4b0bc73c1c7816f5b7a36229a95acfc76c8Mon Sep 17 00:00:00 2001
From: Richard Fitzgerald <[email protected]>
Date: Thu, 19 Jul 2018 11:50:39 +0100
Subject: [PATCH] ASoC: wm_adsp: Parse HOST_BUFFER controls
Currently the compressed streams in DSP firmwares are identified essentially by looking at a fixed location inside the firmware. This is fragile and also limits things to a single compressed stream.
Here a new form of firmware parameter is added, the HOST_BUFFER which identifies a compressed stream from meta-data in the firmware file. This is more robust and allows for the possiblity of using multiple streams per core in the future. Currently the implementation is still limited to a single stream and will use the first HOST_BUFFER parameter encountered. If there aren't any HOST_BUFFER parameters it will fall back to the legacy way of finding the host buffer.
--- sound/soc/codecs/wm_adsp.c | 66 +++++++++++++++++++++++++++++++++++++- sound/soc/codecs/wmfw.h | 1 + 2 files changed, 66 insertions(+), 1 deletion(-)
sound/soc/codecs/wm_adsp.c +65 -1
@@ -1607,6 +1607,15 @@ static int wm_adsp_parse_coeff(struct wm_adsp *dsp,if (ret)return -EINVAL ;break ; +case WMFW_CTL_TYPE_HOST_BUFFER : + ret =wm_adsp_check_coeff_flags (dsp, &coeff_blk, +WMFW_CTL_FLAG_SYS | +WMFW_CTL_FLAG_VOLATILE | +WMFW_CTL_FLAG_READABLE , +0 ); +if (ret) +return -EINVAL ; +break ;default :adsp_err (dsp,"Unknown control type: %d\n" , coeff_blk.ctl_type);
@@ -3200,7 +3209,7 @@ static inline int wm_adsp_buffer_write(struct wm_adsp_compr_buf *buf, buf->host_buf_ptr + field_offset, data); } -static int wm_adsp_buffer_locate (struct wm_adsp_compr_buf *buf) +static int wm_adsp_legacy_host_buf_addr (struct wm_adsp_compr_buf *buf) {struct wm_adsp_alg_region *alg_region;struct wm_adsp *dsp = buf->dsp;
@@ -3239,6 +3248,61 @@ static int wm_adsp_buffer_locate(struct wm_adsp_compr_buf *buf)return 0 ; } +static struct wm_coeff_ctl * +wm_adsp_find_host_buffer_ctrl (struct wm_adsp_compr_buf *buf) +{ +struct wm_adsp *dsp = buf->dsp; +struct wm_coeff_ctl *ctl; + +list_for_each_entry (ctl, &dsp->ctl_list, list) { +if (ctl->type !=WMFW_CTL_TYPE_HOST_BUFFER ) +continue ; + +if (!ctl->enabled) +continue ; + +return ctl; + } + +return NULL ; +} + +static int wm_adsp_buffer_locate (struct wm_adsp_compr_buf *buf) +{ +struct wm_adsp *dsp = buf->dsp; +struct wm_coeff_ctl *ctl; +unsigned int reg; +u32 val; +int i, ret; + + ctl =wm_adsp_find_host_buffer_ctrl (buf); +if (!ctl) +return wm_adsp_legacy_host_buf_addr (buf); + + ret =wm_coeff_base_reg (ctl, ®); +if (ret) +return ret; + +for (i =0 ; i <5 ; ++i) { + ret =regmap_raw_read (dsp->regmap, reg, &val,sizeof (val)); +if (ret <0 ) +return ret; + +if (val) +break ; + +usleep_range (1000 ,2000 ); + } + +if (!val) +return -EIO ; + + buf->host_buf_ptr =be32_to_cpu (val); +adsp_dbg (dsp,"host_buf_ptr=%x\n" , buf->host_buf_ptr); + +return 0 ; +} +static int wm_adsp_buffer_populate (struct wm_adsp_compr_buf *buf) {const struct wm_adsp_fw_caps *caps = wm_adsp_fw[buf->dsp->fw].caps;
sound/soc/codecs/wmfw.h +1 -0
@@ -29,6 +29,7 @@/* Non-ALSA coefficient types start at 0x1000 */ #define WMFW_CTL_TYPE_ACKED 0x1000/* acked control */ #define WMFW_CTL_TYPE_HOSTEVENT 0x1001/* event control */ +#define WMFW_CTL_TYPE_HOST_BUFFER 0x1002/* host buffer pointer */ struct wmfw_header {char magic[4 ];
Signature · 1 line
2.18.0
Mark Brown
maintainerApplied "ASoC: wm_adsp: Correct algorithm list allocation size" to the asoc tree
In reply to Charles KeepaxThe patch
ASoC: wm_adsp: Correct algorithm list allocation size
has been applied to the asoc tree at
https://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
517ee74e1b3124b696f293aa4e220418f8125b4cMon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Thu, 19 Jul 2018 11:50:35 +0100
Subject: [PATCH] ASoC: wm_adsp: Correct algorithm list allocation size
Commit 6396bb221514 ("treewide: kzalloc() -> kcalloc()") was overlooked when doing some refactoring to the algorithm list handling, which lead to twice as much buffer being allocated as required for reading the algorithm list. A kcalloc is no longer appropriate since the allocation size is now in bytes not registers, as such change back to kzalloc.
--- sound/soc/codecs/wm_adsp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm_adsp.c +1 -1
@@ -1906,7 +1906,7 @@ static void *wm_adsp_read_algs(struct wm_adsp *dsp, size_t n_algs,/* Convert length from DSP words to bytes */ len *=sizeof (u32); - alg =kcalloc (len,2 ,GFP_KERNEL |GFP_DMA ); + alg =kzalloc (len,GFP_KERNEL |GFP_DMA );if (!alg)return ERR_PTR (-ENOMEM );
Signature · 1 line
2.18.0