ASoC: wm_adsp: Correct some missing locking
Subsystems (3)
PATCH 1/3 ASoC: wm_adsp: Correct some missing locking
The recent refactoring overlooked some places which should be covered by the pwr_lock, all code that affects or depends on the power status of the DSP should be covered, this patch adds the missing coverage.
--- sound/soc/codecs/wm_adsp.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
sound/soc/codecs/wm_adsp.c +12 -7
@@ -2575,6 +2575,8 @@ int wm_adsp2_early_event(struct snd_soc_dapm_widget *w,queue_work (system_unbound_wq, &dsp->boot_work);break ;case SND_SOC_DAPM_PRE_PMD : +mutex_lock (&dsp->pwr_lock); +wm_adsp_debugfs_clear (dsp); dsp->fw_id =0 ;
@@ -2590,6 +2592,8 @@ int wm_adsp2_early_event(struct snd_soc_dapm_widget *w,wm_adsp_free_alg_regions (dsp); +mutex_unlock (&dsp->pwr_lock); +adsp_dbg (dsp,"Shutdown complete\n" );break ;default :
@@ -2612,8 +2616,12 @@ int wm_adsp2_event(struct snd_soc_dapm_widget *w,case SND_SOC_DAPM_POST_PMU :flush_work (&dsp->boot_work); -if (!dsp->booted) -return -EIO ; +mutex_lock (&dsp->pwr_lock); + +if (!dsp->booted) { + ret = -EIO ; + goto err; + } ret =wm_adsp2_ena (dsp);if (ret !=0 )
@@ -2633,14 +2641,10 @@ int wm_adsp2_event(struct snd_soc_dapm_widget *w, dsp->running = true; -mutex_lock (&dsp->pwr_lock); -if (wm_adsp_fw[dsp->fw].num_caps !=0 ) { ret =wm_adsp_buffer_init (dsp); -if (ret <0 ) { -mutex_unlock (&dsp->pwr_lock); +if (ret <0 ) goto err; - } }mutex_unlock (&dsp->pwr_lock);
@@ -2685,6 +2689,7 @@ int wm_adsp2_event(struct snd_soc_dapm_widget *w, err:regmap_update_bits (dsp->regmap, dsp->base +ADSP2_CONTROL ,ADSP2_SYS_ENA |ADSP2_CORE_ENA |ADSP2_START ,0 ); +mutex_unlock (&dsp->pwr_lock);return ret; }EXPORT_SYMBOL_GPL (wm_adsp2_event);
Signature · 1 line
2.1.4
PATCH 2/3 ASoC: wm_adsp: Set booted/running flags at the end of bring up
The booted and running flags should really only be set once all the steps at that power level have been complete. Currently operations can fail after the flags have been set, which would leave us in an inconsistent state where the flags are set but the things expected to reach that level have not happened. Whilst there isn't really any major impact from this it is best to clean it up.
--- sound/soc/codecs/wm_adsp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/wm_adsp.c +4 -4
@@ -2492,14 +2492,14 @@ static void wm_adsp2_boot_work(struct work_struct *work)if (ret !=0 ) goto err_ena; - dsp->booted = true; -/* Turn DSP back off until we are ready to run */ ret =regmap_update_bits (dsp->regmap, dsp->base +ADSP2_CONTROL ,ADSP2_SYS_ENA ,0 );if (ret !=0 ) goto err_ena; + dsp->booted = true; +mutex_unlock (&dsp->pwr_lock);return ;
@@ -2639,14 +2639,14 @@ int wm_adsp2_event(struct snd_soc_dapm_widget *w,if (ret !=0 ) goto err; - dsp->running = true; -if (wm_adsp_fw[dsp->fw].num_caps !=0 ) { ret =wm_adsp_buffer_init (dsp);if (ret <0 ) goto err; } + dsp->running = true; +mutex_unlock (&dsp->pwr_lock);break ;
Signature · 1 line
2.1.4
Mark Brown
maintainerApplied "ASoC: wm_adsp: Set booted/running flags at the end of bring up" to the asoc tree
The patch
ASoC: wm_adsp: Set booted/running flags at the end of bring up
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
e779974b86491cc938dfdcbfbf8fb363a40bc9eaMon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Tue, 24 Jan 2017 11:44:00 +0000
Subject: [PATCH] ASoC: wm_adsp: Set booted/running flags at the end of bring
up
The booted and running flags should really only be set once all the steps at that power level have been complete. Currently operations can fail after the flags have been set, which would leave us in an inconsistent state where the flags are set but the things expected to reach that level have not happened. Whilst there isn't really any major impact from this it is best to clean it up.
--- sound/soc/codecs/wm_adsp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/wm_adsp.c +4 -4
@@ -2469,14 +2469,14 @@ static void wm_adsp2_boot_work(struct work_struct *work)if (ret !=0 ) goto err_ena; - dsp->booted = true; -/* Turn DSP back off until we are ready to run */ ret =regmap_update_bits (dsp->regmap, dsp->base +ADSP2_CONTROL ,ADSP2_SYS_ENA ,0 );if (ret !=0 ) goto err_ena; + dsp->booted = true; +mutex_unlock (&dsp->pwr_lock);return ;
@@ -2616,14 +2616,14 @@ int wm_adsp2_event(struct snd_soc_dapm_widget *w,if (ret !=0 ) goto err; - dsp->running = true; -if (wm_adsp_fw[dsp->fw].num_caps !=0 ) { ret =wm_adsp_buffer_init (dsp);if (ret <0 ) goto err; } + dsp->running = true; +mutex_unlock (&dsp->pwr_lock);break ;
Signature · 1 line
2.11.0
PATCH 3/3 ASoC: wm_adsp: Fixup wm_adsp2_boot_work error paths
In reply to Charles KeepaxCurrently we are not disabling MEM_ENA on the error path, we should really do this to unwind the state back to how it was. This patch adds a clear of MEM_ENA on the error path, again there is no major issues caused by this minor fix.
--- sound/soc/codecs/wm_adsp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
sound/soc/codecs/wm_adsp.c +4 -1
@@ -2473,7 +2473,7 @@ static void wm_adsp2_boot_work(struct work_struct *work) ret =wm_adsp2_ena (dsp);if (ret !=0 ) - goto err_mutex; + goto err_mem; ret =wm_adsp_load (dsp);if (ret !=0 )
@@ -2507,6 +2507,9 @@ static void wm_adsp2_boot_work(struct work_struct *work) err_ena:regmap_update_bits (dsp->regmap, dsp->base +ADSP2_CONTROL ,ADSP2_SYS_ENA |ADSP2_CORE_ENA |ADSP2_START ,0 ); +err_mem: +regmap_update_bits (dsp->regmap, dsp->base +ADSP2_CONTROL , +ADSP2_MEM_ENA ,0 ); err_mutex:mutex_unlock (&dsp->pwr_lock); }
Signature · 1 line
2.1.4
Mark Brown
maintainerApplied "ASoC: wm_adsp: Fixup wm_adsp2_boot_work error paths" to the asoc tree
The patch
ASoC: wm_adsp: Fixup wm_adsp2_boot_work error paths
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
d589d8b83503c1f153965f4c2747349ccca6995eMon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Tue, 24 Jan 2017 11:44:01 +0000
Subject: [PATCH] ASoC: wm_adsp: Fixup wm_adsp2_boot_work error paths
Currently we are not disabling MEM_ENA on the error path, we should really do this to unwind the state back to how it was. This patch adds a clear of MEM_ENA on the error path, again there is no major issues caused by this minor fix.
--- sound/soc/codecs/wm_adsp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
sound/soc/codecs/wm_adsp.c +4 -1
@@ -2450,7 +2450,7 @@ static void wm_adsp2_boot_work(struct work_struct *work) ret =wm_adsp2_ena (dsp);if (ret !=0 ) - goto err_mutex; + goto err_mem; ret =wm_adsp_load (dsp);if (ret !=0 )
@@ -2484,6 +2484,9 @@ static void wm_adsp2_boot_work(struct work_struct *work) err_ena:regmap_update_bits (dsp->regmap, dsp->base +ADSP2_CONTROL ,ADSP2_SYS_ENA |ADSP2_CORE_ENA |ADSP2_START ,0 ); +err_mem: +regmap_update_bits (dsp->regmap, dsp->base +ADSP2_CONTROL , +ADSP2_MEM_ENA ,0 ); err_mutex:mutex_unlock (&dsp->pwr_lock); }
Signature · 1 line
2.11.0
Mark Brown
maintainerApplied "ASoC: wm_adsp: Correct some missing locking" to the asoc tree
In reply to Charles KeepaxThe patch
ASoC: wm_adsp: Correct some missing locking
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
bb24ee411ae949eaffe24c6be2b3d87f271507b5Mon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Tue, 24 Jan 2017 11:43:59 +0000
Subject: [PATCH] ASoC: wm_adsp: Correct some missing locking
The recent refactoring overlooked some places which should be covered by the pwr_lock, all code that affects or depends on the power status of the DSP should be covered, this patch adds the missing coverage.
--- sound/soc/codecs/wm_adsp.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
sound/soc/codecs/wm_adsp.c +12 -7
@@ -2552,6 +2552,8 @@ int wm_adsp2_early_event(struct snd_soc_dapm_widget *w,queue_work (system_unbound_wq, &dsp->boot_work);break ;case SND_SOC_DAPM_PRE_PMD : +mutex_lock (&dsp->pwr_lock); +wm_adsp_debugfs_clear (dsp); dsp->fw_id =0 ;
@@ -2567,6 +2569,8 @@ int wm_adsp2_early_event(struct snd_soc_dapm_widget *w,wm_adsp_free_alg_regions (dsp); +mutex_unlock (&dsp->pwr_lock); +adsp_dbg (dsp,"Shutdown complete\n" );break ;default :
@@ -2589,8 +2593,12 @@ int wm_adsp2_event(struct snd_soc_dapm_widget *w,case SND_SOC_DAPM_POST_PMU :flush_work (&dsp->boot_work); -if (!dsp->booted) -return -EIO ; +mutex_lock (&dsp->pwr_lock); + +if (!dsp->booted) { + ret = -EIO ; + goto err; + } ret =wm_adsp2_ena (dsp);if (ret !=0 )
@@ -2610,14 +2618,10 @@ int wm_adsp2_event(struct snd_soc_dapm_widget *w, dsp->running = true; -mutex_lock (&dsp->pwr_lock); -if (wm_adsp_fw[dsp->fw].num_caps !=0 ) { ret =wm_adsp_buffer_init (dsp); -if (ret <0 ) { -mutex_unlock (&dsp->pwr_lock); +if (ret <0 ) goto err; - } }mutex_unlock (&dsp->pwr_lock);
@@ -2662,6 +2666,7 @@ int wm_adsp2_event(struct snd_soc_dapm_widget *w, err:regmap_update_bits (dsp->regmap, dsp->base +ADSP2_CONTROL ,ADSP2_SYS_ENA |ADSP2_CORE_ENA |ADSP2_START ,0 ); +mutex_unlock (&dsp->pwr_lock);return ret; }EXPORT_SYMBOL_GPL (wm_adsp2_event);
Signature · 1 line
2.11.0