Repository navigation
[RFC] dai: zephyr: request a burst, not the whole FIFO, from the DMA - #11521
Draft
mohittalwar23 wants to merge 1 commit into
Draft
mohittalwar23 wants to merge 1 commit into
mohittalwar23 wants to merge 1 commit into
Conversation
dai_set_dma_config() assigns config->burst_elems straight into dma_config.source_burst_length. Zephyr documents that field as the bytes moved per DMA request, but burst_elems carries dai_get_fifo_depth() for SAI and friends, so the engine is asked to move a whole FIFO per request. The peripheral has nothing like that available when it raises the request, so the excess is discarded: the ring drains faster than real time while the FIFO starves. SOF's own drivers never use burst_elems raw. src/drivers/imx/edma.c halves it, "divide by two to fill the FIFO to half its size", and src/drivers/imx/sdma.c applies burst_elems * width / 8. Only the Zephyr path forwards it unscaled. Request a small fixed number of samples instead, matching the figure Linux uses on the same hardware (fsl_sai's FSL_SAI_MAXBURST_TX is 6 words), and keep the caller's value when it is smaller still. Measured on an i.MX8MP EVK, with a Zephyr SDMA driver that takes its watermark from the burst length (an out-of-tree series, its 64 byte safety clamp removed for the test). Without this change the engine is asked for 512 bytes per request, the SAI FIFO underruns continuously and every playback fails with an I/O error. With it the engine uses 24 bytes, and playback and a headset-mic loopback run clean with no xruns. The nxp_sdma driver at SOF's current Zephyr pin ignores the burst, so there both builds behave the same. Signed-off-by: Mohit Talwar <talwarmohit2005@gmail.com>
Collaborator
|
Can one of the admins verify this patch?
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RFC, from the Zephyr i.MX8MP SAI/SDMA discussion (zephyrproject-rtos/zephyr#117960),
where we were asked to raise the SOF side separately.
dai_set_dma_config()copiesconfig->burst_elemsstraight intodma_config.source_burst_length. Zephyr documents that field as the bytes moved per DMArequest. For SAI, ESAI and MICFIL, though,
burst_elemsisdai_get_fifo_depth(): thewhole FIFO in bytes (512 B for i.MX8MP SAI3). A DMA driver that honours the field is
asked to move a whole FIFO per request, more than the peripheral has ready when it raises
that request. SOF's own native drivers never forward it raw:
imx/edma.chalves it andimx/sdma.cscales it.This patch requests 6 samples per request, the figure Linux's
fsl_saiuses(
FSL_SAI_MAXBURST_TX/RX). It keeps the caller's value when that is smaller.What it changes today. Code reading only, apart from the i.MX8MP rows:
1 << BFTH→ capped at 6 × widthdma_nxp_edmathen needs block size % (6 × width) == 0dma_nxp_sdmadoesn't read the burst todayThe questions for reviewers:
source_burst_length?the burst?
Testing (i.MX8MP EVK, NXP BSP Linux 6.6.52,
imx8mp-evk-sof-wm8960). Each run playeda 12 s scale on repeat for 2 minutes, then looped the headset mic to the headphones for 2
minutes, while listening.
SOF
mainagainst its Zephyr pin, with and without this patch: they sound the same.Both were clean, with 0 xruns and no DSP warnings. A functional battery (S16/S24/S32,
periods 24/48/192/1024, capture, 8 s loopback) was also identical. That's expected,
since today's Zephyr SDMA driver ignores the burst.
Zephyr with the SDMA series from Draft upstream discussion: i.MX8MP MCUX SAI cannot use Zephyr SDMA reliably zephyrproject-rtos/zephyr#117960, which derives the SAI watermark from the
burst. For this test only, the series' 64 B clamp was removed, so the DMA uses exactly
what SOF asks for:
15 s), every
aplayfails withInput/output error, and the headphones only click;clean, with 0 xruns.
The series itself keeps the 64 B clamp until SOF settles this, so it doesn't depend on
this patch.
Not tested on Intel or on NXP eDMA platforms; I have no hardware for them.
Cc: @dbaluta @iuliana-prodan @LaurentiuM1234