STRUCT DRM_PRIVATE_OBJ(9)
π struct drm_private_obj(9)
okay so this is a page from the Kernel API Manual and honestly bestie, it's giving "driver private atomic object" realness β¨ β like the glow-up base struct that your driver's own private state sits on top of. Let's get into it π«Ά
πΈ NAME πΈ
struct drm_private_obj β the base struct for a driver private atomic object. no cap, that's literally what it is π
β¨ SYNOPSIS β¨
struct drm_private_obj {
struct drm_device *dev;
struct list_head head;
struct drm_modeset_lock lock;
struct drm_private_state *state;
const struct drm_private_state_funcs *funcs;
};
π Members π
devβ the parent DRM device. the whole fam, basically πheadβ list entry used to attach a private object to adrm_device(it gets queued todrm_mode_config.privobj_list). lowkey it's how your object gets found in the group chat πlockβ modeset lock that protects the state object. keep it safe bestie πstateβ the current atomic state for this driver private object. this is the main character state state β¨funcsβ functions to manipulate the state of this driver private object, seedrm_private_state_funcs. the little helper squad π§
π¦ Description π¦
A driver private object is initialized by calling drm_atomic_private_obj_init and cleaned up by calling drm_atomic_private_obj_fini. that's the whole life cycle, birth and fini, iconic π
Currently it only tracks the state update functions and the opaque driver private state itself, but in the future it might also track which drm_modeset_lock is required to duplicate and update this object's state. so like, watch this space π
All private objects must be initialized before the DRM device they are attached to is registered to the DRM subsystem (that's the call to drm_dev_register), and they should stay around until this DRM device is unregistered (the call to drm_dev_unregister). In other words β and say it with me β private objects' lifetime is tied to the DRM device lifetime π. This implies that:
- all calls to
drm_atomic_private_obj_initmust be done before callingdrm_dev_register - all calls to
drm_atomic_private_obj_finimust be done after callingdrm_dev_unregister
If that private object is used to store a state shared by multiple CRTCs, proper care must be taken to ensure that non-blocking commits are properly ordered, to avoid a use-after-free issue π fr fr, this part is not a vibe.
Indeed β assuming a sequence of two non-blocking drm_atomic_commit on two different drm_crtc using different drm_plane and drm_connector, so with no resources shared, there's no guarantee on which commit is going to happen first. However, the second drm_atomic_commit will consider the first drm_private_obj its old state, and will be in charge of freeing it whenever the second drm_atomic_commit is done.
If the first drm_atomic_commit happens after it, it will consider its drm_private_obj the new state and will be likely to access it β resulting in an access to a freed memory region π so yeah. that's the bad ending.
Drivers should store (and get a reference to) thedrm_crtc_commitstructure in our private state indrm_mode_config_helper_funcs.atomic_commit_setup, and then wait for that commit to complete as the first step ofdrm_mode_config_helper_funcs.atomic_commit_tail, similar todrm_atomic_helper_wait_for_dependencies. π₯ do this, bestie, please.
π SEE ALSO π
- Kernel file
./include/drm/drm_atomic.h struct drm_crtc_commit(9)struct drm_private_state_funcs(9)drm_for_each_privobj(9)struct drm_private_state(9)struct drm_atomic_commit(9)drm_crtc_commit_get(9)drm_crtc_commit_put(9)drm_atomic_commit_get(9)drm_atomic_commit_put(9)drm_atomic_get_old_crtc_state(9)drm_atomic_get_new_crtc_state(9)drm_atomic_get_old_plane_state(9)drm_atomic_get_new_plane_state(9)drm_atomic_get_old_connector_state(9)drm_atomic_get_new_connector_state(9)__drm_atomic_get_current_plane_state(9)for_each_oldnew_connector_in_state(9)for_each_old_connector_in_state(9)for_each_new_connector_in_state(9)for_each_oldnew_crtc_in_state(9)for_each_old_crtc_in_state(9)for_each_new_crtc_in_state(9)for_each_oldnew_colorop_in_state(9)for_each_new_colorop_in_state(9)for_each_oldnew_plane_in_state(9)for_each_oldnew_plane_in_state_reverse(9)for_each_new_plane_in_state_reverse(9)for_each_old_plane_in_state(9)for_each_new_plane_in_state(9)for_each_oldnew_private_obj_in_state(9)for_each_old_private_obj_in_state(9)for_each_new_private_obj_in_state(9)drm_atomic_crtc_needs_modeset(9)drm_atomic_crtc_effectively_active(9)struct drm_bus_cfg(9)struct drm_bridge_state(9)
that's the whole thing bestie, go forth and manage your private objects responsibly π
source: ./include/drm Β· dated October 2026 Β· struct drm_private_obj(9) β mwah, catch you in the next manpage ππ
π¦ 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