drm/atomic: Allocate drm_private_state through a callback
Subsystems (15)
Maxime Ripard
maintainerv2 cover drm/atomic: Allocate drm_private_state through a callback
Hi,
This series started from my work on the hardware state readout[1], and was suggested by Dmitry[2].
This series deal with the fact that drm_private_obj (and thus bridges) are not initialized using the same pattern than any other object. This series solves that inconsistency by aligning it to what we're doing for all the other objects.
This was tested on a TI SK-AM62, with three bridges.
Let me know what you think,
Maxime
1: https://lore.kernel.org/dri-devel/[email protected]/
2: https://lore.kernel.org/dri-devel/zvqtehg66dbrrdmik6ylo2kdk74umfzo5hbfkizwsb352nlyqv@jgouvmbfwa4x/
---
Changes in v2:
- Switch to a new hook instead of reset since some drm_private_objs want
to persist across suspends
- Drop the call to drm_private_obj_funcs.reset in
drm_mode_config_reset()
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Maxime Ripard (16):
drm/atomic: Add dev pointer to drm_private_obj
drm/atomic: Make drm_atomic_private_obj_init fallible drm/atomic: Add new atomic_create_state callback to drm_private_obj drm/atomic-helper: Add private_obj atomic_create_state helper drm/bridge: Switch private_obj initialization to atomic_create_state drm/dp_mst: Switch private_obj initialization to atomic_create_state drm/dp_tunnel: Switch private_obj initialization to atomic_create_state drm/amdgpu: Switch private_obj initialization to atomic_create_state drm/arm: komeda: Switch private_obj initialization to atomic_create_state drm/ingenic: Switch private_obj initialization to atomic_create_state drm/msm: mdp5: Switch private_obj initialization to atomic_create_state drm/msm: dpu1: Switch private_obj initialization to atomic_create_state drm/omapdrm: Switch private_obj initialization to atomic_create_state drm/tegra: Switch private_obj initialization to atomic_create_state drm/vc4: Switch private_obj initialization to atomic_create_state drm/atomic: Remove state argument to drm_atomic_private_obj_init
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 51 ++--- .../gpu/drm/arm/display/komeda/komeda_pipeline.h | 2 + .../drm/arm/display/komeda/komeda_private_obj.c | 208 ++++++++++++++------- drivers/gpu/drm/display/drm_dp_mst_topology.c | 36 ++-- drivers/gpu/drm/display/drm_dp_tunnel.c | 25 ++- drivers/gpu/drm/drm_atomic.c | 24 ++- drivers/gpu/drm/drm_atomic_state_helper.c | 22 +++ drivers/gpu/drm/drm_bridge.c | 32 ++-- drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 28 +-- drivers/gpu/drm/ingenic/ingenic-ipu.c | 28 +-- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 41 ++-- drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c | 40 ++-- drivers/gpu/drm/omapdrm/omap_drv.c | 22 ++- drivers/gpu/drm/tegra/hub.c | 22 ++- drivers/gpu/drm/vc4/vc4_kms.c | 67 ++++--- include/drm/drm_atomic.h | 25 ++- include/drm/drm_atomic_state_helper.h | 3 + 17 files changed, 444 insertions(+), 232 deletions(-)
---
base-commit: aa1c2b073ad23847dd2e7bdc7d30009f34ed7f59
change-id: 20251008-drm-private-obj-reset-ae1e2741027a
Best regards,
Signature · 1 line
Maxime Ripard <[email protected]>
Maxime Ripard
maintainerPATCH v2 1/16 drm/atomic: Add dev pointer to drm_private_obj
All the objects that need to implement some callbacks in KMS have a pointer in there structure to the main drm_device.
However, it's not the case for drm_private_objs, which makes it harder than it needs to be to implement some of its callbacks. Let's add that pointer.
--- drivers/gpu/drm/drm_atomic.c | 1 + include/drm/drm_atomic.h | 5 +++++ 2 files changed, 6 insertions(+)
drivers/gpu/drm/drm_atomic.c +1 -0
@@ -790,10 +790,11 @@ drm_atomic_private_obj_init(struct drm_device *dev, {memset (obj,0 ,sizeof (*obj));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;
include/drm/drm_atomic.h +5 -0
@@ -282,10 +282,15 @@ struct drm_private_state_funcs {* commit to complete as the first step of * &drm_mode_config_helper_funcs.atomic_commit_tail, similar to * drm_atomic_helper_wait_for_dependencies(). */ struct drm_private_obj { +/** +* @dev: parent DRM device +*/ +struct drm_device *dev; +/** * @head: List entry used to attach a private object to a &drm_device * (queued to &drm_mode_config.privobj_list). */ struct list_head head;
Signature · 1 line
2.51.0
Re: [PATCH v2 01/16] drm/atomic: Add dev pointer to drm_private_obj
Hello,
Quoted 10 lines · Maxime Ripard
All the objects that need to implement some callbacks in KMS have a pointer in there structure to the main
drm_device.However, it's not the case for
drm_private_objs, which makes it harder than it needs to be to implement some of its callbacks. Let's add that pointer.Reviewed-by Dmitry Baryshkov <[email protected]>Reviewed-by Tomi Valkeinen <[email protected]>Signed-off-by Maxime Ripard <[email protected]>
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Re: (subset) [PATCH v2 01/16] drm/atomic: Add dev pointer to drm_private_obj
In reply to Maxime RipardQuoted 8 lines · Maxime Ripard
All the objects that need to implement some callbacks in KMS have a pointer in there structure to the main
drm_device.However, it's not the case for
drm_private_objs, which makes it harder than it needs to be to implement some of its callbacks. Let's add that pointer.[...]
Applied to misc/kernel.git (drm-misc-next).
Thanks!
Maxime
Maxime Ripard
maintainerPATCH v2 2/16 drm/atomic: Make drm_atomic_private_obj_init fallible
In reply to Maxime RipardSince we're going to move the drm_private_obj state allocation to a callback, we need to be able to deal with its possible failure.
Make drm_private_obj_init return an error code on failure.
--- drivers/gpu/drm/drm_atomic.c | 14 +++++++++----- include/drm/drm_atomic.h | 8 ++++---- 2 files changed, 13 insertions(+), 9 deletions(-)
drivers/gpu/drm/drm_atomic.c +9 -5
@@ -779,16 +779,18 @@ static void drm_atomic_plane_print_state(struct drm_printer *p,* @funcs: pointer to the struct of function pointers that identify the object * type * * Initialize the private object, which can be embedded into any * driver private object that needs its own atomic state. +* +* RETURNS: +* Zero on success, error code on failure */ -void -drm_atomic_private_obj_init (struct drm_device *dev, -struct drm_private_obj *obj, -struct drm_private_state *state, -const struct drm_private_state_funcs *funcs) +int drm_atomic_private_obj_init (struct drm_device *dev, +struct drm_private_obj *obj, +struct drm_private_state *state, +const struct drm_private_state_funcs *funcs) {memset (obj,0 ,sizeof (*obj));drm_modeset_lock_init (&obj->lock);
@@ -796,10 +798,12 @@ drm_atomic_private_obj_init(struct drm_device *dev, obj->state = state; obj->funcs = funcs;list_add_tail (&obj->head, &dev->mode_config.privobj_list); state->obj = obj; + +return 0 ; }EXPORT_SYMBOL (drm_atomic_private_obj_init);/** * drm_atomic_private_obj_fini - finalize private object
include/drm/drm_atomic.h +4 -4
@@ -606,14 +606,14 @@ drm_atomic_get_plane_state(struct drm_atomic_state *state, struct drm_plane *plane);struct drm_connector_state *__must_check drm_atomic_get_connector_state (struct drm_atomic_state *state,struct drm_connector *connector); -void drm_atomic_private_obj_init (struct drm_device *dev, -struct drm_private_obj *obj, -struct drm_private_state *state, -const struct drm_private_state_funcs *funcs); +int drm_atomic_private_obj_init (struct drm_device *dev, +struct drm_private_obj *obj, +struct drm_private_state *state, +const struct drm_private_state_funcs *funcs);void drm_atomic_private_obj_fini (struct drm_private_obj *obj);struct drm_private_state *__must_check drm_atomic_get_private_obj_state (struct drm_atomic_state *state,struct drm_private_obj *obj);
Signature · 1 line
2.51.0
Maxime Ripard
maintainerPATCH v2 3/16 drm/atomic: Add new atomic_create_state callback to drm_private_obj
In reply to Maxime RipardThe 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.
--- drivers/gpu/drm/drm_atomic.c | 20 ++++++++++++++++++-- include/drm/drm_atomic.h | 13 +++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_atomic.c +18 -2
@@ -793,15 +793,31 @@ int drm_atomic_private_obj_init(struct drm_device *dev,memset (obj,0 ,sizeof (*obj));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.reset 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) { +if (obj->funcs->atomic_create_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 ; }EXPORT_SYMBOL (drm_atomic_private_obj_init);
include/drm/drm_atomic.h +13 -0
@@ -205,10 +205,23 @@ struct drm_private_state;* added to the atomic states is expected to have an implementation of these * hooks and pass a pointer to its drm_private_state_funcs struct to * drm_atomic_get_private_obj_state(). */ struct drm_private_state_funcs { +/** +* @atomic_create_state: +* +* Allocates a pristine, initialized, state for the private +* object and returns it. +* +* RETURNS: +* +* A new, pristine, private state instance or an error pointer +* on failure. +*/ +struct drm_private_state *(*atomic_create_state)(struct drm_private_obj *obj); +/** * @atomic_duplicate_state: * * Duplicate the current state of the private object and return it. It * is an error to call this before obj->state has been initialized.
Signature · 1 line
2.51.0
Re: [PATCH v2 03/16] drm/atomic: Add new atomic_create_state callback to drm_private_obj
Quoted 11 lines · Maxime Ripard
The
drm_private_objinitialization was inconsistent with the rest of the KMS objects. Indeed, it required to pass a preallocated state indrm_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 somedrm_private_obj, the DisplayPort ones in particular, need to be persistent across and suspend/resume cycle, and such a cycle would calldrm_mode_config_reset().
Doesn't that mean that we need to save private objects's state in drm_atomic_helper_duplicate_state() and restore it in drm_atomic_helper_commit_duplicated_state()? Private objects don't have .atomic_commit() callbacks, but they can be used by other objects during drm_atomic_commit().
Quoted 26 lines
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.
Signed-off-by Maxime Ripard <[email protected]>--- drivers/gpu/drm/drm_atomic.c | 20 ++++++++++++++++++-- include/drm/drm_atomic.h | 13 +++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-)drivers/gpu/drm/drm_atomic.c +0
-0@@ -793,15 +793,31 @@ int drm_atomic_private_obj_init(struct drm_device *dev,memset (obj,0 ,sizeof (*obj));drm_modeset_lock_init (&obj->lock); obj->dev = dev;
drivers/gpu/drm/drm_atomic.c int drm_atomic_private_obj_init(struct drm_device *dev, · line 805
Quoted 10 lines
drivers/gpu/drm/drm_atomic.c +5
-2- 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.reset yet. For the +* time being, let's only call reset if the passed state is +* NULL. Otherwise, we will fallback to the previous behaviour.
This comment does no longer reflect the code.
Quoted 50 lines
drivers/gpu/drm/drm_atomic.c +13
-0+*/ +if (!state) { +if (obj->funcs->atomic_create_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 ; }EXPORT_SYMBOL (drm_atomic_private_obj_init);include/drm/drm_atomic.h +13
-0@@ -205,10 +205,23 @@ struct drm_private_state;* added to the atomic states is expected to have an implementation of these * hooks and pass a pointer to its drm_private_state_funcs struct to * drm_atomic_get_private_obj_state(). */ struct drm_private_state_funcs { +/** +* @atomic_create_state: +* +* Allocates a pristine, initialized, state for the private +* object and returns it. +* +* RETURNS: +* +* A new, pristine, private state instance or an error pointer +* on failure. +*/ +struct drm_private_state *(*atomic_create_state)(struct drm_private_obj *obj); +/** * @atomic_duplicate_state: * * Duplicate the current state of the private object and return it. It * is an error to call this before obj->state has been initialized. Signature · 2 lines
-- 2.51.0
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH v2 03/16] drm/atomic: Add new atomic_create_state callback to drm_private_obj
Quoted 58 lines · Dmitry Baryshkov
Quoted 11 lines · Maxime Ripard
The
drm_private_objinitialization was inconsistent with the rest of the KMS objects. Indeed, it required to pass a preallocated state indrm_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 somedrm_private_obj, the DisplayPort ones in particular, need to be persistent across and suspend/resume cycle, and such a cycle would calldrm_mode_config_reset().Doesn't that mean that we need to save private objects's state in
drm_atomic_helper_duplicate_state()and restore it indrm_atomic_helper_commit_duplicated_state()? Private objects don't have .atomic_commit() callbacks, but they can be used by other objects duringdrm_atomic_commit().Quoted 26 lines
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.
Signed-off-by Maxime Ripard <[email protected]>--- drivers/gpu/drm/drm_atomic.c | 20 ++++++++++++++++++-- include/drm/drm_atomic.h | 13 +++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-)drivers/gpu/drm/drm_atomic.c +0
-0@@ -793,15 +793,31 @@ int drm_atomic_private_obj_init(struct drm_device *dev,memset (obj,0 ,sizeof (*obj));drm_modeset_lock_init (&obj->lock); obj->dev = dev;drivers/gpu/drm/drm_atomic.c int drm_atomic_private_obj_init(struct drm_device *dev, · line 805
Quoted 10 lines
drivers/gpu/drm/drm_atomic.c +5
-2- 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.reset yet. For the +* time being, let's only call reset if the passed state is +* NULL. Otherwise, we will fallback to the previous behaviour. This comment does no longer reflect the code.
Quoted 3 lines
drivers/gpu/drm/drm_atomic.c int drm_atomic_private_obj_init(struct drm_device *dev, · line 808
Quoted 3 lines
drivers/gpu/drm/drm_atomic.c +3
-0+*/ +if (!state) { +if (obj->funcs->atomic_create_state) {
Shouldn't this callback be mandatory here? Otherwise we can easily end up with the object without a connected state, if the driver doesn't implement it.
Quoted 51 lines
Quoted 47 lines
drivers/gpu/drm/drm_atomic.c +10
-0+ 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 ; }EXPORT_SYMBOL (drm_atomic_private_obj_init);include/drm/drm_atomic.h +13
-0@@ -205,10 +205,23 @@ struct drm_private_state;* added to the atomic states is expected to have an implementation of these * hooks and pass a pointer to its drm_private_state_funcs struct to * drm_atomic_get_private_obj_state(). */ struct drm_private_state_funcs { +/** +* @atomic_create_state: +* +* Allocates a pristine, initialized, state for the private +* object and returns it. +* +* RETURNS: +* +* A new, pristine, private state instance or an error pointer +* on failure. +*/ +struct drm_private_state *(*atomic_create_state)(struct drm_private_obj *obj); +/** * @atomic_duplicate_state: * * Duplicate the current state of the private object and return it. It * is an error to call this before obj->state has been initialized. Signature · 2 lines
-- 2.51.0Signature · 2 lines
With best wishes Dmitry
Signature · 2 lines
With best wishes Dmitry
Luca Ceresoli
reviewerRe: [PATCH v2 03/16] drm/atomic: Add new atomic_create_state callback to drm_private_obj
Hello Maxime, Dmitry,
Quoted 59 lines · Dmitry Baryshkov
Quoted 58 lines · Dmitry Baryshkov
Quoted 11 lines · Maxime Ripard
The
drm_private_objinitialization was inconsistent with the rest of the KMS objects. Indeed, it required to pass a preallocated state indrm_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 somedrm_private_obj, the DisplayPort ones in particular, need to be persistent across and suspend/resume cycle, and such a cycle would calldrm_mode_config_reset().Doesn't that mean that we need to save private objects's state in
drm_atomic_helper_duplicate_state()and restore it indrm_atomic_helper_commit_duplicated_state()? Private objects don't have .atomic_commit() callbacks, but they can be used by other objects duringdrm_atomic_commit().Quoted 26 lines
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.
Signed-off-by Maxime Ripard <[email protected]>--- drivers/gpu/drm/drm_atomic.c | 20 ++++++++++++++++++-- include/drm/drm_atomic.h | 13 +++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-)drivers/gpu/drm/drm_atomic.c +0
-0@@ -793,15 +793,31 @@ int drm_atomic_private_obj_init(struct drm_device *dev,memset (obj,0 ,sizeof (*obj));drm_modeset_lock_init (&obj->lock); obj->dev = dev;drivers/gpu/drm/drm_atomic.c int drm_atomic_private_obj_init(struct drm_device *dev, · line 805
Quoted 10 lines
drivers/gpu/drm/drm_atomic.c +5
-2- 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.reset yet. For the +* time being, let's only call reset if the passed state is +* NULL. Otherwise, we will fallback to the previous behaviour. This comment does no longer reflect the code.
Quoted 7 lines
Quoted 3 lines
drivers/gpu/drm/drm_atomic.c int drm_atomic_private_obj_init(struct drm_device *dev, · line 808
Quoted 3 lines
drivers/gpu/drm/drm_atomic.c +3
-0+*/ +if (!state) { +if (obj->funcs->atomic_create_state) {Shouldn't this callback be mandatory here? Otherwise we can easily end up with the object without a connected state, if the driver doesn't implement it.
AFAICT Dmitry's point looks reasonable to me. Should you go along this path, why not adding a
WARN_ON((!state && !obj->funcs->atomic_create_state) ||
(state && obj->funcs->atomic_create_state));to prevent bad usage?
Just my 2c,
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Maxime Ripard
maintainerRe: [PATCH v2 03/16] drm/atomic: Add new atomic_create_state callback to drm_private_obj
In reply to Dmitry BaryshkovHi,
Quoted 13 lines · Dmitry Baryshkov
Quoted 11 lines · Maxime Ripard
The
drm_private_objinitialization was inconsistent with the rest of the KMS objects. Indeed, it required to pass a preallocated state indrm_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 somedrm_private_obj, the DisplayPort ones in particular, need to be persistent across and suspend/resume cycle, and such a cycle would calldrm_mode_config_reset().
Quoted 5 lines
Doesn't that mean that we need to save private objects's state in
drm_atomic_helper_duplicate_state()and restore it indrm_atomic_helper_commit_duplicated_state()? Private objects don't have .atomic_commit() callbacks, but they can be used by other objects duringdrm_atomic_commit().
Not really, because private objs aren't reset in drm_mode_config_reset(), so there's nothing to save and restore, the objects before the suspend are still going to be there after the resume.
Maxime
Maxime Ripard
maintainerPATCH v2 4/16 drm/atomic-helper: Add private_obj atomic_create_state helper
In reply to Maxime RipardNow that we have an atomic_create_state callback for drm_private_objs, we can provide a helper for it.
It's somewhat different from the other similar helpers though, because we definitely expect drm_private_obj to be subclassed. It wouldn't make sense for a driver to use it as-is.
So we can't provide a straight implementation of the atomic_create_state callback, but rather we provide the parts that will deal with the drm_private_obj initialization, and we will leave the allocation and initialization of the subclass to drivers.
--- drivers/gpu/drm/drm_atomic_state_helper.c | 22 ++++++++++++++++++++++ include/drm/drm_atomic_state_helper.h | 3 +++ 2 files changed, 25 insertions(+)
drivers/gpu/drm/drm_atomic_state_helper.c +22 -0
@@ -707,10 +707,32 @@ void drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,__drm_atomic_helper_connector_destroy_state (state);kfree (state); }EXPORT_SYMBOL (drm_atomic_helper_connector_destroy_state); +/** +* __drm_atomic_helper_private_obj_create_state - initializes private object state +* @obj: private object +* @state: new state to initialize +* +* Initializes the newly allocated @state, usually required when +* initializing the drivers. +* +* @obj is assumed to be zeroed. +* +* This is useful for drivers that use private states. +*/ +void __drm_atomic_helper_private_obj_create_state (struct drm_private_obj *obj, +struct drm_private_state *state) +{ +if (state) + state->obj = obj; + + obj->state = state; +} +EXPORT_SYMBOL (__drm_atomic_helper_private_obj_create_state); +/** * __drm_atomic_helper_private_obj_duplicate_state - copy atomic private state * @obj: CRTC object * @state: new private object state *
include/drm/drm_atomic_state_helper.h +3 -0
@@ -82,10 +82,13 @@ struct drm_connector_state * drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector);void __drm_atomic_helper_connector_destroy_state (struct drm_connector_state *state);void drm_atomic_helper_connector_destroy_state (struct drm_connector *connector,struct drm_connector_state *state); + +void __drm_atomic_helper_private_obj_create_state (struct drm_private_obj *obj, +struct drm_private_state *state);void __drm_atomic_helper_private_obj_duplicate_state (struct drm_private_obj *obj,struct drm_private_state *state);void __drm_atomic_helper_bridge_duplicate_state (struct drm_bridge *bridge,struct drm_bridge_state *state);
Signature · 1 line
2.51.0
Re: [PATCH v2 04/16] drm/atomic-helper: Add private_obj atomic_create_state helper
Quoted 12 lines · Maxime Ripard
Now that we have an
atomic_create_statecallback fordrm_private_objs, we can provide a helper for it.It's somewhat different from the other similar helpers though, because we definitely expect
drm_private_objto be subclassed. It wouldn't make sense for a driver to use it as-is.So we can't provide a straight implementation of the
atomic_create_statecallback, but rather we provide the parts that will deal with thedrm_private_objinitialization, and we will leave the allocation and initialization of the subclass to drivers.
Quoted 6 lines
Signed-off-by Maxime Ripard <[email protected]>--- drivers/gpu/drm/drm_atomic_state_helper.c | 22 ++++++++++++++++++++++ include/drm/drm_atomic_state_helper.h | 3 +++ 2 files changed, 25 insertions(+)
Signature · 2 lines
With best wishes Dmitry
Maxime Ripard
maintainerPATCH v2 5/16 drm/bridge: Switch private_obj initialization to atomic_create_state
In reply to Maxime RipardThe bridge implementation relies on a drm_private_obj, that is initialized by allocating and initializing a state, and then passing it to drm_private_obj_init.
Since we're gradually moving away from that pattern to the more established one relying on a atomic_create_state implementation, let's migrate this instance to the new pattern.
---
--- drivers/gpu/drm/drm_bridge.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-)
drivers/gpu/drm/drm_bridge.c +18 -15
@@ -394,11 +394,27 @@ drm_bridge_atomic_destroy_priv_state(struct drm_private_obj *obj,struct drm_bridge *bridge =drm_priv_to_bridge (obj); bridge->funcs->atomic_destroy_state (bridge, state); } +static struct drm_private_state * +drm_bridge_atomic_create_priv_state (struct drm_private_obj *obj) +{ +struct drm_bridge *bridge =drm_priv_to_bridge (obj); +struct drm_bridge_state *state; + + state = bridge->funcs->atomic_reset (bridge); +if (IS_ERR (state)) +return ERR_PTR (-ENOMEM ); + +__drm_atomic_helper_private_obj_create_state (obj, &state->base); + +return &state->base; +} +static const struct drm_private_state_funcs drm_bridge_priv_state_funcs = { + .atomic_create_state = drm_bridge_atomic_create_priv_state, .atomic_duplicate_state = drm_bridge_atomic_duplicate_priv_state, .atomic_destroy_state = drm_bridge_atomic_destroy_priv_state, };static bool drm_bridge_is_atomic (struct drm_bridge *bridge)
@@ -462,30 +478,17 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, ret = bridge->funcs->attach (bridge, encoder, flags);if (ret <0 ) goto err_reset_bridge; } -if (drm_bridge_is_atomic (bridge)) { -struct drm_bridge_state *state; - - state = bridge->funcs->atomic_reset (bridge); -if (IS_ERR (state)) { - ret =PTR_ERR (state); - goto err_detach_bridge; - } - +if (drm_bridge_is_atomic (bridge))drm_atomic_private_obj_init (bridge->dev, &bridge->base, - &state->base, +NULL , &drm_bridge_priv_state_funcs); - }return 0 ; -err_detach_bridge: -if (bridge->funcs->detach) - bridge->funcs->detach (bridge); - err_reset_bridge: bridge->dev =NULL ; bridge->encoder =NULL ;list_del (&bridge->chain_node);
Signature · 1 line
2.51.0
Luca Ceresoli
reviewerRe: [PATCH v2 05/16] drm/bridge: Switch private_obj initialization to atomic_create_state
Hello Maxime,
Quoted 31 lines · Maxime Ripard
The bridge implementation relies on a
drm_private_obj, that is initialized by allocating and initializing a state, and then passing it todrm_private_obj_init.Since we're gradually moving away from that pattern to the more established one relying on a
atomic_create_stateimplementation, let's migrate this instance to the new pattern.Reviewed-by Dmitry Baryshkov <[email protected]>Signed-off-by Maxime Ripard <[email protected]>---
Cc Andrzej Hajda <[email protected]>Cc Neil Armstrong <[email protected]>Cc Robert Foss <[email protected]>Cc Laurent Pinchart <[email protected]>Cc Jonas Karlman <[email protected]>Cc Jernej Skrabec <[email protected]>--- drivers/gpu/drm/drm_bridge.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-)drivers/gpu/drm/drm_bridge.c +0
-0@@ -394,11 +394,27 @@ drm_bridge_atomic_destroy_priv_state(struct drm_private_obj *obj,struct drm_bridge *bridge =drm_priv_to_bridge (obj); bridge->funcs->atomic_destroy_state (bridge, state); }
drivers/gpu/drm/drm_bridge.c drm_bridge_atomic_destroy_priv_state(struct drm_private_obj *obj, · line 407
Quoted 10 lines
drivers/gpu/drm/drm_bridge.c +9
-0+static struct drm_private_state * +drm_bridge_atomic_create_priv_state (struct drm_private_obj *obj) +{ +struct drm_bridge *bridge =drm_priv_to_bridge (obj); +struct drm_bridge_state *state; + + state = bridge->funcs->atomic_reset (bridge); +if (IS_ERR (state)) +return ERR_PTR (-ENOMEM );
This is slightly changing the behaviour, assuming that every error is -ENOMEM, while in the current implementation any error code is just propagated. I searched all .atomic_reset callbacks and apparently none can return any other error, so this would not introduce a bug with current drivers. However the atomic_reset docs say any ERR_PTR can be returned, thus a future driver would be allowed to return another error value, even thoug it's unlikely. The drm_bridge.c core having no control over what other drivers do, I wonder whether we should just return ERR_PTR(state) here, and keep the check on the drm_atomic_private_obj_init() return value below.
I have no strong position about which direction is best however. Maybe changing the docs to say "Return: only -ENOMEM", and add here a WARN_ON(IS_ERR(state) && ERR_PTR(state) != -ENOMEM)?
Quoted 23 lines
drivers/gpu/drm/drm_bridge.c +2
-11@@ -462,30 +478,17 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, ret = bridge->funcs->attach (bridge, encoder, flags);if (ret <0 ) goto err_reset_bridge; } -if (drm_bridge_is_atomic (bridge)) { -struct drm_bridge_state *state; - - state = bridge->funcs->atomic_reset (bridge); -if (IS_ERR (state)) { - ret =PTR_ERR (state); - goto err_detach_bridge; - } - +if (drm_bridge_is_atomic (bridge))drm_atomic_private_obj_init (bridge->dev, &bridge->base, - &state->base, +NULL , &drm_bridge_priv_state_funcs); - }return 0 ;
drivers/gpu/drm/drm_bridge.c int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, · line 494
Quoted 10 lines
drivers/gpu/drm/drm_bridge.c +0
-4-err_detach_bridge: -if (bridge->funcs->detach) - bridge->funcs->detach (bridge); - err_reset_bridge: bridge->dev =NULL ; bridge->encoder =NULL ;list_del (&bridge->chain_node);
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Maxime Ripard
maintainerRe: [PATCH v2 05/16] drm/bridge: Switch private_obj initialization to atomic_create_state
Quoted 56 lines · Luca Ceresoli
Hello Maxime,
Quoted 31 lines · Maxime Ripard
The bridge implementation relies on a
drm_private_obj, that is initialized by allocating and initializing a state, and then passing it todrm_private_obj_init.Since we're gradually moving away from that pattern to the more established one relying on a
atomic_create_stateimplementation, let's migrate this instance to the new pattern.Reviewed-by Dmitry Baryshkov <[email protected]>Signed-off-by Maxime Ripard <[email protected]>---
Cc Andrzej Hajda <[email protected]>Cc Neil Armstrong <[email protected]>Cc Robert Foss <[email protected]>Cc Laurent Pinchart <[email protected]>Cc Jonas Karlman <[email protected]>Cc Jernej Skrabec <[email protected]>--- drivers/gpu/drm/drm_bridge.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-)drivers/gpu/drm/drm_bridge.c +0
-0@@ -394,11 +394,27 @@ drm_bridge_atomic_destroy_priv_state(struct drm_private_obj *obj,struct drm_bridge *bridge =drm_priv_to_bridge (obj); bridge->funcs->atomic_destroy_state (bridge, state); }drivers/gpu/drm/drm_bridge.c drm_bridge_atomic_destroy_priv_state(struct drm_private_obj *obj, · line 407
Quoted 10 lines
drivers/gpu/drm/drm_bridge.c +9
-0+static struct drm_private_state * +drm_bridge_atomic_create_priv_state (struct drm_private_obj *obj) +{ +struct drm_bridge *bridge =drm_priv_to_bridge (obj); +struct drm_bridge_state *state; + + state = bridge->funcs->atomic_reset (bridge); +if (IS_ERR (state)) +return ERR_PTR (-ENOMEM );This is slightly changing the behaviour, assuming that every error is
-ENOMEM, while in the current implementation any error code is just propagated. I searched all .atomic_reset callbacks and apparently none can return any other error, so this would not introduce a bug with current drivers. However theatomic_resetdocs say anyERR_PTRcan be returned, thus a future driver would be allowed to return another error value, even thoug it's unlikely. Thedrm_bridge.ccore having no control over what other drivers do, I wonder whether we should just returnERR_PTR(state)here, and keep the check on thedrm_atomic_private_obj_init()return value below.
Quoted 3 lines
I have no strong position about which direction is best however. Maybe changing the docs to say "Return: only
-ENOMEM", and add here aWARN_ON(IS_ERR(state) && ERR_PTR(state) != -ENOMEM)?
No, it's a good catch, we should totally return state and not ignore it.
Thanks!
Maxime
Maxime Ripard
maintainerPATCH v2 6/16 drm/dp_mst: Switch private_obj initialization to atomic_create_state
In reply to Maxime RipardThe DP MST implementation relies on a drm_private_obj, that is initialized by allocating and initializing a state, and then passing it to drm_private_obj_init.
Since we're gradually moving away from that pattern to the more established one relying on a atomic_create_state implementation, let's migrate this instance to the new pattern.
--- drivers/gpu/drm/display/drm_dp_mst_topology.c | 37 +++++++++++++++++---------- 1 file changed, 24 insertions(+), 13 deletions(-)
drivers/gpu/drm/display/drm_dp_mst_topology.c +24 -13
@@ -5181,10 +5181,32 @@ static void drm_dp_mst_destroy_state(struct drm_private_obj *obj,kfree (mst_state->commit_deps);kfree (mst_state); } +static struct drm_private_state * +drm_dp_mst_atomic_create_state (struct drm_private_obj *obj) +{ +struct drm_dp_mst_topology_mgr *mgr = +to_dp_mst_topology_mgr (obj); +struct drm_dp_mst_topology_state *mst_state; + + mst_state =kzalloc (sizeof (*mst_state),GFP_KERNEL ); +if (!mst_state) +return ERR_PTR (-ENOMEM ); + +__drm_atomic_helper_private_obj_create_state (obj, &mst_state->base); + + mst_state->total_avail_slots =63 ; + mst_state->start_slot =1 ; + + mst_state->mgr = mgr; +INIT_LIST_HEAD (&mst_state->payloads); + +return &mst_state->base; +} +static bool drm_dp_mst_port_downstream_of_branch (struct drm_dp_mst_port *port,struct drm_dp_mst_branch *branch) {while (port->parent) {if (port->parent == branch)
@@ -5617,10 +5639,11 @@ int drm_dp_mst_atomic_check(struct drm_atomic_state *state)return ret; }EXPORT_SYMBOL (drm_dp_mst_atomic_check);const struct drm_private_state_funcs drm_dp_mst_topology_state_funcs = { + .atomic_create_state = drm_dp_mst_atomic_create_state, .atomic_duplicate_state = drm_dp_mst_duplicate_state, .atomic_destroy_state = drm_dp_mst_destroy_state, };EXPORT_SYMBOL (drm_dp_mst_topology_state_funcs);
@@ -5705,12 +5728,10 @@ EXPORT_SYMBOL(drm_atomic_get_new_mst_topology_state);int drm_dp_mst_topology_mgr_init (struct drm_dp_mst_topology_mgr *mgr,struct drm_device *dev,struct drm_dp_aux *aux,int max_dpcd_transaction_bytes,int max_payloads,int conn_base_id) { -struct drm_dp_mst_topology_state *mst_state; -mutex_init (&mgr->lock);mutex_init (&mgr->qlock);mutex_init (&mgr->delayed_destroy_lock);mutex_init (&mgr->up_req_lock);mutex_init (&mgr->probe_lock);
@@ -5740,22 +5761,12 @@ int drm_dp_mst_topology_mgr_init(struct drm_dp_mst_topology_mgr *mgr, mgr->aux = aux; mgr->max_dpcd_transaction_bytes = max_dpcd_transaction_bytes; mgr->max_payloads = max_payloads; mgr->conn_base_id = conn_base_id; - mst_state =kzalloc (sizeof (*mst_state),GFP_KERNEL ); -if (mst_state ==NULL ) -return -ENOMEM ; - - mst_state->total_avail_slots =63 ; - mst_state->start_slot =1 ; - - mst_state->mgr = mgr; -INIT_LIST_HEAD (&mst_state->payloads); -drm_atomic_private_obj_init (dev, &mgr->base, - &mst_state->base, +NULL , &drm_dp_mst_topology_state_funcs);return 0 ; }EXPORT_SYMBOL (drm_dp_mst_topology_mgr_init);
Signature · 1 line
2.51.0
Maxime Ripard
maintainerPATCH v2 7/16 drm/dp_tunnel: Switch private_obj initialization to atomic_create_state
In reply to Maxime RipardThe DP tunnel implementation relies on a drm_private_obj, that is initialized by allocating and initializing a state, and then passing it to drm_private_obj_init.
Since we're gradually moving away from that pattern to the more established one relying on a atomic_create_state implementation, let's migrate this instance to the new pattern.
--- drivers/gpu/drm/display/drm_dp_tunnel.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)
drivers/gpu/drm/display/drm_dp_tunnel.c +16 -9
@@ -1495,11 +1495,26 @@ tunnel_group_duplicate_state(struct drm_private_obj *obj)static void tunnel_group_destroy_state (struct drm_private_obj *obj,struct drm_private_state *state) {free_group_state (to_group_state (state)); } +static struct drm_private_state *tunnel_group_atomic_create_state (struct drm_private_obj *obj) +{ +struct drm_dp_tunnel_group_state *group_state; + + group_state =kzalloc (sizeof (*group_state),GFP_KERNEL ); +if (!group_state) +return ERR_PTR (-ENOMEM ); + +__drm_atomic_helper_private_obj_create_state (obj, &group_state->base); +INIT_LIST_HEAD (&group_state->tunnel_states); + +return &group_state->base; +} +static const struct drm_private_state_funcs tunnel_group_funcs = { + .atomic_create_state = tunnel_group_atomic_create_state, .atomic_duplicate_state = tunnel_group_duplicate_state, .atomic_destroy_state = tunnel_group_destroy_state, };/**
@@ -1579,23 +1594,15 @@ drm_dp_tunnel_atomic_get_new_state(struct drm_atomic_state *state, }EXPORT_SYMBOL (drm_dp_tunnel_atomic_get_new_state);static bool init_group (struct drm_dp_tunnel_mgr *mgr,struct drm_dp_tunnel_group *group) { -struct drm_dp_tunnel_group_state *group_state; - - group_state =kzalloc (sizeof (*group_state),GFP_KERNEL ); -if (!group_state) -return false; - -INIT_LIST_HEAD (&group_state->tunnel_states); - group->mgr = mgr; group->available_bw =-1 ;INIT_LIST_HEAD (&group->tunnels); -drm_atomic_private_obj_init (mgr->dev, &group->base, &group_state->base, +drm_atomic_private_obj_init (mgr->dev, &group->base,NULL , &tunnel_group_funcs);return true; }
Signature · 1 line
2.51.0
Maxime Ripard
maintainerPATCH v2 8/16 drm/amdgpu: Switch private_obj initialization to atomic_create_state
In reply to Maxime RipardThe amdgpu driver relies on a drm_private_obj, that is initialized by allocating and initializing a state, and then passing it to drm_private_obj_init.
Since we're gradually moving away from that pattern to the more established one relying on a atomic_create_state implementation, let's migrate this instance to the new pattern.
---
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 52 ++++++++++++----------- 1 file changed, 28 insertions(+), 24 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +28 -24
@@ -4675,18 +4675,41 @@ static void dm_atomic_destroy_state(struct drm_private_obj *obj,dc_state_release (dm_state->context);kfree (dm_state); } +static struct drm_private_state * +dm_atomic_create_state (struct drm_private_obj *obj) +{ +struct amdgpu_device *adev =drm_to_adev (obj->dev); +struct dm_atomic_state *dm_state; +struct dc_state *context; + + dm_state =kzalloc (sizeof (*dm_state),GFP_KERNEL ); +if (!dm_state) +return ERR_PTR (-ENOMEM ); + + context =dc_state_create_current_copy (adev->dm.dc); +if (!context) { +kfree (dm_state); +return ERR_PTR (-ENOMEM ); + } + +__drm_atomic_helper_private_obj_create_state (obj, &dm_state->base); + dm_state->context = context; + +return &dm_state->base; +} +static struct drm_private_state_funcs dm_atomic_state_funcs = { + .atomic_create_state = dm_atomic_create_state, .atomic_duplicate_state = dm_atomic_duplicate_state, .atomic_destroy_state = dm_atomic_destroy_state, };static int amdgpu_dm_mode_config_init (struct amdgpu_device *adev) { -struct dm_atomic_state *state;int r; adev->mode_info.mode_config_initialized = true;adev_to_drm (adev)->mode_config.funcs = (void *)&amdgpu_dm_mode_funcs;
@@ -4702,46 +4725,27 @@ static int amdgpu_dm_mode_config_init(struct amdgpu_device *adev)else adev_to_drm (adev)->mode_config.prefer_shadow =1 ;/* indicates support for immediate flip */ adev_to_drm (adev)->mode_config.async_page_flip = true; - state =kzalloc (sizeof (*state),GFP_KERNEL ); -if (!state) -return -ENOMEM ; - - state->context =dc_state_create_current_copy (adev->dm.dc); -if (!state->context) { -kfree (state); -return -ENOMEM ; - } -drm_atomic_private_obj_init (adev_to_drm (adev), &adev->dm.atomic_obj, - &state->base, +NULL , &dm_atomic_state_funcs); r =amdgpu_display_modeset_create_props (adev); -if (r) { -dc_state_release (state->context); -kfree (state); +if (r)return r; - }#ifdef AMD_PRIVATE_COLOR -if (amdgpu_dm_create_color_properties (adev)) { -dc_state_release (state->context); -kfree (state); +if (amdgpu_dm_create_color_properties (adev))return -ENOMEM ; - }#endif r =amdgpu_dm_audio_init (adev); -if (r) { -dc_state_release (state->context); -kfree (state); +if (r)return r; - }return 0 ; }#define AMDGPU_DM_DEFAULT_MIN_BACKLIGHT 12
Signature · 1 line
2.51.0
Maxime Ripard
maintainerPATCH v2 9/16 drm/arm: komeda: Switch private_obj initialization to atomic_create_state
In reply to Maxime RipardThe ARM komeda driver relies on a number of drm_private_objs, that are initialized by allocating and initializing a state, and then passing it to drm_private_obj_init.
Since we're gradually moving away from that pattern to the more established one relying on a atomic_create_state implementation, let's migrate this instance to the new pattern.
---
--- .../gpu/drm/arm/display/komeda/komeda_pipeline.h | 2 + .../drm/arm/display/komeda/komeda_private_obj.c | 208 ++++++++++++++------- 2 files changed, 146 insertions(+), 64 deletions(-)
drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h +2 -0
@@ -126,10 +126,12 @@ struct komeda_component {* @funcs: chip functions to access HW */ const struct komeda_component_funcs *funcs; }; +#define to_component (o) container_of(o, struct komeda_component, obj) +/** * struct komeda_component_output * * a component has multiple outputs, if want to know where the data * comes from, only know the component is not enough, we still need to know
drivers/gpu/drm/arm/display/komeda/komeda_private_obj.c +144 -64
355 lines not on this page · raw message
Signature · 1 line
2.51.0
Maxime Ripard
maintainerPATCH v2 10/16 drm/ingenic: Switch private_obj initialization to atomic_create_state
In reply to Maxime RipardThe ingenic driver relies on two drm_private_objs, that are initialized by allocating and initializing a state, and then passing it to drm_private_obj_init.
Since we're gradually moving away from that pattern to the more established one relying on a atomic_create_state implementation, let's migrate this instance to the new pattern.
---
--- drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 28 +++++++++++++++++----------- drivers/gpu/drm/ingenic/ingenic-ipu.c | 28 ++++++++++++++++------------ 2 files changed, 33 insertions(+), 23 deletions(-)
drivers/gpu/drm/ingenic/ingenic-drm-drv.c +17 -11
@@ -947,10 +947,24 @@ static void ingenic_drm_destroy_state(struct drm_private_obj *obj,struct ingenic_drm_private_state *priv_state =to_ingenic_drm_priv_state (state);kfree (priv_state); } +static struct drm_private_state * +ingenic_drm_create_state (struct drm_private_obj *obj) +{ +struct ingenic_drm_private_state *priv_state; + + priv_state =kzalloc (sizeof (*priv_state),GFP_KERNEL ); +if (!priv_state) +return ERR_PTR (-ENOMEM ); + +__drm_atomic_helper_private_obj_create_state (obj, &priv_state->base); + +return &priv_state->base; +} +DEFINE_DRM_GEM_DMA_FOPS (ingenic_drm_fops);static const struct drm_driver ingenic_drm_driver_data = { .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_ATOMIC , .name ="ingenic-drm" ,
@@ -1027,10 +1041,11 @@ static const struct drm_mode_config_funcs ingenic_drm_mode_config_funcs = {static struct drm_mode_config_helper_funcs ingenic_drm_mode_config_helpers = { .atomic_commit_tail = drm_atomic_helper_commit_tail, };static const struct drm_private_state_funcs ingenic_drm_private_state_funcs = { + .atomic_create_state = ingenic_drm_create_state, .atomic_duplicate_state = ingenic_drm_duplicate_state, .atomic_destroy_state = ingenic_drm_destroy_state, };static void ingenic_drm_unbind_all (void *d)
@@ -1080,11 +1095,10 @@ static void ingenic_drm_atomic_private_obj_fini(struct drm_device *drm, void *pr }static int ingenic_drm_bind (struct device *dev,bool has_components) {struct platform_device *pdev =to_platform_device (dev); -struct ingenic_drm_private_state *private_state;const struct jz_soc_info *soc_info;struct ingenic_drm *priv;struct clk *parent_clk;struct drm_plane *primary;struct drm_bridge *bridge;
@@ -1380,23 +1394,17 @@ static int ingenic_drm_bind(struct device *dev, bool has_components)if (ret) {dev_err (dev,"Unable to register clock notifier\n" ); goto err_devclk_disable; } - private_state =kzalloc (sizeof (*private_state),GFP_KERNEL ); -if (!private_state) { - ret = -ENOMEM ; - goto err_clk_notifier_unregister; - } - -drm_atomic_private_obj_init (drm, &priv->private_obj, &private_state->base, +drm_atomic_private_obj_init (drm, &priv->private_obj,NULL , &ingenic_drm_private_state_funcs); ret =drmm_add_action_or_reset (drm, ingenic_drm_atomic_private_obj_fini, &priv->private_obj);if (ret) - goto err_private_state_free; + goto err_clk_notifier_unregister; ret =drm_dev_register (drm,0 );if (ret) {dev_err (dev,"Failed to register DRM driver\n" ); goto err_clk_notifier_unregister;
@@ -1404,12 +1412,10 @@ static int ingenic_drm_bind(struct device *dev, bool has_components)drm_client_setup (drm,NULL );return 0 ; -err_private_state_free: -kfree (private_state); err_clk_notifier_unregister:clk_notifier_unregister (parent_clk, &priv->clock_nb); err_devclk_disable:if (priv->lcd_clk)clk_disable_unprepare (priv->lcd_clk);
drivers/gpu/drm/ingenic/ingenic-ipu.c +16 -12
@@ -748,11 +748,26 @@ static void ingenic_ipu_destroy_state(struct drm_private_obj *obj,struct ingenic_ipu_private_state *priv_state =to_ingenic_ipu_priv_state (state);kfree (priv_state); } +static struct drm_private_state * +ingenic_ipu_create_state (struct drm_private_obj *obj) +{ +struct ingenic_ipu_private_state *priv_state; + + priv_state =kzalloc (sizeof (*priv_state),GFP_KERNEL ); +if (!priv_state) +return ERR_PTR (-ENOMEM ); + +__drm_atomic_helper_private_obj_create_state (obj, &priv_state->base); + +return &priv_state->base; +} +static const struct drm_private_state_funcs ingenic_ipu_private_state_funcs = { + .atomic_create_state = ingenic_ipu_create_state, .atomic_duplicate_state = ingenic_ipu_duplicate_state, .atomic_destroy_state = ingenic_ipu_destroy_state, };static irqreturn_t ingenic_ipu_irq_handler (int irq,void *arg)
@@ -791,11 +806,10 @@ static const struct regmap_config ingenic_ipu_regmap_config = { };static int ingenic_ipu_bind (struct device *dev,struct device *master,void *d) {struct platform_device *pdev =to_platform_device (dev); -struct ingenic_ipu_private_state *private_state;const struct soc_info *soc_info;struct drm_device *drm = d;struct drm_plane *plane;struct ingenic_ipu *ipu;void __iomem *base;
@@ -885,24 +899,14 @@ static int ingenic_ipu_bind(struct device *dev, struct device *master, void *d)if (err) {dev_err (dev,"Unable to prepare clock\n" );return err; } - private_state =kzalloc (sizeof (*private_state),GFP_KERNEL ); -if (!private_state) { - err = -ENOMEM ; - goto err_clk_unprepare; - } - -drm_atomic_private_obj_init (drm, &ipu->private_obj, &private_state->base, +drm_atomic_private_obj_init (drm, &ipu->private_obj,NULL , &ingenic_ipu_private_state_funcs);return 0 ; - -err_clk_unprepare: -clk_unprepare (ipu->clk); -return err; }static void ingenic_ipu_unbind (struct device *dev,struct device *master,void *d) {
Signature · 1 line
2.51.0
Maxime Ripard
maintainerPATCH v2 11/16 drm/msm: mdp5: Switch private_obj initialization to atomic_create_state
In reply to Maxime RipardThe MSM mdp5 driver relies on a drm_private_obj, that is initialized by allocating and initializing a state, and then passing it to drm_private_obj_init.
Since we're gradually moving away from that pattern to the more established one relying on a atomic_create_state implementation, let's migrate this instance to the new pattern.
---
--- drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c | 41 +++++++++++++++++--------------- 1 file changed, 22 insertions(+), 19 deletions(-)
drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c +22 -19
@@ -112,41 +112,44 @@ static void mdp5_global_destroy_state(struct drm_private_obj *obj,struct mdp5_global_state *mdp5_state =to_mdp5_global_state (state);kfree (mdp5_state); } +static struct drm_private_state * +mdp5_global_create_state (struct drm_private_obj *obj) +{ +struct drm_device *dev = obj->dev; +struct msm_drm_private *priv = dev->dev_private; +struct mdp5_kms *mdp5_kms =to_mdp5_kms (to_mdp_kms (priv->kms)); +struct mdp5_global_state *mdp5_state; + + mdp5_state =kzalloc (sizeof (*mdp5_state),GFP_KERNEL ); +if (!mdp5_state) +return ERR_PTR (-ENOMEM ); + +__drm_atomic_helper_private_obj_create_state (obj, &mdp5_state->base); + mdp5_state->mdp5_kms = mdp5_kms; + +return &mdp5_state->base; +} +static void mdp5_global_print_state (struct drm_printer *p,const struct drm_private_state *state) {struct mdp5_global_state *mdp5_state =to_mdp5_global_state (state);if (mdp5_state->mdp5_kms->smp)mdp5_smp_dump (mdp5_state->mdp5_kms->smp, p, mdp5_state); }static const struct drm_private_state_funcs mdp5_global_state_funcs = { + .atomic_create_state = mdp5_global_create_state, .atomic_duplicate_state = mdp5_global_duplicate_state, .atomic_destroy_state = mdp5_global_destroy_state, .atomic_print_state = mdp5_global_print_state, }; -static int mdp5_global_obj_init (struct mdp5_kms *mdp5_kms) -{ -struct mdp5_global_state *state; - - state =kzalloc (sizeof (*state),GFP_KERNEL ); -if (!state) -return -ENOMEM ; - - state->mdp5_kms = mdp5_kms; - -drm_atomic_private_obj_init (mdp5_kms->dev, &mdp5_kms->glob_state, - &state->base, - &mdp5_global_state_funcs); -return 0 ; -} -static void mdp5_enable_commit (struct msm_kms *kms) {struct mdp5_kms *mdp5_kms =to_mdp5_kms (to_mdp_kms (kms));pm_runtime_get_sync (&mdp5_kms->pdev->dev); }
@@ -711,13 +714,13 @@ static int mdp5_init(struct platform_device *pdev, struct drm_device *dev)u32 major, minor;int ret; mdp5_kms->dev = dev; - ret =mdp5_global_obj_init (mdp5_kms); -if (ret) - goto fail; +drm_atomic_private_obj_init (mdp5_kms->dev, &mdp5_kms->glob_state, +NULL , + &mdp5_global_state_funcs);/* we need to set a default rate before enabling. Set a safe * rate first, then figure out hw revision, and then set a * more optimal rate: */
Signature · 1 line
2.51.0
Re: [PATCH v2 11/16] drm/msm: mdp5: Switch private_obj initialization to atomic_create_state
Quoted 20 lines · Maxime Ripard
The MSM mdp5 driver relies on a
drm_private_obj, that is initialized by allocating and initializing a state, and then passing it todrm_private_obj_init.Since we're gradually moving away from that pattern to the more established one relying on a
atomic_create_stateimplementation, let's migrate this instance to the new pattern.Signed-off-by Maxime Ripard <[email protected]>---
Cc Rob Clark <[email protected]>Cc Dmitry Baryshkov <[email protected]>Cc Abhinav Kumar <[email protected]>Cc Jessica Zhang <[email protected]>Cc Sean Paul <[email protected]>Cc Marijn Suijten <[email protected]>
Quoted 4 lines
--- drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c | 41 +++++++++++++++++--------------- 1 file changed, 22 insertions(+), 19 deletions(-)
Signature · 2 lines
With best wishes Dmitry
Maxime Ripard
maintainerPATCH v2 12/16 drm/msm: dpu1: Switch private_obj initialization to atomic_create_state
In reply to Maxime RipardThe MSM dpu1 driver relies on a drm_private_obj, that is initialized by allocating and initializing a state, and then passing it to drm_private_obj_init.
Since we're gradually moving away from that pattern to the more established one relying on a atomic_create_state implementation, let's migrate this instance to the new pattern.
---
--- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 42 +++++++++++++++++---------------- 1 file changed, 22 insertions(+), 20 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +22 -20
@@ -365,41 +365,43 @@ static void dpu_kms_global_destroy_state(struct drm_private_obj *obj,struct dpu_global_state *dpu_state =to_dpu_global_state (state);kfree (dpu_state); } +static struct drm_private_state * +dpu_kms_global_create_state (struct drm_private_obj *obj) +{ +struct drm_device *dev = obj->dev; +struct msm_drm_private *priv = dev->dev_private; +struct dpu_kms *dpu_kms =to_dpu_kms (priv->kms); +struct dpu_global_state *dpu_state; + + dpu_state =kzalloc (sizeof (*dpu_state),GFP_KERNEL ); +if (!dpu_state) +return ERR_PTR (-ENOMEM ); + +__drm_atomic_helper_private_obj_create_state (obj, &dpu_state->base); + dpu_state->rm = &dpu_kms->rm; + +return &dpu_state->base; +} +static void dpu_kms_global_print_state (struct drm_printer *p,const struct drm_private_state *state) {const struct dpu_global_state *global_state =to_dpu_global_state (state);dpu_rm_print_state (p, global_state); }static const struct drm_private_state_funcs dpu_kms_global_state_funcs = { + .atomic_create_state = dpu_kms_global_create_state, .atomic_duplicate_state = dpu_kms_global_duplicate_state, .atomic_destroy_state = dpu_kms_global_destroy_state, .atomic_print_state = dpu_kms_global_print_state, }; -static int dpu_kms_global_obj_init (struct dpu_kms *dpu_kms) -{ -struct dpu_global_state *state; - - state =kzalloc (sizeof (*state),GFP_KERNEL ); -if (!state) -return -ENOMEM ; - -drm_atomic_private_obj_init (dpu_kms->dev, &dpu_kms->global_state, - &state->base, - &dpu_kms_global_state_funcs); - - state->rm = &dpu_kms->rm; - -return 0 ; -} -static void dpu_kms_global_obj_fini (struct dpu_kms *dpu_kms) {drm_atomic_private_obj_fini (&dpu_kms->global_state); }
@@ -1156,13 +1158,13 @@ static int dpu_kms_hw_init(struct msm_kms *kms) dev = dpu_kms->dev; dev->mode_config.cursor_width =512 ; dev->mode_config.cursor_height =512 ; - rc =dpu_kms_global_obj_init (dpu_kms); -if (rc) -return rc; +drm_atomic_private_obj_init (dpu_kms->dev, &dpu_kms->global_state, +NULL , + &dpu_kms_global_state_funcs);atomic_set (&dpu_kms->bandwidth_ref,0 ); rc =pm_runtime_resume_and_get (&dpu_kms->pdev->dev);if (rc <0 )
Signature · 1 line
2.51.0
Re: [PATCH v2 12/16] drm/msm: dpu1: Switch private_obj initialization to atomic_create_state
Quoted 19 lines · Maxime Ripard
The MSM dpu1 driver relies on a
drm_private_obj, that is initialized by allocating and initializing a state, and then passing it todrm_private_obj_init.Since we're gradually moving away from that pattern to the more established one relying on a
atomic_create_stateimplementation, let's migrate this instance to the new pattern.Signed-off-by Maxime Ripard <[email protected]>---
Cc Rob Clark <[email protected]>Cc Dmitry Baryshkov <[email protected]>Cc Abhinav Kumar <[email protected]>Cc Jessica Zhang <[email protected]>Cc Sean Paul <[email protected]>Cc Marijn Suijten <[email protected]>
Quoted 4 lines
--- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 42 +++++++++++++++++---------------- 1 file changed, 22 insertions(+), 20 deletions(-)
Signature · 2 lines
With best wishes Dmitry
Maxime Ripard
maintainerPATCH v2 13/16 drm/omapdrm: Switch private_obj initialization to atomic_create_state
In reply to Maxime RipardThe omapdrm driver relies on a drm_private_obj, that is initialized by allocating and initializing a state, and then passing it to drm_private_obj_init.
Since we're gradually moving away from that pattern to the more established one relying on a atomic_create_state implementation, let's migrate this instance to the new pattern.
---
--- drivers/gpu/drm/omapdrm/omap_drv.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
drivers/gpu/drm/omapdrm/omap_drv.c +16 -6
@@ -272,25 +272,35 @@ static void omap_global_destroy_state(struct drm_private_obj *obj,struct omap_global_state *omap_state =to_omap_global_state (state);kfree (omap_state); } +static struct drm_private_state * +omap_global_atomic_create_state (struct drm_private_obj *obj) +{ +struct omap_global_state *state; + + state =kzalloc (sizeof (*state),GFP_KERNEL ); +if (!state) +return ERR_PTR (-ENOMEM ); + +__drm_atomic_helper_private_obj_create_state (obj, &state->base); + +return &state->base; +} +static const struct drm_private_state_funcs omap_global_state_funcs = { + .atomic_create_state = omap_global_atomic_create_state, .atomic_duplicate_state = omap_global_duplicate_state, .atomic_destroy_state = omap_global_destroy_state, };static int omap_global_obj_init (struct drm_device *dev) {struct omap_drm_private *priv = dev->dev_private; -struct omap_global_state *state; - state =kzalloc (sizeof (*state),GFP_KERNEL ); -if (!state) -return -ENOMEM ; - -drm_atomic_private_obj_init (dev, &priv->glob_obj, &state->base, +drm_atomic_private_obj_init (dev, &priv->glob_obj,NULL , &omap_global_state_funcs);return 0 ; }static void omap_global_obj_fini (struct omap_drm_private *priv)
Signature · 1 line
2.51.0
Maxime Ripard
maintainerPATCH v2 14/16 drm/tegra: Switch private_obj initialization to atomic_create_state
In reply to Maxime RipardThe tegra driver relies on a drm_private_obj, that is initialized by allocating and initializing a state, and then passing it to drm_private_obj_init.
Since we're gradually moving away from that pattern to the more established one relying on a atomic_create_state implementation, let's migrate this instance to the new pattern.
---
--- drivers/gpu/drm/tegra/hub.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
drivers/gpu/drm/tegra/hub.c +16 -6
@@ -822,11 +822,26 @@ static void tegra_display_hub_destroy_state(struct drm_private_obj *obj,to_tegra_display_hub_state (state);kfree (hub_state); } +static struct drm_private_state * +tegra_display_hub_create_state (struct drm_private_obj *obj) +{ +struct tegra_display_hub_state *hub_state; + + hub_state =kzalloc (sizeof (*hub_state),GFP_KERNEL ); +if (!hub_state) +return ERR_PTR (-ENOMEM ); + +__drm_atomic_helper_private_obj_create_state (obj, &hub_state->base); + +return &hub_state->base; +} +static const struct drm_private_state_funcs tegra_display_hub_state_funcs = { + .atomic_create_state = tegra_display_hub_create_state, .atomic_duplicate_state = tegra_display_hub_duplicate_state, .atomic_destroy_state = tegra_display_hub_destroy_state, }; static struct tegra_display_hub_state *
@@ -938,17 +953,12 @@ void tegra_display_hub_atomic_commit(struct drm_device *drm,static int tegra_display_hub_init (struct host1x_client *client) {struct tegra_display_hub *hub =to_tegra_display_hub (client);struct drm_device *drm =dev_get_drvdata (client->host);struct tegra_drm *tegra = drm->dev_private; -struct tegra_display_hub_state *state; - state =kzalloc (sizeof (*state),GFP_KERNEL ); -if (!state) -return -ENOMEM ; - -drm_atomic_private_obj_init (drm, &hub->base, &state->base, +drm_atomic_private_obj_init (drm, &hub->base,NULL , &tegra_display_hub_state_funcs); tegra->hub = hub;return 0 ;
Signature · 1 line
2.51.0
Maxime Ripard
maintainerPATCH v2 15/16 drm/vc4: Switch private_obj initialization to atomic_create_state
In reply to Maxime RipardThe vc4 driver relies on a drm_private_obj, that is initialized by allocating and initializing a state, and then passing it to drm_private_obj_init.
Since we're gradually moving away from that pattern to the more established one relying on a atomic_create_state implementation, let's migrate this instance to the new pattern.
---
--- drivers/gpu/drm/vc4/vc4_kms.c | 69 ++++++++++++++++++++++++++++++------------- 1 file changed, 48 insertions(+), 21 deletions(-)
drivers/gpu/drm/vc4/vc4_kms.c +48 -21
@@ -82,11 +82,26 @@ static void vc4_ctm_destroy_state(struct drm_private_obj *obj,struct vc4_ctm_state *ctm_state =to_vc4_ctm_state (state);kfree (ctm_state); } +static struct drm_private_state * +vc4_ctm_create_state (struct drm_private_obj *obj) +{ +struct vc4_ctm_state *ctm_state; + + ctm_state =kzalloc (sizeof (*ctm_state),GFP_KERNEL ); +if (!ctm_state) +return ERR_PTR (-ENOMEM ); + +__drm_atomic_helper_private_obj_create_state (obj, &ctm_state->base); + +return &ctm_state->base; +} +static const struct drm_private_state_funcs vc4_ctm_state_funcs = { + .atomic_create_state = vc4_ctm_create_state, .atomic_duplicate_state = vc4_ctm_duplicate_state, .atomic_destroy_state = vc4_ctm_destroy_state, };static void vc4_ctm_obj_fini (struct drm_device *dev,void *unused)
@@ -96,19 +111,13 @@ static void vc4_ctm_obj_fini(struct drm_device *dev, void *unused)drm_atomic_private_obj_fini (&vc4->ctm_manager); }static int vc4_ctm_obj_init (struct vc4_dev *vc4) { -struct vc4_ctm_state *ctm_state; -drm_modeset_lock_init (&vc4->ctm_state_lock); - ctm_state =kzalloc (sizeof (*ctm_state),GFP_KERNEL ); -if (!ctm_state) -return -ENOMEM ; - -drm_atomic_private_obj_init (&vc4->base, &vc4->ctm_manager, &ctm_state->base, +drm_atomic_private_obj_init (&vc4->base, &vc4->ctm_manager,NULL , &vc4_ctm_state_funcs);return drmm_add_action_or_reset (&vc4->base, vc4_ctm_obj_fini,NULL ); }
@@ -715,13 +724,28 @@ static void vc4_load_tracker_destroy_state(struct drm_private_obj *obj, load_state =to_vc4_load_tracker_state (state);kfree (load_state); } +static struct drm_private_state * +vc4_load_tracker_create_state (struct drm_private_obj *obj) +{ +struct vc4_load_tracker_state *load_state; + + load_state =kzalloc (sizeof (*load_state),GFP_KERNEL ); +if (!load_state) +return ERR_PTR (-ENOMEM ); + +__drm_atomic_helper_private_obj_create_state (obj, &load_state->base); + +return &load_state->base; +} +static const struct drm_private_state_funcs vc4_load_tracker_state_funcs = { .atomic_duplicate_state = vc4_load_tracker_duplicate_state, .atomic_destroy_state = vc4_load_tracker_destroy_state, + .atomic_create_state = vc4_load_tracker_create_state, };static void vc4_load_tracker_obj_fini (struct drm_device *dev,void *unused) {struct vc4_dev *vc4 =to_vc4_dev (dev);
@@ -729,18 +753,12 @@ static void vc4_load_tracker_obj_fini(struct drm_device *dev, void *unused)drm_atomic_private_obj_fini (&vc4->load_tracker); }static int vc4_load_tracker_obj_init (struct vc4_dev *vc4) { -struct vc4_load_tracker_state *load_state; - - load_state =kzalloc (sizeof (*load_state),GFP_KERNEL ); -if (!load_state) -return -ENOMEM ; -drm_atomic_private_obj_init (&vc4->base, &vc4->load_tracker, - &load_state->base, +NULL , &vc4_load_tracker_state_funcs);return drmm_add_action_or_reset (&vc4->base, vc4_load_tracker_obj_fini,NULL ); }
@@ -797,11 +815,26 @@ static void vc4_hvs_channels_print_state(struct drm_printer *p,drm_printf (p,"\t\tin use=%d\n" , hvs_state->fifo_state[i].in_use);drm_printf (p,"\t\tload=%lu\n" , hvs_state->fifo_state[i].fifo_load); } } +static struct drm_private_state * +vc4_hvs_channels_create_state (struct drm_private_obj *obj) +{ +struct vc4_hvs_state *hvs_state; + + hvs_state =kzalloc (sizeof (*hvs_state),GFP_KERNEL ); +if (!hvs_state) +return ERR_PTR (-ENOMEM ); + +__drm_atomic_helper_private_obj_create_state (obj, &hvs_state->base); + +return &hvs_state->base; +} +static const struct drm_private_state_funcs vc4_hvs_state_funcs = { + .atomic_create_state = vc4_hvs_channels_create_state, .atomic_duplicate_state = vc4_hvs_channels_duplicate_state, .atomic_destroy_state = vc4_hvs_channels_destroy_state, .atomic_print_state = vc4_hvs_channels_print_state, };
@@ -812,18 +845,12 @@ static void vc4_hvs_channels_obj_fini(struct drm_device *dev, void *unused)drm_atomic_private_obj_fini (&vc4->hvs_channels); }static int vc4_hvs_channels_obj_init (struct vc4_dev *vc4) { -struct vc4_hvs_state *state; - - state =kzalloc (sizeof (*state),GFP_KERNEL ); -if (!state) -return -ENOMEM ; -drm_atomic_private_obj_init (&vc4->base, &vc4->hvs_channels, - &state->base, +NULL , &vc4_hvs_state_funcs);return drmm_add_action_or_reset (&vc4->base, vc4_hvs_channels_obj_fini,NULL ); }
Signature · 1 line
2.51.0
Maxime Ripard
maintainerPATCH v2 16/16 drm/atomic: Remove state argument to drm_atomic_private_obj_init
In reply to Maxime RipardNow that all drm_private_objs users have been converted to use atomic_create_state instead of the old ad-hoc initialization, we can remove the state parameter from drm_private_obj_init and the fallback code.
---
To: Liviu Dudau <[email protected]>
To: Andrzej Hajda <[email protected]>
To: Neil Armstrong <[email protected]>
To: Robert Foss <[email protected]>
To: Paul Cercueil <[email protected]>
To: Tomi Valkeinen <[email protected]>
To: Thierry Reding <[email protected]>
To: Mikko Perttunen <[email protected]>
To: Jonathan Hunter <[email protected]>
To: Dave Stevenson <[email protected]>
Cc: Rodrigo Siqueira <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Abhinav Kumar <[email protected]>
Cc: Jessica Zhang <[email protected]>
Cc: Sean Paul <[email protected]>
Cc: Marijn Suijten <[email protected]>
Cc: "Maíra Canal" <[email protected]>
Cc: Raspberry Pi Kernel Maintenance <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 1 - .../gpu/drm/arm/display/komeda/komeda_private_obj.c | 16 ++++++++-------- drivers/gpu/drm/display/drm_dp_mst_topology.c | 1 - drivers/gpu/drm/display/drm_dp_tunnel.c | 2 +- drivers/gpu/drm/drm_atomic.c | 21 ++++----------------- drivers/gpu/drm/drm_bridge.c | 1 - drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 2 +- drivers/gpu/drm/ingenic/ingenic-ipu.c | 2 +- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 1 - drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c | 1 - drivers/gpu/drm/omapdrm/omap_drv.c | 2 +- drivers/gpu/drm/tegra/hub.c | 2 +- drivers/gpu/drm/vc4/vc4_kms.c | 4 +--- include/drm/drm_atomic.h | 1 - 14 files changed, 18 insertions(+), 39 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -1
@@ -4727,11 +4727,10 @@ static int amdgpu_dm_mode_config_init(struct amdgpu_device *adev)/* indicates support for immediate flip */ adev_to_drm (adev)->mode_config.async_page_flip = true;drm_atomic_private_obj_init (adev_to_drm (adev), &adev->dm.atomic_obj, -NULL , &dm_atomic_state_funcs); r =amdgpu_display_modeset_create_props (adev);if (r)return r;
drivers/gpu/drm/arm/display/komeda/komeda_private_obj.c +8 -8
@@ -63,11 +63,11 @@ static const struct drm_private_state_funcs komeda_layer_obj_funcs = { };static int komeda_layer_obj_add (struct komeda_kms_dev *kms,struct komeda_layer *layer) { -drm_atomic_private_obj_init (&kms->base, &layer->base.obj,NULL , +drm_atomic_private_obj_init (&kms->base, &layer->base.obj, &komeda_layer_obj_funcs);return 0 ; } static struct drm_private_state *
@@ -116,11 +116,11 @@ static const struct drm_private_state_funcs komeda_scaler_obj_funcs = {static int komeda_scaler_obj_add (struct komeda_kms_dev *kms,struct komeda_scaler *scaler) {drm_atomic_private_obj_init (&kms->base, - &scaler->base.obj,NULL , + &scaler->base.obj, &komeda_scaler_obj_funcs);return 0 ; } static struct drm_private_state *
@@ -168,11 +168,11 @@ static const struct drm_private_state_funcs komeda_compiz_obj_funcs = { };static int komeda_compiz_obj_add (struct komeda_kms_dev *kms,struct komeda_compiz *compiz) { -drm_atomic_private_obj_init (&kms->base, &compiz->base.obj,NULL , +drm_atomic_private_obj_init (&kms->base, &compiz->base.obj, &komeda_compiz_obj_funcs);return 0 ; }
@@ -222,11 +222,11 @@ static const struct drm_private_state_funcs komeda_splitter_obj_funcs = {static int komeda_splitter_obj_add (struct komeda_kms_dev *kms,struct komeda_splitter *splitter) {drm_atomic_private_obj_init (&kms->base, - &splitter->base.obj,NULL , + &splitter->base.obj, &komeda_splitter_obj_funcs);return 0 ; }
@@ -275,11 +275,11 @@ static const struct drm_private_state_funcs komeda_merger_obj_funcs = {static int komeda_merger_obj_add (struct komeda_kms_dev *kms,struct komeda_merger *merger) {drm_atomic_private_obj_init (&kms->base, - &merger->base.obj,NULL , + &merger->base.obj, &komeda_merger_obj_funcs);return 0 ; }
@@ -328,11 +328,11 @@ static const struct drm_private_state_funcs komeda_improc_obj_funcs = { };static int komeda_improc_obj_add (struct komeda_kms_dev *kms,struct komeda_improc *improc) { -drm_atomic_private_obj_init (&kms->base, &improc->base.obj,NULL , +drm_atomic_private_obj_init (&kms->base, &improc->base.obj, &komeda_improc_obj_funcs);return 0 ; }
@@ -381,11 +381,11 @@ static const struct drm_private_state_funcs komeda_timing_ctrlr_obj_funcs = { };static int komeda_timing_ctrlr_obj_add (struct komeda_kms_dev *kms,struct komeda_timing_ctrlr *ctrlr) { -drm_atomic_private_obj_init (&kms->base, &ctrlr->base.obj,NULL , +drm_atomic_private_obj_init (&kms->base, &ctrlr->base.obj, &komeda_timing_ctrlr_obj_funcs);return 0 ; }
@@ -435,11 +435,11 @@ static const struct drm_private_state_funcs komeda_pipeline_obj_funcs = { };static int komeda_pipeline_obj_add (struct komeda_kms_dev *kms,struct komeda_pipeline *pipe) { -drm_atomic_private_obj_init (&kms->base, &pipe->obj,NULL , +drm_atomic_private_obj_init (&kms->base, &pipe->obj, &komeda_pipeline_obj_funcs);return 0 ; }
drivers/gpu/drm/display/drm_dp_mst_topology.c +0 -1
@@ -5762,11 +5762,10 @@ int drm_dp_mst_topology_mgr_init(struct drm_dp_mst_topology_mgr *mgr, mgr->max_dpcd_transaction_bytes = max_dpcd_transaction_bytes; mgr->max_payloads = max_payloads; mgr->conn_base_id = conn_base_id;drm_atomic_private_obj_init (dev, &mgr->base, -NULL , &drm_dp_mst_topology_state_funcs);return 0 ; }EXPORT_SYMBOL (drm_dp_mst_topology_mgr_init);
drivers/gpu/drm/display/drm_dp_tunnel.c +1 -1
@@ -1598,11 +1598,11 @@ static bool init_group(struct drm_dp_tunnel_mgr *mgr, struct drm_dp_tunnel_group { group->mgr = mgr; group->available_bw =-1 ;INIT_LIST_HEAD (&group->tunnels); -drm_atomic_private_obj_init (mgr->dev, &group->base,NULL , +drm_atomic_private_obj_init (mgr->dev, &group->base, &tunnel_group_funcs);return true; }
drivers/gpu/drm/drm_atomic.c +4 -17
@@ -773,11 +773,10 @@ static void drm_atomic_plane_print_state(struct drm_printer *p,/** * drm_atomic_private_obj_init - initialize private object * @dev: DRM device this object will be attached to * @obj: private object -* @state: initial private object state * @funcs: pointer to the struct of function pointers that identify the object * type * * Initialize the private object, which can be embedded into any * driver private object that needs its own atomic state.
@@ -785,38 +784,26 @@ static void drm_atomic_plane_print_state(struct drm_printer *p,* RETURNS: * Zero on success, error code on failure */ int drm_atomic_private_obj_init (struct drm_device *dev,struct drm_private_obj *obj, -struct drm_private_state *state,const struct drm_private_state_funcs *funcs) {memset (obj,0 ,sizeof (*obj));drm_modeset_lock_init (&obj->lock); obj->dev = dev; obj->funcs = funcs;list_add_tail (&obj->head, &dev->mode_config.privobj_list); -/* -* Not all users of drm_atomic_private_obj_init have been -* converted to using &drm_private_obj_funcs.reset 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) { -if (obj->funcs->atomic_create_state) { - state = obj->funcs->atomic_create_state (obj); -if (IS_ERR (state)) -return PTR_ERR (state); +if (obj->funcs->atomic_create_state) { +struct drm_private_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 ; }EXPORT_SYMBOL (drm_atomic_private_obj_init);
drivers/gpu/drm/drm_bridge.c +0 -1
@@ -480,11 +480,10 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, goto err_reset_bridge; }if (drm_bridge_is_atomic (bridge))drm_atomic_private_obj_init (bridge->dev, &bridge->base, -NULL , &drm_bridge_priv_state_funcs);return 0 ; err_reset_bridge:
drivers/gpu/drm/ingenic/ingenic-drm-drv.c +1 -1
@@ -1394,11 +1394,11 @@ static int ingenic_drm_bind(struct device *dev, bool has_components)if (ret) {dev_err (dev,"Unable to register clock notifier\n" ); goto err_devclk_disable; } -drm_atomic_private_obj_init (drm, &priv->private_obj,NULL , +drm_atomic_private_obj_init (drm, &priv->private_obj, &ingenic_drm_private_state_funcs); ret =drmm_add_action_or_reset (drm, ingenic_drm_atomic_private_obj_fini, &priv->private_obj);if (ret)
drivers/gpu/drm/ingenic/ingenic-ipu.c +1 -1
@@ -899,11 +899,11 @@ static int ingenic_ipu_bind(struct device *dev, struct device *master, void *d)if (err) {dev_err (dev,"Unable to prepare clock\n" );return err; } -drm_atomic_private_obj_init (drm, &ipu->private_obj,NULL , +drm_atomic_private_obj_init (drm, &ipu->private_obj, &ingenic_ipu_private_state_funcs);return 0 ; }
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +0 -1
@@ -1159,11 +1159,10 @@ static int dpu_kms_hw_init(struct msm_kms *kms) dev->mode_config.cursor_width =512 ; dev->mode_config.cursor_height =512 ;drm_atomic_private_obj_init (dpu_kms->dev, &dpu_kms->global_state, -NULL , &dpu_kms_global_state_funcs);atomic_set (&dpu_kms->bandwidth_ref,0 ); rc =pm_runtime_resume_and_get (&dpu_kms->pdev->dev);
drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c +0 -1
@@ -715,11 +715,10 @@ static int mdp5_init(struct platform_device *pdev, struct drm_device *dev)int ret; mdp5_kms->dev = dev;drm_atomic_private_obj_init (mdp5_kms->dev, &mdp5_kms->glob_state, -NULL , &mdp5_global_state_funcs);/* we need to set a default rate before enabling. Set a safe * rate first, then figure out hw revision, and then set a * more optimal rate:
drivers/gpu/drm/omapdrm/omap_drv.c +1 -1
@@ -296,11 +296,11 @@ static const struct drm_private_state_funcs omap_global_state_funcs = {static int omap_global_obj_init (struct drm_device *dev) {struct omap_drm_private *priv = dev->dev_private; -drm_atomic_private_obj_init (dev, &priv->glob_obj,NULL , +drm_atomic_private_obj_init (dev, &priv->glob_obj, &omap_global_state_funcs);return 0 ; }static void omap_global_obj_fini (struct omap_drm_private *priv)
drivers/gpu/drm/tegra/hub.c +1 -1
@@ -954,11 +954,11 @@ static int tegra_display_hub_init(struct host1x_client *client) {struct tegra_display_hub *hub =to_tegra_display_hub (client);struct drm_device *drm =dev_get_drvdata (client->host);struct tegra_drm *tegra = drm->dev_private; -drm_atomic_private_obj_init (drm, &hub->base,NULL , +drm_atomic_private_obj_init (drm, &hub->base, &tegra_display_hub_state_funcs); tegra->hub = hub;return 0 ;
drivers/gpu/drm/vc4/vc4_kms.c +1 -3
@@ -113,11 +113,11 @@ static void vc4_ctm_obj_fini(struct drm_device *dev, void *unused)static int vc4_ctm_obj_init (struct vc4_dev *vc4) {drm_modeset_lock_init (&vc4->ctm_state_lock); -drm_atomic_private_obj_init (&vc4->base, &vc4->ctm_manager,NULL , +drm_atomic_private_obj_init (&vc4->base, &vc4->ctm_manager, &vc4_ctm_state_funcs);return drmm_add_action_or_reset (&vc4->base, vc4_ctm_obj_fini,NULL ); }
@@ -754,11 +754,10 @@ static void vc4_load_tracker_obj_fini(struct drm_device *dev, void *unused) }static int vc4_load_tracker_obj_init (struct vc4_dev *vc4) {drm_atomic_private_obj_init (&vc4->base, &vc4->load_tracker, -NULL , &vc4_load_tracker_state_funcs);return drmm_add_action_or_reset (&vc4->base, vc4_load_tracker_obj_fini,NULL ); }
@@ -846,11 +845,10 @@ static void vc4_hvs_channels_obj_fini(struct drm_device *dev, void *unused) }static int vc4_hvs_channels_obj_init (struct vc4_dev *vc4) {drm_atomic_private_obj_init (&vc4->base, &vc4->hvs_channels, -NULL , &vc4_hvs_state_funcs);return drmm_add_action_or_reset (&vc4->base, vc4_hvs_channels_obj_fini,NULL ); }
include/drm/drm_atomic.h +0 -1
@@ -621,11 +621,10 @@ struct drm_connector_state * __must_check drm_atomic_get_connector_state(struct drm_atomic_state *state, struct drm_connector *connector);int drm_atomic_private_obj_init (struct drm_device *dev,struct drm_private_obj *obj, -struct drm_private_state *state,const struct drm_private_state_funcs *funcs);void drm_atomic_private_obj_fini (struct drm_private_obj *obj);struct drm_private_state *__must_check drm_atomic_get_private_obj_state(struct drm_atomic_state *state,
Signature · 1 line
2.51.0