diff options
author | Charles Keepax <ckeepax@opensource.wolfsonmicro.com> | 2017-01-24 06:43:59 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2017-01-24 07:14:36 -0500 |
commit | bb24ee411ae949eaffe24c6be2b3d87f271507b5 (patch) | |
tree | 7a4fc04c3c8b9bb511ac792763a22a46dcabb746 | |
parent | af813a6fd8740537bfa5801768e90cc95d9262a3 (diff) |
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>
-rw-r--r-- | sound/soc/codecs/wm_adsp.c | 19 |
1 files 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, | |||
2552 | queue_work(system_unbound_wq, &dsp->boot_work); | 2552 | queue_work(system_unbound_wq, &dsp->boot_work); |
2553 | break; | 2553 | break; |
2554 | case SND_SOC_DAPM_PRE_PMD: | 2554 | case SND_SOC_DAPM_PRE_PMD: |
2555 | mutex_lock(&dsp->pwr_lock); | ||
2556 | |||
2555 | wm_adsp_debugfs_clear(dsp); | 2557 | wm_adsp_debugfs_clear(dsp); |
2556 | 2558 | ||
2557 | dsp->fw_id = 0; | 2559 | dsp->fw_id = 0; |
@@ -2567,6 +2569,8 @@ int wm_adsp2_early_event(struct snd_soc_dapm_widget *w, | |||
2567 | 2569 | ||
2568 | wm_adsp_free_alg_regions(dsp); | 2570 | wm_adsp_free_alg_regions(dsp); |
2569 | 2571 | ||
2572 | mutex_unlock(&dsp->pwr_lock); | ||
2573 | |||
2570 | adsp_dbg(dsp, "Shutdown complete\n"); | 2574 | adsp_dbg(dsp, "Shutdown complete\n"); |
2571 | break; | 2575 | break; |
2572 | default: | 2576 | default: |
@@ -2589,8 +2593,12 @@ int wm_adsp2_event(struct snd_soc_dapm_widget *w, | |||
2589 | case SND_SOC_DAPM_POST_PMU: | 2593 | case SND_SOC_DAPM_POST_PMU: |
2590 | flush_work(&dsp->boot_work); | 2594 | flush_work(&dsp->boot_work); |
2591 | 2595 | ||
2592 | if (!dsp->booted) | 2596 | mutex_lock(&dsp->pwr_lock); |
2593 | return -EIO; | 2597 | |
2598 | if (!dsp->booted) { | ||
2599 | ret = -EIO; | ||
2600 | goto err; | ||
2601 | } | ||
2594 | 2602 | ||
2595 | ret = wm_adsp2_ena(dsp); | 2603 | ret = wm_adsp2_ena(dsp); |
2596 | if (ret != 0) | 2604 | if (ret != 0) |
@@ -2610,14 +2618,10 @@ int wm_adsp2_event(struct snd_soc_dapm_widget *w, | |||
2610 | 2618 | ||
2611 | dsp->running = true; | 2619 | dsp->running = true; |
2612 | 2620 | ||
2613 | mutex_lock(&dsp->pwr_lock); | ||
2614 | |||
2615 | if (wm_adsp_fw[dsp->fw].num_caps != 0) { | 2621 | if (wm_adsp_fw[dsp->fw].num_caps != 0) { |
2616 | ret = wm_adsp_buffer_init(dsp); | 2622 | ret = wm_adsp_buffer_init(dsp); |
2617 | if (ret < 0) { | 2623 | if (ret < 0) |
2618 | mutex_unlock(&dsp->pwr_lock); | ||
2619 | goto err; | 2624 | goto err; |
2620 | } | ||
2621 | } | 2625 | } |
2622 | 2626 | ||
2623 | mutex_unlock(&dsp->pwr_lock); | 2627 | mutex_unlock(&dsp->pwr_lock); |
@@ -2662,6 +2666,7 @@ int wm_adsp2_event(struct snd_soc_dapm_widget *w, | |||
2662 | err: | 2666 | err: |
2663 | regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, | 2667 | regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, |
2664 | ADSP2_SYS_ENA | ADSP2_CORE_ENA | ADSP2_START, 0); | 2668 | ADSP2_SYS_ENA | ADSP2_CORE_ENA | ADSP2_START, 0); |
2669 | mutex_unlock(&dsp->pwr_lock); | ||
2665 | return ret; | 2670 | return ret; |
2666 | } | 2671 | } |
2667 | EXPORT_SYMBOL_GPL(wm_adsp2_event); | 2672 | EXPORT_SYMBOL_GPL(wm_adsp2_event); |