[Intel-gfx] [PATCH 4/9] intel_gpu_top: read max/current gt freq via sysfs

Robert Bragg robert.bragg at intel.com
Fri Jul 18 17:38:48 CEST 2014


---
 tools/intel_gpu_top.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
index 7574ef0..3115b5e 100644
--- a/tools/intel_gpu_top.c
+++ b/tools/intel_gpu_top.c
@@ -39,6 +39,9 @@
 #include <sys/time.h>
 #include <sys/wait.h>
 #include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
 #ifdef HAVE_TERMIOS_H
 #include <termios.h>
 #endif
@@ -127,6 +130,24 @@ gettime(void)
 }
 
 static int
+read_file_int(const char *file)
+{
+	char buf[32];
+	int fd, n;
+
+	fd = open(file, 0);
+	if (fd < 0)
+	    return -1;
+	n = read(fd, buf, sizeof (buf) - 1);
+	close(fd);
+	if (n < 0)
+	    return -1;
+
+	buf[n] = '\0';
+	return strtol(buf, 0, 0);
+}
+
+static int
 top_bits_sort(const void *a, const void *b)
 {
 	struct top_bit * const *bit_a = a;
@@ -280,6 +301,16 @@ print_clock_info(struct pci_device *pci_dev)
 		print_clock("render", render_clock);
 		printf("  ");
 		print_clock("display", display_clock);
+	} else {
+	    int max_render_clock;
+	    int cur_render_clock;
+
+	    max_render_clock = read_file_int("/sys/class/drm/card0/gt_max_freq_mhz");
+	    cur_render_clock = read_file_int("/sys/class/drm/card0/gt_cur_freq_mhz");
+
+	    print_clock("max render", max_render_clock);
+	    printf("  ");
+	    print_clock("current render", cur_render_clock);
 	}
 
 
-- 
2.0.1

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.




More information about the Intel-gfx mailing list