Repository navigation
[RFC] dai: zephyr: request a burst, not the whole FIFO, from the DMA - #11521
mohittalwar23 wants to merge 1 commit into
Conversation
|
Can one of the admins verify this patch?
|
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 for SAI, ESAI and MICFIL burst_elems is dai_get_fifo_depth(), the whole FIFO in bytes (512 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 the request: the excess is discarded, the ring drains faster than real time and the FIFO starves. SOF's own drivers never use burst_elems raw: src/drivers/imx/edma.c halves it and src/drivers/imx/sdma.c applies burst_elems * width / 8. Only the Zephyr path forwards it unscaled. Request 6 samples per request instead, the figure Linux's fsl_sai uses on the same hardware (FSL_SAI_MAXBURST_TX/RX), and keep the caller's value when it is smaller. Effect on other DAIs, from reading the code: Intel SSP and ALH already ask for less and are unchanged; the Intel HDA DMA driver ignores the burst; Intel DMIC is capped only for blobs with BFTH >= 5. NXP SAI and ESAI over eDMA move 6 samples per minor loop instead of a whole FIFO, so dma_nxp_edma then needs block sizes that are a multiple of that. Not tested on Intel or eDMA hardware. Tested on an i.MX8MP EVK (NXP BSP Linux 6.6.52, imx8mp-evk-sof-wm8960 DTB), with and without this patch: a scale played on repeat for 2 minutes, then the headset mic looped to the headphones for 2 minutes, listening and counting xruns. - SOF main against its Zephyr pin: both sound the same, with no xruns, as nxp_sdma at that pin ignores the burst. - Against a Zephyr SDMA series that derives the SAI watermark from the burst (zephyrproject-rtos/zephyr#117960, its 64 byte clamp removed for the test): without this patch 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 both runs are clean, with no xruns. Signed-off-by: Mohit Talwar <talwarmohit2005@gmail.com>
378721d to
a622e1a
Compare
|
Updated: the code comments are one line each now, and the details are in the commit message. The code itself is unchanged. Testing, on the i.MX8MP EVK: 2 minutes of scale playback and 2 minutes of headset mic loopback, listening, with xruns counted and the DSP log checked. Both on SOF's Zephyr pin (same as without the patch) and on Zephyr with the SDMA series, where the DMA actually uses the burst (24 bytes per request): clean, 0 xruns. Without the patch, with the SDMA driver's 64-byte cap removed for the test, the SDMA moves 512 bytes per request: playback was only clicks, every aplay stopped with Input/output error, and the DSP logged about 2,500 SAI FIFO underruns in 15 s. |
|
@lgirdwood LGTM. Thanks @mohittalwar23 ! |
|
Thanks @dbaluta! I could only test on i.MX8MP (SDMA). On the eDMA platforms (i.MX8QM/QXP/93/95) this changes NBYTES to 6 samples, so if someone has one of those boards at hand, a quick playback check would be good. Same for Intel Platform. |
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