[PATCH i-g-t 2/3] lib/kms+tests: Use cached connector state

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Speeds up testcases except for those where we want to exercise the
probing itself. The only exceptions left where we do a full probe are

- pm_rpm: We use it to make sure the kernel doesn't get things wrong
  with power domains, so we really want to exercise the full probe
  paths. And there the only place really is the specific validation
  done with the data gathered by get_drm_info.

- kmstest_force_ functions: Newer kernels should be better at
  re-probing state when the force sysfs fields change, but better safe
  than sorry.

v2: I also consolidated the start_n_modes and start_connectors while
at it - move one of the fixup hunks to this patch that accidentally
got misplaced (Thomas).

Cc: Thomas Wood <thomas.wood@xxxxxxxxx>
Signed-off-by: Daniel Vetter <daniel.vetter@xxxxxxxxx>
---
 lib/igt_kms.c                    | 16 ++++++++++++++--
 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      | 41 +++++++++++++++++++++++++---------------
 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 ++-
 11 files changed, 54 insertions(+), 28 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 528164499828..fd4f05e81f3d 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;
 }
@@ -480,6 +486,7 @@ void kmstest_force_edid(int drm_fd, drmModeConnector *connector,
 {
 	char *path;
 	int debugfs_fd, ret;
+	drmModeConnector *temp;
 
 	igt_assert_neq(asprintf(&path, "%s-%d/edid_override", kmstest_connector_type_str(connector->connector_type), connector->connector_type_id),
 		       -1);
@@ -494,6 +501,11 @@ void kmstest_force_edid(int drm_fd, drmModeConnector *connector,
 		ret = write(debugfs_fd, edid, length);
 	close(debugfs_fd);
 
+	/* 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);
 }
 
@@ -556,7 +568,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;
 
@@ -1979,7 +1991,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 4cf765cd713d..bfc981ee279d 100644
--- a/tests/kms_3d.c
+++ b/tests/kms_3d.c
@@ -43,7 +43,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)
@@ -66,7 +66,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 dccf5355c287..3f801749fc2b 100644
--- a/tests/kms_draw_crc.c
+++ b/tests/kms_draw_crc.c
@@ -232,8 +232,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 0feb1a4969a9..3c93378eb96b 100644
--- a/tests/kms_fbcon_fbt.c
+++ b/tests/kms_fbcon_fbt.c
@@ -63,7 +63,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 7157e709f0eb..a3acc3dd28e8 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -418,7 +418,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 99a5649ec0c3..637f625a852f 100644
--- a/tests/kms_force_connector.c
+++ b/tests/kms_force_connector.c
@@ -42,7 +42,8 @@ static void reset_connectors(void)
 
 	for (int i = 0; i < res->count_connectors; i++) {
 
-		connector = drmModeGetConnector(drm_fd, res->connectors[i]);
+		connector = drmModeGetConnectorCurrent(drm_fd,
+						       res->connectors[i]);
 
 		kmstest_force_connector(drm_fd, connector,
 					FORCE_CONNECTOR_UNSPECIFIED);
@@ -71,7 +72,7 @@ int main(int argc, char **argv)
 	int drm_fd = 0;
 	drmModeRes *res;
 	drmModeConnector *vga_connector = NULL, *temp;
-	int start_n_modes;
+	int start_n_modes, start_connection;
 	struct option long_opts[] = {
 		{"reset", 0, 0, 'r'},
 		{0, 0, 0, 0}
@@ -89,10 +90,14 @@ int main(int argc, char **argv)
 		/* 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);
 
@@ -108,7 +113,8 @@ int main(int argc, char **argv)
 
 		/* 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_eq(temp->connection, DRM_MODE_CONNECTED);
 		igt_assert_lt(0, temp->count_modes);
 		drmModeFreeConnector(temp);
@@ -123,7 +129,8 @@ int main(int argc, char **argv)
 		/* force the connector off */
 		kmstest_force_connector(drm_fd, vga_connector,
 					FORCE_CONNECTOR_OFF);
-		temp = drmModeGetConnector(drm_fd, vga_connector->connector_id);
+		temp = drmModeGetConnectorCurrent(drm_fd,
+						  vga_connector->connector_id);
 		igt_assert_eq(temp->connection, DRM_MODE_DISCONNECTED);
 		igt_assert_eq(0, temp->count_modes);
 		drmModeFreeConnector(temp);
@@ -131,23 +138,26 @@ int main(int argc, char **argv)
 		/* 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_eq(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 */
 		kmstest_force_edid(drm_fd, vga_connector,
 				   igt_kms_get_base_edid(), EDID_LENGTH);
-		temp = drmModeGetConnector(drm_fd,
-					   vga_connector->connector_id);
+		temp = drmModeGetConnectorCurrent(drm_fd,
+						  vga_connector->connector_id);
+
+		igt_debug("num_conn %i\n", temp->count_modes);
 
 		CHECK_MODE(temp->modes[0], 1920, 1080, 60);
 		/* Don't check non-preferred modes to avoid to tight coupling
@@ -157,14 +167,15 @@ int main(int argc, char **argv)
 
 		/* remove edid */
 		kmstest_force_edid(drm_fd, vga_connector, NULL, 0);
-		temp = drmModeGetConnector(drm_fd, vga_connector->connector_id);
+		kmstest_force_connector(drm_fd, vga_connector,
+					FORCE_CONNECTOR_UNSPECIFIED);
+		temp = drmModeGetConnectorCurrent(drm_fd,
+						  vga_connector->connector_id);
 		/* the connector should now have the same number of modes that
 		 * it started with */
 		igt_assert_eq(temp->count_modes, start_n_modes);
 		drmModeFreeConnector(temp);
 
-		kmstest_force_connector(drm_fd, vga_connector,
-					FORCE_CONNECTOR_UNSPECIFIED);
 	}
 
 	igt_fixture {
diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c
index 4734f25398b4..fbeeb4bf0b8d 100644
--- a/tests/kms_frontbuffer_tracking.c
+++ b/tests/kms_frontbuffer_tracking.c
@@ -1266,7 +1266,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]);
 
 	rc = drmSetClientCap(drm.fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
diff --git a/tests/kms_setmode.c b/tests/kms_setmode.c
index cf06aabf3e5a..d5ac8f931b55 100644
--- a/tests/kms_setmode.c
+++ b/tests/kms_setmode.c
@@ -504,7 +504,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 b62876c4c253..257ae1b8b1d9 100644
--- a/tests/pm_lpsp.c
+++ b/tests/pm_lpsp.c
@@ -231,7 +231,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 e9ba9ea24307..37aef96ed267 100644
--- a/tests/pm_rpm.c
+++ b/tests/pm_rpm.c
@@ -370,7 +370,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);
 	}
@@ -405,6 +405,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 28875b2d21e5..74e60b6f4bda 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -132,7 +132,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

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux