Skip to content

[RFC] dai: zephyr: request a burst, not the whole FIFO, from the DMA - #11521

Draft
mohittalwar23 wants to merge 1 commit into
thesofproject:mainfrom
mohittalwar23:rfc/dai-zephyr-burst
Draft

mohittalwar23 wants to merge 1 commit into
thesofproject:mainfrom
mohittalwar23:rfc/dai-zephyr-burst

Conversation

@mohittalwar23

Copy link
Copy Markdown

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() copies config->burst_elems straight into
dma_config.source_burst_length. Zephyr documents that field as the bytes moved per DMA
request. For SAI, ESAI and MICFIL, though, burst_elems is dai_get_fifo_depth(): the
whole 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.c halves it and
imx/sdma.c scales it.

This patch requests 6 samples per request, the figure Linux's fsl_sai uses
(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:

DAI / DMA Before → after Effect
Intel SSP, ALH 2 / 4 → unchanged none
Intel HDA 8 → 6 × width none: the HDA DMA driver ignores burst
Intel DMIC 1 << BFTH → capped at 6 × width only for blobs with BFTH ≥ 5, and only where GPDMA serves DMIC
NXP SAI/ESAI over eDMA (i.MX8QM/QXP/8ULP/93/95) FIFO bytes → 6 × width NBYTES drops; dma_nxp_edma then needs block size % (6 × width) == 0
NXP SAI over SDMA (i.MX8MP) 512 → 24 (S32) none yet: Zephyr's dma_nxp_sdma doesn't read the burst today

The questions for reviewers:

  1. Is "bytes per request" the contract SOF should follow for source_burst_length?
  2. Should this apply to every DAI, or only where the DMA driver derives a watermark from
    the burst?
  3. Is the eDMA NBYTES change acceptable, or should eDMA keep its current value?

Testing (i.MX8MP EVK, NXP BSP Linux 6.6.52, imx8mp-evk-sof-wm8960). Each run played
a 12 s scale on repeat for 2 minutes, then looped the headset mic to the headphones for 2
minutes, while listening.

  • SOF main against 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:

    • without this patch: the SAI FIFO underruns continuously (about 2,500 warnings in
      15 s), every aplay fails with Input/output error, and the headphones only click;
    • with it: the DMA uses a 24 B watermark, and the scale and the mic loop are both
      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

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>
@sofci

sofci commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

reply test this please to run this test once

@mohittalwar23 mohittalwar23 changed the title dai: zephyr: request a burst, not the whole FIFO, from the DMA [RFC] dai: zephyr: request a burst, not the whole FIFO, from the DMA Nov 22, 2026

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, @dbaluta @thesofproject/nxp needs your approvals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants