[PATCH 8/9] atomic debug

José Roberto de Souza jose.souza at intel.com
Thu Dec 19 15:12:08 UTC 2019


atomic state diff

squash atomic
---
 drivers/gpu/drm/drm_atomic.c                 | 280 +++++++++++++++++++
 drivers/gpu/drm/drm_crtc_internal.h          |   2 +
 drivers/gpu/drm/drm_dp_mst_topology.c        |  28 ++
 drivers/gpu/drm/i915/display/intel_display.c |  18 ++
 include/drm/drm_dp_mst_helper.h              |   3 +
 include/drm/drm_modes.h                      |   3 +
 6 files changed, 334 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index ab4508f25986..8d2bd7db8544 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -1425,6 +1425,261 @@ int __drm_atomic_helper_set_config(struct drm_mode_set *set,
 }
 EXPORT_SYMBOL(__drm_atomic_helper_set_config);
 
+static void
+plane_name_print(struct drm_printer *p, const struct drm_plane *plane,
+		 bool *printed)
+{
+	if (!*printed) {
+		*printed = true;
+		drm_printf(p, "plane[%u]: %s\n", plane->base.id, plane->name);
+	}
+}
+
+static void
+plane_diff_print(struct drm_printer *p, const struct drm_plane *plane,
+		 const struct drm_plane_state *old,
+		 const struct drm_plane_state *new)
+{
+	struct drm_rect old_rect, new_rect;
+	bool name_printed = false;
+
+	if (old->crtc != new->crtc) {
+		plane_name_print(p, plane, &name_printed);
+
+		drm_printf(p, "\told crtc=%s\n", old->crtc ? old->crtc->name : "(null)");
+		drm_printf(p, "\tnew crtc=%s\n", new->crtc ? new->crtc->name : "(null)");
+	}
+
+	if (old->fb != new->fb) {
+		plane_name_print(p, plane, &name_printed);
+
+		drm_printf(p, "\told fb=%u\n", old->fb ? old->fb->base.id : 0);
+		if (old->fb)
+			drm_framebuffer_print_info(p, 2, old->fb);
+
+		drm_printf(p, "\tnew fb=%u\n", new->fb ? new->fb->base.id : 0);
+		if (new->fb)
+			drm_framebuffer_print_info(p, 2, new->fb);
+	}
+
+	old_rect = drm_plane_state_dest(old);
+	new_rect = drm_plane_state_dest(new);
+	if (!drm_rect_equals(&old_rect, &new_rect)) {
+		plane_name_print(p, plane, &name_printed);
+
+		drm_printf(p, "\told crtc-pos=" DRM_RECT_FMT "\n", DRM_RECT_ARG(&old_rect));
+		drm_printf(p, "\tnew crtc-pos=" DRM_RECT_FMT "\n", DRM_RECT_ARG(&new_rect));
+	}
+
+	old_rect = drm_plane_state_src(old);
+	new_rect = drm_plane_state_src(new);
+	if (!drm_rect_equals(&old_rect, &new_rect)) {
+		plane_name_print(p, plane, &name_printed);
+
+		drm_printf(p, "\told src-pos=" DRM_RECT_FMT "\n", DRM_RECT_ARG(&old_rect));
+		drm_printf(p, "\tnew src-pos=" DRM_RECT_FMT "\n", DRM_RECT_ARG(&new_rect));
+	}
+
+	if (old->rotation != new->rotation) {
+		plane_name_print(p, plane, &name_printed);
+
+		drm_printf(p, "\told rotation=%x\n", old->rotation);
+		drm_printf(p, "\tnew rotation=%x\n", old->rotation);
+	}
+
+	if (old->normalized_zpos != new->normalized_zpos) {
+		plane_name_print(p, plane, &name_printed);
+
+		drm_printf(p, "\told normalized-zpos=%x\n", old->normalized_zpos);
+		drm_printf(p, "\told normalized-zpos=%x\n", new->normalized_zpos);
+	}
+
+	if (old->color_encoding != new->color_encoding) {
+		plane_name_print(p, plane, &name_printed);
+
+		drm_printf(p, "\told color-encoding=%s\n",
+			   drm_get_color_encoding_name(old->color_encoding));
+		drm_printf(p, "\tnew color-encoding=%s\n",
+			   drm_get_color_encoding_name(new->color_encoding));
+	}
+
+	if (old->color_range != new->color_range) {
+		plane_name_print(p, plane, &name_printed);
+
+		drm_printf(p, "\told color-range=%s\n",
+			   drm_get_color_range_name(old->color_range));
+		drm_printf(p, "\tnew color-range=%s\n",
+			   drm_get_color_range_name(new->color_range));
+	}
+}
+
+static void
+crtc_name_print(struct drm_printer *p, const struct drm_crtc *crtc,
+		bool *printed)
+{
+	if (!*printed) {
+		*printed = true;
+		drm_printf(p, "crtc[%u]: %s\n", crtc->base.id, crtc->name);
+	}
+}
+
+static void
+crtc_diff_print(struct drm_printer *p, const struct drm_crtc *crtc,
+		const struct drm_crtc_state *old,
+		const struct drm_crtc_state *new)
+{
+	bool name_printed = false;
+
+	if (old->enable != new->enable) {
+		crtc_name_print(p, crtc, &name_printed);
+
+		drm_printf(p, "\told enable=%d\n", old->enable);
+		drm_printf(p, "\tnew enable=%d\n", new->enable);
+	}
+
+	if (old->active != new->active) {
+		crtc_name_print(p, crtc, &name_printed);
+
+		drm_printf(p, "\told active=%d\n", old->active);
+		drm_printf(p, "\tnew active=%d\n", new->active);
+	}
+
+	if (new->planes_changed) {
+		crtc_name_print(p, crtc, &name_printed);
+
+		drm_printf(p, "\tnew planes_changed=%d\n", new->planes_changed);
+	}
+
+	if (new->mode_changed) {
+		crtc_name_print(p, crtc, &name_printed);
+
+		drm_printf(p, "\tnew mode_changed=%d\n", new->mode_changed);
+	}
+
+	if (new->active_changed) {
+		crtc_name_print(p, crtc, &name_printed);
+
+		drm_printf(p, "\tnew active_changed=%d\n", new->active_changed);
+	}
+
+	if (new->connectors_changed) {
+		crtc_name_print(p, crtc, &name_printed);
+
+		drm_printf(p, "\tnew connectors_changed=%d\n", new->connectors_changed);
+	}
+
+	if (new->color_mgmt_changed) {
+		crtc_name_print(p, crtc, &name_printed);
+
+		drm_printf(p, "\tnew color_mgmt_changed=%d\n", new->color_mgmt_changed);
+	}
+
+	if (old->plane_mask != new->plane_mask) {
+		crtc_name_print(p, crtc, &name_printed);
+
+		drm_printf(p, "\told plane_mask=%x\n", old->plane_mask);
+		drm_printf(p, "\tnew plane_mask=%x\n", new->plane_mask);
+	}
+
+	if (old->connector_mask != new->connector_mask) {
+		crtc_name_print(p, crtc, &name_printed);
+
+		drm_printf(p, "\told connector_mask=%x\n", old->connector_mask);
+		drm_printf(p, "\tnew connector_mask=%x\n", new->connector_mask);
+	}
+
+	if (old->encoder_mask != new->encoder_mask) {
+		crtc_name_print(p, crtc, &name_printed);
+
+		drm_printf(p, "\told encoder_mask=%x\n", old->encoder_mask);
+		drm_printf(p, "\tnew encoder_mask=%x\n", new->encoder_mask);
+	}
+
+	if (!drm_mode_match(&old->mode, &new->mode, DRM_MODE_MATCH_ALL)) {
+		crtc_name_print(p, crtc, &name_printed);
+
+		drm_printf(p, "\told mode: " DRM_MODE_FMT "\n", DRM_MODE_ARG(&old->mode));
+		drm_printf(p, "\tnew mode: " DRM_MODE_FMT "\n", DRM_MODE_ARG(&new->mode));
+	}
+}
+
+static void
+conn_name_print(struct drm_printer *p, const struct drm_connector *conn,
+		bool *printed)
+{
+	if (!*printed) {
+		*printed = true;
+		drm_printf(p, "connector[%u]: %s\n", conn->base.id, conn->name);
+	}
+}
+
+static void
+conn_diff_print(struct drm_printer *p, const struct drm_connector *conn,
+		const struct drm_connector_state *old,
+		const struct drm_connector_state *new)
+{
+	bool name_printed = false;
+
+	if (old->crtc != new->crtc) {
+		conn_name_print(p, conn, &name_printed);
+
+		drm_printf(p, "\told crtc=%s\n", old->crtc ? old->crtc->name : "(null)");
+		drm_printf(p, "\tnew crtc=%s\n", new->crtc ? new->crtc->name : "(null)");
+	}
+
+	/*if (new->hdr_metadata_changed) {
+		conn_name_print(p, conn, &name_printed);
+
+		drm_printf(p, "\tnew hdr_metadata_changed=%d\n",
+			   new->hdr_metadata_changed);
+	}*/
+
+	if (conn->connector_type == DRM_MODE_CONNECTOR_WRITEBACK) {
+		int old_fb_id, new_fb_id;
+
+		if (old->writeback_job && old->writeback_job->fb)
+			old_fb_id = old->writeback_job->fb->base.id;
+		else
+			old_fb_id = -1;
+
+		if (new->writeback_job && new->writeback_job->fb)
+			new_fb_id = old->writeback_job->fb->base.id;
+		else
+			new_fb_id = -1;
+
+		if (old_fb_id != new_fb_id) {
+			conn_name_print(p, conn, &name_printed);
+
+			drm_printf(p, "\told fb=%d\n", old_fb_id);
+			drm_printf(p, "\tnew fb=%d\n", new_fb_id);
+		}
+	}
+}
+
+void drm_atomic_diff_print(const struct drm_atomic_state *state)
+{
+	struct drm_printer p = drm_info_printer(state->dev->dev);
+	struct drm_plane *plane;
+	struct drm_plane_state *old_plane_state, *new_plane_state;
+	struct drm_crtc *crtc;
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
+	struct drm_connector *conn;
+	struct drm_connector_state *old_conn_state, *new_conn_state;
+	int i;
+
+	DRM_DEBUG_ATOMIC("checking %p\n", state);
+
+	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i)
+		plane_diff_print(&p, plane, old_plane_state, new_plane_state);
+
+	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i)
+		crtc_diff_print(&p, crtc, old_crtc_state, new_crtc_state);
+
+	for_each_oldnew_connector_in_state(state, conn, old_conn_state, new_conn_state, i)
+		conn_diff_print(&p, conn, old_conn_state, new_conn_state);
+}
+EXPORT_SYMBOL(drm_atomic_diff_print);
+
 void drm_atomic_print_state(const struct drm_atomic_state *state)
 {
 	struct drm_printer p = drm_info_printer(state->dev->dev);
@@ -1447,6 +1702,31 @@ void drm_atomic_print_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);
 }
+EXPORT_SYMBOL(drm_atomic_print_state);
+
+void drm_atomic_print_old_state(const struct drm_atomic_state *state)
+{
+	struct drm_printer p = drm_info_printer(state->dev->dev);
+	struct drm_plane *plane;
+	struct drm_plane_state *plane_state;
+	struct drm_crtc *crtc;
+	struct drm_crtc_state *crtc_state;
+	struct drm_connector *connector;
+	struct drm_connector_state *connector_state;
+	int i;
+
+	DRM_DEBUG_ATOMIC("checking %p\n", state);
+
+	for_each_old_plane_in_state(state, plane, plane_state, i)
+		drm_atomic_plane_print_state(&p, plane_state);
+
+	for_each_old_crtc_in_state(state, crtc, crtc_state, i)
+		drm_atomic_crtc_print_state(&p, crtc_state);
+
+	for_each_old_connector_in_state(state, connector, connector_state, i)
+		drm_atomic_connector_print_state(&p, connector_state);
+}
+EXPORT_SYMBOL(drm_atomic_print_old_state);
 
 static void __drm_state_dump(struct drm_device *dev, struct drm_printer *p,
 			     bool take_locks)
diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h
index c7d5e4c21423..8f37f0a4f2c3 100644
--- a/drivers/gpu/drm/drm_crtc_internal.h
+++ b/drivers/gpu/drm/drm_crtc_internal.h
@@ -231,6 +231,8 @@ int __drm_atomic_helper_set_config(struct drm_mode_set *set,
 				   struct drm_atomic_state *state);
 
 void drm_atomic_print_state(const struct drm_atomic_state *state);
+void drm_atomic_print_old_state(const struct drm_atomic_state *state);
+void drm_atomic_diff_print(const struct drm_atomic_state *state);
 
 /* drm_atomic_uapi.c */
 int drm_atomic_connector_commit_dpms(struct drm_atomic_state *state,
diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index e68d23043973..3332f449fa82 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -4083,6 +4083,34 @@ static int drm_dp_init_vcpi(struct drm_dp_mst_topology_mgr *mgr,
 	return 0;
 }
 
+int drm_dp_atomic_vcpi_print(struct drm_atomic_state *state,
+			     struct drm_dp_mst_topology_mgr *mgr)
+{
+	struct drm_printer p = drm_info_printer(state->dev->dev);
+	struct drm_dp_mst_topology_state *topology_state;
+	struct drm_dp_vcpi_allocation *pos;
+
+	topology_state = drm_atomic_get_mst_topology_state(state, mgr);
+	if (IS_ERR(topology_state))
+		return PTR_ERR(topology_state);
+
+	drm_printf(&p, "drm_dp_atomic_vcpi_print() { \n");
+
+	list_for_each_entry(pos, &topology_state->vcpis, next) {
+		const char *name = "none";
+
+		if (pos->port && pos->port->connector)
+			name = pos->port->connector->name;
+
+		drm_printf(&p, "\tconn=%s vcpi=%i\n", name, pos->vcpi);
+	}
+
+	drm_printf(&p, "}\n");
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_dp_atomic_vcpi_print);
+
 /**
  * drm_dp_atomic_find_vcpi_slots() - Find and add VCPI slots to the state
  * @state: global atomic state
diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 8258d2b53db8..808da76e211a 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -42,6 +42,7 @@
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_rect.h>
 #include <drm/i915_drm.h>
+#include "../drm_crtc_internal.h"
 
 #include "display/intel_crt.h"
 #include "display/intel_ddi.h"
@@ -14054,6 +14055,19 @@ static int intel_atomic_check(struct drm_device *dev,
 	if (ret)
 		goto fail;
 
+	/*
+	DRM_DEBUG_ATOMIC("intel_atomic_check() new print state [\n");
+	drm_atomic_print_state(state);
+	DRM_DEBUG_ATOMIC("]\n");
+
+	DRM_DEBUG_ATOMIC("intel_atomic_check() old print state [\n");
+	drm_atomic_print_old_state(state);
+	DRM_DEBUG_ATOMIC("]\n");
+	*/
+	DRM_DEBUG_ATOMIC("intel_atomic_check() diff1 [\n");
+	drm_atomic_diff_print(_state);
+	DRM_DEBUG_ATOMIC("]\n");
+
 	for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
 					    new_crtc_state, i) {
 		if (!needs_modeset(new_crtc_state)) {
@@ -14177,6 +14191,10 @@ static int intel_atomic_check(struct drm_device *dev,
 				       "[modeset]" : "[fastset]");
 	}
 
+	DRM_DEBUG_ATOMIC("intel_atomic_check() diff2 [\n");
+	drm_atomic_diff_print(_state);
+	DRM_DEBUG_ATOMIC("]\n");
+
 	return 0;
 
  fail:
diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h
index 5699493c6fb1..8771aefc8547 100644
--- a/include/drm/drm_dp_mst_helper.h
+++ b/include/drm/drm_dp_mst_helper.h
@@ -774,6 +774,9 @@ void drm_dp_mst_connector_early_unregister(struct drm_connector *connector,
 
 struct drm_dp_mst_topology_state *drm_atomic_get_mst_topology_state(struct drm_atomic_state *state,
 								    struct drm_dp_mst_topology_mgr *mgr);
+
+int drm_dp_atomic_vcpi_print(struct drm_atomic_state *state, struct drm_dp_mst_topology_mgr *mgr);
+
 int __must_check
 drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state,
 			      struct drm_dp_mst_topology_mgr *mgr,
diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
index e946e20c61d8..9e1e131b9a92 100644
--- a/include/drm/drm_modes.h
+++ b/include/drm/drm_modes.h
@@ -168,6 +168,9 @@ enum drm_mode_status {
 #define DRM_MODE_MATCH_FLAGS (1 << 2)
 #define DRM_MODE_MATCH_3D_FLAGS (1 << 3)
 #define DRM_MODE_MATCH_ASPECT_RATIO (1 << 4)
+#define DRM_MODE_MATCH_ALL (DRM_MODE_MATCH_TIMINGS | DRM_MODE_MATCH_CLOCK | \
+			    DRM_MODE_MATCH_FLAGS | DRM_MODE_MATCH_3D_FLAGS | \
+			    DRM_MODE_MATCH_ASPECT_RATIO)
 
 /**
  * struct drm_display_mode - DRM kernel-internal display mode structure
-- 
2.24.1



More information about the Intel-gfx-trybot mailing list