A number of drivers (amdgpu, komeda, vc4, etc.) leverage the
drm_private_state structure, but we don't have any infrastructure to
provide debugging like we do for the other components state. Let's add
an atomic_print_state hook to be consistent.

Signed-off-by: Maxime Ripard <max...@cerno.tech>
---
 drivers/gpu/drm/drm_atomic.c | 16 ++++++++++++++++
 include/drm/drm_atomic.h     | 13 +++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index ee2496ff3dcc..b9246206ed54 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -789,6 +789,8 @@ 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;
 }
 EXPORT_SYMBOL(drm_atomic_private_obj_init);
 
@@ -1640,6 +1642,15 @@ int __drm_atomic_helper_set_config(struct drm_mode_set 
*set,
 }
 EXPORT_SYMBOL(__drm_atomic_helper_set_config);
 
+static void drm_atomic_private_obj_print_state(struct drm_printer *p,
+                                              const struct drm_private_state 
*state)
+{
+       struct drm_private_obj *obj = state->obj;
+
+       if (obj->funcs->atomic_print_state)
+               obj->funcs->atomic_print_state(p, state);
+}
+
 /**
  * drm_atomic_print_new_state - prints drm atomic state
  * @state: atomic configuration to check
@@ -1660,6 +1671,8 @@ void drm_atomic_print_new_state(const struct 
drm_atomic_state *state,
        struct drm_crtc_state *crtc_state;
        struct drm_connector *connector;
        struct drm_connector_state *connector_state;
+       struct drm_private_obj *obj;
+       struct drm_private_state *obj_state;
        int i;
 
        if (!p) {
@@ -1677,6 +1690,9 @@ void drm_atomic_print_new_state(const struct 
drm_atomic_state *state,
 
        for_each_new_connector_in_state(state, connector, connector_state, i)
                drm_atomic_connector_print_state(p, connector_state);
+
+       for_each_new_private_obj_in_state(state, obj, obj_state, i)
+               drm_atomic_private_obj_print_state(p, obj_state);
 }
 EXPORT_SYMBOL(drm_atomic_print_new_state);
 
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index 1701c2128a5c..7e188cd9452b 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -227,6 +227,18 @@ struct drm_private_state_funcs {
         */
        void (*atomic_destroy_state)(struct drm_private_obj *obj,
                                     struct drm_private_state *state);
+
+       /**
+        * @atomic_print_state:
+        *
+        * If driver subclasses &struct drm_private_state, it should implement
+        * this optional hook for printing additional driver specific state.
+        *
+        * Do not call this directly, use drm_atomic_private_obj_print_state()
+        * instead.
+        */
+       void (*atomic_print_state)(struct drm_printer *p,
+                                  const struct drm_private_state *state);
 };
 
 /**
@@ -319,6 +331,7 @@ struct drm_private_obj {
  */
 struct drm_private_state {
        struct drm_atomic_state *state;
+       struct drm_private_obj *obj;
 };
 
 struct __drm_private_objs_state {
-- 
2.35.1

Reply via email to