Skip to content

Commit acf676b

Browse files
ujfalusivinodkoul
authored andcommitted
soundwire: intel: Move suspend tracking from trigger to pm suspend
Mark all open DAI runtimes as suspended in the component .suspend callback instead of relying on SNDRV_PCM_TRIGGER_SUSPEND, which is not delivered during PAUSE or xrun states. If during system suspend a dai is open it means that it is in either in SUSPENDED, PAUSED or STOPPED (due to xrun) state and they will need to be re-initialized during resume (which is done in .prepare callback). Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://patch.msgid.link/20260508101755.1247039-1-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 4e90368 commit acf676b

2 files changed

Lines changed: 33 additions & 37 deletions

File tree

drivers/soundwire/intel.c

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -906,19 +906,6 @@ static int intel_trigger(struct snd_pcm_substream *substream, int cmd, struct sn
906906
}
907907

908908
switch (cmd) {
909-
case SNDRV_PCM_TRIGGER_SUSPEND:
910-
911-
/*
912-
* The .prepare callback is used to deal with xruns and resume operations.
913-
* In the case of xruns, the DMAs and SHIM registers cannot be touched,
914-
* but for resume operations the DMAs and SHIM registers need to be initialized.
915-
* the .trigger callback is used to track the suspend case only.
916-
*/
917-
918-
dai_runtime->suspended = true;
919-
920-
break;
921-
922909
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
923910
dai_runtime->paused = true;
924911
break;
@@ -955,24 +942,20 @@ static int intel_component_dais_suspend(struct snd_soc_component *component)
955942
struct snd_soc_dai *dai;
956943

957944
/*
958-
* In the corner case where a SUSPEND happens during a PAUSE, the ALSA core
959-
* does not throw the TRIGGER_SUSPEND. This leaves the DAIs in an unbalanced state.
960-
* Since the component suspend is called last, we can trap this corner case
961-
* and force the DAIs to release their resources.
945+
* Mark all open streams as suspended.
946+
* Open streams at this point can be in SUSPENDED, PAUSED or STOPPED
947+
* state and during prepare the DMAs and SHIM registers need to be
948+
* initialized for them.
949+
* The STOPPED state is a special corner case which can happen if audio
950+
* experiences xrun at suspend time.
962951
*/
963952
for_each_component_dais(component, dai) {
964953
struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai);
965954
struct sdw_cdns_dai_runtime *dai_runtime;
966955

967956
dai_runtime = cdns->dai_runtime_array[dai->id];
968957

969-
if (!dai_runtime)
970-
continue;
971-
972-
if (dai_runtime->suspended)
973-
continue;
974-
975-
if (dai_runtime->paused)
958+
if (dai_runtime)
976959
dai_runtime->suspended = true;
977960
}
978961

drivers/soundwire/intel_ace2x.c

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -894,19 +894,6 @@ static int intel_trigger(struct snd_pcm_substream *substream, int cmd, struct sn
894894
}
895895

896896
switch (cmd) {
897-
case SNDRV_PCM_TRIGGER_SUSPEND:
898-
899-
/*
900-
* The .prepare callback is used to deal with xruns and resume operations.
901-
* In the case of xruns, the DMAs and SHIM registers cannot be touched,
902-
* but for resume operations the DMAs and SHIM registers need to be initialized.
903-
* the .trigger callback is used to track the suspend case only.
904-
*/
905-
906-
dai_runtime->suspended = true;
907-
908-
break;
909-
910897
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
911898
dai_runtime->paused = true;
912899
break;
@@ -930,8 +917,34 @@ static const struct snd_soc_dai_ops intel_pcm_dai_ops = {
930917
.get_stream = intel_get_sdw_stream,
931918
};
932919

920+
static int intel_component_dais_suspend(struct snd_soc_component *component)
921+
{
922+
struct snd_soc_dai *dai;
923+
924+
/*
925+
* Mark all open streams as suspended.
926+
* Open streams at this point can be in SUSPENDED, PAUSED or STOPPED
927+
* state and during prepare the DMAs and SHIM registers need to be
928+
* initialized for them.
929+
* The STOPPED state is a special corner case which can happen if audio
930+
* experiences xrun at suspend time.
931+
*/
932+
for_each_component_dais(component, dai) {
933+
struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai);
934+
struct sdw_cdns_dai_runtime *dai_runtime;
935+
936+
dai_runtime = cdns->dai_runtime_array[dai->id];
937+
938+
if (dai_runtime)
939+
dai_runtime->suspended = true;
940+
}
941+
942+
return 0;
943+
}
944+
933945
static const struct snd_soc_component_driver dai_component = {
934946
.name = "soundwire",
947+
.suspend = intel_component_dais_suspend,
935948
};
936949

937950
/*

0 commit comments

Comments
 (0)