Skip to contentSkip to conversation

lpsp platform agnostic support

PATCH Superseded Anshuman Gupta 4 participants 18 messages Mar 23, 2020 – Mar 24, 2020 Library code

v2 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v2 cover lpsp platform agnostic support

This series adds lpsp igt val platform agnostic support. This has been a big gap on igt validation side in order to validate low power single pipe use cases.

V2 update of this series had fixed CI failures observed with v1. This should be test with i915 lpsp support, which adds i915_lpsp_info debugfs.

Anshuman Gupta (5):
lib/igt_pm: Add lib func to get lpsp capability tests/i915_pm_lpsp: lpsp platform agnostic support tests/i915_pm_lpsp: Skip panel-fitter subtest for 1024x768 panels tests/i915_pm_lpsp: screens-disabled subtest use igt_wait tests/i915_pm_rpm: lpsp/non-lpsp screen mode_set_data

 lib/igt_pm.c              |  27 ++++
 lib/igt_pm.h              |   1 +
 tests/i915/i915_pm_lpsp.c | 311 +++++++++++++++++++++++---------------
 tests/i915/i915_pm_rpm.c  |  53 ++++---
 4 files changed, 248 insertions(+), 144 deletions(-)
Signature · 6 lines
2.25.2

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#1 lore raw

PATCH v2 1/5 lib/igt_pm: Add lib func to get lpsp capability

This lib function evaluate the lpsp capability from the connector specific debugfs attribute i915_lpsp_info.

---
 lib/igt_pm.c | 27 +++++++++++++++++++++++++++
 lib/igt_pm.h |  1 +
 2 files changed, 28 insertions(+)
lib/igt_pm.c +27 -0
index 9d441e1b..7a6cab7c 100644
@@ -37,6 +37,7 @@
 #include <dirent.h>
 
 #include "drmtest.h"
+#include "igt_kms.h"
 #include "igt_pm.h"
 #include "igt_aux.h"
 #include "igt_sysfs.h"
@@ -827,3 +828,29 @@ bool igt_pm_pc8_plus_residencies_enabled(int msr_fd)
 
 	return true;
 }
+
+/**
+ * igt_output_is_lpsp_capable:
+ * @drm_fd: fd to drm device
+ * @output: igt output for which lpsp capability need to be evaluated
+ * Check lpsp capability for a given output.
+ *
+ * Returns:
+ * True if given output is lpsp capable otherwise false.
+ */
+bool igt_output_is_lpsp_capable(int drm_fd, igt_output_t *output)
+{
+	char buf[256];
+	int fd, len;
+
+	fd = igt_debugfs_connector_dir(drm_fd, output->name, O_RDONLY);
+	igt_require(fd >= 0);
+	len = igt_debugfs_simple_read(fd, "i915_lpsp_info", buf, sizeof(buf));
+
+	if (len < 0)
+		igt_assert_eq(len, -ENODEV);
+
+	close(fd);
+
+	return strstr(buf, "LPSP capable");
+}
lib/igt_pm.h +1 -0
index 5e438452..076d8c27 100644
@@ -53,5 +53,6 @@ enum igt_runtime_pm_status igt_get_runtime_pm_status(void);
 bool igt_wait_for_pm_status(enum igt_runtime_pm_status status);
 bool igt_pm_dmc_loaded(int debugfs);
 bool igt_pm_pc8_plus_residencies_enabled(int msr_fd);
+bool igt_output_is_lpsp_capable(int drm_fd, igt_output_t *output);
 
 #endif /* IGT_PM_H */
Signature · 6 lines
2.25.2

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#2 lore raw

Re: [igt-dev] [PATCH i-g-t v2 1/5] lib/igt_pm: Add lib func to get lpsp capability

Quoted 26 lines · Anshuman Gupta

This lib function evaluate the lpsp capability from the connector specific debugfs attribute i915_lpsp_info.

---
 lib/igt_pm.c | 27 +++++++++++++++++++++++++++
 lib/igt_pm.h |  1 +
 2 files changed, 28 insertions(+)
lib/igt_pm.c +2 -0
index 9d441e1b..7a6cab7c 100644
@@ -37,6 +37,7 @@
 #include <dirent.h>
 
 #include "drmtest.h"
+#include "igt_kms.h"
 #include "igt_pm.h"
 #include "igt_aux.h"
 #include "igt_sysfs.h"
@@ -827,3 +828,29 @@ bool igt_pm_pc8_plus_residencies_enabled(int msr_fd)
 
 	return true;
 }
+

lib/igt_pm.c bool igt_pm_pc8_plus_residencies_enabled(int msr_fd) · line 841

Quoted 10 lines
lib/igt_pm.c +10 -0
+/**
+ * igt_output_is_lpsp_capable:
+ * @drm_fd: fd to drm device
+ * @output: igt output for which lpsp capability need to be evaluated
+ * Check lpsp capability for a given output.
+ *
+ * Returns:
+ * True if given output is lpsp capable otherwise false.
+ */
+bool igt_output_is_lpsp_capable(int drm_fd, igt_output_t *output)

Do we have a file for i915-specific features? If not, maybe prefixing the function with i915 would help readers understand that this is an i915-specific function.

Quoted 21 lines
lib/igt_pm.c +15 -0
+{
+	char buf[256];
+	int fd, len;
+
+	fd = igt_debugfs_connector_dir(drm_fd, output->name, O_RDONLY);
+	igt_require(fd >= 0);
+	len = igt_debugfs_simple_read(fd, "i915_lpsp_info", buf, sizeof(buf));
+
+	if (len < 0)
+		igt_assert_eq(len, -ENODEV);
+
+	close(fd);
+
+	return strstr(buf, "LPSP capable");
+}
lib/igt_pm.h +0 -0
index 5e438452..076d8c27 100644

lib/igt_pm.h enum igt_runtime_pm_status igt_get_runtime_pm_status(void); · line 58

Quoted 6 lines
lib/igt_pm.h +1 -0
@@ -53,5 +53,6 @@ enum igt_runtime_pm_status igt_get_runtime_pm_status(void);
 bool igt_wait_for_pm_status(enum igt_runtime_pm_status status);
 bool igt_pm_dmc_loaded(int debugfs);
 bool igt_pm_pc8_plus_residencies_enabled(int msr_fd);
+bool igt_output_is_lpsp_capable(int drm_fd, igt_output_t *output);
 
 #endif /* IGT_PM_H */

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#3 lore raw

Re: [igt-dev] [PATCH i-g-t v2 1/5] lib/igt_pm: Add lib func to get lpsp capability

Quoted 33 lines · Martin
Quoted 32 lines · Anshuman Gupta

This lib function evaluate the lpsp capability from the connector specific debugfs attribute i915_lpsp_info.

---
 lib/igt_pm.c | 27 +++++++++++++++++++++++++++
 lib/igt_pm.h |  1 +
 2 files changed, 28 insertions(+)
lib/igt_pm.c +8 -0
index 9d441e1b..7a6cab7c 100644
@@ -37,6 +37,7 @@
 #include <dirent.h>
 
 #include "drmtest.h"
+#include "igt_kms.h"
 #include "igt_pm.h"
 #include "igt_aux.h"
 #include "igt_sysfs.h"
@@ -827,3 +828,29 @@ bool igt_pm_pc8_plus_residencies_enabled(int msr_fd)
 
 	return true;
 }
+
+/**
+ * igt_output_is_lpsp_capable:
+ * @drm_fd: fd to drm device
+ * @output: igt output for which lpsp capability need to be evaluated
+ * Check lpsp capability for a given output.
+ *
Quoted 8 lines

lib/igt_pm.c bool igt_pm_pc8_plus_residencies_enabled(int msr_fd) · line 841

Quoted 4 lines
lib/igt_pm.c +4 -0
+ * Returns:
+ * True if given output is lpsp capable otherwise false.
+ */
+bool igt_output_is_lpsp_capable(int drm_fd, igt_output_t *output)

Do we have a file for i915-specific features? If not, maybe prefixing the function with i915 would help readers understand that this is an i915-specific function.

I am unable to find any igt lib file for i915-features. IMO this is a power feature, igt_pm.c suits it. I will change the prefix to i915_ but all other function in this file are using igt_ prefix,
i hope that will not be an issue.
Thanks,
Anshuman Gupta.

Quoted 26 lines
Quoted 26 lines
lib/igt_pm.c +15 -0
+{
+	char buf[256];
+	int fd, len;
+
+	fd = igt_debugfs_connector_dir(drm_fd, output->name, O_RDONLY);
+	igt_require(fd >= 0);
+	len = igt_debugfs_simple_read(fd, "i915_lpsp_info", buf, sizeof(buf));
+
+	if (len < 0)
+		igt_assert_eq(len, -ENODEV);
+
+	close(fd);
+
+	return strstr(buf, "LPSP capable");
+}
lib/igt_pm.h +1 -0
index 5e438452..076d8c27 100644
@@ -53,5 +53,6 @@ enum igt_runtime_pm_status igt_get_runtime_pm_status(void);
 bool igt_wait_for_pm_status(enum igt_runtime_pm_status status);
 bool igt_pm_dmc_loaded(int debugfs);
 bool igt_pm_pc8_plus_residencies_enabled(int msr_fd);
+bool igt_output_is_lpsp_capable(int drm_fd, igt_output_t *output);
 
Quoted 6 lines

lib/igt_pm.h enum igt_runtime_pm_status igt_get_runtime_pm_status(void); · line 58

Quoted 2 lines
lib/igt_pm.h +0 -0
 #endif /* IGT_PM_H */

pub 2048R/33A53379 2019-12-02 Martin Peres <[email protected]> sub 2048R/C5E7DE5F 2019-12-02 [expires: 2020-12-01]

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#4 lore raw

PATCH v2 2/5 tests/i915_pm_lpsp: lpsp platform agnostic support

In reply to Anshuman Gupta

Current implementation of lpsp igt test, assumed that every non-edp panel isn't a lpsp panel but it is not true on TGL anymore, any HDMI/DP/DSI panel connected on pipe A and connected to PORT_{A,B,C} can drive LPSP.
Even on older Gen9 platform a DP panel can drive lpsp on Port A. This requires complete design change in current lpsp igt for a platform agnostic support.

The new igt approach is relies on connector specific debugfs attribute i915_lpsp_info, which exposes whether an output is capable of driving lpsp and whether lpsp is enabled.

v2:
- CI failures fixup.

---
 tests/i915/i915_pm_lpsp.c | 303 +++++++++++++++++++++++---------------
 1 file changed, 186 insertions(+), 117 deletions(-)
tests/i915/i915_pm_lpsp.c +186 -117
index 42938e10..e400c92e 100644
@@ -25,49 +25,125 @@
  */
 
 #include "igt.h"
+#include "igt_kmod.h"
+#include "igt_pm.h"
+#include "igt_sysfs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
 
+#define MAX_SINK_LPSP_INFO_BUF_LEN	5000
 
-static bool supports_lpsp(uint32_t devid)
+#define PWR_DOMAIN_INFO "i915_power_domain_info"
+
+const char *snd_module[10] = {"snd_hda_codec_hdmi", "snd_hda_intel", "snd_hda_codec", "snd_hda_core", NULL};
+
+typedef struct {
+	int drm_fd;
+	int debugfs_fd;
+	uint32_t devid;
+	char *pwr_dmn_info;
+	igt_display_t display;
+	struct igt_fb fb;
+	drmModeModeInfo *mode;
+	igt_output_t *output;
+} data_t;
+
+static void debugfs_read(int fd, const char *param, char *buf, int len)
 {
-	return IS_HASWELL(devid) || IS_BROADWELL(devid);
+	len = igt_debugfs_simple_read(fd, param, buf, len);
+	if (len < 0)
+		igt_assert_eq(len, -ENODEV);
 }
 
-static bool lpsp_is_enabled(int drm_fd)
+static bool lpsp_is_enabled(data_t *data)
 {
-	uint32_t val;
+	char buf[MAX_SINK_LPSP_INFO_BUF_LEN];
+	int fd;
+
+	fd = igt_debugfs_connector_dir(data->drm_fd, data->output->name,
+				       O_RDONLY);
+	igt_require(fd >= 0);
+
+	debugfs_read(fd, "i915_lpsp_info", buf, sizeof(buf));
+	close(fd);
 
-	val = INREG(HSW_PWR_WELL_CTL2);
-	return !(val & HSW_PWR_WELL_STATE_ENABLED);
+	return strstr(buf, "LPSP enabled");
 }
 
-/* The LPSP mode is all about an enabled pipe, but we expect to also be in the
- * low power mode when no pipes are enabled, so do this check anyway. */
-static void screens_disabled_subtest(int drm_fd, drmModeResPtr drm_res)
+/*
+ * The LPSP mode is all about an enabled pipe, but we expect to also be in the
+ * low power mode when no pipes are enabled, so do this check anyway.
+ */
+static void screens_disabled_subtest(data_t *data)
 {
-	kmstest_unset_all_crtcs(drm_fd, drm_res);
-	igt_assert(lpsp_is_enabled(drm_fd));
+	igt_output_t *output;
+	enum pipe pipe;
+	igt_plane_t *primary;
+
+	for_each_pipe_with_single_output(&data->display, pipe, output) {
+		data->output = output;
+		igt_output_set_pipe(data->output, pipe);
+		primary = igt_output_get_plane_type(data->output,
+						    DRM_PLANE_TYPE_PRIMARY);
+		igt_plane_set_fb(primary, NULL);
+		igt_display_commit(&data->display);
+	}
+
+	igt_assert(lpsp_is_enabled(data));
 }
 
-static uint32_t create_fb(int drm_fd, int width, int height)
+static void check_output_lpsp(data_t *data)
 {
-	struct igt_fb fb;
+	if (igt_output_is_lpsp_capable(data->drm_fd, data->output))
+		igt_assert_f(lpsp_is_enabled(data), "%s: lpsp is not enabled\n%s:\n%s\n",
+			     data->output->name, PWR_DOMAIN_INFO, data->pwr_dmn_info =
+			     igt_sysfs_get(data->debugfs_fd, PWR_DOMAIN_INFO));
+	else
+		igt_assert(!lpsp_is_enabled(data));
+}
 
