Skip to contentSkip to conversation

drm/i915: add rc6 residency times to debugfs

PATCH In review Ben Widawsky 3 participants 18 messages Mar 26, 2012 – Mar 27, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 drm/i915: add rc6 residency times to debugfs

RC6 residency should be in intervals of 1.28us, and the counter wraps. Here is an example using awk to get the various RC6 and RC6+ residency times in seconds, since boot.

cat /sys/kernel/debug/dri/0/i915_drpc_info | grep residency | awk -F':' -F' ' '{print $5 * 1.28 / 1000000}'

This is primarily for debug, and QA/application developers using the sysfs interface looking for more insight.

Untested on IVB.

v2: move comment to the correct place
commeit message changes

Reviewed-by (v1): Eugeni Dodonov <[email protected]> Signed-off-by (v1): Daniel Vetter <[email protected]>

---
 drivers/gpu/drm/i915/i915_debugfs.c |   11 +++++++++++
 drivers/gpu/drm/i915/i915_reg.h     |    5 +++++
 2 files changed, 16 insertions(+)
drivers/gpu/drm/i915/i915_debugfs.c +11 -0
index 66c90d4..4257151 100644
@@ -1133,6 +1133,17 @@ static int gen6_drpc_info(struct seq_file *m)
 
 	seq_printf(m, "Core Power Down: %s\n",
 		   yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK));
+
+	/* Not exactly sure what this is */
+	seq_printf(m, "RC6 \"Locked to RPn\" residency since boot: %d\n",
+		   I915_READ(GEN6_GT_GFX_RC6_LOCKED));
+	seq_printf(m, "RC6 residency since boot: %d\n",
+		   I915_READ(GEN6_GT_GFX_RC6));
+	seq_printf(m, "RC6+ residency since boot: %d\n",
+		   I915_READ(GEN6_GT_GFX_RC6p));
+	seq_printf(m, "RC6++ residency since boot: %d\n",
+		   I915_READ(GEN6_GT_GFX_RC6pp));
+
 	return 0;
 }
 
drivers/gpu/drm/i915/i915_reg.h +5 -0
index f3609f2..b1c3d35 100644
@@ -3799,6 +3799,11 @@
 						 GEN6_PM_RP_DOWN_THRESHOLD | \
 						 GEN6_PM_RP_DOWN_TIMEOUT)
 
+#define GEN6_GT_GFX_RC6_LOCKED			0x138104
+#define GEN6_GT_GFX_RC6				0x138108
+#define GEN6_GT_GFX_RC6p			0x13810C
+#define GEN6_GT_GFX_RC6pp			0x138110
+
 #define GEN6_PCODE_MAILBOX			0x138124
 #define   GEN6_PCODE_READY			(1<<31)
 #define   GEN6_READ_OC_PARAMS			0xc
Signature · 1 line
1.7.9.4
#1 lore raw

PATCH 1/3 build: make sure we have asprintf

---
 configure.ac |    2 ++
 1 file changed, 2 insertions(+)
configure.ac +2 -0
index f778a9a..567f10d 100644
@@ -32,6 +32,7 @@ AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_AUX_DIR([build-aux])
 AC_USE_SYSTEM_EXTENSIONS
 AC_SYS_LARGEFILE
+AC_GNU_SOURCE
 
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 AM_PATH_PYTHON([3],, [:])
@@ -43,6 +44,7 @@ AC_CHECK_MEMBERS([struct sysinfo.totalram],[],[],[AC_INCLUDES_DEFAULT
 #include <sys/sysinfo.h>
 ])
 AC_CHECK_FUNCS([swapctl])
+AC_CHECK_FUNCS([asprintf])
 
 # Initialize libtool
 AC_DISABLE_STATIC
Signature · 1 line
1.7.9.4
#2 lore raw

PATCH v2 3/3 drm/i915: rc6 in sysfs

In reply to Ben Widawsky

Merge rc6 information into the power group for our device. Until now the i915 driver has not had any sysfs entries (aside from the connector stuff enabled by drm core). Since it seems like we're likely to have more in the future I created a new file for sysfs stubs, as well as the rc6 sysfs functions which don't really belong elsewhere (perhaps i915_suspend, but most of the stuff is in intel_display,c).

displays #ms GPU has been in rc6 since boot:
cat /sys/class/drm/card0/power/rc6

displays #ms GPU has been in deep rc6 since boot:
cat /sys/class/drm/card0/power/rc6p

displays #ms GPU has been in deepest rc6 since boot:
cat /sys/class/drm/card0/power/rc6pp

Important note: I've seen on SNB that even when RC6 is *not* enabled the rc6 register seems to have a random value in it. I cannot explain a reason for this. Those writing tools that utilize this value need to be careful and probably want to scrutinize the value very carefully.

Please see intel-gpu-tools patches for sample code.

Untested on IVB.

v2: use calc_residency units to milliseconds for the other RC6 types

CC Arjan van de Ven <[email protected]>
---
 drivers/gpu/drm/i915/Makefile     |    1 +
 drivers/gpu/drm/i915/i915_dma.c   |    4 ++
 drivers/gpu/drm/i915/i915_drv.h   |    4 ++
 drivers/gpu/drm/i915/i915_sysfs.c |  100 +++++++++++++++++++++++++++++++++++++
 4 files changed, 109 insertions(+)
 create mode 100644 drivers/gpu/drm/i915/i915_sysfs.c
drivers/gpu/drm/i915/Makefile +1 -0
index ce7fc77..f801330 100644
@@ -12,6 +12,7 @@ i915-y := i915_drv.o i915_dma.o i915_irq.o \
 	  i915_gem_execbuffer.o \
 	  i915_gem_gtt.o \
 	  i915_gem_tiling.o \
+	  i915_sysfs.o \
 	  i915_trace_points.o \
 	  intel_display.o \
 	  intel_crt.o \
drivers/gpu/drm/i915/i915_dma.c +4 -0
index fdff009..64dfbb8 100644
@@ -2113,6 +2113,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 		}
 	}
 
+	i915_setup_sysfs(dev);
+
 	/* Must be done after probing outputs */
 	intel_opregion_init(dev);
 	acpi_video_register();
@@ -2164,6 +2166,8 @@ int i915_driver_unload(struct drm_device *dev)
 	i915_mch_dev = NULL;
 	spin_unlock(&mchdev_lock);
 
+	i915_teardown_sysfs(dev);
+
 	if (dev_priv->mm.inactive_shrinker.shrink)
 		unregister_shrinker(&dev_priv->mm.inactive_shrinker);
 
drivers/gpu/drm/i915/i915_drv.h +4 -0
index 22ab4db..e267774 100644
@@ -1365,6 +1365,10 @@ extern int i915_restore_state(struct drm_device *dev);
 extern int i915_save_state(struct drm_device *dev);
 extern int i915_restore_state(struct drm_device *dev);
 
+/* i915_sysfs.c */
+void i915_setup_sysfs(struct drm_device *dev_priv);
+void i915_teardown_sysfs(struct drm_device *dev_priv);
+
 /* intel_i2c.c */
 extern int intel_setup_gmbus(struct drm_device *dev);
 extern void intel_teardown_gmbus(struct drm_device *dev);
drivers/gpu/drm/i915/i915_sysfs.c new file +100 -0

100 lines not on this page · raw message

Signature · 6 lines
1.7.9.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

PATCH 2/3 drm/i915: extract intel_enable_rc6()

In reply to Ben Widawsky

This function tells us the state of RC6. In the future perhaps it will even give something like a mask back telling which RC6 types are enabled.

In order to return sane values to userspace for an upcoming RC6 sysfs interface (since register behavior seems to be somewhat random), we will query this value, and therefore it needs to be available to the rest of the driver.

---
 drivers/gpu/drm/i915/i915_drv.h      |    1 +
 drivers/gpu/drm/i915/intel_display.c |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index bbbc1a4..22ab4db 100644
@@ -1414,6 +1414,7 @@ extern void ironlake_enable_rc6(struct drm_device *dev);
 extern void gen6_set_rps(struct drm_device *dev, u8 val);
 extern void intel_detect_pch(struct drm_device *dev);
 extern int intel_trans_dp_port_sel(struct drm_crtc *crtc);
+extern int intel_enable_rc6(const struct drm_device *dev);
 
 extern void __gen6_gt_force_wake_get(struct drm_i915_private *dev_priv);
 extern void __gen6_gt_force_wake_mt_get(struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/intel_display.c +1 -1
index ab62c96..efbf709 100644
@@ -8235,7 +8235,7 @@ void intel_init_emon(struct drm_device *dev)
 	dev_priv->corr = (lcfuse & LCFUSE_HIV_MASK);
 }
 
-static int intel_enable_rc6(struct drm_device *dev)
+int intel_enable_rc6(const struct drm_device *dev)
 {
 	/*
 	 * Respect the kernel parameter if it is set
Signature · 1 line
1.7.9.4
#4 lore raw

Re: [PATCH 2/3] drm/i915: extract intel_enable_rc6()

Quoted 3 lines · Ben Widawsky

This function tells us the state of RC6. In the future perhaps it will even give something like a mask back telling which RC6 types are enabled.

This comment somehow sounds like you expect to use this when Eugeni's patches are merged. But actually your patch doesn't apply without Eugeni's patches, because they change the return type from bool to int.

So can you be slightly less fuzzy in your comments, please?

/rant
-Daniel

Quoted 44 lines

In order to return sane values to userspace for an upcoming RC6 sysfs interface (since register behavior seems to be somewhat random), we will query this value, and therefore it needs to be available to the rest of the driver.

---
 drivers/gpu/drm/i915/i915_drv.h      |    1 +
 drivers/gpu/drm/i915/intel_display.c |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index bbbc1a4..22ab4db 100644
@@ -1414,6 +1414,7 @@ extern void ironlake_enable_rc6(struct drm_device *dev);
 extern void gen6_set_rps(struct drm_device *dev, u8 val);
 extern void intel_detect_pch(struct drm_device *dev);
 extern int intel_trans_dp_port_sel(struct drm_crtc *crtc);
+extern int intel_enable_rc6(const struct drm_device *dev);
 
 extern void __gen6_gt_force_wake_get(struct drm_i915_private *dev_priv);
 extern void __gen6_gt_force_wake_mt_get(struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/intel_display.c +1 -1
index ab62c96..efbf709 100644
@@ -8235,7 +8235,7 @@ void intel_init_emon(struct drm_device *dev)
 	dev_priv->corr = (lcfuse & LCFUSE_HIV_MASK);
 }
 
-static int intel_enable_rc6(struct drm_device *dev)
+int intel_enable_rc6(const struct drm_device *dev)
 {
 	/*
 	 * Respect the kernel parameter if it is set
Signature · 6 lines
1.7.9.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48
#5 lore raw

PATCH 2/3 drm/i915: extract card getting

In reply to Ben Widawsky

I didn't test this very thoroughly...

---
 lib/drmtest.c |  122 +++++++++++++++++++++++++++++++++++++++------------------
 1 file changed, 83 insertions(+), 39 deletions(-)
lib/drmtest.c +83 -39
index f9b7a6f..063b5c5 100644
@@ -26,6 +26,8 @@
  *
  */
 
+#define _GNU_SOURCE
+#include <stdio.h>
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
@@ -112,70 +114,112 @@ void gem_quiescent_gpu(int fd)
 	gem_sync(fd, handle);
 }
 
-/** Open the first DRM device we can find, searching up to 16 device nodes */
-int drm_open_any(void)
+static bool is_master(int fd)
 {
-	char name[20];
+	drm_client_t client;
+	int ret;
+
+	/* Check that we're the only opener and authed. */
+	client.idx = 0;
+	ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client);
+	assert (ret == 0);
+	if (!client.auth) {
+		return 0;
+	}
+	client.idx = 1;
+	ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client);
+	if (ret != -1 || errno != EINVAL) {
+		return 0;
+	}
+	return 1;
+}
+
+/**
+ * drm_get_card() - get an intel card number for use in /dev or /sys
+ *
+ * @master: -1 not a master, 0 don't care, 1 is the master
+ *
+ * returns -1 on error
+ */
+int drm_get_card(int master)
+{
+	char *name;
 	int i, fd;
 
 	for (i = 0; i < 16; i++) {
-		sprintf(name, "/dev/dri/card%d", i);
+		int ret;
+
+		ret = asprintf(&name, "/dev/dri/card%u", i);
+		if (ret == -1)
+			return -1;
 		fd = open(name, O_RDWR);
+		free(name);
+
 		if (fd == -1)
 			continue;
 
-		if (is_intel(fd)) {
+		if (is_intel(fd) && master == 0) {
 			gem_quiescent_gpu(fd);
-			return fd;
+			break;
+		}
+
+		if (master == 1 && is_master(fd)) {
+			close(fd);
+			break;
+		}
+
+		if (master == -1 && !is_master(fd)) {
+			close(fd);
+			break;
 		}
 
 		close(fd);
 	}
-	fprintf(stderr, "failed to open any drm device. retry as root?\n");
-	abort();
+
+	return i;
 }
 
+/** Open the first DRM device we can find, searching up to 16 device nodes */
+int drm_open_any(void)
+{
+	char *name;
+	int ret, fd;
+
+	ret = asprintf(&name, "/dev/dri/card%d", drm_get_card(0));
+	if (ret == -1)
+		return -1;
+
+	fd = open(name, O_RDWR);
+	free(name);
+
+	if (fd == -1)
+		fprintf(stderr, "failed to open any drm device. retry as root?\n");
+
+	assert(is_intel(fd));
+
+	return fd;
+}
 
 /**
  * Open the first DRM device we can find where we end up being the master.
  */
 int drm_open_any_master(void)
 {
-	char name[20];
-	int i, fd;
+	char *name;
+	int ret, fd;
 
-	for (i = 0; i < 16; i++) {
-		drm_client_t client;
-		int ret;
+	ret = asprintf(&name, "/dev/dri/card%d", drm_get_card(1));
+	if (ret == -1)
+		return -1;
 
-		sprintf(name, "/dev/dri/card%d", i);
-		fd = open(name, O_RDWR);
-		if (fd == -1)
-			continue;
+	fd = open(name, O_RDWR);
+	free(name);
+	if (fd == -1)
+		fprintf(stderr, "Couldn't find an un-controlled DRM device\n");
 
-		if (!is_intel(fd)) {
-			close(fd);
-			continue;
-		}
+	assert(is_intel(fd));
 
-		/* Check that we're the only opener and authed. */
-		client.idx = 0;
-		ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client);
-		assert (ret == 0);
-		if (!client.auth) {
-			close(fd);
-			continue;
-		}
-		client.idx = 1;
-		ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client);
-		if (ret != -1 || errno != EINVAL) {
-			close(fd);
-			continue;
-		}
-		return fd;
-	}
-	fprintf(stderr, "Couldn't find an un-controlled DRM device\n");
-	abort();
+	return fd;
 }
 
 void gem_set_tiling(int fd, uint32_t handle, int tiling, int stride)
