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,
James Calligeros <jcalligeros99@gmail.com>
Subject: [PATCH 2/9] ASoC: apple: mca: use readx_poll_timeout to check for cluster reset
Date: Sun, 18 May 2025 20:50:47 +1000 [thread overview]
Message-ID: <20250518-mca-fixes-v1-2-ee1015a695f6@gmail.com> (raw)
In-Reply-To: <20250518-mca-fixes-v1-0-ee1015a695f6@gmail.com>
MCA clusters should take no longer than 1 microsecond to reset, however
it has been observed to take longer on very rare occasions.
Rather than just add an unreasonably long usleep(), use readx_poll_timeout
to poll the status register for a clear reset bit. This lets us have a
very safe maximum wait time, but continue early if we are ready to do so.
Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
---
sound/soc/apple/mca.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/sound/soc/apple/mca.c b/sound/soc/apple/mca.c
index 5dd24ab90d0f052bb48f451cf009dc2e9128014d..7113da4bdea7b687c0d44d2bbf3a511b8299056f 100644
--- a/sound/soc/apple/mca.c
+++ b/sound/soc/apple/mca.c
@@ -24,6 +24,7 @@
#include <linux/clk.h>
#include <linux/dma-mapping.h>
#include <linux/init.h>
+#include <linux/iopoll.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
@@ -197,6 +198,7 @@ static void mca_fe_early_trigger(struct snd_pcm_substream *substream, int cmd,
int serdes_unit = is_tx ? CLUSTER_TX_OFF : CLUSTER_RX_OFF;
int serdes_conf =
serdes_unit + (is_tx ? REG_TX_SERDES_CONF : REG_RX_SERDES_CONF);
+ int ret, status;
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
@@ -211,11 +213,15 @@ static void mca_fe_early_trigger(struct snd_pcm_substream *substream, int cmd,
SERDES_STATUS_RST);
/*
* Experiments suggest that it takes at most ~1 us
- * for the bit to clear, so wait 2 us for good measure.
+ * for the bit to clear, however this has been seen to fail.
+ * Wait up to 50 us for the reset bit to clear.
*/
- udelay(2);
- WARN_ON(readl_relaxed(cl->base + serdes_unit + REG_SERDES_STATUS) &
- SERDES_STATUS_RST);
+ ret = readx_poll_timeout(readl_relaxed,
+ cl->base + serdes_unit + REG_SERDES_STATUS,
+ status, !(status & SERDES_STATUS_RST), 2, 50);
+ if (ret || (status & SERDES_STATUS_RST))
+ dev_warn(cl->host->dev, "MCA cluster failed to reset\n");
+
mca_modify(cl, serdes_conf, SERDES_CONF_SYNC_SEL,
FIELD_PREP(SERDES_CONF_SYNC_SEL, 0));
mca_modify(cl, serdes_conf, SERDES_CONF_SYNC_SEL,
--
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 ` James Calligeros [this message]
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 ` [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-2-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=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