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 111Connectors have 1 configurable attribute: 112 113- status: Connection status: 1 connected, 2 disconnected, 3 unknown (same values 114 as those exposed by the "status" property of a connector) 115 116To finish the configuration, link the different pipeline items:: 117 118 sudo ln -s /config/vkms/my-vkms/crtcs/crtc0 /config/vkms/my-vkms/planes/plane0/possible_crtcs 119 sudo ln -s /config/vkms/my-vkms/crtcs/crtc0 /config/vkms/my-vkms/encoders/encoder0/possible_crtcs 120 sudo ln -s /config/vkms/my-vkms/encoders/encoder0 /config/vkms/my-vkms/connectors/connector0/possible_encoders 121 122Since at least one primary plane is required, make sure to set the right type:: 123 124 echo "1" | sudo tee /config/vkms/my-vkms/planes/plane0/type 125 126Once you are done configuring the VKMS instance, enable it:: 127 128 echo "1" | sudo tee /config/vkms/my-vkms/enabled 129 130Finally, you can remove the VKMS instance disabling it:: 131 132 echo "0" | sudo tee /config/vkms/my-vkms/enabled 133 134And removing the top level directory and its subdirectories:: 135 136 sudo rm /config/vkms/my-vkms/planes/*/possible_crtcs/* 137 sudo rm /config/vkms/my-vkms/encoders/*/possible_crtcs/* 138 sudo rm /config/vkms/my-vkms/connectors/*/possible_encoders/* 139 sudo rmdir /config/vkms/my-vkms/planes/* 140 sudo rmdir /config/vkms/my-vkms/crtcs/* 141 sudo rmdir /config/vkms/my-vkms/encoders/* 142 sudo rmdir /config/vkms/my-vkms/connectors/* 143 sudo rmdir /config/vkms/my-vkms 144 145Testing With IGT 146================ 147 148The IGT GPU Tools is a test suite used specifically for debugging and 149development of the DRM drivers. 150The IGT Tools can be installed from 151`here <https://gitlab.freedesktop.org/drm/igt-gpu-tools>`_ . 152 153The tests need to be run without a compositor, so you need to switch to text 154only mode. You can do this by:: 155 156 sudo systemctl isolate multi-user.target 157 158To return to graphical mode, do:: 159 160 sudo systemctl isolate graphical.target 161 162Once you are in text only mode, you can run tests using the --device switch 163or IGT_DEVICE variable to specify the device filter for the driver we want 164to test. IGT_DEVICE can also be used with the run-test.sh script to run the 165tests for a specific driver:: 166 167 sudo ./build/tests/<name of test> --device "sys:/sys/devices/platform/vkms" 168 sudo IGT_DEVICE="sys:/sys/devices/platform/vkms" ./build/tests/<name of test> 169 sudo IGT_DEVICE="sys:/sys/devices/platform/vkms" ./scripts/run-tests.sh -t <name of test> 170 171For example, to test the functionality of the writeback library, 172we can run the kms_writeback test:: 173 174 sudo ./build/tests/kms_writeback --device "sys:/sys/devices/platform/vkms" 175 sudo IGT_DEVICE="sys:/sys/devices/platform/vkms" ./build/tests/kms_writeback 176 sudo IGT_DEVICE="sys:/sys/devices/platform/vkms" ./scripts/run-tests.sh -t kms_writeback 177 178You can also run subtests if you do not want to run the entire test:: 179 180 sudo ./build/tests/kms_flip --run-subtest basic-plain-flip --device "sys:/sys/devices/platform/vkms" 181 sudo IGT_DEVICE="sys:/sys/devices/platform/vkms" ./build/tests/kms_flip --run-subtest basic-plain-flip 182 183Testing With KUnit 184================== 185 186KUnit (Kernel unit testing framework) provides a common framework for unit tests 187within the Linux kernel. 188More information in ../dev-tools/kunit/index.rst . 189 190To run the VKMS KUnit tests:: 191 192 tools/testing/kunit/kunit.py run --kunitconfig=drivers/gpu/drm/vkms/tests 193 194TODO 195==== 196 197If you want to do any of the items listed below, please share your interest 198with VKMS maintainers. 199 200IGT better support 201------------------ 202 203Debugging: 204 205- kms_plane: some test cases are failing due to timeout on capturing CRC; 206 207Virtual hardware (vblank-less) mode: 208 209- VKMS already has support for vblanks simulated via hrtimers, which can be 210 tested with kms_flip test; in some way, we can say that VKMS already mimics 211 the real hardware vblank. However, we also have virtual hardware that does 212 not support vblank interrupt and completes page_flip events right away; in 213 this case, compositor developers may end up creating a busy loop on virtual 214 hardware. It would be useful to support Virtual Hardware behavior in VKMS 215 because this can help compositor developers to test their features in 216 multiple scenarios. 217 218Add Plane Features 219------------------ 220 221There's lots of plane features we could add support for: 222 223- Add background color KMS property[Good to get started]. 224 225- Scaling. 226 227- Additional buffer formats. Low/high bpp RGB formats would be interesting 228 [Good to get started]. 229 230- Async updates (currently only possible on cursor plane using the legacy 231 cursor api). 232 233For all of these, we also want to review the igt test coverage and make sure 234all relevant igt testcases work on vkms. They are good options for internship 235project. 236 237Runtime Configuration 238--------------------- 239 240We want to be able to reconfigure vkms instance without having to reload the 241module through configfs. Use/Test-cases: 242 243- Hotplug/hotremove connectors on the fly (to be able to test DP MST handling 244 of compositors). 245 246- Change output configuration: Plug/unplug screens, change EDID, allow changing 247 the refresh rate. 248 249Writeback support 250----------------- 251 252- The writeback and CRC capture operations share the use of composer_enabled 253 boolean to ensure vblanks. Probably, when these operations work together, 254 composer_enabled needs to refcounting the composer state to proper work. 255 [Good to get started] 256 257- Add support for cloned writeback outputs and related test cases using a 258 cloned output in the IGT kms_writeback. 259 260- As a v4l device. This is useful for debugging compositors on special vkms 261 configurations, so that developers see what's really going on. 262 263Output Features 264--------------- 265 266- Variable refresh rate/freesync support. This probably needs prime buffer 267 sharing support, so that we can use vgem fences to simulate rendering in 268 testing. Also needs support to specify the EDID. 269 270- Add support for link status, so that compositors can validate their runtime 271 fallbacks when e.g. a Display Port link goes bad. 272 273CRC API Improvements 274-------------------- 275 276- Optimize CRC computation ``compute_crc()`` and plane blending ``blend()`` 277 278Atomic Check using eBPF 279----------------------- 280 281Atomic drivers have lots of restrictions which are not exposed to userspace in 282any explicit form through e.g. possible property values. Userspace can only 283inquiry about these limits through the atomic IOCTL, possibly using the 284TEST_ONLY flag. Trying to add configurable code for all these limits, to allow 285compositors to be tested against them, would be rather futile exercise. Instead 286we could add support for eBPF to validate any kind of atomic state, and 287implement a library of different restrictions. 288 289This needs a bunch of features (plane compositing, multiple outputs, ...) 290enabled already to make sense. 291