-	return igt_create_pattern_fb(drm_fd, width, height, DRM_FORMAT_XRGB8888,
-				     LOCAL_DRM_FORMAT_MOD_NONE, &fb);
+static void setup_lpsp_output(data_t *data)
+{
+	igt_plane_t *primary;
+
+	/* set output pipe = PIPE_A for LPSP */
+	igt_output_set_pipe(data->output, PIPE_A);
+	primary = igt_output_get_plane_type(data->output,
+					    DRM_PLANE_TYPE_PRIMARY);
+	igt_plane_set_fb(primary, NULL);
+	igt_create_pattern_fb(data->drm_fd,
+			      data->mode->hdisplay, data->mode->vdisplay,
+			      DRM_FORMAT_XRGB8888,
+			      LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->fb);
+	igt_plane_set_fb(primary, &data->fb);
+	igt_display_commit(&data->display);
+}
+
+static void cleanup_lpsp_output(data_t *data)
+{
+	igt_plane_t *primary;
+
+	if (!data->output)
+		return;
+
+	primary = igt_output_get_plane_type(data->output,
+					    DRM_PLANE_TYPE_PRIMARY);
+	igt_plane_set_fb(primary, NULL);
+	igt_output_set_pipe(data->output, PIPE_NONE);
+	igt_display_commit(&data->display);
+	igt_remove_fb(data->drm_fd, &data->fb);
+	data->output = NULL;
 }
 
