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 3/9] ASoC: apple: mca: Move clock shutdown to backend shutdown
Date: Sun, 18 May 2025 20:50:48 +1000 [thread overview]
Message-ID: <20250518-mca-fixes-v1-3-ee1015a695f6@gmail.com> (raw)
In-Reply-To: <20250518-mca-fixes-v1-0-ee1015a695f6@gmail.com>
From: Hector Martin <marcan@marcan.st>
Codecs are set to mute after hw_free, so yanking the clock out from
under them in hw_free leads to breakage. Move the clock shutdown to the
shutdown op, which is late enough.
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
---
sound/soc/apple/mca.c | 48 +++++++++++--------------
1 file changed, 20 insertions(+), 28 deletions(-)
diff --git a/sound/soc/apple/mca.c b/sound/soc/apple/mca.c
index 7113da4bdea7b687c0d44d2bbf3a511b8299056f..69f2e852d4aeb2d53eea5d7fee400b2337a09065 100644
--- a/sound/soc/apple/mca.c
+++ b/sound/soc/apple/mca.c
@@ -361,33 +361,6 @@ static int mca_be_prepare(struct snd_pcm_substream *substream,
return 0;
}
-static int mca_be_hw_free(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;
-
- if (cl->port_driver < 0)
- return -EINVAL;
-
- /*
- * We are operating on a foreign cluster here, but since we
- * belong to the same PCM, accesses should have been
- * synchronized at ASoC level.
- */
- fe_cl = &mca->clusters[cl->port_driver];
- if (!mca_fe_clocks_in_use(fe_cl))
- return 0; /* Nothing to do */
-
- cl->clocks_in_use[substream->stream] = false;
-
- if (!mca_fe_clocks_in_use(fe_cl))
- mca_fe_disable_clocks(fe_cl);
-
- return 0;
-}
-
static unsigned int mca_crop_mask(unsigned int mask, int nchans)
{
while (hweight32(mask) > nchans)
@@ -785,6 +758,26 @@ static void mca_be_shutdown(struct snd_pcm_substream *substream,
struct mca_cluster *cl = mca_dai_to_cluster(dai);
struct mca_data *mca = cl->host;
+ if (cl->clocks_in_use[substream->stream] &&
+ !WARN_ON(cl->port_driver < 0)) {
+ struct mca_cluster *fe_cl = &mca->clusters[cl->port_driver];
+
+ /*
+ * Typically the CODECs we are paired with will require clocks
+ * to be present at time of mute with the 'mute_stream' op.
+ * We need to disable the clocks here at the earliest (hw_free
+ * would be too early).
+ *
+ * We are operating on a foreign cluster here, but since we
+ * belong to the same PCM, accesses should have been
+ * synchronized at ASoC level.
+ */
+ cl->clocks_in_use[substream->stream] = false;
+
+ if (!mca_fe_clocks_in_use(fe_cl))
+ mca_fe_disable_clocks(fe_cl);
+ }
+
cl->port_started[substream->stream] = false;
if (!mca_be_started(cl)) {
@@ -802,7 +795,6 @@ static void mca_be_shutdown(struct snd_pcm_substream *substream,
static const struct snd_soc_dai_ops mca_be_ops = {
.prepare = mca_be_prepare,
- .hw_free = mca_be_hw_free,
.startup = mca_be_startup,
.shutdown = mca_be_shutdown,
};
--
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 ` James Calligeros [this message]
2025-05-19 10:38 ` [PATCH 3/9] ASoC: apple: mca: Move clock shutdown to backend shutdown 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 ` [PATCH 8/9] ASoC: apple: mca: Do not mark clocks in use for non-providers James Calligeros
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-3-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