All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cezary Rojewski <cezary.rojewski@intel.com>
To: alsa-devel@alsa-project.org, broonie@kernel.org
Cc: Cezary Rojewski <cezary.rojewski@intel.com>,
	pierre-louis.bossart@linux.intel.com, tiwai@suse.com,
	hdegoede@redhat.com, amadeuszx.slawinski@linux.intel.com
Subject: [PATCH 2/2] ASoC: Intel: avs: Disconnect substream if suspend or resume fails
Date: Thu, 10 Nov 2022 15:13:30 +0100	[thread overview]
Message-ID: <20221110141330.740916-3-cezary.rojewski@intel.com> (raw)
In-Reply-To: <20221110141330.740916-1-cezary.rojewski@intel.com>

To improve performance and overall system stability, suspend/resume
operations for ASoC cards always return success status and defer the
actual work.

Because of that, if a substream fails to resume, userspace may still
attempt to invoke commands on it as from their perspective the operation
completed successfully. Set substream's state to DISCONNECTED to ensure
no further commands are attempted.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 sound/soc/intel/avs/pcm.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c
index ca624fbb5c0d..f95c530ffeb1 100644
--- a/sound/soc/intel/avs/pcm.c
+++ b/sound/soc/intel/avs/pcm.c
@@ -934,8 +934,11 @@ static int avs_component_pm_op(struct snd_soc_component *component, bool be,
 			rtd = snd_pcm_substream_chip(data->substream);
 			if (rtd->dai_link->no_pcm == be && !rtd->dai_link->ignore_suspend) {
 				ret = op(dai, data);
-				if (ret < 0)
+				if (ret < 0) {
+					data->substream->runtime->status->state =
+						SNDRV_PCM_STATE_DISCONNECTED;
 					return ret;
+				}
 			}
 		}
 
@@ -944,8 +947,11 @@ static int avs_component_pm_op(struct snd_soc_component *component, bool be,
 			rtd = snd_pcm_substream_chip(data->substream);
 			if (rtd->dai_link->no_pcm == be && !rtd->dai_link->ignore_suspend) {
 				ret = op(dai, data);
-				if (ret < 0)
+				if (ret < 0) {
+					data->substream->runtime->status->state =
+						SNDRV_PCM_STATE_DISCONNECTED;
 					return ret;
+				}
 			}
 		}
 	}
-- 
2.25.1


  parent reply	other threads:[~2022-11-10 13:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-10 14:13 [PATCH 0/2] ASoC: Intel: avs: DSP recovery and resume fixes Cezary Rojewski
2022-11-10 14:13 ` [PATCH 1/2] ASoC: Intel: avs: Lock substream before snd_pcm_stop() Cezary Rojewski
2022-11-10 14:13 ` Cezary Rojewski [this message]
2022-11-10 15:39   ` [PATCH 2/2] ASoC: Intel: avs: Disconnect substream if suspend or resume fails Pierre-Louis Bossart
2022-11-10 16:06     ` Cezary Rojewski
2022-11-10 16:18       ` Pierre-Louis Bossart
2022-11-10 16:29         ` Cezary Rojewski
2022-11-10 16:36           ` Pierre-Louis Bossart
2022-11-10 16:44             ` Cezary Rojewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221110141330.740916-3-cezary.rojewski@intel.com \
    --to=cezary.rojewski@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=amadeuszx.slawinski@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=hdegoede@redhat.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.