Chris Wilson | b98bade | 2013-08-20 21:39:27 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2013 Intel Corporation |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice (including the next |
| 12 | * paragraph) shall be included in all copies or substantial portions of the |
| 13 | * Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 21 | * IN THE SOFTWARE. |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #ifndef GPU_TOP_H |
| 26 | #define GPU_TOP_H |
| 27 | |
Chris Wilson | f9a50de | 2013-08-17 11:12:07 +0100 | [diff] [blame] | 28 | #define MAX_RINGS 4 |
| 29 | |
| 30 | #include <stdint.h> |
| 31 | |
| 32 | struct gpu_top { |
Chris Wilson | 2e482a3 | 2013-08-20 19:11:44 +0100 | [diff] [blame] | 33 | enum { PERF, MMIO } type; |
Chris Wilson | f9a50de | 2013-08-17 11:12:07 +0100 | [diff] [blame] | 34 | int fd; |
Chris Wilson | 2e482a3 | 2013-08-20 19:11:44 +0100 | [diff] [blame] | 35 | |
Chris Wilson | f9a50de | 2013-08-17 11:12:07 +0100 | [diff] [blame] | 36 | int num_rings; |
Chris Wilson | 2e482a3 | 2013-08-20 19:11:44 +0100 | [diff] [blame] | 37 | int have_wait; |
| 38 | int have_sema; |
| 39 | |
Chris Wilson | f9a50de | 2013-08-17 11:12:07 +0100 | [diff] [blame] | 40 | struct gpu_top_ring { |
| 41 | const char *name; |
| 42 | union gpu_top_payload { |
| 43 | struct { |
| 44 | uint8_t busy; |
| 45 | uint8_t wait; |
| 46 | uint8_t sema; |
| 47 | } u; |
| 48 | uint32_t payload; |
| 49 | } u; |
| 50 | } ring[MAX_RINGS]; |
Chris Wilson | 2e482a3 | 2013-08-20 19:11:44 +0100 | [diff] [blame] | 51 | |
| 52 | struct gpu_top_stat { |
| 53 | uint64_t time; |
| 54 | uint64_t busy[MAX_RINGS]; |
| 55 | uint64_t wait[MAX_RINGS]; |
| 56 | uint64_t sema[MAX_RINGS]; |
| 57 | } stat[2]; |
| 58 | int count; |
Chris Wilson | f9a50de | 2013-08-17 11:12:07 +0100 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | void gpu_top_init(struct gpu_top *gt); |
| 62 | int gpu_top_update(struct gpu_top *gt); |
Chris Wilson | b98bade | 2013-08-20 21:39:27 +0100 | [diff] [blame] | 63 | |
| 64 | #endif /* GPU_TOP_H */ |