overlay: Fill the blank charts with error messages
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 22 Aug 2013 10:59:58 +0000 (10:59 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Thu, 22 Aug 2013 10:59:58 +0000 (10:59 +0000)
Instead of showing nothing, show a "space left intentionally blank"
message.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
overlay/gpu-perf.c
overlay/gpu-perf.h
overlay/overlay.c

index d5e461c..b9ca11b 100644 (file)
@@ -301,8 +301,10 @@ void gpu_perf_init(struct gpu_perf *gp, unsigned flags)
                perf_tracepoint_open(gp, "i915", "i915_gem_request_wait_end", wait_end);
        perf_tracepoint_open(gp, "i915", "i915_flip_complete", flip_complete);
 
-       if (gp->nr_events == 0)
+       if (gp->nr_events == 0) {
+               gp->error = "i915.ko tracepoints not available";
                return;
+       }
 
        if (perf_mmap(gp))
                return;
index 3b91bd5..53699f7 100644 (file)
@@ -30,6 +30,7 @@
 #define MAX_RINGS 4
 
 struct gpu_perf {
+       const char *error;
        int page_size;
        int nr_cpus;
        int nr_events;
index 04ff5ee..e783a6f 100644 (file)
@@ -289,15 +289,26 @@ static void show_gpu_perf(struct overlay_context *ctx, struct overlay_gpu_perf *
        cairo_pattern_t *linear;
        int x, y, y1, y2, n;
 
+       cairo_rectangle(ctx->cr, ctx->width/2+6-.5, 12-.5, ctx->width/2-18+1, ctx->height/2-18+1);
+       cairo_set_source_rgb(ctx->cr, .15, .15, .15);
+       cairo_set_line_width(ctx->cr, 1);
+       cairo_stroke(ctx->cr);
+
+       if (gp->gpu_perf.error) {
+               cairo_text_extents_t extents;
+               cairo_text_extents(ctx->cr, gp->gpu_perf.error, &extents);
+               cairo_move_to(ctx->cr,
+                             ctx->width/2+6 + (ctx->width/2-18 - extents.width)/2.,
+                             12 + (ctx->height/2-18 + extents.height)/2.);
+               cairo_show_text(ctx->cr, gp->gpu_perf.error);
+               return;
+       }
+
        gpu_perf_update(&gp->gpu_perf);
 
        y = 12 + 12 - 2;
        x = ctx->width/2 + 6;
 
-       cairo_rectangle(ctx->cr, ctx->width/2+6-.5, 12-.5, ctx->width/2-18+1, ctx->height/2-18+1);
-       cairo_set_source_rgb(ctx->cr, .15, .15, .15);
-       cairo_set_line_width(ctx->cr, 1);
-       cairo_stroke(ctx->cr);
 
        for (comm = gp->gpu_perf.comm; comm; comm = comm->next) {
                int total;
@@ -495,6 +506,17 @@ static void show_gpu_freq(struct overlay_context *ctx, struct overlay_gpu_freq *
        cairo_set_line_width(ctx->cr, 1);
        cairo_stroke(ctx->cr);
 
+       if (gf->gpu_freq.error) {
+               const char *txt = "GPU frequency not found in debugfs";
+               cairo_text_extents_t extents;
+               cairo_text_extents(ctx->cr, txt, &extents);
+               cairo_move_to(ctx->cr,
+                             12 + (ctx->width/2-18 - extents.width)/2.,
+                             ctx->height/2+6 + (ctx->height/2-18 + extents.height)/2.);
+               cairo_show_text(ctx->cr, txt);
+               return;
+       }
+
        if (has_freq) {
                if (gf->gpu_freq.current)
                        chart_add_sample(&gf->current, gf->gpu_freq.current);