Commit b7898396 authored by Takashi Iwai's avatar Takashi Iwai Committed by Mark Brown

ASoC: soc-pcm: Fix and cleanup DPCM locking

The existing locking for DPCM has several issues
a) a confusing mix of card->mutex and card->pcm_mutex.
b) a dpcm_lock spinlock added inconsistently and on paths that could
be recursively taken. The use of irqsave/irqrestore was also overkill.

The suggested model is:

1) The pcm_mutex is the top-most protection of BE links in the FE. The
pcm_mutex is applied always on either the top PCM callbacks or the
external call from DAPM, not taken in the internal functions.

2) the FE stream lock is taken in higher levels before invoking
dpcm_be_dai_trigger()

3) when adding and deleting a BE, both the pcm_mutex and FE stream
lock are taken.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
[clarification of commit message by plbossart]
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarKai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20211207173745.15850-4-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent bbf7d3b1
...@@ -893,8 +893,6 @@ struct snd_soc_card { ...@@ -893,8 +893,6 @@ struct snd_soc_card {
struct mutex pcm_mutex; struct mutex pcm_mutex;
enum snd_soc_pcm_subclass pcm_subclass; enum snd_soc_pcm_subclass pcm_subclass;
spinlock_t dpcm_lock;
int (*probe)(struct snd_soc_card *card); int (*probe)(struct snd_soc_card *card);
int (*late_probe)(struct snd_soc_card *card); int (*late_probe)(struct snd_soc_card *card);
int (*remove)(struct snd_soc_card *card); int (*remove)(struct snd_soc_card *card);
......
...@@ -2315,7 +2315,6 @@ int snd_soc_register_card(struct snd_soc_card *card) ...@@ -2315,7 +2315,6 @@ int snd_soc_register_card(struct snd_soc_card *card)
mutex_init(&card->mutex); mutex_init(&card->mutex);
mutex_init(&card->dapm_mutex); mutex_init(&card->dapm_mutex);
mutex_init(&card->pcm_mutex); mutex_init(&card->pcm_mutex);
spin_lock_init(&card->dpcm_lock);
return snd_soc_bind_card(card); return snd_soc_bind_card(card);
} }
......
...@@ -27,6 +27,31 @@ ...@@ -27,6 +27,31 @@
#include <sound/soc-link.h> #include <sound/soc-link.h>
#include <sound/initval.h> #include <sound/initval.h>
static inline void snd_soc_dpcm_mutex_lock(struct snd_soc_pcm_runtime *rtd)
{
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
}
static inline void snd_soc_dpcm_mutex_unlock(struct snd_soc_pcm_runtime *rtd)
{
mutex_unlock(&rtd->card->pcm_mutex);
}
#define snd_soc_dpcm_mutex_assert_held(rtd) \
lockdep_assert_held(&(rtd)->card->pcm_mutex)
static inline void snd_soc_dpcm_stream_lock_irq(struct snd_soc_pcm_runtime *rtd,
int stream)
{
snd_pcm_stream_lock_irq(snd_soc_dpcm_get_substream(rtd, stream));
}
static inline void snd_soc_dpcm_stream_unlock_irq(struct snd_soc_pcm_runtime *rtd,
int stream)
{
snd_pcm_stream_unlock_irq(snd_soc_dpcm_get_substream(rtd, stream));
}
#define DPCM_MAX_BE_USERS 8 #define DPCM_MAX_BE_USERS 8
static inline const char *soc_cpu_dai_name(struct snd_soc_pcm_runtime *rtd) static inline const char *soc_cpu_dai_name(struct snd_soc_pcm_runtime *rtd)
...@@ -73,7 +98,6 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe, ...@@ -73,7 +98,6 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe,
struct snd_pcm_hw_params *params = &fe->dpcm[stream].hw_params; struct snd_pcm_hw_params *params = &fe->dpcm[stream].hw_params;
struct snd_soc_dpcm *dpcm; struct snd_soc_dpcm *dpcm;
ssize_t offset = 0; ssize_t offset = 0;
unsigned long flags;
/* FE state */ /* FE state */
offset += scnprintf(buf + offset, size - offset, offset += scnprintf(buf + offset, size - offset,
...@@ -101,7 +125,6 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe, ...@@ -101,7 +125,6 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe,
goto out; goto out;
} }
spin_lock_irqsave(&fe->card->dpcm_lock, flags);
for_each_dpcm_be(fe, stream, dpcm) { for_each_dpcm_be(fe, stream, dpcm) {
struct snd_soc_pcm_runtime *be = dpcm->be; struct snd_soc_pcm_runtime *be = dpcm->be;
params = &dpcm->hw_params; params = &dpcm->hw_params;
...@@ -122,7 +145,6 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe, ...@@ -122,7 +145,6 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe,
params_channels(params), params_channels(params),
params_rate(params)); params_rate(params));
} }
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
out: out:
return offset; return offset;
} }
...@@ -145,11 +167,13 @@ static ssize_t dpcm_state_read_file(struct file *file, char __user *user_buf, ...@@ -145,11 +167,13 @@ static ssize_t dpcm_state_read_file(struct file *file, char __user *user_buf,
if (!buf) if (!buf)
return -ENOMEM; return -ENOMEM;
snd_soc_dpcm_mutex_lock(fe);
for_each_pcm_streams(stream) for_each_pcm_streams(stream)
if (snd_soc_dai_stream_valid(asoc_rtd_to_cpu(fe, 0), stream)) if (snd_soc_dai_stream_valid(asoc_rtd_to_cpu(fe, 0), stream))
offset += dpcm_show_state(fe, stream, offset += dpcm_show_state(fe, stream,
buf + offset, buf + offset,
out_count - offset); out_count - offset);
snd_soc_dpcm_mutex_unlock(fe);
ret = simple_read_from_buffer(user_buf, count, ppos, buf, offset); ret = simple_read_from_buffer(user_buf, count, ppos, buf, offset);
...@@ -221,14 +245,14 @@ static void dpcm_set_fe_update_state(struct snd_soc_pcm_runtime *fe, ...@@ -221,14 +245,14 @@ static void dpcm_set_fe_update_state(struct snd_soc_pcm_runtime *fe,
struct snd_pcm_substream *substream = struct snd_pcm_substream *substream =
snd_soc_dpcm_get_substream(fe, stream); snd_soc_dpcm_get_substream(fe, stream);
snd_pcm_stream_lock_irq(substream); snd_soc_dpcm_stream_lock_irq(fe, stream);
if (state == SND_SOC_DPCM_UPDATE_NO && fe->dpcm[stream].trigger_pending) { if (state == SND_SOC_DPCM_UPDATE_NO && fe->dpcm[stream].trigger_pending) {
dpcm_fe_dai_do_trigger(substream, dpcm_fe_dai_do_trigger(substream,
fe->dpcm[stream].trigger_pending - 1); fe->dpcm[stream].trigger_pending - 1);
fe->dpcm[stream].trigger_pending = 0; fe->dpcm[stream].trigger_pending = 0;
} }
fe->dpcm[stream].runtime_update = state; fe->dpcm[stream].runtime_update = state;
snd_pcm_stream_unlock_irq(substream); snd_soc_dpcm_stream_unlock_irq(fe, stream);
} }
static void dpcm_set_be_update_state(struct snd_soc_pcm_runtime *be, static void dpcm_set_be_update_state(struct snd_soc_pcm_runtime *be,
...@@ -256,7 +280,7 @@ void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd, ...@@ -256,7 +280,7 @@ void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
struct snd_soc_dai *dai; struct snd_soc_dai *dai;
int i; int i;
lockdep_assert_held(&rtd->card->pcm_mutex); snd_soc_dpcm_mutex_assert_held(rtd);
for_each_rtd_dais(rtd, i, dai) for_each_rtd_dais(rtd, i, dai)
snd_soc_dai_action(dai, stream, action); snd_soc_dai_action(dai, stream, action);
...@@ -309,6 +333,8 @@ int dpcm_dapm_stream_event(struct snd_soc_pcm_runtime *fe, int dir, ...@@ -309,6 +333,8 @@ int dpcm_dapm_stream_event(struct snd_soc_pcm_runtime *fe, int dir,
{ {
struct snd_soc_dpcm *dpcm; struct snd_soc_dpcm *dpcm;
snd_soc_dpcm_mutex_assert_held(fe);
for_each_dpcm_be(fe, dir, dpcm) { for_each_dpcm_be(fe, dir, dpcm) {
struct snd_soc_pcm_runtime *be = dpcm->be; struct snd_soc_pcm_runtime *be = dpcm->be;
...@@ -646,14 +672,14 @@ static int soc_pcm_components_close(struct snd_pcm_substream *substream, ...@@ -646,14 +672,14 @@ static int soc_pcm_components_close(struct snd_pcm_substream *substream,
return ret; return ret;
} }
static int soc_pcm_clean(struct snd_pcm_substream *substream, int rollback) static int soc_pcm_clean(struct snd_soc_pcm_runtime *rtd,
struct snd_pcm_substream *substream, int rollback)
{ {
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
struct snd_soc_component *component; struct snd_soc_component *component;
struct snd_soc_dai *dai; struct snd_soc_dai *dai;
int i; int i;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); snd_soc_dpcm_mutex_assert_held(rtd);
if (!rollback) if (!rollback)
snd_soc_runtime_deactivate(rtd, substream->stream); snd_soc_runtime_deactivate(rtd, substream->stream);
...@@ -665,9 +691,6 @@ static int soc_pcm_clean(struct snd_pcm_substream *substream, int rollback) ...@@ -665,9 +691,6 @@ static int soc_pcm_clean(struct snd_pcm_substream *substream, int rollback)
soc_pcm_components_close(substream, rollback); soc_pcm_components_close(substream, rollback);
mutex_unlock(&rtd->card->pcm_mutex);
snd_soc_pcm_component_pm_runtime_put(rtd, substream, rollback); snd_soc_pcm_component_pm_runtime_put(rtd, substream, rollback);
for_each_rtd_components(rtd, i, component) for_each_rtd_components(rtd, i, component)
...@@ -682,9 +705,21 @@ static int soc_pcm_clean(struct snd_pcm_substream *substream, int rollback) ...@@ -682,9 +705,21 @@ static int soc_pcm_clean(struct snd_pcm_substream *substream, int rollback)
* freed here. The cpu DAI, codec DAI, machine and components are also * freed here. The cpu DAI, codec DAI, machine and components are also
* shutdown. * shutdown.
*/ */
static int __soc_pcm_close(struct snd_soc_pcm_runtime *rtd,
struct snd_pcm_substream *substream)
{
return soc_pcm_clean(rtd, substream, 0);
}
/* PCM close ops for non-DPCM streams */
static int soc_pcm_close(struct snd_pcm_substream *substream) static int soc_pcm_close(struct snd_pcm_substream *substream)
{ {
return soc_pcm_clean(substream, 0); struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
snd_soc_dpcm_mutex_lock(rtd);
soc_pcm_clean(rtd, substream, 0);
snd_soc_dpcm_mutex_unlock(rtd);
return 0;
} }
static int soc_hw_sanity_check(struct snd_pcm_substream *substream) static int soc_hw_sanity_check(struct snd_pcm_substream *substream)
...@@ -730,21 +765,21 @@ static int soc_hw_sanity_check(struct snd_pcm_substream *substream) ...@@ -730,21 +765,21 @@ static int soc_hw_sanity_check(struct snd_pcm_substream *substream)
* then initialized and any private data can be allocated. This also calls * then initialized and any private data can be allocated. This also calls
* startup for the cpu DAI, component, machine and codec DAI. * startup for the cpu DAI, component, machine and codec DAI.
*/ */
static int soc_pcm_open(struct snd_pcm_substream *substream) static int __soc_pcm_open(struct snd_soc_pcm_runtime *rtd,
struct snd_pcm_substream *substream)
{ {
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
struct snd_soc_component *component; struct snd_soc_component *component;
struct snd_soc_dai *dai; struct snd_soc_dai *dai;
int i, ret = 0; int i, ret = 0;
snd_soc_dpcm_mutex_assert_held(rtd);
for_each_rtd_components(rtd, i, component) for_each_rtd_components(rtd, i, component)
pinctrl_pm_select_default_state(component->dev); pinctrl_pm_select_default_state(component->dev);
ret = snd_soc_pcm_component_pm_runtime_get(rtd, substream); ret = snd_soc_pcm_component_pm_runtime_get(rtd, substream);
if (ret < 0) if (ret < 0)
goto pm_err; goto err;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
ret = soc_pcm_components_open(substream); ret = soc_pcm_components_open(substream);
if (ret < 0) if (ret < 0)
...@@ -791,16 +826,26 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) ...@@ -791,16 +826,26 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
snd_soc_runtime_activate(rtd, substream->stream); snd_soc_runtime_activate(rtd, substream->stream);
ret = 0; ret = 0;
err: err:
mutex_unlock(&rtd->card->pcm_mutex);
pm_err:
if (ret < 0) { if (ret < 0) {
soc_pcm_clean(substream, 1); soc_pcm_clean(rtd, substream, 1);
dev_err(rtd->dev, "%s() failed (%d)", __func__, ret); dev_err(rtd->dev, "%s() failed (%d)", __func__, ret);
} }
return ret; return ret;
} }
/* PCM open ops for non-DPCM streams */
static int soc_pcm_open(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
int ret;
snd_soc_dpcm_mutex_lock(rtd);
ret = __soc_pcm_open(rtd, substream);
snd_soc_dpcm_mutex_unlock(rtd);
return ret;
}
static void codec2codec_close_delayed_work(struct snd_soc_pcm_runtime *rtd) static void codec2codec_close_delayed_work(struct snd_soc_pcm_runtime *rtd)
{ {
/* /*
...@@ -816,13 +861,13 @@ static void codec2codec_close_delayed_work(struct snd_soc_pcm_runtime *rtd) ...@@ -816,13 +861,13 @@ static void codec2codec_close_delayed_work(struct snd_soc_pcm_runtime *rtd)
* rate, etc. This function is non atomic and can be called multiple times, * rate, etc. This function is non atomic and can be called multiple times,
* it can refer to the runtime info. * it can refer to the runtime info.
*/ */
static int soc_pcm_prepare(struct snd_pcm_substream *substream) static int __soc_pcm_prepare(struct snd_soc_pcm_runtime *rtd,
struct snd_pcm_substream *substream)
{ {
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
struct snd_soc_dai *dai; struct snd_soc_dai *dai;
int i, ret = 0; int i, ret = 0;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); snd_soc_dpcm_mutex_assert_held(rtd);
ret = snd_soc_link_prepare(substream); ret = snd_soc_link_prepare(substream);
if (ret < 0) if (ret < 0)
...@@ -850,14 +895,24 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) ...@@ -850,14 +895,24 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
snd_soc_dai_digital_mute(dai, 0, substream->stream); snd_soc_dai_digital_mute(dai, 0, substream->stream);
out: out:
mutex_unlock(&rtd->card->pcm_mutex);
if (ret < 0) if (ret < 0)
dev_err(rtd->dev, "ASoC: %s() failed (%d)\n", __func__, ret); dev_err(rtd->dev, "ASoC: %s() failed (%d)\n", __func__, ret);
return ret; return ret;
} }
/* PCM prepare ops for non-DPCM streams */
static int soc_pcm_prepare(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
int ret;
snd_soc_dpcm_mutex_lock(rtd);
ret = __soc_pcm_prepare(rtd, substream);
snd_soc_dpcm_mutex_unlock(rtd);
return ret;
}
static void soc_pcm_codec_params_fixup(struct snd_pcm_hw_params *params, static void soc_pcm_codec_params_fixup(struct snd_pcm_hw_params *params,
unsigned int mask) unsigned int mask)
{ {
...@@ -869,13 +924,13 @@ static void soc_pcm_codec_params_fixup(struct snd_pcm_hw_params *params, ...@@ -869,13 +924,13 @@ static void soc_pcm_codec_params_fixup(struct snd_pcm_hw_params *params,
interval->max = channels; interval->max = channels;
} }
static int soc_pcm_hw_clean(struct snd_pcm_substream *substream, int rollback) static int soc_pcm_hw_clean(struct snd_soc_pcm_runtime *rtd,
struct snd_pcm_substream *substream, int rollback)
{ {
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
struct snd_soc_dai *dai; struct snd_soc_dai *dai;
int i; int i;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); snd_soc_dpcm_mutex_assert_held(rtd);
/* clear the corresponding DAIs parameters when going to be inactive */ /* clear the corresponding DAIs parameters when going to be inactive */
for_each_rtd_dais(rtd, i, dai) { for_each_rtd_dais(rtd, i, dai) {
...@@ -900,16 +955,28 @@ static int soc_pcm_hw_clean(struct snd_pcm_substream *substream, int rollback) ...@@ -900,16 +955,28 @@ static int soc_pcm_hw_clean(struct snd_pcm_substream *substream, int rollback)
if (snd_soc_dai_stream_valid(dai, substream->stream)) if (snd_soc_dai_stream_valid(dai, substream->stream))
snd_soc_dai_hw_free(dai, substream, rollback); snd_soc_dai_hw_free(dai, substream, rollback);
mutex_unlock(&rtd->card->pcm_mutex);
return 0; return 0;
} }
/* /*
* Frees resources allocated by hw_params, can be called multiple times * Frees resources allocated by hw_params, can be called multiple times
*/ */
static int __soc_pcm_hw_free(struct snd_soc_pcm_runtime *rtd,
struct snd_pcm_substream *substream)
{
return soc_pcm_hw_clean(rtd, substream, 0);
}
/* hw_free PCM ops for non-DPCM streams */
static int soc_pcm_hw_free(struct snd_pcm_substream *substream) static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
{ {
return soc_pcm_hw_clean(substream, 0); struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
int ret;
snd_soc_dpcm_mutex_lock(rtd);
ret = __soc_pcm_hw_free(rtd, substream);
snd_soc_dpcm_mutex_unlock(rtd);
return ret;
} }
/* /*
...@@ -917,15 +984,15 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream) ...@@ -917,15 +984,15 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
* function can also be called multiple times and can allocate buffers * function can also be called multiple times and can allocate buffers
* (using snd_pcm_lib_* ). It's non-atomic. * (using snd_pcm_lib_* ). It's non-atomic.
*/ */
static int soc_pcm_hw_params(struct snd_pcm_substream *substream, static int __soc_pcm_hw_params(struct snd_soc_pcm_runtime *rtd,
struct snd_pcm_hw_params *params) struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{ {
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
struct snd_soc_dai *cpu_dai; struct snd_soc_dai *cpu_dai;
struct snd_soc_dai *codec_dai; struct snd_soc_dai *codec_dai;
int i, ret = 0; int i, ret = 0;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); snd_soc_dpcm_mutex_assert_held(rtd);
ret = soc_pcm_params_symmetry(substream, params); ret = soc_pcm_params_symmetry(substream, params);
if (ret) if (ret)
...@@ -997,16 +1064,27 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -997,16 +1064,27 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
ret = snd_soc_pcm_component_hw_params(substream, params); ret = snd_soc_pcm_component_hw_params(substream, params);
out: out:
mutex_unlock(&rtd->card->pcm_mutex);
if (ret < 0) { if (ret < 0) {
soc_pcm_hw_clean(substream, 1); soc_pcm_hw_clean(rtd, substream, 1);
dev_err(rtd->dev, "ASoC: %s() failed (%d)\n", __func__, ret); dev_err(rtd->dev, "ASoC: %s() failed (%d)\n", __func__, ret);
} }
return ret; return ret;
} }
/* hw_params PCM ops for non-DPCM streams */
static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
int ret;
snd_soc_dpcm_mutex_lock(rtd);
ret = __soc_pcm_hw_params(rtd, substream, params);
snd_soc_dpcm_mutex_unlock(rtd);
return ret;
}
static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd) static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
{ {
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
...@@ -1107,7 +1185,8 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe, ...@@ -1107,7 +1185,8 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe,
struct snd_pcm_substream *fe_substream; struct snd_pcm_substream *fe_substream;
struct snd_pcm_substream *be_substream; struct snd_pcm_substream *be_substream;
struct snd_soc_dpcm *dpcm; struct snd_soc_dpcm *dpcm;
unsigned long flags;
snd_soc_dpcm_mutex_assert_held(fe);
/* only add new dpcms */ /* only add new dpcms */
for_each_dpcm_be(fe, stream, dpcm) { for_each_dpcm_be(fe, stream, dpcm) {
...@@ -1137,10 +1216,10 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe, ...@@ -1137,10 +1216,10 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe,
dpcm->fe = fe; dpcm->fe = fe;
be->dpcm[stream].runtime = fe->dpcm[stream].runtime; be->dpcm[stream].runtime = fe->dpcm[stream].runtime;
dpcm->state = SND_SOC_DPCM_LINK_STATE_NEW; dpcm->state = SND_SOC_DPCM_LINK_STATE_NEW;
spin_lock_irqsave(&fe->card->dpcm_lock, flags); snd_soc_dpcm_stream_lock_irq(fe, stream);
list_add(&dpcm->list_be, &fe->dpcm[stream].be_clients); list_add(&dpcm->list_be, &fe->dpcm[stream].be_clients);
list_add(&dpcm->list_fe, &be->dpcm[stream].fe_clients); list_add(&dpcm->list_fe, &be->dpcm[stream].fe_clients);
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags); snd_soc_dpcm_stream_unlock_irq(fe, stream);
dev_dbg(fe->dev, "connected new DPCM %s path %s %s %s\n", dev_dbg(fe->dev, "connected new DPCM %s path %s %s %s\n",
stream ? "capture" : "playback", fe->dai_link->name, stream ? "capture" : "playback", fe->dai_link->name,
...@@ -1183,8 +1262,10 @@ static void dpcm_be_reparent(struct snd_soc_pcm_runtime *fe, ...@@ -1183,8 +1262,10 @@ static void dpcm_be_reparent(struct snd_soc_pcm_runtime *fe,
void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream) void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream)
{ {
struct snd_soc_dpcm *dpcm, *d; struct snd_soc_dpcm *dpcm, *d;
unsigned long flags;
snd_soc_dpcm_mutex_assert_held(fe);
snd_soc_dpcm_stream_lock_irq(fe, stream);
for_each_dpcm_be_safe(fe, stream, dpcm, d) { for_each_dpcm_be_safe(fe, stream, dpcm, d) {
dev_dbg(fe->dev, "ASoC: BE %s disconnect check for %s\n", dev_dbg(fe->dev, "ASoC: BE %s disconnect check for %s\n",
stream ? "capture" : "playback", stream ? "capture" : "playback",
...@@ -1202,12 +1283,11 @@ void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream) ...@@ -1202,12 +1283,11 @@ void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream)
dpcm_remove_debugfs_state(dpcm); dpcm_remove_debugfs_state(dpcm);
spin_lock_irqsave(&fe->card->dpcm_lock, flags);
list_del(&dpcm->list_be); list_del(&dpcm->list_be);
list_del(&dpcm->list_fe); list_del(&dpcm->list_fe);
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
kfree(dpcm); kfree(dpcm);
} }
snd_soc_dpcm_stream_unlock_irq(fe, stream);
} }
/* get BE for DAI widget and stream */ /* get BE for DAI widget and stream */
...@@ -1431,12 +1511,9 @@ int dpcm_process_paths(struct snd_soc_pcm_runtime *fe, ...@@ -1431,12 +1511,9 @@ int dpcm_process_paths(struct snd_soc_pcm_runtime *fe,
void dpcm_clear_pending_state(struct snd_soc_pcm_runtime *fe, int stream) void dpcm_clear_pending_state(struct snd_soc_pcm_runtime *fe, int stream)
{ {
struct snd_soc_dpcm *dpcm; struct snd_soc_dpcm *dpcm;
unsigned long flags;
spin_lock_irqsave(&fe->card->dpcm_lock, flags);
for_each_dpcm_be(fe, stream, dpcm) for_each_dpcm_be(fe, stream, dpcm)
dpcm_set_be_update_state(dpcm->be, stream, SND_SOC_DPCM_UPDATE_NO); dpcm_set_be_update_state(dpcm->be, stream, SND_SOC_DPCM_UPDATE_NO);
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
} }
void dpcm_be_dai_stop(struct snd_soc_pcm_runtime *fe, int stream, void dpcm_be_dai_stop(struct snd_soc_pcm_runtime *fe, int stream,
...@@ -1472,12 +1549,12 @@ void dpcm_be_dai_stop(struct snd_soc_pcm_runtime *fe, int stream, ...@@ -1472,12 +1549,12 @@ void dpcm_be_dai_stop(struct snd_soc_pcm_runtime *fe, int stream,
continue; continue;
if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) { if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) {
soc_pcm_hw_free(be_substream); __soc_pcm_hw_free(be, be_substream);
be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE;
} }
} }
soc_pcm_close(be_substream); __soc_pcm_close(be, be_substream);
be_substream->runtime = NULL; be_substream->runtime = NULL;
be->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; be->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE;
} }
...@@ -1525,7 +1602,7 @@ int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream) ...@@ -1525,7 +1602,7 @@ int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream)
stream ? "capture" : "playback", be->dai_link->name); stream ? "capture" : "playback", be->dai_link->name);
be_substream->runtime = be->dpcm[stream].runtime; be_substream->runtime = be->dpcm[stream].runtime;
err = soc_pcm_open(be_substream); err = __soc_pcm_open(be, be_substream);
if (err < 0) { if (err < 0) {
be->dpcm[stream].users--; be->dpcm[stream].users--;
if (be->dpcm[stream].users < 0) if (be->dpcm[stream].users < 0)
...@@ -1769,7 +1846,7 @@ static int dpcm_fe_dai_startup(struct snd_pcm_substream *fe_substream) ...@@ -1769,7 +1846,7 @@ static int dpcm_fe_dai_startup(struct snd_pcm_substream *fe_substream)
dev_dbg(fe->dev, "ASoC: open FE %s\n", fe->dai_link->name); dev_dbg(fe->dev, "ASoC: open FE %s\n", fe->dai_link->name);
/* start the DAI frontend */ /* start the DAI frontend */
ret = soc_pcm_open(fe_substream); ret = __soc_pcm_open(fe, fe_substream);
if (ret < 0) if (ret < 0)
goto unwind; goto unwind;
...@@ -1800,6 +1877,8 @@ static int dpcm_fe_dai_shutdown(struct snd_pcm_substream *substream) ...@@ -1800,6 +1877,8 @@ static int dpcm_fe_dai_shutdown(struct snd_pcm_substream *substream)
struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
int stream = substream->stream; int stream = substream->stream;
snd_soc_dpcm_mutex_assert_held(fe);
dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE);
/* shutdown the BEs */ /* shutdown the BEs */
...@@ -1808,7 +1887,7 @@ static int dpcm_fe_dai_shutdown(struct snd_pcm_substream *substream) ...@@ -1808,7 +1887,7 @@ static int dpcm_fe_dai_shutdown(struct snd_pcm_substream *substream)
dev_dbg(fe->dev, "ASoC: close FE %s\n", fe->dai_link->name); dev_dbg(fe->dev, "ASoC: close FE %s\n", fe->dai_link->name);
/* now shutdown the frontend */ /* now shutdown the frontend */
soc_pcm_close(substream); __soc_pcm_close(fe, substream);
/* run the stream stop event */ /* run the stream stop event */
dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_STOP); dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_STOP);
...@@ -1853,7 +1932,7 @@ void dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream) ...@@ -1853,7 +1932,7 @@ void dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream)
dev_dbg(be->dev, "ASoC: hw_free BE %s\n", dev_dbg(be->dev, "ASoC: hw_free BE %s\n",
be->dai_link->name); be->dai_link->name);
soc_pcm_hw_free(be_substream); __soc_pcm_hw_free(be, be_substream);
be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE;
} }
...@@ -1864,13 +1943,13 @@ static int dpcm_fe_dai_hw_free(struct snd_pcm_substream *substream) ...@@ -1864,13 +1943,13 @@ static int dpcm_fe_dai_hw_free(struct snd_pcm_substream *substream)
struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
int stream = substream->stream; int stream = substream->stream;
mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); snd_soc_dpcm_mutex_lock(fe);
dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE);
dev_dbg(fe->dev, "ASoC: hw_free FE %s\n", fe->dai_link->name); dev_dbg(fe->dev, "ASoC: hw_free FE %s\n", fe->dai_link->name);
/* call hw_free on the frontend */ /* call hw_free on the frontend */
soc_pcm_hw_free(substream); soc_pcm_hw_clean(fe, substream, 0);
/* only hw_params backends that are either sinks or sources /* only hw_params backends that are either sinks or sources
* to this frontend DAI */ * to this frontend DAI */
...@@ -1879,7 +1958,7 @@ static int dpcm_fe_dai_hw_free(struct snd_pcm_substream *substream) ...@@ -1879,7 +1958,7 @@ static int dpcm_fe_dai_hw_free(struct snd_pcm_substream *substream)
fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE;
dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO);
mutex_unlock(&fe->card->mutex); snd_soc_dpcm_mutex_unlock(fe);
return 0; return 0;
} }
...@@ -1923,7 +2002,7 @@ int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream) ...@@ -1923,7 +2002,7 @@ int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream)
dev_dbg(be->dev, "ASoC: hw_params BE %s\n", dev_dbg(be->dev, "ASoC: hw_params BE %s\n",
be->dai_link->name); be->dai_link->name);
ret = soc_pcm_hw_params(be_substream, &dpcm->hw_params); ret = __soc_pcm_hw_params(be, be_substream, &dpcm->hw_params);
if (ret < 0) if (ret < 0)
goto unwind; goto unwind;
...@@ -1953,7 +2032,7 @@ int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream) ...@@ -1953,7 +2032,7 @@ int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream)
(be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP)) (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP))
continue; continue;
soc_pcm_hw_free(be_substream); __soc_pcm_hw_free(be, be_substream);
} }
return ret; return ret;
...@@ -1965,7 +2044,7 @@ static int dpcm_fe_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -1965,7 +2044,7 @@ static int dpcm_fe_dai_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
int ret, stream = substream->stream; int ret, stream = substream->stream;
mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); snd_soc_dpcm_mutex_lock(fe);
dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE);
memcpy(&fe->dpcm[stream].hw_params, params, memcpy(&fe->dpcm[stream].hw_params, params,
...@@ -1979,7 +2058,7 @@ static int dpcm_fe_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -1979,7 +2058,7 @@ static int dpcm_fe_dai_hw_params(struct snd_pcm_substream *substream,
params_channels(params), params_format(params)); params_channels(params), params_format(params));
/* call hw_params on the frontend */ /* call hw_params on the frontend */
ret = soc_pcm_hw_params(substream, params); ret = __soc_pcm_hw_params(fe, substream, params);
if (ret < 0) if (ret < 0)
dpcm_be_dai_hw_free(fe, stream); dpcm_be_dai_hw_free(fe, stream);
else else
...@@ -1987,7 +2066,7 @@ static int dpcm_fe_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -1987,7 +2066,7 @@ static int dpcm_fe_dai_hw_params(struct snd_pcm_substream *substream,
out: out:
dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO);
mutex_unlock(&fe->card->mutex); snd_soc_dpcm_mutex_unlock(fe);
if (ret < 0) if (ret < 0)
dev_err(fe->dev, "ASoC: %s failed (%d)\n", __func__, ret); dev_err(fe->dev, "ASoC: %s failed (%d)\n", __func__, ret);
...@@ -2258,7 +2337,7 @@ int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream) ...@@ -2258,7 +2337,7 @@ int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream)
dev_dbg(be->dev, "ASoC: prepare BE %s\n", dev_dbg(be->dev, "ASoC: prepare BE %s\n",
be->dai_link->name); be->dai_link->name);
ret = soc_pcm_prepare(be_substream); ret = __soc_pcm_prepare(be, be_substream);
if (ret < 0) if (ret < 0)
break; break;
...@@ -2276,7 +2355,7 @@ static int dpcm_fe_dai_prepare(struct snd_pcm_substream *substream) ...@@ -2276,7 +2355,7 @@ static int dpcm_fe_dai_prepare(struct snd_pcm_substream *substream)
struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
int stream = substream->stream, ret = 0; int stream = substream->stream, ret = 0;
mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); snd_soc_dpcm_mutex_lock(fe);
dev_dbg(fe->dev, "ASoC: prepare FE %s\n", fe->dai_link->name); dev_dbg(fe->dev, "ASoC: prepare FE %s\n", fe->dai_link->name);
...@@ -2295,7 +2374,7 @@ static int dpcm_fe_dai_prepare(struct snd_pcm_substream *substream) ...@@ -2295,7 +2374,7 @@ static int dpcm_fe_dai_prepare(struct snd_pcm_substream *substream)
goto out; goto out;
/* call prepare on the frontend */ /* call prepare on the frontend */
ret = soc_pcm_prepare(substream); ret = __soc_pcm_prepare(fe, substream);
if (ret < 0) if (ret < 0)
goto out; goto out;
...@@ -2303,7 +2382,7 @@ static int dpcm_fe_dai_prepare(struct snd_pcm_substream *substream) ...@@ -2303,7 +2382,7 @@ static int dpcm_fe_dai_prepare(struct snd_pcm_substream *substream)
out: out:
dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO);
mutex_unlock(&fe->card->mutex); snd_soc_dpcm_mutex_unlock(fe);
if (ret < 0) if (ret < 0)
dev_err(fe->dev, "ASoC: %s() failed (%d)\n", __func__, ret); dev_err(fe->dev, "ASoC: %s() failed (%d)\n", __func__, ret);
...@@ -2354,7 +2433,6 @@ static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream) ...@@ -2354,7 +2433,6 @@ static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream)
struct snd_soc_dpcm *dpcm; struct snd_soc_dpcm *dpcm;
enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream];
int ret = 0; int ret = 0;
unsigned long flags;
dev_dbg(fe->dev, "ASoC: runtime %s open on FE %s\n", dev_dbg(fe->dev, "ASoC: runtime %s open on FE %s\n",
stream ? "capture" : "playback", fe->dai_link->name); stream ? "capture" : "playback", fe->dai_link->name);
...@@ -2423,7 +2501,6 @@ static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream) ...@@ -2423,7 +2501,6 @@ static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream)
dpcm_be_dai_shutdown(fe, stream); dpcm_be_dai_shutdown(fe, stream);
disconnect: disconnect:
/* disconnect any pending BEs */ /* disconnect any pending BEs */
spin_lock_irqsave(&fe->card->dpcm_lock, flags);
for_each_dpcm_be(fe, stream, dpcm) { for_each_dpcm_be(fe, stream, dpcm) {
struct snd_soc_pcm_runtime *be = dpcm->be; struct snd_soc_pcm_runtime *be = dpcm->be;
...@@ -2435,7 +2512,6 @@ static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream) ...@@ -2435,7 +2512,6 @@ static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream)
be->dpcm[stream].state == SND_SOC_DPCM_STATE_NEW) be->dpcm[stream].state == SND_SOC_DPCM_STATE_NEW)
dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE; dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE;
} }
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
if (ret < 0) if (ret < 0)
dev_err(fe->dev, "ASoC: %s() failed (%d)\n", __func__, ret); dev_err(fe->dev, "ASoC: %s() failed (%d)\n", __func__, ret);
...@@ -2510,7 +2586,7 @@ int snd_soc_dpcm_runtime_update(struct snd_soc_card *card) ...@@ -2510,7 +2586,7 @@ int snd_soc_dpcm_runtime_update(struct snd_soc_card *card)
struct snd_soc_pcm_runtime *fe; struct snd_soc_pcm_runtime *fe;
int ret = 0; int ret = 0;
mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_RUNTIME); mutex_lock_nested(&card->pcm_mutex, card->pcm_subclass);
/* shutdown all old paths first */ /* shutdown all old paths first */
for_each_card_rtds(card, fe) { for_each_card_rtds(card, fe) {
ret = soc_dpcm_fe_runtime_update(fe, 0); ret = soc_dpcm_fe_runtime_update(fe, 0);
...@@ -2526,7 +2602,7 @@ int snd_soc_dpcm_runtime_update(struct snd_soc_card *card) ...@@ -2526,7 +2602,7 @@ int snd_soc_dpcm_runtime_update(struct snd_soc_card *card)
} }
out: out:
mutex_unlock(&card->mutex); mutex_unlock(&card->pcm_mutex);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(snd_soc_dpcm_runtime_update); EXPORT_SYMBOL_GPL(snd_soc_dpcm_runtime_update);
...@@ -2537,6 +2613,8 @@ static void dpcm_fe_dai_cleanup(struct snd_pcm_substream *fe_substream) ...@@ -2537,6 +2613,8 @@ static void dpcm_fe_dai_cleanup(struct snd_pcm_substream *fe_substream)
struct snd_soc_dpcm *dpcm; struct snd_soc_dpcm *dpcm;
int stream = fe_substream->stream; int stream = fe_substream->stream;
snd_soc_dpcm_mutex_assert_held(fe);
/* mark FE's links ready to prune */ /* mark FE's links ready to prune */
for_each_dpcm_be(fe, stream, dpcm) for_each_dpcm_be(fe, stream, dpcm)
dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE; dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE;
...@@ -2551,12 +2629,12 @@ static int dpcm_fe_dai_close(struct snd_pcm_substream *fe_substream) ...@@ -2551,12 +2629,12 @@ static int dpcm_fe_dai_close(struct snd_pcm_substream *fe_substream)
struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream); struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream);
int ret; int ret;
mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); snd_soc_dpcm_mutex_lock(fe);
ret = dpcm_fe_dai_shutdown(fe_substream); ret = dpcm_fe_dai_shutdown(fe_substream);
dpcm_fe_dai_cleanup(fe_substream); dpcm_fe_dai_cleanup(fe_substream);
mutex_unlock(&fe->card->mutex); snd_soc_dpcm_mutex_unlock(fe);
return ret; return ret;
} }
...@@ -2567,7 +2645,7 @@ static int dpcm_fe_dai_open(struct snd_pcm_substream *fe_substream) ...@@ -2567,7 +2645,7 @@ static int dpcm_fe_dai_open(struct snd_pcm_substream *fe_substream)
int ret; int ret;
int stream = fe_substream->stream; int stream = fe_substream->stream;
mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); snd_soc_dpcm_mutex_lock(fe);
fe->dpcm[stream].runtime = fe_substream->runtime; fe->dpcm[stream].runtime = fe_substream->runtime;
ret = dpcm_path_get(fe, stream, &list); ret = dpcm_path_get(fe, stream, &list);
...@@ -2584,7 +2662,7 @@ static int dpcm_fe_dai_open(struct snd_pcm_substream *fe_substream) ...@@ -2584,7 +2662,7 @@ static int dpcm_fe_dai_open(struct snd_pcm_substream *fe_substream)
dpcm_clear_pending_state(fe, stream); dpcm_clear_pending_state(fe, stream);
dpcm_path_put(&list); dpcm_path_put(&list);
open_end: open_end:
mutex_unlock(&fe->card->mutex); snd_soc_dpcm_mutex_unlock(fe);
return ret; return ret;
} }
...@@ -2845,10 +2923,8 @@ static int snd_soc_dpcm_check_state(struct snd_soc_pcm_runtime *fe, ...@@ -2845,10 +2923,8 @@ static int snd_soc_dpcm_check_state(struct snd_soc_pcm_runtime *fe,
struct snd_soc_dpcm *dpcm; struct snd_soc_dpcm *dpcm;
int state; int state;
int ret = 1; int ret = 1;
unsigned long flags;
int i; int i;
spin_lock_irqsave(&fe->card->dpcm_lock, flags);
for_each_dpcm_fe(be, stream, dpcm) { for_each_dpcm_fe(be, stream, dpcm) {
if (dpcm->fe == fe) if (dpcm->fe == fe)
...@@ -2862,7 +2938,6 @@ static int snd_soc_dpcm_check_state(struct snd_soc_pcm_runtime *fe, ...@@ -2862,7 +2938,6 @@ static int snd_soc_dpcm_check_state(struct snd_soc_pcm_runtime *fe,
} }
} }
} }
spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
/* it's safe to do this BE DAI */ /* it's safe to do this BE DAI */
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment