drm: Add plane->name and use it in debug prints
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 8 Dec 2015 16:41:54 +0000 (18:41 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 11 Dec 2015 08:13:53 +0000 (09:13 +0100)
Show a sensible name for the plane in debug mesages. The driver
may supply its own name, otherwise the core genrates the name
("plane-0", "plane-1" etc.).

v2: kstrdup() the name passed by the caller (Jani)
v3: Generate a default name if the driver doesn't supply one

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1449592922-5545-7-git-send-email-ville.syrjala@linux.intel.com
drivers/gpu/drm/drm_atomic.c
drivers/gpu/drm/drm_atomic_helper.c
drivers/gpu/drm/drm_crtc.c
include/drm/drm_crtc.h

index feb66895e48cf3dda1c7213668987ea29a7c5375..6a21e5c378c1a2e5daa2d0197f0a304aa5336b10 100644 (file)
@@ -549,8 +549,8 @@ drm_atomic_get_plane_state(struct drm_atomic_state *state,
        state->planes[index] = plane;
        plane_state->state = state;
 
-       DRM_DEBUG_ATOMIC("Added [PLANE:%d] %p state to %p\n",
-                        plane->base.id, plane_state, state);
+       DRM_DEBUG_ATOMIC("Added [PLANE:%d:%s] %p state to %p\n",
+                        plane->base.id, plane->name, plane_state, state);
 
        if (plane_state->crtc) {
                struct drm_crtc_state *crtc_state;
@@ -770,8 +770,8 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
        }
 
        if (plane_switching_crtc(state->state, plane, state)) {
-               DRM_DEBUG_ATOMIC("[PLANE:%d] switching CRTC directly\n",
-                                plane->base.id);
+               DRM_DEBUG_ATOMIC("[PLANE:%d:%s] switching CRTC directly\n",
+                                plane->base.id, plane->name);
                return -EINVAL;
        }
 
@@ -1248,8 +1248,8 @@ int drm_atomic_check_only(struct drm_atomic_state *state)
        for_each_plane_in_state(state, plane, plane_state, i) {
                ret = drm_atomic_plane_check(plane, plane_state);
                if (ret) {
-                       DRM_DEBUG_ATOMIC("[PLANE:%d] atomic core check failed\n",
-                                        plane->base.id);
+                       DRM_DEBUG_ATOMIC("[PLANE:%d:%s] atomic core check failed\n",
+                                        plane->base.id, plane->name);
                        return ret;
                }
        }
index 6ba3fe5639e4c4f2a754c6733c328d08aad077f0..63f925b75357df20a0c7e855226f527f8b84c6c2 100644 (file)
@@ -545,8 +545,8 @@ drm_atomic_helper_check_planes(struct drm_device *dev,
 
                ret = funcs->atomic_check(plane, plane_state);
                if (ret) {
-                       DRM_DEBUG_ATOMIC("[PLANE:%d] atomic driver check failed\n",
-                                        plane->base.id);
+                       DRM_DEBUG_ATOMIC("[PLANE:%d:%s] atomic driver check failed\n",
+                                        plane->base.id, plane->name);
                        return ret;
                }
        }
index efa57e8a99b5bf535fc8a6b1c3b1f3ab7160172a..62fa95fa547118f2d47fbb6b62ab811412e6e67b 100644 (file)
@@ -1181,6 +1181,18 @@ void drm_encoder_cleanup(struct drm_encoder *encoder)
 }
 EXPORT_SYMBOL(drm_encoder_cleanup);
 
+static unsigned int drm_num_planes(struct drm_device *dev)
+{
+       unsigned int num = 0;
+       struct drm_plane *tmp;
+
+       drm_for_each_plane(tmp, dev) {
+               num++;
+       }
+
+       return num;
+}
+
 /**
  * drm_universal_plane_init - Initialize a new universal plane object
  * @dev: DRM device
@@ -1224,6 +1236,22 @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane,
                return -ENOMEM;
        }
 
+       if (name) {
+               va_list ap;
+
+               va_start(ap, name);
+               plane->name = kvasprintf(GFP_KERNEL, name, ap);
+               va_end(ap);
+       } else {
+               plane->name = kasprintf(GFP_KERNEL, "plane-%d",
+                                       drm_num_planes(dev));
+       }
+       if (!plane->name) {
+               kfree(plane->format_types);
+               drm_mode_object_put(dev, &plane->base);
+               return -ENOMEM;
+       }
+
        memcpy(plane->format_types, formats, format_count * sizeof(uint32_t));
        plane->format_count = format_count;
        plane->possible_crtcs = possible_crtcs;
@@ -1314,6 +1342,8 @@ void drm_plane_cleanup(struct drm_plane *plane)
        if (plane->state && plane->funcs->atomic_destroy_state)
                plane->funcs->atomic_destroy_state(plane, plane->state);
 
+       kfree(plane->name);
+
        memset(plane, 0, sizeof(*plane));
 }
 EXPORT_SYMBOL(drm_plane_cleanup);
index 4bea0a1151bc01009fe2a8682f27adf7f4696d09..c2f98ba2bb9869f127395b8094d515e61f3c5eac 100644 (file)
@@ -1496,6 +1496,8 @@ struct drm_plane {
        struct drm_device *dev;
        struct list_head head;
 
+       char *name;
+
        struct drm_modeset_lock mutex;
 
        struct drm_mode_object base;