dmatest.rst 7.7 KB

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