STRUCT DRM_FILE(9)
π¦ struct drm_file(9) β your fave Kernel API Manual, bestie π¦
okay so before we even get into it β hi, this is the page for struct drm_file from the Kernel API Manual, and yes we are gonna read the whole thing together, no skimming, i got you π
β¨ NAME β¨
struct drm_file β the DRM file private data. that's it, that's the vibe: it's the per-open-file little private stash the DRM subsystem keeps for you π
πΈ SYNOPSIS πΈ
here's the whole struct, laid out, untouched, exactly as it lives β i'm literally not touching a single character of this, periodt:
struct drm_file {
bool authenticated;
bool stereo_allowed;
bool universal_planes;
bool atomic;
bool aspect_ratio_allowed;
bool writeback_connectors;
bool plane_color_pipeline;
bool was_master;
bool is_master;
bool supports_virtualized_cursor_plane;
struct drm_master *master;
spinlock_t master_lookup_lock;
struct pid *pid;
u64 client_id;
drm_magic_t magic;
struct list_head lhead;
struct drm_minor *minor;
struct idr object_idr;
spinlock_t table_lock;
struct xarray syncobj_xa;
struct file *filp;
void *driver_priv;
struct list_head fbs;
struct mutex fbs_lock;
struct list_head blobs;
wait_queue_head_t event_wait;
struct list_head pending_event_list;
struct list_head event_list;
int event_space;
struct mutex event_read_lock;
struct drm_prime_file_private prime;
const char *client_name;
struct mutex client_name_lock;
struct dentry *debugfs_client;
};
π MEMBERS π
okay this is the long part and honestly the main character energy of the whole page. buckle up, we're going field by field, and nothing gets skipped π
authenticatedβ tells you whether the client is allowed to submit rendering at all. for legacy nodes this means it must be authenticated, no exceptions. also: see the :ref:section on primary nodes and authentication <drm_primary_node>.stereo_allowedβTruewhen the client has asked us to expose stereo 3D mode flags. cute, they want depth perception πuniversal_planesβTrueif the client understands CRTC primary planes and cursor planes in the plane list. it gets set automatically whenatomicis set β like a little freebie, iykyk.atomicβTrueif the client understands atomic properties. slay.aspect_ratio_allowedβTrue, if the client can handle picture aspect ratios and has requested to pass this information along with the mode. πΌοΈwriteback_connectorsβTrueif client understands writeback connectors.plane_color_pipelineβTrueif client understands plane color pipelines.was_masterβ this client has, or had, master capability. protected bystruct drm_device.master_mutex.
the whole point: it's used to ensure that CAP_SYS_ADMIN is not enforced, if the client is or was master in the past. so like, it's the "we used to be somebody" flag π
is_masterβ this client is the creator of master. protected bystruct drm_device.master_mutex.
also see the :ref:section on primary nodes and authentication <drm_primary_node>.
supports_virtualized_cursor_planeβ this client is capable of handling the cursor plane with the restrictions imposed on it by the virtualized drivers.
this implies that the cursor plane has to behave like a cursor, i.e. track cursor movement. it also requires setting of the hotspot properties by the client on the cursor plane. π±οΈ
masterβ the master this node is currently associated with. protected bystruct drm_device.master_mutex, and serialized bymaster_lookup_lock.
only relevant if drm_is_primary_client returns true. note that this only matches drm_device.master if the master is the currently active one.
to update master, both drm_device.master_mutex and master_lookup_lock need to be held, therefore holding either of them is safe and enough for the read side.
when dereferencing this pointer, either hold struct drm_device.master_mutex for the duration of the pointer's use, or use drm_file_get_master if struct drm_device.master_mutex is not currently held and there is no other need to hold it. this prevents master from being freed during use. π«Ά
also see authentication and is_master and the :ref:section on primary nodes and authentication <drm_primary_node>.
master_lookup_lockβ serializesmaster.pidβ the process that is using this file.
β οΈ must only be dereferenced under a rcu_read_lock or equivalent.
updates are guarded with dev->filelist_mutex and reference must be dropped after a RCU grace period to accommodate lockless readers. no cap, this one's strict.
client_idβ a unique id forfdinfo. πmagicβ authentication magic, seeauthenticated.lheadβ list of all open files of a DRM device, linked intodrm_device.filelist. protected bydrm_device.filelist_mutex.minorβstruct drm_minorfor this file.object_idrβ mapping of mm object handles to object pointers. used by the GEM subsystem. protected bytable_lock.
note that allocated entries might be NULL as a transient state when creating or deleting a handle. π
table_lockβ protectsobject_idr.syncobj_xaβ mapping of sync object handles to object pointers.filpβ pointer to the core file structure.driver_privβ optional pointer for driver private data. can be allocated indrm_driver.openand should be freed indrm_driver.postclose. (allocate in open, free in postclose β that's the whole contract bestie, don't get it twisted π)fbsβ list ofstruct drm_framebufferassociated with this file, using thedrm_framebuffer.filp_headentry.
protected by fbs_lock. note that the fbs list holds a reference on the framebuffer object to prevent it from untimely disappearing. literally holding on for dear life π
fbs_lockβ protectsfbs.blobsβ user-created blob properties; this retains a reference on the property.
protected by drm_mode_config.blob_lock;
event_waitβ waitqueue for new events added toevent_list.pending_event_listβ list of pendingstruct drm_pending_event, used to clean up pending events in case this file gets closed before the event is signalled. uses thedrm_pending_event.pending_linkentry.
protect by drm_device.event_lock.
event_listβ list ofstruct drm_pending_event, ready for delivery to userspace throughdrm_read. uses thedrm_pending_event.linkentry.
protect by drm_device.event_lock.
event_spaceβ available event space to prevent userspace from exhausting kernel memory. currently limited to the fairly arbitrary value of 4KB. (yes, "fairly arbitrary" is the official wording and honestly? iconic.)event_read_lockβ serializesdrm_read.primeβ per-file buffer caches used by the PRIME buffer sharing code.client_nameβ userspace-provided name; useful for accounting and debugging. πclient_name_lockβ protectsclient_name.debugfs_clientβ debugfs directory for each client under a drm node.
π DESCRIPTION π
this structure tracks DRM state per open file descriptor. that's the whole thing! it's the little per-fd brain cell π§
π SEE ALSO π
- Kernel file
./include/drm/drm_file.h struct drm_minor(9)struct drm_pending_event(9)drm_is_primary_client(9)drm_is_render_client(9)drm_is_accel_client(9)struct drm_memory_stats(9)
π real talk: none of these locks are decorative. if the page says holdmaster_lookup_lockordrm_device.master_mutex, hold them β that's how you avoid a use-after-free situation that would be genuinely tragic.
and that's the page!! this one came out of ./include/drm, dated October 2026, and it's literally titled struct drm_file(9) β 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