ASoC: wm_adsp: Avoid narrow race condition on compr pointer
Subsystems (3)
PATCH 1/4 ASoC: wm_adsp: Avoid narrow race condition on compr pointer
There is a very small window between then wm_adsp_compr_free gets call and when the DSP is actually powered down. If we get an IRQ from the DSP in this window then the wm_adsp_compr pointer will be NULL. This patch adds a check for this into the IRQ handler to avoid any issues when this happens.
--- sound/soc/codecs/wm_adsp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm_adsp.c +1 -1
@@ -2857,7 +2857,7 @@ int wm_adsp_compr_handle_irq(struct wm_adsp *dsp) goto out; } -if (compr->stream) +if (compr && compr->stream)snd_compr_fragment_elapsed (compr->stream); out:
Signature · 1 line
2.1.4
PATCH 2/4 ASoC: wm_adsp: Explicitly set the control access flags in all cases
In the case where the firmware does not tell us the access flags for the control, we let ALSA select a default (READWRITE). But really we should be applying the volatile flag in this case, as we will read the control from the DSP if it is on in this case. This patch explicitly sets the access flags in all cases.
--- sound/soc/codecs/wm_adsp.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/codecs/wm_adsp.c +3 -0
@@ -877,6 +877,9 @@ static int wmfw_add_ctl(struct wm_adsp *dsp, struct wm_coeff_ctl *ctl) kcontrol->access |=SNDRV_CTL_ELEM_ACCESS_READ ;if (ctl->flags &WMFW_CTL_FLAG_VOLATILE ) kcontrol->access |=SNDRV_CTL_ELEM_ACCESS_VOLATILE ; + }else { + kcontrol->access =SNDRV_CTL_ELEM_ACCESS_READWRITE ; + kcontrol->access |=SNDRV_CTL_ELEM_ACCESS_VOLATILE ; } ret = snd_soc_add_card_controls(dsp->card,
Signature · 1 line
2.1.4
Mark Brown
maintainerApplied "ASoC: wm_adsp: Explicitly set the control access flags in all cases" to the asoc tree
The patch
ASoC: wm_adsp: Explicitly set the control access flags in all cases
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
cc815c4b86d14630a7d4ca4f4c7d2c2acb88cb52Mon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Fri, 19 Feb 2016 14:44:42 +0000
Subject: [PATCH] ASoC: wm_adsp: Explicitly set the control access flags in all
cases
In the case where the firmware does not tell us the access flags for the control, we let ALSA select a default (READWRITE). But really we should be applying the volatile flag in this case, as we will read the control from the DSP if it is on in this case. This patch explicitly sets the access flags in all cases.
--- sound/soc/codecs/wm_adsp.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/codecs/wm_adsp.c +3 -0
@@ -857,6 +857,9 @@ static int wmfw_add_ctl(struct wm_adsp *dsp, struct wm_coeff_ctl *ctl) kcontrol->access |=SNDRV_CTL_ELEM_ACCESS_READ ;if (ctl->flags &WMFW_CTL_FLAG_VOLATILE ) kcontrol->access |=SNDRV_CTL_ELEM_ACCESS_VOLATILE ; + }else { + kcontrol->access =SNDRV_CTL_ELEM_ACCESS_READWRITE ; + kcontrol->access |=SNDRV_CTL_ELEM_ACCESS_VOLATILE ; } ret = snd_soc_add_card_controls(dsp->card,
Signature · 1 line
2.7.0
PATCH 3/4 ASoC: wm_adsp: Fixup some odd line wrapping
In reply to Charles Keepax--- sound/soc/codecs/wm_adsp.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-)
sound/soc/codecs/wm_adsp.c +7 -16
@@ -882,15 +882,13 @@ static int wmfw_add_ctl(struct wm_adsp *dsp, struct wm_coeff_ctl *ctl) kcontrol->access |=SNDRV_CTL_ELEM_ACCESS_VOLATILE ; } - ret =snd_soc_add_card_controls (dsp->card, - kcontrol,1 ); + ret =snd_soc_add_card_controls (dsp->card, kcontrol,1 );if (ret <0 ) goto err_kcontrol;kfree (kcontrol); - ctl->kcontrol =snd_soc_card_get_kcontrol (dsp->card, - ctl->name); + ctl->kcontrol =snd_soc_card_get_kcontrol (dsp->card, ctl->name);return 0 ;
@@ -910,9 +908,7 @@ static int wm_coeff_init_control_caches(struct wm_adsp *dsp)if (ctl->flags &WMFW_CTL_FLAG_VOLATILE )continue ; - ret =wm_coeff_read_control (ctl, - ctl->cache, - ctl->len); + ret =wm_coeff_read_control (ctl, ctl->cache, ctl->len);if (ret <0 )return ret; }
@@ -929,9 +925,7 @@ static int wm_coeff_sync_controls(struct wm_adsp *dsp)if (!ctl->enabled)continue ;if (ctl->set && !(ctl->flags &WMFW_CTL_FLAG_VOLATILE )) { - ret =wm_coeff_write_control (ctl, - ctl->cache, - ctl->len); + ret =wm_coeff_write_control (ctl, ctl->cache, ctl->len);if (ret <0 )return ret; }
@@ -1527,8 +1521,7 @@ static void *wm_adsp_read_algs(struct wm_adsp *dsp, size_t n_algs, ret =regmap_raw_read (dsp->regmap, pos, alg, len *2 );if (ret !=0 ) { -adsp_err (dsp,"Failed to read algorithm list: %d\n" , - ret); +adsp_err (dsp,"Failed to read algorithm list: %d\n" , ret);kfree (alg);return ERR_PTR (ret); }
@@ -2027,8 +2020,7 @@ int wm_adsp1_event(struct snd_soc_dapm_widget *w, goto err_mutex; } - val = (val & dsp->sysclk_mask) - >> dsp->sysclk_shift; + val = (val & dsp->sysclk_mask) >> dsp->sysclk_shift; ret = regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_31,
@@ -2121,8 +2113,7 @@ static int wm_adsp2_ena(struct wm_adsp *dsp)/* Wait for the RAM to start, should be near instantaneous */ for (count =0 ; count <10 ; ++count) { - ret =regmap_read (dsp->regmap, dsp->base +ADSP2_STATUS1 , - &val); + ret =regmap_read (dsp->regmap, dsp->base +ADSP2_STATUS1 , &val);if (ret !=0 )return ret;
Signature · 1 line
2.1.4
Mark Brown
maintainerApplied "ASoC: wm_adsp: Fixup some odd line wrapping" to the asoc tree
The patch
ASoC: wm_adsp: Fixup some odd line wrapping
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
7d00cd975a52e637da19548c1cc7d87a0a32b49cMon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Fri, 19 Feb 2016 14:44:43 +0000
Subject: [PATCH] ASoC: wm_adsp: Fixup some odd line wrapping
--- sound/soc/codecs/wm_adsp.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-)
sound/soc/codecs/wm_adsp.c +7 -16
@@ -862,15 +862,13 @@ static int wmfw_add_ctl(struct wm_adsp *dsp, struct wm_coeff_ctl *ctl) kcontrol->access |=SNDRV_CTL_ELEM_ACCESS_VOLATILE ; } - ret =snd_soc_add_card_controls (dsp->card, - kcontrol,1 ); + ret =snd_soc_add_card_controls (dsp->card, kcontrol,1 );if (ret <0 ) goto err_kcontrol;kfree (kcontrol); - ctl->kcontrol =snd_soc_card_get_kcontrol (dsp->card, - ctl->name); + ctl->kcontrol =snd_soc_card_get_kcontrol (dsp->card, ctl->name);return 0 ;
@@ -890,9 +888,7 @@ static int wm_coeff_init_control_caches(struct wm_adsp *dsp)if (ctl->flags &WMFW_CTL_FLAG_VOLATILE )continue ; - ret =wm_coeff_read_control (ctl, - ctl->cache, - ctl->len); + ret =wm_coeff_read_control (ctl, ctl->cache, ctl->len);if (ret <0 )return ret; }
@@ -909,9 +905,7 @@ static int wm_coeff_sync_controls(struct wm_adsp *dsp)if (!ctl->enabled)continue ;if (ctl->set && !(ctl->flags &WMFW_CTL_FLAG_VOLATILE )) { - ret =wm_coeff_write_control (ctl, - ctl->cache, - ctl->len); + ret =wm_coeff_write_control (ctl, ctl->cache, ctl->len);if (ret <0 )return ret; }
@@ -1507,8 +1501,7 @@ static void *wm_adsp_read_algs(struct wm_adsp *dsp, size_t n_algs, ret =regmap_raw_read (dsp->regmap, pos, alg, len *2 );if (ret !=0 ) { -adsp_err (dsp,"Failed to read algorithm list: %d\n" , - ret); +adsp_err (dsp,"Failed to read algorithm list: %d\n" , ret);kfree (alg);return ERR_PTR (ret); }
@@ -2007,8 +2000,7 @@ int wm_adsp1_event(struct snd_soc_dapm_widget *w, goto err_mutex; } - val = (val & dsp->sysclk_mask) - >> dsp->sysclk_shift; + val = (val & dsp->sysclk_mask) >> dsp->sysclk_shift; ret = regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_31,
@@ -2101,8 +2093,7 @@ static int wm_adsp2_ena(struct wm_adsp *dsp)/* Wait for the RAM to start, should be near instantaneous */ for (count =0 ; count <10 ; ++count) { - ret =regmap_read (dsp->regmap, dsp->base +ADSP2_STATUS1 , - &val); + ret =regmap_read (dsp->regmap, dsp->base +ADSP2_STATUS1 , &val);if (ret !=0 )return ret;
Signature · 1 line
2.7.0
PATCH 4/4 ASoC: wm_adsp: wm_coeff_{read|write}_control should use passed length
In reply to Charles Keepaxwm_coeff_{read|write}_control were using the control length rather than the length parameter passed to them. This is not causing any issues as the two values are currently always the same, but this needs fixed to allow future improvements.
--- sound/soc/codecs/wm_adsp.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
sound/soc/codecs/wm_adsp.c +8 -8
@@ -741,19 +741,19 @@ static int wm_coeff_write_control(struct wm_coeff_ctl *ctl, reg = ctl->alg_region.base + ctl->offset; reg =wm_adsp_region_to_reg (mem, reg); - scratch =kmemdup (buf, ctl->len,GFP_KERNEL |GFP_DMA ); + scratch =kmemdup (buf, len,GFP_KERNEL |GFP_DMA );if (!scratch)return -ENOMEM ; ret =regmap_raw_write (dsp->regmap, reg, scratch, - ctl->len); + len);if (ret) {adsp_err (dsp,"Failed to write %zu bytes to %x: %d\n" , - ctl->len, reg, ret); + len, reg, ret);kfree (scratch);return ret; } -adsp_dbg (dsp,"Wrote %zu bytes to %x\n" , ctl->len, reg); +adsp_dbg (dsp,"Wrote %zu bytes to %x\n" , len, reg);kfree (scratch);
@@ -800,20 +800,20 @@ static int wm_coeff_read_control(struct wm_coeff_ctl *ctl, reg = ctl->alg_region.base + ctl->offset; reg =wm_adsp_region_to_reg (mem, reg); - scratch =kmalloc (ctl->len,GFP_KERNEL |GFP_DMA ); + scratch =kmalloc (len,GFP_KERNEL |GFP_DMA );if (!scratch)return -ENOMEM ; - ret =regmap_raw_read (dsp->regmap, reg, scratch, ctl->len); + ret =regmap_raw_read (dsp->regmap, reg, scratch, len);if (ret) {adsp_err (dsp,"Failed to read %zu bytes from %x: %d\n" , ctl->len, reg, ret);kfree (scratch);return ret; } -adsp_dbg (dsp,"Read %zu bytes from %x\n" , ctl->len, reg); +adsp_dbg (dsp,"Read %zu bytes from %x\n" , len, reg); -memcpy (buf, scratch, ctl->len); +memcpy (buf, scratch, len);kfree (scratch);return 0 ;
Signature · 1 line
2.1.4
Mark Brown
maintainerApplied "ASoC: wm_adsp: wm_coeff_{read|write}_control should use passed length" to the asoc tree
The patch
ASoC: wm_adsp: wm_coeff_{read|write}_control should use passed length
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
4f8ea6d759f6ed5d448472143cef7681e319c958Mon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Fri, 19 Feb 2016 14:44:44 +0000
Subject: [PATCH] ASoC: wm_adsp: wm_coeff_{read|write}_control should use
passed length
wm_coeff_{read|write}_control were using the control length rather than the length parameter passed to them. This is not causing any issues as the two values are currently always the same, but this needs fixed to allow future improvements.
--- sound/soc/codecs/wm_adsp.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
sound/soc/codecs/wm_adsp.c +8 -8
@@ -721,19 +721,19 @@ static int wm_coeff_write_control(struct wm_coeff_ctl *ctl, reg = ctl->alg_region.base + ctl->offset; reg =wm_adsp_region_to_reg (mem, reg); - scratch =kmemdup (buf, ctl->len,GFP_KERNEL |GFP_DMA ); + scratch =kmemdup (buf, len,GFP_KERNEL |GFP_DMA );if (!scratch)return -ENOMEM ; ret =regmap_raw_write (dsp->regmap, reg, scratch, - ctl->len); + len);if (ret) {adsp_err (dsp,"Failed to write %zu bytes to %x: %d\n" , - ctl->len, reg, ret); + len, reg, ret);kfree (scratch);return ret; } -adsp_dbg (dsp,"Wrote %zu bytes to %x\n" , ctl->len, reg); +adsp_dbg (dsp,"Wrote %zu bytes to %x\n" , len, reg);kfree (scratch);
@@ -780,20 +780,20 @@ static int wm_coeff_read_control(struct wm_coeff_ctl *ctl, reg = ctl->alg_region.base + ctl->offset; reg =wm_adsp_region_to_reg (mem, reg); - scratch =kmalloc (ctl->len,GFP_KERNEL |GFP_DMA ); + scratch =kmalloc (len,GFP_KERNEL |GFP_DMA );if (!scratch)return -ENOMEM ; - ret =regmap_raw_read (dsp->regmap, reg, scratch, ctl->len); + ret =regmap_raw_read (dsp->regmap, reg, scratch, len);if (ret) {adsp_err (dsp,"Failed to read %zu bytes from %x: %d\n" , ctl->len, reg, ret);kfree (scratch);return ret; } -adsp_dbg (dsp,"Read %zu bytes from %x\n" , ctl->len, reg); +adsp_dbg (dsp,"Read %zu bytes from %x\n" , len, reg); -memcpy (buf, scratch, ctl->len); +memcpy (buf, scratch, len);kfree (scratch);return 0 ;
Signature · 1 line
2.7.0
Mark Brown
maintainerApplied "ASoC: wm_adsp: Avoid narrow race condition on compr pointer" to the asoc tree
In reply to Charles KeepaxThe patch
ASoC: wm_adsp: Avoid narrow race condition on compr pointer
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
c7dae7c4c60693286298e300b3d140c8cff46daaMon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Fri, 19 Feb 2016 14:44:41 +0000
Subject: [PATCH] ASoC: wm_adsp: Avoid narrow race condition on compr pointer
There is a very small window between then wm_adsp_compr_free gets call and when the DSP is actually powered down. If we get an IRQ from the DSP in this window then the wm_adsp_compr pointer will be NULL. This patch adds a check for this into the IRQ handler to avoid any issues when this happens.
--- sound/soc/codecs/wm_adsp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm_adsp.c +1 -1
@@ -2845,7 +2845,7 @@ int wm_adsp_compr_handle_irq(struct wm_adsp *dsp) goto out; } -if (compr->stream) +if (compr && compr->stream)snd_compr_fragment_elapsed (compr->stream); out:
Signature · 1 line
2.7.0