1*4882a593Smuzhiyun============== 2*4882a593SmuzhiyunDMA Test Guide 3*4882a593Smuzhiyun============== 4*4882a593Smuzhiyun 5*4882a593SmuzhiyunAndy Shevchenko <andriy.shevchenko@linux.intel.com> 6*4882a593Smuzhiyun 7*4882a593SmuzhiyunThis small document introduces how to test DMA drivers using dmatest module. 8*4882a593Smuzhiyun 9*4882a593Smuzhiyun.. note:: 10*4882a593Smuzhiyun The test suite works only on the channels that have at least one 11*4882a593Smuzhiyun capability of the following: DMA_MEMCPY (memory-to-memory), DMA_MEMSET 12*4882a593Smuzhiyun (const-to-memory or memory-to-memory, when emulated), DMA_XOR, DMA_PQ. 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun.. note:: 15*4882a593Smuzhiyun In case of any related questions use the official mailing list 16*4882a593Smuzhiyun dmaengine@vger.kernel.org. 17*4882a593Smuzhiyun 18*4882a593SmuzhiyunPart 1 - How to build the test module 19*4882a593Smuzhiyun===================================== 20*4882a593Smuzhiyun 21*4882a593SmuzhiyunThe menuconfig contains an option that could be found by following path: 22*4882a593Smuzhiyun 23*4882a593Smuzhiyun Device Drivers -> DMA Engine support -> DMA Test client 24*4882a593Smuzhiyun 25*4882a593SmuzhiyunIn the configuration file the option called CONFIG_DMATEST. The dmatest could 26*4882a593Smuzhiyunbe built as module or inside kernel. Let's consider those cases. 27*4882a593Smuzhiyun 28*4882a593SmuzhiyunPart 2 - When dmatest is built as a module 29*4882a593Smuzhiyun========================================== 30*4882a593Smuzhiyun 31*4882a593SmuzhiyunExample of usage:: 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun % modprobe dmatest timeout=2000 iterations=1 channel=dma0chan0 run=1 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun...or:: 36*4882a593Smuzhiyun 37*4882a593Smuzhiyun % modprobe dmatest 38*4882a593Smuzhiyun % echo 2000 > /sys/module/dmatest/parameters/timeout 39*4882a593Smuzhiyun % echo 1 > /sys/module/dmatest/parameters/iterations 40*4882a593Smuzhiyun % echo dma0chan0 > /sys/module/dmatest/parameters/channel 41*4882a593Smuzhiyun % echo 1 > /sys/module/dmatest/parameters/run 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun...or on the kernel command line:: 44*4882a593Smuzhiyun 45*4882a593Smuzhiyun dmatest.timeout=2000 dmatest.iterations=1 dmatest.channel=dma0chan0 dmatest.run=1 46*4882a593Smuzhiyun 47*4882a593SmuzhiyunExample of multi-channel test usage (new in the 5.0 kernel):: 48*4882a593Smuzhiyun 49*4882a593Smuzhiyun % modprobe dmatest 50*4882a593Smuzhiyun % echo 2000 > /sys/module/dmatest/parameters/timeout 51*4882a593Smuzhiyun % echo 1 > /sys/module/dmatest/parameters/iterations 52*4882a593Smuzhiyun % echo dma0chan0 > /sys/module/dmatest/parameters/channel 53*4882a593Smuzhiyun % echo dma0chan1 > /sys/module/dmatest/parameters/channel 54*4882a593Smuzhiyun % echo dma0chan2 > /sys/module/dmatest/parameters/channel 55*4882a593Smuzhiyun % echo 1 > /sys/module/dmatest/parameters/run 56*4882a593Smuzhiyun 57*4882a593Smuzhiyun.. note:: 58*4882a593Smuzhiyun For all tests, starting in the 5.0 kernel, either single- or multi-channel, 59*4882a593Smuzhiyun the channel parameter(s) must be set after all other parameters. It is at 60*4882a593Smuzhiyun that time that the existing parameter values are acquired for use by the 61*4882a593Smuzhiyun thread(s). All other parameters are shared. Therefore, if changes are made 62*4882a593Smuzhiyun to any of the other parameters, and an additional channel specified, the 63*4882a593Smuzhiyun (shared) parameters used for all threads will use the new values. 64*4882a593Smuzhiyun After the channels are specified, each thread is set as pending. All threads 65*4882a593Smuzhiyun begin execution when the run parameter is set to 1. 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun.. hint:: 68*4882a593Smuzhiyun A list of available channels can be found by running the following command:: 69*4882a593Smuzhiyun 70*4882a593Smuzhiyun % ls -1 /sys/class/dma/ 71*4882a593Smuzhiyun 72*4882a593SmuzhiyunOnce started a message like " dmatest: Added 1 threads using dma0chan0" is 73*4882a593Smuzhiyunemitted. A thread for that specific channel is created and is now pending, the 74*4882a593Smuzhiyunpending thread is started once run is to 1. 75*4882a593Smuzhiyun 76*4882a593SmuzhiyunNote that running a new test will not stop any in progress test. 77*4882a593Smuzhiyun 78*4882a593SmuzhiyunThe following command returns the state of the test. :: 79*4882a593Smuzhiyun 80*4882a593Smuzhiyun % cat /sys/module/dmatest/parameters/run 81*4882a593Smuzhiyun 82*4882a593SmuzhiyunTo wait for test completion userpace can poll 'run' until it is false, or use 83*4882a593Smuzhiyunthe wait parameter. Specifying 'wait=1' when loading the module causes module 84*4882a593Smuzhiyuninitialization to pause until a test run has completed, while reading 85*4882a593Smuzhiyun/sys/module/dmatest/parameters/wait waits for any running test to complete 86*4882a593Smuzhiyunbefore returning. For example, the following scripts wait for 42 tests 87*4882a593Smuzhiyunto complete before exiting. Note that if 'iterations' is set to 'infinite' then 88*4882a593Smuzhiyunwaiting is disabled. 89*4882a593Smuzhiyun 90*4882a593SmuzhiyunExample:: 91*4882a593Smuzhiyun 92*4882a593Smuzhiyun % modprobe dmatest run=1 iterations=42 wait=1 93*4882a593Smuzhiyun % modprobe -r dmatest 94*4882a593Smuzhiyun 95*4882a593Smuzhiyun...or:: 96*4882a593Smuzhiyun 97*4882a593Smuzhiyun % modprobe dmatest run=1 iterations=42 98*4882a593Smuzhiyun % cat /sys/module/dmatest/parameters/wait 99*4882a593Smuzhiyun % modprobe -r dmatest 100*4882a593Smuzhiyun 101*4882a593SmuzhiyunPart 3 - When built-in in the kernel 102*4882a593Smuzhiyun==================================== 103*4882a593Smuzhiyun 104*4882a593SmuzhiyunThe module parameters that is supplied to the kernel command line will be used 105*4882a593Smuzhiyunfor the first performed test. After user gets a control, the test could be 106*4882a593Smuzhiyunre-run with the same or different parameters. For the details see the above 107*4882a593Smuzhiyunsection `Part 2 - When dmatest is built as a module`_. 108*4882a593Smuzhiyun 109*4882a593SmuzhiyunIn both cases the module parameters are used as the actual values for the test 110*4882a593Smuzhiyuncase. You always could check them at run-time by running :: 111*4882a593Smuzhiyun 112*4882a593Smuzhiyun % grep -H . /sys/module/dmatest/parameters/* 113*4882a593Smuzhiyun 114*4882a593SmuzhiyunPart 4 - Gathering the test results 115*4882a593Smuzhiyun=================================== 116*4882a593Smuzhiyun 117*4882a593SmuzhiyunTest results are printed to the kernel log buffer with the format:: 118*4882a593Smuzhiyun 119*4882a593Smuzhiyun "dmatest: result <channel>: <test id>: '<error msg>' with src_off=<val> dst_off=<val> len=<val> (<err code>)" 120*4882a593Smuzhiyun 121*4882a593SmuzhiyunExample of output:: 122*4882a593Smuzhiyun 123*4882a593Smuzhiyun % dmesg | tail -n 1 124*4882a593Smuzhiyun dmatest: result dma0chan0-copy0: #1: No errors with src_off=0x7bf dst_off=0x8ad len=0x3fea (0) 125*4882a593Smuzhiyun 126*4882a593SmuzhiyunThe message format is unified across the different types of errors. A 127*4882a593Smuzhiyunnumber in the parentheses represents additional information, e.g. error 128*4882a593Smuzhiyuncode, error counter, or status. A test thread also emits a summary line at 129*4882a593Smuzhiyuncompletion listing the number of tests executed, number that failed, and a 130*4882a593Smuzhiyunresult code. 131*4882a593Smuzhiyun 132*4882a593SmuzhiyunExample:: 133*4882a593Smuzhiyun 134*4882a593Smuzhiyun % dmesg | tail -n 1 135*4882a593Smuzhiyun dmatest: dma0chan0-copy0: summary 1 test, 0 failures 1000 iops 100000 KB/s (0) 136*4882a593Smuzhiyun 137*4882a593SmuzhiyunThe details of a data miscompare error are also emitted, but do not follow the 138*4882a593Smuzhiyunabove format. 139*4882a593Smuzhiyun 140*4882a593SmuzhiyunPart 5 - Handling channel allocation 141*4882a593Smuzhiyun==================================== 142*4882a593Smuzhiyun 143*4882a593SmuzhiyunAllocating Channels 144*4882a593Smuzhiyun------------------- 145*4882a593Smuzhiyun 146*4882a593SmuzhiyunChannels do not need to be configured prior to starting a test run. Attempting 147*4882a593Smuzhiyunto run the test without configuring the channels will result in testing any 148*4882a593Smuzhiyunchannels that are available. 149*4882a593Smuzhiyun 150*4882a593SmuzhiyunExample:: 151*4882a593Smuzhiyun 152*4882a593Smuzhiyun % echo 1 > /sys/module/dmatest/parameters/run 153*4882a593Smuzhiyun dmatest: No channels configured, continue with any 154*4882a593Smuzhiyun 155*4882a593SmuzhiyunChannels are registered using the "channel" parameter. Channels can be requested by their 156*4882a593Smuzhiyunname, once requested, the channel is registered and a pending thread is added to the test list. 157*4882a593Smuzhiyun 158*4882a593SmuzhiyunExample:: 159*4882a593Smuzhiyun 160*4882a593Smuzhiyun % echo dma0chan2 > /sys/module/dmatest/parameters/channel 161*4882a593Smuzhiyun dmatest: Added 1 threads using dma0chan2 162*4882a593Smuzhiyun 163*4882a593SmuzhiyunMore channels can be added by repeating the example above. 164*4882a593SmuzhiyunReading back the channel parameter will return the name of last channel that was added successfully. 165*4882a593Smuzhiyun 166*4882a593SmuzhiyunExample:: 167*4882a593Smuzhiyun 168*4882a593Smuzhiyun % echo dma0chan1 > /sys/module/dmatest/parameters/channel 169*4882a593Smuzhiyun dmatest: Added 1 threads using dma0chan1 170*4882a593Smuzhiyun % echo dma0chan2 > /sys/module/dmatest/parameters/channel 171*4882a593Smuzhiyun dmatest: Added 1 threads using dma0chan2 172*4882a593Smuzhiyun % cat /sys/module/dmatest/parameters/channel 173*4882a593Smuzhiyun dma0chan2 174*4882a593Smuzhiyun 175*4882a593SmuzhiyunAnother method of requesting channels is to request a channel with an empty string, Doing so 176*4882a593Smuzhiyunwill request all channels available to be tested: 177*4882a593Smuzhiyun 178*4882a593SmuzhiyunExample:: 179*4882a593Smuzhiyun 180*4882a593Smuzhiyun % echo "" > /sys/module/dmatest/parameters/channel 181*4882a593Smuzhiyun dmatest: Added 1 threads using dma0chan0 182*4882a593Smuzhiyun dmatest: Added 1 threads using dma0chan3 183*4882a593Smuzhiyun dmatest: Added 1 threads using dma0chan4 184*4882a593Smuzhiyun dmatest: Added 1 threads using dma0chan5 185*4882a593Smuzhiyun dmatest: Added 1 threads using dma0chan6 186*4882a593Smuzhiyun dmatest: Added 1 threads using dma0chan7 187*4882a593Smuzhiyun dmatest: Added 1 threads using dma0chan8 188*4882a593Smuzhiyun 189*4882a593SmuzhiyunAt any point during the test configuration, reading the "test_list" parameter will 190*4882a593Smuzhiyunprint the list of currently pending tests. 191*4882a593Smuzhiyun 192*4882a593SmuzhiyunExample:: 193*4882a593Smuzhiyun 194*4882a593Smuzhiyun % cat /sys/module/dmatest/parameters/test_list 195*4882a593Smuzhiyun dmatest: 1 threads using dma0chan0 196*4882a593Smuzhiyun dmatest: 1 threads using dma0chan3 197*4882a593Smuzhiyun dmatest: 1 threads using dma0chan4 198*4882a593Smuzhiyun dmatest: 1 threads using dma0chan5 199*4882a593Smuzhiyun dmatest: 1 threads using dma0chan6 200*4882a593Smuzhiyun dmatest: 1 threads using dma0chan7 201*4882a593Smuzhiyun dmatest: 1 threads using dma0chan8 202*4882a593Smuzhiyun 203*4882a593SmuzhiyunNote: Channels will have to be configured for each test run as channel configurations do not 204*4882a593Smuzhiyuncarry across to the next test run. 205*4882a593Smuzhiyun 206*4882a593SmuzhiyunReleasing Channels 207*4882a593Smuzhiyun------------------- 208*4882a593Smuzhiyun 209*4882a593SmuzhiyunChannels can be freed by setting run to 0. 210*4882a593Smuzhiyun 211*4882a593SmuzhiyunExample:: 212*4882a593Smuzhiyun 213*4882a593Smuzhiyun % echo dma0chan1 > /sys/module/dmatest/parameters/channel 214*4882a593Smuzhiyun dmatest: Added 1 threads using dma0chan1 215*4882a593Smuzhiyun % cat /sys/class/dma/dma0chan1/in_use 216*4882a593Smuzhiyun 1 217*4882a593Smuzhiyun % echo 0 > /sys/module/dmatest/parameters/run 218*4882a593Smuzhiyun % cat /sys/class/dma/dma0chan1/in_use 219*4882a593Smuzhiyun 0 220*4882a593Smuzhiyun 221*4882a593SmuzhiyunChannels allocated by previous test runs are automatically freed when a new 222*4882a593Smuzhiyunchannel is requested after completing a successful test run. 223