summaryrefslogtreecommitdiff
path: root/drivers/gpu/msm/adreno_profile.h
blob: 4d81abd14837a2ecb28ac00a53e0c0ecd2d7b591 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */
#ifndef __ADRENO_PROFILE_H
#define __ADRENO_PROFILE_H
#include <linux/seq_file.h>

/**
 * struct adreno_profile_assigns_list: linked list for assigned perf counters
 * @list: linkage  for nodes in list
 * @name: group name  or GPU name name
 * @groupid: group id
 * @countable: countable assigned to perfcounter
 * @offset: perfcounter register address offset
 */
struct adreno_profile_assigns_list {
	struct list_head list;
	char name[25];
	unsigned int groupid;
	unsigned int countable;
	unsigned int offset;    /* LO offset */
	unsigned int offset_hi; /* HI offset */
};

struct adreno_profile {
	struct list_head assignments_list; /* list of all assignments */
	unsigned int assignment_count;  /* Number of assigned counters */
	unsigned int *log_buffer;
	unsigned int *log_head;
	unsigned int *log_tail;
	bool enabled;
	/* counter, pre_ib, and post_ib held in one large circular buffer
	 * shared between kgsl and GPU
	 * counter entry 0
	 * pre_ib entry 0
	 * post_ib entry 0
	 * ...
	 * counter entry N
	 * pre_ib entry N
	 * post_ib entry N
	 */
	struct kgsl_memdesc shared_buffer;
	unsigned int shared_head;
	unsigned int shared_tail;
	unsigned int shared_size;
};

#define ADRENO_PROFILE_SHARED_BUF_SIZE_DWORDS (48 * 4096 / sizeof(uint))
/* sized @ 48 pages should allow for over 50 outstanding IBs minimum, 1755 max*/

#define ADRENO_PROFILE_LOG_BUF_SIZE  (1024 * 920)
/* sized for 1024 entries of fully assigned 45 cnters in log buffer, 230 pages*/
#define ADRENO_PROFILE_LOG_BUF_SIZE_DWORDS  (ADRENO_PROFILE_LOG_BUF_SIZE / \
						sizeof(unsigned int))

#ifdef CONFIG_DEBUG_FS
void adreno_profile_init(struct adreno_device *adreno_dev);
void adreno_profile_close(struct adreno_device *adreno_dev);
int adreno_profile_process_results(struct  adreno_device *adreno_dev);
void adreno_profile_preib_processing(struct adreno_device *adreno_dev,
		struct adreno_context *drawctxt, unsigned int *cmd_flags,
		unsigned int **rbptr);
void adreno_profile_postib_processing(struct  adreno_device *adreno_dev,
		unsigned int *cmd_flags, unsigned int **rbptr);
#else
static inline void adreno_profile_init(struct adreno_device *adreno_dev) { }
static inline void adreno_profile_close(struct adreno_device *adreno_dev) { }
static inline int adreno_profile_process_results(
		struct adreno_device *adreno_dev)
{
	return 0;
}

static inline void adreno_profile_preib_processing(
		struct adreno_device *adreno_dev,
		struct adreno_context *drawctxt, unsigned int *cmd_flags,
		unsigned int **rbptr) { }

static inline void adreno_profile_postib_processing(
		struct adreno_device *adreno_dev,
		unsigned int *cmd_flags, unsigned int **rbptr) { }
#endif

static inline bool adreno_profile_enabled(struct adreno_profile *profile)
{
	return profile->enabled;
}

static inline bool adreno_profile_has_assignments(
	struct adreno_profile *profile)
{
	return list_empty(&profile->assignments_list) ? false : true;
}

static inline bool adreno_profile_assignments_ready(
	struct adreno_profile *profile)
{
	return adreno_profile_enabled(profile) &&
		adreno_profile_has_assignments(profile);
}

#endif