diff mbox

[5/6] drm/atomic: add debugfs file to dump out atomic state

Message ID 1476489353-16261-6-git-send-email-robdclark@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Rob Clark Oct. 14, 2016, 11:55 p.m. UTC
Signed-off-by: Rob Clark <robdclark@gmail.com>
---
 drivers/gpu/drm/drm_atomic.c  | 40 ++++++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/drm_debugfs.c |  9 +++++++++
 include/drm/drm_atomic.h      |  4 ++++
 3 files changed, 53 insertions(+)

Comments

Sean Paul Oct. 17, 2016, 5 p.m. UTC | #1
On Fri, Oct 14, 2016 at 7:55 PM, Rob Clark <robdclark@gmail.com> wrote:

A short commit message detailing the change and info printed would
probably be helpful.


Aside from that,

Reviewed-by: Sean Paul <seanpaul@chromium.org>

> Signed-off-by: Rob Clark <robdclark@gmail.com>
> ---
>  drivers/gpu/drm/drm_atomic.c  | 40 ++++++++++++++++++++++++++++++++++++++++
>  drivers/gpu/drm/drm_debugfs.c |  9 +++++++++
>  include/drm/drm_atomic.h      |  4 ++++
>  3 files changed, 53 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 3cc3cb5..117d429 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -1565,6 +1565,46 @@ static void drm_atomic_print_state(const struct drm_atomic_state *state)
>                 drm_atomic_connector_print_state(&p, connector_state);
>  }
>
> +#ifdef CONFIG_DEBUG_FS
> +static int drm_state_info(struct seq_file *m, void *data)
> +{
> +       struct drm_info_node *node = (struct drm_info_node *) m->private;
> +       struct drm_device *dev = node->minor->dev;
> +       struct drm_mode_config *config = &dev->mode_config;
> +       struct drm_plane *plane;
> +       struct drm_crtc *crtc;
> +       struct drm_connector *connector;
> +       struct drm_print p = drm_print_seq_file(m);
> +
> +       drm_modeset_lock_all(dev);
> +
> +       list_for_each_entry(plane, &config->plane_list, head)
> +               drm_atomic_plane_print_state(&p, plane->state);
> +
> +       list_for_each_entry(crtc, &config->crtc_list, head)
> +               drm_atomic_crtc_print_state(&p, crtc->state);
> +
> +       list_for_each_entry(connector, &config->connector_list, head)
> +               drm_atomic_connector_print_state(&p, connector->state);
> +
> +       drm_modeset_unlock_all(dev);
> +
> +       return 0;
> +}
> +
> +/* any use in debugfs files to dump individual planes/crtc/etc? */
> +static const struct drm_info_list drm_atomic_debugfs_list[] = {
> +       {"state", drm_state_info, 0},
> +};
> +
> +int drm_atomic_debugfs_init(struct drm_minor *minor)
> +{
> +       return drm_debugfs_create_files(drm_atomic_debugfs_list,
> +                       ARRAY_SIZE(drm_atomic_debugfs_list),
> +                       minor->debugfs_root, minor);
> +}
> +#endif
> +
>  /*
>   * The big monstor ioctl
>   */
> diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
> index fa10cef..d8945a9 100644
> --- a/drivers/gpu/drm/drm_debugfs.c
> +++ b/drivers/gpu/drm/drm_debugfs.c
> @@ -36,6 +36,7 @@
>  #include <linux/export.h>
>  #include <drm/drmP.h>
>  #include <drm/drm_edid.h>
> +#include <drm/drm_atomic.h>
>  #include "drm_internal.h"
>
>  #if defined(CONFIG_DEBUG_FS)
> @@ -163,6 +164,14 @@ int drm_debugfs_init(struct drm_minor *minor, int minor_id,
>                 return ret;
>         }
>
> +       if (drm_core_check_feature(dev, DRIVER_ATOMIC)) {
> +               ret = drm_atomic_debugfs_init(minor);
> +               if (ret) {
> +                       DRM_ERROR("Failed to create atomic debugfs files\n");
> +                       return ret;
> +               }
> +       }
> +
>         if (dev->driver->debugfs_init) {
>                 ret = dev->driver->debugfs_init(minor);
>                 if (ret) {
> diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
> index 856a9c8..68422f6 100644
> --- a/include/drm/drm_atomic.h
> +++ b/include/drm/drm_atomic.h
> @@ -181,6 +181,10 @@ int __must_check drm_atomic_check_only(struct drm_atomic_state *state);
>  int __must_check drm_atomic_commit(struct drm_atomic_state *state);
>  int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
>
> +#ifdef CONFIG_DEBUG_FS
> +int drm_atomic_debugfs_init(struct drm_minor *minor);
> +#endif
> +
>  #define for_each_connector_in_state(__state, connector, connector_state, __i) \
>         for ((__i) = 0;                                                 \
>              (__i) < (__state)->num_connector &&                                \
> --
> 2.7.4
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 3cc3cb5..117d429 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -1565,6 +1565,46 @@  static void drm_atomic_print_state(const struct drm_atomic_state *state)
 		drm_atomic_connector_print_state(&p, connector_state);
 }
 
+#ifdef CONFIG_DEBUG_FS
+static int drm_state_info(struct seq_file *m, void *data)
+{
+	struct drm_info_node *node = (struct drm_info_node *) m->private;
+	struct drm_device *dev = node->minor->dev;
+	struct drm_mode_config *config = &dev->mode_config;
+	struct drm_plane *plane;
+	struct drm_crtc *crtc;
+	struct drm_connector *connector;
+	struct drm_print p = drm_print_seq_file(m);
+
+	drm_modeset_lock_all(dev);
+
+	list_for_each_entry(plane, &config->plane_list, head)
+		drm_atomic_plane_print_state(&p, plane->state);
+
+	list_for_each_entry(crtc, &config->crtc_list, head)
+		drm_atomic_crtc_print_state(&p, crtc->state);
+
+	list_for_each_entry(connector, &config->connector_list, head)
+		drm_atomic_connector_print_state(&p, connector->state);
+
+	drm_modeset_unlock_all(dev);
+
+	return 0;
+}
+
+/* any use in debugfs files to dump individual planes/crtc/etc? */
+static const struct drm_info_list drm_atomic_debugfs_list[] = {
+	{"state", drm_state_info, 0},
+};
+
+int drm_atomic_debugfs_init(struct drm_minor *minor)
+{
+	return drm_debugfs_create_files(drm_atomic_debugfs_list,
+			ARRAY_SIZE(drm_atomic_debugfs_list),
+			minor->debugfs_root, minor);
+}
+#endif
+
 /*
  * The big monstor ioctl
  */
diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index fa10cef..d8945a9 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -36,6 +36,7 @@ 
 #include <linux/export.h>
 #include <drm/drmP.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_atomic.h>
 #include "drm_internal.h"
 
 #if defined(CONFIG_DEBUG_FS)
@@ -163,6 +164,14 @@  int drm_debugfs_init(struct drm_minor *minor, int minor_id,
 		return ret;
 	}
 
+	if (drm_core_check_feature(dev, DRIVER_ATOMIC)) {
+		ret = drm_atomic_debugfs_init(minor);
+		if (ret) {
+			DRM_ERROR("Failed to create atomic debugfs files\n");
+			return ret;
+		}
+	}
+
 	if (dev->driver->debugfs_init) {
 		ret = dev->driver->debugfs_init(minor);
 		if (ret) {
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index 856a9c8..68422f6 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -181,6 +181,10 @@  int __must_check drm_atomic_check_only(struct drm_atomic_state *state);
 int __must_check drm_atomic_commit(struct drm_atomic_state *state);
 int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
 
+#ifdef CONFIG_DEBUG_FS
+int drm_atomic_debugfs_init(struct drm_minor *minor);
+#endif
+
 #define for_each_connector_in_state(__state, connector, connector_state, __i) \
 	for ((__i) = 0;							\
 	     (__i) < (__state)->num_connector &&				\