233 lines · plain
1==============2DMA Test Guide3==============4 5Andy Shevchenko <andriy.shevchenko@linux.intel.com>6 7This small document introduces how to test DMA drivers using dmatest module.8 9The dmatest module tests DMA memcpy, memset, XOR and RAID6 P+Q operations using10various lengths and various offsets into the source and destination buffers. It11will initialize both buffers with a repeatable pattern and verify that the DMA12engine copies the requested region and nothing more. It will also verify that13the bytes aren't swapped around, and that the source buffer isn't modified.14 15The dmatest module can be configured to test a specific channel. It can also16test multiple channels at the same time, and it can start multiple threads17competing for the same channel.18 19.. note::20 The test suite works only on the channels that have at least one21 capability of the following: DMA_MEMCPY (memory-to-memory), DMA_MEMSET22 (const-to-memory or memory-to-memory, when emulated), DMA_XOR, DMA_PQ.23 24.. note::25 In case of any related questions use the official mailing list26 dmaengine@vger.kernel.org.27 28Part 1 - How to build the test module29=====================================30 31The menuconfig contains an option that could be found by following path:32 33 Device Drivers -> DMA Engine support -> DMA Test client34 35In the configuration file the option called CONFIG_DMATEST. The dmatest could36be built as module or inside kernel. Let's consider those cases.37 38Part 2 - When dmatest is built as a module39==========================================40 41Example of usage::42 43 % modprobe dmatest timeout=2000 iterations=1 channel=dma0chan0 run=144 45...or::46 47 % modprobe dmatest48 % echo 2000 > /sys/module/dmatest/parameters/timeout49 % echo 1 > /sys/module/dmatest/parameters/iterations50 % echo dma0chan0 > /sys/module/dmatest/parameters/channel51 % echo 1 > /sys/module/dmatest/parameters/run52 53...or on the kernel command line::54 55 dmatest.timeout=2000 dmatest.iterations=1 dmatest.channel=dma0chan0 dmatest.run=156 57Example of multi-channel test usage (new in the 5.0 kernel)::58 59 % modprobe dmatest60 % echo 2000 > /sys/module/dmatest/parameters/timeout61 % echo 1 > /sys/module/dmatest/parameters/iterations62 % echo dma0chan0 > /sys/module/dmatest/parameters/channel63 % echo dma0chan1 > /sys/module/dmatest/parameters/channel64 % echo dma0chan2 > /sys/module/dmatest/parameters/channel65 % echo 1 > /sys/module/dmatest/parameters/run66 67.. note::68 For all tests, starting in the 5.0 kernel, either single- or multi-channel,69 the channel parameter(s) must be set after all other parameters. It is at70 that time that the existing parameter values are acquired for use by the71 thread(s). All other parameters are shared. Therefore, if changes are made72 to any of the other parameters, and an additional channel specified, the73 (shared) parameters used for all threads will use the new values.74 After the channels are specified, each thread is set as pending. All threads75 begin execution when the run parameter is set to 1.76 77.. hint::78 A list of available channels can be found by running the following command::79 80 % ls -1 /sys/class/dma/81 82Once started a message like " dmatest: Added 1 threads using dma0chan0" is83emitted. A thread for that specific channel is created and is now pending, the84pending thread is started once run is to 1.85 86Note that running a new test will not stop any in progress test.87 88The following command returns the state of the test. ::89 90 % cat /sys/module/dmatest/parameters/run91 92To wait for test completion userspace can poll 'run' until it is false, or use93the wait parameter. Specifying 'wait=1' when loading the module causes module94initialization to pause until a test run has completed, while reading95/sys/module/dmatest/parameters/wait waits for any running test to complete96before returning. For example, the following scripts wait for 42 tests97to complete before exiting. Note that if 'iterations' is set to 'infinite' then98waiting is disabled.99 100Example::101 102 % modprobe dmatest run=1 iterations=42 wait=1103 % modprobe -r dmatest104 105...or::106 107 % modprobe dmatest run=1 iterations=42108 % cat /sys/module/dmatest/parameters/wait109 % modprobe -r dmatest110 111Part 3 - When built-in in the kernel112====================================113 114The module parameters that is supplied to the kernel command line will be used115for the first performed test. After user gets a control, the test could be116re-run with the same or different parameters. For the details see the above117section `Part 2 - When dmatest is built as a module`_.118 119In both cases the module parameters are used as the actual values for the test120case. You always could check them at run-time by running ::121 122 % grep -H . /sys/module/dmatest/parameters/*123 124Part 4 - Gathering the test results125===================================126 127Test results are printed to the kernel log buffer with the format::128 129 "dmatest: result <channel>: <test id>: '<error msg>' with src_off=<val> dst_off=<val> len=<val> (<err code>)"130 131Example of output::132 133 % dmesg | tail -n 1134 dmatest: result dma0chan0-copy0: #1: No errors with src_off=0x7bf dst_off=0x8ad len=0x3fea (0)135 136The message format is unified across the different types of errors. A137number in the parentheses represents additional information, e.g. error138code, error counter, or status. A test thread also emits a summary line at139completion listing the number of tests executed, number that failed, and a140result code.141 142Example::143 144 % dmesg | tail -n 1145 dmatest: dma0chan0-copy0: summary 1 test, 0 failures 1000 iops 100000 KB/s (0)146 147The details of a data miscompare error are also emitted, but do not follow the148above format.149 150Part 5 - Handling channel allocation151====================================152 153Allocating Channels154-------------------155 156Channels do not need to be configured prior to starting a test run. Attempting157to run the test without configuring the channels will result in testing any158channels that are available.159 160Example::161 162 % echo 1 > /sys/module/dmatest/parameters/run163 dmatest: No channels configured, continue with any164 165Channels are registered using the "channel" parameter. Channels can be requested by their166name, once requested, the channel is registered and a pending thread is added to the test list.167 168Example::169 170 % echo dma0chan2 > /sys/module/dmatest/parameters/channel171 dmatest: Added 1 threads using dma0chan2172 173More channels can be added by repeating the example above.174Reading back the channel parameter will return the name of last channel that was added successfully.175 176Example::177 178 % echo dma0chan1 > /sys/module/dmatest/parameters/channel179 dmatest: Added 1 threads using dma0chan1180 % echo dma0chan2 > /sys/module/dmatest/parameters/channel181 dmatest: Added 1 threads using dma0chan2182 % cat /sys/module/dmatest/parameters/channel183 dma0chan2184 185Another method of requesting channels is to request a channel with an empty string, Doing so186will request all channels available to be tested:187 188Example::189 190 % echo "" > /sys/module/dmatest/parameters/channel191 dmatest: Added 1 threads using dma0chan0192 dmatest: Added 1 threads using dma0chan3193 dmatest: Added 1 threads using dma0chan4194 dmatest: Added 1 threads using dma0chan5195 dmatest: Added 1 threads using dma0chan6196 dmatest: Added 1 threads using dma0chan7197 dmatest: Added 1 threads using dma0chan8198 199At any point during the test configuration, reading the "test_list" parameter will200print the list of currently pending tests.201 202Example::203 204 % cat /sys/module/dmatest/parameters/test_list205 dmatest: 1 threads using dma0chan0206 dmatest: 1 threads using dma0chan3207 dmatest: 1 threads using dma0chan4208 dmatest: 1 threads using dma0chan5209 dmatest: 1 threads using dma0chan6210 dmatest: 1 threads using dma0chan7211 dmatest: 1 threads using dma0chan8212 213Note: Channels will have to be configured for each test run as channel configurations do not214carry across to the next test run.215 216Releasing Channels217-------------------218 219Channels can be freed by setting run to 0.220 221Example::222 223 % echo dma0chan1 > /sys/module/dmatest/parameters/channel224 dmatest: Added 1 threads using dma0chan1225 % cat /sys/class/dma/dma0chan1/in_use226 1227 % echo 0 > /sys/module/dmatest/parameters/run228 % cat /sys/class/dma/dma0chan1/in_use229 0230 231Channels allocated by previous test runs are automatically freed when a new232channel is requested after completing a successful test run.233