* [PATCH 1/3] ASoC: wm_adsp: Correct some missing locking
@ 2017-01-24 11:43 Charles Keepax
2017-01-24 11:44 ` [PATCH 2/3] ASoC: wm_adsp: Set booted/running flags at the end of bring up Charles Keepax
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Charles Keepax @ 2017-01-24 11:43 UTC (permalink / raw)
To: broonie; +Cc: alsa-devel, patches, lgirdwood
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.
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
sound/soc/codecs/wm_adsp.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index 73dbe4c..08a4a61 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -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);
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] ASoC: wm_adsp: Set booted/running flags at the end of bring up
2017-01-24 11:43 [PATCH 1/3] ASoC: wm_adsp: Correct some missing locking Charles Keepax
@ 2017-01-24 11:44 ` Charles Keepax
2017-01-24 18:39 ` Applied "ASoC: wm_adsp: Set booted/running flags at the end of bring up" to the asoc tree Mark Brown
2017-01-24 11:44 ` [PATCH 3/3] ASoC: wm_adsp: Fixup wm_adsp2_boot_work error paths Charles Keepax
2017-01-24 18:39 ` Applied "ASoC: wm_adsp: Correct some missing locking" " Mark Brown
2 siblings, 1 reply; 6+ messages in thread
From: Charles Keepax @ 2017-01-24 11:44 UTC (permalink / raw)
To: broonie; +Cc: alsa-devel, patches, lgirdwood
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.
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
sound/soc/codecs/wm_adsp.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index 08a4a61..822dfef 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -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;
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] ASoC: wm_adsp: Fixup wm_adsp2_boot_work error paths
2017-01-24 11:43 [PATCH 1/3] ASoC: wm_adsp: Correct some missing locking Charles Keepax
2017-01-24 11:44 ` [PATCH 2/3] ASoC: wm_adsp: Set booted/running flags at the end of bring up Charles Keepax
@ 2017-01-24 11:44 ` Charles Keepax
2017-01-24 18:39 ` Applied "ASoC: wm_adsp: Fixup wm_adsp2_boot_work error paths" to the asoc tree Mark Brown
2017-01-24 18:39 ` Applied "ASoC: wm_adsp: Correct some missing locking" " Mark Brown
2 siblings, 1 reply; 6+ messages in thread
From: Charles Keepax @ 2017-01-24 11:44 UTC (permalink / raw)
To: broonie; +Cc: alsa-devel, patches, lgirdwood
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.
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
sound/soc/codecs/wm_adsp.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index 822dfef..d151224 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -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);
}
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Applied "ASoC: wm_adsp: Fixup wm_adsp2_boot_work error paths" to the asoc tree
2017-01-24 11:44 ` [PATCH 3/3] ASoC: wm_adsp: Fixup wm_adsp2_boot_work error paths Charles Keepax
@ 2017-01-24 18:39 ` Mark Brown
0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2017-01-24 18:39 UTC (permalink / raw)
To: Charles Keepax; +Cc: alsa-devel, broonie, patches, lgirdwood
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
>From d589d8b83503c1f153965f4c2747349ccca6995e Mon Sep 17 00:00:00 2001
From: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
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.
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
sound/soc/codecs/wm_adsp.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index 746a5e23cb8b..651857b529f9 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -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);
}
--
2.11.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Applied "ASoC: wm_adsp: Set booted/running flags at the end of bring up" to the asoc tree
2017-01-24 11:44 ` [PATCH 2/3] ASoC: wm_adsp: Set booted/running flags at the end of bring up Charles Keepax
@ 2017-01-24 18:39 ` Mark Brown
0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2017-01-24 18:39 UTC (permalink / raw)
To: Charles Keepax; +Cc: alsa-devel, broonie, patches, lgirdwood
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
>From e779974b86491cc938dfdcbfbf8fb363a40bc9ea Mon Sep 17 00:00:00 2001
From: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
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.
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
sound/soc/codecs/wm_adsp.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index 09e50e5e7870..746a5e23cb8b 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -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;
--
2.11.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Applied "ASoC: wm_adsp: Correct some missing locking" to the asoc tree
2017-01-24 11:43 [PATCH 1/3] ASoC: wm_adsp: Correct some missing locking Charles Keepax
2017-01-24 11:44 ` [PATCH 2/3] ASoC: wm_adsp: Set booted/running flags at the end of bring up Charles Keepax
2017-01-24 11:44 ` [PATCH 3/3] ASoC: wm_adsp: Fixup wm_adsp2_boot_work error paths Charles Keepax
@ 2017-01-24 18:39 ` Mark Brown
2 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2017-01-24 18:39 UTC (permalink / raw)
To: Charles Keepax; +Cc: alsa-devel, broonie, patches, lgirdwood
The 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
>From bb24ee411ae949eaffe24c6be2b3d87f271507b5 Mon Sep 17 00:00:00 2001
From: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
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.
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
sound/soc/codecs/wm_adsp.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index ed615ce8a496..09e50e5e7870 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -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);
--
2.11.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-01-24 18:39 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-24 11:43 [PATCH 1/3] ASoC: wm_adsp: Correct some missing locking Charles Keepax
2017-01-24 11:44 ` [PATCH 2/3] ASoC: wm_adsp: Set booted/running flags at the end of bring up Charles Keepax
2017-01-24 18:39 ` Applied "ASoC: wm_adsp: Set booted/running flags at the end of bring up" to the asoc tree Mark Brown
2017-01-24 11:44 ` [PATCH 3/3] ASoC: wm_adsp: Fixup wm_adsp2_boot_work error paths Charles Keepax
2017-01-24 18:39 ` Applied "ASoC: wm_adsp: Fixup wm_adsp2_boot_work error paths" to the asoc tree Mark Brown
2017-01-24 18:39 ` Applied "ASoC: wm_adsp: Correct some missing locking" " Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).