ASoC: apple: mca: Fix final status read on SERDES reset
Subsystems (3)
Martin Povišer
maintainerPATCH 1/3 ASoC: apple: mca: Fix final status read on SERDES reset
From within the early trigger we are doing a reset of the SERDES unit, but the final status read is on a bad address. Add the missing SERDES unit offset in calculation of the address.
--- sound/soc/apple/mca.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/apple/mca.c +1 -1
@@ -210,7 +210,7 @@ static void mca_fe_early_trigger(struct snd_pcm_substream *substream, int cmd, SERDES_CONF_SOME_RST);readl_relaxed (cl->base + serdes_conf);mca_modify (cl, serdes_conf,SERDES_STATUS_RST ,0 ); -WARN_ON (readl_relaxed (cl->base +REG_SERDES_STATUS ) & +WARN_ON (readl_relaxed (cl->base + serdes_unit +REG_SERDES_STATUS ) &SERDES_STATUS_RST );break ;default :
Signature · 1 line
2.33.0
Martin Povišer
maintainerPATCH 2/3 ASoC: apple: mca: Fix SERDES reset sequence
Fix the reset sequence of reads and writes that we invoke from within the early trigger. It looks like there never was a SERDES_CONF_SOME_RST bit that should be involved in the reset sequence, and its presence in the driver code is a mistake from earlier.
Instead, the reset sequence should go as follows: We should switch the the SERDES unit's SYNC_SEL mux to the value of 7 (so outside the range of 1...6 representing cluster's SYNCGEN units), then raise the RST bit in SERDES_STATUS and wait for it to clear.
Properly resetting the SERDES unit fixes frame desynchronization hazard in case of long frames (longer than 4 used slots). The desynchronization manifests itself by rotating the PCM channels.
--- sound/soc/apple/mca.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
sound/soc/apple/mca.c +13 -5
@@ -101,7 +101,6 @@#define SERDES_CONF_UNK3 BIT(14)#define SERDES_CONF_NO_DATA_FEEDBACK BIT(15)#define SERDES_CONF_SYNC_SEL GENMASK(18, 16) -#define SERDES_CONF_SOME_RST BIT(19)#define REG_TX_SERDES_BITSTART 0x08#define REG_RX_SERDES_BITSTART 0x0c#define REG_TX_SERDES_SLOTMASK 0x0c
@@ -203,15 +202,24 @@ static void mca_fe_early_trigger(struct snd_pcm_substream *substream, int cmd,case SNDRV_PCM_TRIGGER_START :case SNDRV_PCM_TRIGGER_RESUME :case SNDRV_PCM_TRIGGER_PAUSE_RELEASE : +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 , +FIELD_PREP (SERDES_CONF_SYNC_SEL ,7 ));mca_modify (cl, serdes_unit +REG_SERDES_STATUS ,SERDES_STATUS_EN |SERDES_STATUS_RST ,SERDES_STATUS_RST ); -mca_modify (cl, serdes_conf,SERDES_CONF_SOME_RST , -SERDES_CONF_SOME_RST ); -readl_relaxed (cl->base + serdes_conf); -mca_modify (cl, serdes_conf,SERDES_STATUS_RST ,0 ); +/* +* Experiments suggest that it takes at most ~1 us +* for the bit to clear, so wait 2 us for good measure. +*/ +udelay (2 );WARN_ON (readl_relaxed (cl->base + serdes_unit +REG_SERDES_STATUS ) &SERDES_STATUS_RST ); +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 , +FIELD_PREP (SERDES_CONF_SYNC_SEL , cl->no +1 ));break ;default :break ;
Signature · 1 line
2.33.0
Martin Povišer
maintainerPATCH 3/3 ASoC: apple: mca: Improve handling of unavailable DMA channels
In reply to Martin PovišerWhen we fail to obtain a DMA channel, don't return a blanket -EINVAL, instead return the original error code if there's one. This makes deferring work as it should. Also don't print an error message for -EPROBE_DEFER.
--- sound/soc/apple/mca.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
sound/soc/apple/mca.c +9 -2
@@ -950,10 +950,17 @@ static int mca_pcm_new(struct snd_soc_component *component, chan =mca_request_dma_channel (cl, i);if (IS_ERR_OR_NULL (chan)) { +mca_pcm_free (component, rtd->pcm); + +if (chan &&PTR_ERR (chan) == -EPROBE_DEFER ) +return PTR_ERR (chan); +dev_err (component->dev,"unable to obtain DMA channel (stream %d cluster %d): %pe\n" , i, cl->no, chan); -mca_pcm_free (component, rtd->pcm); -return -EINVAL ; + +if (!chan) +return -EINVAL ; +return PTR_ERR (chan); } cl->dma_chans[i] = chan;
Signature · 1 line
2.33.0
Mark Brown
maintainerQuoted 5 lines · Martin Povišer
From within the early trigger we are doing a reset of the SERDES unit, but the final status read is on a bad address. Add the missing SERDES unit offset in calculation of the address.
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/3] ASoC: apple: mca: Fix final status read on SERDES reset
commit: aaf5f0d76b6e1870e3674408de2b13a92a4d4059
[2/3] ASoC: apple: mca: Fix SERDES reset sequence
commit: d8b3e396088d787771f19fd3b7949e080dc31d6f
[3/3] ASoC: apple: mca: Improve handling of unavailable DMA channels
commit: fb1847cc460c127b12720119eae5f438ffc62e85All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark