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