Signature · 1 line
1.7.9.4
#6 lore raw

Re: [PATCH 2/3] drm/i915: extract card getting

Quoted 3 lines · Ben Widawsky

I didn't test this very thoroughly...

Tested on my ivb, where i915 is drm device 1 (instead of the usual 0). Seems to work.

Quoted 176 lines
---
 lib/drmtest.c |  122 +++++++++++++++++++++++++++++++++++++++------------------
 1 file changed, 83 insertions(+), 39 deletions(-)
lib/drmtest.c +83 -39
index f9b7a6f..063b5c5 100644
@@ -26,6 +26,8 @@
  *
  */
 
+#define _GNU_SOURCE
+#include <stdio.h>
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
@@ -112,70 +114,112 @@ void gem_quiescent_gpu(int fd)
 	gem_sync(fd, handle);
 }
 
-/** Open the first DRM device we can find, searching up to 16 device nodes */
-int drm_open_any(void)
+static bool is_master(int fd)
 {
-	char name[20];
+	drm_client_t client;
+	int ret;
+
+	/* Check that we're the only opener and authed. */
+	client.idx = 0;
+	ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client);
+	assert (ret == 0);
+	if (!client.auth) {
+		return 0;
+	}
+	client.idx = 1;
+	ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client);
+	if (ret != -1 || errno != EINVAL) {
+		return 0;
+	}
+	return 1;
+}
+
+/**
+ * drm_get_card() - get an intel card number for use in /dev or /sys
+ *
+ * @master: -1 not a master, 0 don't care, 1 is the master
+ *
+ * returns -1 on error
+ */
+int drm_get_card(int master)
+{
+	char *name;
 	int i, fd;
 
 	for (i = 0; i < 16; i++) {
-		sprintf(name, "/dev/dri/card%d", i);
+		int ret;
+
+		ret = asprintf(&name, "/dev/dri/card%u", i);
+		if (ret == -1)
+			return -1;
 		fd = open(name, O_RDWR);
+		free(name);
+
 		if (fd == -1)
 			continue;
 
-		if (is_intel(fd)) {
+		if (is_intel(fd) && master == 0) {
 			gem_quiescent_gpu(fd);
-			return fd;
+			break;
+		}
+
+		if (master == 1 && is_master(fd)) {
+			close(fd);
+			break;
+		}
+
+		if (master == -1 && !is_master(fd)) {
+			close(fd);
+			break;
 		}
 
 		close(fd);
 	}
-	fprintf(stderr, "failed to open any drm device. retry as root?\n");
-	abort();
+
+	return i;
 }
 
+/** Open the first DRM device we can find, searching up to 16 device nodes */
+int drm_open_any(void)
+{
+	char *name;
+	int ret, fd;
+
+	ret = asprintf(&name, "/dev/dri/card%d", drm_get_card(0));
+	if (ret == -1)
+		return -1;
+
+	fd = open(name, O_RDWR);
+	free(name);
+
+	if (fd == -1)
+		fprintf(stderr, "failed to open any drm device. retry as root?\n");
+
+	assert(is_intel(fd));
+
+	return fd;
+}
 
 /**
  * Open the first DRM device we can find where we end up being the master.
  */
 int drm_open_any_master(void)
 {
-	char name[20];
-	int i, fd;
+	char *name;
+	int ret, fd;
 
-	for (i = 0; i < 16; i++) {
-		drm_client_t client;
-		int ret;
+	ret = asprintf(&name, "/dev/dri/card%d", drm_get_card(1));
+	if (ret == -1)
+		return -1;
 
-		sprintf(name, "/dev/dri/card%d", i);
-		fd = open(name, O_RDWR);
-		if (fd == -1)
-			continue;
+	fd = open(name, O_RDWR);
+	free(name);
+	if (fd == -1)
+		fprintf(stderr, "Couldn't find an un-controlled DRM device\n");
 
-		if (!is_intel(fd)) {
-			close(fd);
-			continue;
-		}
+	assert(is_intel(fd));
 
-		/* Check that we're the only opener and authed. */
-		client.idx = 0;
-		ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client);
-		assert (ret == 0);
-		if (!client.auth) {
-			close(fd);
-			continue;
-		}
-		client.idx = 1;
-		ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client);
-		if (ret != -1 || errno != EINVAL) {
-			close(fd);
-			continue;
-		}
-		return fd;
-	}
-	fprintf(stderr, "Couldn't find an un-controlled DRM device\n");
-	abort();
+	return fd;
 }
 
 void gem_set_tiling(int fd, uint32_t handle, int tiling, int stride)
