From: James Calligeros <jcalligeros99@gmail.com>
To: "Martin Povišer" <povik+lin@cutebit.org>,
"Liam Girdwood" <lgirdwood@gmail.com>,
"Mark Brown" <broonie@kernel.org>,
"Jaroslav Kysela" <perex@perex.cz>,
"Takashi Iwai" <tiwai@suse.com>
Cc: asahi@lists.linux.dev, linux-sound@vger.kernel.org,
linux-kernel@vger.kernel.org, Hector Martin <marcan@marcan.st>,
James Calligeros <jcalligeros99@gmail.com>
Subject: [PATCH 8/9] ASoC: apple: mca: Do not mark clocks in use for non-providers
Date: Sun, 18 May 2025 20:50:53 +1000 [thread overview]
Message-ID: <20250518-mca-fixes-v1-8-ee1015a695f6@gmail.com> (raw)
In-Reply-To: <20250518-mca-fixes-v1-0-ee1015a695f6@gmail.com>
From: Hector Martin <marcan@marcan.st>
On the speakers PCM, this sequence:
1. Open playback
2. Open sense
3. Close playback
4. Close sense
would result in the sense FE being marked as clocks in use at (2), since
there is a clock provider (playback FE). Then at (4) this would WARN since
there is no driver any more when closing the in use clocks.
If (1) and (2) are reversed this does not happen, since the sense PCM is
not marked as using the clocks when there is no provider yet. So, check
explicitly whether the substream FE is a clock provider in be_prepare,
and skip everything if it isn't.
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
---
sound/soc/apple/mca.c | 67 ++++++++++++++-----------
1 file changed, 37 insertions(+), 30 deletions(-)
diff --git a/sound/soc/apple/mca.c b/sound/soc/apple/mca.c
index 441da5ef3de1c0be1dc607ff2490046206660e59..25d04b3d8a57a8551f2ac1c0cd2dbf2997d907e8 100644
--- a/sound/soc/apple/mca.c
+++ b/sound/soc/apple/mca.c
@@ -354,36 +354,6 @@ static bool mca_fe_clocks_in_use(struct mca_cluster *cl)
return false;
}
-static int mca_be_prepare(struct snd_pcm_substream *substream,
- struct snd_soc_dai *dai)
-{
- struct mca_cluster *cl = mca_dai_to_cluster(dai);
- struct mca_data *mca = cl->host;
- struct mca_cluster *fe_cl;
- int ret;
-
- if (cl->port_clk_driver < 0)
- return 0;
-
- fe_cl = &mca->clusters[cl->port_clk_driver];
-
- /*
- * Typically the CODECs we are paired with will require clocks
- * to be present at time of unmute with the 'mute_stream' op
- * or at time of DAPM widget power-up. We need to enable clocks
- * here at the latest (frontend prepare would be too late).
- */
- if (!mca_fe_clocks_in_use(fe_cl)) {
- ret = mca_fe_enable_clocks(fe_cl);
- if (ret < 0)
- return ret;
- }
-
- cl->clocks_in_use[substream->stream] = true;
-
- return 0;
-}
-
static int mca_fe_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
@@ -787,6 +757,43 @@ static struct snd_soc_pcm_runtime *mca_be_get_fe(struct snd_soc_pcm_runtime *be,
return fe;
}
+static int mca_be_prepare(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *dai)
+{
+ struct snd_soc_pcm_runtime *be = snd_soc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *fe = mca_be_get_fe(be, substream->stream);
+ struct mca_cluster *cl = mca_dai_to_cluster(dai);
+ struct mca_data *mca = cl->host;
+ struct mca_cluster *fe_cl, *fe_clk_cl;
+ int ret;
+
+ fe_cl = mca_dai_to_cluster(snd_soc_rtd_to_cpu(fe, 0));
+
+ if (!fe_cl->clk_provider)
+ return 0;
+
+ if (cl->port_clk_driver < 0)
+ return 0;
+
+ fe_clk_cl = &mca->clusters[cl->port_clk_driver];
+
+ /*
+ * Typically the CODECs we are paired with will require clocks
+ * to be present at time of unmute with the 'mute_stream' op
+ * or at time of DAPM widget power-up. We need to enable clocks
+ * here at the latest (frontend prepare would be too late).
+ */
+ if (!mca_fe_clocks_in_use(fe_clk_cl)) {
+ ret = mca_fe_enable_clocks(fe_clk_cl);
+ if (ret < 0)
+ return ret;
+ }
+
+ cl->clocks_in_use[substream->stream] = true;
+
+ return 0;
+}
+
static int mca_be_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
--
2.49.0
next prev parent reply other threads:[~2025-05-18 10:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-18 10:50 [PATCH 0/9] ASoC: apple: mca: support simultaneous I2S capture on the frontend James Calligeros
2025-05-18 10:50 ` [PATCH 1/9] ASoC: apple: mca: Constrain channels according to TDM mask James Calligeros
2025-05-18 10:50 ` [PATCH 2/9] ASoC: apple: mca: use readx_poll_timeout to check for cluster reset James Calligeros
2025-05-18 10:50 ` [PATCH 3/9] ASoC: apple: mca: Move clock shutdown to backend shutdown James Calligeros
2025-05-19 10:38 ` Mark Brown
2025-05-18 10:50 ` [PATCH 4/9] ASoC: apple: mca: Separate data & clock port setup James Calligeros
2025-05-18 10:50 ` [PATCH 5/9] ASoC: apple: mca: Factor out mca_be_get_fe James Calligeros
2025-05-18 10:50 ` [PATCH 6/9] ASoC: apple: mca: Support FEs being clock consumers James Calligeros
2025-05-18 10:50 ` [PATCH 7/9] ASoC: apple: mca: Support capture on multiples BEs James Calligeros
2025-05-18 10:50 ` James Calligeros [this message]
2025-05-18 10:50 ` [PATCH 9/9] ASoC: apple: mca: Add delay after configuring clock James Calligeros
2025-05-20 9:20 ` (subset) [PATCH 0/9] ASoC: apple: mca: support simultaneous I2S capture on the frontend 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=20250518-mca-fixes-v1-8-ee1015a695f6@gmail.com \
--to=jcalligeros99@gmail.com \
--cc=asahi@lists.linux.dev \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=marcan@marcan.st \
--cc=perex@perex.cz \
--cc=povik+lin@cutebit.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox