STRUCT DRM_DRIVER(9)
π NAME
okay so this is the manual page for struct drm_driver(9) β literally the DRM driver structure, bestie. it's giving "the blueprint for how a DRM driver family does its thing." let's get into it. π
π SYNOPSIS
struct drm_driver {
int (*load) (struct drm_device *, unsigned long flags);
int (*open) (struct drm_device *, struct drm_file *);
void (*postclose) (struct drm_device *, struct drm_file *);
void (*unload) (struct drm_device *);
void (*release) (struct drm_device *);
void (*master_set)(struct drm_device *dev, struct drm_file
*file_priv, bool from_open);
void (*master_drop)(struct drm_device *dev, struct drm_file
*file_priv);
void (*debugfs_init)(struct drm_minor *minor);
struct drm_gem_object *(*gem_create_object)(struct drm_device *dev,
size_t size);
int (*prime_handle_to_fd)(struct drm_device *dev, struct drm_file
*file_priv, uint32_t handle, uint32_t flags, int *prime_fd);
int (*prime_fd_to_handle)(struct drm_device *dev, struct drm_file
*file_priv, int prime_fd, uint32_t *handle);
struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev,
struct dma_buf *dma_buf);
struct drm_gem_object *(*gem_prime_import_sg_table)( struct
drm_device *dev, struct dma_buf_attachment *attach, struct sg_table
*sgt);
int (*dumb_create)(struct drm_file *file_priv, struct drm_device
*dev, struct drm_mode_create_dumb *args);
int (*dumb_map_offset)(struct drm_file *file_priv, struct drm_device
*dev, uint32_t handle, uint64_t *offset);
int (*fbdev_probe)(struct drm_fb_helper *fbdev_helper, struct
drm_fb_helper_surface_size *sizes);
void (*show_fdinfo)(struct drm_printer *p, struct drm_file *f);
int major;
int minor;
int patchlevel;
char *name;
char *desc;
u32 driver_features;
const struct drm_ioctl_desc *ioctls;
int num_ioctls;
const struct file_operations *fops;
};
β¨ Members β¨
loadβ okay so this is the backward-compatible driver callback to complete initialization steps after the driver is registered. but bestie, for this reason it may suffer from race conditions, and its use is deprecated for new drivers. it's therefore only supported for existing drivers not yet converted to the new scheme. seedevm_drm_dev_allocanddrm_dev_registerfor the proper and race-free way to set up astruct drm_device. and literally: this is deprecated, do not use! returns: zero on success, non-zero value on failure. periodt. πopenβ this is the driver callback when a newstruct drm_fileis opened. useful for setting up driver-private data structures like buffer allocators, execution contexts, or similar things. such driver-private resources must be released again inpostclose. since the display/modeset side of DRM can only be owned by exactly onestruct drm_file(seedrm_file.is_masteranddrm_device.master), there should never be a need to set up any modeset related resources in this callback. doing so would be a driver design bug, no cap. returns:0on success, a negative error code on failure, which will be promoted to userspace as the result of theopensystem call. π¦postcloseβ one of the driver callbacks when a newstruct drm_fileis closed. useful for tearing down driver-private data structures allocated inopenlike buffer allocators, execution contexts, or similar things. same vibe asopen: since the display/modeset side of DRM can only be owned by exactly onestruct drm_file(seedrm_file.is_masteranddrm_device.master), there should never be a need to tear down any modeset related resources in this callback. doing so would be a driver design bug. πΈunloadβ reverse the effects of the driverloadcallback. ideally, the clean up performed by the driver should happen in the reverse order of the initialization. similarly to theloadhook, this handler is deprecated and its usage should be dropped in favor of an open-coded teardown function at the driver layer. seedrm_dev_unregisteranddrm_dev_putfor the proper way to remove astruct drm_device. theunloadhook is called right after unregistering the device. πreleaseβ optional callback for destroying device data after the final reference is released, i.e. the device is being destroyed. this is deprecated β clean up all memory allocations associated with adrm_deviceusingdrmm_add_action,drmm_kmallocand related managed resources functions. πmaster_setβ called whenever the minor master is set. only used by vmwgfx. πmaster_dropβ called whenever the minor master is dropped. only used by vmwgfx. πdebugfs_initβ allows drivers to create driver-specific debugfs files. β¨gem_create_objectβ constructor for gem objects. hook for allocating the GEM object struct, for use by the CMA and SHMEM GEM helpers. returns a GEM object on success, or anERR_PTR-encoded error code otherwise. π₯prime_handle_to_fdβ PRIME export function. only used by vmwgfx. πprime_fd_to_handleβ PRIME import function. only used by vmwgfx. πgem_prime_importβ import hook for GEM drivers. this defaults todrm_gem_prime_importif not set. βgem_prime_import_sg_tableβ optional hook used by the PRIME helper functionsdrm_gem_prime_importrespectivelydrm_gem_prime_import_dev. βdumb_createβ this creates a new dumb buffer in the driver's backing storage manager (GEM, TTM or something else entirely) and returns the resulting buffer handle. this handle can then be wrapped up into a framebuffer modeset object. note that userspace is not allowed to use such objects for render acceleration β drivers must create their own private ioctls for such a use case. width, height and depth are specified in thedrm_mode_create_dumbargument. the callback needs to fill thehandle,pitchandsizefor the created buffer. called by the user via ioctl. returns: zero on success, negative errno on failure. πdumb_map_offsetβ allocate an offset in the drm device node's address space to be able to memory map a dumb buffer. the default implementation isdrm_gem_create_mmap_offset. GEM based drivers must not overwrite this. called by the user via ioctl. returns: zero on success, negative errno on failure. πfbdev_probeβ allocates and initialize thefb_infostructure for fbdev emulation. furthermore it also needs to allocate the DRM framebuffer used to back the fbdev. this callback is mandatory for fbdev support. returns:0on success ot a negative error code otherwise. (yes, it says "ot" in the original, slay typo π) π§show_fdinfoβ print device specific fdinfo. seeDocumentation/gpu/drm-usage-stats.rst. πmajorβ driver major number. π’minorβ driver minor number. π’patchlevelβ driver patch level. π’nameβ driver name. π·οΈdescβ driver description. πdriver_featuresβ driver features, seeenum drm_driver_feature. drivers can disable some features on a per-instance basis usingdrm_device.driver_features. ποΈioctlsβ array of driver-private IOCTL description entries. see the chapter on :ref:IOCTL support in the userland interfaces chapter<drm_driver_ioctl>for the full details. πnum_ioctlsβ number of entries inioctls. π’fopsβ file operations for the DRM device node. see the discussion in :ref:file operations<drm_driver_fops>for in-depth coverage and some examples. π
πΈ Description
this structure represent the common code for a family of cards. there will be one struct drm_device for each card present in this family. it contains lots of vfunc entries, and a pile of those probably should be moved to more appropriate places like drm_mode_config_funcs or into a new operations structure for GEM drivers. it's giving "we know it's a bit messy, but it works." π
π SEE ALSO
- Kernel file
./include/drm/drm_drv.h enum drm_driver_feature(9)devm_drm_dev_alloc(9)drm_dev_is_unplugged(9)drm_core_check_all_features(9)drm_core_check_feature(9)drm_drv_uses_atomic_modeset(9)
k bye bestie, this iconic page is from ./include/drm, dated October 2026, and it's literally the struct drm_driver(9) manual. slay. π
πβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms