[Intel-gfx] [PATCH] [RFC] lib/kms: Use cached connector state

Daniel Vetter daniel.vetter at ffwll.ch
Wed Aug 26 08:04:52 PDT 2015


Speeds up testcases except for those where we want to exercise the
probing itself.

Note this blew up and I ragequit after a few more regressions
uncovered in a chain, so this isn't all that well-tested really :(

Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
---
 configure.ac                     |  2 +-
 lib/igt_kms.c                    | 10 ++++++++--
 tests/kms_3d.c                   |  4 ++--
 tests/kms_draw_crc.c             |  4 ++--
 tests/kms_fbcon_fbt.c            |  2 +-
 tests/kms_flip.c                 |  2 +-
 tests/kms_force_connector.c      | 22 +++++++++++++---------
 tests/kms_frontbuffer_tracking.c |  2 +-
 tests/kms_setmode.c              |  2 +-
 tests/pm_lpsp.c                  |  2 +-
 tests/pm_rpm.c                   |  4 +++-
 tests/testdisplay.c              |  3 ++-
 12 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/configure.ac b/configure.ac
index 3770b2fc8a59..1db39bcce2c0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -85,7 +85,7 @@ if test "x$GCC" = "xyes"; then
 fi
 AC_SUBST(ASSEMBLER_WARN_CFLAGS)
 
-PKG_CHECK_MODULES(DRM, [libdrm_intel >= 2.4.55 libdrm])
+PKG_CHECK_MODULES(DRM, [libdrm_intel >= 2.4.61 libdrm])
 PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10])
 PKG_CHECK_MODULES(OVERLAY_XVLIB, [xv x11 xext dri2proto >= 2.6], enable_overlay_xvlib=yes, enable_overlay_xvlib=no)
 PKG_CHECK_MODULES(OVERLAY_XLIB, [cairo-xlib dri2proto >= 2.6], enable_overlay_xlib=yes, enable_overlay_xlib=no)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 0bb16b4e73b2..591b520a3a77 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -393,6 +393,7 @@ bool kmstest_force_connector(int drm_fd, drmModeConnector *connector,
 	char *path, **tmp;
 	const char *value;
 	int debugfs_fd, ret, len;
+	drmModeConnector *temp;
 	uint32_t devid;
 
 	devid = intel_get_drm_devid(drm_fd);
@@ -459,6 +460,11 @@ bool kmstest_force_connector(int drm_fd, drmModeConnector *connector,
 
 	igt_install_exit_handler(reset_connectors_at_exit);
 
+	/* To allow callers to always use GetConnectorCurrent we need to force a
+	 * redetection here. */
+	temp = drmModeGetConnector(drm_fd, connector->connector_id);
+	drmModeFreeConnector(temp);
+
 	igt_assert(ret != -1);
 	return (ret == -1) ? false : true;
 }
@@ -556,7 +562,7 @@ bool kmstest_get_connector_config(int drm_fd, uint32_t connector_id,
 	}
 
 	/* First, find the connector & mode */
-	connector = drmModeGetConnector(drm_fd, connector_id);
+	connector = drmModeGetConnectorCurrent(drm_fd, connector_id);
 	if (!connector)
 		goto err2;
 
@@ -1963,7 +1969,7 @@ void igt_enable_connectors(void)
 
 	for (int i = 0; i < res->count_connectors; i++) {
 
-		c = drmModeGetConnector(drm_fd, res->connectors[i]);
+		c = drmModeGetConnectorCurrent(drm_fd, res->connectors[i]);
 
 		/* don't attempt to force connectors that are already connected
 		 */
diff --git a/tests/kms_3d.c b/tests/kms_3d.c
index 76f0b25e8a35..3f1304e605c1 100644
--- a/tests/kms_3d.c
+++ b/tests/kms_3d.c
@@ -45,7 +45,7 @@ igt_simple_main
 	/* find an hdmi connector */
 	for (int i = 0; i < res->count_connectors; i++) {
 
-		connector = drmModeGetConnector(drm_fd, res->connectors[i]);
+		connector = drmModeGetConnectorCurrent(drm_fd, res->connectors[i]);
 
 		if (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA &&
 		    connector->connection == DRM_MODE_DISCONNECTED)
@@ -68,7 +68,7 @@ igt_simple_main
 
 	/* check for 3D modes */
 	mode_count = 0;
-	connector = drmModeGetConnector(drm_fd, connector_id);
+	connector = drmModeGetConnectorCurrent(drm_fd, connector_id);
 	for (int i = 0; i < connector->count_modes; i++) {
 		if (connector->modes[i].flags & DRM_MODE_FLAG_3D_MASK)
 			mode_count++;
diff --git a/tests/kms_draw_crc.c b/tests/kms_draw_crc.c
index 9fcf997e9286..52639e6d2855 100644
--- a/tests/kms_draw_crc.c
+++ b/tests/kms_draw_crc.c
@@ -192,8 +192,8 @@ static void setup_environment(void)
 	igt_assert(drm_res->count_connectors <= MAX_CONNECTORS);
 
 	for (i = 0; i < drm_res->count_connectors; i++)
-		drm_connectors[i] = drmModeGetConnector(drm_fd,
-							drm_res->connectors[i]);
+		drm_connectors[i] = drmModeGetConnectorCurrent(drm_fd,
+							       drm_res->connectors[i]);
 
 	kmstest_set_vt_graphics_mode();
 
diff --git a/tests/kms_fbcon_fbt.c b/tests/kms_fbcon_fbt.c
index f0750145438d..3b7ed9f6a562 100644
--- a/tests/kms_fbcon_fbt.c
+++ b/tests/kms_fbcon_fbt.c
@@ -67,7 +67,7 @@ static void setup_drm(struct drm_info *drm)
 	igt_assert(drm->res->count_connectors <= MAX_CONNECTORS);
 
 	for (i = 0; i < drm->res->count_connectors; i++)
-		drm->connectors[i] = drmModeGetConnector(drm->fd,
+		drm->connectors[i] = drmModeGetConnectorCurrent(drm->fd,
 						drm->res->connectors[i]);
 
 	kmstest_set_vt_graphics_mode();
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 25c924305c32..bd767be23969 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -400,7 +400,7 @@ static void dpms_off_other_outputs(struct test_output *o)
 				goto next;
 		}
 
-		connector = drmModeGetConnector(drm_fd, connector_id);
+		connector = drmModeGetConnectorCurrent(drm_fd, connector_id);
 
 		kmstest_set_connector_dpms(drm_fd, connector,  DRM_MODE_DPMS_ON);
 		kmstest_set_connector_dpms(drm_fd, connector,  DRM_MODE_DPMS_OFF);
diff --git a/tests/kms_force_connector.c b/tests/kms_force_connector.c
index 42aaa7f696ad..096b49aad540 100644
--- a/tests/kms_force_connector.c
+++ b/tests/kms_force_connector.c
@@ -39,7 +39,7 @@ igt_main
 	drmModeRes *res;
 	drmModeConnector *vga_connector = NULL, *temp;
 	igt_display_t display;
-	int start_n_modes;
+	int start_n_modes, start_connection;
 
 	igt_fixture {
 		drm_fd = drm_open_any_master();
@@ -48,10 +48,13 @@ igt_main
 		/* find the vga connector */
 		for (int i = 0; i < res->count_connectors; i++) {
 
-			vga_connector = drmModeGetConnector(drm_fd, res->connectors[i]);
+			vga_connector = drmModeGetConnectorCurrent(drm_fd, res->connectors[i]);
 
-			if (vga_connector->connector_type == DRM_MODE_CONNECTOR_VGA)
+			if (vga_connector->connector_type == DRM_MODE_CONNECTOR_VGA) {
+				start_n_modes = vga_connector->count_modes;
+				start_connection = vga_connector->connection;
 				break;
+			}
 
 			drmModeFreeConnector(vga_connector);
 
@@ -64,7 +67,7 @@ igt_main
 	igt_subtest("force-connector-state") {
 		/* force the connector on and check the reported values */
 		kmstest_force_connector(drm_fd, vga_connector, FORCE_CONNECTOR_ON);
-		temp = drmModeGetConnector(drm_fd, vga_connector->connector_id);
+		temp = drmModeGetConnectorCurrent(drm_fd, vga_connector->connector_id);
 		igt_assert(temp->connection == DRM_MODE_CONNECTED);
 		igt_assert(temp->count_modes > 0);
 		drmModeFreeConnector(temp);
@@ -86,16 +89,15 @@ igt_main
 		/* check that the previous state is restored */
 		kmstest_force_connector(drm_fd, vga_connector,
 					FORCE_CONNECTOR_UNSPECIFIED);
-		temp = drmModeGetConnector(drm_fd, vga_connector->connector_id);
-		igt_assert(temp->connection == vga_connector->connection);
+		temp = drmModeGetConnectorCurrent(drm_fd, vga_connector->connector_id);
+		igt_assert_eq(temp->connection, start_connection);
 		drmModeFreeConnector(temp);
 	}
 
 	igt_subtest("force-edid") {
 		kmstest_force_connector(drm_fd, vga_connector,
 					FORCE_CONNECTOR_ON);
-		temp = drmModeGetConnector(drm_fd, vga_connector->connector_id);
-		start_n_modes = temp->count_modes;
+		temp = drmModeGetConnectorCurrent(drm_fd, vga_connector->connector_id);
 		drmModeFreeConnector(temp);
 
 		/* test edid forcing */
@@ -104,6 +106,8 @@ igt_main
 		temp = drmModeGetConnector(drm_fd,
 					   vga_connector->connector_id);
 
+		igt_debug("num_conn %i\n", temp->count_modes);
+
 		CHECK_MODE(temp->modes[0], 1920, 1080, 60);
 		CHECK_MODE(temp->modes[1], 1280, 720, 60);
 		CHECK_MODE(temp->modes[2], 1024, 768, 60);
@@ -117,7 +121,7 @@ igt_main
 		temp = drmModeGetConnector(drm_fd, vga_connector->connector_id);
 		/* the connector should now have the same number of modes that
 		 * it started with */
-		igt_assert(temp->count_modes == start_n_modes);
+		igt_assert_eq(temp->count_modes, start_n_modes);
 		drmModeFreeConnector(temp);
 
 		kmstest_force_connector(drm_fd, vga_connector,
diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c
index e9be045ad3a6..b7ccc3b26fd3 100644
--- a/tests/kms_frontbuffer_tracking.c
+++ b/tests/kms_frontbuffer_tracking.c
@@ -1048,7 +1048,7 @@ static void setup_drm(void)
 	igt_assert(drm.res->count_connectors <= MAX_CONNECTORS);
 
 	for (i = 0; i < drm.res->count_connectors; i++)
-		drm.connectors[i] = drmModeGetConnector(drm.fd,
+		drm.connectors[i] = drmModeGetConnectorCurrent(drm.fd,
 						drm.res->connectors[i]);
 
 	drm.planes = drmModeGetPlaneResources(drm.fd);
diff --git a/tests/kms_setmode.c b/tests/kms_setmode.c
index 82769ab7dadb..a757018f22d1 100644
--- a/tests/kms_setmode.c
+++ b/tests/kms_setmode.c
@@ -495,7 +495,7 @@ static int get_one_connector(drmModeRes *resources, int connector_id,
 	drmModeConnector *connector;
 	drmModeModeInfo mode;
 
-	connector = drmModeGetConnector(drm_fd, connector_id);
+	connector = drmModeGetConnectorCurrent(drm_fd, connector_id);
 	igt_assert(connector);
 	cconf->connector = connector;
 
diff --git a/tests/pm_lpsp.c b/tests/pm_lpsp.c
index 3ed4c788016f..705d404b6991 100644
--- a/tests/pm_lpsp.c
+++ b/tests/pm_lpsp.c
@@ -235,7 +235,7 @@ igt_main
 		igt_assert(drm_res->count_connectors <= MAX_CONNECTORS);
 
 		for (i = 0; i < drm_res->count_connectors; i++)
-			drm_connectors[i] = drmModeGetConnector(drm_fd,
+			drm_connectors[i] = drmModeGetConnectorCurrent(drm_fd,
 							drm_res->connectors[i]);
 
 		disable_audio_runtime_pm();
diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c
index d509fa838b3c..3250711fda77 100644
--- a/tests/pm_rpm.c
+++ b/tests/pm_rpm.c
@@ -377,7 +377,7 @@ static void init_mode_set_data(struct mode_set_data *data)
 	igt_assert(data->res->count_connectors <= MAX_CONNECTORS);
 
 	for (i = 0; i < data->res->count_connectors; i++) {
-		data->connectors[i] = drmModeGetConnector(drm_fd,
+		data->connectors[i] = drmModeGetConnectorCurrent(drm_fd,
 						data->res->connectors[i]);
 		data->edids[i] = get_connector_edid(data->connectors[i], i);
 	}
@@ -412,6 +412,8 @@ static void get_drm_info(struct compare_data *data)
 	igt_assert(data->res->count_crtcs <= MAX_CRTCS);
 
 	for (i = 0; i < data->res->count_connectors; i++) {
+		/* Don't use GetConnectorCurrent, we want to force a reprobe
+		 * here. */
 		data->connectors[i] = drmModeGetConnector(drm_fd,
 						data->res->connectors[i]);
 		data->edids[i] = get_connector_edid(data->connectors[i], i);
diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index 9068a9581ff5..b27ed05fe73d 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -135,7 +135,8 @@ static void dump_connectors_fd(int drmfd)
 	for (i = 0; i < mode_resources->count_connectors; i++) {
 		drmModeConnector *connector;
 
-		connector = drmModeGetConnector(drmfd, mode_resources->connectors[i]);
+		connector = drmModeGetConnectorCurrent(drmfd,
+						       mode_resources->connectors[i]);
 		if (!connector) {
 			igt_warn("could not get connector %i: %s\n", mode_resources->connectors[i], strerror(errno));
 			continue;
-- 
2.1.0



More information about the Intel-gfx mailing list