Tests:I2C-core-DMA
!SUPER EARLY DRAFT!
This document describes how to test that the Linux I2C core properly handles DMA buffers. The I2C IP cores of a Renesas R-Car M3-W serve as examples here.
Contents
Setup
Kernel Version and Configuration
Support for this feature is expected to land upstream in v4.14. It is currently available in a topic branch:
git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git renesas/topic/i2c-core-dma
The following kernel options need to be set in addition to the defconfig:
CONFIG_DMA_API_DEBUG=y
Hardware Environment
- Salvator-X/r8a7796 (R-Car M3-W SoC)
Software Environment
Besides a busybox, the i2cdump utility from the i2c-tools package is needed.
Testing
We use the following command to to trigger DMA:
i2cdump -y -f 2 0x10 i # I2C/i2c-rcar i2cdump -y -f 7 0x50 i # IIC_DVFS/i2c-sh_mobile
before this task
Preparations
Use the following command to get a Kernel without the I2C core DMA improvements, but with some DMA fixes for R-Car Gen3 I2C/IIC:
$ git checkout eec50514b00477 Note: checking out 'eec50514b00477'. ... HEAD is now at eec50514b00477... arm64: dts: r8a7796: add DMA for IIC_DVFS
IIC_DVFS/i2c-sh_mobile
Triggering an I2C access with DMA gives a stack dump:
# i2cdump -y -f 7 0x50 i rcar-dmac e6700000.dma-controller: DMA-API: device driver maps memory from stack [addr=ffffffc636997cb0] ------------[ cut here ]------------ WARNING: CPU: 0 PID: 877 at lib/dma-debug.c:1188 check_for_stack+0xb0/0x100 ...
I2C/i2c-rcar
This driver suffers from the same problem, yet DMA-DEBUG does not trigger. i2c-rcar maps new DMA buffers in interrupt context where likely a different task stack is in use. DMA-DEBUG can only detect stack usage from the current task. Still, the problem is present for i2c-rcar, too.