summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMaxime Ripard <mripard@kernel.org>2026-01-28 15:43:46 +0300
committerMaxime Ripard <mripard@kernel.org>2026-02-10 12:05:33 +0300
commit47b5ac7daa46e2bc8e4916d856fdc036ac145bb6 (patch)
treeee8ccf8e0e04e094a5b59a479debf2d5b09fcd51 /drivers
parent95ffa10056b33bf5a90090b02da2edd52e1e281c (diff)
downloadlinux-47b5ac7daa46e2bc8e4916d856fdc036ac145bb6.tar.xz
drm/atomic: Add new atomic_create_state callback to drm_private_obj
The drm_private_obj initialization was inconsistent with the rest of the KMS objects. Indeed, it required to pass a preallocated state in drm_private_obj_init(), while all the others objects would have a reset callback that would be called later on to create the state. However, reset really is meant to reset the hardware and software state. That it creates an initial state is a side-effect that has been used in all objects but drm_private_obj. This is made more complex since some drm_private_obj, the DisplayPort ones in particular, need to be persistent across and suspend/resume cycle, and such a cycle would call drm_mode_config_reset(). Thus, we need to add a new callback to allocate a pristine state for a given private object. This discussion has also came up during the atomic state readout discussion, so it might be introduced into the other objects later on. Until all drivers are converted to that new allocation pattern, we will only call it if the passed state is NULL. This will be removed eventually. Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Link: https://patch.msgid.link/20260128-drm-private-obj-reset-v4-2-90891fa3d3b0@redhat.com Signed-off-by: Maxime Ripard <mripard@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/drm_atomic.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 4191a8333fc4..e3029c8f02e5 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -941,11 +941,25 @@ int drm_atomic_private_obj_init(struct drm_device *dev,
drm_modeset_lock_init(&obj->lock);
obj->dev = dev;
- obj->state = state;
obj->funcs = funcs;
list_add_tail(&obj->head, &dev->mode_config.privobj_list);
- state->obj = obj;
+ /*
+ * Not all users of drm_atomic_private_obj_init have been
+ * converted to using &drm_private_obj_funcs.atomic_create_state yet.
+ * For the time being, let's only call reset if the passed state is
+ * NULL. Otherwise, we will fallback to the previous behaviour.
+ */
+ if (!state) {
+ state = obj->funcs->atomic_create_state(obj);
+ if (IS_ERR(state))
+ return PTR_ERR(state);
+
+ obj->state = state;
+ } else {
+ obj->state = state;
+ state->obj = obj;
+ }
return 0;
}