Tests:SDHI-DMA-Sync

From eLinux.org
Revision as of 10:31, 15 February 2017 by W sang (talk | contribs) (initial version)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This document describes how to test for SDHI that both, DMA transfer and SD access, have properly completed before continuing.

Setup

Kernel Version and Configuration

Support for this feature is expected to land upstream in v4.13. It is currently available in a topic branch:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git renesas/topic/sdhi-dma-sync

It is critical that CONFIG_MMC_SDHI is enabled for these tests. All debug messages examined in this test are automatically created during boot. There is no need to trigger the messages by some event.

Hardware Environment

  • Lager/r8a7790 (R-Car H2 SoC) with a microSD card inserted into CN8 (SDHI0)

Testing

without DEBUG

By default, debug messages are disabled, so one shouldn't notice a difference under any workload although the underlying synchronization mechanisms have changed. For this report, multiple terabyte have been written to and read from various cards using the following commands.

Write:

dd if=/dev/urandom of=/dev/mmcblk1 bs=64k count=946 conv=fsync

Read:

dd if=/dev/mmcblk1 of=/tmp/a bs=64k count=946 conv=fsync

Note: These examples access a 64MB card. For bigger cards, you might want to adjust the bs and count paramteres of the dd command.

with DEBUG

To verify that synchronization works, we need to enable DEBUG. It is not recommended to use CONFIG_MMC_DEBUG because it will create too many log messages. It is recommended to add to the top of the file drivers/mmc/host/tmio_mmc_dma.c the following line and recompile:

#define DEBUG

With an SD card insterted during boot, you can see two types of patterns for the log messages.

sh_mobile_sdhi ee100000.sd: DMA complete (0x40000400)
sh_mobile_sdhi ee100000.sd: DATAEND complete (0x20800400)

The hex values are the status bits of the SDHI core. This case is the "DMA is first" case. When DMA is complete, the CBUSY bit is still set, so access to the card is ongoing (0x4xxxxxxx). After the dma_dataend completion returns, CBUSY is cleared and SCLKDIVEN is set (0x2xxxxxxx), so the access has ended and we can continue.

sh_mobile_sdhi ee100000.sd: DMA complete (0x20800400)
sh_mobile_sdhi ee100000.sd: DATAEND complete (0x20800400)

This is the "DATAEND first" case. When DMA completes, the status bits already indicate that CBUSY is cleared(0x2xxxxxxx). The dma_dataend completion will immediately return and we can continue.

Conclusion

It could be demonstrated that the above topic branch synchronizes the completion of DMA and termination of SD card access before continuing a transfer. Regardless which of the two events come first, a consistent state is reached before continuing.

Remark

The original problem with synchronization was reported in connection with an SDIO card and CMD53. This exact scenario could not be recreated since SDIO seems to be non-functional on the Lager board. This needs to be investigated but is a seperate issue.