diff options
author | Peter Ujfalusi <peter.ujfalusi@ti.com> | 2019-08-13 06:45:32 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2019-08-15 10:07:43 -0400 |
commit | 72b745e3ad65deac94ea4eb83262c52ba3ffdb5b (patch) | |
tree | a5850d63c1e97e8fc8d4a6e1f29b8d6e181b112a /sound | |
parent | 12f0bfadf69bb154052722e7e4e5cd1639044c76 (diff) |
ASoC: core: Move pcm_mutex up to card level from snd_soc_pcm_runtime
The pcm_mutex is used to prevent concurrent execution of snd_pcm_ops
callbacks. This works fine most of the cases but it can not handle setups
when the same DAI is used by different rtd, for example:
pcm3168a have two DAIs: one for Playback and one for Capture.
If the codec is connected to a single CPU DAI we need to have two dai_link
to support both playback and capture.
In this case the snd_pcm_ops callbacks can be executed in parallel causing
unexpected races in DAI drivers.
By moving the pcm_mutex up to card level this can be solved
while - hopefully - not breaking other setups.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Tested-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20190813104532.16669-1-peter.ujfalusi@ti.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/soc-compress.c | 48 | ||||
-rw-r--r-- | sound/soc/soc-core.c | 2 | ||||
-rw-r--r-- | sound/soc/soc-pcm.c | 36 |
3 files changed, 43 insertions, 43 deletions
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index 289211069a1e..9e54d8ae6d2c 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c | |||
@@ -80,7 +80,7 @@ static int soc_compr_open(struct snd_compr_stream *cstream) | |||
80 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 80 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
81 | int ret; | 81 | int ret; |
82 | 82 | ||
83 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 83 | mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); |
84 | 84 | ||
85 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->startup) { | 85 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->startup) { |
86 | ret = cpu_dai->driver->cops->startup(cstream, cpu_dai); | 86 | ret = cpu_dai->driver->cops->startup(cstream, cpu_dai); |
@@ -108,7 +108,7 @@ static int soc_compr_open(struct snd_compr_stream *cstream) | |||
108 | 108 | ||
109 | snd_soc_runtime_activate(rtd, cstream->direction); | 109 | snd_soc_runtime_activate(rtd, cstream->direction); |
110 | 110 | ||
111 | mutex_unlock(&rtd->pcm_mutex); | 111 | mutex_unlock(&rtd->card->pcm_mutex); |
112 | 112 | ||
113 | return 0; | 113 | return 0; |
114 | 114 | ||
@@ -118,7 +118,7 @@ machine_err: | |||
118 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown) | 118 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown) |
119 | cpu_dai->driver->cops->shutdown(cstream, cpu_dai); | 119 | cpu_dai->driver->cops->shutdown(cstream, cpu_dai); |
120 | out: | 120 | out: |
121 | mutex_unlock(&rtd->pcm_mutex); | 121 | mutex_unlock(&rtd->card->pcm_mutex); |
122 | return ret; | 122 | return ret; |
123 | } | 123 | } |
124 | 124 | ||
@@ -224,7 +224,7 @@ static void close_delayed_work(struct work_struct *work) | |||
224 | container_of(work, struct snd_soc_pcm_runtime, delayed_work.work); | 224 | container_of(work, struct snd_soc_pcm_runtime, delayed_work.work); |
225 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 225 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
226 | 226 | ||
227 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 227 | mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); |
228 | 228 | ||
229 | dev_dbg(rtd->dev, | 229 | dev_dbg(rtd->dev, |
230 | "Compress ASoC: pop wq checking: %s status: %s waiting: %s\n", | 230 | "Compress ASoC: pop wq checking: %s status: %s waiting: %s\n", |
@@ -239,7 +239,7 @@ static void close_delayed_work(struct work_struct *work) | |||
239 | SND_SOC_DAPM_STREAM_STOP); | 239 | SND_SOC_DAPM_STREAM_STOP); |
240 | } | 240 | } |
241 | 241 | ||
242 | mutex_unlock(&rtd->pcm_mutex); | 242 | mutex_unlock(&rtd->card->pcm_mutex); |
243 | } | 243 | } |
244 | 244 | ||
245 | static int soc_compr_free(struct snd_compr_stream *cstream) | 245 | static int soc_compr_free(struct snd_compr_stream *cstream) |
@@ -249,7 +249,7 @@ static int soc_compr_free(struct snd_compr_stream *cstream) | |||
249 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 249 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
250 | int stream; | 250 | int stream; |
251 | 251 | ||
252 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 252 | mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); |
253 | 253 | ||
254 | if (cstream->direction == SND_COMPRESS_PLAYBACK) | 254 | if (cstream->direction == SND_COMPRESS_PLAYBACK) |
255 | stream = SNDRV_PCM_STREAM_PLAYBACK; | 255 | stream = SNDRV_PCM_STREAM_PLAYBACK; |
@@ -292,7 +292,7 @@ static int soc_compr_free(struct snd_compr_stream *cstream) | |||
292 | SND_SOC_DAPM_STREAM_STOP); | 292 | SND_SOC_DAPM_STREAM_STOP); |
293 | } | 293 | } |
294 | 294 | ||
295 | mutex_unlock(&rtd->pcm_mutex); | 295 | mutex_unlock(&rtd->card->pcm_mutex); |
296 | return 0; | 296 | return 0; |
297 | } | 297 | } |
298 | 298 | ||
@@ -375,7 +375,7 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd) | |||
375 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 375 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
376 | int ret; | 376 | int ret; |
377 | 377 | ||
378 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 378 | mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); |
379 | 379 | ||
380 | ret = soc_compr_components_trigger(cstream, cmd); | 380 | ret = soc_compr_components_trigger(cstream, cmd); |
381 | if (ret < 0) | 381 | if (ret < 0) |
@@ -394,7 +394,7 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd) | |||
394 | } | 394 | } |
395 | 395 | ||
396 | out: | 396 | out: |
397 | mutex_unlock(&rtd->pcm_mutex); | 397 | mutex_unlock(&rtd->card->pcm_mutex); |
398 | return ret; | 398 | return ret; |
399 | } | 399 | } |
400 | 400 | ||
@@ -480,7 +480,7 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream, | |||
480 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 480 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
481 | int ret; | 481 | int ret; |
482 | 482 | ||
483 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 483 | mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); |
484 | 484 | ||
485 | /* | 485 | /* |
486 | * First we call set_params for the CPU DAI, then the component | 486 | * First we call set_params for the CPU DAI, then the component |
@@ -514,14 +514,14 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream, | |||
514 | 514 | ||
515 | /* cancel any delayed stream shutdown that is pending */ | 515 | /* cancel any delayed stream shutdown that is pending */ |
516 | rtd->pop_wait = 0; | 516 | rtd->pop_wait = 0; |
517 | mutex_unlock(&rtd->pcm_mutex); | 517 | mutex_unlock(&rtd->card->pcm_mutex); |
518 | 518 | ||
519 | cancel_delayed_work_sync(&rtd->delayed_work); | 519 | cancel_delayed_work_sync(&rtd->delayed_work); |
520 | 520 | ||
521 | return 0; | 521 | return 0; |
522 | 522 | ||
523 | err: | 523 | err: |
524 | mutex_unlock(&rtd->pcm_mutex); | 524 | mutex_unlock(&rtd->card->pcm_mutex); |
525 | return ret; | 525 | return ret; |
526 | } | 526 | } |
527 | 527 | ||
@@ -593,7 +593,7 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream, | |||
593 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 593 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
594 | int ret = 0; | 594 | int ret = 0; |
595 | 595 | ||
596 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 596 | mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); |
597 | 597 | ||
598 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->get_params) { | 598 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->get_params) { |
599 | ret = cpu_dai->driver->cops->get_params(cstream, params, cpu_dai); | 599 | ret = cpu_dai->driver->cops->get_params(cstream, params, cpu_dai); |
@@ -613,7 +613,7 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream, | |||
613 | } | 613 | } |
614 | 614 | ||
615 | err: | 615 | err: |
616 | mutex_unlock(&rtd->pcm_mutex); | 616 | mutex_unlock(&rtd->card->pcm_mutex); |
617 | return ret; | 617 | return ret; |
618 | } | 618 | } |
619 | 619 | ||
@@ -625,7 +625,7 @@ static int soc_compr_get_caps(struct snd_compr_stream *cstream, | |||
625 | struct snd_soc_rtdcom_list *rtdcom; | 625 | struct snd_soc_rtdcom_list *rtdcom; |
626 | int ret = 0; | 626 | int ret = 0; |
627 | 627 | ||
628 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 628 | mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); |
629 | 629 | ||
630 | for_each_rtdcom(rtd, rtdcom) { | 630 | for_each_rtdcom(rtd, rtdcom) { |
631 | component = rtdcom->component; | 631 | component = rtdcom->component; |
@@ -638,7 +638,7 @@ static int soc_compr_get_caps(struct snd_compr_stream *cstream, | |||
638 | break; | 638 | break; |
639 | } | 639 | } |
640 | 640 | ||
641 | mutex_unlock(&rtd->pcm_mutex); | 641 | mutex_unlock(&rtd->card->pcm_mutex); |
642 | return ret; | 642 | return ret; |
643 | } | 643 | } |
644 | 644 | ||
@@ -650,7 +650,7 @@ static int soc_compr_get_codec_caps(struct snd_compr_stream *cstream, | |||
650 | struct snd_soc_rtdcom_list *rtdcom; | 650 | struct snd_soc_rtdcom_list *rtdcom; |
651 | int ret = 0; | 651 | int ret = 0; |
652 | 652 | ||
653 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 653 | mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); |
654 | 654 | ||
655 | for_each_rtdcom(rtd, rtdcom) { | 655 | for_each_rtdcom(rtd, rtdcom) { |
656 | component = rtdcom->component; | 656 | component = rtdcom->component; |
@@ -664,7 +664,7 @@ static int soc_compr_get_codec_caps(struct snd_compr_stream *cstream, | |||
664 | break; | 664 | break; |
665 | } | 665 | } |
666 | 666 | ||
667 | mutex_unlock(&rtd->pcm_mutex); | 667 | mutex_unlock(&rtd->card->pcm_mutex); |
668 | return ret; | 668 | return ret; |
669 | } | 669 | } |
670 | 670 | ||
@@ -676,7 +676,7 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes) | |||
676 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 676 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
677 | int ret = 0; | 677 | int ret = 0; |
678 | 678 | ||
679 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 679 | mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); |
680 | 680 | ||
681 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->ack) { | 681 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->ack) { |
682 | ret = cpu_dai->driver->cops->ack(cstream, bytes, cpu_dai); | 682 | ret = cpu_dai->driver->cops->ack(cstream, bytes, cpu_dai); |
@@ -697,7 +697,7 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes) | |||
697 | } | 697 | } |
698 | 698 | ||
699 | err: | 699 | err: |
700 | mutex_unlock(&rtd->pcm_mutex); | 700 | mutex_unlock(&rtd->card->pcm_mutex); |
701 | return ret; | 701 | return ret; |
702 | } | 702 | } |
703 | 703 | ||
@@ -710,7 +710,7 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream, | |||
710 | int ret = 0; | 710 | int ret = 0; |
711 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 711 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
712 | 712 | ||
713 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 713 | mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); |
714 | 714 | ||
715 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->pointer) | 715 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->pointer) |
716 | cpu_dai->driver->cops->pointer(cstream, tstamp, cpu_dai); | 716 | cpu_dai->driver->cops->pointer(cstream, tstamp, cpu_dai); |
@@ -726,7 +726,7 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream, | |||
726 | break; | 726 | break; |
727 | } | 727 | } |
728 | 728 | ||
729 | mutex_unlock(&rtd->pcm_mutex); | 729 | mutex_unlock(&rtd->card->pcm_mutex); |
730 | return ret; | 730 | return ret; |
731 | } | 731 | } |
732 | 732 | ||
@@ -738,7 +738,7 @@ static int soc_compr_copy(struct snd_compr_stream *cstream, | |||
738 | struct snd_soc_rtdcom_list *rtdcom; | 738 | struct snd_soc_rtdcom_list *rtdcom; |
739 | int ret = 0; | 739 | int ret = 0; |
740 | 740 | ||
741 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 741 | mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); |
742 | 742 | ||
743 | for_each_rtdcom(rtd, rtdcom) { | 743 | for_each_rtdcom(rtd, rtdcom) { |
744 | component = rtdcom->component; | 744 | component = rtdcom->component; |
@@ -751,7 +751,7 @@ static int soc_compr_copy(struct snd_compr_stream *cstream, | |||
751 | break; | 751 | break; |
752 | } | 752 | } |
753 | 753 | ||
754 | mutex_unlock(&rtd->pcm_mutex); | 754 | mutex_unlock(&rtd->card->pcm_mutex); |
755 | return ret; | 755 | return ret; |
756 | } | 756 | } |
757 | 757 | ||
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index abe2f47cee6e..b3f820fb53e6 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -1360,7 +1360,6 @@ static int soc_post_component_init(struct snd_soc_pcm_runtime *rtd, | |||
1360 | rtd->dev->groups = soc_dev_attr_groups; | 1360 | rtd->dev->groups = soc_dev_attr_groups; |
1361 | dev_set_name(rtd->dev, "%s", name); | 1361 | dev_set_name(rtd->dev, "%s", name); |
1362 | dev_set_drvdata(rtd->dev, rtd); | 1362 | dev_set_drvdata(rtd->dev, rtd); |
1363 | mutex_init(&rtd->pcm_mutex); | ||
1364 | INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_PLAYBACK].be_clients); | 1363 | INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_PLAYBACK].be_clients); |
1365 | INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_CAPTURE].be_clients); | 1364 | INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_CAPTURE].be_clients); |
1366 | INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_PLAYBACK].fe_clients); | 1365 | INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_PLAYBACK].fe_clients); |
@@ -2383,6 +2382,7 @@ int snd_soc_register_card(struct snd_soc_card *card) | |||
2383 | card->instantiated = 0; | 2382 | card->instantiated = 0; |
2384 | mutex_init(&card->mutex); | 2383 | mutex_init(&card->mutex); |
2385 | mutex_init(&card->dapm_mutex); | 2384 | mutex_init(&card->dapm_mutex); |
2385 | mutex_init(&card->pcm_mutex); | ||
2386 | spin_lock_init(&card->dpcm_lock); | 2386 | spin_lock_init(&card->dpcm_lock); |
2387 | 2387 | ||
2388 | return snd_soc_bind_card(card); | 2388 | return snd_soc_bind_card(card); |
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index da657c8179cc..e163dde5eab1 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c | |||
@@ -36,7 +36,7 @@ | |||
36 | * Increments the active count for all the DAIs and components attached to a PCM | 36 | * Increments the active count for all the DAIs and components attached to a PCM |
37 | * runtime. Should typically be called when a stream is opened. | 37 | * runtime. Should typically be called when a stream is opened. |
38 | * | 38 | * |
39 | * Must be called with the rtd->pcm_mutex being held | 39 | * Must be called with the rtd->card->pcm_mutex being held |
40 | */ | 40 | */ |
41 | void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd, int stream) | 41 | void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd, int stream) |
42 | { | 42 | { |
@@ -44,7 +44,7 @@ void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd, int stream) | |||
44 | struct snd_soc_dai *codec_dai; | 44 | struct snd_soc_dai *codec_dai; |
45 | int i; | 45 | int i; |
46 | 46 | ||
47 | lockdep_assert_held(&rtd->pcm_mutex); | 47 | lockdep_assert_held(&rtd->card->pcm_mutex); |
48 | 48 | ||
49 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { | 49 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { |
50 | cpu_dai->playback_active++; | 50 | cpu_dai->playback_active++; |
@@ -72,7 +72,7 @@ void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd, int stream) | |||
72 | * Decrements the active count for all the DAIs and components attached to a PCM | 72 | * Decrements the active count for all the DAIs and components attached to a PCM |
73 | * runtime. Should typically be called when a stream is closed. | 73 | * runtime. Should typically be called when a stream is closed. |
74 | * | 74 | * |
75 | * Must be called with the rtd->pcm_mutex being held | 75 | * Must be called with the rtd->card->pcm_mutex being held |
76 | */ | 76 | */ |
77 | void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd, int stream) | 77 | void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd, int stream) |
78 | { | 78 | { |
@@ -80,7 +80,7 @@ void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd, int stream) | |||
80 | struct snd_soc_dai *codec_dai; | 80 | struct snd_soc_dai *codec_dai; |
81 | int i; | 81 | int i; |
82 | 82 | ||
83 | lockdep_assert_held(&rtd->pcm_mutex); | 83 | lockdep_assert_held(&rtd->card->pcm_mutex); |
84 | 84 | ||
85 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { | 85 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { |
86 | cpu_dai->playback_active--; | 86 | cpu_dai->playback_active--; |
@@ -506,7 +506,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) | |||
506 | pm_runtime_get_sync(component->dev); | 506 | pm_runtime_get_sync(component->dev); |
507 | } | 507 | } |
508 | 508 | ||
509 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 509 | mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); |
510 | 510 | ||
511 | /* startup the audio subsystem */ | 511 | /* startup the audio subsystem */ |
512 | ret = snd_soc_dai_startup(cpu_dai, substream); | 512 | ret = snd_soc_dai_startup(cpu_dai, substream); |
@@ -604,7 +604,7 @@ dynamic: | |||
604 | 604 | ||
605 | snd_soc_runtime_activate(rtd, substream->stream); | 605 | snd_soc_runtime_activate(rtd, substream->stream); |
606 | 606 | ||
607 | mutex_unlock(&rtd->pcm_mutex); | 607 | mutex_unlock(&rtd->card->pcm_mutex); |
608 | return 0; | 608 | return 0; |
609 | 609 | ||
610 | config_err: | 610 | config_err: |
@@ -623,7 +623,7 @@ component_err: | |||
623 | 623 | ||
624 | snd_soc_dai_shutdown(cpu_dai, substream); | 624 | snd_soc_dai_shutdown(cpu_dai, substream); |
625 | out: | 625 | out: |
626 | mutex_unlock(&rtd->pcm_mutex); | 626 | mutex_unlock(&rtd->card->pcm_mutex); |
627 | 627 | ||
628 | for_each_rtdcom(rtd, rtdcom) { | 628 | for_each_rtdcom(rtd, rtdcom) { |
629 | component = rtdcom->component; | 629 | component = rtdcom->component; |
@@ -653,7 +653,7 @@ static void close_delayed_work(struct work_struct *work) | |||
653 | container_of(work, struct snd_soc_pcm_runtime, delayed_work.work); | 653 | container_of(work, struct snd_soc_pcm_runtime, delayed_work.work); |
654 | struct snd_soc_dai *codec_dai = rtd->codec_dais[0]; | 654 | struct snd_soc_dai *codec_dai = rtd->codec_dais[0]; |
655 | 655 | ||
656 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 656 | mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); |
657 | 657 | ||
658 | dev_dbg(rtd->dev, "ASoC: pop wq checking: %s status: %s waiting: %s\n", | 658 | dev_dbg(rtd->dev, "ASoC: pop wq checking: %s status: %s waiting: %s\n", |
659 | codec_dai->driver->playback.stream_name, | 659 | codec_dai->driver->playback.stream_name, |
@@ -667,7 +667,7 @@ static void close_delayed_work(struct work_struct *work) | |||
667 | SND_SOC_DAPM_STREAM_STOP); | 667 | SND_SOC_DAPM_STREAM_STOP); |
668 | } | 668 | } |
669 | 669 | ||
670 | mutex_unlock(&rtd->pcm_mutex); | 670 | mutex_unlock(&rtd->card->pcm_mutex); |
671 | } | 671 | } |
672 | 672 | ||
673 | static void codec2codec_close_delayed_work(struct work_struct *work) | 673 | static void codec2codec_close_delayed_work(struct work_struct *work) |
@@ -694,7 +694,7 @@ static int soc_pcm_close(struct snd_pcm_substream *substream) | |||
694 | struct snd_soc_dai *codec_dai; | 694 | struct snd_soc_dai *codec_dai; |
695 | int i; | 695 | int i; |
696 | 696 | ||
697 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 697 | mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); |
698 | 698 | ||
699 | snd_soc_runtime_deactivate(rtd, substream->stream); | 699 | snd_soc_runtime_deactivate(rtd, substream->stream); |
700 | 700 | ||
@@ -738,7 +738,7 @@ static int soc_pcm_close(struct snd_pcm_substream *substream) | |||
738 | SND_SOC_DAPM_STREAM_STOP); | 738 | SND_SOC_DAPM_STREAM_STOP); |
739 | } | 739 | } |
740 | 740 | ||
741 | mutex_unlock(&rtd->pcm_mutex); | 741 | mutex_unlock(&rtd->card->pcm_mutex); |
742 | 742 | ||
743 | for_each_rtdcom(rtd, rtdcom) { | 743 | for_each_rtdcom(rtd, rtdcom) { |
744 | component = rtdcom->component; | 744 | component = rtdcom->component; |
@@ -771,7 +771,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) | |||
771 | struct snd_soc_dai *codec_dai; | 771 | struct snd_soc_dai *codec_dai; |
772 | int i, ret = 0; | 772 | int i, ret = 0; |
773 | 773 | ||
774 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 774 | mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); |
775 | 775 | ||
776 | if (rtd->dai_link->ops->prepare) { | 776 | if (rtd->dai_link->ops->prepare) { |
777 | ret = rtd->dai_link->ops->prepare(substream); | 777 | ret = rtd->dai_link->ops->prepare(substream); |
@@ -826,7 +826,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) | |||
826 | snd_soc_dai_digital_mute(cpu_dai, 0, substream->stream); | 826 | snd_soc_dai_digital_mute(cpu_dai, 0, substream->stream); |
827 | 827 | ||
828 | out: | 828 | out: |
829 | mutex_unlock(&rtd->pcm_mutex); | 829 | mutex_unlock(&rtd->card->pcm_mutex); |
830 | return ret; | 830 | return ret; |
831 | } | 831 | } |
832 | 832 | ||
@@ -876,7 +876,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, | |||
876 | struct snd_soc_dai *codec_dai; | 876 | struct snd_soc_dai *codec_dai; |
877 | int i, ret = 0; | 877 | int i, ret = 0; |
878 | 878 | ||
879 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 879 | mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); |
880 | if (rtd->dai_link->ops->hw_params) { | 880 | if (rtd->dai_link->ops->hw_params) { |
881 | ret = rtd->dai_link->ops->hw_params(substream, params); | 881 | ret = rtd->dai_link->ops->hw_params(substream, params); |
882 | if (ret < 0) { | 882 | if (ret < 0) { |
@@ -962,7 +962,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, | |||
962 | if (ret) | 962 | if (ret) |
963 | goto component_err; | 963 | goto component_err; |
964 | out: | 964 | out: |
965 | mutex_unlock(&rtd->pcm_mutex); | 965 | mutex_unlock(&rtd->card->pcm_mutex); |
966 | return ret; | 966 | return ret; |
967 | 967 | ||
968 | component_err: | 968 | component_err: |
@@ -986,7 +986,7 @@ codec_err: | |||
986 | if (rtd->dai_link->ops->hw_free) | 986 | if (rtd->dai_link->ops->hw_free) |
987 | rtd->dai_link->ops->hw_free(substream); | 987 | rtd->dai_link->ops->hw_free(substream); |
988 | 988 | ||
989 | mutex_unlock(&rtd->pcm_mutex); | 989 | mutex_unlock(&rtd->card->pcm_mutex); |
990 | return ret; | 990 | return ret; |
991 | } | 991 | } |
992 | 992 | ||
@@ -1001,7 +1001,7 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream) | |||
1001 | bool playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; | 1001 | bool playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; |
1002 | int i; | 1002 | int i; |
1003 | 1003 | ||
1004 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 1004 | mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); |
1005 | 1005 | ||
1006 | /* clear the corresponding DAIs parameters when going to be inactive */ | 1006 | /* clear the corresponding DAIs parameters when going to be inactive */ |
1007 | if (cpu_dai->active == 1) { | 1007 | if (cpu_dai->active == 1) { |
@@ -1043,7 +1043,7 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream) | |||
1043 | 1043 | ||
1044 | snd_soc_dai_hw_free(cpu_dai, substream); | 1044 | snd_soc_dai_hw_free(cpu_dai, substream); |
1045 | 1045 | ||
1046 | mutex_unlock(&rtd->pcm_mutex); | 1046 | mutex_unlock(&rtd->card->pcm_mutex); |
1047 | return 0; | 1047 | return 0; |
1048 | } | 1048 | } |
1049 | 1049 | ||