DRIVER SPECIFIC IOCTLS(9)
π driver specific ioctls π
okay bestie, welcome to driver specific ioctls β that's the page, section 9 of the Kernel API Manual, and it's genuinely all about how render drivers get their own private IOCTLs. buckle up π
β¨ the whole vibe (aka where we're at)
first things first, periodt: driver private IOCTLs should only be needed for drivers that support rendering. kernel modesetting is all standardized, and it gets extended through properties. there are a few exceptions floating around in some existing drivers β they define IOCTLs for use by the display DRM master β but ngl they all predate properties. old money, not new money π
so, if you do have a render driver, you always have to support it through driver private properties. there's a few steps needed to wire all the things up π§
πΈ step one: define the struct
you need to define the structure for your IOCTL in your driver private UAPI header, include/uapi/drm/my_driver_drm.h:
struct my_driver_operation {
u32 some_thing;
u32 another_thing;
};
please make sure you follow all the best practices from Documentation/process/botching-up-ioctls.rst π
β οΈ heads up bestie: drm_ioctl automatically zero-extends structures, so make sure you can add more stuff at the end β i.e. don't put a variable sized array there. don't do it. i'm serious. π
π¦ step two: define your IOCTL number
then you need to define your IOCTL number, using one of DRM_IO, DRM_IOR, DRM_IOW or DRM_IOWR. it must start with the DRM_IOCTL_ prefix β¨
##define DRM_IOCTL_MY_DRIVER_OPERATION DRM_IOW(DRM_COMMAND_BASE, struct my_driver_operation)
DRM driver private IOCTL must be in the range from DRM_COMMAND_BASE to DRM_COMMAND_END. no cap, that's the whole range, stay in it π
π step three: wire up the handlers
finally you need an array of struct drm_ioctl_desc to wire up the handlers and set the access rights:
static const struct drm_ioctl_desc my_driver_ioctls[] = {
DRM_IOCTL_DEF_DRV(MY_DRIVER_OPERATION, my_driver_operation,
DRM_AUTH|DRM_RENDER_ALLOW),
};
and then assign this to the drm_driver.ioctls field in your driver structure. slay, you're basically done π
π one more thing
see the separate chapter on file operations<drm_driver_fops> (:ref: β yk the ref markup) for how the driver-specific IOCTLs are wired up π«Ά
β SEE ALSO β
- Kernel file
./drivers/gpu/drm/drm_ioctl.cgetuniqueandsetversionstory(9) drm_noop(9)drm_invalid_op(9)drm_ioctl(9)drm_ioctl_flags(9)
aaand that's the page!! π this iconic little number lives at ./drivers/gpu/drm, dated October 2026 β go off, kernel docs, you ate ππΈ
π¦ 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