summaryrefslogtreecommitdiff
path: root/overlay/gpu-top.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-08-20 23:19:45 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-08-20 23:19:45 +0100
commita7b742092700b68d049597d1f25574cac41bb63a (patch)
treeec65748d1dee1b0701b162201517263d455ada8d /overlay/gpu-top.c
parent0b78c1632c88d2995baa0cdf40e120e628ea8a27 (diff)
overlay: Fix sampling of i915 perf event
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'overlay/gpu-top.c')
-rw-r--r--overlay/gpu-top.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/overlay/gpu-top.c b/overlay/gpu-top.c
index e7729779..d613553e 100644
--- a/overlay/gpu-top.c
+++ b/overlay/gpu-top.c
@@ -72,10 +72,12 @@ static uint64_t i915_type_id(void)
int fd, n;
fd = open("/sys/bus/event_source/devices/i915/type", 0);
- if (fd < 0)
- return 0;
- n = read(fd, buf, sizeof(buf)-1);
- close(fd);
+ if (fd < 0) {
+ n = -1;
+ } else {
+ n = read(fd, buf, sizeof(buf)-1);
+ close(fd);
+ }
if (n < 0)
return 0;
@@ -310,7 +312,7 @@ int gpu_top_update(struct gpu_top *gt)
struct gpu_top_stat *s = &gt->stat[gt->count++&1];
struct gpu_top_stat *d = &gt->stat[gt->count&1];
uint64_t *sample, d_time;
- int n;
+ int n, m;
len = read(gt->fd, data, sizeof(data));
if (len < 0)
@@ -319,12 +321,12 @@ int gpu_top_update(struct gpu_top *gt)
sample = (uint64_t *)data + 1;
s->time = *sample++;
- for (n = 0; n < gt->num_rings; n++) {
- s->busy[n] = sample[n];
+ for (n = m = 0; n < gt->num_rings; n++) {
+ s->busy[n] = sample[m++];
if (gt->have_wait)
- s->wait[n] = sample[n];
+ s->wait[n] = sample[m++];
if (gt->have_sema)
- s->sema[n] = sample[n];
+ s->sema[n] = sample[m++];
}
if (gt->count == 1)