diff mbox

[2/2] intel_gpu_top: Add param to force ring reads for busyness

Message ID 1456107838-2265-2-git-send-email-ben@bwidawsk.net (mailing list archive)
State New, archived
Headers show

Commit Message

Ben Widawsky Feb. 22, 2016, 2:23 a.m. UTC
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 man/intel_gpu_top.man |  3 +++
 tools/intel_gpu_top.c | 25 +++++++++++++++++--------
 2 files changed, 20 insertions(+), 8 deletions(-)
diff mbox

Patch

diff --git a/man/intel_gpu_top.man b/man/intel_gpu_top.man
index d90a7ee..be0f1be 100644
--- a/man/intel_gpu_top.man
+++ b/man/intel_gpu_top.man
@@ -24,6 +24,9 @@  and output statistics to stdout.
 execute a command, and leave when it is finished. Note that the entire command
 with all parameters should be included as one parameter.
 .TP
+.B -f
+force reading of ring busyness registers on HSW (may hang system).
+.TP
 .B -h
 show usage notes
 .SH EXAMPLES
diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
index 33a8e0c..ab154c8 100644
--- a/tools/intel_gpu_top.c
+++ b/tools/intel_gpu_top.c
@@ -324,13 +324,17 @@  static uint32_t ring_read(struct ring *ring, uint32_t reg)
 	return INREG(ring->mmio + reg);
 }
 
-static void ring_init(struct ring *ring, uint32_t devid)
+static void ring_init(struct ring *ring, uint32_t devid, bool ring_read_override)
 {
 	ring->size = (((ring_read(ring, RING_LEN) & RING_NR_PAGES) >> 12) + 1) * 4096;
 
 	if (IS_HASWELL(devid)) {
-		fprintf(stderr, "Skipping reads of head, and tail registers to avoid hangs\n");
-		ring->skip_ring_reads = true;
+		if (ring_read_override) {
+			fprintf(stderr, "Forcing reads of head, and tail registers may cause hangs\n");
+		} else {
+			fprintf(stderr, "Skipping reads of head, and tail registers to avoid hangs\n");
+			ring->skip_ring_reads = true;
+		}
 	}
 }
 
@@ -417,6 +421,7 @@  usage(const char *appname)
 			"[-e <command>]       command to profile\n"
 			"[-o <file>]          output statistics to file. If file is '-',"
 			"                     run in batch mode and output statistics to stdio only \n"
+			"[-f]                 force reading of ring busyness registers on HSW (may hang system)\n"
 			"[-h]                 show this help screen\n"
 			"\n",
 			appname,
@@ -451,9 +456,10 @@  int main(int argc, char **argv)
 	int child_stat;
 	char *cmd=NULL;
 	int interactive=1;
+	bool force_reads = false;
 
 	/* Parse options? */
-	while ((ch = getopt(argc, argv, "s:o:e:h")) != -1) {
+	while ((ch = getopt(argc, argv, "s:o:e:fh")) != -1) {
 		switch (ch) {
 		case 'e': cmd = strdup(optarg);
 			break;
@@ -477,6 +483,9 @@  int main(int argc, char **argv)
 				exit(1);
 			}
 			break;
+		case 'f':
+			force_reads = true;
+			break;
 		case 'h':
 			usage(argv[0]);
 			exit(0);
@@ -531,12 +540,12 @@  int main(int argc, char **argv)
 	/* Grab access to the registers */
 	intel_register_access_init(pci_dev, 0);
 
-	ring_init(&render_ring, devid);
+	ring_init(&render_ring, devid, force_reads);
 	if (IS_GEN4(devid) || IS_GEN5(devid))
-		ring_init(&bsd_ring, devid);
+		ring_init(&bsd_ring, devid, force_reads);
 	if (IS_GEN6(devid) || IS_GEN7(devid)) {
-		ring_init(&bsd6_ring, devid);
-		ring_init(&blt_ring, devid);
+		ring_init(&bsd6_ring, devid, force_reads);
+		ring_init(&blt_ring, devid, force_reads);
 	}
 
 	/* Initialize GPU stats */