blob: b15f6c980d11a44a4806a098970a84d60193cecc [file] [log] [blame]
Robert Bragg5182f642017-06-13 12:23:02 +01001/*
2 * Autogenerated file by GPU Top : https://github.com/rib/gputop
3 * DO NOT EDIT manually!
4 *
5 *
6 * Copyright (c) 2015 Intel Corporation
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice (including the next
16 * paragraph) shall be included in all copies or substantial portions of the
17 * Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 * IN THE SOFTWARE.
26 *
27 */
28
29#include <linux/sysfs.h>
30
31#include "i915_drv.h"
32#include "i915_oa_chv.h"
33
34enum metric_set_id {
35 METRIC_SET_ID_RENDER_BASIC = 1,
36};
37
38int i915_oa_n_builtin_metric_sets_chv = 1;
39
40static const struct i915_oa_reg b_counter_config_render_basic[] = {
41 { _MMIO(0x2740), 0x00000000 },
42 { _MMIO(0x2710), 0x00000000 },
43 { _MMIO(0x2714), 0x00800000 },
44 { _MMIO(0x2720), 0x00000000 },
45 { _MMIO(0x2724), 0x00800000 },
46};
47
48static const struct i915_oa_reg flex_eu_config_render_basic[] = {
49 { _MMIO(0xe458), 0x00005004 },
50 { _MMIO(0xe558), 0x00010003 },
51 { _MMIO(0xe658), 0x00012011 },
52 { _MMIO(0xe758), 0x00015014 },
53 { _MMIO(0xe45c), 0x00051050 },
54 { _MMIO(0xe55c), 0x00053052 },
55 { _MMIO(0xe65c), 0x00055054 },
56};
57
58static const struct i915_oa_reg mux_config_render_basic[] = {
59 { _MMIO(0x9888), 0x59800000 },
60 { _MMIO(0x9888), 0x59800001 },
61 { _MMIO(0x9888), 0x285a0006 },
62 { _MMIO(0x9888), 0x2c110014 },
63 { _MMIO(0x9888), 0x2e110000 },
64 { _MMIO(0x9888), 0x2c310014 },
65 { _MMIO(0x9888), 0x2e310000 },
66 { _MMIO(0x9888), 0x2b8303df },
67 { _MMIO(0x9888), 0x3580024f },
68 { _MMIO(0x9888), 0x00580888 },
69 { _MMIO(0x9888), 0x1e5a0015 },
70 { _MMIO(0x9888), 0x205a0014 },
71 { _MMIO(0x9888), 0x045a0000 },
72 { _MMIO(0x9888), 0x025a0000 },
73 { _MMIO(0x9888), 0x02180500 },
74 { _MMIO(0x9888), 0x00190555 },
75 { _MMIO(0x9888), 0x021d0500 },
76 { _MMIO(0x9888), 0x021f0a00 },
77 { _MMIO(0x9888), 0x00380444 },
78 { _MMIO(0x9888), 0x02390500 },
79 { _MMIO(0x9888), 0x003a0666 },
80 { _MMIO(0x9888), 0x00100111 },
81 { _MMIO(0x9888), 0x06110030 },
82 { _MMIO(0x9888), 0x0a110031 },
83 { _MMIO(0x9888), 0x0e110046 },
84 { _MMIO(0x9888), 0x04110000 },
85 { _MMIO(0x9888), 0x00110000 },
86 { _MMIO(0x9888), 0x00130111 },
87 { _MMIO(0x9888), 0x00300444 },
88 { _MMIO(0x9888), 0x08310030 },
89 { _MMIO(0x9888), 0x0c310031 },
90 { _MMIO(0x9888), 0x10310046 },
91 { _MMIO(0x9888), 0x04310000 },
92 { _MMIO(0x9888), 0x00310000 },
93 { _MMIO(0x9888), 0x00330444 },
94 { _MMIO(0x9888), 0x038a0a00 },
95 { _MMIO(0x9888), 0x018b0fff },
96 { _MMIO(0x9888), 0x038b0a00 },
97 { _MMIO(0x9888), 0x01855000 },
98 { _MMIO(0x9888), 0x03850055 },
99 { _MMIO(0x9888), 0x13830021 },
100 { _MMIO(0x9888), 0x15830020 },
101 { _MMIO(0x9888), 0x1783002f },
102 { _MMIO(0x9888), 0x1983002e },
103 { _MMIO(0x9888), 0x1b83002d },
104 { _MMIO(0x9888), 0x1d83002c },
105 { _MMIO(0x9888), 0x05830000 },
106 { _MMIO(0x9888), 0x01840555 },
107 { _MMIO(0x9888), 0x03840500 },
108 { _MMIO(0x9888), 0x23800074 },
109 { _MMIO(0x9888), 0x2580007d },
110 { _MMIO(0x9888), 0x05800000 },
111 { _MMIO(0x9888), 0x01805000 },
112 { _MMIO(0x9888), 0x03800055 },
113 { _MMIO(0x9888), 0x01865000 },
114 { _MMIO(0x9888), 0x03860055 },
115 { _MMIO(0x9888), 0x01875000 },
116 { _MMIO(0x9888), 0x03870055 },
117 { _MMIO(0x9888), 0x418000aa },
118 { _MMIO(0x9888), 0x4380000a },
119 { _MMIO(0x9888), 0x45800000 },
120 { _MMIO(0x9888), 0x4780000a },
121 { _MMIO(0x9888), 0x49800000 },
122 { _MMIO(0x9888), 0x4b800000 },
123 { _MMIO(0x9888), 0x4d800000 },
124 { _MMIO(0x9888), 0x4f800000 },
125 { _MMIO(0x9888), 0x51800000 },
126 { _MMIO(0x9888), 0x53800000 },
127 { _MMIO(0x9888), 0x55800000 },
128 { _MMIO(0x9888), 0x57800000 },
129 { _MMIO(0x9888), 0x59800000 },
130};
131
132static int
133get_render_basic_mux_config(struct drm_i915_private *dev_priv,
134 const struct i915_oa_reg **regs,
135 int *lens)
136{
137 int n = 0;
138
139 BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs) < 1);
140 BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs_lens) < 1);
141
142 regs[n] = mux_config_render_basic;
143 lens[n] = ARRAY_SIZE(mux_config_render_basic);
144 n++;
145
146 return n;
147}
148
149int i915_oa_select_metric_set_chv(struct drm_i915_private *dev_priv)
150{
151 dev_priv->perf.oa.n_mux_configs = 0;
152 dev_priv->perf.oa.b_counter_regs = NULL;
153 dev_priv->perf.oa.b_counter_regs_len = 0;
154 dev_priv->perf.oa.flex_regs = NULL;
155 dev_priv->perf.oa.flex_regs_len = 0;
156
157 switch (dev_priv->perf.oa.metrics_set) {
158 case METRIC_SET_ID_RENDER_BASIC:
159 dev_priv->perf.oa.n_mux_configs =
160 get_render_basic_mux_config(dev_priv,
161 dev_priv->perf.oa.mux_regs,
162 dev_priv->perf.oa.mux_regs_lens);
163 if (dev_priv->perf.oa.n_mux_configs == 0) {
164 DRM_DEBUG_DRIVER("No suitable MUX config for \"RENDER_BASIC\" metric set\n");
165
166 /* EINVAL because *_register_sysfs already checked this
167 * and so it wouldn't have been advertised to userspace and
168 * so shouldn't have been requested
169 */
170 return -EINVAL;
171 }
172
173 dev_priv->perf.oa.b_counter_regs =
174 b_counter_config_render_basic;
175 dev_priv->perf.oa.b_counter_regs_len =
176 ARRAY_SIZE(b_counter_config_render_basic);
177
178 dev_priv->perf.oa.flex_regs =
179 flex_eu_config_render_basic;
180 dev_priv->perf.oa.flex_regs_len =
181 ARRAY_SIZE(flex_eu_config_render_basic);
182
183 return 0;
184 default:
185 return -ENODEV;
186 }
187}
188
189static ssize_t
190show_render_basic_id(struct device *kdev, struct device_attribute *attr, char *buf)
191{
192 return sprintf(buf, "%d\n", METRIC_SET_ID_RENDER_BASIC);
193}
194
195static struct device_attribute dev_attr_render_basic_id = {
196 .attr = { .name = "id", .mode = 0444 },
197 .show = show_render_basic_id,
198 .store = NULL,
199};
200
201static struct attribute *attrs_render_basic[] = {
202 &dev_attr_render_basic_id.attr,
203 NULL,
204};
205
206static struct attribute_group group_render_basic = {
207 .name = "9d8a3af5-c02c-4a4a-b947-f1672469e0fb",
208 .attrs = attrs_render_basic,
209};
210
211int
212i915_perf_register_sysfs_chv(struct drm_i915_private *dev_priv)
213{
214 const struct i915_oa_reg *mux_regs[ARRAY_SIZE(dev_priv->perf.oa.mux_regs)];
215 int mux_lens[ARRAY_SIZE(dev_priv->perf.oa.mux_regs_lens)];
216 int ret = 0;
217
218 if (get_render_basic_mux_config(dev_priv, mux_regs, mux_lens)) {
219 ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_render_basic);
220 if (ret)
221 goto error_render_basic;
222 }
223
224 return 0;
225
226error_render_basic:
227 return ret;
228}
229
230void
231i915_perf_unregister_sysfs_chv(struct drm_i915_private *dev_priv)
232{
233 const struct i915_oa_reg *mux_regs[ARRAY_SIZE(dev_priv->perf.oa.mux_regs)];
234 int mux_lens[ARRAY_SIZE(dev_priv->perf.oa.mux_regs_lens)];
235
236 if (get_render_basic_mux_config(dev_priv, mux_regs, mux_lens))
237 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_render_basic);
238}