-static void edp_subtest(int drm_fd, drmModeResPtr drm_res,
-			drmModeConnectorPtr *drm_connectors, uint32_t devid,
-			bool use_panel_fitter)
+static void edp_subtest(data_t *data, bool use_panel_fitter)
 {
-	int i, rc;
-	uint32_t crtc_id = 0, buffer_id = 0;
-	drmModeConnectorPtr connector = NULL;
-	drmModeModeInfoPtr mode = NULL;
+	igt_display_t *display = &data->display;
+	igt_output_t *output;
+	int valid_output;
+
 	drmModeModeInfo std_1024_mode = {
 		.clock = 65000,
 		.hdisplay = 1024,
@@ -86,23 +162,17 @@ static void edp_subtest(int drm_fd, drmModeResPtr drm_res,
 		.name = "Custom 1024x768",
 	};
 
-	kmstest_unset_all_crtcs(drm_fd, drm_res);
-
-	for (i = 0; i < drm_res->count_connectors; i++) {
-		drmModeConnectorPtr c = drm_connectors[i];
+	for_each_connected_output(display, output) {
+		drmModeConnectorPtr c = output->config.connector;
 
 		if (c->connector_type != DRM_MODE_CONNECTOR_eDP)
 			continue;
-		if (c->connection != DRM_MODE_CONNECTED)
+		if (!igt_pipe_connector_valid(PIPE_A, output))
 			continue;
 
-		if (!use_panel_fitter && c->count_modes) {
-			connector = c;
-			mode = &c->modes[0];
-			break;
-		}
+		data->output = output;
+
 		if (use_panel_fitter) {
-			connector = c;
 
 			/* This is one of the modes Xorg creates for panels, so
 			 * it should work just fine. Notice that Gens that
@@ -113,124 +183,123 @@ static void edp_subtest(int drm_fd, drmModeResPtr drm_res,
 				   c->modes[0].hdisplay > 1024);
 			igt_assert(c->count_modes &&
 				   c->modes[0].vdisplay > 768);
-			mode = &std_1024_mode;
-			break;
+			data->mode = &std_1024_mode;
+			igt_output_override_mode(output, data->mode);
+		} else {
+			data->mode = igt_output_get_mode(output);
 		}
-	}
-	igt_require(connector);
 
-	crtc_id = kmstest_find_crtc_for_connector(drm_fd, drm_res, connector,
-						  0);
-	buffer_id = create_fb(drm_fd, mode->hdisplay, mode->vdisplay);
+		setup_lpsp_output(data);
+
+		if (use_panel_fitter && IS_HASWELL(data->devid))
+			igt_assert(!lpsp_is_enabled(data));
+		else
+			check_output_lpsp(data);
 
-	igt_assert(buffer_id);
-	igt_assert(connector);
-	igt_assert(mode);
+		cleanup_lpsp_output(data);
+		valid_output++;
+	}
 
-	rc = drmModeSetCrtc(drm_fd, crtc_id, buffer_id, 0, 0,
-			    &connector->connector_id, 1, mode);
-	igt_assert_eq(rc, 0);
+	igt_require_f(valid_output, "No edp connector found\n");
+}
 
-	if (use_panel_fitter) {
-		if (IS_HASWELL(devid))
-			igt_assert(!lpsp_is_enabled(drm_fd));
-		else
-			igt_assert(lpsp_is_enabled(drm_fd));
-	} else {
-		igt_assert(lpsp_is_enabled(drm_fd));
+static bool unload_snd_hda_core_module(void)
+{
+	int i;
+
+	/* unbind snd_hda_intel */
+	kick_snd_hda_intel();
+
+	for (i = 0; snd_module[i]; i++) {
+		if (igt_kmod_is_loaded(snd_module[i]) &&
+		    igt_kmod_unload(snd_module[i], KMOD_REMOVE_FORCE)) {
+			igt_warn("Could not unload %s\n", snd_module[i]);
+			igt_kmod_list_loaded();
+			igt_lsof("/dev/snd");
+			return false;
+		}
 	}
+
+	return true;
 }
 
-static void non_edp_subtest(int drm_fd, drmModeResPtr drm_res,
-			    drmModeConnectorPtr *drm_connectors)
+static void load_snd_hda_core_module(void)
 {
-	int i, rc;
-	uint32_t crtc_id = 0, buffer_id = 0;
-	drmModeConnectorPtr connector = NULL;
-	drmModeModeInfoPtr mode = NULL;
+	igt_kmod_load("snd_hda_core", NULL);
+}
+
+static void non_edp_subtest(data_t *data)
+{
+	igt_display_t *display = &data->display;
+	igt_output_t *output;
+	int valid_output;
 
-	kmstest_unset_all_crtcs(drm_fd, drm_res);
+	/* DP/HDMI panel requires to drive lpsp without audio */
+	igt_require(unload_snd_hda_core_module());
 
-	for (i = 0; i < drm_res->count_connectors; i++) {
-		drmModeConnectorPtr c = drm_connectors[i];
+	for_each_connected_output(display, output) {
+		drmModeConnectorPtr c = output->config.connector;
 
 		if (c->connector_type == DRM_MODE_CONNECTOR_eDP)
 			continue;
 		if (c->connection != DRM_MODE_CONNECTED)
 			continue;
+		if (!igt_pipe_connector_valid(PIPE_A, output))
+			continue;
 
-		if (c->count_modes) {
-			connector = c;
-			mode = &c->modes[0];
-			break;
-		}
+		data->output = output;
+		data->mode = igt_output_get_mode(output);
+		setup_lpsp_output(data);
+		check_output_lpsp(data);
+		cleanup_lpsp_output(data);
+		load_snd_hda_core_module();
+		valid_output++;
 	}
-	igt_require(connector);
-
-	crtc_id = kmstest_find_crtc_for_connector(drm_fd, drm_res, connector,
-						  0);
-	buffer_id = create_fb(drm_fd, mode->hdisplay, mode->vdisplay);
 
-	igt_assert(buffer_id);
-	igt_assert(mode);
-
-	rc = drmModeSetCrtc(drm_fd, crtc_id, buffer_id, 0, 0,
-			    &connector->connector_id, 1, mode);
-	igt_assert_eq(rc, 0);
-
-	igt_assert(!lpsp_is_enabled(drm_fd));
+	igt_require_f(valid_output, "No non-edp connector found\n");
 }
 
-#define MAX_CONNECTORS 32
-
-int drm_fd;
-uint32_t devid;
-drmModeResPtr drm_res;
-drmModeConnectorPtr drm_connectors[MAX_CONNECTORS];
-struct intel_mmio_data mmio_data;
+IGT_TEST_DESCRIPTION("These tests validates display Low Power Single Pipe configurations");
 igt_main
 {
-	igt_fixture {
-		int i;
-
-		drm_fd = drm_open_driver_master(DRIVER_INTEL);
-		igt_require(drm_fd >= 0);
-
-		devid = intel_get_drm_devid(drm_fd);
+	data_t data = {};
 
-		drm_res = drmModeGetResources(drm_fd);
-		igt_require(drm_res);
-		igt_assert(drm_res->count_connectors <= MAX_CONNECTORS);
-
-		for (i = 0; i < drm_res->count_connectors; i++)
-			drm_connectors[i] = drmModeGetConnectorCurrent(drm_fd,
-							drm_res->connectors[i]);
+	igt_fixture {
 
+		data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
+		igt_require(data.drm_fd >= 0);
+		data.debugfs_fd = igt_debugfs_dir(data.drm_fd);
+		igt_require(data.debugfs_fd >= 0);
 		igt_pm_enable_audio_runtime_pm();
-
-		igt_require(supports_lpsp(devid));
-
-		intel_register_access_init(&mmio_data, intel_get_pci_device(), 0, drm_fd);
-
 		kmstest_set_vt_graphics_mode();
+		data.devid = intel_get_drm_devid(data.drm_fd);
+		igt_display_require(&data.display, data.drm_fd);
+		igt_require(igt_pm_dmc_loaded(data.debugfs_fd));
 	}
 
+	igt_describe("This test validates lpsp while all crtc are disabled");
 	igt_subtest("screens-disabled")
-		screens_disabled_subtest(drm_fd, drm_res);
+		screens_disabled_subtest(&data);
+	igt_describe("This test validates lpsp on eDP panel");
 	igt_subtest("edp-native")
-		edp_subtest(drm_fd, drm_res, drm_connectors, devid, false);
+		edp_subtest(&data, false);
+	igt_fixture
+		cleanup_lpsp_output(&data);
+	igt_describe("This test validates lpsp on eDP panel while forcing panel_fitter");
 	igt_subtest("edp-panel-fitter")
-		edp_subtest(drm_fd, drm_res, drm_connectors, devid, true);
+		edp_subtest(&data, true);
+	igt_fixture
+		cleanup_lpsp_output(&data);
+	igt_describe("This test validates lpsp on DP/HDMI/DSI panels");
 	igt_subtest("non-edp")
-		non_edp_subtest(drm_fd, drm_res, drm_connectors);
+		non_edp_subtest(&data);
+	igt_fixture
+		cleanup_lpsp_output(&data);
 
 	igt_fixture {
-		int i;
-
-		intel_register_access_fini(&mmio_data);
-		for (i = 0; i < drm_res->count_connectors; i++)
-			drmModeFreeConnector(drm_connectors[i]);
-		drmModeFreeResources(drm_res);
-		close(drm_fd);
+		free(data.pwr_dmn_info);
+		load_snd_hda_core_module();
+		close(data.drm_fd);
+		igt_display_fini(&data.display);
 	}
 }
Signature · 6 lines
2.25.2

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#5 lore raw

Re: [igt-dev] [PATCH i-g-t v2 2/5] tests/i915_pm_lpsp: lpsp platform agnostic support

Quoted 275 lines · Anshuman Gupta

Current implementation of lpsp igt test, assumed that every non-edp panel isn't a lpsp panel but it is not true on TGL anymore, any HDMI/DP/DSI panel connected on pipe A and connected to PORT_{A,B,C} can drive LPSP.
Even on older Gen9 platform a DP panel can drive lpsp on Port A. This requires complete design change in current lpsp igt for a platform agnostic support.

The new igt approach is relies on connector specific debugfs attribute i915_lpsp_info, which exposes whether an output is capable of driving lpsp and whether lpsp is enabled.

v2:
- CI failures fixup.

---
 tests/i915/i915_pm_lpsp.c | 303 +++++++++++++++++++++++---------------
 1 file changed, 186 insertions(+), 117 deletions(-)
tests/i915/i915_pm_lpsp.c +138 -59
index 42938e10..e400c92e 100644
@@ -25,49 +25,125 @@
  */
 
 #include "igt.h"
+#include "igt_kmod.h"
+#include "igt_pm.h"
+#include "igt_sysfs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
 
+#define MAX_SINK_LPSP_INFO_BUF_LEN	5000
 
-static bool supports_lpsp(uint32_t devid)
+#define PWR_DOMAIN_INFO "i915_power_domain_info"
+
+const char *snd_module[10] = {"snd_hda_codec_hdmi", "snd_hda_intel", "snd_hda_codec", "snd_hda_core", NULL};
+
+typedef struct {
+	int drm_fd;
+	int debugfs_fd;
+	uint32_t devid;
+	char *pwr_dmn_info;
+	igt_display_t display;
+	struct igt_fb fb;
+	drmModeModeInfo *mode;
+	igt_output_t *output;
+} data_t;
+
+static void debugfs_read(int fd, const char *param, char *buf, int len)
 {
-	return IS_HASWELL(devid) || IS_BROADWELL(devid);
+	len = igt_debugfs_simple_read(fd, param, buf, len);
+	if (len < 0)
+		igt_assert_eq(len, -ENODEV);
 }
 
-static bool lpsp_is_enabled(int drm_fd)
+static bool lpsp_is_enabled(data_t *data)
 {
-	uint32_t val;
+	char buf[MAX_SINK_LPSP_INFO_BUF_LEN];
+	int fd;
+
+	fd = igt_debugfs_connector_dir(data->drm_fd, data->output->name,
+				       O_RDONLY);
+	igt_require(fd >= 0);
+
+	debugfs_read(fd, "i915_lpsp_info", buf, sizeof(buf));
+	close(fd);
 
-	val = INREG(HSW_PWR_WELL_CTL2);
-	return !(val & HSW_PWR_WELL_STATE_ENABLED);
+	return strstr(buf, "LPSP enabled");
 }
 
-/* The LPSP mode is all about an enabled pipe, but we expect to also be in the
- * low power mode when no pipes are enabled, so do this check anyway. */
-static void screens_disabled_subtest(int drm_fd, drmModeResPtr drm_res)
+/*
+ * The LPSP mode is all about an enabled pipe, but we expect to also be in the
+ * low power mode when no pipes are enabled, so do this check anyway.
+ */
+static void screens_disabled_subtest(data_t *data)
 {
-	kmstest_unset_all_crtcs(drm_fd, drm_res);
-	igt_assert(lpsp_is_enabled(drm_fd));
+	igt_output_t *output;
+	enum pipe pipe;
+	igt_plane_t *primary;
+
+	for_each_pipe_with_single_output(&data->display, pipe, output) {
+		data->output = output;
+		igt_output_set_pipe(data->output, pipe);
+		primary = igt_output_get_plane_type(data->output,
+						    DRM_PLANE_TYPE_PRIMARY);
+		igt_plane_set_fb(primary, NULL);
+		igt_display_commit(&data->display);
+	}
+
+	igt_assert(lpsp_is_enabled(data));
 }
 
-static uint32_t create_fb(int drm_fd, int width, int height)
+static void check_output_lpsp(data_t *data)
 {
-	struct igt_fb fb;
+	if (igt_output_is_lpsp_capable(data->drm_fd, data->output))
+		igt_assert_f(lpsp_is_enabled(data), "%s: lpsp is not enabled\n%s:\n%s\n",
+			     data->output->name, PWR_DOMAIN_INFO, data->pwr_dmn_info =
+			     igt_sysfs_get(data->debugfs_fd, PWR_DOMAIN_INFO));
+	else
+		igt_assert(!lpsp_is_enabled(data));
+}
 
-	return igt_create_pattern_fb(drm_fd, width, height, DRM_FORMAT_XRGB8888,
-				     LOCAL_DRM_FORMAT_MOD_NONE, &fb);
+static void setup_lpsp_output(data_t *data)
+{
+	igt_plane_t *primary;
+
+	/* set output pipe = PIPE_A for LPSP */
+	igt_output_set_pipe(data->output, PIPE_A);
+	primary = igt_output_get_plane_type(data->output,
+					    DRM_PLANE_TYPE_PRIMARY);
+	igt_plane_set_fb(primary, NULL);
+	igt_create_pattern_fb(data->drm_fd,
+			      data->mode->hdisplay, data->mode->vdisplay,
+			      DRM_FORMAT_XRGB8888,
+			      LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->fb);
+	igt_plane_set_fb(primary, &data->fb);
+	igt_display_commit(&data->display);
+}
+
+static void cleanup_lpsp_output(data_t *data)
+{
+	igt_plane_t *primary;
+
+	if (!data->output)
+		return;
+
+	primary = igt_output_get_plane_type(data->output,
+					    DRM_PLANE_TYPE_PRIMARY);
+	igt_plane_set_fb(primary, NULL);
+	igt_output_set_pipe(data->output, PIPE_NONE);
+	igt_display_commit(&data->display);
+	igt_remove_fb(data->drm_fd, &data->fb);
+	data->output = NULL;
 }
 
-static void edp_subtest(int drm_fd, drmModeResPtr drm_res,
-			drmModeConnectorPtr *drm_connectors, uint32_t devid,
-			bool use_panel_fitter)
+static void edp_subtest(data_t *data, bool use_panel_fitter)
 {
-	int i, rc;
-	uint32_t crtc_id = 0, buffer_id = 0;
-	drmModeConnectorPtr connector = NULL;
-	drmModeModeInfoPtr mode = NULL;
+	igt_display_t *display = &data->display;
+	igt_output_t *output;
+	int valid_output;
+
 	drmModeModeInfo std_1024_mode = {
 		.clock = 65000,
 		.hdisplay = 1024,
@@ -86,23 +162,17 @@ static void edp_subtest(int drm_fd, drmModeResPtr drm_res,
 		.name = "Custom 1024x768",
 	};
 
-	kmstest_unset_all_crtcs(drm_fd, drm_res);
-
-	for (i = 0; i < drm_res->count_connectors; i++) {
-		drmModeConnectorPtr c = drm_connectors[i];
+	for_each_connected_output(display, output) {
+		drmModeConnectorPtr c = output->config.connector;
 
 		if (c->connector_type != DRM_MODE_CONNECTOR_eDP)
 			continue;
-		if (c->connection != DRM_MODE_CONNECTED)
+		if (!igt_pipe_connector_valid(PIPE_A, output))
 			continue;
 
-		if (!use_panel_fitter && c->count_modes) {
-			connector = c;
-			mode = &c->modes[0];
-			break;
-		}
+		data->output = output;
+
 		if (use_panel_fitter) {
-			connector = c;
 
 			/* This is one of the modes Xorg creates for panels, so
 			 * it should work just fine. Notice that Gens that
@@ -113,124 +183,123 @@ static void edp_subtest(int drm_fd, drmModeResPtr drm_res,
 				   c->modes[0].hdisplay > 1024);
 			igt_assert(c->count_modes &&
 				   c->modes[0].vdisplay > 768);
-			mode = &std_1024_mode;
-			break;
+			data->mode = &std_1024_mode;
+			igt_output_override_mode(output, data->mode);
+		} else {
+			data->mode = igt_output_get_mode(output);
 		}
-	}
-	igt_require(connector);
 
-	crtc_id = kmstest_find_crtc_for_connector(drm_fd, drm_res, connector,
-						  0);
-	buffer_id = create_fb(drm_fd, mode->hdisplay, mode->vdisplay);
+		setup_lpsp_output(data);
+
+		if (use_panel_fitter && IS_HASWELL(data->devid))
+			igt_assert(!lpsp_is_enabled(data));
+		else
+			check_output_lpsp(data);
 
-	igt_assert(buffer_id);
-	igt_assert(connector);
-	igt_assert(mode);
+		cleanup_lpsp_output(data);
+		valid_output++;
+	}
 
-	rc = drmModeSetCrtc(drm_fd, crtc_id, buffer_id, 0, 0,
-			    &connector->connector_id, 1, mode);
-	igt_assert_eq(rc, 0);
+	igt_require_f(valid_output, "No edp connector found\n");
+}
 
-	if (use_panel_fitter) {
-		if (IS_HASWELL(devid))
-			igt_assert(!lpsp_is_enabled(drm_fd));
-		else
-			igt_assert(lpsp_is_enabled(drm_fd));
-	} else {
-		igt_assert(lpsp_is_enabled(drm_fd));
+static bool unload_snd_hda_core_module(void)
+{
+	int i;
+
+	/* unbind snd_hda_intel */
+	kick_snd_hda_intel();
+
+	for (i = 0; snd_module[i]; i++) {
+		if (igt_kmod_is_loaded(snd_module[i]) &&
+		    igt_kmod_unload(snd_module[i], KMOD_REMOVE_FORCE)) {
+			igt_warn("Could not unload %s\n", snd_module[i]);
+			igt_kmod_list_loaded();
+			igt_lsof("/dev/snd");
+			return false;
+		}
 	}
+
+	return true;
 }
 
-static void non_edp_subtest(int drm_fd, drmModeResPtr drm_res,
-			    drmModeConnectorPtr *drm_connectors)
+static void load_snd_hda_core_module(void)
 {
-	int i, rc;
-	uint32_t crtc_id = 0, buffer_id = 0;
-	drmModeConnectorPtr connector = NULL;
-	drmModeModeInfoPtr mode = NULL;
+	igt_kmod_load("snd_hda_core", NULL);
+}

tests/i915/i915_pm_lpsp.c static void edp_subtest(int drm_fd, drmModeResPtr drm_res, · line 238

Quoted 10 lines
tests/i915/i915_pm_lpsp.c +8 -1
+
+static void non_edp_subtest(data_t *data)
+{
+	igt_display_t *display = &data->display;
+	igt_output_t *output;
+	int valid_output;
 
-	kmstest_unset_all_crtcs(drm_fd, drm_res);
+	/* DP/HDMI panel requires to drive lpsp without audio */
+	igt_require(unload_snd_hda_core_module());

I'm not super happy with having to unload modules that it would be very easy to forget to re-add and would make audio tests fail :s

IMO, if the DUT is not playing sound, we should be able to enter LPSP. If no, then I would consider this a driver bug for wasting energy sending 0s to the screen.

Thoughts on this?

Martin

Quoted 115 lines
tests/i915/i915_pm_lpsp.c +36 -54
-	for (i = 0; i < drm_res->count_connectors; i++) {
-		drmModeConnectorPtr c = drm_connectors[i];
+	for_each_connected_output(display, output) {
+		drmModeConnectorPtr c = output->config.connector;
 
 		if (c->connector_type == DRM_MODE_CONNECTOR_eDP)
 			continue;
 		if (c->connection != DRM_MODE_CONNECTED)
 			continue;
+		if (!igt_pipe_connector_valid(PIPE_A, output))
+			continue;
 
-		if (c->count_modes) {
-			connector = c;
-			mode = &c->modes[0];
-			break;
-		}
+		data->output = output;
+		data->mode = igt_output_get_mode(output);
+		setup_lpsp_output(data);
+		check_output_lpsp(data);
+		cleanup_lpsp_output(data);
+		load_snd_hda_core_module();
+		valid_output++;
 	}
-	igt_require(connector);
-
-	crtc_id = kmstest_find_crtc_for_connector(drm_fd, drm_res, connector,
-						  0);
-	buffer_id = create_fb(drm_fd, mode->hdisplay, mode->vdisplay);
 
-	igt_assert(buffer_id);
-	igt_assert(mode);
-
-	rc = drmModeSetCrtc(drm_fd, crtc_id, buffer_id, 0, 0,
-			    &connector->connector_id, 1, mode);
-	igt_assert_eq(rc, 0);
-
-	igt_assert(!lpsp_is_enabled(drm_fd));
+	igt_require_f(valid_output, "No non-edp connector found\n");
 }
 
-#define MAX_CONNECTORS 32
-
-int drm_fd;
-uint32_t devid;
-drmModeResPtr drm_res;
-drmModeConnectorPtr drm_connectors[MAX_CONNECTORS];
-struct intel_mmio_data mmio_data;
+IGT_TEST_DESCRIPTION("These tests validates display Low Power Single Pipe configurations");
 igt_main
 {
-	igt_fixture {
-		int i;
-
-		drm_fd = drm_open_driver_master(DRIVER_INTEL);
-		igt_require(drm_fd >= 0);
-
-		devid = intel_get_drm_devid(drm_fd);
+	data_t data = {};
 
-		drm_res = drmModeGetResources(drm_fd);
-		igt_require(drm_res);
-		igt_assert(drm_res->count_connectors <= MAX_CONNECTORS);
-
-		for (i = 0; i < drm_res->count_connectors; i++)
-			drm_connectors[i] = drmModeGetConnectorCurrent(drm_fd,
-							drm_res->connectors[i]);
+	igt_fixture {
 
+		data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
+		igt_require(data.drm_fd >= 0);
+		data.debugfs_fd = igt_debugfs_dir(data.drm_fd);
+		igt_require(data.debugfs_fd >= 0);
 		igt_pm_enable_audio_runtime_pm();
-
-		igt_require(supports_lpsp(devid));
-
-		intel_register_access_init(&mmio_data, intel_get_pci_device(), 0, drm_fd);
-
 		kmstest_set_vt_graphics_mode();
+		data.devid = intel_get_drm_devid(data.drm_fd);
+		igt_display_require(&data.display, data.drm_fd);
+		igt_require(igt_pm_dmc_loaded(data.debugfs_fd));
 	}
 
+	igt_describe("This test validates lpsp while all crtc are disabled");
 	igt_subtest("screens-disabled")
-		screens_disabled_subtest(drm_fd, drm_res);
+		screens_disabled_subtest(&data);
+	igt_describe("This test validates lpsp on eDP panel");
 	igt_subtest("edp-native")
-		edp_subtest(drm_fd, drm_res, drm_connectors, devid, false);
+		edp_subtest(&data, false);
+	igt_fixture
+		cleanup_lpsp_output(&data);
+	igt_describe("This test validates lpsp on eDP panel while forcing panel_fitter");
 	igt_subtest("edp-panel-fitter")
-		edp_subtest(drm_fd, drm_res, drm_connectors, devid, true);
+		edp_subtest(&data, true);
+	igt_fixture
+		cleanup_lpsp_output(&data);
+	igt_describe("This test validates lpsp on DP/HDMI/DSI panels");
 	igt_subtest("non-edp")
-		non_edp_subtest(drm_fd, drm_res, drm_connectors);
+		non_edp_subtest(&data);
+	igt_fixture
+		cleanup_lpsp_output(&data);
 
 	igt_fixture {
-		int i;
-
-		intel_register_access_fini(&mmio_data);
-		for (i = 0; i < drm_res->count_connectors; i++)

tests/i915/i915_pm_lpsp.c static void edp_subtest(int drm_fd, drmModeResPtr drm_res,

Quoted 10 lines
tests/i915/i915_pm_lpsp.c +4 -3
-			drmModeFreeConnector(drm_connectors[i]);
-		drmModeFreeResources(drm_res);
-		close(drm_fd);
+		free(data.pwr_dmn_info);
+		load_snd_hda_core_module();
+		close(data.drm_fd);
+		igt_display_fini(&data.display);
 	}
 }
 

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#6 lore raw

Re: [igt-dev] [PATCH i-g-t v2 2/5] tests/i915_pm_lpsp: lpsp platform agnostic support

Quoted 290 lines · Martin
Quoted 275 lines · Anshuman Gupta

Current implementation of lpsp igt test, assumed that every non-edp panel isn't a lpsp panel but it is not true on TGL anymore, any HDMI/DP/DSI panel connected on pipe A and connected to PORT_{A,B,C} can drive LPSP.
Even on older Gen9 platform a DP panel can drive lpsp on Port A. This requires complete design change in current lpsp igt for a platform agnostic support.

The new igt approach is relies on connector specific debugfs attribute i915_lpsp_info, which exposes whether an output is capable of driving lpsp and whether lpsp is enabled.

v2:
- CI failures fixup.

---
 tests/i915/i915_pm_lpsp.c | 303 +++++++++++++++++++++++---------------
 1 file changed, 186 insertions(+), 117 deletions(-)
tests/i915/i915_pm_lpsp.c +138 -59
index 42938e10..e400c92e 100644
@@ -25,49 +25,125 @@
  */
 
 #include "igt.h"
+#include "igt_kmod.h"
+#include "igt_pm.h"
+#include "igt_sysfs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
 
+#define MAX_SINK_LPSP_INFO_BUF_LEN	5000
 
-static bool supports_lpsp(uint32_t devid)
+#define PWR_DOMAIN_INFO "i915_power_domain_info"
+
+const char *snd_module[10] = {"snd_hda_codec_hdmi", "snd_hda_intel", "snd_hda_codec", "snd_hda_core", NULL};
+
+typedef struct {
+	int drm_fd;
+	int debugfs_fd;
+	uint32_t devid;
+	char *pwr_dmn_info;
+	igt_display_t display;
+	struct igt_fb fb;
+	drmModeModeInfo *mode;
+	igt_output_t *output;
+} data_t;
+
+static void debugfs_read(int fd, const char *param, char *buf, int len)
 {
-	return IS_HASWELL(devid) || IS_BROADWELL(devid);
+	len = igt_debugfs_simple_read(fd, param, buf, len);
+	if (len < 0)
+		igt_assert_eq(len, -ENODEV);
 }
 
-static bool lpsp_is_enabled(int drm_fd)
+static bool lpsp_is_enabled(data_t *data)
 {
-	uint32_t val;
+	char buf[MAX_SINK_LPSP_INFO_BUF_LEN];
+	int fd;
+
+	fd = igt_debugfs_connector_dir(data->drm_fd, data->output->name,
+				       O_RDONLY);
+	igt_require(fd >= 0);
+
+	debugfs_read(fd, "i915_lpsp_info", buf, sizeof(buf));
+	close(fd);
 
-	val = INREG(HSW_PWR_WELL_CTL2);
-	return !(val & HSW_PWR_WELL_STATE_ENABLED);
+	return strstr(buf, "LPSP enabled");
 }
 
-/* The LPSP mode is all about an enabled pipe, but we expect to also be in the
- * low power mode when no pipes are enabled, so do this check anyway. */
-static void screens_disabled_subtest(int drm_fd, drmModeResPtr drm_res)
+/*
+ * The LPSP mode is all about an enabled pipe, but we expect to also be in the
+ * low power mode when no pipes are enabled, so do this check anyway.
+ */
+static void screens_disabled_subtest(data_t *data)
 {
-	kmstest_unset_all_crtcs(drm_fd, drm_res);
-	igt_assert(lpsp_is_enabled(drm_fd));
+	igt_output_t *output;
+	enum pipe pipe;
+	igt_plane_t *primary;
+
+	for_each_pipe_with_single_output(&data->display, pipe, output) {
+		data->output = output;
+		igt_output_set_pipe(data->output, pipe);
+		primary = igt_output_get_plane_type(data->output,
+						    DRM_PLANE_TYPE_PRIMARY);
+		igt_plane_set_fb(primary, NULL);
+		igt_display_commit(&data->display);
+	}
+
+	igt_assert(lpsp_is_enabled(data));
 }
 
-static uint32_t create_fb(int drm_fd, int width, int height)
+static void check_output_lpsp(data_t *data)
 {
-	struct igt_fb fb;
+	if (igt_output_is_lpsp_capable(data->drm_fd, data->output))
+		igt_assert_f(lpsp_is_enabled(data), "%s: lpsp is not enabled\n%s:\n%s\n",
+			     data->output->name, PWR_DOMAIN_INFO, data->pwr_dmn_info =
+			     igt_sysfs_get(data->debugfs_fd, PWR_DOMAIN_INFO));
+	else
+		igt_assert(!lpsp_is_enabled(data));
+}
 
-	return igt_create_pattern_fb(drm_fd, width, height, DRM_FORMAT_XRGB8888,
-				     LOCAL_DRM_FORMAT_MOD_NONE, &fb);
+static void setup_lpsp_output(data_t *data)
+{
+	igt_plane_t *primary;
+
+	/* set output pipe = PIPE_A for LPSP */
+	igt_output_set_pipe(data->output, PIPE_A);
+	primary = igt_output_get_plane_type(data->output,
+					    DRM_PLANE_TYPE_PRIMARY);
+	igt_plane_set_fb(primary, NULL);
+	igt_create_pattern_fb(data->drm_fd,
+			      data->mode->hdisplay, data->mode->vdisplay,
+			      DRM_FORMAT_XRGB8888,
+			      LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->fb);
+	igt_plane_set_fb(primary, &data->fb);
+	igt_display_commit(&data->display);
+}
+
+static void cleanup_lpsp_output(data_t *data)
+{
+	igt_plane_t *primary;
+
+	if (!data->output)
+		return;
+
+	primary = igt_output_get_plane_type(data->output,
+					    DRM_PLANE_TYPE_PRIMARY);
+	igt_plane_set_fb(primary, NULL);
+	igt_output_set_pipe(data->output, PIPE_NONE);
+	igt_display_commit(&data->display);
+	igt_remove_fb(data->drm_fd, &data->fb);
+	data->output = NULL;
 }
 
-static void edp_subtest(int drm_fd, drmModeResPtr drm_res,
-			drmModeConnectorPtr *drm_connectors, uint32_t devid,
-			bool use_panel_fitter)
+static void edp_subtest(data_t *data, bool use_panel_fitter)
 {
-	int i, rc;
-	uint32_t crtc_id = 0, buffer_id = 0;
-	drmModeConnectorPtr connector = NULL;
-	drmModeModeInfoPtr mode = NULL;
+	igt_display_t *display = &data->display;
+	igt_output_t *output;
+	int valid_output;
+
 	drmModeModeInfo std_1024_mode = {
 		.clock = 65000,
 		.hdisplay = 1024,
@@ -86,23 +162,17 @@ static void edp_subtest(int drm_fd, drmModeResPtr drm_res,
 		.name = "Custom 1024x768",
 	};
 
-	kmstest_unset_all_crtcs(drm_fd, drm_res);
-
-	for (i = 0; i < drm_res->count_connectors; i++) {
-		drmModeConnectorPtr c = drm_connectors[i];
+	for_each_connected_output(display, output) {
+		drmModeConnectorPtr c = output->config.connector;
 
 		if (c->connector_type != DRM_MODE_CONNECTOR_eDP)
 			continue;
-		if (c->connection != DRM_MODE_CONNECTED)
+		if (!igt_pipe_connector_valid(PIPE_A, output))
 			continue;
 
-		if (!use_panel_fitter && c->count_modes) {
-			connector = c;
-			mode = &c->modes[0];
-			break;
-		}
+		data->output = output;
+
 		if (use_panel_fitter) {
-			connector = c;
 
 			/* This is one of the modes Xorg creates for panels, so
 			 * it should work just fine. Notice that Gens that
@@ -113,124 +183,123 @@ static void edp_subtest(int drm_fd, drmModeResPtr drm_res,
 				   c->modes[0].hdisplay > 1024);
 			igt_assert(c->count_modes &&
 				   c->modes[0].vdisplay > 768);
-			mode = &std_1024_mode;
-			break;
+			data->mode = &std_1024_mode;
+			igt_output_override_mode(output, data->mode);
+		} else {
+			data->mode = igt_output_get_mode(output);
 		}
-	}
-	igt_require(connector);
 
-	crtc_id = kmstest_find_crtc_for_connector(drm_fd, drm_res, connector,
-						  0);
-	buffer_id = create_fb(drm_fd, mode->hdisplay, mode->vdisplay);
+		setup_lpsp_output(data);
+
+		if (use_panel_fitter && IS_HASWELL(data->devid))
+			igt_assert(!lpsp_is_enabled(data));
+		else
+			check_output_lpsp(data);
 
-	igt_assert(buffer_id);
-	igt_assert(connector);
-	igt_assert(mode);
+		cleanup_lpsp_output(data);
+		valid_output++;
+	}
 
-	rc = drmModeSetCrtc(drm_fd, crtc_id, buffer_id, 0, 0,
-			    &connector->connector_id, 1, mode);
-	igt_assert_eq(rc, 0);
+	igt_require_f(valid_output, "No edp connector found\n");
+}
 
-	if (use_panel_fitter) {
-		if (IS_HASWELL(devid))
-			igt_assert(!lpsp_is_enabled(drm_fd));
-		else
-			igt_assert(lpsp_is_enabled(drm_fd));
-	} else {
-		igt_assert(lpsp_is_enabled(drm_fd));
+static bool unload_snd_hda_core_module(void)
+{
+	int i;
+
+	/* unbind snd_hda_intel */
+	kick_snd_hda_intel();
+
+	for (i = 0; snd_module[i]; i++) {
+		if (igt_kmod_is_loaded(snd_module[i]) &&
+		    igt_kmod_unload(snd_module[i], KMOD_REMOVE_FORCE)) {
+			igt_warn("Could not unload %s\n", snd_module[i]);
+			igt_kmod_list_loaded();
+			igt_lsof("/dev/snd");
+			return false;
+		}
 	}
+
+	return true;
 }
 
-static void non_edp_subtest(int drm_fd, drmModeResPtr drm_res,
-			    drmModeConnectorPtr *drm_connectors)
+static void load_snd_hda_core_module(void)
 {
-	int i, rc;
-	uint32_t crtc_id = 0, buffer_id = 0;
-	drmModeConnectorPtr connector = NULL;
-	drmModeModeInfoPtr mode = NULL;
+	igt_kmod_load("snd_hda_core", NULL);
+}

tests/i915/i915_pm_lpsp.c static void edp_subtest(int drm_fd, drmModeResPtr drm_res, · line 238

Quoted 10 lines
tests/i915/i915_pm_lpsp.c +8 -1
+
+static void non_edp_subtest(data_t *data)
+{
+	igt_display_t *display = &data->display;
+	igt_output_t *output;
+	int valid_output;
 
-	kmstest_unset_all_crtcs(drm_fd, drm_res);
+	/* DP/HDMI panel requires to drive lpsp without audio */
+	igt_require(unload_snd_hda_core_module());

I'm not super happy with having to unload modules that it would be very easy to forget to re-add and would make audio tests fail :s

Quoted 3 lines

IMO, if the DUT is not playing sound, we should be able to enter LPSP. If no, then I would consider this a driver bug for wasting energy sending 0s to the screen.

i915 contorls AUDIO power domain on request of i915_audio_component_ops get_power/put_power, which is an external dependency.
Despite unloading the module, it fails to enter lpsp for HDMI panels, audio driver didn't invoke the put_power to release the i915 power resources. It seems bug with audio driver interface.
My plan was to raise a gitlab bug based upon lpsp failure due to AUDIO_POWER_DOMAIN non-zero ref count despite there was no audio module.

Quoted 2 lines

Thoughts on this?

I agree with you, if there is no audio is being played from DP/hdmi we should be able to enter lpsp, but it seems audio codec requires power at the time of codec probe itself.
@Kai Vehmanen may be the best one to confirm hdmi-codec behavior?

IMO this should not block our igt validation, therefore i think in order to validate i915 lpsp use cases it would be a better approach to unload the snd module. These igt are pending since time of haswell/broadwell. Please suggest how to proceed this?
Thanks,
Anshuman Gupta.

Quoted 124 lines

Martin

Quoted 121 lines
tests/i915/i915_pm_lpsp.c +39 -57
-	for (i = 0; i < drm_res->count_connectors; i++) {
-		drmModeConnectorPtr c = drm_connectors[i];
+	for_each_connected_output(display, output) {
+		drmModeConnectorPtr c = output->config.connector;
 
 		if (c->connector_type == DRM_MODE_CONNECTOR_eDP)
 			continue;
 		if (c->connection != DRM_MODE_CONNECTED)
 			continue;
+		if (!igt_pipe_connector_valid(PIPE_A, output))
+			continue;
 
-		if (c->count_modes) {
-			connector = c;
-			mode = &c->modes[0];
-			break;
-		}
+		data->output = output;
+		data->mode = igt_output_get_mode(output);
+		setup_lpsp_output(data);
+		check_output_lpsp(data);
+		cleanup_lpsp_output(data);
+		load_snd_hda_core_module();
+		valid_output++;
 	}
-	igt_require(connector);
-
-	crtc_id = kmstest_find_crtc_for_connector(drm_fd, drm_res, connector,
-						  0);
-	buffer_id = create_fb(drm_fd, mode->hdisplay, mode->vdisplay);
 
-	igt_assert(buffer_id);
-	igt_assert(mode);
-
-	rc = drmModeSetCrtc(drm_fd, crtc_id, buffer_id, 0, 0,
-			    &connector->connector_id, 1, mode);
-	igt_assert_eq(rc, 0);
-
-	igt_assert(!lpsp_is_enabled(drm_fd));
+	igt_require_f(valid_output, "No non-edp connector found\n");
 }
 
-#define MAX_CONNECTORS 32
-
-int drm_fd;
-uint32_t devid;
-drmModeResPtr drm_res;
-drmModeConnectorPtr drm_connectors[MAX_CONNECTORS];
-struct intel_mmio_data mmio_data;
+IGT_TEST_DESCRIPTION("These tests validates display Low Power Single Pipe configurations");
 igt_main
 {
-	igt_fixture {
-		int i;
-
-		drm_fd = drm_open_driver_master(DRIVER_INTEL);
-		igt_require(drm_fd >= 0);
-
-		devid = intel_get_drm_devid(drm_fd);
+	data_t data = {};
 
-		drm_res = drmModeGetResources(drm_fd);
-		igt_require(drm_res);
-		igt_assert(drm_res->count_connectors <= MAX_CONNECTORS);
-
-		for (i = 0; i < drm_res->count_connectors; i++)
-			drm_connectors[i] = drmModeGetConnectorCurrent(drm_fd,
-							drm_res->connectors[i]);
+	igt_fixture {
 
+		data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
+		igt_require(data.drm_fd >= 0);
+		data.debugfs_fd = igt_debugfs_dir(data.drm_fd);
+		igt_require(data.debugfs_fd >= 0);
 		igt_pm_enable_audio_runtime_pm();
-
-		igt_require(supports_lpsp(devid));
-
-		intel_register_access_init(&mmio_data, intel_get_pci_device(), 0, drm_fd);
-
 		kmstest_set_vt_graphics_mode();
+		data.devid = intel_get_drm_devid(data.drm_fd);
+		igt_display_require(&data.display, data.drm_fd);
+		igt_require(igt_pm_dmc_loaded(data.debugfs_fd));
 	}
 
+	igt_describe("This test validates lpsp while all crtc are disabled");
 	igt_subtest("screens-disabled")
-		screens_disabled_subtest(drm_fd, drm_res);
+		screens_disabled_subtest(&data);
+	igt_describe("This test validates lpsp on eDP panel");
 	igt_subtest("edp-native")
-		edp_subtest(drm_fd, drm_res, drm_connectors, devid, false);
+		edp_subtest(&data, false);
+	igt_fixture
+		cleanup_lpsp_output(&data);
+	igt_describe("This test validates lpsp on eDP panel while forcing panel_fitter");
 	igt_subtest("edp-panel-fitter")
-		edp_subtest(drm_fd, drm_res, drm_connectors, devid, true);
+		edp_subtest(&data, true);
+	igt_fixture
+		cleanup_lpsp_output(&data);
+	igt_describe("This test validates lpsp on DP/HDMI/DSI panels");
 	igt_subtest("non-edp")
-		non_edp_subtest(drm_fd, drm_res, drm_connectors);
+		non_edp_subtest(&data);
+	igt_fixture
+		cleanup_lpsp_output(&data);
 
 	igt_fixture {
-		int i;
-
-		intel_register_access_fini(&mmio_data);
-		for (i = 0; i < drm_res->count_connectors; i++)
-			drmModeFreeConnector(drm_connectors[i]);
-		drmModeFreeResources(drm_res);
-		close(drm_fd);
+		free(data.pwr_dmn_info);
+		load_snd_hda_core_module();
+		close(data.drm_fd);
Quoted 8 lines

tests/i915/i915_pm_lpsp.c static void edp_subtest(int drm_fd, drmModeResPtr drm_res,

Quoted 4 lines
tests/i915/i915_pm_lpsp.c +1 -0
+		igt_display_fini(&data.display);
 	}
 }
 

pub 2048R/33A53379 2019-12-02 Martin Peres <[email protected]> sub 2048R/C5E7DE5F 2019-12-02 [expires: 2020-12-01]

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#7 lore raw

Re: [igt-dev] [PATCH i-g-t v2 2/5] tests/i915_pm_lpsp: lpsp platform agnostic support

Quoted 294 lines · Anshuman
Quoted 290 lines · Martin
Quoted 275 lines · Anshuman Gupta

Current implementation of lpsp igt test, assumed that every non-edp panel isn't a lpsp panel but it is not true on TGL anymore, any HDMI/DP/DSI panel connected on pipe A and connected to PORT_{A,B,C} can drive LPSP.
Even on older Gen9 platform a DP panel can drive lpsp on Port A. This requires complete design change in current lpsp igt for a platform agnostic support.

The new igt approach is relies on connector specific debugfs attribute i915_lpsp_info, which exposes whether an output is capable of driving lpsp and whether lpsp is enabled.

v2:
- CI failures fixup.

---
 tests/i915/i915_pm_lpsp.c | 303 +++++++++++++++++++++++---------------
 1 file changed, 186 insertions(+), 117 deletions(-)
tests/i915/i915_pm_lpsp.c +138 -59
index 42938e10..e400c92e 100644
@@ -25,49 +25,125 @@
  */
 
 #include "igt.h"
+#include "igt_kmod.h"
+#include "igt_pm.h"
+#include "igt_sysfs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
 
+#define MAX_SINK_LPSP_INFO_BUF_LEN	5000
 
-static bool supports_lpsp(uint32_t devid)
+#define PWR_DOMAIN_INFO "i915_power_domain_info"
+
+const char *snd_module[10] = {"snd_hda_codec_hdmi", "snd_hda_intel", "snd_hda_codec", "snd_hda_core", NULL};
+
+typedef struct {
+	int drm_fd;
+	int debugfs_fd;
+	uint32_t devid;
+	char *pwr_dmn_info;
+	igt_display_t display;
+	struct igt_fb fb;
+	drmModeModeInfo *mode;
+	igt_output_t *output;
+} data_t;
+
+static void debugfs_read(int fd, const char *param, char *buf, int len)
 {
-	return IS_HASWELL(devid) || IS_BROADWELL(devid);
+	len = igt_debugfs_simple_read(fd, param, buf, len);
+	if (len < 0)
+		igt_assert_eq(len, -ENODEV);
 }
 
-static bool lpsp_is_enabled(int drm_fd)
+static bool lpsp_is_enabled(data_t *data)
 {
-	uint32_t val;
+	char buf[MAX_SINK_LPSP_INFO_BUF_LEN];
+	int fd;
+
+	fd = igt_debugfs_connector_dir(data->drm_fd, data->output->name,
+				       O_RDONLY);
+	igt_require(fd >= 0);
+
+	debugfs_read(fd, "i915_lpsp_info", buf, sizeof(buf));
+	close(fd);
 
-	val = INREG(HSW_PWR_WELL_CTL2);
-	return !(val & HSW_PWR_WELL_STATE_ENABLED);
+	return strstr(buf, "LPSP enabled");
 }
 
-/* The LPSP mode is all about an enabled pipe, but we expect to also be in the
- * low power mode when no pipes are enabled, so do this check anyway. */
-static void screens_disabled_subtest(int drm_fd, drmModeResPtr drm_res)
+/*
+ * The LPSP mode is all about an enabled pipe, but we expect to also be in the
+ * low power mode when no pipes are enabled, so do this check anyway.
+ */
+static void screens_disabled_subtest(data_t *data)
 {
-	kmstest_unset_all_crtcs(drm_fd, drm_res);
-	igt_assert(lpsp_is_enabled(drm_fd));
+	igt_output_t *output;
+	enum pipe pipe;
+	igt_plane_t *primary;
+
+	for_each_pipe_with_single_output(&data->display, pipe, output) {
+		data->output = output;
+		igt_output_set_pipe(data->output, pipe);
+		primary = igt_output_get_plane_type(data->output,
+						    DRM_PLANE_TYPE_PRIMARY);
+		igt_plane_set_fb(primary, NULL);
+		igt_display_commit(&data->display);
+	}
+
+	igt_assert(lpsp_is_enabled(data));
 }
 
-static uint32_t create_fb(int drm_fd, int width, int height)
+static void check_output_lpsp(data_t *data)
 {
-	struct igt_fb fb;
+	if (igt_output_is_lpsp_capable(data->drm_fd, data->output))
+		igt_assert_f(lpsp_is_enabled(data), "%s: lpsp is not enabled\n%s:\n%s\n",
+			     data->output->name, PWR_DOMAIN_INFO, data->pwr_dmn_info =
+			     igt_sysfs_get(data->debugfs_fd, PWR_DOMAIN_INFO));
+	else
+		igt_assert(!lpsp_is_enabled(data));
+}
 
-	return igt_create_pattern_fb(drm_fd, width, height, DRM_FORMAT_XRGB8888,
-				     LOCAL_DRM_FORMAT_MOD_NONE, &fb);
+static void setup_lpsp_output(data_t *data)
+{
+	igt_plane_t *primary;
+
+	/* set output pipe = PIPE_A for LPSP */
+	igt_output_set_pipe(data->output, PIPE_A);
+	primary = igt_output_get_plane_type(data->output,
+					    DRM_PLANE_TYPE_PRIMARY);
+	igt_plane_set_fb(primary, NULL);
+	igt_create_pattern_fb(data->drm_fd,
+			      data->mode->hdisplay, data->mode->vdisplay,
+			      DRM_FORMAT_XRGB8888,
+			      LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->fb);
+	igt_plane_set_fb(primary, &data->fb);
+	igt_display_commit(&data->display);
+}
+
+static void cleanup_lpsp_output(data_t *data)
+{
+	igt_plane_t *primary;
+
+	if (!data->output)
+		return;
+
+	primary = igt_output_get_plane_type(data->output,
+					    DRM_PLANE_TYPE_PRIMARY);
+	igt_plane_set_fb(primary, NULL);
+	igt_output_set_pipe(data->output, PIPE_NONE);
+	igt_display_commit(&data->display);
+	igt_remove_fb(data->drm_fd, &data->fb);
+	data->output = NULL;
 }
 
-static void edp_subtest(int drm_fd, drmModeResPtr drm_res,
-			drmModeConnectorPtr *drm_connectors, uint32_t devid,
-			bool use_panel_fitter)
+static void edp_subtest(data_t *data, bool use_panel_fitter)
 {
-	int i, rc;
-	uint32_t crtc_id = 0, buffer_id = 0;
-	drmModeConnectorPtr connector = NULL;
-	drmModeModeInfoPtr mode = NULL;
+	igt_display_t *display = &data->display;
+	igt_output_t *output;
+	int valid_output;
+
 	drmModeModeInfo std_1024_mode = {
 		.clock = 65000,
 		.hdisplay = 1024,
@@ -86,23 +162,17 @@ static void edp_subtest(int drm_fd, drmModeResPtr drm_res,
 		.name = "Custom 1024x768",
 	};
 
-	kmstest_unset_all_crtcs(drm_fd, drm_res);
-
-	for (i = 0; i < drm_res->count_connectors; i++) {
-		drmModeConnectorPtr c = drm_connectors[i];
+	for_each_connected_output(display, output) {
+		drmModeConnectorPtr c = output->config.connector;
 
 		if (c->connector_type != DRM_MODE_CONNECTOR_eDP)
 			continue;
-		if (c->connection != DRM_MODE_CONNECTED)
+		if (!igt_pipe_connector_valid(PIPE_A, output))
 			continue;
 
-		if (!use_panel_fitter && c->count_modes) {
-			connector = c;
-			mode = &c->modes[0];
-			break;
-		}
+		data->output = output;
+
 		if (use_panel_fitter) {
-			connector = c;
 
 			/* This is one of the modes Xorg creates for panels, so
 			 * it should work just fine. Notice that Gens that
@@ -113,124 +183,123 @@ static void edp_subtest(int drm_fd, drmModeResPtr drm_res,
 				   c->modes[0].hdisplay > 1024);
 			igt_assert(c->count_modes &&
 				   c->modes[0].vdisplay > 768);
-			mode = &std_1024_mode;
-			break;
+			data->mode = &std_1024_mode;
+			igt_output_override_mode(output, data->mode);
+		} else {
+			data->mode = igt_output_get_mode(output);
 		}
-	}
-	igt_require(connector);
 
-	crtc_id = kmstest_find_crtc_for_connector(drm_fd, drm_res, connector,
-						  0);
-	buffer_id = create_fb(drm_fd, mode->hdisplay, mode->vdisplay);
+		setup_lpsp_output(data);
+
+		if (use_panel_fitter && IS_HASWELL(data->devid))
+			igt_assert(!lpsp_is_enabled(data));
+		else
+			check_output_lpsp(data);
 
-	igt_assert(buffer_id);
-	igt_assert(connector);
-	igt_assert(mode);
+		cleanup_lpsp_output(data);
+		valid_output++;
+	}
 
-	rc = drmModeSetCrtc(drm_fd, crtc_id, buffer_id, 0, 0,
-			    &connector->connector_id, 1, mode);
-	igt_assert_eq(rc, 0);
+	igt_require_f(valid_output, "No edp connector found\n");
+}
 
-	if (use_panel_fitter) {
-		if (IS_HASWELL(devid))
-			igt_assert(!lpsp_is_enabled(drm_fd));
-		else
-			igt_assert(lpsp_is_enabled(drm_fd));
-	} else {
-		igt_assert(lpsp_is_enabled(drm_fd));
+static bool unload_snd_hda_core_module(void)
+{
+	int i;
+
+	/* unbind snd_hda_intel */
+	kick_snd_hda_intel();
+
+	for (i = 0; snd_module[i]; i++) {
+		if (igt_kmod_is_loaded(snd_module[i]) &&
+		    igt_kmod_unload(snd_module[i], KMOD_REMOVE_FORCE)) {
+			igt_warn("Could not unload %s\n", snd_module[i]);
+			igt_kmod_list_loaded();
+			igt_lsof("/dev/snd");
+			return false;
+		}
 	}
+
+	return true;
 }
 
-static void non_edp_subtest(int drm_fd, drmModeResPtr drm_res,
-			    drmModeConnectorPtr *drm_connectors)
+static void load_snd_hda_core_module(void)
 {
-	int i, rc;
-	uint32_t crtc_id = 0, buffer_id = 0;
-	drmModeConnectorPtr connector = NULL;
-	drmModeModeInfoPtr mode = NULL;
+	igt_kmod_load("snd_hda_core", NULL);
+}

tests/i915/i915_pm_lpsp.c static void edp_subtest(int drm_fd, drmModeResPtr drm_res, · line 238

Quoted 10 lines
tests/i915/i915_pm_lpsp.c +8 -1
+
+static void non_edp_subtest(data_t *data)
+{
+	igt_display_t *display = &data->display;
+	igt_output_t *output;
+	int valid_output;
 
-	kmstest_unset_all_crtcs(drm_fd, drm_res);
+	/* DP/HDMI panel requires to drive lpsp without audio */
+	igt_require(unload_snd_hda_core_module());

I'm not super happy with having to unload modules that it would be very easy to forget to re-add and would make audio tests fail :s

Quoted 3 lines

IMO, if the DUT is not playing sound, we should be able to enter LPSP. If no, then I would consider this a driver bug for wasting energy sending 0s to the screen.

Quoted 8 lines

i915 contorls AUDIO power domain on request of i915_audio_component_ops get_power/put_power, which is an external dependency.
Despite unloading the module, it fails to enter lpsp for HDMI panels, audio driver didn't invoke the put_power to release the i915 power resources. It seems bug with audio driver interface.
My plan was to raise a gitlab bug based upon lpsp failure due to AUDIO_POWER_DOMAIN non-zero ref count despite there was no audio module.

Yet another reason not to remove the modules then ;)

Quoted 7 lines
Quoted 2 lines

Thoughts on this?

I agree with you, if there is no audio is being played from DP/hdmi we should be able to enter lpsp, but it seems audio codec requires power at the time of codec probe itself.
@Kai Vehmanen may be the best one to confirm hdmi-codec behavior?

Quoted 5 lines

IMO this should not block our igt validation, therefore i think in order to validate i915 lpsp use cases it would be a better approach to unload the snd module. These igt are pending since time of haswell/broadwell. Please suggest how to proceed this?

I agree that this series is a step forward, and I want to see this series merged sooner rather than later. What I don't want to see is painting the grass green by working around actual bugs. I suggest you stop unloading the modules and let the tests fail until the kernel gets fixed. It should be easy to do and we can merge the series.

As for validation, painting the grass green by working around real issues is not acceptable. You can say in the bug we will file that the cause is related to the audio codec, but working around it in the test should be a no-no. We want normal users to be able to reach LPSP, not just the ones who force-disable audio at boot. So, our IGT tests should reflect the normal case :)

Martin

Quoted 136 lines

Thanks,
Anshuman Gupta.

Quoted 132 lines

Martin

Quoted 115 lines
tests/i915/i915_pm_lpsp.c +36 -54
-	for (i = 0; i < drm_res->count_connectors; i++) {
-		drmModeConnectorPtr c = drm_connectors[i];
+	for_each_connected_output(display, output) {
+		drmModeConnectorPtr c = output->config.connector;
 
 		if (c->connector_type == DRM_MODE_CONNECTOR_eDP)
 			continue;
 		if (c->connection != DRM_MODE_CONNECTED)
 			continue;
+		if (!igt_pipe_connector_valid(PIPE_A, output))
+			continue;
 
-		if (c->count_modes) {
-			connector = c;
-			mode = &c->modes[0];
-			break;
-		}
+		data->output = output;
+		data->mode = igt_output_get_mode(output);
+		setup_lpsp_output(data);
+		check_output_lpsp(data);
+		cleanup_lpsp_output(data);
+		load_snd_hda_core_module();
+		valid_output++;
 	}
-	igt_require(connector);
-
-	crtc_id = kmstest_find_crtc_for_connector(drm_fd, drm_res, connector,
-						  0);
-	buffer_id = create_fb(drm_fd, mode->hdisplay, mode->vdisplay);
 
-	igt_assert(buffer_id);
-	igt_assert(mode);
-
-	rc = drmModeSetCrtc(drm_fd, crtc_id, buffer_id, 0, 0,
-			    &connector->connector_id, 1, mode);
-	igt_assert_eq(rc, 0);
-
-	igt_assert(!lpsp_is_enabled(drm_fd));
+	igt_require_f(valid_output, "No non-edp connector found\n");
 }
 
-#define MAX_CONNECTORS 32
-
-int drm_fd;
-uint32_t devid;
-drmModeResPtr drm_res;
-drmModeConnectorPtr drm_connectors[MAX_CONNECTORS];
-struct intel_mmio_data mmio_data;
+IGT_TEST_DESCRIPTION("These tests validates display Low Power Single Pipe configurations");
 igt_main
 {
-	igt_fixture {
-		int i;
-
-		drm_fd = drm_open_driver_master(DRIVER_INTEL);
-		igt_require(drm_fd >= 0);
-
-		devid = intel_get_drm_devid(drm_fd);
+	data_t data = {};
 
-		drm_res = drmModeGetResources(drm_fd);
-		igt_require(drm_res);
-		igt_assert(drm_res->count_connectors <= MAX_CONNECTORS);
-
-		for (i = 0; i < drm_res->count_connectors; i++)
-			drm_connectors[i] = drmModeGetConnectorCurrent(drm_fd,
-							drm_res->connectors[i]);
+	igt_fixture {
 
+		data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
+		igt_require(data.drm_fd >= 0);
+		data.debugfs_fd = igt_debugfs_dir(data.drm_fd);
+		igt_require(data.debugfs_fd >= 0);
 		igt_pm_enable_audio_runtime_pm();
-
-		igt_require(supports_lpsp(devid));
-
-		intel_register_access_init(&mmio_data, intel_get_pci_device(), 0, drm_fd);
-
 		kmstest_set_vt_graphics_mode();
+		data.devid = intel_get_drm_devid(data.drm_fd);
+		igt_display_require(&data.display, data.drm_fd);
+		igt_require(igt_pm_dmc_loaded(data.debugfs_fd));
 	}
 
+	igt_describe("This test validates lpsp while all crtc are disabled");
 	igt_subtest("screens-disabled")
-		screens_disabled_subtest(drm_fd, drm_res);
+		screens_disabled_subtest(&data);
+	igt_describe("This test validates lpsp on eDP panel");
 	igt_subtest("edp-native")
-		edp_subtest(drm_fd, drm_res, drm_connectors, devid, false);
+		edp_subtest(&data, false);
+	igt_fixture
+		cleanup_lpsp_output(&data);
+	igt_describe("This test validates lpsp on eDP panel while forcing panel_fitter");
 	igt_subtest("edp-panel-fitter")
-		edp_subtest(drm_fd, drm_res, drm_connectors, devid, true);
+		edp_subtest(&data, true);
+	igt_fixture
+		cleanup_lpsp_output(&data);
+	igt_describe("This test validates lpsp on DP/HDMI/DSI panels");
 	igt_subtest("non-edp")
-		non_edp_subtest(drm_fd, drm_res, drm_connectors);
+		non_edp_subtest(&data);
+	igt_fixture
+		cleanup_lpsp_output(&data);
 
 	igt_fixture {
-		int i;
-
-		intel_register_access_fini(&mmio_data);
-		for (i = 0; i < drm_res->count_connectors; i++)

tests/i915/i915_pm_lpsp.c static void edp_subtest(int drm_fd, drmModeResPtr drm_res,

Quoted 10 lines
tests/i915/i915_pm_lpsp.c +4 -3
-			drmModeFreeConnector(drm_connectors[i]);
-		drmModeFreeResources(drm_res);
-		close(drm_fd);
+		free(data.pwr_dmn_info);
+		load_snd_hda_core_module();
+		close(data.drm_fd);
+		igt_display_fini(&data.display);
 	}
 }
 

pub 2048R/33A53379 2019-12-02 Martin Peres <[email protected]> sub 2048R/C5E7DE5F 2019-12-02 [expires: 2020-12-01]

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#8 lore raw

Re: [igt-dev] [PATCH i-g-t v2 2/5] tests/i915_pm_lpsp: lpsp platform agnostic support

In reply to Anshuman Gupta

Hey,

Quoted 7 lines · Anshuman Gupta
Quoted 6 lines · Martin

tests/i915/i915_pm_lpsp.c static void edp_subtest(int drm_fd, drmModeResPtr drm_res, · line 238

Quoted 2 lines · Anshuman Gupta
tests/i915/i915_pm_lpsp.c +2 -0
+	/* DP/HDMI panel requires to drive lpsp without audio */
+	igt_require(unload_snd_hda_core_module());

I'm not super happy with having to unload modules that it would be very easy to forget to re-add and would make audio tests fail :s

at least this may be painful to maintain. We have three audio drivers in active use (HDA snd-hda-intel, SST DSP and SOF DSP -> drivers is selected at runtime dependsing on hw generation, enabled features and the available DSP FW), and the modules you need to unload are different for all three, and may change over time. So not so nice to maintain if you need to support a large variety of hardware targets.

Quoted 8 lines
Quoted 3 lines

IMO, if the DUT is not playing sound, we should be able to enter LPSP. If no, then I would consider this a driver bug for wasting energy sending 0s to the screen.

i915 contorls AUDIO power domain on request of i915_audio_component_ops get_power/put_power, which is an external dependency.
Despite unloading the module, it fails to enter lpsp for HDMI panels, audio driver didn't invoke the put_power to release the i915 power resources. It seems bug with audio driver interface.

Yes, this sounds like a plain bug. Audio should never keep powers on unless it needs it for some actual use-case.

Quoted 9 lines

My plan was to raise a gitlab bug based upon lpsp failure due to AUDIO_POWER_DOMAIN non-zero ref count despite there was no audio module.

Quoted 2 lines

Thoughts on this?

I agree with you, if there is no audio is being played from DP/hdmi we should be able to enter lpsp, but it seems audio codec requires power at the time of codec probe itself.
@Kai Vehmanen may be the best one to confirm hdmi-codec behavior?

Yes, audio codec asks for i915 power when it is probed, and also whenever it uses the HDA bus. But when it is idle, it will release i915 power via put_power. One possible problem could be that the audio driver is uilt without runtime pm support. Then it will indeed keep a ref to i915 power all the time. Can you provide a bit of data about the case (which hardware, kernel config used, possible dmesg log of error)?

Br, Kai (Sound Open Firmware (SOF) team)
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#9 lore raw

Re: [igt-dev] [PATCH i-g-t v2 2/5] tests/i915_pm_lpsp: lpsp platform agnostic support

Quoted 22 lines · Kai Vehmanen

Hey,

Quoted 7 lines · Anshuman Gupta
Quoted 6 lines · Martin

tests/i915/i915_pm_lpsp.c static void edp_subtest(int drm_fd, drmModeResPtr drm_res, · line 238

Quoted 2 lines · Anshuman Gupta
tests/i915/i915_pm_lpsp.c +2 -0
+	/* DP/HDMI panel requires to drive lpsp without audio */
+	igt_require(unload_snd_hda_core_module());

I'm not super happy with having to unload modules that it would be very easy to forget to re-add and would make audio tests fail :s

at least this may be painful to maintain. We have three audio drivers in active use (HDA snd-hda-intel, SST DSP and SOF DSP -> drivers is selected at runtime dependsing on hw generation, enabled features and the available DSP FW), and the modules you need to unload are different for all three, and may change over time. So not so nice to maintain if you need to support a large variety of hardware targets.

Quoted 3 lines
Quoted 3 lines

IMO, if the DUT is not playing sound, we should be able to enter LPSP. If no, then I would consider this a driver bug for wasting energy sending 0s to the screen.

Quoted 8 lines
Quoted 5 lines

i915 contorls AUDIO power domain on request of i915_audio_component_ops get_power/put_power, which is an external dependency.
Despite unloading the module, it fails to enter lpsp for HDMI panels, audio driver didn't invoke the put_power to release the i915 power resources. It seems bug with audio driver interface.

Yes, this sounds like a plain bug. Audio should never keep powers on unless it needs it for some actual use-case.

Thanks kai for your comment based upon your comment, i investigated it and found, while enabling crtc i915 also gets ref count for AUDIO_POWER_DOMAIN if there is valid ELD.
This was failing the test.
Thanks,
Anshuman Gupta.

Quoted 11 lines
Quoted 10 lines

My plan was to raise a gitlab bug based upon lpsp failure due to AUDIO_POWER_DOMAIN non-zero ref count despite there was no audio module.

Quoted 2 lines

Thoughts on this?

I agree with you, if there is no audio is being played from DP/hdmi we should be able to enter lpsp, but it seems audio codec requires power at the time of codec probe itself.
@Kai Vehmanen may be the best one to confirm hdmi-codec behavior?

Quoted 8 lines

Yes, audio codec asks for i915 power when it is probed, and also whenever it uses the HDA bus. But when it is idle, it will release i915 power via put_power. One possible problem could be that the audio driver is uilt without runtime pm support. Then it will indeed keep a ref to i915 power all the time. Can you provide a bit of data about the case (which hardware, kernel config used, possible dmesg log of error)?

Br, Kai (Sound Open Firmware (SOF) team)

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#10 lore raw

PATCH v2 3/5 tests/i915_pm_lpsp: Skip panel-fitter subtest for 1024x768 panels

In reply to Anshuman Gupta

It makes sense to skip the test if edp-panel native resoultion is limted to 1024x768 rather than failing the test.

---
 tests/i915/i915_pm_lpsp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tests/i915/i915_pm_lpsp.c +4 -4
index e400c92e..0ce694e6 100644
@@ -179,10 +179,10 @@ static void edp_subtest(data_t *data, bool use_panel_fitter)
 			 * support LPSP are too new for panels with native
 			 * 1024x768 resolution, so this should force the panel
 			 * fitter. */
-			igt_assert(c->count_modes &&
-				   c->modes[0].hdisplay > 1024);
-			igt_assert(c->count_modes &&
-				   c->modes[0].vdisplay > 768);
+			igt_require(c->count_modes &&
+				    c->modes[0].hdisplay > 1024);
+			igt_require(c->count_modes &&
+				    c->modes[0].vdisplay > 768);
 			data->mode = &std_1024_mode;
 			igt_output_override_mode(output, data->mode);
 		} else {
Signature · 6 lines
2.25.2

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Acked-by Martin Peres on v2 3/5
#11 lore raw

Re: [igt-dev] [PATCH i-g-t v2 3/5] tests/i915_pm_lpsp: Skip panel-fitter subtest for 1024x768 panels

Quoted 2 lines · Anshuman Gupta

It makes sense to skip the test if edp-panel native resoultion is limted to 1024x768 rather than failing the test.

Quoted 16 lines
---
 tests/i915/i915_pm_lpsp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tests/i915/i915_pm_lpsp.c +0 -1
index e400c92e..0ce694e6 100644
@@ -179,10 +179,10 @@ static void edp_subtest(data_t *data, bool use_panel_fitter)
 			 * support LPSP are too new for panels with native
 			 * 1024x768 resolution, so this should force the panel
 			 * fitter. */
-			igt_assert(c->count_modes &&

tests/i915/i915_pm_lpsp.c static void edp_subtest(data_t *data, bool use_panel_fitter) · line 188

Quoted 10 lines
tests/i915/i915_pm_lpsp.c +4 -3
-				   c->modes[0].hdisplay > 1024);
-			igt_assert(c->count_modes &&
-				   c->modes[0].vdisplay > 768);
+			igt_require(c->count_modes &&
+				    c->modes[0].hdisplay > 1024);
+			igt_require(c->count_modes &&
+				    c->modes[0].vdisplay > 768);
 			data->mode = &std_1024_mode;
 			igt_output_override_mode(output, data->mode);
 		} else {

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#12 lore raw

PATCH v2 4/5 tests/i915_pm_lpsp: screens-disabled subtest use igt_wait

In reply to Anshuman Gupta

Some times delayed audio codec disabling causes failure of test, using igt_wait to check lpsp after disabling all outputs.

---
 tests/i915/i915_pm_lpsp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/i915/i915_pm_lpsp.c +1 -1
index 0ce694e6..5f15c034 100644
@@ -91,7 +91,7 @@ static void screens_disabled_subtest(data_t *data)
 		igt_display_commit(&data->display);
 	}
 
-	igt_assert(lpsp_is_enabled(data));
+	igt_assert(igt_wait(lpsp_is_enabled(data), 1000, 100));
 }
 
 static void check_output_lpsp(data_t *data)
Signature · 6 lines
2.25.2

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#13 lore raw

Re: [igt-dev] [PATCH i-g-t v2 4/5] tests/i915_pm_lpsp: screens-disabled subtest use igt_wait

Quoted 2 lines · Anshuman Gupta

Some times delayed audio codec disabling causes failure of test, using igt_wait to check lpsp after disabling all outputs.

Seems like this answers my question on patch 2/5: We are sending audio to the screen even when we do not have anything to send...

I know there are some screens that take ages to re-enable sound after not getting any for a while, but waiting 10 or even 30s without sound before disabling it does not sound like a terrible idea. My TV automatically disables sound after way less than that anyway.

So, to me, this is a driver bug.

That being said, the patch is fine even if your reason for it is not acceptable.

Martin

Quoted 12 lines
---
 tests/i915/i915_pm_lpsp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/i915/i915_pm_lpsp.c +0 -0
index 0ce694e6..5f15c034 100644

tests/i915/i915_pm_lpsp.c static void screens_disabled_subtest(data_t *data) · line 97

Quoted 8 lines
tests/i915/i915_pm_lpsp.c +1 -1
@@ -91,7 +91,7 @@ static void screens_disabled_subtest(data_t *data)
 		igt_display_commit(&data->display);
 	}
 
-	igt_assert(lpsp_is_enabled(data));
+	igt_assert(igt_wait(lpsp_is_enabled(data), 1000, 100));
 }
 
 static void check_output_lpsp(data_t *data)

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#14 lore raw

Re: [igt-dev] [PATCH i-g-t v2 4/5] tests/i915_pm_lpsp: screens-disabled subtest use igt_wait

Quoted 12 lines · Martin
Quoted 2 lines · Anshuman Gupta

Some times delayed audio codec disabling causes failure of test, using igt_wait to check lpsp after disabling all outputs.

Seems like this answers my question on patch 2/5: We are sending audio to the screen even when we do not have anything to send...

I know there are some screens that take ages to re-enable sound after not getting any for a while, but waiting 10 or even 30s without sound before disabling it does not sound like a terrible idea. My TV automatically disables sound after way less than that anyway.

Quoted 4 lines

So, to me, this is a driver bug.

That being said, the patch is fine even if your reason for it is not acceptable.

Thanks Martin for comment, i will drop this patch, remove the unloading of sound moudles from 2/5 patch, and will send an update. Thanks,
Anshuman Gupta,

Quoted 20 lines

Martin

Quoted 18 lines
---
 tests/i915/i915_pm_lpsp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/i915/i915_pm_lpsp.c +1 -1
index 0ce694e6..5f15c034 100644
@@ -91,7 +91,7 @@ static void screens_disabled_subtest(data_t *data)
 		igt_display_commit(&data->display);
 	}
 
-	igt_assert(lpsp_is_enabled(data));
+	igt_assert(igt_wait(lpsp_is_enabled(data), 1000, 100));
 }
 
Quoted 6 lines

tests/i915/i915_pm_lpsp.c static void screens_disabled_subtest(data_t *data) · line 97

Quoted 2 lines
tests/i915/i915_pm_lpsp.c +0 -0
 static void check_output_lpsp(data_t *data)

pub 2048R/33A53379 2019-12-02 Martin Peres <[email protected]> sub 2048R/C5E7DE5F 2019-12-02 [expires: 2020-12-01]

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#15 lore raw

PATCH v2 5/5 tests/i915_pm_rpm: lpsp/non-lpsp screen mode_set_data

In reply to Anshuman Gupta

Initialize the mode set params for lpsp/non-lpsp screen based upon their output lpsp capability instead of edp/non-edp output type.

v2:
- CI failures fixup.

---
 tests/i915/i915_pm_rpm.c | 53 +++++++++++++++++++++++-----------------
 1 file changed, 30 insertions(+), 23 deletions(-)
tests/i915/i915_pm_rpm.c +30 -23
index 4f8124dc..e2fb732c 100644
@@ -94,6 +94,7 @@ struct mode_set_data {
 	drmModeResPtr res;
 	drmModeConnectorPtr connectors[MAX_CONNECTORS];
 	drmModePropertyBlobPtr edids[MAX_CONNECTORS];
+	igt_display_t display;
 
 	uint32_t devid;
 };
@@ -254,29 +255,29 @@ static bool init_modeset_params_for_type(struct mode_set_data *data,
 {
 	drmModeConnectorPtr connector = NULL;
 	drmModeModeInfoPtr mode = NULL;
+	igt_output_t *output = NULL;
+	igt_display_t *display = &data->display;
 
-	if (!data->res)
+	if (!data->res || !display)
 		return false;
 
-	for (int i = 0; i < data->res->count_connectors; i++) {
-		drmModeConnectorPtr c = data->connectors[i];
+	for_each_connected_output(display, output) {
+		drmModeConnectorPtr c = output->config.connector;
 
 		if (type == SCREEN_TYPE_LPSP &&
-		    c->connector_type != DRM_MODE_CONNECTOR_eDP)
+		     !igt_output_is_lpsp_capable(drm_fd, output))
 			continue;
 
 		if (type == SCREEN_TYPE_NON_LPSP &&
-		    c->connector_type == DRM_MODE_CONNECTOR_eDP)
+		    igt_output_is_lpsp_capable(drm_fd, output))
 			continue;
 
-		if (c->connection == DRM_MODE_CONNECTED && c->count_modes) {
-			connector = c;
-			mode = &c->modes[0];
-			break;
-		}
+		connector = c;
+		mode = igt_output_get_mode(output);
+		break;
 	}
 
-	if (!connector)
+	if (!connector || !mode)
 		return false;
 
 	igt_create_pattern_fb(drm_fd, mode->hdisplay, mode->vdisplay,
@@ -397,6 +398,7 @@ static void init_mode_set_data(struct mode_set_data *data)
 		kmstest_set_vt_graphics_mode();
 	}
 
+	igt_display_require(&data->display, drm_fd);
 	data->devid = intel_get_drm_devid(drm_fd);
 	init_modeset_cached_params(&ms_data);
 }
@@ -410,6 +412,8 @@ static void fini_mode_set_data(struct mode_set_data *data)
 		}
 		drmModeFreeResources(data->res);
 	}
+
+	igt_display_fini(&data->display);
 }
 
 static void get_drm_info(struct compare_data *data)
@@ -760,7 +764,7 @@ static void dump_file(int dir, const char *filename)
 	free(contents);
 }
 
-static bool setup_environment(void)
+static bool setup_environment(bool display_disabled)
 {
 	if (has_runtime_pm)
 		goto out;
@@ -772,7 +776,8 @@ static bool setup_environment(void)
 	debugfs = igt_debugfs_dir(drm_fd);
 	igt_require(debugfs != -1);
 
-	init_mode_set_data(&ms_data);
+	if (!display_disabled)
+		init_mode_set_data(&ms_data);
 
 	igt_pm_enable_sata_link_power_management();
 
@@ -785,13 +790,14 @@ static bool setup_environment(void)
 	igt_require(igt_pm_dmc_loaded(debugfs));
 
 out:
-	disable_all_screens(&ms_data);
+	if (!display_disabled)
+		disable_all_screens(&ms_data);
 	dump_file(debugfs, "i915_runtime_pm_status");
 
 	return wait_for_suspended();
 }
 
-static void teardown_environment(void)
+static void teardown_environment(bool display_disabled)
 {
 	close(msr_fd);
 	if (has_pc8)
@@ -801,7 +807,8 @@ static void teardown_environment(void)
 
 	igt_pm_restore_sata_link_power_management();
 
-	fini_mode_set_data(&ms_data);
+	if (!display_disabled)
+		fini_mode_set_data(&ms_data);
 
 	close(debugfs);
 	close(drm_fd);
@@ -2008,7 +2015,7 @@ static struct option long_options[] = {
 igt_main_args("", long_options, help_str, opt_handler, NULL)
 {
 	igt_subtest("basic-rte") {
-		igt_assert(setup_environment());
+		igt_assert(setup_environment(false));
 		basic_subtest();
 	}
 
@@ -2016,7 +2023,7 @@ igt_main_args("", long_options, help_str, opt_handler, NULL)
 	 * PC8+. We don't want bug reports from cases where the machine is just
 	 * not properly configured. */
 	igt_fixture
-		igt_require(setup_environment());
+		igt_require(setup_environment(false));
 
 	if (stay)
 		igt_subtest("stay")
@@ -2146,7 +2153,7 @@ igt_main_args("", long_options, help_str, opt_handler, NULL)
 	}
 
 	igt_fixture
-		teardown_environment();
+		teardown_environment(false);
 
 	igt_subtest("module-reload") {
 		igt_debug("Reload w/o display\n");
@@ -2155,9 +2162,9 @@ igt_main_args("", long_options, help_str, opt_handler, NULL)
 		igt_kmsg(KMSG_INFO "Reloading i915 w/o display\n");
 		igt_assert_eq(igt_i915_driver_load("disable_display=1 mmio_debug=-1"), 0);
 
-		igt_assert(setup_environment());
+		igt_assert(setup_environment(true));
 		igt_assert(igt_wait(device_in_pci_d3(), 2000, 100));
-		teardown_environment();
+		teardown_environment(true);
 
 		igt_debug("Reload as normal\n");
 		igt_i915_driver_unload();
@@ -2165,11 +2172,11 @@ igt_main_args("", long_options, help_str, opt_handler, NULL)
 		igt_kmsg(KMSG_INFO "Reloading i915 as normal\n");
 		igt_assert_eq(igt_i915_driver_load("mmio_debug=-1"), 0);
 
-		igt_assert(setup_environment());
+		igt_assert(setup_environment(false));
 		igt_assert(igt_wait(device_in_pci_d3(), 2000, 100));
 		if (enable_one_screen_with_type(&ms_data, SCREEN_TYPE_ANY))
 			drm_resources_equal_subtest();
-		teardown_environment();
+		teardown_environment(false);
 
 		/* Remove our mmio_debugging module */
 		igt_i915_driver_unload();
Signature · 6 lines
2.25.2

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Acked-by Martin Peres on v2 5/5
#16 lore raw

Re: [igt-dev] [PATCH i-g-t v2 5/5] tests/i915_pm_rpm: lpsp/non-lpsp screen mode_set_data

Quoted 6 lines · Anshuman Gupta

Initialize the mode set params for lpsp/non-lpsp screen based upon their output lpsp capability instead of edp/non-edp output type.

v2:
- CI failures fixup.

This patch is:

Congrats on your series, Anshuman! My only gripe with it is letting the audio free-wheel even when we don't need it and could reach LPSP.

That being said, if you were to remove the sound drivers unloading, the series would be very close to a mergeable state. It's OK if the new tests fail, they can be fixed with a corresponding i915 patch series.

Thanks again!

Martin

Quoted 166 lines
---
 tests/i915/i915_pm_rpm.c | 53 +++++++++++++++++++++++-----------------
 1 file changed, 30 insertions(+), 23 deletions(-)
tests/i915/i915_pm_rpm.c +28 -21
index 4f8124dc..e2fb732c 100644
@@ -94,6 +94,7 @@ struct mode_set_data {
 	drmModeResPtr res;
 	drmModeConnectorPtr connectors[MAX_CONNECTORS];
 	drmModePropertyBlobPtr edids[MAX_CONNECTORS];
+	igt_display_t display;
 
 	uint32_t devid;
 };
@@ -254,29 +255,29 @@ static bool init_modeset_params_for_type(struct mode_set_data *data,
 {
 	drmModeConnectorPtr connector = NULL;
 	drmModeModeInfoPtr mode = NULL;
+	igt_output_t *output = NULL;
+	igt_display_t *display = &data->display;
 
-	if (!data->res)
+	if (!data->res || !display)
 		return false;
 
-	for (int i = 0; i < data->res->count_connectors; i++) {
-		drmModeConnectorPtr c = data->connectors[i];
+	for_each_connected_output(display, output) {
+		drmModeConnectorPtr c = output->config.connector;
 
 		if (type == SCREEN_TYPE_LPSP &&
-		    c->connector_type != DRM_MODE_CONNECTOR_eDP)
+		     !igt_output_is_lpsp_capable(drm_fd, output))
 			continue;
 
 		if (type == SCREEN_TYPE_NON_LPSP &&
-		    c->connector_type == DRM_MODE_CONNECTOR_eDP)
+		    igt_output_is_lpsp_capable(drm_fd, output))
 			continue;
 
-		if (c->connection == DRM_MODE_CONNECTED && c->count_modes) {
-			connector = c;
-			mode = &c->modes[0];
-			break;
-		}
+		connector = c;
+		mode = igt_output_get_mode(output);
+		break;
 	}
 
-	if (!connector)
+	if (!connector || !mode)
 		return false;
 
 	igt_create_pattern_fb(drm_fd, mode->hdisplay, mode->vdisplay,
@@ -397,6 +398,7 @@ static void init_mode_set_data(struct mode_set_data *data)
 		kmstest_set_vt_graphics_mode();
 	}
 
+	igt_display_require(&data->display, drm_fd);
 	data->devid = intel_get_drm_devid(drm_fd);
 	init_modeset_cached_params(&ms_data);
 }
@@ -410,6 +412,8 @@ static void fini_mode_set_data(struct mode_set_data *data)
 		}
 		drmModeFreeResources(data->res);
 	}
+
+	igt_display_fini(&data->display);
 }
 
 static void get_drm_info(struct compare_data *data)
@@ -760,7 +764,7 @@ static void dump_file(int dir, const char *filename)
 	free(contents);
 }
 
-static bool setup_environment(void)
+static bool setup_environment(bool display_disabled)
 {
 	if (has_runtime_pm)
 		goto out;
@@ -772,7 +776,8 @@ static bool setup_environment(void)
 	debugfs = igt_debugfs_dir(drm_fd);
 	igt_require(debugfs != -1);
 
-	init_mode_set_data(&ms_data);
+	if (!display_disabled)
+		init_mode_set_data(&ms_data);
 
 	igt_pm_enable_sata_link_power_management();
 
@@ -785,13 +790,14 @@ static bool setup_environment(void)
 	igt_require(igt_pm_dmc_loaded(debugfs));
 
 out:
-	disable_all_screens(&ms_data);
+	if (!display_disabled)
+		disable_all_screens(&ms_data);
 	dump_file(debugfs, "i915_runtime_pm_status");
 
 	return wait_for_suspended();
 }
 
-static void teardown_environment(void)
+static void teardown_environment(bool display_disabled)
 {
 	close(msr_fd);
 	if (has_pc8)
@@ -801,7 +807,8 @@ static void teardown_environment(void)
 
 	igt_pm_restore_sata_link_power_management();
 
-	fini_mode_set_data(&ms_data);
+	if (!display_disabled)
+		fini_mode_set_data(&ms_data);
 
 	close(debugfs);
 	close(drm_fd);
@@ -2008,7 +2015,7 @@ static struct option long_options[] = {
 igt_main_args("", long_options, help_str, opt_handler, NULL)
 {
 	igt_subtest("basic-rte") {
-		igt_assert(setup_environment());
+		igt_assert(setup_environment(false));
 		basic_subtest();
 	}
 
@@ -2016,7 +2023,7 @@ igt_main_args("", long_options, help_str, opt_handler, NULL)
 	 * PC8+. We don't want bug reports from cases where the machine is just
 	 * not properly configured. */
 	igt_fixture
-		igt_require(setup_environment());
+		igt_require(setup_environment(false));
 
 	if (stay)
 		igt_subtest("stay")
@@ -2146,7 +2153,7 @@ igt_main_args("", long_options, help_str, opt_handler, NULL)
 	}
 
 	igt_fixture
-		teardown_environment();
+		teardown_environment(false);
 
 	igt_subtest("module-reload") {
 		igt_debug("Reload w/o display\n");
@@ -2155,9 +2162,9 @@ igt_main_args("", long_options, help_str, opt_handler, NULL)
 		igt_kmsg(KMSG_INFO "Reloading i915 w/o display\n");
 		igt_assert_eq(igt_i915_driver_load("disable_display=1 mmio_debug=-1"), 0);
 
-		igt_assert(setup_environment());
+		igt_assert(setup_environment(true));
 		igt_assert(igt_wait(device_in_pci_d3(), 2000, 100));
-		teardown_environment();
+		teardown_environment(true);
 
 		igt_debug("Reload as normal\n");
 		igt_i915_driver_unload();
@@ -2165,11 +2172,11 @@ igt_main_args("", long_options, help_str, opt_handler, NULL)
 		igt_kmsg(KMSG_INFO "Reloading i915 as normal\n");
 		igt_assert_eq(igt_i915_driver_load("mmio_debug=-1"), 0);
 

tests/i915/i915_pm_rpm.c igt_main_args("", long_options, help_str, opt_handler, NULL) · line 2182

Quoted 10 lines
tests/i915/i915_pm_rpm.c +2 -2
-		igt_assert(setup_environment());
+		igt_assert(setup_environment(false));
 		igt_assert(igt_wait(device_in_pci_d3(), 2000, 100));
 		if (enable_one_screen_with_type(&ms_data, SCREEN_TYPE_ANY))
 			drm_resources_equal_subtest();
-		teardown_environment();
+		teardown_environment(false);
 
 		/* Remove our mmio_debugging module */
 		igt_i915_driver_unload();

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#17 lore raw

[igt-dev] ✗ Fi.CI.BAT: failure for lpsp platform agnostic support (rev3)

In reply to Anshuman Gupta
== Series Details ==

== Series Details ==

Series: lpsp platform agnostic support (rev3)
URL : https://patchwork.freedesktop.org/series/74647/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_8172 -> IGTPW_4338
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with IGTPW_4338 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in IGTPW_4338, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/index.html

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in IGTPW_4338:

### IGT changes ###

#### Possible regressions ####

* igt@i915_pm_rpm@basic-pci-d3-state:
- fi-glk-dsi: [PASS][1] -> [FAIL][2] +2 similar issues
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-glk-dsi/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-glk-dsi/igt@[email protected]
- fi-icl-u2: [PASS][3] -> [FAIL][4] +1 similar issue
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-icl-u2/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-icl-u2/igt@[email protected]
- fi-kbl-r: [PASS][5] -> [FAIL][6] +2 similar issues
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-kbl-r/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-kbl-r/igt@[email protected]
- fi-icl-guc: [PASS][7] -> [FAIL][8] +2 similar issues
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-icl-guc/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-icl-guc/igt@[email protected]
- fi-bdw-5557u: [PASS][9] -> [FAIL][10] +2 similar issues
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-bdw-5557u/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-bdw-5557u/igt@[email protected]
- fi-kbl-soraka: [PASS][11] -> [FAIL][12] +2 similar issues
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-kbl-soraka/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-kbl-soraka/igt@[email protected]

* igt@i915_pm_rpm@basic-rte:
- fi-kbl-7500u: NOTRUN -> [FAIL][13] +2 similar issues
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-kbl-7500u/igt@[email protected]
- fi-gdg-551: NOTRUN -> [FAIL][14] +2 similar issues
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-gdg-551/igt@[email protected]
- fi-skl-lmem: NOTRUN -> [FAIL][15] +2 similar issues
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-skl-lmem/igt@[email protected]
- fi-cml-u2: [PASS][16] -> [FAIL][17] +2 similar issues
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-cml-u2/igt@[email protected]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-cml-u2/igt@[email protected]
- fi-bxt-dsi: [PASS][18] -> [FAIL][19] +2 similar issues
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-bxt-dsi/igt@[email protected]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-bxt-dsi/igt@[email protected]
- fi-byt-j1900: [PASS][20] -> [FAIL][21] +2 similar issues
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-byt-j1900/igt@[email protected]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-byt-j1900/igt@[email protected]
- fi-hsw-4770: [PASS][22] -> [FAIL][23] +2 similar issues
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-hsw-4770/igt@[email protected]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-hsw-4770/igt@[email protected]
- fi-snb-2520m: NOTRUN -> [FAIL][24] +2 similar issues
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-snb-2520m/igt@[email protected]
- fi-apl-guc: [PASS][25] -> [FAIL][26] +2 similar issues
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-apl-guc/igt@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-apl-guc/igt@[email protected]

* igt@i915_pm_rpm@module-reload:
- fi-cfl-8109u: [PASS][27] -> [FAIL][28] +2 similar issues
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-cfl-8109u/igt@[email protected]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-cfl-8109u/igt@[email protected]
- fi-skl-6600u: [PASS][29] -> [FAIL][30] +2 similar issues
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-skl-6600u/igt@[email protected]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-skl-6600u/igt@[email protected]
- fi-cfl-8700k: [PASS][31] -> [FAIL][32] +2 similar issues
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-cfl-8700k/igt@[email protected]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-cfl-8700k/igt@[email protected]
- fi-bsw-kefka: [PASS][33] -> [FAIL][34] +2 similar issues
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-bsw-kefka/igt@[email protected]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-bsw-kefka/igt@[email protected]
- fi-kbl-x1275: [PASS][35] -> [FAIL][36] +2 similar issues
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-kbl-x1275/igt@[email protected]
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-kbl-x1275/igt@[email protected]
- fi-icl-dsi: [PASS][37] -> [FAIL][38] +2 similar issues
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-icl-dsi/igt@[email protected]
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-icl-dsi/igt@[email protected]
- fi-skl-guc: [PASS][39] -> [FAIL][40] +2 similar issues
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-skl-guc/igt@[email protected]
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-skl-guc/igt@[email protected]
- fi-bsw-n3050: NOTRUN -> [FAIL][41] +2 similar issues
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-bsw-n3050/igt@[email protected]
- fi-skl-6700k2: [PASS][42] -> [FAIL][43] +2 similar issues
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-skl-6700k2/igt@[email protected]
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-skl-6700k2/igt@[email protected]
- fi-cfl-guc: [PASS][44] -> [FAIL][45] +2 similar issues
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-cfl-guc/igt@[email protected]
[45]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-cfl-guc/igt@[email protected]
- fi-icl-y: [PASS][46] -> [FAIL][47] +2 similar issues
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-icl-y/igt@[email protected]
[47]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-icl-y/igt@[email protected]
- fi-cml-s: [PASS][48] -> [FAIL][49] +2 similar issues
[48]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-cml-s/igt@[email protected]
[49]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-cml-s/igt@[email protected]

#### Warnings ####

* igt@i915_pm_rpm@basic-pci-d3-state:
- fi-bwr-2160: [SKIP][50] ([fdo#109271]) -> [FAIL][51] +2 similar issues
[50]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-bwr-2160/igt@[email protected]
[51]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-bwr-2160/igt@[email protected]

* igt@i915_pm_rpm@basic-rte:
- fi-ivb-3770: [SKIP][52] ([fdo#109271]) -> [FAIL][53] +2 similar issues
[52]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-ivb-3770/igt@[email protected]
[53]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-ivb-3770/igt@[email protected]

* igt@i915_pm_rpm@module-reload:
- fi-pnv-d510: [SKIP][54] ([fdo#109271]) -> [FAIL][55] +2 similar issues
[54]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-pnv-d510/igt@[email protected]
[55]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-pnv-d510/igt@[email protected]
- fi-ilk-650: [SKIP][56] ([fdo#109271]) -> [FAIL][57] +2 similar issues
[56]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-ilk-650/igt@[email protected]
[57]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-ilk-650/igt@[email protected]
- fi-blb-e6850: [SKIP][58] ([fdo#109271]) -> [FAIL][59] +2 similar issues
[58]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-blb-e6850/igt@[email protected]
[59]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-blb-e6850/igt@[email protected]
- fi-elk-e7500: [SKIP][60] ([fdo#109271]) -> [FAIL][61] +2 similar issues
[60]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-elk-e7500/igt@[email protected]
[61]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-elk-e7500/igt@[email protected]
- fi-icl-u2: [DMESG-WARN][62] ([i915#289]) -> [FAIL][63]
[62]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-icl-u2/igt@[email protected]
[63]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-icl-u2/igt@[email protected]

#### Suppressed ####

The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.

* igt@i915_pm_rpm@basic-pci-d3-state:
- {fi-kbl-7560u}: NOTRUN -> [FAIL][64] +2 similar issues
[64]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-kbl-7560u/igt@[email protected]

* igt@i915_pm_rpm@basic-rte:
- {fi-ehl-1}: [PASS][65] -> [FAIL][66] +2 similar issues
[65]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-ehl-1/igt@[email protected]
[66]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-ehl-1/igt@[email protected]
- {fi-tgl-u}: [PASS][67] -> [FAIL][68] +2 similar issues
[67]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-tgl-u/igt@[email protected]
[68]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-tgl-u/igt@[email protected]

Known issues
------------

Here are the changes found in IGTPW_4338 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@i915_pm_rpm@module-reload:
- fi-kbl-8809g: [PASS][69] -> [SKIP][70] ([fdo#109271])
[69]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-kbl-8809g/igt@[email protected]
[70]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-kbl-8809g/igt@[email protected]

#### Possible fixes ####

* igt@i915_selftest@live@hangcheck:
- {fi-ehl-1}: [INCOMPLETE][71] -> [PASS][72]
[71]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8172/fi-ehl-1/igt@i915_selftest@[email protected]
[72]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/fi-ehl-1/igt@i915_selftest@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[i915#289]: https://gitlab.freedesktop.org/drm/intel/issues/289

Participating hosts (39 -> 40)
------------------------------

Additional (7): fi-bsw-n3050 fi-snb-2520m fi-kbl-7500u fi-gdg-551 fi-skl-lmem fi-kbl-7560u fi-bsw-nick
Missing (6): fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-byt-clapper fi-bdw-samus

Build changes
-------------

* CI: CI-20190529 -> None
* IGT: IGT_5526 -> IGTPW_4338

CI-20190529: 20190529
CI_DRM_8172: b53e00acaa550df13d601f258011b180013c5d38 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_4338: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/index.html
IGT_5526: f49ebeee9f54d6f23c60a842f75f65561d452ab0 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4338/index.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev