261 lines · 10.3 KB · Text
RawDownload
===================Userland interfaces=================== The DRM core exports several interfaces to applications, generallyintended to be used through corresponding libdrm wrapper functions. Inaddition, drivers export device-specific interfaces for use by userspacedrivers & device-aware applications through ioctls and sysfs files. External interfaces include: memory mapping, context management, DMAoperations, AGP management, vblank control, fence management, memorymanagement, and output management. Cover generic ioctls and sysfs layout here. We only need high-levelinfo, since man pages should cover the rest. libdrm Device Lookup==================== .. kernel-doc:: drivers/gpu/drm/drm_ioctl.c   :doc: getunique and setversion story  .. _drm_primary_node: Primary Nodes, DRM Master and Authentication============================================ .. kernel-doc:: drivers/gpu/drm/drm_auth.c   :doc: master and authentication .. kernel-doc:: drivers/gpu/drm/drm_auth.c   :export: .. kernel-doc:: include/drm/drm_auth.h   :internal: Open-Source Userspace Requirements================================== The DRM subsystem has stricter requirements than most other kernel subsystems onwhat the userspace side for new uAPI needs to look like. This section hereexplains what exactly those requirements are, and why they exist. The short summary is that any addition of DRM uAPI requires correspondingopen-sourced userspace patches, and those patches must be reviewed and ready formerging into a suitable and canonical upstream project. GFX devices (both display and render/GPU side) are really complex bits ofhardware, with userspace and kernel by necessity having to work together reallyclosely.  The interfaces, for rendering and modesetting, must be extremely wideand flexible, and therefore it is almost always impossible to precisely definethem for every possible corner case. This in turn makes it really practicallyinfeasible to differentiate between behaviour that's required by userspace, andwhich must not be changed to avoid regressions, and behaviour which is only anaccidental artifact of the current implementation. Without access to the full source code of all userspace users that means itbecomes impossible to change the implementation details, since userspace coulddepend upon the accidental behaviour of the current implementation in minutedetails. And debugging such regressions without access to source code is prettymuch impossible. As a consequence this means: - The Linux kernel's "no regression" policy holds in practice only for  open-source userspace of the DRM subsystem. DRM developers are perfectly fine  if closed-source blob drivers in userspace use the same uAPI as the open  drivers, but they must do so in the exact same way as the open drivers.  Creative (ab)use of the interfaces will, and in the past routinely has, lead  to breakage. - Any new userspace interface must have an open-source implementation as  demonstration vehicle. The other reason for requiring open-source userspace is uAPI review. Since thekernel and userspace parts of a GFX stack must work together so closely, codereview can only assess whether a new interface achieves its goals by looking atboth sides. Making sure that the interface indeed covers the use-case fullyleads to a few additional requirements: - The open-source userspace must not be a toy/test application, but the real  thing. Specifically it needs to handle all the usual error and corner cases.  These are often the places where new uAPI falls apart and hence essential to  assess the fitness of a proposed interface. - The userspace side must be fully reviewed and tested to the standards of that  userspace project. For e.g. mesa this means piglit testcases and review on the  mailing list. This is again to ensure that the new interface actually gets the  job done. - The userspace patches must be against the canonical upstream, not some vendor  fork. This is to make sure that no one cheats on the review and testing  requirements by doing a quick fork. - The kernel patch can only be merged after all the above requirements are met,  but it **must** be merged **before** the userspace patches land. uAPI always flows  from the kernel, doing things the other way round risks divergence of the uAPI  definitions and header files. These are fairly steep requirements, but have grown out from years of sharedpain and experience with uAPI added hastily, and almost always regretted aboutjust as fast. GFX devices change really fast, requiring a paradigm shift andentire new set of uAPI interfaces every few years at least. Together with theLinux kernel's guarantee to keep existing userspace running for 10+ years thisis already rather painful for the DRM subsystem, with multiple different uAPIsfor the same thing co-existing. If we add a few more complete mistakes into themix every year it would be entirely unmanageable. .. _drm_render_node: Render nodes============ DRM core provides multiple character-devices for user-space to use.Depending on which device is opened, user-space can perform a differentset of operations (mainly ioctls). The primary node is always createdand called card<num>. Additionally, a currently unused control node,called controlD<num> is also created. The primary node provides alllegacy operations and historically was the only interface used byuserspace. With KMS, the control node was introduced. However, theplanned KMS control interface has never been written and so the controlnode stays unused to date. With the increased use of offscreen renderers and GPGPU applications,clients no longer require running compositors or graphics servers tomake use of a GPU. But the DRM API required unprivileged clients toauthenticate to a DRM-Master prior to getting GPU access. To avoid thisstep and to grant clients GPU access without authenticating, rendernodes were introduced. Render nodes solely serve render clients, thatis, no modesetting or privileged ioctls can be issued on render nodes.Only non-global rendering commands are allowed. If a driver supportsrender nodes, it must advertise it via the DRIVER_RENDER DRM drivercapability. If not supported, the primary node must be used for renderclients together with the legacy drmAuth authentication procedure. If a driver advertises render node support, DRM core will create aseparate render node called renderD<num>. There will be one render nodeper device. No ioctls except PRIME-related ioctls will be allowed onthis node. Especially GEM_OPEN will be explicitly prohibited. Rendernodes are designed to avoid the buffer-leaks, which occur if clientsguess the flink names or mmap offsets on the legacy interface.Additionally to this basic interface, drivers must mark theirdriver-dependent render-only ioctls as DRM_RENDER_ALLOW so renderclients can use them. Driver authors must be careful not to allow anyprivileged ioctls on render nodes. With render nodes, user-space can now control access to the render nodevia basic file-system access-modes. A running graphics server whichauthenticates clients on the privileged primary/legacy node is no longerrequired. Instead, a client can open the render node and is immediatelygranted GPU access. Communication between clients (or servers) is donevia PRIME. FLINK from render node to legacy node is not supported. Newclients must not use the insecure FLINK interface. Besides dropping all modeset/global ioctls, render nodes also drop theDRM-Master concept. There is no reason to associate render clients witha DRM-Master as they are independent of any graphics server. Besides,they must work without any running master, anyway. Drivers must be ableto run without a master object if they support render nodes. If, on theother hand, a driver requires shared state between clients which isvisible to user-space and accessible beyond open-file boundaries, theycannot support render nodes. IOCTL Support on Device Nodes============================= .. kernel-doc:: drivers/gpu/drm/drm_ioctl.c   :doc: driver specific ioctls .. kernel-doc:: include/drm/drm_ioctl.h   :internal: .. kernel-doc:: drivers/gpu/drm/drm_ioctl.c   :export: .. kernel-doc:: drivers/gpu/drm/drm_ioc32.c   :export: Testing and validation====================== Validating changes with IGT--------------------------- There's a collection of tests that aims to cover the whole functionality ofDRM drivers and that can be used to check that changes to DRM drivers or thecore don't regress existing functionality. This test suite is called IGT andits code can be found in https://cgit.freedesktop.org/drm/igt-gpu-tools/. To build IGT, start by installing its build dependencies. In Debian-basedsystems:: 	# apt-get build-dep intel-gpu-tools And in Fedora-based systems:: 	# dnf builddep intel-gpu-tools Then clone the repository:: 	$ git clone git://anongit.freedesktop.org/drm/igt-gpu-tools Configure the build system and start the build:: 	$ cd igt-gpu-tools && ./autogen.sh && make -j6 Download the piglit dependency:: 	$ ./scripts/run-tests.sh -d And run the tests:: 	$ ./scripts/run-tests.sh -t kms -t core -s run-tests.sh is a wrapper around piglit that will execute the tests matchingthe -t options. A report in HTML format will be available in./results/html/index.html. Results can be compared with piglit. Display CRC Support------------------- .. kernel-doc:: drivers/gpu/drm/drm_debugfs_crc.c   :doc: CRC ABI .. kernel-doc:: drivers/gpu/drm/drm_debugfs_crc.c   :export: Debugfs Support--------------- .. kernel-doc:: include/drm/drm_debugfs.h   :internal: .. kernel-doc:: drivers/gpu/drm/drm_debugfs.c   :export: Sysfs Support============= .. kernel-doc:: drivers/gpu/drm/drm_sysfs.c   :doc: overview .. kernel-doc:: drivers/gpu/drm/drm_sysfs.c   :export:  VBlank event handling===================== The DRM core exposes two vertical blank related ioctls: DRM_IOCTL_WAIT_VBLANK    This takes a struct drm_wait_vblank structure as its argument, and    it is used to block or request a signal when a specified vblank    event occurs. DRM_IOCTL_MODESET_CTL    This was only used for user-mode-settind drivers around modesetting    changes to allow the kernel to update the vblank interrupt after    mode setting, since on many devices the vertical blank counter is    reset to 0 at some point during modeset. Modern drivers should not    call this any more since with kernel mode setting it is a no-op.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t