From c9f0173764c5266ebd29a3d57ea8a379440346b4 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 25 Aug 2013 20:13:31 +0100 Subject: overlay: Monitor interrupts Signed-off-by: Chris Wilson --- overlay/Makefile.am | 2 ++ overlay/gem-interrupts.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++ overlay/gem-interrupts.h | 38 +++++++++++++++++++++++ overlay/overlay.c | 19 +++++++++--- 4 files changed, 136 insertions(+), 4 deletions(-) create mode 100644 overlay/gem-interrupts.c create mode 100644 overlay/gem-interrupts.h (limited to 'overlay') diff --git a/overlay/Makefile.am b/overlay/Makefile.am index b01bf389..41f42cc8 100644 --- a/overlay/Makefile.am +++ b/overlay/Makefile.am @@ -15,6 +15,8 @@ intel_gpu_overlay_SOURCES = \ cpu-top.c \ debugfs.h \ debugfs.c \ + gem-interrupts.h \ + gem-interrupts.c \ gem-objects.h \ gem-objects.c \ gpu-top.h \ diff --git a/overlay/gem-interrupts.c b/overlay/gem-interrupts.c new file mode 100644 index 00000000..7377ee71 --- /dev/null +++ b/overlay/gem-interrupts.c @@ -0,0 +1,81 @@ +/* + * Copyright © 2013 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. + * + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "gem-interrupts.h" +#include "debugfs.h" + +int gem_interrupts_init(struct gem_interrupts *irqs) +{ + char buf[1024]; + struct stat st; + + + memset(irqs, 0, sizeof(*irqs)); + + sprintf(buf, "%s/i915_gem_interrupt", debugfs_dri_path); + if (stat(buf, &st)) + return irqs->error = errno; + + return 0; +} + +int gem_interrupts_update(struct gem_interrupts *irqs) +{ + char buf[8192], *b; + int fd, len; + + if (irqs->error) + return irqs->error; + + sprintf(buf, "%s/i915_gem_interrupt", debugfs_dri_path); + fd = open(buf, 0); + if (fd < 0) + return irqs->error = errno; + len = read(fd, buf, sizeof(buf)-1); + close(fd); + + if (len < 0) + return irqs->error = errno; + + buf[len] = '\0'; + + b = strstr(buf, "Interrupts received:"); + if (b == NULL) + return irqs->error = ENOENT; + + fd = irqs->last_count == 0; + irqs->last_count = irqs->count; + irqs->count = strtoull(b + sizeof("Interrupts received:"), 0, 0); + irqs->delta = irqs->count - irqs->last_count; + + return fd ? EAGAIN : 0; +} diff --git a/overlay/gem-interrupts.h b/overlay/gem-interrupts.h new file mode 100644 index 00000000..e9dbc4a9 --- /dev/null +++ b/overlay/gem-interrupts.h @@ -0,0 +1,38 @@ +/* + * Copyright © 2013 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. + * + */ + +#ifndef GEM_INTERRUPTS_H +#define GEM_INTERRUPTS_H + +#include + +struct gem_interrupts { + long unsigned last_count, count, delta; + int error; +}; + +int gem_interrupts_init(struct gem_interrupts *irqs); +int gem_interrupts_update(struct gem_interrupts *irqs); + +#endif /* GEM_INTERRUPTS_H */ diff --git a/overlay/overlay.c b/overlay/overlay.c index 67c4a86c..03e6ada8 100644 --- a/overlay/overlay.c +++ b/overlay/overlay.c @@ -40,6 +40,7 @@ #include "config.h" #include "cpu-top.h" #include "debugfs.h" +#include "gem-interrupts.h" #include "gem-objects.h" #include "gpu-freq.h" #include "gpu-top.h" @@ -101,6 +102,7 @@ struct overlay_gpu_perf { struct overlay_gpu_freq { struct gpu_freq gpu_freq; struct rc6 rc6; + struct gem_interrupts irqs; struct power power; struct chart current; struct chart request; @@ -489,6 +491,7 @@ static void init_gpu_freq(struct overlay_context *ctx, } rc6_init(&gf->rc6); + gem_interrupts_init(&gf->irqs); } static void show_gpu_freq(struct overlay_context *ctx, struct overlay_gpu_freq *gf) @@ -499,6 +502,7 @@ static void show_gpu_freq(struct overlay_context *ctx, struct overlay_gpu_freq * int has_freq = gpu_freq_update(&gf->gpu_freq) == 0; int has_rc6 = rc6_update(&gf->rc6) == 0; int has_power = power_update(&gf->power) == 0; + int has_irqs = gem_interrupts_update(&gf->irqs) == 0; cairo_pattern_t *linear; cairo_rectangle(ctx->cr, 12-.5, ctx->height/2+6-.5, ctx->width/2-18+1, ctx->height/2-18+1); @@ -545,12 +549,12 @@ static void show_gpu_freq(struct overlay_context *ctx, struct overlay_gpu_freq * y2 += 14; y2 += 14; } - if (has_rc6) { + if (has_rc6) y2 += 14; - } - if (has_power) { + if (has_power) + y2 += 14; + if (has_irqs) y2 += 14; - } y1 += -12 - 2; y2 += -14 + 4; @@ -612,6 +616,13 @@ static void show_gpu_freq(struct overlay_context *ctx, struct overlay_gpu_freq * cairo_show_text(ctx->cr, buf); y += 14; } + + if (has_irqs) { + sprintf(buf, "Interrupts: %llu", (long long unsigned)gf->irqs.delta); + cairo_move_to(ctx->cr, 12, y); + cairo_show_text(ctx->cr, buf); + y += 14; + } } static void init_gem_objects(struct overlay_context *ctx, -- cgit v1.2.3