Signature · 6 lines
1.7.9.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48
#7 lore raw

PATCH v2 3/3 tests: rc6 residency test

In reply to Ben Widawsky

This is meant to test the sysfs entry for showing rc6 residency in milliseconds. Remember, sysfs is a permanent interface.

v2: use new get_card interface to try "all" devices check rc6p and rc6pp in addition to rc6

---
 lib/drmtest.h         |    1 +
 tests/Makefile.am     |    1 +
 tests/rc6_residency.c |   91 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 93 insertions(+)
 create mode 100644 tests/rc6_residency.c
lib/drmtest.h +1 -0
index 96fbf1a..42f238c 100644
@@ -35,6 +35,7 @@
 #include "xf86drm.h"
 #include "intel_batchbuffer.h"
 
+int drm_get_card(int master);
 int drm_open_any(void);
 int drm_open_any_master(void);
 
tests/Makefile.am +1 -0
index 6544ec7..a8eed88 100644
@@ -56,6 +56,7 @@ TESTS_progs = \
 	drm_vma_limiter_cpu \
 	drm_vma_limiter_gtt \
 	drm_vma_limiter_cached \
+	rc6_residency \
 	$(NULL)
 
 # IMPORTANT: The ZZ_ tests need to be run last!
tests/rc6_residency.c new file +91 -0

91 lines not on this page · raw message

Signature · 6 lines
1.7.9.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#8 lore raw

Re: [PATCH v2 3/3] tests: rc6 residency test

Quoted 7 lines · Ben Widawsky

This is meant to test the sysfs entry for showing rc6 residency in milliseconds. Remember, sysfs is a permanent interface.

v2: use new get_card interface to try "all" devices check rc6p and rc6pp in addition to rc6

You're still missing the drm_quiescent_gpu(fd) call before doing the residency measurements. Which makes this test fail reliably in the i-g-t testsuite because the gpu is still busy from previous tests. Please run new tests also in the context of the full testuite to catch such issues.

If this leaking of gpu business annoys you to much, you could create a drm_close_dev(fd) which calls drm_quiescent_gpu and replace the final close on the dev with this in all tests.

Also, to keep things in line with other testes, can you name this sysfs_rc6_residency?
-Daniel

Quoted 135 lines
---
 lib/drmtest.h         |    1 +
 tests/Makefile.am     |    1 +
 tests/rc6_residency.c |   91 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 93 insertions(+)
 create mode 100644 tests/rc6_residency.c
lib/drmtest.h +1 -0
index 96fbf1a..42f238c 100644
@@ -35,6 +35,7 @@
 #include "xf86drm.h"
 #include "intel_batchbuffer.h"
 
+int drm_get_card(int master);
 int drm_open_any(void);
 int drm_open_any_master(void);
 
tests/Makefile.am +1 -0
index 6544ec7..a8eed88 100644
@@ -56,6 +56,7 @@ TESTS_progs = \
 	drm_vma_limiter_cpu \
 	drm_vma_limiter_gtt \
 	drm_vma_limiter_cached \
+	rc6_residency \
 	$(NULL)
 
 # IMPORTANT: The ZZ_ tests need to be run last!
tests/rc6_residency.c new file +91 -0
new file mode 100644
index 0000000..5c2e442
@@ -0,0 +1,91 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Ben Widawsky <[email protected]>
+ *
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include "drmtest.h"
+
+static unsigned int readit(const char *path)
+{
+	unsigned int ret;
+
+	FILE *file;
+	file = fopen(path, "r");
+	if (file == NULL) {
+		fprintf(stderr, "Couldn't open %s (%d)\n", path, errno);
+		abort();
+	}
+	fscanf(file, "%u", &ret);
+	fclose(file);
+
+	return ret;
+}
+
+int main(int argc, char *argv[])
+{
+	const int device = drm_get_card(0);
+	char *path, *pathp, *pathpp;
+	int fd, ret;
+	unsigned int value1, value1p, value1pp, value2, value2p, value2pp;
+	int diff;
+
+	/* Use drm_open_any to verify device existence */
+	fd = drm_open_any();
+	close(fd);
+
+	ret = asprintf(&path, "/sys/class/drm/card%d/power/rc6", device);
+	assert(ret != -1);
+	ret = asprintf(&pathp, "/sys/class/drm/card%d/power/rc6p", device);
+	assert(ret != -1);
+	ret = asprintf(&pathpp, "/sys/class/drm/card%d/power/rc6pp", device);
+	assert(ret != -1);
+
+	value1 = readit(path);
+	value1p = readit(pathp);
+	value1pp = readit(pathpp);
+	// Sleep for 3 seconds and compare
+	sleep(3);
+	value2 = readit(path);
+	value2p = readit(pathp);
+	value2pp = readit(pathpp);
+
+	diff = (value2pp - value1pp) +
+		(value2p - value1p) +
+		(value2 - value1);
+
+	/* Plenty of fudge */
+	if (diff > 3900 || diff < 2100) {
+		printf("%d\n", diff);
+		exit(EXIT_FAILURE);
+	}
+
+	free(path);
+	exit(EXIT_SUCCESS);
+}
Signature · 6 lines
1.7.9.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48
#9 lore raw

Re: [PATCH v2 3/3] tests: rc6 residency test

Quoted 7 lines · Daniel Vetter
Quoted 6 lines · Ben Widawsky

This is meant to test the sysfs entry for showing rc6 residency in milliseconds. Remember, sysfs is a permanent interface.

v2: use new get_card interface to try "all" devices check rc6p and rc6pp in addition to rc6

Quoted 6 lines
Quoted 1 line

You're still missing the drm_quiescent_gpu(fd) call before doing the residency measurements. Which makes this test fail reliably in the i-g-t testsuite because the gpu is still busy from previous tests. Please run new tests also in the context of the full testuite to catch such issues.

Actually the quiescent seems to be there, so I don't know what's going on. -Daniel

Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48
#10 lore raw

Re: [PATCH v2 3/3] tests: rc6 residency test

Quoted 10 lines · On Mon, 26 Mar 2012 11:40:55 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 9 lines · Daniel Vetter
Quoted 7 lines · Ben Widawsky

This is meant to test the sysfs entry for showing rc6 residency in milliseconds. Remember, sysfs is a permanent interface.

v2: use new get_card interface to try "all" devices check rc6p and rc6pp in addition to rc6

Quoted 8 lines
Quoted 5 lines

You're still missing the drm_quiescent_gpu(fd) call before doing the residency measurements. Which makes this test fail reliably in the i-g-t testsuite because the gpu is still busy from previous tests. Please run new tests also in the context of the full testuite to catch such issues.

Actually the quiescent seems to be there, so I don't know what's going on. -Daniel

I ran this on IVB, both individual and with make test (Ken's machine), and it passed.

Ben

#11 lore raw

Re: [PATCH v2 3/3] tests: rc6 residency test

Quoted 19 lines · Ben Widawsky
Quoted 16 lines · On Mon, 26 Mar 2012 11:40:55 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 14 lines · Daniel Vetter
Quoted 7 lines · Ben Widawsky

This is meant to test the sysfs entry for showing rc6 residency in milliseconds. Remember, sysfs is a permanent interface.

v2: use new get_card interface to try "all" devices check rc6p and rc6pp in addition to rc6

You're still missing the drm_quiescent_gpu(fd) call before doing the residency measurements. Which makes this test fail reliably in the i-g-t testsuite because the gpu is still busy from previous tests. Please run new tests also in the context of the full testuite to catch such issues.

Quoted 5 lines
Quoted 2 lines

Actually the quiescent seems to be there, so I don't know what's going on. -Daniel

I ran this on IVB, both individual and with make test (Ken's machine), and it passed.

Ok, I'll digg into this and try to find out why it fails on my ivb. -Daniel

Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48
#12 lore raw

Re: [PATCH v2 3/3] tests: rc6 residency test

In reply to Ben Widawsky
Quoted 25 lines · Ben Widawsky
tests/rc6_residency.c new file +25 -0
+int main(int argc, char *argv[])
+{
+	const int device = drm_get_card(0);
+	char *path, *pathp, *pathpp;
+	int fd, ret;
+	unsigned int value1, value1p, value1pp, value2, value2p, value2pp;
+	int diff;
+
+	/* Use drm_open_any to verify device existence */
+	fd = drm_open_any();
+	close(fd);
+
+	ret = asprintf(&path, "/sys/class/drm/card%d/power/rc6", device);
+	assert(ret != -1);
+	ret = asprintf(&pathp, "/sys/class/drm/card%d/power/rc6p", device);
+	assert(ret != -1);
+	ret = asprintf(&pathpp, "/sys/class/drm/card%d/power/rc6pp", device);
+	assert(ret != -1);
+
+	value1 = readit(path);
+	value1p = readit(pathp);
+	value1pp = readit(pathpp);
+	// Sleep for 3 seconds and compare
+	sleep(3);
+	value2 = readit(path);

tests/rc6_residency.c line 85

Quoted 10 lines
tests/rc6_residency.c new file +10 -0
+	value2p = readit(pathp);
+	value2pp = readit(pathpp);
+
+	diff = (value2pp - value1pp) +
+		(value2p - value1p) +
+		(value2 - value1);
+
+	/* Plenty of fudge */
+	if (diff > 3900 || diff < 2100) {
+		printf("%d\n", diff);

While I bitch around: A slightly more informative error message could be usueful ;-)

Cheers, Daniel

Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48
#13 lore raw
In reply to Ben Widawsky
Quoted 10 lines · Ben Widawsky

RC6 residency should be in intervals of 1.28us, and the counter wraps. Here is an example using awk to get the various RC6 and RC6+ residency times in seconds, since boot.

cat /sys/kernel/debug/dri/0/i915_drpc_info | grep residency | awk -F':' -F' ' '{print $5 * 1.28 / 1000000}'

This is primarily for debug, and QA/application developers using the sysfs interface looking for more insight.

Untested on IVB.

Tested on my ivb, seems to yield sane numbers for the default configuration (i.e. enable rc+rc6p, disable rc6pp). -Daniel

Quoted 58 lines

v2: move comment to the correct place
commeit message changes

Reviewed-by (v1): Eugeni Dodonov <[email protected]> Signed-off-by (v1): Daniel Vetter <[email protected]>

---
 drivers/gpu/drm/i915/i915_debugfs.c |   11 +++++++++++
 drivers/gpu/drm/i915/i915_reg.h     |    5 +++++
 2 files changed, 16 insertions(+)
drivers/gpu/drm/i915/i915_debugfs.c +11 -0
index 66c90d4..4257151 100644
@@ -1133,6 +1133,17 @@ static int gen6_drpc_info(struct seq_file *m)
 
 	seq_printf(m, "Core Power Down: %s\n",
 		   yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK));
+
+	/* Not exactly sure what this is */
+	seq_printf(m, "RC6 \"Locked to RPn\" residency since boot: %d\n",
+		   I915_READ(GEN6_GT_GFX_RC6_LOCKED));
+	seq_printf(m, "RC6 residency since boot: %d\n",
+		   I915_READ(GEN6_GT_GFX_RC6));
+	seq_printf(m, "RC6+ residency since boot: %d\n",
+		   I915_READ(GEN6_GT_GFX_RC6p));
+	seq_printf(m, "RC6++ residency since boot: %d\n",
+		   I915_READ(GEN6_GT_GFX_RC6pp));
+
 	return 0;
 }
 
drivers/gpu/drm/i915/i915_reg.h +5 -0
index f3609f2..b1c3d35 100644
@@ -3799,6 +3799,11 @@
 						 GEN6_PM_RP_DOWN_THRESHOLD | \
 						 GEN6_PM_RP_DOWN_TIMEOUT)
 
+#define GEN6_GT_GFX_RC6_LOCKED			0x138104
+#define GEN6_GT_GFX_RC6				0x138108
+#define GEN6_GT_GFX_RC6p			0x13810C
+#define GEN6_GT_GFX_RC6pp			0x138110
+
 #define GEN6_PCODE_MAILBOX			0x138124
 #define   GEN6_PCODE_READY			(1<<31)
 #define   GEN6_READ_OC_PARAMS			0xc
