The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Richard Fitzgerald <rf@opensource.cirrus.com>
To: <broonie@kernel.org>
Cc: <alsa-devel@alsa-project.org>, <linux-kernel@vger.kernel.org>,
	<patches@opensource.cirrus.com>,
	Richard Fitzgerald <rf@opensource.cirrus.com>
Subject: [PATCH 3/6] ASoC: cs35l56: Skip first init_completion wait in dsp_work if init_done
Date: Tue, 11 Apr 2023 16:25:25 +0100	[thread overview]
Message-ID: <20230411152528.329803-4-rf@opensource.cirrus.com> (raw)
In-Reply-To: <20230411152528.329803-1-rf@opensource.cirrus.com>

At the start of dsp_work() only wait for init_completion if !init_done.
This allows system suspend to re-queue dsp_work() without having to
do a dummy complete() of init_completion.

A dummy completion in system suspend would have to be conditional on
init_done. But that would create a possible race condition between our
system resume and cs35l56_init() in the corner case that we suspend right
after the SoundWire core has enumerated and reported ATTACHED.

It is safer and simpler to have cs35l56_init() as the only place that
init_completion is completed, and dsp_work() as the only place that
it is consumed.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
 sound/soc/codecs/cs35l56.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/cs35l56.c b/sound/soc/codecs/cs35l56.c
index 997a5c5acaab..62c44276c121 100644
--- a/sound/soc/codecs/cs35l56.c
+++ b/sound/soc/codecs/cs35l56.c
@@ -866,7 +866,8 @@ static void cs35l56_dsp_work(struct work_struct *work)
 	unsigned int val;
 	int ret = 0;
 
-	if (!wait_for_completion_timeout(&cs35l56->init_completion,
+	if (!cs35l56->init_done &&
+	    !wait_for_completion_timeout(&cs35l56->init_completion,
 					 msecs_to_jiffies(5000))) {
 		dev_err(cs35l56->dev, "%s: init_completion timed out\n", __func__);
 		goto complete;
-- 
2.30.2


  parent reply	other threads:[~2023-04-11 15:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-11 15:25 [PATCH 0/6] ASoC: cs35l56: Add system suspend handling Richard Fitzgerald
2023-04-11 15:25 ` [PATCH 1/6] ASoC: cs35l56: Remove quick-cancelling of dsp_work() Richard Fitzgerald
2023-04-11 15:25 ` [PATCH 2/6] ASoC: cs35l56: Use DAPM widget for firmware PLAY/PAUSE Richard Fitzgerald
2023-04-11 15:25 ` Richard Fitzgerald [this message]
2023-04-11 15:25 ` [PATCH 4/6] ASoC: cs35l56: Always wait for firmware boot in runtime-resume Richard Fitzgerald
2023-04-11 15:25 ` [PATCH 5/6] ASoC: cs35l56: Add basic system suspend handling Richard Fitzgerald
2023-04-11 15:25 ` [PATCH 6/6] ASoC: cs35l56: Re-patch firmware after system suspend Richard Fitzgerald
2023-04-12 19:00 ` [PATCH 0/6] ASoC: cs35l56: Add system suspend handling Mark Brown

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=20230411152528.329803-4-rf@opensource.cirrus.com \
    --to=rf@opensource.cirrus.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@opensource.cirrus.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox