[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250518-mca-fixes-v1-2-ee1015a695f6@gmail.com>
Date: Sun, 18 May 2025 20:50:47 +1000
From: James Calligeros <jcalligeros99@...il.com>
To: Martin PoviĊĦer <povik+lin@...ebit.org>,
Liam Girdwood <lgirdwood@...il.com>, Mark Brown <broonie@...nel.org>,
Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai <tiwai@...e.com>
Cc: asahi@...ts.linux.dev, linux-sound@...r.kernel.org,
linux-kernel@...r.kernel.org, James Calligeros <jcalligeros99@...il.com>
Subject: [PATCH 2/9] ASoC: apple: mca: use readx_poll_timeout to check for
cluster reset
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@...il.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
Powered by blists - more mailing lists