vkms.rst 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. .. _vkms:
  2. ==========================================
  3. drm/vkms Virtual Kernel Modesetting
  4. ==========================================
  5. .. kernel-doc:: drivers/gpu/drm/vkms/vkms_drv.c
  6. :doc: vkms (Virtual Kernel Modesetting)
  7. Setup
  8. =====
  9. The VKMS driver can be setup with the following steps:
  10. To check if VKMS is loaded, run::
  11. lsmod | grep vkms
  12. This should list the VKMS driver. If no output is obtained, then
  13. you need to enable and/or load the VKMS driver.
  14. Ensure that the VKMS driver has been set as a loadable module in your
  15. kernel config file. Do::
  16. make nconfig
  17. Go to `Device Drivers> Graphics support`
  18. Enable `Virtual KMS (EXPERIMENTAL)`
  19. Compile and build the kernel for the changes to get reflected.
  20. Now, to load the driver, use::
  21. sudo modprobe vkms
  22. On running the lsmod command now, the VKMS driver will appear listed.
  23. You can also observe the driver being loaded in the dmesg logs.
  24. The VKMS driver has optional features to simulate different kinds of hardware,
  25. which are exposed as module options. You can use the `modinfo` command
  26. to see the module options for vkms::
  27. modinfo vkms
  28. Module options are helpful when testing, and enabling modules
  29. can be done while loading vkms. For example, to load vkms with cursor enabled,
  30. use::
  31. sudo modprobe vkms enable_cursor=1
  32. To disable the driver, use ::
  33. sudo modprobe -r vkms
  34. Configuring With Configfs
  35. =========================
  36. It is possible to create and configure multiple VKMS instances via configfs.
  37. Start by mounting configfs and loading VKMS::
  38. sudo mount -t configfs none /config
  39. sudo modprobe vkms
  40. Once VKMS is loaded, ``/config/vkms`` is created automatically. Each directory
  41. under ``/config/vkms`` represents a VKMS instance, create a new one::
  42. sudo mkdir /config/vkms/my-vkms
  43. By default, the instance is disabled::
  44. cat /config/vkms/my-vkms/enabled
  45. 0
  46. And directories are created for each configurable item of the display pipeline::
  47. tree /config/vkms/my-vkms
  48. ├── connectors
  49. ├── crtcs
  50. ├── enabled
  51. ├── encoders
  52. └── planes
  53. To add items to the display pipeline, create one or more directories under the
  54. available paths.
  55. Start by creating one or more planes::
  56. sudo mkdir /config/vkms/my-vkms/planes/plane0
  57. Planes have 1 configurable attribute:
  58. - type: Plane type: 0 overlay, 1 primary, 2 cursor (same values as those
  59. exposed by the "type" property of a plane)
  60. Continue by creating one or more CRTCs::
  61. sudo mkdir /config/vkms/my-vkms/crtcs/crtc0
  62. CRTCs have 1 configurable attribute:
  63. - writeback: Enable or disable writeback connector support by writing 1 or 0
  64. Next, create one or more encoders::
  65. sudo mkdir /config/vkms/my-vkms/encoders/encoder0
  66. Last but not least, create one or more connectors::
  67. sudo mkdir /config/vkms/my-vkms/connectors/connector0
  68. Connectors have 1 configurable attribute:
  69. - status: Connection status: 1 connected, 2 disconnected, 3 unknown (same values
  70. as those exposed by the "status" property of a connector)
  71. To finish the configuration, link the different pipeline items::
  72. sudo ln -s /config/vkms/my-vkms/crtcs/crtc0 /config/vkms/my-vkms/planes/plane0/possible_crtcs
  73. sudo ln -s /config/vkms/my-vkms/crtcs/crtc0 /config/vkms/my-vkms/encoders/encoder0/possible_crtcs
  74. sudo ln -s /config/vkms/my-vkms/encoders/encoder0 /config/vkms/my-vkms/connectors/connector0/possible_encoders
  75. Since at least one primary plane is required, make sure to set the right type::
  76. echo "1" | sudo tee /config/vkms/my-vkms/planes/plane0/type
  77. Once you are done configuring the VKMS instance, enable it::
  78. echo "1" | sudo tee /config/vkms/my-vkms/enabled
  79. Finally, you can remove the VKMS instance disabling it::
  80. echo "0" | sudo tee /config/vkms/my-vkms/enabled
  81. And removing the top level directory and its subdirectories::
  82. sudo rm /config/vkms/my-vkms/planes/*/possible_crtcs/*
  83. sudo rm /config/vkms/my-vkms/encoders/*/possible_crtcs/*
  84. sudo rm /config/vkms/my-vkms/connectors/*/possible_encoders/*
  85. sudo rmdir /config/vkms/my-vkms/planes/*
  86. sudo rmdir /config/vkms/my-vkms/crtcs/*
  87. sudo rmdir /config/vkms/my-vkms/encoders/*
  88. sudo rmdir /config/vkms/my-vkms/connectors/*
  89. sudo rmdir /config/vkms/my-vkms
  90. Testing With IGT
  91. ================
  92. The IGT GPU Tools is a test suite used specifically for debugging and
  93. development of the DRM drivers.
  94. The IGT Tools can be installed from
  95. `here <https://gitlab.freedesktop.org/drm/igt-gpu-tools>`_ .
  96. The tests need to be run without a compositor, so you need to switch to text
  97. only mode. You can do this by::
  98. sudo systemctl isolate multi-user.target
  99. To return to graphical mode, do::
  100. sudo systemctl isolate graphical.target
  101. Once you are in text only mode, you can run tests using the IGT_FORCE_DRIVER
  102. variable to specify the device filter for the driver we want to test.
  103. IGT_FORCE_DRIVER can also be used with the run-tests.sh script to run the
  104. tests for a specific driver::
  105. sudo IGT_FORCE_DRIVER="vkms" ./build/tests/<name of test>
  106. sudo IGT_FORCE_DRIVER="vkms" ./scripts/run-tests.sh -t <name of test>
  107. For example, to test the functionality of the writeback library,
  108. we can run the kms_writeback test::
  109. sudo IGT_FORCE_DRIVER="vkms" ./build/tests/kms_writeback
  110. sudo IGT_FORCE_DRIVER="vkms" ./scripts/run-tests.sh -t kms_writeback
  111. You can also run subtests if you do not want to run the entire test::
  112. sudo IGT_FORCE_DRIVER="vkms" ./build/tests/kms_flip --run-subtest basic-plain-flip
  113. Testing With KUnit
  114. ==================
  115. KUnit (Kernel unit testing framework) provides a common framework for unit tests
  116. within the Linux kernel.
  117. More information in ../dev-tools/kunit/index.rst .
  118. To run the VKMS KUnit tests::
  119. tools/testing/kunit/kunit.py run --kunitconfig=drivers/gpu/drm/vkms/tests
  120. TODO
  121. ====
  122. If you want to do any of the items listed below, please share your interest
  123. with VKMS maintainers.
  124. IGT better support
  125. ------------------
  126. Debugging:
  127. - kms_plane: some test cases are failing due to timeout on capturing CRC;
  128. Virtual hardware (vblank-less) mode:
  129. - VKMS already has support for vblanks simulated via hrtimers, which can be
  130. tested with kms_flip test; in some way, we can say that VKMS already mimics
  131. the real hardware vblank. However, we also have virtual hardware that does
  132. not support vblank interrupt and completes page_flip events right away; in
  133. this case, compositor developers may end up creating a busy loop on virtual
  134. hardware. It would be useful to support Virtual Hardware behavior in VKMS
  135. because this can help compositor developers to test their features in
  136. multiple scenarios.
  137. Add Plane Features
  138. ------------------
  139. There's lots of plane features we could add support for:
  140. - Add background color KMS property[Good to get started].
  141. - Scaling.
  142. - Additional buffer formats. Low/high bpp RGB formats would be interesting
  143. [Good to get started].
  144. - Async updates (currently only possible on cursor plane using the legacy
  145. cursor api).
  146. For all of these, we also want to review the igt test coverage and make sure
  147. all relevant igt testcases work on vkms. They are good options for internship
  148. project.
  149. Runtime Configuration
  150. ---------------------
  151. We want to be able to reconfigure vkms instance without having to reload the
  152. module through configfs. Use/Test-cases:
  153. - Hotplug/hotremove connectors on the fly (to be able to test DP MST handling
  154. of compositors).
  155. - Change output configuration: Plug/unplug screens, change EDID, allow changing
  156. the refresh rate.
  157. Writeback support
  158. -----------------
  159. - The writeback and CRC capture operations share the use of composer_enabled
  160. boolean to ensure vblanks. Probably, when these operations work together,
  161. composer_enabled needs to refcounting the composer state to proper work.
  162. [Good to get started]
  163. - Add support for cloned writeback outputs and related test cases using a
  164. cloned output in the IGT kms_writeback.
  165. - As a v4l device. This is useful for debugging compositors on special vkms
  166. configurations, so that developers see what's really going on.
  167. Output Features
  168. ---------------
  169. - Variable refresh rate/freesync support. This probably needs prime buffer
  170. sharing support, so that we can use vgem fences to simulate rendering in
  171. testing. Also needs support to specify the EDID.
  172. - Add support for link status, so that compositors can validate their runtime
  173. fallbacks when e.g. a Display Port link goes bad.
  174. CRC API Improvements
  175. --------------------
  176. - Optimize CRC computation ``compute_crc()`` and plane blending ``blend()``
  177. Atomic Check using eBPF
  178. -----------------------
  179. Atomic drivers have lots of restrictions which are not exposed to userspace in
  180. any explicit form through e.g. possible property values. Userspace can only
  181. inquiry about these limits through the atomic IOCTL, possibly using the
  182. TEST_ONLY flag. Trying to add configurable code for all these limits, to allow
  183. compositors to be tested against them, would be rather futile exercise. Instead
  184. we could add support for eBPF to validate any kind of atomic state, and
  185. implement a library of different restrictions.
  186. This needs a bunch of features (plane compositing, multiple outputs, ...)
  187. enabled already to make sense.