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_PERF_H |
| 26 | #define GPU_PERF_H |
| 27 | |
Chris Wilson | cc45a9a | 2013-08-17 17:38:37 +0100 | [diff] [blame] | 28 | #include <stdint.h> |
Chris Wilson | eb799b2 | 2014-12-21 13:53:27 +0000 | [diff] [blame] | 29 | #include <stdbool.h> |
Chris Wilson | cc45a9a | 2013-08-17 17:38:37 +0100 | [diff] [blame] | 30 | |
Chris Wilson | 8ec8040 | 2017-02-23 09:59:01 +0000 | [diff] [blame] | 31 | #define MAX_RINGS 16 |
Chris Wilson | b20a6b8 | 2013-08-22 01:30:02 +0100 | [diff] [blame] | 32 | |
Chris Wilson | cc45a9a | 2013-08-17 17:38:37 +0100 | [diff] [blame] | 33 | struct gpu_perf { |
Chris Wilson | 1847869 | 2013-08-22 10:59:58 +0000 | [diff] [blame] | 34 | const char *error; |
Chris Wilson | cc45a9a | 2013-08-17 17:38:37 +0100 | [diff] [blame] | 35 | int page_size; |
| 36 | int nr_cpus; |
| 37 | int nr_events; |
| 38 | int *fd; |
| 39 | void **map; |
| 40 | struct gpu_perf_sample { |
| 41 | uint64_t id; |
Chris Wilson | 8cdb5bc | 2013-08-17 18:24:39 +0100 | [diff] [blame] | 42 | int (*func)(struct gpu_perf *, const void *); |
Chris Wilson | cc45a9a | 2013-08-17 17:38:37 +0100 | [diff] [blame] | 43 | } *sample; |
| 44 | |
Chris Wilson | 474ce53 | 2013-08-29 12:01:38 +0100 | [diff] [blame] | 45 | unsigned flip_complete[MAX_RINGS]; |
| 46 | unsigned ctx_switch[MAX_RINGS]; |
| 47 | |
Chris Wilson | cbbd55a | 2013-08-17 20:04:11 +0100 | [diff] [blame] | 48 | struct gpu_perf_comm { |
| 49 | struct gpu_perf_comm *next; |
| 50 | char name[256]; |
| 51 | pid_t pid; |
Chris Wilson | eb799b2 | 2014-12-21 13:53:27 +0000 | [diff] [blame] | 52 | bool active; |
Chris Wilson | 8ec8040 | 2017-02-23 09:59:01 +0000 | [diff] [blame] | 53 | int nr_requests[MAX_RINGS]; |
Chris Wilson | cc9de39 | 2013-08-17 20:32:58 +0100 | [diff] [blame] | 54 | void *user_data; |
Chris Wilson | eed59ea | 2013-08-17 21:14:10 +0100 | [diff] [blame] | 55 | |
Chris Wilson | eed59ea | 2013-08-17 21:14:10 +0100 | [diff] [blame] | 56 | uint64_t wait_time; |
Chris Wilson | 908df37 | 2013-08-26 14:11:27 +0100 | [diff] [blame] | 57 | uint32_t nr_sema; |
Chris Wilson | 2b961d9 | 2013-08-29 13:31:24 +0100 | [diff] [blame] | 58 | |
| 59 | time_t show; |
Chris Wilson | cbbd55a | 2013-08-17 20:04:11 +0100 | [diff] [blame] | 60 | } *comm; |
Chris Wilson | 67f533f | 2013-08-17 22:33:35 +0100 | [diff] [blame] | 61 | struct gpu_perf_time { |
| 62 | struct gpu_perf_time *next; |
| 63 | struct gpu_perf_comm *comm; |
Chris Wilson | 959b0c2 | 2017-05-10 15:06:44 +0100 | [diff] [blame] | 64 | uint32_t context; |
Chris Wilson | 67f533f | 2013-08-17 22:33:35 +0100 | [diff] [blame] | 65 | uint32_t seqno; |
| 66 | uint64_t time; |
Chris Wilson | b20a6b8 | 2013-08-22 01:30:02 +0100 | [diff] [blame] | 67 | } *wait[MAX_RINGS]; |
Chris Wilson | cc45a9a | 2013-08-17 17:38:37 +0100 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | void gpu_perf_init(struct gpu_perf *gp, unsigned flags); |
| 71 | int gpu_perf_update(struct gpu_perf *gp); |
Chris Wilson | b98bade | 2013-08-20 21:39:27 +0100 | [diff] [blame] | 72 | |
| 73 | #endif /* GPU_PERF_H */ |