Signature · 6 lines
1.7.9.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48
Reviewed-by
#14 lore raw
Quoted 8 lines · Daniel Vetter
Quoted 5 lines · Ben Widawsky

RC6 residency should be in intervals of 1.28us, and the counter wraps. Here is an example using awk to get the various RC6 and RC6+ residency times in seconds, since boot.

cat /sys/kernel/debug/dri/0/i915_drpc_info | grep residency | awk -F':'

-F' ' '{print $5 * 1.28 / 1000000}'

Quoted 1 line
Quoted 8 lines
Quoted 4 lines

This is primarily for debug, and QA/application developers using the sysfs interface looking for more insight.

Untested on IVB.

Tested on my ivb, seems to yield sane numbers for the default configuration (i.e. enable rc+rc6p, disable rc6pp).

Yeah, it should work on IVB except for some strange behavior sometimes (I noticed that on IVB we sometimes get into RC6 even if we pass the i915_enable_rc6=0 parameter). I don't know if it is Bios playing some tricks with us or something changed in the mailbox communication, but no harm came from this so far. I'll see what is going on there.

But for the patch itself:

Nothing like new and shiny powertop power-saving options :).

Signature · 2 lines
Eugeni Dodonov
<http://eugeni.dodonov.net/>

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#15 lore raw
Quoted 27 lines · On Mon, 26 Mar 2012 09:33:51 -0300 Eugeni Dodonov <[email protected]> wrote:
Quoted 9 lines · Daniel Vetter
Quoted 6 lines · Ben Widawsky

RC6 residency should be in intervals of 1.28us, and the counter wraps. Here is an example using awk to get the various RC6 and RC6+ residency times in seconds, since boot.

cat /sys/kernel/debug/dri/0/i915_drpc_info | grep residency | awk -F':'

-F' ' '{print $5 * 1.28 / 1000000}'

Quoted 1 line
Quoted 8 lines
Quoted 4 lines

This is primarily for debug, and QA/application developers using the sysfs interface looking for more insight.

Untested on IVB.

Tested on my ivb, seems to yield sane numbers for the default configuration (i.e. enable rc+rc6p, disable rc6pp).

Yeah, it should work on IVB except for some strange behavior sometimes (I noticed that on IVB we sometimes get into RC6 even if we pass the i915_enable_rc6=0 parameter). I don't know if it is Bios playing some tricks with us or something changed in the mailbox communication, but no harm came from this so far. I'll see what is going on there.

Quoted 5 lines

But for the patch itself:

Nothing like new and shiny powertop power-saving options :).

Well as I said... at least on SNB it seems the RC6 value is never 0. But I suspect this isn't because we go into RC6, but rather just a uninitialized register value. Probably would be nice to follow up with the designers on this one.

#16 lore raw
In reply to Eugeni Dodonov
Quoted 27 lines · On Mon, 26 Mar 2012 09:33:51 -0300 Eugeni Dodonov <[email protected]> wrote:
Quoted 9 lines · Daniel Vetter
Quoted 6 lines · Ben Widawsky

RC6 residency should be in intervals of 1.28us, and the counter wraps. Here is an example using awk to get the various RC6 and RC6+ residency times in seconds, since boot.

cat /sys/kernel/debug/dri/0/i915_drpc_info | grep residency | awk -F':'

-F' ' '{print $5 * 1.28 / 1000000}'

Quoted 1 line
Quoted 8 lines
Quoted 4 lines

This is primarily for debug, and QA/application developers using the sysfs interface looking for more insight.

Untested on IVB.

Tested on my ivb, seems to yield sane numbers for the default configuration (i.e. enable rc+rc6p, disable rc6pp).

Yeah, it should work on IVB except for some strange behavior sometimes (I noticed that on IVB we sometimes get into RC6 even if we pass the i915_enable_rc6=0 parameter). I don't know if it is Bios playing some tricks with us or something changed in the mailbox communication, but no harm came from this so far. I'll see what is going on there.

Quoted 5 lines

But for the patch itself:

Nothing like new and shiny powertop power-saving options :).

I'd like to resubmit this patch with either %u or %x instead of the %d. Can I still keep your r-b?

#17 lore raw
Quoted 3 lines · Ben Widawsky

I'd like to resubmit this patch with either %u or %x instead of the %d. Can I still keep your r-b?

I'd vote for %u - it makes more sense as we are counting real time here. But sure, you can keep my R-b for this.

Signature · 2 lines
Eugeni Dodonov
 <http://eugeni.dodonov.net/>

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx