dmatest.rst 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. ==============
  2. DMA Test Guide
  3. ==============
  4. Andy Shevchenko <[email protected]>
  5. This small document introduces how to test DMA drivers using dmatest module.
  6. The dmatest module tests DMA memcpy, memset, XOR and RAID6 P+Q operations using
  7. various lengths and various offsets into the source and destination buffers. It
  8. will initialize both buffers with a repeatable pattern and verify that the DMA
  9. engine copies the requested region and nothing more. It will also verify that
  10. the bytes aren't swapped around, and that the source buffer isn't modified.
  11. The dmatest module can be configured to test a specific channel. It can also
  12. test multiple channels at the same time, and it can start multiple threads
  13. competing for the same channel.
  14. .. note::
  15. The test suite works only on the channels that have at least one
  16. capability of the following: DMA_MEMCPY (memory-to-memory), DMA_MEMSET
  17. (const-to-memory or memory-to-memory, when emulated), DMA_XOR, DMA_PQ.
  18. .. note::
  19. In case of any related questions use the official mailing list
  20. [email protected].
  21. Part 1 - How to build the test module
  22. =====================================
  23. The menuconfig contains an option that could be found by following path:
  24. Device Drivers -> DMA Engine support -> DMA Test client
  25. In the configuration file the option called CONFIG_DMATEST. The dmatest could
  26. be built as module or inside kernel. Let's consider those cases.
  27. Part 2 - When dmatest is built as a module
  28. ==========================================
  29. Example of usage::
  30. % modprobe dmatest timeout=2000 iterations=1 channel=dma0chan0 run=1
  31. ...or::
  32. % modprobe dmatest
  33. % echo 2000 > /sys/module/dmatest/parameters/timeout
  34. % echo 1 > /sys/module/dmatest/parameters/iterations
  35. % echo dma0chan0 > /sys/module/dmatest/parameters/channel
  36. % echo 1 > /sys/module/dmatest/parameters/run
  37. ...or on the kernel command line::
  38. dmatest.timeout=2000 dmatest.iterations=1 dmatest.channel=dma0chan0 dmatest.run=1
  39. Example of multi-channel test usage (new in the 5.0 kernel)::
  40. % modprobe dmatest
  41. % echo 2000 > /sys/module/dmatest/parameters/timeout
  42. % echo 1 > /sys/module/dmatest/parameters/iterations
  43. % echo dma0chan0 > /sys/module/dmatest/parameters/channel
  44. % echo dma0chan1 > /sys/module/dmatest/parameters/channel
  45. % echo dma0chan2 > /sys/module/dmatest/parameters/channel
  46. % echo 1 > /sys/module/dmatest/parameters/run
  47. .. note::
  48. For all tests, starting in the 5.0 kernel, either single- or multi-channel,
  49. the channel parameter(s) must be set after all other parameters. It is at
  50. that time that the existing parameter values are acquired for use by the
  51. thread(s). All other parameters are shared. Therefore, if changes are made
  52. to any of the other parameters, and an additional channel specified, the
  53. (shared) parameters used for all threads will use the new values.
  54. After the channels are specified, each thread is set as pending. All threads
  55. begin execution when the run parameter is set to 1.
  56. .. hint::
  57. A list of available channels can be found by running the following command::
  58. % ls -1 /sys/class/dma/
  59. Once started a message like " dmatest: Added 1 threads using dma0chan0" is
  60. emitted. A thread for that specific channel is created and is now pending, the
  61. pending thread is started once run is to 1.
  62. Note that running a new test will not stop any in progress test.
  63. The following command returns the state of the test. ::
  64. % cat /sys/module/dmatest/parameters/run
  65. To wait for test completion userpace can poll 'run' until it is false, or use
  66. the wait parameter. Specifying 'wait=1' when loading the module causes module
  67. initialization to pause until a test run has completed, while reading
  68. /sys/module/dmatest/parameters/wait waits for any running test to complete
  69. before returning. For example, the following scripts wait for 42 tests
  70. to complete before exiting. Note that if 'iterations' is set to 'infinite' then
  71. waiting is disabled.
  72. Example::
  73. % modprobe dmatest run=1 iterations=42 wait=1
  74. % modprobe -r dmatest
  75. ...or::
  76. % modprobe dmatest run=1 iterations=42
  77. % cat /sys/module/dmatest/parameters/wait
  78. % modprobe -r dmatest
  79. Part 3 - When built-in in the kernel
  80. ====================================
  81. The module parameters that is supplied to the kernel command line will be used
  82. for the first performed test. After user gets a control, the test could be
  83. re-run with the same or different parameters. For the details see the above
  84. section `Part 2 - When dmatest is built as a module`_.
  85. In both cases the module parameters are used as the actual values for the test
  86. case. You always could check them at run-time by running ::
  87. % grep -H . /sys/module/dmatest/parameters/*
  88. Part 4 - Gathering the test results
  89. ===================================
  90. Test results are printed to the kernel log buffer with the format::
  91. "dmatest: result <channel>: <test id>: '<error msg>' with src_off=<val> dst_off=<val> len=<val> (<err code>)"
  92. Example of output::
  93. % dmesg | tail -n 1
  94. dmatest: result dma0chan0-copy0: #1: No errors with src_off=0x7bf dst_off=0x8ad len=0x3fea (0)
  95. The message format is unified across the different types of errors. A
  96. number in the parentheses represents additional information, e.g. error
  97. code, error counter, or status. A test thread also emits a summary line at
  98. completion listing the number of tests executed, number that failed, and a
  99. result code.
  100. Example::
  101. % dmesg | tail -n 1
  102. dmatest: dma0chan0-copy0: summary 1 test, 0 failures 1000 iops 100000 KB/s (0)
  103. The details of a data miscompare error are also emitted, but do not follow the
  104. above format.
  105. Part 5 - Handling channel allocation
  106. ====================================
  107. Allocating Channels
  108. -------------------
  109. Channels do not need to be configured prior to starting a test run. Attempting
  110. to run the test without configuring the channels will result in testing any
  111. channels that are available.
  112. Example::
  113. % echo 1 > /sys/module/dmatest/parameters/run
  114. dmatest: No channels configured, continue with any
  115. Channels are registered using the "channel" parameter. Channels can be requested by their
  116. name, once requested, the channel is registered and a pending thread is added to the test list.
  117. Example::
  118. % echo dma0chan2 > /sys/module/dmatest/parameters/channel
  119. dmatest: Added 1 threads using dma0chan2
  120. More channels can be added by repeating the example above.
  121. Reading back the channel parameter will return the name of last channel that was added successfully.
  122. Example::
  123. % echo dma0chan1 > /sys/module/dmatest/parameters/channel
  124. dmatest: Added 1 threads using dma0chan1
  125. % echo dma0chan2 > /sys/module/dmatest/parameters/channel
  126. dmatest: Added 1 threads using dma0chan2
  127. % cat /sys/module/dmatest/parameters/channel
  128. dma0chan2
  129. Another method of requesting channels is to request a channel with an empty string, Doing so
  130. will request all channels available to be tested:
  131. Example::
  132. % echo "" > /sys/module/dmatest/parameters/channel
  133. dmatest: Added 1 threads using dma0chan0
  134. dmatest: Added 1 threads using dma0chan3
  135. dmatest: Added 1 threads using dma0chan4
  136. dmatest: Added 1 threads using dma0chan5
  137. dmatest: Added 1 threads using dma0chan6
  138. dmatest: Added 1 threads using dma0chan7
  139. dmatest: Added 1 threads using dma0chan8
  140. At any point during the test configuration, reading the "test_list" parameter will
  141. print the list of currently pending tests.
  142. Example::
  143. % cat /sys/module/dmatest/parameters/test_list
  144. dmatest: 1 threads using dma0chan0
  145. dmatest: 1 threads using dma0chan3
  146. dmatest: 1 threads using dma0chan4
  147. dmatest: 1 threads using dma0chan5
  148. dmatest: 1 threads using dma0chan6
  149. dmatest: 1 threads using dma0chan7
  150. dmatest: 1 threads using dma0chan8
  151. Note: Channels will have to be configured for each test run as channel configurations do not
  152. carry across to the next test run.
  153. Releasing Channels
  154. -------------------
  155. Channels can be freed by setting run to 0.
  156. Example::
  157. % echo dma0chan1 > /sys/module/dmatest/parameters/channel
  158. dmatest: Added 1 threads using dma0chan1
  159. % cat /sys/class/dma/dma0chan1/in_use
  160. 1
  161. % echo 0 > /sys/module/dmatest/parameters/run
  162. % cat /sys/class/dma/dma0chan1/in_use
  163. 0
  164. Channels allocated by previous test runs are automatically freed when a new
  165. channel is requested after completing a successful test run.