[PATCH RFC 0/2] mmc: jz4740: Use the integrated DMA controller on the X1600

From: Olivier Louvignes

Date: Sun Oct 25 2026 - 10:05:14 EST


The X1600's MSCs have no request lines to the system DMA controller, so
jz4740_mmc runs them in PIO. This series uses the MSC's own descriptor
DMA there instead. On a HiBy R1 (X1600, SDHC, 4-bit, 50 MHz), reads go
from 17.3 to 22.5 MB/s and writes from 13.9 to 18.2 MB/s, with the CPU
free.

It is an RFC because of how a read is known to be finished. On the
X1600:

- DMA_DATA_DONE (IFLG bit 31) never came in our tests, masked or
unmasked. Rockbox's driver for the X1000 and X1600 waits for it, with
the FIFO thresholds (CMDAT RTRG/TTRG) at 32; we tried those thresholds
only with the flags masked.
- DMAEND (IFLG bit 16) is only flagged while it is unmasked, as the
manual says. Unmasked, it came for every read we watched, including
the 8- and 64-byte register reads at card setup; MSC_STAT's DMAEND
stayed clear for the 64-byte one.
- Waiting for the DMAEND interrupt made reads very slow in a first
attempt (minutes to list a directory). We haven't found why.

So this version polls: a read is done once DMADA has reached the end of
the last segment with DMALEN at 0, or on DMAEND. Is there a completion
signal on this controller that we have missed, or is this acceptable?

Second, reads under a block (the SCR and SD status at card setup)
sometimes never raised DATA_TRAN_DONE through the DMA, and the card
setup timed out, so they stay on PIO.

Third, SDIO writes that brcmfmac glued together from several frames, in
segments that end inside a block, timed out through the DMA (CMD53,
-ETIMEDOUT) and left the bus dead, while the same writes went through PIO
cleanly. Transfers with such a segment stay on PIO.

Fourth, the X1600 manual's two descriptions of the descriptor's LINK bit
disagree. The code follows the MSC_DMACMD register table, which the
hardware matches: reads spanning several descriptors work.

The R1's Wi-Fi (brcmfmac over SDIO on the other MSC) goes through it
too: its firmware download of about 420 KB in CMD53 transfers read back
correctly, and with the rule above, 10 rounds of DNS, HTTP and ping and
three Wi-Fi off/on cycles went through cleanly.

Only the new ingenic,x1600-mmc compatible turns this on, so the other
SoCs keep their external DMA or PIO. Not tested: error paths (CRC
errors, a card pulled mid-transfer), suspend and resume.

Olivier Louvignes (2):
dt-bindings: mmc: ingenic: Add the X1600
mmc: jz4740: Use the integrated DMA controller on the X1600

.../devicetree/bindings/mmc/ingenic,mmc.yaml | 3 +
drivers/mmc/host/jz4740_mmc.c | 182 ++++++++++++++++--
2 files changed, 174 insertions(+), 11 deletions(-)


base-commit: fd9af27f6c2319713bb23832066585f8a59a1771
--
2.39.5