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 
28 #include <stdint.h>
29 #include <stdbool.h>
30 
31 #define MAX_RINGS 16
32 
33 struct gpu_perf {
34 	const char *error;
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;
42 		int (*func)(struct gpu_perf *, const void *);
43 	} *sample;
44 
45 	unsigned flip_complete[MAX_RINGS];
46 	unsigned ctx_switch[MAX_RINGS];
47 
48 	struct gpu_perf_comm {
49 		struct gpu_perf_comm *next;
50 		char name[256];
51 		pid_t pid;
52 		bool active;
53 		int nr_requests[MAX_RINGS];
54 		void *user_data;
55 
56 		uint64_t wait_time;
57 		uint32_t nr_sema;
58 
59 		time_t show;
60 	} *comm;
61 	struct gpu_perf_time {
62 		struct gpu_perf_time *next;
63 		struct gpu_perf_comm *comm;
64 		uint32_t context;
65 		uint32_t seqno;
66 		uint64_t time;
67 	} *wait[MAX_RINGS];
68 };
69 
70 void gpu_perf_init(struct gpu_perf *gp, unsigned flags);
71 int gpu_perf_update(struct gpu_perf *gp);
72 
73 #endif /* GPU_PERF_H */
74