]>
Commit | Line | Data |
---|---|---|
2cd46ad2 KW |
1 | /* |
2 | * Copyright 2015 Advanced Micro Devices, Inc. | |
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 shall be included in | |
12 | * all copies or substantial portions of the Software. | |
13 | * | |
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | |
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | |
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
20 | * OTHER DEALINGS IN THE SOFTWARE. | |
21 | * | |
22 | */ | |
23 | #include <linux/firmware.h> | |
24 | #include "amdgpu.h" | |
25 | #include "amdgpu_ih.h" | |
26 | #include "amdgpu_gfx.h" | |
27 | #include "amdgpu_ucode.h" | |
28 | #include "si/clearstate_si.h" | |
25069e06 TSD |
29 | #include "bif/bif_3_0_d.h" |
30 | #include "bif/bif_3_0_sh_mask.h" | |
31 | #include "oss/oss_1_0_d.h" | |
32 | #include "oss/oss_1_0_sh_mask.h" | |
33 | #include "gca/gfx_6_0_d.h" | |
34 | #include "gca/gfx_6_0_sh_mask.h" | |
35 | #include "gmc/gmc_6_0_d.h" | |
36 | #include "gmc/gmc_6_0_sh_mask.h" | |
37 | #include "dce/dce_6_0_d.h" | |
38 | #include "dce/dce_6_0_sh_mask.h" | |
39 | #include "gca/gfx_7_2_enum.h" | |
40 | #include "si_enums.h" | |
2cd46ad2 KW |
41 | |
42 | static void gfx_v6_0_set_ring_funcs(struct amdgpu_device *adev); | |
43 | static void gfx_v6_0_set_irq_funcs(struct amdgpu_device *adev); | |
44 | static void gfx_v6_0_get_cu_info(struct amdgpu_device *adev); | |
45 | ||
46 | MODULE_FIRMWARE("radeon/tahiti_pfp.bin"); | |
47 | MODULE_FIRMWARE("radeon/tahiti_me.bin"); | |
48 | MODULE_FIRMWARE("radeon/tahiti_ce.bin"); | |
49 | MODULE_FIRMWARE("radeon/tahiti_rlc.bin"); | |
50 | ||
51 | MODULE_FIRMWARE("radeon/pitcairn_pfp.bin"); | |
52 | MODULE_FIRMWARE("radeon/pitcairn_me.bin"); | |
53 | MODULE_FIRMWARE("radeon/pitcairn_ce.bin"); | |
54 | MODULE_FIRMWARE("radeon/pitcairn_rlc.bin"); | |
55 | ||
56 | MODULE_FIRMWARE("radeon/verde_pfp.bin"); | |
57 | MODULE_FIRMWARE("radeon/verde_me.bin"); | |
58 | MODULE_FIRMWARE("radeon/verde_ce.bin"); | |
59 | MODULE_FIRMWARE("radeon/verde_rlc.bin"); | |
60 | ||
61 | MODULE_FIRMWARE("radeon/oland_pfp.bin"); | |
62 | MODULE_FIRMWARE("radeon/oland_me.bin"); | |
63 | MODULE_FIRMWARE("radeon/oland_ce.bin"); | |
64 | MODULE_FIRMWARE("radeon/oland_rlc.bin"); | |
65 | ||
66 | MODULE_FIRMWARE("radeon/hainan_pfp.bin"); | |
67 | MODULE_FIRMWARE("radeon/hainan_me.bin"); | |
68 | MODULE_FIRMWARE("radeon/hainan_ce.bin"); | |
69 | MODULE_FIRMWARE("radeon/hainan_rlc.bin"); | |
70 | ||
71 | static u32 gfx_v6_0_get_csb_size(struct amdgpu_device *adev); | |
72 | static void gfx_v6_0_get_csb_buffer(struct amdgpu_device *adev, volatile u32 *buffer); | |
73 | //static void gfx_v6_0_init_cp_pg_table(struct amdgpu_device *adev); | |
74 | static void gfx_v6_0_init_pg(struct amdgpu_device *adev); | |
75 | ||
25069e06 TSD |
76 | #define ARRAY_MODE(x) ((x) << GB_TILE_MODE0__ARRAY_MODE__SHIFT) |
77 | #define PIPE_CONFIG(x) ((x) << GB_TILE_MODE0__PIPE_CONFIG__SHIFT) | |
78 | #define TILE_SPLIT(x) ((x) << GB_TILE_MODE0__TILE_SPLIT__SHIFT) | |
79 | #define MICRO_TILE_MODE(x) ((x) << 0) | |
80 | #define SAMPLE_SPLIT(x) ((x) << GB_TILE_MODE0__SAMPLE_SPLIT__SHIFT) | |
81 | #define BANK_WIDTH(x) ((x) << 14) | |
82 | #define BANK_HEIGHT(x) ((x) << 16) | |
83 | #define MACRO_TILE_ASPECT(x) ((x) << 18) | |
84 | #define NUM_BANKS(x) ((x) << 20) | |
2cd46ad2 KW |
85 | |
86 | static const u32 verde_rlc_save_restore_register_list[] = | |
87 | { | |
88 | (0x8000 << 16) | (0x98f4 >> 2), | |
89 | 0x00000000, | |
90 | (0x8040 << 16) | (0x98f4 >> 2), | |
91 | 0x00000000, | |
92 | (0x8000 << 16) | (0xe80 >> 2), | |
93 | 0x00000000, | |
94 | (0x8040 << 16) | (0xe80 >> 2), | |
95 | 0x00000000, | |
96 | (0x8000 << 16) | (0x89bc >> 2), | |
97 | 0x00000000, | |
98 | (0x8040 << 16) | (0x89bc >> 2), | |
99 | 0x00000000, | |
100 | (0x8000 << 16) | (0x8c1c >> 2), | |
101 | 0x00000000, | |
102 | (0x8040 << 16) | (0x8c1c >> 2), | |
103 | 0x00000000, | |
104 | (0x9c00 << 16) | (0x98f0 >> 2), | |
105 | 0x00000000, | |
106 | (0x9c00 << 16) | (0xe7c >> 2), | |
107 | 0x00000000, | |
108 | (0x8000 << 16) | (0x9148 >> 2), | |
109 | 0x00000000, | |
110 | (0x8040 << 16) | (0x9148 >> 2), | |
111 | 0x00000000, | |
112 | (0x9c00 << 16) | (0x9150 >> 2), | |
113 | 0x00000000, | |
114 | (0x9c00 << 16) | (0x897c >> 2), | |
115 | 0x00000000, | |
116 | (0x9c00 << 16) | (0x8d8c >> 2), | |
117 | 0x00000000, | |
118 | (0x9c00 << 16) | (0xac54 >> 2), | |
119 | 0X00000000, | |
120 | 0x3, | |
121 | (0x9c00 << 16) | (0x98f8 >> 2), | |
122 | 0x00000000, | |
123 | (0x9c00 << 16) | (0x9910 >> 2), | |
124 | 0x00000000, | |
125 | (0x9c00 << 16) | (0x9914 >> 2), | |
126 | 0x00000000, | |
127 | (0x9c00 << 16) | (0x9918 >> 2), | |
128 | 0x00000000, | |
129 | (0x9c00 << 16) | (0x991c >> 2), | |
130 | 0x00000000, | |
131 | (0x9c00 << 16) | (0x9920 >> 2), | |
132 | 0x00000000, | |
133 | (0x9c00 << 16) | (0x9924 >> 2), | |
134 | 0x00000000, | |
135 | (0x9c00 << 16) | (0x9928 >> 2), | |
136 | 0x00000000, | |
137 | (0x9c00 << 16) | (0x992c >> 2), | |
138 | 0x00000000, | |
139 | (0x9c00 << 16) | (0x9930 >> 2), | |
140 | 0x00000000, | |
141 | (0x9c00 << 16) | (0x9934 >> 2), | |
142 | 0x00000000, | |
143 | (0x9c00 << 16) | (0x9938 >> 2), | |
144 | 0x00000000, | |
145 | (0x9c00 << 16) | (0x993c >> 2), | |
146 | 0x00000000, | |
147 | (0x9c00 << 16) | (0x9940 >> 2), | |
148 | 0x00000000, | |
149 | (0x9c00 << 16) | (0x9944 >> 2), | |
150 | 0x00000000, | |
151 | (0x9c00 << 16) | (0x9948 >> 2), | |
152 | 0x00000000, | |
153 | (0x9c00 << 16) | (0x994c >> 2), | |
154 | 0x00000000, | |
155 | (0x9c00 << 16) | (0x9950 >> 2), | |
156 | 0x00000000, | |
157 | (0x9c00 << 16) | (0x9954 >> 2), | |
158 | 0x00000000, | |
159 | (0x9c00 << 16) | (0x9958 >> 2), | |
160 | 0x00000000, | |
161 | (0x9c00 << 16) | (0x995c >> 2), | |
162 | 0x00000000, | |
163 | (0x9c00 << 16) | (0x9960 >> 2), | |
164 | 0x00000000, | |
165 | (0x9c00 << 16) | (0x9964 >> 2), | |
166 | 0x00000000, | |
167 | (0x9c00 << 16) | (0x9968 >> 2), | |
168 | 0x00000000, | |
169 | (0x9c00 << 16) | (0x996c >> 2), | |
170 | 0x00000000, | |
171 | (0x9c00 << 16) | (0x9970 >> 2), | |
172 | 0x00000000, | |
173 | (0x9c00 << 16) | (0x9974 >> 2), | |
174 | 0x00000000, | |
175 | (0x9c00 << 16) | (0x9978 >> 2), | |
176 | 0x00000000, | |
177 | (0x9c00 << 16) | (0x997c >> 2), | |
178 | 0x00000000, | |
179 | (0x9c00 << 16) | (0x9980 >> 2), | |
180 | 0x00000000, | |
181 | (0x9c00 << 16) | (0x9984 >> 2), | |
182 | 0x00000000, | |
183 | (0x9c00 << 16) | (0x9988 >> 2), | |
184 | 0x00000000, | |
185 | (0x9c00 << 16) | (0x998c >> 2), | |
186 | 0x00000000, | |
187 | (0x9c00 << 16) | (0x8c00 >> 2), | |
188 | 0x00000000, | |
189 | (0x9c00 << 16) | (0x8c14 >> 2), | |
190 | 0x00000000, | |
191 | (0x9c00 << 16) | (0x8c04 >> 2), | |
192 | 0x00000000, | |
193 | (0x9c00 << 16) | (0x8c08 >> 2), | |
194 | 0x00000000, | |
195 | (0x8000 << 16) | (0x9b7c >> 2), | |
196 | 0x00000000, | |
197 | (0x8040 << 16) | (0x9b7c >> 2), | |
198 | 0x00000000, | |
199 | (0x8000 << 16) | (0xe84 >> 2), | |
200 | 0x00000000, | |
201 | (0x8040 << 16) | (0xe84 >> 2), | |
202 | 0x00000000, | |
203 | (0x8000 << 16) | (0x89c0 >> 2), | |
204 | 0x00000000, | |
205 | (0x8040 << 16) | (0x89c0 >> 2), | |
206 | 0x00000000, | |
207 | (0x8000 << 16) | (0x914c >> 2), | |
208 | 0x00000000, | |
209 | (0x8040 << 16) | (0x914c >> 2), | |
210 | 0x00000000, | |
211 | (0x8000 << 16) | (0x8c20 >> 2), | |
212 | 0x00000000, | |
213 | (0x8040 << 16) | (0x8c20 >> 2), | |
214 | 0x00000000, | |
215 | (0x8000 << 16) | (0x9354 >> 2), | |
216 | 0x00000000, | |
217 | (0x8040 << 16) | (0x9354 >> 2), | |
218 | 0x00000000, | |
219 | (0x9c00 << 16) | (0x9060 >> 2), | |
220 | 0x00000000, | |
221 | (0x9c00 << 16) | (0x9364 >> 2), | |
222 | 0x00000000, | |
223 | (0x9c00 << 16) | (0x9100 >> 2), | |
224 | 0x00000000, | |
225 | (0x9c00 << 16) | (0x913c >> 2), | |
226 | 0x00000000, | |
227 | (0x8000 << 16) | (0x90e0 >> 2), | |
228 | 0x00000000, | |
229 | (0x8000 << 16) | (0x90e4 >> 2), | |
230 | 0x00000000, | |
231 | (0x8000 << 16) | (0x90e8 >> 2), | |
232 | 0x00000000, | |
233 | (0x8040 << 16) | (0x90e0 >> 2), | |
234 | 0x00000000, | |
235 | (0x8040 << 16) | (0x90e4 >> 2), | |
236 | 0x00000000, | |
237 | (0x8040 << 16) | (0x90e8 >> 2), | |
238 | 0x00000000, | |
239 | (0x9c00 << 16) | (0x8bcc >> 2), | |
240 | 0x00000000, | |
241 | (0x9c00 << 16) | (0x8b24 >> 2), | |
242 | 0x00000000, | |
243 | (0x9c00 << 16) | (0x88c4 >> 2), | |
244 | 0x00000000, | |
245 | (0x9c00 << 16) | (0x8e50 >> 2), | |
246 | 0x00000000, | |
247 | (0x9c00 << 16) | (0x8c0c >> 2), | |
248 | 0x00000000, | |
249 | (0x9c00 << 16) | (0x8e58 >> 2), | |
250 | 0x00000000, | |
251 | (0x9c00 << 16) | (0x8e5c >> 2), | |
252 | 0x00000000, | |
253 | (0x9c00 << 16) | (0x9508 >> 2), | |
254 | 0x00000000, | |
255 | (0x9c00 << 16) | (0x950c >> 2), | |
256 | 0x00000000, | |
257 | (0x9c00 << 16) | (0x9494 >> 2), | |
258 | 0x00000000, | |
259 | (0x9c00 << 16) | (0xac0c >> 2), | |
260 | 0x00000000, | |
261 | (0x9c00 << 16) | (0xac10 >> 2), | |
262 | 0x00000000, | |
263 | (0x9c00 << 16) | (0xac14 >> 2), | |
264 | 0x00000000, | |
265 | (0x9c00 << 16) | (0xae00 >> 2), | |
266 | 0x00000000, | |
267 | (0x9c00 << 16) | (0xac08 >> 2), | |
268 | 0x00000000, | |
269 | (0x9c00 << 16) | (0x88d4 >> 2), | |
270 | 0x00000000, | |
271 | (0x9c00 << 16) | (0x88c8 >> 2), | |
272 | 0x00000000, | |
273 | (0x9c00 << 16) | (0x88cc >> 2), | |
274 | 0x00000000, | |
275 | (0x9c00 << 16) | (0x89b0 >> 2), | |
276 | 0x00000000, | |
277 | (0x9c00 << 16) | (0x8b10 >> 2), | |
278 | 0x00000000, | |
279 | (0x9c00 << 16) | (0x8a14 >> 2), | |
280 | 0x00000000, | |
281 | (0x9c00 << 16) | (0x9830 >> 2), | |
282 | 0x00000000, | |
283 | (0x9c00 << 16) | (0x9834 >> 2), | |
284 | 0x00000000, | |
285 | (0x9c00 << 16) | (0x9838 >> 2), | |
286 | 0x00000000, | |
287 | (0x9c00 << 16) | (0x9a10 >> 2), | |
288 | 0x00000000, | |
289 | (0x8000 << 16) | (0x9870 >> 2), | |
290 | 0x00000000, | |
291 | (0x8000 << 16) | (0x9874 >> 2), | |
292 | 0x00000000, | |
293 | (0x8001 << 16) | (0x9870 >> 2), | |
294 | 0x00000000, | |
295 | (0x8001 << 16) | (0x9874 >> 2), | |
296 | 0x00000000, | |
297 | (0x8040 << 16) | (0x9870 >> 2), | |
298 | 0x00000000, | |
299 | (0x8040 << 16) | (0x9874 >> 2), | |
300 | 0x00000000, | |
301 | (0x8041 << 16) | (0x9870 >> 2), | |
302 | 0x00000000, | |
303 | (0x8041 << 16) | (0x9874 >> 2), | |
304 | 0x00000000, | |
305 | 0x00000000 | |
306 | }; | |
307 | ||
308 | static int gfx_v6_0_init_microcode(struct amdgpu_device *adev) | |
309 | { | |
310 | const char *chip_name; | |
311 | char fw_name[30]; | |
312 | int err; | |
313 | const struct gfx_firmware_header_v1_0 *cp_hdr; | |
314 | const struct rlc_firmware_header_v1_0 *rlc_hdr; | |
315 | ||
316 | DRM_DEBUG("\n"); | |
317 | ||
318 | switch (adev->asic_type) { | |
319 | case CHIP_TAHITI: | |
320 | chip_name = "tahiti"; | |
321 | break; | |
322 | case CHIP_PITCAIRN: | |
323 | chip_name = "pitcairn"; | |
324 | break; | |
325 | case CHIP_VERDE: | |
326 | chip_name = "verde"; | |
327 | break; | |
328 | case CHIP_OLAND: | |
329 | chip_name = "oland"; | |
330 | break; | |
331 | case CHIP_HAINAN: | |
332 | chip_name = "hainan"; | |
333 | break; | |
334 | default: BUG(); | |
335 | } | |
336 | ||
337 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name); | |
338 | err = request_firmware(&adev->gfx.pfp_fw, fw_name, adev->dev); | |
339 | if (err) | |
340 | goto out; | |
341 | err = amdgpu_ucode_validate(adev->gfx.pfp_fw); | |
342 | if (err) | |
343 | goto out; | |
344 | cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.pfp_fw->data; | |
345 | adev->gfx.pfp_fw_version = le32_to_cpu(cp_hdr->header.ucode_version); | |
346 | adev->gfx.pfp_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version); | |
347 | ||
348 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name); | |
349 | err = request_firmware(&adev->gfx.me_fw, fw_name, adev->dev); | |
350 | if (err) | |
351 | goto out; | |
352 | err = amdgpu_ucode_validate(adev->gfx.me_fw); | |
353 | if (err) | |
354 | goto out; | |
355 | cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.me_fw->data; | |
356 | adev->gfx.me_fw_version = le32_to_cpu(cp_hdr->header.ucode_version); | |
357 | adev->gfx.me_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version); | |
358 | ||
359 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_ce.bin", chip_name); | |
360 | err = request_firmware(&adev->gfx.ce_fw, fw_name, adev->dev); | |
361 | if (err) | |
362 | goto out; | |
363 | err = amdgpu_ucode_validate(adev->gfx.ce_fw); | |
364 | if (err) | |
365 | goto out; | |
366 | cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.ce_fw->data; | |
367 | adev->gfx.ce_fw_version = le32_to_cpu(cp_hdr->header.ucode_version); | |
368 | adev->gfx.ce_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version); | |
369 | ||
370 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", chip_name); | |
371 | err = request_firmware(&adev->gfx.rlc_fw, fw_name, adev->dev); | |
372 | if (err) | |
373 | goto out; | |
374 | err = amdgpu_ucode_validate(adev->gfx.rlc_fw); | |
375 | rlc_hdr = (const struct rlc_firmware_header_v1_0 *)adev->gfx.rlc_fw->data; | |
376 | adev->gfx.rlc_fw_version = le32_to_cpu(rlc_hdr->header.ucode_version); | |
377 | adev->gfx.rlc_feature_version = le32_to_cpu(rlc_hdr->ucode_feature_version); | |
378 | ||
379 | out: | |
380 | if (err) { | |
381 | printk(KERN_ERR | |
382 | "gfx6: Failed to load firmware \"%s\"\n", | |
383 | fw_name); | |
384 | release_firmware(adev->gfx.pfp_fw); | |
385 | adev->gfx.pfp_fw = NULL; | |
386 | release_firmware(adev->gfx.me_fw); | |
387 | adev->gfx.me_fw = NULL; | |
388 | release_firmware(adev->gfx.ce_fw); | |
389 | adev->gfx.ce_fw = NULL; | |
390 | release_firmware(adev->gfx.rlc_fw); | |
391 | adev->gfx.rlc_fw = NULL; | |
392 | } | |
393 | return err; | |
394 | } | |
395 | ||
396 | static void gfx_v6_0_tiling_mode_table_init(struct amdgpu_device *adev) | |
397 | { | |
398 | const u32 num_tile_mode_states = 32; | |
399 | u32 reg_offset, gb_tile_moden, split_equal_to_row_size; | |
400 | ||
401 | switch (adev->gfx.config.mem_row_size_in_kb) { | |
402 | case 1: | |
403 | split_equal_to_row_size = ADDR_SURF_TILE_SPLIT_1KB; | |
404 | break; | |
405 | case 2: | |
406 | default: | |
407 | split_equal_to_row_size = ADDR_SURF_TILE_SPLIT_2KB; | |
408 | break; | |
409 | case 4: | |
410 | split_equal_to_row_size = ADDR_SURF_TILE_SPLIT_4KB; | |
411 | break; | |
412 | } | |
413 | ||
3548f9a8 FC |
414 | if (adev->asic_type == CHIP_VERDE) { |
415 | for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++) { | |
416 | switch (reg_offset) { | |
417 | case 0: | |
418 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | |
419 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
420 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
421 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) | | |
422 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
423 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
424 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | | |
425 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
426 | break; | |
427 | case 1: | |
428 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | |
429 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
430 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
431 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B) | | |
432 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
433 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
434 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | | |
435 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
436 | break; | |
437 | case 2: | |
438 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | |
439 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
440 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
441 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | |
442 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
443 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
444 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | | |
445 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
446 | break; | |
447 | case 3: | |
448 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | |
449 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
450 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
451 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
452 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | |
453 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
454 | NUM_BANKS(ADDR_SURF_8_BANK) | | |
455 | TILE_SPLIT(split_equal_to_row_size)); | |
456 | break; | |
457 | case 4: | |
458 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | |
459 | ARRAY_MODE(ARRAY_1D_TILED_THIN1) | | |
460 | PIPE_CONFIG(ADDR_SURF_P4_8x16)); | |
461 | break; | |
462 | case 5: | |
463 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | |
464 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
465 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
466 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) | | |
467 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
468 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | |
469 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
470 | NUM_BANKS(ADDR_SURF_4_BANK)); | |
471 | break; | |
472 | case 6: | |
473 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | |
474 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
475 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
476 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | |
477 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
478 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
479 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
480 | NUM_BANKS(ADDR_SURF_4_BANK)); | |
481 | break; | |
482 | case 7: | |
483 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | |
484 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
485 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
486 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) | | |
487 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
488 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
489 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
490 | NUM_BANKS(ADDR_SURF_2_BANK)); | |
491 | break; | |
492 | case 8: | |
493 | gb_tile_moden = (ARRAY_MODE(ARRAY_LINEAR_ALIGNED)); | |
494 | break; | |
495 | case 9: | |
496 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) | | |
497 | ARRAY_MODE(ARRAY_1D_TILED_THIN1) | | |
498 | PIPE_CONFIG(ADDR_SURF_P4_8x16)); | |
499 | break; | |
500 | case 10: | |
501 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) | | |
502 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
503 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
504 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | |
505 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
506 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
507 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | | |
508 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
509 | break; | |
510 | case 11: | |
511 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) | | |
512 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
513 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
514 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | |
515 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
516 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | |
517 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | | |
518 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
519 | break; | |
520 | case 12: | |
521 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) | | |
522 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
523 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
524 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) | | |
525 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
526 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | |
527 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | | |
528 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
529 | break; | |
530 | case 13: | |
531 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
532 | ARRAY_MODE(ARRAY_1D_TILED_THIN1) | | |
533 | PIPE_CONFIG(ADDR_SURF_P4_8x16)); | |
534 | break; | |
535 | case 14: | |
536 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
537 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
538 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
539 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | |
540 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
541 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
542 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | | |
543 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
544 | break; | |
545 | case 15: | |
546 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
547 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
548 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
549 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | |
550 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
551 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | |
552 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | | |
553 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
554 | break; | |
555 | case 16: | |
556 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
557 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
558 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
559 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) | | |
560 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
561 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | |
562 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | | |
563 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
564 | break; | |
565 | case 17: | |
566 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
567 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
568 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
569 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
570 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | |
571 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | | |
572 | NUM_BANKS(ADDR_SURF_16_BANK) | | |
573 | TILE_SPLIT(split_equal_to_row_size)); | |
574 | break; | |
575 | case 18: | |
576 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
577 | ARRAY_MODE(ARRAY_1D_TILED_THICK) | | |
578 | PIPE_CONFIG(ADDR_SURF_P4_8x16)); | |
579 | break; | |
580 | case 19: | |
581 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
582 | ARRAY_MODE(ARRAY_2D_TILED_XTHICK) | | |
583 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
584 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
585 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | |
586 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | | |
587 | NUM_BANKS(ADDR_SURF_16_BANK) | | |
588 | TILE_SPLIT(split_equal_to_row_size)); | |
589 | break; | |
590 | case 20: | |
591 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
592 | ARRAY_MODE(ARRAY_2D_TILED_THICK) | | |
593 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
594 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
595 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | |
596 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | | |
597 | NUM_BANKS(ADDR_SURF_16_BANK) | | |
598 | TILE_SPLIT(split_equal_to_row_size)); | |
599 | break; | |
600 | case 21: | |
601 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
602 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
603 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
604 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | |
605 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
606 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
607 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
608 | NUM_BANKS(ADDR_SURF_8_BANK)); | |
609 | break; | |
610 | case 22: | |
611 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
612 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
613 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
614 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | |
615 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
616 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | |
617 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
618 | NUM_BANKS(ADDR_SURF_8_BANK)); | |
619 | break; | |
620 | case 23: | |
621 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
622 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
623 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
624 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | |
625 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
626 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
627 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
628 | NUM_BANKS(ADDR_SURF_4_BANK)); | |
629 | break; | |
630 | case 24: | |
631 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
632 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
633 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
634 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) | | |
635 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
636 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | |
637 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
638 | NUM_BANKS(ADDR_SURF_4_BANK)); | |
639 | break; | |
640 | case 25: | |
641 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
642 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
643 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
644 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) | | |
645 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
646 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
647 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
648 | NUM_BANKS(ADDR_SURF_2_BANK)); | |
649 | break; | |
650 | case 26: | |
651 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
652 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
653 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
654 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) | | |
655 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
656 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
657 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
658 | NUM_BANKS(ADDR_SURF_2_BANK)); | |
659 | break; | |
660 | case 27: | |
661 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
662 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
663 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
664 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) | | |
665 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
666 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
667 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
668 | NUM_BANKS(ADDR_SURF_2_BANK)); | |
669 | break; | |
670 | case 28: | |
671 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
672 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
673 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
674 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) | | |
675 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
676 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
677 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
678 | NUM_BANKS(ADDR_SURF_2_BANK)); | |
679 | break; | |
680 | case 29: | |
681 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
682 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
683 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
684 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) | | |
685 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
686 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
687 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
688 | NUM_BANKS(ADDR_SURF_2_BANK)); | |
689 | break; | |
690 | case 30: | |
691 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
692 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
693 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
694 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_2KB) | | |
695 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
696 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | |
697 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
698 | NUM_BANKS(ADDR_SURF_2_BANK)); | |
699 | break; | |
700 | default: | |
701 | continue; | |
702 | } | |
703 | adev->gfx.config.tile_mode_array[reg_offset] = gb_tile_moden; | |
704 | WREG32(mmGB_TILE_MODE0 + reg_offset, gb_tile_moden); | |
705 | } | |
706 | } else if (adev->asic_type == CHIP_OLAND || | |
25069e06 | 707 | adev->asic_type == CHIP_HAINAN) { |
2cd46ad2 KW |
708 | for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++) { |
709 | switch (reg_offset) { | |
710 | case 0: | |
f8d9422e FC |
711 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | |
712 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
713 | PIPE_CONFIG(ADDR_SURF_P2) | | |
2cd46ad2 | 714 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) | |
2cd46ad2 KW |
715 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
716 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
f8d9422e FC |
717 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
718 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
2cd46ad2 | 719 | break; |
45682886 | 720 | case 1: |
f8d9422e FC |
721 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | |
722 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
723 | PIPE_CONFIG(ADDR_SURF_P2) | | |
2cd46ad2 | 724 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B) | |
2cd46ad2 KW |
725 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
726 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
f8d9422e FC |
727 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
728 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
2cd46ad2 KW |
729 | break; |
730 | case 2: | |
f8d9422e FC |
731 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | |
732 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
733 | PIPE_CONFIG(ADDR_SURF_P2) | | |
2cd46ad2 | 734 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | |
2cd46ad2 KW |
735 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
736 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
f8d9422e FC |
737 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
738 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
2cd46ad2 | 739 | break; |
45682886 | 740 | case 3: |
f8d9422e FC |
741 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | |
742 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
743 | PIPE_CONFIG(ADDR_SURF_P2) | | |
2cd46ad2 | 744 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
f8d9422e FC |
745 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | |
746 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
747 | NUM_BANKS(ADDR_SURF_8_BANK) | | |
748 | TILE_SPLIT(split_equal_to_row_size)); | |
2cd46ad2 | 749 | break; |
45682886 | 750 | case 4: |
f8d9422e FC |
751 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | |
752 | ARRAY_MODE(ARRAY_1D_TILED_THIN1) | | |
753 | PIPE_CONFIG(ADDR_SURF_P2)); | |
2cd46ad2 | 754 | break; |
45682886 | 755 | case 5: |
f8d9422e FC |
756 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | |
757 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
758 | PIPE_CONFIG(ADDR_SURF_P2) | | |
759 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) | | |
2cd46ad2 | 760 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
f8d9422e FC |
761 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
762 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
763 | NUM_BANKS(ADDR_SURF_8_BANK)); | |
2cd46ad2 | 764 | break; |
45682886 | 765 | case 6: |
f8d9422e FC |
766 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | |
767 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
768 | PIPE_CONFIG(ADDR_SURF_P2) | | |
769 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | |
2cd46ad2 | 770 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
f8d9422e FC |
771 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | |
772 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
773 | NUM_BANKS(ADDR_SURF_8_BANK)); | |
2cd46ad2 | 774 | break; |
45682886 | 775 | case 7: |
f8d9422e FC |
776 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | |
777 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
778 | PIPE_CONFIG(ADDR_SURF_P2) | | |
779 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) | | |
2cd46ad2 | 780 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
f8d9422e FC |
781 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | |
782 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
783 | NUM_BANKS(ADDR_SURF_4_BANK)); | |
2cd46ad2 | 784 | break; |
45682886 | 785 | case 8: |
f8d9422e | 786 | gb_tile_moden = (ARRAY_MODE(ARRAY_LINEAR_ALIGNED)); |
2cd46ad2 | 787 | break; |
45682886 | 788 | case 9: |
f8d9422e FC |
789 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) | |
790 | ARRAY_MODE(ARRAY_1D_TILED_THIN1) | | |
791 | PIPE_CONFIG(ADDR_SURF_P2)); | |
2cd46ad2 | 792 | break; |
45682886 | 793 | case 10: |
f8d9422e FC |
794 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) | |
795 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
796 | PIPE_CONFIG(ADDR_SURF_P2) | | |
2cd46ad2 | 797 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | |
2cd46ad2 KW |
798 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
799 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
f8d9422e FC |
800 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
801 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
2cd46ad2 | 802 | break; |
45682886 | 803 | case 11: |
f8d9422e FC |
804 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) | |
805 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
806 | PIPE_CONFIG(ADDR_SURF_P2) | | |
2cd46ad2 | 807 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | |
2cd46ad2 KW |
808 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
809 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | |
f8d9422e FC |
810 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
811 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
2cd46ad2 | 812 | break; |
45682886 | 813 | case 12: |
f8d9422e FC |
814 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) | |
815 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
816 | PIPE_CONFIG(ADDR_SURF_P2) | | |
2cd46ad2 | 817 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) | |
2cd46ad2 KW |
818 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
819 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | |
f8d9422e FC |
820 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
821 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
2cd46ad2 | 822 | break; |
45682886 | 823 | case 13: |
f8d9422e FC |
824 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | |
825 | ARRAY_MODE(ARRAY_1D_TILED_THIN1) | | |
826 | PIPE_CONFIG(ADDR_SURF_P2)); | |
2cd46ad2 | 827 | break; |
45682886 | 828 | case 14: |
f8d9422e FC |
829 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | |
830 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
831 | PIPE_CONFIG(ADDR_SURF_P2) | | |
2cd46ad2 | 832 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | |
2cd46ad2 KW |
833 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
834 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
f8d9422e FC |
835 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
836 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
2cd46ad2 | 837 | break; |
45682886 | 838 | case 15: |
f8d9422e FC |
839 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | |
840 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
841 | PIPE_CONFIG(ADDR_SURF_P2) | | |
2cd46ad2 | 842 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | |
2cd46ad2 KW |
843 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
844 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | |
f8d9422e FC |
845 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
846 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
2cd46ad2 | 847 | break; |
45682886 | 848 | case 16: |
f8d9422e FC |
849 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | |
850 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
851 | PIPE_CONFIG(ADDR_SURF_P2) | | |
2cd46ad2 | 852 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) | |
2cd46ad2 KW |
853 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
854 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | |
f8d9422e FC |
855 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
856 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
2cd46ad2 | 857 | break; |
45682886 | 858 | case 17: |
f8d9422e FC |
859 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | |
860 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
861 | PIPE_CONFIG(ADDR_SURF_P2) | | |
862 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
863 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | |
864 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | | |
2cd46ad2 | 865 | NUM_BANKS(ADDR_SURF_16_BANK) | |
f8d9422e FC |
866 | TILE_SPLIT(split_equal_to_row_size)); |
867 | break; | |
868 | case 18: | |
869 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
870 | ARRAY_MODE(ARRAY_1D_TILED_THICK) | | |
871 | PIPE_CONFIG(ADDR_SURF_P2)); | |
872 | break; | |
873 | case 19: | |
874 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
875 | ARRAY_MODE(ARRAY_2D_TILED_XTHICK) | | |
876 | PIPE_CONFIG(ADDR_SURF_P2) | | |
2cd46ad2 KW |
877 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
878 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | |
f8d9422e FC |
879 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
880 | NUM_BANKS(ADDR_SURF_16_BANK) | | |
881 | TILE_SPLIT(split_equal_to_row_size)); | |
882 | break; | |
883 | case 20: | |
884 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
885 | ARRAY_MODE(ARRAY_2D_TILED_THICK) | | |
886 | PIPE_CONFIG(ADDR_SURF_P2) | | |
887 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
888 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | |
889 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | | |
890 | NUM_BANKS(ADDR_SURF_16_BANK) | | |
891 | TILE_SPLIT(split_equal_to_row_size)); | |
2cd46ad2 | 892 | break; |
45682886 | 893 | case 21: |
f8d9422e FC |
894 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | |
895 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
896 | PIPE_CONFIG(ADDR_SURF_P2) | | |
2cd46ad2 | 897 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | |
2cd46ad2 KW |
898 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) | |
899 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
f8d9422e FC |
900 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
901 | NUM_BANKS(ADDR_SURF_8_BANK)); | |
2cd46ad2 | 902 | break; |
45682886 | 903 | case 22: |
f8d9422e FC |
904 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | |
905 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
906 | PIPE_CONFIG(ADDR_SURF_P2) | | |
2cd46ad2 | 907 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | |
f8d9422e FC |
908 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) | |
909 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | |
910 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
911 | NUM_BANKS(ADDR_SURF_8_BANK)); | |
2cd46ad2 | 912 | break; |
45682886 | 913 | case 23: |
f8d9422e FC |
914 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | |
915 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
916 | PIPE_CONFIG(ADDR_SURF_P2) | | |
2cd46ad2 | 917 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | |
2cd46ad2 KW |
918 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
919 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | |
f8d9422e FC |
920 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
921 | NUM_BANKS(ADDR_SURF_8_BANK)); | |
2cd46ad2 | 922 | break; |
45682886 | 923 | case 24: |
f8d9422e FC |
924 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | |
925 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
926 | PIPE_CONFIG(ADDR_SURF_P2) | | |
2cd46ad2 | 927 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) | |
2cd46ad2 KW |
928 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
929 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | |
f8d9422e FC |
930 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
931 | NUM_BANKS(ADDR_SURF_8_BANK)); | |
2cd46ad2 | 932 | break; |
45682886 | 933 | case 25: |
f8d9422e FC |
934 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | |
935 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
936 | PIPE_CONFIG(ADDR_SURF_P2) | | |
937 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) | | |
938 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
939 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | |
940 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
941 | NUM_BANKS(ADDR_SURF_4_BANK)); | |
942 | break; | |
943 | case 26: | |
944 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
945 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
946 | PIPE_CONFIG(ADDR_SURF_P2) | | |
947 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) | | |
948 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
949 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | |
950 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
951 | NUM_BANKS(ADDR_SURF_4_BANK)); | |
952 | break; | |
953 | case 27: | |
954 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
955 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
956 | PIPE_CONFIG(ADDR_SURF_P2) | | |
2cd46ad2 | 957 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) | |
f8d9422e FC |
958 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
959 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | |
960 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
961 | NUM_BANKS(ADDR_SURF_4_BANK)); | |
962 | break; | |
963 | case 28: | |
964 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
965 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
966 | PIPE_CONFIG(ADDR_SURF_P2) | | |
967 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) | | |
968 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
969 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | |
970 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
971 | NUM_BANKS(ADDR_SURF_4_BANK)); | |
972 | break; | |
973 | case 29: | |
974 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
975 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
976 | PIPE_CONFIG(ADDR_SURF_P2) | | |
977 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) | | |
978 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
979 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | |
980 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
981 | NUM_BANKS(ADDR_SURF_4_BANK)); | |
982 | break; | |
983 | case 30: | |
984 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
985 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
986 | PIPE_CONFIG(ADDR_SURF_P2) | | |
987 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_2KB) | | |
2cd46ad2 KW |
988 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
989 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | |
f8d9422e FC |
990 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
991 | NUM_BANKS(ADDR_SURF_4_BANK)); | |
2cd46ad2 KW |
992 | break; |
993 | default: | |
f8d9422e | 994 | continue; |
2cd46ad2 KW |
995 | } |
996 | adev->gfx.config.tile_mode_array[reg_offset] = gb_tile_moden; | |
25069e06 | 997 | WREG32(mmGB_TILE_MODE0 + reg_offset, gb_tile_moden); |
2cd46ad2 KW |
998 | } |
999 | } else if ((adev->asic_type == CHIP_TAHITI) || (adev->asic_type == CHIP_PITCAIRN)) { | |
1000 | for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++) { | |
1001 | switch (reg_offset) { | |
7c0a705e FC |
1002 | case 0: |
1003 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | |
1004 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
2cd46ad2 KW |
1005 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | |
1006 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) | | |
2cd46ad2 KW |
1007 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
1008 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
7c0a705e FC |
1009 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
1010 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
2cd46ad2 | 1011 | break; |
7c0a705e FC |
1012 | case 1: |
1013 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | |
1014 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
2cd46ad2 KW |
1015 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | |
1016 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B) | | |
2cd46ad2 KW |
1017 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
1018 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
7c0a705e FC |
1019 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
1020 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
2cd46ad2 | 1021 | break; |
7c0a705e FC |
1022 | case 2: |
1023 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | |
1024 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
2cd46ad2 KW |
1025 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | |
1026 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | |
2cd46ad2 KW |
1027 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
1028 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
7c0a705e FC |
1029 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
1030 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
2cd46ad2 | 1031 | break; |
7c0a705e FC |
1032 | case 3: |
1033 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | |
1034 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
2cd46ad2 | 1035 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | |
2cd46ad2 KW |
1036 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
1037 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
7c0a705e FC |
1038 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
1039 | NUM_BANKS(ADDR_SURF_4_BANK) | | |
1040 | TILE_SPLIT(split_equal_to_row_size)); | |
2cd46ad2 | 1041 | break; |
7c0a705e FC |
1042 | case 4: |
1043 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | |
1044 | ARRAY_MODE(ARRAY_1D_TILED_THIN1) | | |
1045 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16)); | |
2cd46ad2 | 1046 | break; |
7c0a705e FC |
1047 | case 5: |
1048 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | |
1049 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
2cd46ad2 | 1050 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | |
7c0a705e | 1051 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) | |
2cd46ad2 | 1052 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
7c0a705e FC |
1053 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | |
1054 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
1055 | NUM_BANKS(ADDR_SURF_2_BANK)); | |
2cd46ad2 | 1056 | break; |
7c0a705e FC |
1057 | case 6: |
1058 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | |
1059 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
2cd46ad2 | 1060 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | |
7c0a705e | 1061 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | |
2cd46ad2 | 1062 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
7c0a705e FC |
1063 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_8) | |
1064 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
1065 | NUM_BANKS(ADDR_SURF_2_BANK)); | |
2cd46ad2 | 1066 | break; |
7c0a705e FC |
1067 | case 7: |
1068 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | |
1069 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
1070 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
1071 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) | | |
2cd46ad2 KW |
1072 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
1073 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
7c0a705e FC |
1074 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
1075 | NUM_BANKS(ADDR_SURF_2_BANK)); | |
2cd46ad2 | 1076 | break; |
7c0a705e FC |
1077 | case 8: |
1078 | gb_tile_moden = (ARRAY_MODE(ARRAY_LINEAR_ALIGNED)); | |
2cd46ad2 | 1079 | break; |
7c0a705e FC |
1080 | case 9: |
1081 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) | | |
1082 | ARRAY_MODE(ARRAY_1D_TILED_THIN1) | | |
1083 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16)); | |
2cd46ad2 | 1084 | break; |
7c0a705e FC |
1085 | case 10: |
1086 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) | | |
1087 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
2cd46ad2 KW |
1088 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | |
1089 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | |
2cd46ad2 KW |
1090 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
1091 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
7c0a705e FC |
1092 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
1093 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
2cd46ad2 | 1094 | break; |
7c0a705e FC |
1095 | case 11: |
1096 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) | | |
1097 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
2cd46ad2 KW |
1098 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | |
1099 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | |
2cd46ad2 KW |
1100 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
1101 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | |
7c0a705e FC |
1102 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
1103 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
2cd46ad2 | 1104 | break; |
7c0a705e FC |
1105 | case 12: |
1106 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) | | |
1107 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
2cd46ad2 KW |
1108 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | |
1109 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) | | |
2cd46ad2 KW |
1110 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
1111 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | |
7c0a705e FC |
1112 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
1113 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
2cd46ad2 | 1114 | break; |
7c0a705e FC |
1115 | case 13: |
1116 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
1117 | ARRAY_MODE(ARRAY_1D_TILED_THIN1) | | |
1118 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16)); | |
2cd46ad2 | 1119 | break; |
7c0a705e FC |
1120 | case 14: |
1121 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
1122 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
2cd46ad2 KW |
1123 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | |
1124 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | |
2cd46ad2 KW |
1125 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
1126 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
7c0a705e FC |
1127 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
1128 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
2cd46ad2 | 1129 | break; |
7c0a705e FC |
1130 | case 15: |
1131 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
1132 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
2cd46ad2 KW |
1133 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | |
1134 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | |
2cd46ad2 KW |
1135 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
1136 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | |
7c0a705e FC |
1137 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
1138 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
2cd46ad2 | 1139 | break; |
7c0a705e FC |
1140 | case 16: |
1141 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
1142 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
2cd46ad2 KW |
1143 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | |
1144 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) | | |
2cd46ad2 KW |
1145 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
1146 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | |
7c0a705e FC |
1147 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
1148 | NUM_BANKS(ADDR_SURF_16_BANK)); | |
2cd46ad2 | 1149 | break; |
7c0a705e FC |
1150 | case 17: |
1151 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
1152 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
2cd46ad2 | 1153 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | |
7c0a705e FC |
1154 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
1155 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | |
1156 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
2cd46ad2 | 1157 | NUM_BANKS(ADDR_SURF_16_BANK) | |
7c0a705e FC |
1158 | TILE_SPLIT(split_equal_to_row_size)); |
1159 | break; | |
1160 | case 18: | |
1161 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
1162 | ARRAY_MODE(ARRAY_1D_TILED_THICK) | | |
1163 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16)); | |
1164 | break; | |
1165 | case 19: | |
1166 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
1167 | ARRAY_MODE(ARRAY_2D_TILED_XTHICK) | | |
1168 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | |
2cd46ad2 KW |
1169 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
1170 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | |
7c0a705e FC |
1171 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
1172 | NUM_BANKS(ADDR_SURF_16_BANK) | | |
1173 | TILE_SPLIT(split_equal_to_row_size)); | |
2cd46ad2 | 1174 | break; |
7c0a705e FC |
1175 | case 20: |
1176 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
1177 | ARRAY_MODE(ARRAY_2D_TILED_THICK) | | |
2cd46ad2 | 1178 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | |
7c0a705e FC |
1179 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
1180 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | |
1181 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
2cd46ad2 | 1182 | NUM_BANKS(ADDR_SURF_16_BANK) | |
7c0a705e | 1183 | TILE_SPLIT(split_equal_to_row_size)); |
2cd46ad2 | 1184 | break; |
7c0a705e FC |
1185 | case 21: |
1186 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
1187 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
1188 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | |
1189 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | |
1190 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
1191 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_8) | | |
1192 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
1193 | NUM_BANKS(ADDR_SURF_4_BANK)); | |
1194 | break; | |
1195 | case 22: | |
1196 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
1197 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
2cd46ad2 KW |
1198 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | |
1199 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | |
2cd46ad2 KW |
1200 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
1201 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
7c0a705e FC |
1202 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
1203 | NUM_BANKS(ADDR_SURF_4_BANK)); | |
2cd46ad2 | 1204 | break; |
7c0a705e FC |
1205 | case 23: |
1206 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
1207 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
2cd46ad2 KW |
1208 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | |
1209 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | |
2cd46ad2 | 1210 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
7c0a705e FC |
1211 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_8) | |
1212 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
1213 | NUM_BANKS(ADDR_SURF_2_BANK)); | |
2cd46ad2 | 1214 | break; |
7c0a705e FC |
1215 | case 24: |
1216 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
1217 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
2cd46ad2 KW |
1218 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | |
1219 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) | | |
2cd46ad2 | 1220 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
7c0a705e FC |
1221 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | |
1222 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
1223 | NUM_BANKS(ADDR_SURF_2_BANK)); | |
2cd46ad2 | 1224 | break; |
7c0a705e FC |
1225 | case 25: |
1226 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
1227 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
1228 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
2cd46ad2 | 1229 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) | |
2cd46ad2 | 1230 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
7c0a705e FC |
1231 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | |
1232 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
1233 | NUM_BANKS(ADDR_SURF_2_BANK)); | |
2cd46ad2 | 1234 | break; |
7c0a705e FC |
1235 | case 26: |
1236 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
1237 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
1238 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
1239 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) | | |
1240 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
1241 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
1242 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
1243 | NUM_BANKS(ADDR_SURF_2_BANK)); | |
1244 | break; | |
1245 | case 27: | |
1246 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
1247 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
1248 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
1249 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) | | |
1250 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
1251 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
1252 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
1253 | NUM_BANKS(ADDR_SURF_2_BANK)); | |
2cd46ad2 | 1254 | break; |
7c0a705e FC |
1255 | case 28: |
1256 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
1257 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
1258 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
1259 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) | | |
1260 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
1261 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
1262 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
1263 | NUM_BANKS(ADDR_SURF_2_BANK)); | |
1264 | break; | |
1265 | case 29: | |
1266 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
1267 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
1268 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
1269 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) | | |
1270 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
1271 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | |
1272 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
1273 | NUM_BANKS(ADDR_SURF_2_BANK)); | |
1274 | break; | |
1275 | case 30: | |
1276 | gb_tile_moden = (MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | |
1277 | ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | |
1278 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | |
1279 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_2KB) | | |
1280 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | |
1281 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | |
1282 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | | |
1283 | NUM_BANKS(ADDR_SURF_2_BANK)); | |
1284 | break; | |
1285 | default: | |
1286 | continue; | |
2cd46ad2 KW |
1287 | } |
1288 | adev->gfx.config.tile_mode_array[reg_offset] = gb_tile_moden; | |
25069e06 | 1289 | WREG32(mmGB_TILE_MODE0 + reg_offset, gb_tile_moden); |
2cd46ad2 KW |
1290 | } |
1291 | } else{ | |
1292 | ||
1293 | DRM_ERROR("unknown asic: 0x%x\n", adev->asic_type); | |
1294 | } | |
1295 | ||
1296 | } | |
1297 | ||
1298 | static void gfx_v6_0_select_se_sh(struct amdgpu_device *adev, u32 se_num, | |
1299 | u32 sh_num, u32 instance) | |
1300 | { | |
1301 | u32 data; | |
1302 | ||
1303 | if (instance == 0xffffffff) | |
25069e06 | 1304 | data = REG_SET_FIELD(0, GRBM_GFX_INDEX, INSTANCE_BROADCAST_WRITES, 1); |
2cd46ad2 | 1305 | else |
25069e06 | 1306 | data = REG_SET_FIELD(0, GRBM_GFX_INDEX, INSTANCE_INDEX, instance); |
2cd46ad2 KW |
1307 | |
1308 | if ((se_num == 0xffffffff) && (sh_num == 0xffffffff)) | |
25069e06 TSD |
1309 | data |= GRBM_GFX_INDEX__SH_BROADCAST_WRITES_MASK | |
1310 | GRBM_GFX_INDEX__SE_BROADCAST_WRITES_MASK; | |
2cd46ad2 | 1311 | else if (se_num == 0xffffffff) |
25069e06 TSD |
1312 | data |= GRBM_GFX_INDEX__SE_BROADCAST_WRITES_MASK | |
1313 | (sh_num << GRBM_GFX_INDEX__SH_INDEX__SHIFT); | |
2cd46ad2 | 1314 | else if (sh_num == 0xffffffff) |
25069e06 TSD |
1315 | data |= GRBM_GFX_INDEX__SH_BROADCAST_WRITES_MASK | |
1316 | (se_num << GRBM_GFX_INDEX__SE_INDEX__SHIFT); | |
2cd46ad2 | 1317 | else |
25069e06 TSD |
1318 | data |= (sh_num << GRBM_GFX_INDEX__SH_INDEX__SHIFT) | |
1319 | (se_num << GRBM_GFX_INDEX__SE_INDEX__SHIFT); | |
1320 | WREG32(mmGRBM_GFX_INDEX, data); | |
2cd46ad2 KW |
1321 | } |
1322 | ||
1323 | static u32 gfx_v6_0_create_bitmask(u32 bit_width) | |
1324 | { | |
142333db | 1325 | return (u32)(((u64)1 << bit_width) - 1); |
2cd46ad2 KW |
1326 | } |
1327 | ||
1328 | static u32 gfx_v6_0_get_rb_disabled(struct amdgpu_device *adev, | |
1329 | u32 max_rb_num_per_se, | |
1330 | u32 sh_per_se) | |
1331 | { | |
1332 | u32 data, mask; | |
1333 | ||
25069e06 TSD |
1334 | data = RREG32(mmCC_RB_BACKEND_DISABLE); |
1335 | data &= CC_RB_BACKEND_DISABLE__BACKEND_DISABLE_MASK; | |
1336 | data |= RREG32(mmGC_USER_RB_BACKEND_DISABLE); | |
2cd46ad2 | 1337 | |
25069e06 | 1338 | data >>= CC_RB_BACKEND_DISABLE__BACKEND_DISABLE__SHIFT; |
2cd46ad2 KW |
1339 | |
1340 | mask = gfx_v6_0_create_bitmask(max_rb_num_per_se / sh_per_se); | |
1341 | ||
1342 | return data & mask; | |
1343 | } | |
1344 | ||
865ab832 HR |
1345 | static void gfx_v6_0_raster_config(struct amdgpu_device *adev, u32 *rconf) |
1346 | { | |
1347 | switch (adev->asic_type) { | |
1348 | case CHIP_TAHITI: | |
1349 | case CHIP_PITCAIRN: | |
25069e06 TSD |
1350 | *rconf |= |
1351 | (2 << PA_SC_RASTER_CONFIG__RB_XSEL2__SHIFT) | | |
1352 | (1 << PA_SC_RASTER_CONFIG__RB_XSEL__SHIFT) | | |
1353 | (2 << PA_SC_RASTER_CONFIG__PKR_MAP__SHIFT) | | |
1354 | (1 << PA_SC_RASTER_CONFIG__PKR_YSEL__SHIFT) | | |
1355 | (2 << PA_SC_RASTER_CONFIG__SE_MAP__SHIFT) | | |
1356 | (2 << PA_SC_RASTER_CONFIG__SE_XSEL__SHIFT) | | |
1357 | (2 << PA_SC_RASTER_CONFIG__SE_YSEL__SHIFT); | |
865ab832 HR |
1358 | break; |
1359 | case CHIP_VERDE: | |
25069e06 TSD |
1360 | *rconf |= |
1361 | (1 << PA_SC_RASTER_CONFIG__RB_XSEL__SHIFT) | | |
1362 | (2 << PA_SC_RASTER_CONFIG__PKR_MAP__SHIFT) | | |
1363 | (1 << PA_SC_RASTER_CONFIG__PKR_YSEL__SHIFT); | |
865ab832 HR |
1364 | break; |
1365 | case CHIP_OLAND: | |
25069e06 | 1366 | *rconf |= (1 << PA_SC_RASTER_CONFIG__RB_YSEL__SHIFT); |
865ab832 HR |
1367 | break; |
1368 | case CHIP_HAINAN: | |
1369 | *rconf |= 0x0; | |
1370 | break; | |
1371 | default: | |
1372 | DRM_ERROR("unknown asic: 0x%x\n", adev->asic_type); | |
1373 | break; | |
1374 | } | |
1375 | } | |
1376 | ||
1377 | static void gfx_v6_0_write_harvested_raster_configs(struct amdgpu_device *adev, | |
1378 | u32 raster_config, unsigned rb_mask, | |
1379 | unsigned num_rb) | |
1380 | { | |
1381 | unsigned sh_per_se = max_t(unsigned, adev->gfx.config.max_sh_per_se, 1); | |
1382 | unsigned num_se = max_t(unsigned, adev->gfx.config.max_shader_engines, 1); | |
1383 | unsigned rb_per_pkr = min_t(unsigned, num_rb / num_se / sh_per_se, 2); | |
1384 | unsigned rb_per_se = num_rb / num_se; | |
1385 | unsigned se_mask[4]; | |
1386 | unsigned se; | |
1387 | ||
1388 | se_mask[0] = ((1 << rb_per_se) - 1) & rb_mask; | |
1389 | se_mask[1] = (se_mask[0] << rb_per_se) & rb_mask; | |
1390 | se_mask[2] = (se_mask[1] << rb_per_se) & rb_mask; | |
1391 | se_mask[3] = (se_mask[2] << rb_per_se) & rb_mask; | |
1392 | ||
1393 | WARN_ON(!(num_se == 1 || num_se == 2 || num_se == 4)); | |
1394 | WARN_ON(!(sh_per_se == 1 || sh_per_se == 2)); | |
1395 | WARN_ON(!(rb_per_pkr == 1 || rb_per_pkr == 2)); | |
1396 | ||
1397 | for (se = 0; se < num_se; se++) { | |
1398 | unsigned raster_config_se = raster_config; | |
1399 | unsigned pkr0_mask = ((1 << rb_per_pkr) - 1) << (se * rb_per_se); | |
1400 | unsigned pkr1_mask = pkr0_mask << rb_per_pkr; | |
1401 | int idx = (se / 2) * 2; | |
1402 | ||
1403 | if ((num_se > 1) && (!se_mask[idx] || !se_mask[idx + 1])) { | |
25069e06 | 1404 | raster_config_se &= ~PA_SC_RASTER_CONFIG__SE_MAP_MASK; |
865ab832 HR |
1405 | |
1406 | if (!se_mask[idx]) { | |
25069e06 | 1407 | raster_config_se |= RASTER_CONFIG_SE_MAP_3 << PA_SC_RASTER_CONFIG__SE_MAP__SHIFT; |
865ab832 | 1408 | } else { |
25069e06 | 1409 | raster_config_se |= RASTER_CONFIG_SE_MAP_0 << PA_SC_RASTER_CONFIG__SE_MAP__SHIFT; |
865ab832 HR |
1410 | } |
1411 | } | |
1412 | ||
1413 | pkr0_mask &= rb_mask; | |
1414 | pkr1_mask &= rb_mask; | |
1415 | if (rb_per_se > 2 && (!pkr0_mask || !pkr1_mask)) { | |
25069e06 | 1416 | raster_config_se &= ~PA_SC_RASTER_CONFIG__PKR_MAP_MASK; |
865ab832 HR |
1417 | |
1418 | if (!pkr0_mask) { | |
25069e06 | 1419 | raster_config_se |= RASTER_CONFIG_PKR_MAP_3 << PA_SC_RASTER_CONFIG__PKR_MAP__SHIFT; |
865ab832 | 1420 | } else { |
25069e06 | 1421 | raster_config_se |= RASTER_CONFIG_PKR_MAP_0 << PA_SC_RASTER_CONFIG__PKR_MAP__SHIFT; |
865ab832 HR |
1422 | } |
1423 | } | |
1424 | ||
1425 | if (rb_per_se >= 2) { | |
1426 | unsigned rb0_mask = 1 << (se * rb_per_se); | |
1427 | unsigned rb1_mask = rb0_mask << 1; | |
1428 | ||
1429 | rb0_mask &= rb_mask; | |
1430 | rb1_mask &= rb_mask; | |
1431 | if (!rb0_mask || !rb1_mask) { | |
25069e06 | 1432 | raster_config_se &= ~PA_SC_RASTER_CONFIG__RB_MAP_PKR0_MASK; |
865ab832 HR |
1433 | |
1434 | if (!rb0_mask) { | |
1435 | raster_config_se |= | |
25069e06 | 1436 | RASTER_CONFIG_RB_MAP_3 << PA_SC_RASTER_CONFIG__RB_MAP_PKR0__SHIFT; |
865ab832 HR |
1437 | } else { |
1438 | raster_config_se |= | |
25069e06 | 1439 | RASTER_CONFIG_RB_MAP_0 << PA_SC_RASTER_CONFIG__RB_MAP_PKR0__SHIFT; |
865ab832 HR |
1440 | } |
1441 | } | |
1442 | ||
1443 | if (rb_per_se > 2) { | |
1444 | rb0_mask = 1 << (se * rb_per_se + rb_per_pkr); | |
1445 | rb1_mask = rb0_mask << 1; | |
1446 | rb0_mask &= rb_mask; | |
1447 | rb1_mask &= rb_mask; | |
1448 | if (!rb0_mask || !rb1_mask) { | |
25069e06 | 1449 | raster_config_se &= ~PA_SC_RASTER_CONFIG__RB_MAP_PKR1_MASK; |
865ab832 HR |
1450 | |
1451 | if (!rb0_mask) { | |
1452 | raster_config_se |= | |
25069e06 | 1453 | RASTER_CONFIG_RB_MAP_3 << PA_SC_RASTER_CONFIG__RB_MAP_PKR1__SHIFT; |
865ab832 HR |
1454 | } else { |
1455 | raster_config_se |= | |
25069e06 | 1456 | RASTER_CONFIG_RB_MAP_0 << PA_SC_RASTER_CONFIG__RB_MAP_PKR1__SHIFT; |
865ab832 HR |
1457 | } |
1458 | } | |
1459 | } | |
1460 | } | |
1461 | ||
1462 | /* GRBM_GFX_INDEX has a different offset on SI */ | |
1463 | gfx_v6_0_select_se_sh(adev, se, 0xffffffff, 0xffffffff); | |
25069e06 | 1464 | WREG32(mmPA_SC_RASTER_CONFIG, raster_config_se); |
865ab832 HR |
1465 | } |
1466 | ||
1467 | /* GRBM_GFX_INDEX has a different offset on SI */ | |
1468 | gfx_v6_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); | |
1469 | } | |
1470 | ||
2cd46ad2 KW |
1471 | static void gfx_v6_0_setup_rb(struct amdgpu_device *adev, |
1472 | u32 se_num, u32 sh_per_se, | |
1473 | u32 max_rb_num_per_se) | |
1474 | { | |
1475 | int i, j; | |
1476 | u32 data, mask; | |
1477 | u32 disabled_rbs = 0; | |
1478 | u32 enabled_rbs = 0; | |
865ab832 | 1479 | unsigned num_rb_pipes; |
2cd46ad2 | 1480 | |
deca1d1f | 1481 | mutex_lock(&adev->grbm_idx_mutex); |
2cd46ad2 KW |
1482 | for (i = 0; i < se_num; i++) { |
1483 | for (j = 0; j < sh_per_se; j++) { | |
1484 | gfx_v6_0_select_se_sh(adev, i, j, 0xffffffff); | |
1485 | data = gfx_v6_0_get_rb_disabled(adev, max_rb_num_per_se, sh_per_se); | |
25069e06 | 1486 | disabled_rbs |= data << ((i * sh_per_se + j) * 2); |
2cd46ad2 KW |
1487 | } |
1488 | } | |
1489 | gfx_v6_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); | |
deca1d1f | 1490 | mutex_unlock(&adev->grbm_idx_mutex); |
2cd46ad2 KW |
1491 | |
1492 | mask = 1; | |
1493 | for (i = 0; i < max_rb_num_per_se * se_num; i++) { | |
1494 | if (!(disabled_rbs & mask)) | |
1495 | enabled_rbs |= mask; | |
1496 | mask <<= 1; | |
1497 | } | |
1498 | ||
1499 | adev->gfx.config.backend_enable_mask = enabled_rbs; | |
1500 | adev->gfx.config.num_rbs = hweight32(enabled_rbs); | |
1501 | ||
865ab832 HR |
1502 | num_rb_pipes = min_t(unsigned, adev->gfx.config.max_backends_per_se * |
1503 | adev->gfx.config.max_shader_engines, 16); | |
1504 | ||
deca1d1f | 1505 | mutex_lock(&adev->grbm_idx_mutex); |
2cd46ad2 KW |
1506 | for (i = 0; i < se_num; i++) { |
1507 | gfx_v6_0_select_se_sh(adev, i, 0xffffffff, 0xffffffff); | |
1508 | data = 0; | |
1509 | for (j = 0; j < sh_per_se; j++) { | |
1510 | switch (enabled_rbs & 3) { | |
1511 | case 1: | |
1512 | data |= (RASTER_CONFIG_RB_MAP_0 << (i * sh_per_se + j) * 2); | |
1513 | break; | |
1514 | case 2: | |
1515 | data |= (RASTER_CONFIG_RB_MAP_3 << (i * sh_per_se + j) * 2); | |
1516 | break; | |
1517 | case 3: | |
1518 | default: | |
1519 | data |= (RASTER_CONFIG_RB_MAP_2 << (i * sh_per_se + j) * 2); | |
1520 | break; | |
1521 | } | |
1522 | enabled_rbs >>= 2; | |
1523 | } | |
865ab832 HR |
1524 | gfx_v6_0_raster_config(adev, &data); |
1525 | ||
1526 | if (!adev->gfx.config.backend_enable_mask || | |
1527 | adev->gfx.config.num_rbs >= num_rb_pipes) | |
25069e06 | 1528 | WREG32(mmPA_SC_RASTER_CONFIG, data); |
865ab832 HR |
1529 | else |
1530 | gfx_v6_0_write_harvested_raster_configs(adev, data, | |
1531 | adev->gfx.config.backend_enable_mask, | |
1532 | num_rb_pipes); | |
2cd46ad2 KW |
1533 | } |
1534 | gfx_v6_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); | |
deca1d1f | 1535 | mutex_unlock(&adev->grbm_idx_mutex); |
2cd46ad2 KW |
1536 | } |
1537 | /* | |
1538 | static void gmc_v6_0_init_compute_vmid(struct amdgpu_device *adev) | |
1539 | { | |
1540 | } | |
1541 | */ | |
1542 | ||
1543 | static u32 gfx_v6_0_get_cu_enabled(struct amdgpu_device *adev, u32 cu_per_sh) | |
1544 | { | |
1545 | u32 data, mask; | |
1546 | ||
25069e06 TSD |
1547 | data = RREG32(mmCC_GC_SHADER_ARRAY_CONFIG); |
1548 | data &= CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK; | |
1549 | data |= RREG32(mmGC_USER_SHADER_ARRAY_CONFIG); | |
2cd46ad2 | 1550 | |
25069e06 | 1551 | data >>= CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT; |
2cd46ad2 KW |
1552 | |
1553 | mask = gfx_v6_0_create_bitmask(cu_per_sh); | |
1554 | ||
1555 | return ~data & mask; | |
1556 | } | |
1557 | ||
1558 | ||
1559 | static void gfx_v6_0_setup_spi(struct amdgpu_device *adev, | |
1560 | u32 se_num, u32 sh_per_se, | |
1561 | u32 cu_per_sh) | |
1562 | { | |
1563 | int i, j, k; | |
1564 | u32 data, mask; | |
1565 | u32 active_cu = 0; | |
1566 | ||
deca1d1f | 1567 | mutex_lock(&adev->grbm_idx_mutex); |
2cd46ad2 KW |
1568 | for (i = 0; i < se_num; i++) { |
1569 | for (j = 0; j < sh_per_se; j++) { | |
1570 | gfx_v6_0_select_se_sh(adev, i, j, 0xffffffff); | |
25069e06 | 1571 | data = RREG32(mmSPI_STATIC_THREAD_MGMT_3); |
2cd46ad2 KW |
1572 | active_cu = gfx_v6_0_get_cu_enabled(adev, cu_per_sh); |
1573 | ||
1574 | mask = 1; | |
1575 | for (k = 0; k < 16; k++) { | |
1576 | mask <<= k; | |
1577 | if (active_cu & mask) { | |
1578 | data &= ~mask; | |
25069e06 | 1579 | WREG32(mmSPI_STATIC_THREAD_MGMT_3, data); |
2cd46ad2 KW |
1580 | break; |
1581 | } | |
1582 | } | |
1583 | } | |
1584 | } | |
1585 | gfx_v6_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); | |
deca1d1f | 1586 | mutex_unlock(&adev->grbm_idx_mutex); |
2cd46ad2 KW |
1587 | } |
1588 | ||
1589 | static void gfx_v6_0_gpu_init(struct amdgpu_device *adev) | |
1590 | { | |
1591 | u32 gb_addr_config = 0; | |
1592 | u32 mc_shared_chmap, mc_arb_ramcfg; | |
1593 | u32 sx_debug_1; | |
1594 | u32 hdp_host_path_cntl; | |
1595 | u32 tmp; | |
1596 | ||
1597 | switch (adev->asic_type) { | |
1598 | case CHIP_TAHITI: | |
1599 | adev->gfx.config.max_shader_engines = 2; | |
1600 | adev->gfx.config.max_tile_pipes = 12; | |
1601 | adev->gfx.config.max_cu_per_sh = 8; | |
1602 | adev->gfx.config.max_sh_per_se = 2; | |
1603 | adev->gfx.config.max_backends_per_se = 4; | |
1604 | adev->gfx.config.max_texture_channel_caches = 12; | |
1605 | adev->gfx.config.max_gprs = 256; | |
1606 | adev->gfx.config.max_gs_threads = 32; | |
1607 | adev->gfx.config.max_hw_contexts = 8; | |
1608 | ||
1609 | adev->gfx.config.sc_prim_fifo_size_frontend = 0x20; | |
1610 | adev->gfx.config.sc_prim_fifo_size_backend = 0x100; | |
1611 | adev->gfx.config.sc_hiz_tile_fifo_size = 0x30; | |
1612 | adev->gfx.config.sc_earlyz_tile_fifo_size = 0x130; | |
1613 | gb_addr_config = TAHITI_GB_ADDR_CONFIG_GOLDEN; | |
1614 | break; | |
1615 | case CHIP_PITCAIRN: | |
1616 | adev->gfx.config.max_shader_engines = 2; | |
1617 | adev->gfx.config.max_tile_pipes = 8; | |
1618 | adev->gfx.config.max_cu_per_sh = 5; | |
1619 | adev->gfx.config.max_sh_per_se = 2; | |
1620 | adev->gfx.config.max_backends_per_se = 4; | |
1621 | adev->gfx.config.max_texture_channel_caches = 8; | |
1622 | adev->gfx.config.max_gprs = 256; | |
1623 | adev->gfx.config.max_gs_threads = 32; | |
1624 | adev->gfx.config.max_hw_contexts = 8; | |
1625 | ||
1626 | adev->gfx.config.sc_prim_fifo_size_frontend = 0x20; | |
1627 | adev->gfx.config.sc_prim_fifo_size_backend = 0x100; | |
1628 | adev->gfx.config.sc_hiz_tile_fifo_size = 0x30; | |
1629 | adev->gfx.config.sc_earlyz_tile_fifo_size = 0x130; | |
1630 | gb_addr_config = TAHITI_GB_ADDR_CONFIG_GOLDEN; | |
1631 | break; | |
2cd46ad2 KW |
1632 | case CHIP_VERDE: |
1633 | adev->gfx.config.max_shader_engines = 1; | |
1634 | adev->gfx.config.max_tile_pipes = 4; | |
1635 | adev->gfx.config.max_cu_per_sh = 5; | |
1636 | adev->gfx.config.max_sh_per_se = 2; | |
1637 | adev->gfx.config.max_backends_per_se = 4; | |
1638 | adev->gfx.config.max_texture_channel_caches = 4; | |
1639 | adev->gfx.config.max_gprs = 256; | |
1640 | adev->gfx.config.max_gs_threads = 32; | |
1641 | adev->gfx.config.max_hw_contexts = 8; | |
1642 | ||
1643 | adev->gfx.config.sc_prim_fifo_size_frontend = 0x20; | |
1644 | adev->gfx.config.sc_prim_fifo_size_backend = 0x40; | |
1645 | adev->gfx.config.sc_hiz_tile_fifo_size = 0x30; | |
1646 | adev->gfx.config.sc_earlyz_tile_fifo_size = 0x130; | |
1647 | gb_addr_config = VERDE_GB_ADDR_CONFIG_GOLDEN; | |
1648 | break; | |
1649 | case CHIP_OLAND: | |
1650 | adev->gfx.config.max_shader_engines = 1; | |
1651 | adev->gfx.config.max_tile_pipes = 4; | |
1652 | adev->gfx.config.max_cu_per_sh = 6; | |
1653 | adev->gfx.config.max_sh_per_se = 1; | |
1654 | adev->gfx.config.max_backends_per_se = 2; | |
1655 | adev->gfx.config.max_texture_channel_caches = 4; | |
1656 | adev->gfx.config.max_gprs = 256; | |
1657 | adev->gfx.config.max_gs_threads = 16; | |
1658 | adev->gfx.config.max_hw_contexts = 8; | |
1659 | ||
1660 | adev->gfx.config.sc_prim_fifo_size_frontend = 0x20; | |
1661 | adev->gfx.config.sc_prim_fifo_size_backend = 0x40; | |
1662 | adev->gfx.config.sc_hiz_tile_fifo_size = 0x30; | |
1663 | adev->gfx.config.sc_earlyz_tile_fifo_size = 0x130; | |
1664 | gb_addr_config = VERDE_GB_ADDR_CONFIG_GOLDEN; | |
1665 | break; | |
1666 | case CHIP_HAINAN: | |
1667 | adev->gfx.config.max_shader_engines = 1; | |
1668 | adev->gfx.config.max_tile_pipes = 4; | |
1669 | adev->gfx.config.max_cu_per_sh = 5; | |
1670 | adev->gfx.config.max_sh_per_se = 1; | |
1671 | adev->gfx.config.max_backends_per_se = 1; | |
1672 | adev->gfx.config.max_texture_channel_caches = 2; | |
1673 | adev->gfx.config.max_gprs = 256; | |
1674 | adev->gfx.config.max_gs_threads = 16; | |
1675 | adev->gfx.config.max_hw_contexts = 8; | |
1676 | ||
1677 | adev->gfx.config.sc_prim_fifo_size_frontend = 0x20; | |
1678 | adev->gfx.config.sc_prim_fifo_size_backend = 0x40; | |
1679 | adev->gfx.config.sc_hiz_tile_fifo_size = 0x30; | |
1680 | adev->gfx.config.sc_earlyz_tile_fifo_size = 0x130; | |
1681 | gb_addr_config = HAINAN_GB_ADDR_CONFIG_GOLDEN; | |
1682 | break; | |
1683 | default: | |
1684 | BUG(); | |
1685 | break; | |
1686 | } | |
1687 | ||
25069e06 TSD |
1688 | WREG32(mmGRBM_CNTL, (0xff << GRBM_CNTL__READ_TIMEOUT__SHIFT)); |
1689 | WREG32(mmSRBM_INT_CNTL, 1); | |
1690 | WREG32(mmSRBM_INT_ACK, 1); | |
2cd46ad2 | 1691 | |
25069e06 | 1692 | WREG32(mmBIF_FB_EN, BIF_FB_EN__FB_READ_EN_MASK | BIF_FB_EN__FB_WRITE_EN_MASK); |
2cd46ad2 | 1693 | |
25069e06 TSD |
1694 | mc_shared_chmap = RREG32(mmMC_SHARED_CHMAP); |
1695 | mc_arb_ramcfg = RREG32(mmMC_ARB_RAMCFG); | |
2cd46ad2 KW |
1696 | |
1697 | adev->gfx.config.num_tile_pipes = adev->gfx.config.max_tile_pipes; | |
1698 | adev->gfx.config.mem_max_burst_length_bytes = 256; | |
25069e06 | 1699 | tmp = (mc_arb_ramcfg & MC_ARB_RAMCFG__NOOFCOLS_MASK) >> MC_ARB_RAMCFG__NOOFCOLS__SHIFT; |
2cd46ad2 KW |
1700 | adev->gfx.config.mem_row_size_in_kb = (4 * (1 << (8 + tmp))) / 1024; |
1701 | if (adev->gfx.config.mem_row_size_in_kb > 4) | |
1702 | adev->gfx.config.mem_row_size_in_kb = 4; | |
1703 | adev->gfx.config.shader_engine_tile_size = 32; | |
1704 | adev->gfx.config.num_gpus = 1; | |
1705 | adev->gfx.config.multi_gpu_tile_size = 64; | |
1706 | ||
25069e06 | 1707 | gb_addr_config &= ~GB_ADDR_CONFIG__ROW_SIZE_MASK; |
2cd46ad2 KW |
1708 | switch (adev->gfx.config.mem_row_size_in_kb) { |
1709 | case 1: | |
1710 | default: | |
25069e06 | 1711 | gb_addr_config |= 0 << GB_ADDR_CONFIG__ROW_SIZE__SHIFT; |
2cd46ad2 KW |
1712 | break; |
1713 | case 2: | |
25069e06 | 1714 | gb_addr_config |= 1 << GB_ADDR_CONFIG__ROW_SIZE__SHIFT; |
2cd46ad2 KW |
1715 | break; |
1716 | case 4: | |
25069e06 | 1717 | gb_addr_config |= 2 << GB_ADDR_CONFIG__ROW_SIZE__SHIFT; |
2cd46ad2 KW |
1718 | break; |
1719 | } | |
1720 | adev->gfx.config.gb_addr_config = gb_addr_config; | |
1721 | ||
25069e06 TSD |
1722 | WREG32(mmGB_ADDR_CONFIG, gb_addr_config); |
1723 | WREG32(mmDMIF_ADDR_CONFIG, gb_addr_config); | |
1724 | WREG32(mmDMIF_ADDR_CALC, gb_addr_config); | |
1725 | WREG32(mmHDP_ADDR_CONFIG, gb_addr_config); | |
1726 | WREG32(mmDMA_TILING_CONFIG + DMA0_REGISTER_OFFSET, gb_addr_config); | |
1727 | WREG32(mmDMA_TILING_CONFIG + DMA1_REGISTER_OFFSET, gb_addr_config); | |
1728 | ||
2cd46ad2 KW |
1729 | #if 0 |
1730 | if (adev->has_uvd) { | |
25069e06 TSD |
1731 | WREG32(mmUVD_UDEC_ADDR_CONFIG, gb_addr_config); |
1732 | WREG32(mmUVD_UDEC_DB_ADDR_CONFIG, gb_addr_config); | |
1733 | WREG32(mmUVD_UDEC_DBW_ADDR_CONFIG, gb_addr_config); | |
2cd46ad2 KW |
1734 | } |
1735 | #endif | |
1736 | gfx_v6_0_tiling_mode_table_init(adev); | |
1737 | ||
1738 | gfx_v6_0_setup_rb(adev, adev->gfx.config.max_shader_engines, | |
1739 | adev->gfx.config.max_sh_per_se, | |
1740 | adev->gfx.config.max_backends_per_se); | |
1741 | ||
1742 | gfx_v6_0_setup_spi(adev, adev->gfx.config.max_shader_engines, | |
1743 | adev->gfx.config.max_sh_per_se, | |
1744 | adev->gfx.config.max_cu_per_sh); | |
1745 | ||
1746 | gfx_v6_0_get_cu_info(adev); | |
1747 | ||
25069e06 TSD |
1748 | WREG32(mmCP_QUEUE_THRESHOLDS, ((0x16 << CP_QUEUE_THRESHOLDS__ROQ_IB1_START__SHIFT) | |
1749 | (0x2b << CP_QUEUE_THRESHOLDS__ROQ_IB2_START__SHIFT))); | |
1750 | WREG32(mmCP_MEQ_THRESHOLDS, (0x30 << CP_MEQ_THRESHOLDS__MEQ1_START__SHIFT) | | |
1751 | (0x60 << CP_MEQ_THRESHOLDS__MEQ2_START__SHIFT)); | |
2cd46ad2 | 1752 | |
25069e06 TSD |
1753 | sx_debug_1 = RREG32(mmSX_DEBUG_1); |
1754 | WREG32(mmSX_DEBUG_1, sx_debug_1); | |
2cd46ad2 | 1755 | |
25069e06 | 1756 | WREG32(mmSPI_CONFIG_CNTL_1, (4 << SPI_CONFIG_CNTL_1__VTX_DONE_DELAY__SHIFT)); |
2cd46ad2 | 1757 | |
25069e06 TSD |
1758 | WREG32(mmPA_SC_FIFO_SIZE, ((adev->gfx.config.sc_prim_fifo_size_frontend << PA_SC_FIFO_SIZE__SC_FRONTEND_PRIM_FIFO_SIZE__SHIFT) | |
1759 | (adev->gfx.config.sc_prim_fifo_size_backend << PA_SC_FIFO_SIZE__SC_BACKEND_PRIM_FIFO_SIZE__SHIFT) | | |
1760 | (adev->gfx.config.sc_hiz_tile_fifo_size << PA_SC_FIFO_SIZE__SC_HIZ_TILE_FIFO_SIZE__SHIFT) | | |
1761 | (adev->gfx.config.sc_earlyz_tile_fifo_size << PA_SC_FIFO_SIZE__SC_EARLYZ_TILE_FIFO_SIZE__SHIFT))); | |
2cd46ad2 | 1762 | |
25069e06 TSD |
1763 | WREG32(mmVGT_NUM_INSTANCES, 1); |
1764 | WREG32(mmCP_PERFMON_CNTL, 0); | |
1765 | WREG32(mmSQ_CONFIG, 0); | |
1766 | WREG32(mmPA_SC_FORCE_EOV_MAX_CNTS, ((4095 << PA_SC_FORCE_EOV_MAX_CNTS__FORCE_EOV_MAX_CLK_CNT__SHIFT) | | |
1767 | (255 << PA_SC_FORCE_EOV_MAX_CNTS__FORCE_EOV_MAX_REZ_CNT__SHIFT))); | |
2cd46ad2 | 1768 | |
25069e06 TSD |
1769 | WREG32(mmVGT_CACHE_INVALIDATION, |
1770 | (VC_AND_TC << VGT_CACHE_INVALIDATION__CACHE_INVALIDATION__SHIFT) | | |
1771 | (ES_AND_GS_AUTO << VGT_CACHE_INVALIDATION__AUTO_INVLD_EN__SHIFT)); | |
2cd46ad2 | 1772 | |
25069e06 TSD |
1773 | WREG32(mmVGT_GS_VERTEX_REUSE, 16); |
1774 | WREG32(mmPA_SC_LINE_STIPPLE_STATE, 0); | |
2cd46ad2 | 1775 | |
25069e06 TSD |
1776 | WREG32(mmCB_PERFCOUNTER0_SELECT0, 0); |
1777 | WREG32(mmCB_PERFCOUNTER0_SELECT1, 0); | |
1778 | WREG32(mmCB_PERFCOUNTER1_SELECT0, 0); | |
1779 | WREG32(mmCB_PERFCOUNTER1_SELECT1, 0); | |
1780 | WREG32(mmCB_PERFCOUNTER2_SELECT0, 0); | |
1781 | WREG32(mmCB_PERFCOUNTER2_SELECT1, 0); | |
1782 | WREG32(mmCB_PERFCOUNTER3_SELECT0, 0); | |
1783 | WREG32(mmCB_PERFCOUNTER3_SELECT1, 0); | |
2cd46ad2 | 1784 | |
25069e06 TSD |
1785 | hdp_host_path_cntl = RREG32(mmHDP_HOST_PATH_CNTL); |
1786 | WREG32(mmHDP_HOST_PATH_CNTL, hdp_host_path_cntl); | |
2cd46ad2 | 1787 | |
25069e06 TSD |
1788 | WREG32(mmPA_CL_ENHANCE, PA_CL_ENHANCE__CLIP_VTX_REORDER_ENA_MASK | |
1789 | (3 << PA_CL_ENHANCE__NUM_CLIP_SEQ__SHIFT)); | |
2cd46ad2 KW |
1790 | |
1791 | udelay(50); | |
2cd46ad2 KW |
1792 | } |
1793 | ||
1794 | ||
1795 | static void gfx_v6_0_scratch_init(struct amdgpu_device *adev) | |
1796 | { | |
2cd46ad2 | 1797 | adev->gfx.scratch.num_reg = 7; |
25069e06 | 1798 | adev->gfx.scratch.reg_base = mmSCRATCH_REG0; |
50261151 | 1799 | adev->gfx.scratch.free_mask = (1u << adev->gfx.scratch.num_reg) - 1; |
2cd46ad2 KW |
1800 | } |
1801 | ||
1802 | static int gfx_v6_0_ring_test_ring(struct amdgpu_ring *ring) | |
1803 | { | |
1804 | struct amdgpu_device *adev = ring->adev; | |
1805 | uint32_t scratch; | |
1806 | uint32_t tmp = 0; | |
1807 | unsigned i; | |
1808 | int r; | |
1809 | ||
1810 | r = amdgpu_gfx_scratch_get(adev, &scratch); | |
1811 | if (r) { | |
1812 | DRM_ERROR("amdgpu: cp failed to get scratch reg (%d).\n", r); | |
1813 | return r; | |
1814 | } | |
1815 | WREG32(scratch, 0xCAFEDEAD); | |
1816 | ||
1817 | r = amdgpu_ring_alloc(ring, 3); | |
1818 | if (r) { | |
1819 | DRM_ERROR("amdgpu: cp failed to lock ring %d (%d).\n", ring->idx, r); | |
1820 | amdgpu_gfx_scratch_free(adev, scratch); | |
1821 | return r; | |
1822 | } | |
1823 | amdgpu_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1)); | |
1824 | amdgpu_ring_write(ring, (scratch - PACKET3_SET_CONFIG_REG_START)); | |
1825 | amdgpu_ring_write(ring, 0xDEADBEEF); | |
1826 | amdgpu_ring_commit(ring); | |
1827 | ||
1828 | for (i = 0; i < adev->usec_timeout; i++) { | |
1829 | tmp = RREG32(scratch); | |
1830 | if (tmp == 0xDEADBEEF) | |
1831 | break; | |
1832 | DRM_UDELAY(1); | |
1833 | } | |
1834 | if (i < adev->usec_timeout) { | |
1835 | DRM_INFO("ring test on %d succeeded in %d usecs\n", ring->idx, i); | |
1836 | } else { | |
1837 | DRM_ERROR("amdgpu: ring %d test failed (scratch(0x%04X)=0x%08X)\n", | |
1838 | ring->idx, scratch, tmp); | |
1839 | r = -EINVAL; | |
1840 | } | |
1841 | amdgpu_gfx_scratch_free(adev, scratch); | |
1842 | return r; | |
1843 | } | |
1844 | ||
1845 | static void gfx_v6_0_ring_emit_hdp_flush(struct amdgpu_ring *ring) | |
1846 | { | |
1847 | /* flush hdp cache */ | |
1848 | amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); | |
1849 | amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(1) | | |
1850 | WRITE_DATA_DST_SEL(0))); | |
25069e06 | 1851 | amdgpu_ring_write(ring, mmHDP_MEM_COHERENCY_FLUSH_CNTL); |
2cd46ad2 KW |
1852 | amdgpu_ring_write(ring, 0); |
1853 | amdgpu_ring_write(ring, 0x1); | |
1854 | } | |
1855 | ||
45682886 ML |
1856 | static void gfx_v6_0_ring_emit_vgt_flush(struct amdgpu_ring *ring) |
1857 | { | |
1858 | amdgpu_ring_write(ring, PACKET3(PACKET3_EVENT_WRITE, 0)); | |
1859 | amdgpu_ring_write(ring, EVENT_TYPE(VGT_FLUSH) | | |
1860 | EVENT_INDEX(0)); | |
1861 | } | |
1862 | ||
2cd46ad2 KW |
1863 | /** |
1864 | * gfx_v6_0_ring_emit_hdp_invalidate - emit an hdp invalidate on the cp | |
1865 | * | |
1866 | * @adev: amdgpu_device pointer | |
1867 | * @ridx: amdgpu ring index | |
1868 | * | |
1869 | * Emits an hdp invalidate on the cp. | |
1870 | */ | |
1871 | static void gfx_v6_0_ring_emit_hdp_invalidate(struct amdgpu_ring *ring) | |
1872 | { | |
1873 | amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); | |
1874 | amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(1) | | |
1875 | WRITE_DATA_DST_SEL(0))); | |
25069e06 | 1876 | amdgpu_ring_write(ring, mmHDP_DEBUG0); |
2cd46ad2 KW |
1877 | amdgpu_ring_write(ring, 0); |
1878 | amdgpu_ring_write(ring, 0x1); | |
1879 | } | |
1880 | ||
668f52c3 AD |
1881 | static void gfx_v6_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, |
1882 | u64 seq, unsigned flags) | |
2cd46ad2 KW |
1883 | { |
1884 | bool write64bit = flags & AMDGPU_FENCE_FLAG_64BIT; | |
1885 | bool int_sel = flags & AMDGPU_FENCE_FLAG_INT; | |
1886 | /* flush read cache over gart */ | |
1887 | amdgpu_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1)); | |
25069e06 | 1888 | amdgpu_ring_write(ring, (mmCP_COHER_CNTL2 - PACKET3_SET_CONFIG_REG_START)); |
2cd46ad2 KW |
1889 | amdgpu_ring_write(ring, 0); |
1890 | amdgpu_ring_write(ring, PACKET3(PACKET3_SURFACE_SYNC, 3)); | |
1891 | amdgpu_ring_write(ring, PACKET3_TCL1_ACTION_ENA | | |
1892 | PACKET3_TC_ACTION_ENA | | |
1893 | PACKET3_SH_KCACHE_ACTION_ENA | | |
1894 | PACKET3_SH_ICACHE_ACTION_ENA); | |
1895 | amdgpu_ring_write(ring, 0xFFFFFFFF); | |
1896 | amdgpu_ring_write(ring, 0); | |
1897 | amdgpu_ring_write(ring, 10); /* poll interval */ | |
1898 | /* EVENT_WRITE_EOP - flush caches, send int */ | |
1899 | amdgpu_ring_write(ring, PACKET3(PACKET3_EVENT_WRITE_EOP, 4)); | |
1900 | amdgpu_ring_write(ring, EVENT_TYPE(CACHE_FLUSH_AND_INV_TS_EVENT) | EVENT_INDEX(5)); | |
1901 | amdgpu_ring_write(ring, addr & 0xfffffffc); | |
1902 | amdgpu_ring_write(ring, (upper_32_bits(addr) & 0xffff) | | |
25069e06 TSD |
1903 | ((write64bit ? 2 : 1) << CP_EOP_DONE_DATA_CNTL__DATA_SEL__SHIFT) | |
1904 | ((int_sel ? 2 : 0) << CP_EOP_DONE_DATA_CNTL__INT_SEL__SHIFT)); | |
2cd46ad2 KW |
1905 | amdgpu_ring_write(ring, lower_32_bits(seq)); |
1906 | amdgpu_ring_write(ring, upper_32_bits(seq)); | |
1907 | } | |
1908 | ||
668f52c3 AD |
1909 | static void gfx_v6_0_ring_emit_ib(struct amdgpu_ring *ring, |
1910 | struct amdgpu_ib *ib, | |
1911 | unsigned vm_id, bool ctx_switch) | |
2cd46ad2 KW |
1912 | { |
1913 | u32 header, control = 0; | |
1914 | ||
1915 | /* insert SWITCH_BUFFER packet before first IB in the ring frame */ | |
1916 | if (ctx_switch) { | |
1917 | amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); | |
1918 | amdgpu_ring_write(ring, 0); | |
1919 | } | |
1920 | ||
1921 | if (ib->flags & AMDGPU_IB_FLAG_CE) | |
1922 | header = PACKET3(PACKET3_INDIRECT_BUFFER_CONST, 2); | |
1923 | else | |
1924 | header = PACKET3(PACKET3_INDIRECT_BUFFER, 2); | |
1925 | ||
1926 | control |= ib->length_dw | (vm_id << 24); | |
1927 | ||
1928 | amdgpu_ring_write(ring, header); | |
1929 | amdgpu_ring_write(ring, | |
1930 | #ifdef __BIG_ENDIAN | |
1931 | (2 << 0) | | |
1932 | #endif | |
1933 | (ib->gpu_addr & 0xFFFFFFFC)); | |
1934 | amdgpu_ring_write(ring, upper_32_bits(ib->gpu_addr) & 0xFFFF); | |
1935 | amdgpu_ring_write(ring, control); | |
1936 | } | |
1937 | ||
2cd46ad2 KW |
1938 | /** |
1939 | * gfx_v6_0_ring_test_ib - basic ring IB test | |
1940 | * | |
1941 | * @ring: amdgpu_ring structure holding ring information | |
1942 | * | |
1943 | * Allocate an IB and execute it on the gfx ring (SI). | |
1944 | * Provides a basic gfx ring test to verify that IBs are working. | |
1945 | * Returns 0 on success, error on failure. | |
1946 | */ | |
1947 | static int gfx_v6_0_ring_test_ib(struct amdgpu_ring *ring, long timeout) | |
1948 | { | |
1949 | struct amdgpu_device *adev = ring->adev; | |
1950 | struct amdgpu_ib ib; | |
f54d1867 | 1951 | struct dma_fence *f = NULL; |
2cd46ad2 KW |
1952 | uint32_t scratch; |
1953 | uint32_t tmp = 0; | |
1954 | long r; | |
1955 | ||
1956 | r = amdgpu_gfx_scratch_get(adev, &scratch); | |
1957 | if (r) { | |
1958 | DRM_ERROR("amdgpu: failed to get scratch reg (%ld).\n", r); | |
1959 | return r; | |
1960 | } | |
1961 | WREG32(scratch, 0xCAFEDEAD); | |
1962 | memset(&ib, 0, sizeof(ib)); | |
1963 | r = amdgpu_ib_get(adev, NULL, 256, &ib); | |
1964 | if (r) { | |
1965 | DRM_ERROR("amdgpu: failed to get ib (%ld).\n", r); | |
1966 | goto err1; | |
1967 | } | |
1968 | ib.ptr[0] = PACKET3(PACKET3_SET_CONFIG_REG, 1); | |
1969 | ib.ptr[1] = ((scratch - PACKET3_SET_CONFIG_REG_START)); | |
1970 | ib.ptr[2] = 0xDEADBEEF; | |
1971 | ib.length_dw = 3; | |
1972 | ||
50ddc75e | 1973 | r = amdgpu_ib_schedule(ring, 1, &ib, NULL, &f); |
2cd46ad2 KW |
1974 | if (r) |
1975 | goto err2; | |
1976 | ||
f54d1867 | 1977 | r = dma_fence_wait_timeout(f, false, timeout); |
2cd46ad2 KW |
1978 | if (r == 0) { |
1979 | DRM_ERROR("amdgpu: IB test timed out\n"); | |
1980 | r = -ETIMEDOUT; | |
1981 | goto err2; | |
1982 | } else if (r < 0) { | |
1983 | DRM_ERROR("amdgpu: fence wait failed (%ld).\n", r); | |
1984 | goto err2; | |
1985 | } | |
1986 | tmp = RREG32(scratch); | |
1987 | if (tmp == 0xDEADBEEF) { | |
1988 | DRM_INFO("ib test on ring %d succeeded\n", ring->idx); | |
1989 | r = 0; | |
1990 | } else { | |
1991 | DRM_ERROR("amdgpu: ib test failed (scratch(0x%04X)=0x%08X)\n", | |
1992 | scratch, tmp); | |
1993 | r = -EINVAL; | |
1994 | } | |
1995 | ||
1996 | err2: | |
1997 | amdgpu_ib_free(adev, &ib, NULL); | |
f54d1867 | 1998 | dma_fence_put(f); |
2cd46ad2 KW |
1999 | err1: |
2000 | amdgpu_gfx_scratch_free(adev, scratch); | |
2001 | return r; | |
2002 | } | |
2003 | ||
2004 | static void gfx_v6_0_cp_gfx_enable(struct amdgpu_device *adev, bool enable) | |
2005 | { | |
2006 | int i; | |
25069e06 TSD |
2007 | if (enable) { |
2008 | WREG32(mmCP_ME_CNTL, 0); | |
2009 | } else { | |
2010 | WREG32(mmCP_ME_CNTL, (CP_ME_CNTL__ME_HALT_MASK | | |
2011 | CP_ME_CNTL__PFP_HALT_MASK | | |
2012 | CP_ME_CNTL__CE_HALT_MASK)); | |
2013 | WREG32(mmSCRATCH_UMSK, 0); | |
2cd46ad2 KW |
2014 | for (i = 0; i < adev->gfx.num_gfx_rings; i++) |
2015 | adev->gfx.gfx_ring[i].ready = false; | |
2016 | for (i = 0; i < adev->gfx.num_compute_rings; i++) | |
2017 | adev->gfx.compute_ring[i].ready = false; | |
2018 | } | |
2019 | udelay(50); | |
2020 | } | |
2021 | ||
2022 | static int gfx_v6_0_cp_gfx_load_microcode(struct amdgpu_device *adev) | |
2023 | { | |
2024 | unsigned i; | |
2025 | const struct gfx_firmware_header_v1_0 *pfp_hdr; | |
2026 | const struct gfx_firmware_header_v1_0 *ce_hdr; | |
2027 | const struct gfx_firmware_header_v1_0 *me_hdr; | |
2028 | const __le32 *fw_data; | |
2029 | u32 fw_size; | |
2030 | ||
2031 | if (!adev->gfx.me_fw || !adev->gfx.pfp_fw || !adev->gfx.ce_fw) | |
2032 | return -EINVAL; | |
2033 | ||
2034 | gfx_v6_0_cp_gfx_enable(adev, false); | |
2035 | pfp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.pfp_fw->data; | |
2036 | ce_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.ce_fw->data; | |
2037 | me_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.me_fw->data; | |
2038 | ||
2039 | amdgpu_ucode_print_gfx_hdr(&pfp_hdr->header); | |
2040 | amdgpu_ucode_print_gfx_hdr(&ce_hdr->header); | |
2041 | amdgpu_ucode_print_gfx_hdr(&me_hdr->header); | |
2042 | ||
2043 | /* PFP */ | |
2044 | fw_data = (const __le32 *) | |
2045 | (adev->gfx.pfp_fw->data + le32_to_cpu(pfp_hdr->header.ucode_array_offset_bytes)); | |
2046 | fw_size = le32_to_cpu(pfp_hdr->header.ucode_size_bytes) / 4; | |
25069e06 | 2047 | WREG32(mmCP_PFP_UCODE_ADDR, 0); |
2cd46ad2 | 2048 | for (i = 0; i < fw_size; i++) |
25069e06 TSD |
2049 | WREG32(mmCP_PFP_UCODE_DATA, le32_to_cpup(fw_data++)); |
2050 | WREG32(mmCP_PFP_UCODE_ADDR, 0); | |
2cd46ad2 KW |
2051 | |
2052 | /* CE */ | |
2053 | fw_data = (const __le32 *) | |
2054 | (adev->gfx.ce_fw->data + le32_to_cpu(ce_hdr->header.ucode_array_offset_bytes)); | |
2055 | fw_size = le32_to_cpu(ce_hdr->header.ucode_size_bytes) / 4; | |
25069e06 | 2056 | WREG32(mmCP_CE_UCODE_ADDR, 0); |
2cd46ad2 | 2057 | for (i = 0; i < fw_size; i++) |
25069e06 TSD |
2058 | WREG32(mmCP_CE_UCODE_DATA, le32_to_cpup(fw_data++)); |
2059 | WREG32(mmCP_CE_UCODE_ADDR, 0); | |
2cd46ad2 KW |
2060 | |
2061 | /* ME */ | |
2062 | fw_data = (const __be32 *) | |
2063 | (adev->gfx.me_fw->data + le32_to_cpu(me_hdr->header.ucode_array_offset_bytes)); | |
2064 | fw_size = le32_to_cpu(me_hdr->header.ucode_size_bytes) / 4; | |
25069e06 | 2065 | WREG32(mmCP_ME_RAM_WADDR, 0); |
2cd46ad2 | 2066 | for (i = 0; i < fw_size; i++) |
25069e06 TSD |
2067 | WREG32(mmCP_ME_RAM_DATA, le32_to_cpup(fw_data++)); |
2068 | WREG32(mmCP_ME_RAM_WADDR, 0); | |
2cd46ad2 | 2069 | |
25069e06 TSD |
2070 | WREG32(mmCP_PFP_UCODE_ADDR, 0); |
2071 | WREG32(mmCP_CE_UCODE_ADDR, 0); | |
2072 | WREG32(mmCP_ME_RAM_WADDR, 0); | |
2073 | WREG32(mmCP_ME_RAM_RADDR, 0); | |
2cd46ad2 KW |
2074 | return 0; |
2075 | } | |
2076 | ||
2077 | static int gfx_v6_0_cp_gfx_start(struct amdgpu_device *adev) | |
2078 | { | |
2079 | const struct cs_section_def *sect = NULL; | |
2080 | const struct cs_extent_def *ext = NULL; | |
2081 | struct amdgpu_ring *ring = &adev->gfx.gfx_ring[0]; | |
2082 | int r, i; | |
2083 | ||
2084 | r = amdgpu_ring_alloc(ring, 7 + 4); | |
2085 | if (r) { | |
2086 | DRM_ERROR("amdgpu: cp failed to lock ring (%d).\n", r); | |
2087 | return r; | |
2088 | } | |
2089 | amdgpu_ring_write(ring, PACKET3(PACKET3_ME_INITIALIZE, 5)); | |
2090 | amdgpu_ring_write(ring, 0x1); | |
2091 | amdgpu_ring_write(ring, 0x0); | |
2092 | amdgpu_ring_write(ring, adev->gfx.config.max_hw_contexts - 1); | |
2093 | amdgpu_ring_write(ring, PACKET3_ME_INITIALIZE_DEVICE_ID(1)); | |
2094 | amdgpu_ring_write(ring, 0); | |
2095 | amdgpu_ring_write(ring, 0); | |
2096 | ||
2097 | amdgpu_ring_write(ring, PACKET3(PACKET3_SET_BASE, 2)); | |
2098 | amdgpu_ring_write(ring, PACKET3_BASE_INDEX(CE_PARTITION_BASE)); | |
2099 | amdgpu_ring_write(ring, 0xc000); | |
2100 | amdgpu_ring_write(ring, 0xe000); | |
2101 | amdgpu_ring_commit(ring); | |
2102 | ||
2103 | gfx_v6_0_cp_gfx_enable(adev, true); | |
2104 | ||
2105 | r = amdgpu_ring_alloc(ring, gfx_v6_0_get_csb_size(adev) + 10); | |
2106 | if (r) { | |
2107 | DRM_ERROR("amdgpu: cp failed to lock ring (%d).\n", r); | |
2108 | return r; | |
2109 | } | |
2110 | ||
2111 | amdgpu_ring_write(ring, PACKET3(PACKET3_PREAMBLE_CNTL, 0)); | |
2112 | amdgpu_ring_write(ring, PACKET3_PREAMBLE_BEGIN_CLEAR_STATE); | |
2113 | ||
2114 | for (sect = adev->gfx.rlc.cs_data; sect->section != NULL; ++sect) { | |
2115 | for (ext = sect->section; ext->extent != NULL; ++ext) { | |
2116 | if (sect->id == SECT_CONTEXT) { | |
2117 | amdgpu_ring_write(ring, | |
2118 | PACKET3(PACKET3_SET_CONTEXT_REG, ext->reg_count)); | |
2119 | amdgpu_ring_write(ring, ext->reg_index - PACKET3_SET_CONTEXT_REG_START); | |
2120 | for (i = 0; i < ext->reg_count; i++) | |
2121 | amdgpu_ring_write(ring, ext->extent[i]); | |
2122 | } | |
2123 | } | |
2124 | } | |
2125 | ||
2126 | amdgpu_ring_write(ring, PACKET3(PACKET3_PREAMBLE_CNTL, 0)); | |
2127 | amdgpu_ring_write(ring, PACKET3_PREAMBLE_END_CLEAR_STATE); | |
2128 | ||
2129 | amdgpu_ring_write(ring, PACKET3(PACKET3_CLEAR_STATE, 0)); | |
2130 | amdgpu_ring_write(ring, 0); | |
2131 | ||
2132 | amdgpu_ring_write(ring, PACKET3(PACKET3_SET_CONTEXT_REG, 2)); | |
2133 | amdgpu_ring_write(ring, 0x00000316); | |
2134 | amdgpu_ring_write(ring, 0x0000000e); | |
2135 | amdgpu_ring_write(ring, 0x00000010); | |
2136 | ||
2137 | amdgpu_ring_commit(ring); | |
2138 | ||
2139 | return 0; | |
2140 | } | |
2141 | ||
2142 | static int gfx_v6_0_cp_gfx_resume(struct amdgpu_device *adev) | |
2143 | { | |
2144 | struct amdgpu_ring *ring; | |
2145 | u32 tmp; | |
2146 | u32 rb_bufsz; | |
2147 | int r; | |
2148 | u64 rptr_addr; | |
2149 | ||
25069e06 TSD |
2150 | WREG32(mmCP_SEM_WAIT_TIMER, 0x0); |
2151 | WREG32(mmCP_SEM_INCOMPLETE_TIMER_CNTL, 0x0); | |
2cd46ad2 KW |
2152 | |
2153 | /* Set the write pointer delay */ | |
25069e06 | 2154 | WREG32(mmCP_RB_WPTR_DELAY, 0); |
2cd46ad2 | 2155 | |
25069e06 TSD |
2156 | WREG32(mmCP_DEBUG, 0); |
2157 | WREG32(mmSCRATCH_ADDR, 0); | |
2cd46ad2 KW |
2158 | |
2159 | /* ring 0 - compute and gfx */ | |
2160 | /* Set ring buffer size */ | |
2161 | ring = &adev->gfx.gfx_ring[0]; | |
2162 | rb_bufsz = order_base_2(ring->ring_size / 8); | |
2163 | tmp = (order_base_2(AMDGPU_GPU_PAGE_SIZE/8) << 8) | rb_bufsz; | |
2164 | ||
2165 | #ifdef __BIG_ENDIAN | |
2166 | tmp |= BUF_SWAP_32BIT; | |
2167 | #endif | |
25069e06 | 2168 | WREG32(mmCP_RB0_CNTL, tmp); |
2cd46ad2 KW |
2169 | |
2170 | /* Initialize the ring buffer's read and write pointers */ | |
25069e06 | 2171 | WREG32(mmCP_RB0_CNTL, tmp | CP_RB0_CNTL__RB_RPTR_WR_ENA_MASK); |
2cd46ad2 | 2172 | ring->wptr = 0; |
25069e06 | 2173 | WREG32(mmCP_RB0_WPTR, ring->wptr); |
2cd46ad2 KW |
2174 | |
2175 | /* set the wb address whether it's enabled or not */ | |
2176 | rptr_addr = adev->wb.gpu_addr + (ring->rptr_offs * 4); | |
25069e06 TSD |
2177 | WREG32(mmCP_RB0_RPTR_ADDR, lower_32_bits(rptr_addr)); |
2178 | WREG32(mmCP_RB0_RPTR_ADDR_HI, upper_32_bits(rptr_addr) & 0xFF); | |
2cd46ad2 | 2179 | |
25069e06 | 2180 | WREG32(mmSCRATCH_UMSK, 0); |
2cd46ad2 KW |
2181 | |
2182 | mdelay(1); | |
25069e06 | 2183 | WREG32(mmCP_RB0_CNTL, tmp); |
2cd46ad2 | 2184 | |
25069e06 | 2185 | WREG32(mmCP_RB0_BASE, ring->gpu_addr >> 8); |
2cd46ad2 KW |
2186 | |
2187 | /* start the rings */ | |
2188 | gfx_v6_0_cp_gfx_start(adev); | |
2189 | ring->ready = true; | |
2190 | r = amdgpu_ring_test_ring(ring); | |
2191 | if (r) { | |
2192 | ring->ready = false; | |
2193 | return r; | |
2194 | } | |
2195 | ||
2196 | return 0; | |
2197 | } | |
2198 | ||
6f924e20 | 2199 | static u32 gfx_v6_0_ring_get_rptr(struct amdgpu_ring *ring) |
2cd46ad2 | 2200 | { |
4aeacf0f | 2201 | return ring->adev->wb.wb[ring->rptr_offs]; |
2cd46ad2 KW |
2202 | } |
2203 | ||
832c6ef7 | 2204 | static u32 gfx_v6_0_ring_get_wptr(struct amdgpu_ring *ring) |
2cd46ad2 KW |
2205 | { |
2206 | struct amdgpu_device *adev = ring->adev; | |
2cd46ad2 | 2207 | |
832c6ef7 | 2208 | if (ring == &adev->gfx.gfx_ring[0]) |
25069e06 | 2209 | return RREG32(mmCP_RB0_WPTR); |
832c6ef7 | 2210 | else if (ring == &adev->gfx.compute_ring[0]) |
25069e06 | 2211 | return RREG32(mmCP_RB1_WPTR); |
832c6ef7 | 2212 | else if (ring == &adev->gfx.compute_ring[1]) |
25069e06 | 2213 | return RREG32(mmCP_RB2_WPTR); |
832c6ef7 TSD |
2214 | else |
2215 | BUG(); | |
2cd46ad2 KW |
2216 | } |
2217 | ||
2218 | static void gfx_v6_0_ring_set_wptr_gfx(struct amdgpu_ring *ring) | |
2219 | { | |
2220 | struct amdgpu_device *adev = ring->adev; | |
2221 | ||
25069e06 TSD |
2222 | WREG32(mmCP_RB0_WPTR, ring->wptr); |
2223 | (void)RREG32(mmCP_RB0_WPTR); | |
2cd46ad2 KW |
2224 | } |
2225 | ||
2cd46ad2 KW |
2226 | static void gfx_v6_0_ring_set_wptr_compute(struct amdgpu_ring *ring) |
2227 | { | |
2228 | struct amdgpu_device *adev = ring->adev; | |
2229 | ||
2230 | if (ring == &adev->gfx.compute_ring[0]) { | |
25069e06 TSD |
2231 | WREG32(mmCP_RB1_WPTR, ring->wptr); |
2232 | (void)RREG32(mmCP_RB1_WPTR); | |
2cd46ad2 | 2233 | } else if (ring == &adev->gfx.compute_ring[1]) { |
25069e06 TSD |
2234 | WREG32(mmCP_RB2_WPTR, ring->wptr); |
2235 | (void)RREG32(mmCP_RB2_WPTR); | |
2cd46ad2 KW |
2236 | } else { |
2237 | BUG(); | |
2238 | } | |
2239 | ||
2240 | } | |
2241 | ||
2cd46ad2 KW |
2242 | static int gfx_v6_0_cp_compute_resume(struct amdgpu_device *adev) |
2243 | { | |
2244 | struct amdgpu_ring *ring; | |
2245 | u32 tmp; | |
2246 | u32 rb_bufsz; | |
25069e06 | 2247 | int i, r; |
2cd46ad2 KW |
2248 | u64 rptr_addr; |
2249 | ||
2250 | /* ring1 - compute only */ | |
2251 | /* Set ring buffer size */ | |
2252 | ||
2253 | ring = &adev->gfx.compute_ring[0]; | |
2254 | rb_bufsz = order_base_2(ring->ring_size / 8); | |
2255 | tmp = (order_base_2(AMDGPU_GPU_PAGE_SIZE/8) << 8) | rb_bufsz; | |
2256 | #ifdef __BIG_ENDIAN | |
2257 | tmp |= BUF_SWAP_32BIT; | |
2258 | #endif | |
25069e06 | 2259 | WREG32(mmCP_RB1_CNTL, tmp); |
2cd46ad2 | 2260 | |
25069e06 | 2261 | WREG32(mmCP_RB1_CNTL, tmp | CP_RB1_CNTL__RB_RPTR_WR_ENA_MASK); |
2cd46ad2 | 2262 | ring->wptr = 0; |
25069e06 | 2263 | WREG32(mmCP_RB1_WPTR, ring->wptr); |
2cd46ad2 | 2264 | |
2cd46ad2 | 2265 | rptr_addr = adev->wb.gpu_addr + (ring->rptr_offs * 4); |
25069e06 TSD |
2266 | WREG32(mmCP_RB1_RPTR_ADDR, lower_32_bits(rptr_addr)); |
2267 | WREG32(mmCP_RB1_RPTR_ADDR_HI, upper_32_bits(rptr_addr) & 0xFF); | |
2cd46ad2 KW |
2268 | |
2269 | mdelay(1); | |
25069e06 TSD |
2270 | WREG32(mmCP_RB1_CNTL, tmp); |
2271 | WREG32(mmCP_RB1_BASE, ring->gpu_addr >> 8); | |
2cd46ad2 KW |
2272 | |
2273 | ring = &adev->gfx.compute_ring[1]; | |
2274 | rb_bufsz = order_base_2(ring->ring_size / 8); | |
2275 | tmp = (order_base_2(AMDGPU_GPU_PAGE_SIZE/8) << 8) | rb_bufsz; | |
2276 | #ifdef __BIG_ENDIAN | |
2277 | tmp |= BUF_SWAP_32BIT; | |
2278 | #endif | |
25069e06 | 2279 | WREG32(mmCP_RB2_CNTL, tmp); |
2cd46ad2 | 2280 | |
25069e06 | 2281 | WREG32(mmCP_RB2_CNTL, tmp | CP_RB2_CNTL__RB_RPTR_WR_ENA_MASK); |
2cd46ad2 | 2282 | ring->wptr = 0; |
25069e06 | 2283 | WREG32(mmCP_RB2_WPTR, ring->wptr); |
2cd46ad2 | 2284 | rptr_addr = adev->wb.gpu_addr + (ring->rptr_offs * 4); |
25069e06 TSD |
2285 | WREG32(mmCP_RB2_RPTR_ADDR, lower_32_bits(rptr_addr)); |
2286 | WREG32(mmCP_RB2_RPTR_ADDR_HI, upper_32_bits(rptr_addr) & 0xFF); | |
2cd46ad2 KW |
2287 | |
2288 | mdelay(1); | |
25069e06 TSD |
2289 | WREG32(mmCP_RB2_CNTL, tmp); |
2290 | WREG32(mmCP_RB2_BASE, ring->gpu_addr >> 8); | |
2cd46ad2 | 2291 | |
25069e06 TSD |
2292 | adev->gfx.compute_ring[0].ready = false; |
2293 | adev->gfx.compute_ring[1].ready = false; | |
2cd46ad2 | 2294 | |
25069e06 TSD |
2295 | for (i = 0; i < 2; i++) { |
2296 | r = amdgpu_ring_test_ring(&adev->gfx.compute_ring[i]); | |
2297 | if (r) | |
2298 | return r; | |
2299 | adev->gfx.compute_ring[i].ready = true; | |
2cd46ad2 KW |
2300 | } |
2301 | ||
2302 | return 0; | |
2303 | } | |
2304 | ||
2305 | static void gfx_v6_0_cp_enable(struct amdgpu_device *adev, bool enable) | |
2306 | { | |
2307 | gfx_v6_0_cp_gfx_enable(adev, enable); | |
2308 | } | |
2309 | ||
2310 | static int gfx_v6_0_cp_load_microcode(struct amdgpu_device *adev) | |
2311 | { | |
4aeacf0f | 2312 | return gfx_v6_0_cp_gfx_load_microcode(adev); |
2cd46ad2 KW |
2313 | } |
2314 | ||
2315 | static void gfx_v6_0_enable_gui_idle_interrupt(struct amdgpu_device *adev, | |
2316 | bool enable) | |
45682886 | 2317 | { |
25069e06 | 2318 | u32 tmp = RREG32(mmCP_INT_CNTL_RING0); |
2cd46ad2 KW |
2319 | u32 mask; |
2320 | int i; | |
2321 | ||
2322 | if (enable) | |
25069e06 TSD |
2323 | tmp |= (CP_INT_CNTL__CNTX_BUSY_INT_ENABLE_MASK | |
2324 | CP_INT_CNTL__CNTX_EMPTY_INT_ENABLE_MASK); | |
2cd46ad2 | 2325 | else |
25069e06 TSD |
2326 | tmp &= ~(CP_INT_CNTL__CNTX_BUSY_INT_ENABLE_MASK | |
2327 | CP_INT_CNTL__CNTX_EMPTY_INT_ENABLE_MASK); | |
2328 | WREG32(mmCP_INT_CNTL_RING0, tmp); | |
2cd46ad2 KW |
2329 | |
2330 | if (!enable) { | |
2331 | /* read a gfx register */ | |
25069e06 | 2332 | tmp = RREG32(mmDB_DEPTH_INFO); |
2cd46ad2 KW |
2333 | |
2334 | mask = RLC_BUSY_STATUS | GFX_POWER_STATUS | GFX_CLOCK_STATUS | GFX_LS_STATUS; | |
2335 | for (i = 0; i < adev->usec_timeout; i++) { | |
25069e06 | 2336 | if ((RREG32(mmRLC_STAT) & mask) == (GFX_CLOCK_STATUS | GFX_POWER_STATUS)) |
2cd46ad2 KW |
2337 | break; |
2338 | udelay(1); | |
2339 | } | |
2340 | } | |
2341 | } | |
2342 | ||
2343 | static int gfx_v6_0_cp_resume(struct amdgpu_device *adev) | |
2344 | { | |
2345 | int r; | |
2346 | ||
2347 | gfx_v6_0_enable_gui_idle_interrupt(adev, false); | |
2348 | ||
2349 | r = gfx_v6_0_cp_load_microcode(adev); | |
2350 | if (r) | |
2351 | return r; | |
2352 | ||
2353 | r = gfx_v6_0_cp_gfx_resume(adev); | |
2354 | if (r) | |
2355 | return r; | |
2356 | r = gfx_v6_0_cp_compute_resume(adev); | |
2357 | if (r) | |
2358 | return r; | |
2359 | ||
2360 | gfx_v6_0_enable_gui_idle_interrupt(adev, true); | |
2361 | ||
2362 | return 0; | |
2363 | } | |
2364 | ||
2365 | static void gfx_v6_0_ring_emit_pipeline_sync(struct amdgpu_ring *ring) | |
2366 | { | |
21cd942e | 2367 | int usepfp = (ring->funcs->type == AMDGPU_RING_TYPE_GFX); |
2cd46ad2 KW |
2368 | uint32_t seq = ring->fence_drv.sync_seq; |
2369 | uint64_t addr = ring->fence_drv.gpu_addr; | |
2370 | ||
2371 | amdgpu_ring_write(ring, PACKET3(PACKET3_WAIT_REG_MEM, 5)); | |
2372 | amdgpu_ring_write(ring, (WAIT_REG_MEM_MEM_SPACE(1) | /* memory */ | |
2373 | WAIT_REG_MEM_FUNCTION(3) | /* equal */ | |
2374 | WAIT_REG_MEM_ENGINE(usepfp))); /* pfp or me */ | |
2375 | amdgpu_ring_write(ring, addr & 0xfffffffc); | |
2376 | amdgpu_ring_write(ring, upper_32_bits(addr) & 0xffffffff); | |
2377 | amdgpu_ring_write(ring, seq); | |
2378 | amdgpu_ring_write(ring, 0xffffffff); | |
2379 | amdgpu_ring_write(ring, 4); /* poll interval */ | |
2380 | ||
2381 | if (usepfp) { | |
2382 | /* synce CE with ME to prevent CE fetch CEIB before context switch done */ | |
2383 | amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); | |
2384 | amdgpu_ring_write(ring, 0); | |
2385 | amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); | |
2386 | amdgpu_ring_write(ring, 0); | |
2387 | } | |
2388 | } | |
2389 | ||
2390 | static void gfx_v6_0_ring_emit_vm_flush(struct amdgpu_ring *ring, | |
2391 | unsigned vm_id, uint64_t pd_addr) | |
2392 | { | |
21cd942e | 2393 | int usepfp = (ring->funcs->type == AMDGPU_RING_TYPE_GFX); |
2cd46ad2 KW |
2394 | |
2395 | /* write new base address */ | |
2396 | amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); | |
2397 | amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(1) | | |
2398 | WRITE_DATA_DST_SEL(0))); | |
2399 | if (vm_id < 8) { | |
25069e06 | 2400 | amdgpu_ring_write(ring, (mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR + vm_id )); |
2cd46ad2 | 2401 | } else { |
25069e06 | 2402 | amdgpu_ring_write(ring, (mmVM_CONTEXT8_PAGE_TABLE_BASE_ADDR + (vm_id - 8))); |
2cd46ad2 KW |
2403 | } |
2404 | amdgpu_ring_write(ring, 0); | |
2405 | amdgpu_ring_write(ring, pd_addr >> 12); | |
2406 | ||
2407 | /* bits 0-15 are the VM contexts0-15 */ | |
2408 | amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); | |
2409 | amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(1) | | |
2410 | WRITE_DATA_DST_SEL(0))); | |
25069e06 | 2411 | amdgpu_ring_write(ring, mmVM_INVALIDATE_REQUEST); |
2cd46ad2 KW |
2412 | amdgpu_ring_write(ring, 0); |
2413 | amdgpu_ring_write(ring, 1 << vm_id); | |
2414 | ||
2415 | /* wait for the invalidate to complete */ | |
2416 | amdgpu_ring_write(ring, PACKET3(PACKET3_WAIT_REG_MEM, 5)); | |
2417 | amdgpu_ring_write(ring, (WAIT_REG_MEM_FUNCTION(0) | /* always */ | |
2418 | WAIT_REG_MEM_ENGINE(0))); /* me */ | |
25069e06 | 2419 | amdgpu_ring_write(ring, mmVM_INVALIDATE_REQUEST); |
2cd46ad2 KW |
2420 | amdgpu_ring_write(ring, 0); |
2421 | amdgpu_ring_write(ring, 0); /* ref */ | |
2422 | amdgpu_ring_write(ring, 0); /* mask */ | |
2423 | amdgpu_ring_write(ring, 0x20); /* poll interval */ | |
2424 | ||
2425 | if (usepfp) { | |
2426 | /* sync PFP to ME, otherwise we might get invalid PFP reads */ | |
2427 | amdgpu_ring_write(ring, PACKET3(PACKET3_PFP_SYNC_ME, 0)); | |
2428 | amdgpu_ring_write(ring, 0x0); | |
2429 | ||
2430 | /* synce CE with ME to prevent CE fetch CEIB before context switch done */ | |
2431 | amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); | |
2432 | amdgpu_ring_write(ring, 0); | |
2433 | amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); | |
2434 | amdgpu_ring_write(ring, 0); | |
2435 | } | |
2436 | } | |
2437 | ||
2438 | ||
2439 | static void gfx_v6_0_rlc_fini(struct amdgpu_device *adev) | |
2440 | { | |
2441 | int r; | |
2442 | ||
2443 | if (adev->gfx.rlc.save_restore_obj) { | |
2444 | r = amdgpu_bo_reserve(adev->gfx.rlc.save_restore_obj, false); | |
2445 | if (unlikely(r != 0)) | |
2446 | dev_warn(adev->dev, "(%d) reserve RLC sr bo failed\n", r); | |
2447 | amdgpu_bo_unpin(adev->gfx.rlc.save_restore_obj); | |
2448 | amdgpu_bo_unreserve(adev->gfx.rlc.save_restore_obj); | |
2449 | ||
2450 | amdgpu_bo_unref(&adev->gfx.rlc.save_restore_obj); | |
2451 | adev->gfx.rlc.save_restore_obj = NULL; | |
2452 | } | |
2453 | ||
2454 | if (adev->gfx.rlc.clear_state_obj) { | |
2455 | r = amdgpu_bo_reserve(adev->gfx.rlc.clear_state_obj, false); | |
2456 | if (unlikely(r != 0)) | |
2457 | dev_warn(adev->dev, "(%d) reserve RLC c bo failed\n", r); | |
2458 | amdgpu_bo_unpin(adev->gfx.rlc.clear_state_obj); | |
2459 | amdgpu_bo_unreserve(adev->gfx.rlc.clear_state_obj); | |
2460 | ||
2461 | amdgpu_bo_unref(&adev->gfx.rlc.clear_state_obj); | |
2462 | adev->gfx.rlc.clear_state_obj = NULL; | |
2463 | } | |
2464 | ||
2465 | if (adev->gfx.rlc.cp_table_obj) { | |
2466 | r = amdgpu_bo_reserve(adev->gfx.rlc.cp_table_obj, false); | |
2467 | if (unlikely(r != 0)) | |
2468 | dev_warn(adev->dev, "(%d) reserve RLC cp table bo failed\n", r); | |
2469 | amdgpu_bo_unpin(adev->gfx.rlc.cp_table_obj); | |
2470 | amdgpu_bo_unreserve(adev->gfx.rlc.cp_table_obj); | |
2471 | ||
2472 | amdgpu_bo_unref(&adev->gfx.rlc.cp_table_obj); | |
2473 | adev->gfx.rlc.cp_table_obj = NULL; | |
2474 | } | |
2475 | } | |
2476 | ||
2477 | static int gfx_v6_0_rlc_init(struct amdgpu_device *adev) | |
2478 | { | |
2479 | const u32 *src_ptr; | |
2480 | volatile u32 *dst_ptr; | |
2481 | u32 dws, i; | |
2482 | u64 reg_list_mc_addr; | |
2483 | const struct cs_section_def *cs_data; | |
2484 | int r; | |
2485 | ||
2486 | adev->gfx.rlc.reg_list = verde_rlc_save_restore_register_list; | |
2487 | adev->gfx.rlc.reg_list_size = | |
2488 | (u32)ARRAY_SIZE(verde_rlc_save_restore_register_list); | |
2489 | ||
2490 | adev->gfx.rlc.cs_data = si_cs_data; | |
2491 | src_ptr = adev->gfx.rlc.reg_list; | |
2492 | dws = adev->gfx.rlc.reg_list_size; | |
2493 | cs_data = adev->gfx.rlc.cs_data; | |
2494 | ||
2495 | if (src_ptr) { | |
2496 | /* save restore block */ | |
2497 | if (adev->gfx.rlc.save_restore_obj == NULL) { | |
2cd46ad2 KW |
2498 | r = amdgpu_bo_create(adev, dws * 4, PAGE_SIZE, true, |
2499 | AMDGPU_GEM_DOMAIN_VRAM, | |
2500 | AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED, | |
2501 | NULL, NULL, | |
2502 | &adev->gfx.rlc.save_restore_obj); | |
2503 | ||
2504 | if (r) { | |
2505 | dev_warn(adev->dev, "(%d) create RLC sr bo failed\n", r); | |
2506 | return r; | |
2507 | } | |
2508 | } | |
2509 | ||
2510 | r = amdgpu_bo_reserve(adev->gfx.rlc.save_restore_obj, false); | |
2511 | if (unlikely(r != 0)) { | |
2512 | gfx_v6_0_rlc_fini(adev); | |
2513 | return r; | |
2514 | } | |
2515 | r = amdgpu_bo_pin(adev->gfx.rlc.save_restore_obj, AMDGPU_GEM_DOMAIN_VRAM, | |
2516 | &adev->gfx.rlc.save_restore_gpu_addr); | |
2517 | if (r) { | |
2518 | amdgpu_bo_unreserve(adev->gfx.rlc.save_restore_obj); | |
2519 | dev_warn(adev->dev, "(%d) pin RLC sr bo failed\n", r); | |
2520 | gfx_v6_0_rlc_fini(adev); | |
2521 | return r; | |
2522 | } | |
2523 | ||
2524 | r = amdgpu_bo_kmap(adev->gfx.rlc.save_restore_obj, (void **)&adev->gfx.rlc.sr_ptr); | |
2525 | if (r) { | |
2526 | dev_warn(adev->dev, "(%d) map RLC sr bo failed\n", r); | |
2527 | gfx_v6_0_rlc_fini(adev); | |
2528 | return r; | |
2529 | } | |
2530 | /* write the sr buffer */ | |
2531 | dst_ptr = adev->gfx.rlc.sr_ptr; | |
2532 | for (i = 0; i < adev->gfx.rlc.reg_list_size; i++) | |
2533 | dst_ptr[i] = cpu_to_le32(src_ptr[i]); | |
2534 | amdgpu_bo_kunmap(adev->gfx.rlc.save_restore_obj); | |
2535 | amdgpu_bo_unreserve(adev->gfx.rlc.save_restore_obj); | |
2536 | } | |
2537 | ||
2538 | if (cs_data) { | |
2539 | /* clear state block */ | |
2540 | adev->gfx.rlc.clear_state_size = gfx_v6_0_get_csb_size(adev); | |
2541 | dws = adev->gfx.rlc.clear_state_size + (256 / 4); | |
2542 | ||
2543 | if (adev->gfx.rlc.clear_state_obj == NULL) { | |
2544 | r = amdgpu_bo_create(adev, dws * 4, PAGE_SIZE, true, | |
2545 | AMDGPU_GEM_DOMAIN_VRAM, | |
2546 | AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED, | |
2547 | NULL, NULL, | |
2548 | &adev->gfx.rlc.clear_state_obj); | |
2549 | ||
2550 | if (r) { | |
2551 | dev_warn(adev->dev, "(%d) create RLC c bo failed\n", r); | |
2552 | gfx_v6_0_rlc_fini(adev); | |
2553 | return r; | |
2554 | } | |
2555 | } | |
2556 | r = amdgpu_bo_reserve(adev->gfx.rlc.clear_state_obj, false); | |
2557 | if (unlikely(r != 0)) { | |
2558 | gfx_v6_0_rlc_fini(adev); | |
2559 | return r; | |
2560 | } | |
2561 | r = amdgpu_bo_pin(adev->gfx.rlc.clear_state_obj, AMDGPU_GEM_DOMAIN_VRAM, | |
2562 | &adev->gfx.rlc.clear_state_gpu_addr); | |
2563 | if (r) { | |
2564 | amdgpu_bo_unreserve(adev->gfx.rlc.clear_state_obj); | |
2565 | dev_warn(adev->dev, "(%d) pin RLC c bo failed\n", r); | |
2566 | gfx_v6_0_rlc_fini(adev); | |
2567 | return r; | |
2568 | } | |
2569 | ||
2570 | r = amdgpu_bo_kmap(adev->gfx.rlc.clear_state_obj, (void **)&adev->gfx.rlc.cs_ptr); | |
2571 | if (r) { | |
2572 | dev_warn(adev->dev, "(%d) map RLC c bo failed\n", r); | |
2573 | gfx_v6_0_rlc_fini(adev); | |
2574 | return r; | |
2575 | } | |
2576 | /* set up the cs buffer */ | |
2577 | dst_ptr = adev->gfx.rlc.cs_ptr; | |
2578 | reg_list_mc_addr = adev->gfx.rlc.clear_state_gpu_addr + 256; | |
2579 | dst_ptr[0] = cpu_to_le32(upper_32_bits(reg_list_mc_addr)); | |
2580 | dst_ptr[1] = cpu_to_le32(lower_32_bits(reg_list_mc_addr)); | |
2581 | dst_ptr[2] = cpu_to_le32(adev->gfx.rlc.clear_state_size); | |
2582 | gfx_v6_0_get_csb_buffer(adev, &dst_ptr[(256/4)]); | |
2583 | amdgpu_bo_kunmap(adev->gfx.rlc.clear_state_obj); | |
2584 | amdgpu_bo_unreserve(adev->gfx.rlc.clear_state_obj); | |
2585 | } | |
2586 | ||
2587 | return 0; | |
2588 | } | |
2589 | ||
2590 | static void gfx_v6_0_enable_lbpw(struct amdgpu_device *adev, bool enable) | |
2591 | { | |
25069e06 | 2592 | WREG32_FIELD(RLC_LB_CNTL, LOAD_BALANCE_ENABLE, enable ? 1 : 0); |
2cd46ad2 KW |
2593 | |
2594 | if (!enable) { | |
2595 | gfx_v6_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); | |
25069e06 | 2596 | WREG32(mmSPI_LB_CU_MASK, 0x00ff); |
2cd46ad2 | 2597 | } |
2cd46ad2 KW |
2598 | } |
2599 | ||
2600 | static void gfx_v6_0_wait_for_rlc_serdes(struct amdgpu_device *adev) | |
2601 | { | |
2602 | int i; | |
2603 | ||
2604 | for (i = 0; i < adev->usec_timeout; i++) { | |
25069e06 | 2605 | if (RREG32(mmRLC_SERDES_MASTER_BUSY_0) == 0) |
2cd46ad2 KW |
2606 | break; |
2607 | udelay(1); | |
2608 | } | |
2609 | ||
2610 | for (i = 0; i < adev->usec_timeout; i++) { | |
25069e06 | 2611 | if (RREG32(mmRLC_SERDES_MASTER_BUSY_1) == 0) |
2cd46ad2 KW |
2612 | break; |
2613 | udelay(1); | |
2614 | } | |
2615 | } | |
2616 | ||
2617 | static void gfx_v6_0_update_rlc(struct amdgpu_device *adev, u32 rlc) | |
2618 | { | |
2619 | u32 tmp; | |
2620 | ||
25069e06 | 2621 | tmp = RREG32(mmRLC_CNTL); |
2cd46ad2 | 2622 | if (tmp != rlc) |
25069e06 | 2623 | WREG32(mmRLC_CNTL, rlc); |
2cd46ad2 KW |
2624 | } |
2625 | ||
2626 | static u32 gfx_v6_0_halt_rlc(struct amdgpu_device *adev) | |
2627 | { | |
2628 | u32 data, orig; | |
2629 | ||
25069e06 | 2630 | orig = data = RREG32(mmRLC_CNTL); |
2cd46ad2 | 2631 | |
25069e06 TSD |
2632 | if (data & RLC_CNTL__RLC_ENABLE_F32_MASK) { |
2633 | data &= ~RLC_CNTL__RLC_ENABLE_F32_MASK; | |
2634 | WREG32(mmRLC_CNTL, data); | |
2cd46ad2 KW |
2635 | |
2636 | gfx_v6_0_wait_for_rlc_serdes(adev); | |
2637 | } | |
2638 | ||
2639 | return orig; | |
2640 | } | |
2641 | ||
2642 | static void gfx_v6_0_rlc_stop(struct amdgpu_device *adev) | |
2643 | { | |
25069e06 | 2644 | WREG32(mmRLC_CNTL, 0); |
2cd46ad2 KW |
2645 | |
2646 | gfx_v6_0_enable_gui_idle_interrupt(adev, false); | |
2cd46ad2 KW |
2647 | gfx_v6_0_wait_for_rlc_serdes(adev); |
2648 | } | |
2649 | ||
2650 | static void gfx_v6_0_rlc_start(struct amdgpu_device *adev) | |
2651 | { | |
25069e06 | 2652 | WREG32(mmRLC_CNTL, RLC_CNTL__RLC_ENABLE_F32_MASK); |
2cd46ad2 KW |
2653 | |
2654 | gfx_v6_0_enable_gui_idle_interrupt(adev, true); | |
2655 | ||
2656 | udelay(50); | |
2657 | } | |
2658 | ||
2659 | static void gfx_v6_0_rlc_reset(struct amdgpu_device *adev) | |
2660 | { | |
25069e06 | 2661 | WREG32_FIELD(GRBM_SOFT_RESET, SOFT_RESET_RLC, 1); |
2cd46ad2 | 2662 | udelay(50); |
25069e06 | 2663 | WREG32_FIELD(GRBM_SOFT_RESET, SOFT_RESET_RLC, 0); |
2cd46ad2 KW |
2664 | udelay(50); |
2665 | } | |
2666 | ||
2667 | static bool gfx_v6_0_lbpw_supported(struct amdgpu_device *adev) | |
2668 | { | |
2669 | u32 tmp; | |
2670 | ||
2671 | /* Enable LBPW only for DDR3 */ | |
25069e06 | 2672 | tmp = RREG32(mmMC_SEQ_MISC0); |
2cd46ad2 KW |
2673 | if ((tmp & 0xF0000000) == 0xB0000000) |
2674 | return true; | |
2675 | return false; | |
2676 | } | |
25069e06 | 2677 | |
2cd46ad2 KW |
2678 | static void gfx_v6_0_init_cg(struct amdgpu_device *adev) |
2679 | { | |
2680 | } | |
2681 | ||
2682 | static int gfx_v6_0_rlc_resume(struct amdgpu_device *adev) | |
2683 | { | |
2684 | u32 i; | |
2685 | const struct rlc_firmware_header_v1_0 *hdr; | |
2686 | const __le32 *fw_data; | |
2687 | u32 fw_size; | |
2688 | ||
2689 | ||
2690 | if (!adev->gfx.rlc_fw) | |
2691 | return -EINVAL; | |
2692 | ||
2693 | gfx_v6_0_rlc_stop(adev); | |
2cd46ad2 | 2694 | gfx_v6_0_rlc_reset(adev); |
2cd46ad2 | 2695 | gfx_v6_0_init_pg(adev); |
2cd46ad2 KW |
2696 | gfx_v6_0_init_cg(adev); |
2697 | ||
25069e06 TSD |
2698 | WREG32(mmRLC_RL_BASE, 0); |
2699 | WREG32(mmRLC_RL_SIZE, 0); | |
2700 | WREG32(mmRLC_LB_CNTL, 0); | |
2701 | WREG32(mmRLC_LB_CNTR_MAX, 0xffffffff); | |
2702 | WREG32(mmRLC_LB_CNTR_INIT, 0); | |
2703 | WREG32(mmRLC_LB_INIT_CU_MASK, 0xffffffff); | |
2cd46ad2 | 2704 | |
25069e06 TSD |
2705 | WREG32(mmRLC_MC_CNTL, 0); |
2706 | WREG32(mmRLC_UCODE_CNTL, 0); | |
2cd46ad2 KW |
2707 | |
2708 | hdr = (const struct rlc_firmware_header_v1_0 *)adev->gfx.rlc_fw->data; | |
2709 | fw_size = le32_to_cpu(hdr->header.ucode_size_bytes) / 4; | |
2710 | fw_data = (const __le32 *) | |
2711 | (adev->gfx.rlc_fw->data + le32_to_cpu(hdr->header.ucode_array_offset_bytes)); | |
2712 | ||
2713 | amdgpu_ucode_print_rlc_hdr(&hdr->header); | |
2714 | ||
2715 | for (i = 0; i < fw_size; i++) { | |
25069e06 TSD |
2716 | WREG32(mmRLC_UCODE_ADDR, i); |
2717 | WREG32(mmRLC_UCODE_DATA, le32_to_cpup(fw_data++)); | |
2cd46ad2 | 2718 | } |
25069e06 | 2719 | WREG32(mmRLC_UCODE_ADDR, 0); |
2cd46ad2 KW |
2720 | |
2721 | gfx_v6_0_enable_lbpw(adev, gfx_v6_0_lbpw_supported(adev)); | |
2cd46ad2 KW |
2722 | gfx_v6_0_rlc_start(adev); |
2723 | ||
2724 | return 0; | |
2725 | } | |
2726 | ||
2727 | static void gfx_v6_0_enable_cgcg(struct amdgpu_device *adev, bool enable) | |
2728 | { | |
2729 | u32 data, orig, tmp; | |
2730 | ||
25069e06 | 2731 | orig = data = RREG32(mmRLC_CGCG_CGLS_CTRL); |
2cd46ad2 KW |
2732 | |
2733 | if (enable && (adev->cg_flags & AMD_CG_SUPPORT_GFX_CGCG)) { | |
2734 | gfx_v6_0_enable_gui_idle_interrupt(adev, true); | |
2735 | ||
25069e06 | 2736 | WREG32(mmRLC_GCPM_GENERAL_3, 0x00000080); |
2cd46ad2 KW |
2737 | |
2738 | tmp = gfx_v6_0_halt_rlc(adev); | |
2739 | ||
25069e06 TSD |
2740 | WREG32(mmRLC_SERDES_WR_MASTER_MASK_0, 0xffffffff); |
2741 | WREG32(mmRLC_SERDES_WR_MASTER_MASK_1, 0xffffffff); | |
2742 | WREG32(mmRLC_SERDES_WR_CTRL, 0x00b000ff); | |
2cd46ad2 KW |
2743 | |
2744 | gfx_v6_0_wait_for_rlc_serdes(adev); | |
2cd46ad2 KW |
2745 | gfx_v6_0_update_rlc(adev, tmp); |
2746 | ||
25069e06 | 2747 | WREG32(mmRLC_SERDES_WR_CTRL, 0x007000ff); |
2cd46ad2 | 2748 | |
25069e06 | 2749 | data |= RLC_CGCG_CGLS_CTRL__CGCG_EN_MASK | RLC_CGCG_CGLS_CTRL__CGLS_EN_MASK; |
2cd46ad2 KW |
2750 | } else { |
2751 | gfx_v6_0_enable_gui_idle_interrupt(adev, false); | |
2752 | ||
25069e06 TSD |
2753 | RREG32(mmCB_CGTT_SCLK_CTRL); |
2754 | RREG32(mmCB_CGTT_SCLK_CTRL); | |
2755 | RREG32(mmCB_CGTT_SCLK_CTRL); | |
2756 | RREG32(mmCB_CGTT_SCLK_CTRL); | |
2cd46ad2 | 2757 | |
25069e06 | 2758 | data &= ~(RLC_CGCG_CGLS_CTRL__CGCG_EN_MASK | RLC_CGCG_CGLS_CTRL__CGLS_EN_MASK); |
2cd46ad2 KW |
2759 | } |
2760 | ||
2761 | if (orig != data) | |
25069e06 | 2762 | WREG32(mmRLC_CGCG_CGLS_CTRL, data); |
2cd46ad2 KW |
2763 | |
2764 | } | |
2765 | ||
2766 | static void gfx_v6_0_enable_mgcg(struct amdgpu_device *adev, bool enable) | |
2767 | { | |
2768 | ||
2769 | u32 data, orig, tmp = 0; | |
2770 | ||
2771 | if (enable && (adev->cg_flags & AMD_CG_SUPPORT_GFX_MGCG)) { | |
25069e06 | 2772 | orig = data = RREG32(mmCGTS_SM_CTRL_REG); |
2cd46ad2 KW |
2773 | data = 0x96940200; |
2774 | if (orig != data) | |
25069e06 | 2775 | WREG32(mmCGTS_SM_CTRL_REG, data); |
2cd46ad2 KW |
2776 | |
2777 | if (adev->cg_flags & AMD_CG_SUPPORT_GFX_CP_LS) { | |
25069e06 TSD |
2778 | orig = data = RREG32(mmCP_MEM_SLP_CNTL); |
2779 | data |= CP_MEM_SLP_CNTL__CP_MEM_LS_EN_MASK; | |
2cd46ad2 | 2780 | if (orig != data) |
25069e06 | 2781 | WREG32(mmCP_MEM_SLP_CNTL, data); |
2cd46ad2 KW |
2782 | } |
2783 | ||
25069e06 | 2784 | orig = data = RREG32(mmRLC_CGTT_MGCG_OVERRIDE); |
2cd46ad2 KW |
2785 | data &= 0xffffffc0; |
2786 | if (orig != data) | |
25069e06 | 2787 | WREG32(mmRLC_CGTT_MGCG_OVERRIDE, data); |
2cd46ad2 KW |
2788 | |
2789 | tmp = gfx_v6_0_halt_rlc(adev); | |
2790 | ||
25069e06 TSD |
2791 | WREG32(mmRLC_SERDES_WR_MASTER_MASK_0, 0xffffffff); |
2792 | WREG32(mmRLC_SERDES_WR_MASTER_MASK_1, 0xffffffff); | |
2793 | WREG32(mmRLC_SERDES_WR_CTRL, 0x00d000ff); | |
2cd46ad2 KW |
2794 | |
2795 | gfx_v6_0_update_rlc(adev, tmp); | |
2796 | } else { | |
25069e06 | 2797 | orig = data = RREG32(mmRLC_CGTT_MGCG_OVERRIDE); |
2cd46ad2 KW |
2798 | data |= 0x00000003; |
2799 | if (orig != data) | |
25069e06 | 2800 | WREG32(mmRLC_CGTT_MGCG_OVERRIDE, data); |
2cd46ad2 | 2801 | |
25069e06 TSD |
2802 | data = RREG32(mmCP_MEM_SLP_CNTL); |
2803 | if (data & CP_MEM_SLP_CNTL__CP_MEM_LS_EN_MASK) { | |
2804 | data &= ~CP_MEM_SLP_CNTL__CP_MEM_LS_EN_MASK; | |
2805 | WREG32(mmCP_MEM_SLP_CNTL, data); | |
2cd46ad2 | 2806 | } |
25069e06 TSD |
2807 | orig = data = RREG32(mmCGTS_SM_CTRL_REG); |
2808 | data |= CGTS_SM_CTRL_REG__LS_OVERRIDE_MASK | CGTS_SM_CTRL_REG__OVERRIDE_MASK; | |
2cd46ad2 | 2809 | if (orig != data) |
25069e06 | 2810 | WREG32(mmCGTS_SM_CTRL_REG, data); |
2cd46ad2 KW |
2811 | |
2812 | tmp = gfx_v6_0_halt_rlc(adev); | |
2813 | ||
25069e06 TSD |
2814 | WREG32(mmRLC_SERDES_WR_MASTER_MASK_0, 0xffffffff); |
2815 | WREG32(mmRLC_SERDES_WR_MASTER_MASK_1, 0xffffffff); | |
2816 | WREG32(mmRLC_SERDES_WR_CTRL, 0x00e000ff); | |
2cd46ad2 KW |
2817 | |
2818 | gfx_v6_0_update_rlc(adev, tmp); | |
2819 | } | |
2820 | } | |
2821 | /* | |
2822 | static void gfx_v6_0_update_cg(struct amdgpu_device *adev, | |
2823 | bool enable) | |
2824 | { | |
2825 | gfx_v6_0_enable_gui_idle_interrupt(adev, false); | |
2826 | if (enable) { | |
2827 | gfx_v6_0_enable_mgcg(adev, true); | |
2828 | gfx_v6_0_enable_cgcg(adev, true); | |
2829 | } else { | |
2830 | gfx_v6_0_enable_cgcg(adev, false); | |
2831 | gfx_v6_0_enable_mgcg(adev, false); | |
2832 | } | |
2833 | gfx_v6_0_enable_gui_idle_interrupt(adev, true); | |
2834 | } | |
2835 | */ | |
25069e06 | 2836 | |
2cd46ad2 KW |
2837 | static void gfx_v6_0_enable_sclk_slowdown_on_pu(struct amdgpu_device *adev, |
2838 | bool enable) | |
2839 | { | |
2840 | } | |
2841 | ||
2842 | static void gfx_v6_0_enable_sclk_slowdown_on_pd(struct amdgpu_device *adev, | |
2843 | bool enable) | |
2844 | { | |
2845 | } | |
2846 | ||
2847 | static void gfx_v6_0_enable_cp_pg(struct amdgpu_device *adev, bool enable) | |
2848 | { | |
2849 | u32 data, orig; | |
2850 | ||
25069e06 | 2851 | orig = data = RREG32(mmRLC_PG_CNTL); |
2cd46ad2 KW |
2852 | if (enable && (adev->pg_flags & AMD_PG_SUPPORT_CP)) |
2853 | data &= ~0x8000; | |
2854 | else | |
2855 | data |= 0x8000; | |
2856 | if (orig != data) | |
25069e06 | 2857 | WREG32(mmRLC_PG_CNTL, data); |
2cd46ad2 KW |
2858 | } |
2859 | ||
2860 | static void gfx_v6_0_enable_gds_pg(struct amdgpu_device *adev, bool enable) | |
2861 | { | |
2862 | } | |
2863 | /* | |
2864 | static void gfx_v6_0_init_cp_pg_table(struct amdgpu_device *adev) | |
2865 | { | |
2866 | const __le32 *fw_data; | |
2867 | volatile u32 *dst_ptr; | |
2868 | int me, i, max_me = 4; | |
2869 | u32 bo_offset = 0; | |
2870 | u32 table_offset, table_size; | |
2871 | ||
2872 | if (adev->asic_type == CHIP_KAVERI) | |
2873 | max_me = 5; | |
2874 | ||
2875 | if (adev->gfx.rlc.cp_table_ptr == NULL) | |
2876 | return; | |
2877 | ||
2878 | dst_ptr = adev->gfx.rlc.cp_table_ptr; | |
2879 | for (me = 0; me < max_me; me++) { | |
2880 | if (me == 0) { | |
2881 | const struct gfx_firmware_header_v1_0 *hdr = | |
2882 | (const struct gfx_firmware_header_v1_0 *)adev->gfx.ce_fw->data; | |
2883 | fw_data = (const __le32 *) | |
2884 | (adev->gfx.ce_fw->data + | |
2885 | le32_to_cpu(hdr->header.ucode_array_offset_bytes)); | |
2886 | table_offset = le32_to_cpu(hdr->jt_offset); | |
2887 | table_size = le32_to_cpu(hdr->jt_size); | |
2888 | } else if (me == 1) { | |
2889 | const struct gfx_firmware_header_v1_0 *hdr = | |
2890 | (const struct gfx_firmware_header_v1_0 *)adev->gfx.pfp_fw->data; | |
2891 | fw_data = (const __le32 *) | |
2892 | (adev->gfx.pfp_fw->data + | |
2893 | le32_to_cpu(hdr->header.ucode_array_offset_bytes)); | |
2894 | table_offset = le32_to_cpu(hdr->jt_offset); | |
2895 | table_size = le32_to_cpu(hdr->jt_size); | |
2896 | } else if (me == 2) { | |
2897 | const struct gfx_firmware_header_v1_0 *hdr = | |
2898 | (const struct gfx_firmware_header_v1_0 *)adev->gfx.me_fw->data; | |
2899 | fw_data = (const __le32 *) | |
2900 | (adev->gfx.me_fw->data + | |
2901 | le32_to_cpu(hdr->header.ucode_array_offset_bytes)); | |
2902 | table_offset = le32_to_cpu(hdr->jt_offset); | |
2903 | table_size = le32_to_cpu(hdr->jt_size); | |
2904 | } else if (me == 3) { | |
2905 | const struct gfx_firmware_header_v1_0 *hdr = | |
2906 | (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec_fw->data; | |
2907 | fw_data = (const __le32 *) | |
2908 | (adev->gfx.mec_fw->data + | |
2909 | le32_to_cpu(hdr->header.ucode_array_offset_bytes)); | |
2910 | table_offset = le32_to_cpu(hdr->jt_offset); | |
2911 | table_size = le32_to_cpu(hdr->jt_size); | |
2912 | } else { | |
2913 | const struct gfx_firmware_header_v1_0 *hdr = | |
2914 | (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec2_fw->data; | |
2915 | fw_data = (const __le32 *) | |
2916 | (adev->gfx.mec2_fw->data + | |
2917 | le32_to_cpu(hdr->header.ucode_array_offset_bytes)); | |
2918 | table_offset = le32_to_cpu(hdr->jt_offset); | |
2919 | table_size = le32_to_cpu(hdr->jt_size); | |
2920 | } | |
2921 | ||
2922 | for (i = 0; i < table_size; i ++) { | |
2923 | dst_ptr[bo_offset + i] = | |
2924 | cpu_to_le32(le32_to_cpu(fw_data[table_offset + i])); | |
2925 | } | |
2926 | ||
2927 | bo_offset += table_size; | |
2928 | } | |
2929 | } | |
2930 | */ | |
2931 | static void gfx_v6_0_enable_gfx_cgpg(struct amdgpu_device *adev, | |
2932 | bool enable) | |
2933 | { | |
2cd46ad2 | 2934 | if (enable && (adev->pg_flags & AMD_PG_SUPPORT_GFX_PG)) { |
25069e06 TSD |
2935 | WREG32(mmRLC_TTOP_D, RLC_PUD(0x10) | RLC_PDD(0x10) | RLC_TTPD(0x10) | RLC_MSD(0x10)); |
2936 | WREG32_FIELD(RLC_PG_CNTL, GFX_POWER_GATING_ENABLE, 1); | |
2937 | WREG32_FIELD(RLC_AUTO_PG_CTRL, AUTO_PG_EN, 1); | |
2cd46ad2 | 2938 | } else { |
25069e06 TSD |
2939 | WREG32_FIELD(RLC_AUTO_PG_CTRL, AUTO_PG_EN, 0); |
2940 | (void)RREG32(mmDB_RENDER_CONTROL); | |
2cd46ad2 KW |
2941 | } |
2942 | } | |
2943 | ||
2944 | static u32 gfx_v6_0_get_cu_active_bitmap(struct amdgpu_device *adev, | |
2945 | u32 se, u32 sh) | |
2946 | { | |
2947 | ||
2948 | u32 mask = 0, tmp, tmp1; | |
2949 | int i; | |
2950 | ||
deca1d1f | 2951 | mutex_lock(&adev->grbm_idx_mutex); |
2cd46ad2 | 2952 | gfx_v6_0_select_se_sh(adev, se, sh, 0xffffffff); |
25069e06 TSD |
2953 | tmp = RREG32(mmCC_GC_SHADER_ARRAY_CONFIG); |
2954 | tmp1 = RREG32(mmGC_USER_SHADER_ARRAY_CONFIG); | |
2cd46ad2 | 2955 | gfx_v6_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); |
deca1d1f | 2956 | mutex_unlock(&adev->grbm_idx_mutex); |
2cd46ad2 KW |
2957 | |
2958 | tmp &= 0xffff0000; | |
2959 | ||
2960 | tmp |= tmp1; | |
2961 | tmp >>= 16; | |
2962 | ||
2963 | for (i = 0; i < adev->gfx.config.max_cu_per_sh; i ++) { | |
2964 | mask <<= 1; | |
2965 | mask |= 1; | |
2966 | } | |
2967 | ||
2968 | return (~tmp) & mask; | |
2969 | } | |
2970 | ||
2971 | static void gfx_v6_0_init_ao_cu_mask(struct amdgpu_device *adev) | |
2972 | { | |
2973 | u32 i, j, k, active_cu_number = 0; | |
2974 | ||
2975 | u32 mask, counter, cu_bitmap; | |
2976 | u32 tmp = 0; | |
2977 | ||
2978 | for (i = 0; i < adev->gfx.config.max_shader_engines; i++) { | |
2979 | for (j = 0; j < adev->gfx.config.max_sh_per_se; j++) { | |
2980 | mask = 1; | |
2981 | cu_bitmap = 0; | |
2982 | counter = 0; | |
2983 | for (k = 0; k < adev->gfx.config.max_cu_per_sh; k++) { | |
2984 | if (gfx_v6_0_get_cu_active_bitmap(adev, i, j) & mask) { | |
2985 | if (counter < 2) | |
2986 | cu_bitmap |= mask; | |
2987 | counter++; | |
2988 | } | |
2989 | mask <<= 1; | |
2990 | } | |
2991 | ||
2992 | active_cu_number += counter; | |
2993 | tmp |= (cu_bitmap << (i * 16 + j * 8)); | |
2994 | } | |
2995 | } | |
2996 | ||
25069e06 TSD |
2997 | WREG32(mmRLC_PG_AO_CU_MASK, tmp); |
2998 | WREG32_FIELD(RLC_MAX_PG_CU, MAX_POWERED_UP_CU, active_cu_number); | |
2cd46ad2 KW |
2999 | } |
3000 | ||
3001 | static void gfx_v6_0_enable_gfx_static_mgpg(struct amdgpu_device *adev, | |
3002 | bool enable) | |
3003 | { | |
3004 | u32 data, orig; | |
3005 | ||
25069e06 | 3006 | orig = data = RREG32(mmRLC_PG_CNTL); |
2cd46ad2 | 3007 | if (enable && (adev->pg_flags & AMD_PG_SUPPORT_GFX_SMG)) |
25069e06 | 3008 | data |= RLC_PG_CNTL__STATIC_PER_CU_PG_ENABLE_MASK; |
2cd46ad2 | 3009 | else |
25069e06 | 3010 | data &= ~RLC_PG_CNTL__STATIC_PER_CU_PG_ENABLE_MASK; |
2cd46ad2 | 3011 | if (orig != data) |
25069e06 | 3012 | WREG32(mmRLC_PG_CNTL, data); |
2cd46ad2 KW |
3013 | } |
3014 | ||
3015 | static void gfx_v6_0_enable_gfx_dynamic_mgpg(struct amdgpu_device *adev, | |
3016 | bool enable) | |
3017 | { | |
3018 | u32 data, orig; | |
3019 | ||
25069e06 | 3020 | orig = data = RREG32(mmRLC_PG_CNTL); |
2cd46ad2 | 3021 | if (enable && (adev->pg_flags & AMD_PG_SUPPORT_GFX_DMG)) |
25069e06 | 3022 | data |= RLC_PG_CNTL__DYN_PER_CU_PG_ENABLE_MASK; |
2cd46ad2 | 3023 | else |
25069e06 | 3024 | data &= ~RLC_PG_CNTL__DYN_PER_CU_PG_ENABLE_MASK; |
2cd46ad2 | 3025 | if (orig != data) |
25069e06 | 3026 | WREG32(mmRLC_PG_CNTL, data); |
2cd46ad2 KW |
3027 | } |
3028 | ||
3029 | static void gfx_v6_0_init_gfx_cgpg(struct amdgpu_device *adev) | |
3030 | { | |
3031 | u32 tmp; | |
3032 | ||
25069e06 TSD |
3033 | WREG32(mmRLC_SAVE_AND_RESTORE_BASE, adev->gfx.rlc.save_restore_gpu_addr >> 8); |
3034 | WREG32_FIELD(RLC_PG_CNTL, GFX_POWER_GATING_SRC, 1); | |
3035 | WREG32(mmRLC_CLEAR_STATE_RESTORE_BASE, adev->gfx.rlc.clear_state_gpu_addr >> 8); | |
2cd46ad2 | 3036 | |
25069e06 TSD |
3037 | tmp = RREG32(mmRLC_AUTO_PG_CTRL); |
3038 | tmp &= ~RLC_AUTO_PG_CTRL__GRBM_REG_SAVE_GFX_IDLE_THRESHOLD_MASK; | |
3039 | tmp |= (0x700 << RLC_AUTO_PG_CTRL__GRBM_REG_SAVE_GFX_IDLE_THRESHOLD__SHIFT); | |
3040 | tmp &= ~RLC_AUTO_PG_CTRL__PG_AFTER_GRBM_REG_SAVE_THRESHOLD_MASK; | |
3041 | WREG32(mmRLC_AUTO_PG_CTRL, tmp); | |
2cd46ad2 KW |
3042 | } |
3043 | ||
3044 | static void gfx_v6_0_update_gfx_pg(struct amdgpu_device *adev, bool enable) | |
3045 | { | |
3046 | gfx_v6_0_enable_gfx_cgpg(adev, enable); | |
3047 | gfx_v6_0_enable_gfx_static_mgpg(adev, enable); | |
3048 | gfx_v6_0_enable_gfx_dynamic_mgpg(adev, enable); | |
3049 | } | |
3050 | ||
3051 | static u32 gfx_v6_0_get_csb_size(struct amdgpu_device *adev) | |
3052 | { | |
3053 | u32 count = 0; | |
3054 | const struct cs_section_def *sect = NULL; | |
3055 | const struct cs_extent_def *ext = NULL; | |
3056 | ||
3057 | if (adev->gfx.rlc.cs_data == NULL) | |
3058 | return 0; | |
3059 | ||
3060 | /* begin clear state */ | |
3061 | count += 2; | |
3062 | /* context control state */ | |
3063 | count += 3; | |
3064 | ||
3065 | for (sect = adev->gfx.rlc.cs_data; sect->section != NULL; ++sect) { | |
3066 | for (ext = sect->section; ext->extent != NULL; ++ext) { | |
3067 | if (sect->id == SECT_CONTEXT) | |
3068 | count += 2 + ext->reg_count; | |
3069 | else | |
3070 | return 0; | |
3071 | } | |
3072 | } | |
3073 | /* pa_sc_raster_config */ | |
3074 | count += 3; | |
3075 | /* end clear state */ | |
3076 | count += 2; | |
3077 | /* clear state */ | |
3078 | count += 2; | |
3079 | ||
3080 | return count; | |
3081 | } | |
3082 | ||
3083 | static void gfx_v6_0_get_csb_buffer(struct amdgpu_device *adev, | |
3084 | volatile u32 *buffer) | |
3085 | { | |
3086 | u32 count = 0, i; | |
3087 | const struct cs_section_def *sect = NULL; | |
3088 | const struct cs_extent_def *ext = NULL; | |
3089 | ||
3090 | if (adev->gfx.rlc.cs_data == NULL) | |
3091 | return; | |
3092 | if (buffer == NULL) | |
3093 | return; | |
3094 | ||
3095 | buffer[count++] = cpu_to_le32(PACKET3(PACKET3_PREAMBLE_CNTL, 0)); | |
3096 | buffer[count++] = cpu_to_le32(PACKET3_PREAMBLE_BEGIN_CLEAR_STATE); | |
2cd46ad2 KW |
3097 | buffer[count++] = cpu_to_le32(PACKET3(PACKET3_CONTEXT_CONTROL, 1)); |
3098 | buffer[count++] = cpu_to_le32(0x80000000); | |
3099 | buffer[count++] = cpu_to_le32(0x80000000); | |
3100 | ||
3101 | for (sect = adev->gfx.rlc.cs_data; sect->section != NULL; ++sect) { | |
3102 | for (ext = sect->section; ext->extent != NULL; ++ext) { | |
3103 | if (sect->id == SECT_CONTEXT) { | |
3104 | buffer[count++] = | |
3105 | cpu_to_le32(PACKET3(PACKET3_SET_CONTEXT_REG, ext->reg_count)); | |
3106 | buffer[count++] = cpu_to_le32(ext->reg_index - 0xa000); | |
3107 | for (i = 0; i < ext->reg_count; i++) | |
3108 | buffer[count++] = cpu_to_le32(ext->extent[i]); | |
3109 | } else { | |
3110 | return; | |
3111 | } | |
3112 | } | |
3113 | } | |
3114 | ||
3115 | buffer[count++] = cpu_to_le32(PACKET3(PACKET3_SET_CONTEXT_REG, 1)); | |
25069e06 | 3116 | buffer[count++] = cpu_to_le32(mmPA_SC_RASTER_CONFIG - PACKET3_SET_CONTEXT_REG_START); |
2cd46ad2 KW |
3117 | |
3118 | switch (adev->asic_type) { | |
3119 | case CHIP_TAHITI: | |
3120 | case CHIP_PITCAIRN: | |
3121 | buffer[count++] = cpu_to_le32(0x2a00126a); | |
3122 | break; | |
3123 | case CHIP_VERDE: | |
3124 | buffer[count++] = cpu_to_le32(0x0000124a); | |
3125 | break; | |
3126 | case CHIP_OLAND: | |
3127 | buffer[count++] = cpu_to_le32(0x00000082); | |
3128 | break; | |
3129 | case CHIP_HAINAN: | |
3130 | buffer[count++] = cpu_to_le32(0x00000000); | |
3131 | break; | |
3132 | default: | |
3133 | buffer[count++] = cpu_to_le32(0x00000000); | |
3134 | break; | |
3135 | } | |
3136 | ||
3137 | buffer[count++] = cpu_to_le32(PACKET3(PACKET3_PREAMBLE_CNTL, 0)); | |
3138 | buffer[count++] = cpu_to_le32(PACKET3_PREAMBLE_END_CLEAR_STATE); | |
3139 | ||
3140 | buffer[count++] = cpu_to_le32(PACKET3(PACKET3_CLEAR_STATE, 0)); | |
3141 | buffer[count++] = cpu_to_le32(0); | |
3142 | } | |
3143 | ||
3144 | static void gfx_v6_0_init_pg(struct amdgpu_device *adev) | |
3145 | { | |
3146 | if (adev->pg_flags & (AMD_PG_SUPPORT_GFX_PG | | |
3147 | AMD_PG_SUPPORT_GFX_SMG | | |
3148 | AMD_PG_SUPPORT_GFX_DMG | | |
3149 | AMD_PG_SUPPORT_CP | | |
3150 | AMD_PG_SUPPORT_GDS | | |
3151 | AMD_PG_SUPPORT_RLC_SMU_HS)) { | |
3152 | gfx_v6_0_enable_sclk_slowdown_on_pu(adev, true); | |
3153 | gfx_v6_0_enable_sclk_slowdown_on_pd(adev, true); | |
3154 | if (adev->pg_flags & AMD_PG_SUPPORT_GFX_PG) { | |
3155 | gfx_v6_0_init_gfx_cgpg(adev); | |
3156 | gfx_v6_0_enable_cp_pg(adev, true); | |
3157 | gfx_v6_0_enable_gds_pg(adev, true); | |
3158 | } else { | |
25069e06 TSD |
3159 | WREG32(mmRLC_SAVE_AND_RESTORE_BASE, adev->gfx.rlc.save_restore_gpu_addr >> 8); |
3160 | WREG32(mmRLC_CLEAR_STATE_RESTORE_BASE, adev->gfx.rlc.clear_state_gpu_addr >> 8); | |
2cd46ad2 KW |
3161 | |
3162 | } | |
3163 | gfx_v6_0_init_ao_cu_mask(adev); | |
3164 | gfx_v6_0_update_gfx_pg(adev, true); | |
3165 | } else { | |
3166 | ||
25069e06 TSD |
3167 | WREG32(mmRLC_SAVE_AND_RESTORE_BASE, adev->gfx.rlc.save_restore_gpu_addr >> 8); |
3168 | WREG32(mmRLC_CLEAR_STATE_RESTORE_BASE, adev->gfx.rlc.clear_state_gpu_addr >> 8); | |
2cd46ad2 KW |
3169 | } |
3170 | } | |
3171 | ||
3172 | static void gfx_v6_0_fini_pg(struct amdgpu_device *adev) | |
3173 | { | |
3174 | if (adev->pg_flags & (AMD_PG_SUPPORT_GFX_PG | | |
3175 | AMD_PG_SUPPORT_GFX_SMG | | |
3176 | AMD_PG_SUPPORT_GFX_DMG | | |
3177 | AMD_PG_SUPPORT_CP | | |
3178 | AMD_PG_SUPPORT_GDS | | |
3179 | AMD_PG_SUPPORT_RLC_SMU_HS)) { | |
3180 | gfx_v6_0_update_gfx_pg(adev, false); | |
3181 | if (adev->pg_flags & AMD_PG_SUPPORT_GFX_PG) { | |
3182 | gfx_v6_0_enable_cp_pg(adev, false); | |
3183 | gfx_v6_0_enable_gds_pg(adev, false); | |
3184 | } | |
3185 | } | |
3186 | } | |
3187 | ||
3188 | static uint64_t gfx_v6_0_get_gpu_clock_counter(struct amdgpu_device *adev) | |
3189 | { | |
3190 | uint64_t clock; | |
3191 | ||
3192 | mutex_lock(&adev->gfx.gpu_clock_mutex); | |
25069e06 TSD |
3193 | WREG32(mmRLC_CAPTURE_GPU_CLOCK_COUNT, 1); |
3194 | clock = (uint64_t)RREG32(mmRLC_GPU_CLOCK_COUNT_LSB) | | |
3195 | ((uint64_t)RREG32(mmRLC_GPU_CLOCK_COUNT_MSB) << 32ULL); | |
2cd46ad2 KW |
3196 | mutex_unlock(&adev->gfx.gpu_clock_mutex); |
3197 | return clock; | |
3198 | } | |
3199 | ||
0f444c24 AD |
3200 | static void gfx_v6_ring_emit_cntxcntl(struct amdgpu_ring *ring, uint32_t flags) |
3201 | { | |
45682886 ML |
3202 | if (flags & AMDGPU_HAVE_CTX_SWITCH) |
3203 | gfx_v6_0_ring_emit_vgt_flush(ring); | |
0f444c24 AD |
3204 | amdgpu_ring_write(ring, PACKET3(PACKET3_CONTEXT_CONTROL, 1)); |
3205 | amdgpu_ring_write(ring, 0x80000000); | |
3206 | amdgpu_ring_write(ring, 0); | |
3207 | } | |
3208 | ||
3ee73ed8 TSD |
3209 | |
3210 | static uint32_t wave_read_ind(struct amdgpu_device *adev, uint32_t simd, uint32_t wave, uint32_t address) | |
3211 | { | |
3212 | WREG32(mmSQ_IND_INDEX, | |
3213 | (wave << SQ_IND_INDEX__WAVE_ID__SHIFT) | | |
3214 | (simd << SQ_IND_INDEX__SIMD_ID__SHIFT) | | |
3215 | (address << SQ_IND_INDEX__INDEX__SHIFT) | | |
3216 | (SQ_IND_INDEX__FORCE_READ_MASK)); | |
3217 | return RREG32(mmSQ_IND_DATA); | |
3218 | } | |
3219 | ||
34e646f4 TSD |
3220 | static void wave_read_regs(struct amdgpu_device *adev, uint32_t simd, |
3221 | uint32_t wave, uint32_t thread, | |
3222 | uint32_t regno, uint32_t num, uint32_t *out) | |
3223 | { | |
3224 | WREG32(mmSQ_IND_INDEX, | |
3225 | (wave << SQ_IND_INDEX__WAVE_ID__SHIFT) | | |
3226 | (simd << SQ_IND_INDEX__SIMD_ID__SHIFT) | | |
3227 | (regno << SQ_IND_INDEX__INDEX__SHIFT) | | |
3228 | (thread << SQ_IND_INDEX__THREAD_ID__SHIFT) | | |
3229 | (SQ_IND_INDEX__FORCE_READ_MASK) | | |
3230 | (SQ_IND_INDEX__AUTO_INCR_MASK)); | |
3231 | while (num--) | |
3232 | *(out++) = RREG32(mmSQ_IND_DATA); | |
3233 | } | |
3234 | ||
3ee73ed8 TSD |
3235 | static void gfx_v6_0_read_wave_data(struct amdgpu_device *adev, uint32_t simd, uint32_t wave, uint32_t *dst, int *no_fields) |
3236 | { | |
3237 | /* type 0 wave data */ | |
3238 | dst[(*no_fields)++] = 0; | |
3239 | dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_STATUS); | |
3240 | dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_PC_LO); | |
3241 | dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_PC_HI); | |
3242 | dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_EXEC_LO); | |
3243 | dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_EXEC_HI); | |
3244 | dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_HW_ID); | |
3245 | dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_INST_DW0); | |
3246 | dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_INST_DW1); | |
3247 | dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_GPR_ALLOC); | |
3248 | dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_LDS_ALLOC); | |
3249 | dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_TRAPSTS); | |
3250 | dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_IB_STS); | |
3251 | dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_TBA_LO); | |
3252 | dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_TBA_HI); | |
3253 | dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_TMA_LO); | |
3254 | dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_TMA_HI); | |
3255 | dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_IB_DBG0); | |
3256 | dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_M0); | |
3257 | } | |
3258 | ||
34e646f4 TSD |
3259 | static void gfx_v6_0_read_wave_sgprs(struct amdgpu_device *adev, uint32_t simd, |
3260 | uint32_t wave, uint32_t start, | |
3261 | uint32_t size, uint32_t *dst) | |
3262 | { | |
3263 | wave_read_regs( | |
3264 | adev, simd, wave, 0, | |
3265 | start + SQIND_WAVE_SGPRS_OFFSET, size, dst); | |
3266 | } | |
3267 | ||
2cd46ad2 KW |
3268 | static const struct amdgpu_gfx_funcs gfx_v6_0_gfx_funcs = { |
3269 | .get_gpu_clock_counter = &gfx_v6_0_get_gpu_clock_counter, | |
3270 | .select_se_sh = &gfx_v6_0_select_se_sh, | |
3ee73ed8 | 3271 | .read_wave_data = &gfx_v6_0_read_wave_data, |
34e646f4 | 3272 | .read_wave_sgprs = &gfx_v6_0_read_wave_sgprs, |
2cd46ad2 KW |
3273 | }; |
3274 | ||
3275 | static int gfx_v6_0_early_init(void *handle) | |
3276 | { | |
3277 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
3278 | ||
3279 | adev->gfx.num_gfx_rings = GFX6_NUM_GFX_RINGS; | |
3280 | adev->gfx.num_compute_rings = GFX6_NUM_COMPUTE_RINGS; | |
3281 | adev->gfx.funcs = &gfx_v6_0_gfx_funcs; | |
3282 | gfx_v6_0_set_ring_funcs(adev); | |
3283 | gfx_v6_0_set_irq_funcs(adev); | |
3284 | ||
3285 | return 0; | |
3286 | } | |
3287 | ||
3288 | static int gfx_v6_0_sw_init(void *handle) | |
3289 | { | |
3290 | struct amdgpu_ring *ring; | |
3291 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
3292 | int i, r; | |
3293 | ||
3294 | r = amdgpu_irq_add_id(adev, 181, &adev->gfx.eop_irq); | |
3295 | if (r) | |
3296 | return r; | |
3297 | ||
3298 | r = amdgpu_irq_add_id(adev, 184, &adev->gfx.priv_reg_irq); | |
3299 | if (r) | |
3300 | return r; | |
3301 | ||
3302 | r = amdgpu_irq_add_id(adev, 185, &adev->gfx.priv_inst_irq); | |
3303 | if (r) | |
3304 | return r; | |
3305 | ||
3306 | gfx_v6_0_scratch_init(adev); | |
3307 | ||
3308 | r = gfx_v6_0_init_microcode(adev); | |
3309 | if (r) { | |
3310 | DRM_ERROR("Failed to load gfx firmware!\n"); | |
3311 | return r; | |
3312 | } | |
3313 | ||
3314 | r = gfx_v6_0_rlc_init(adev); | |
3315 | if (r) { | |
3316 | DRM_ERROR("Failed to init rlc BOs!\n"); | |
3317 | return r; | |
3318 | } | |
3319 | ||
3320 | for (i = 0; i < adev->gfx.num_gfx_rings; i++) { | |
3321 | ring = &adev->gfx.gfx_ring[i]; | |
3322 | ring->ring_obj = NULL; | |
3323 | sprintf(ring->name, "gfx"); | |
3324 | r = amdgpu_ring_init(adev, ring, 1024, | |
21cd942e | 3325 | &adev->gfx.eop_irq, AMDGPU_CP_IRQ_GFX_EOP); |
2cd46ad2 KW |
3326 | if (r) |
3327 | return r; | |
3328 | } | |
3329 | ||
3330 | for (i = 0; i < adev->gfx.num_compute_rings; i++) { | |
3331 | unsigned irq_type; | |
3332 | ||
3333 | if ((i >= 32) || (i >= AMDGPU_MAX_COMPUTE_RINGS)) { | |
3334 | DRM_ERROR("Too many (%d) compute rings!\n", i); | |
3335 | break; | |
3336 | } | |
3337 | ring = &adev->gfx.compute_ring[i]; | |
3338 | ring->ring_obj = NULL; | |
3339 | ring->use_doorbell = false; | |
3340 | ring->doorbell_index = 0; | |
3341 | ring->me = 1; | |
3342 | ring->pipe = i; | |
3343 | ring->queue = i; | |
3344 | sprintf(ring->name, "comp %d.%d.%d", ring->me, ring->pipe, ring->queue); | |
3345 | irq_type = AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP + ring->pipe; | |
2255e8c1 | 3346 | r = amdgpu_ring_init(adev, ring, 1024, |
21cd942e | 3347 | &adev->gfx.eop_irq, irq_type); |
2cd46ad2 KW |
3348 | if (r) |
3349 | return r; | |
3350 | } | |
3351 | ||
3352 | return r; | |
3353 | } | |
3354 | ||
3355 | static int gfx_v6_0_sw_fini(void *handle) | |
3356 | { | |
3357 | int i; | |
3358 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
3359 | ||
3360 | amdgpu_bo_unref(&adev->gds.oa_gfx_bo); | |
3361 | amdgpu_bo_unref(&adev->gds.gws_gfx_bo); | |
3362 | amdgpu_bo_unref(&adev->gds.gds_gfx_bo); | |
3363 | ||
3364 | for (i = 0; i < adev->gfx.num_gfx_rings; i++) | |
3365 | amdgpu_ring_fini(&adev->gfx.gfx_ring[i]); | |
3366 | for (i = 0; i < adev->gfx.num_compute_rings; i++) | |
3367 | amdgpu_ring_fini(&adev->gfx.compute_ring[i]); | |
3368 | ||
2cd46ad2 KW |
3369 | gfx_v6_0_rlc_fini(adev); |
3370 | ||
3371 | return 0; | |
3372 | } | |
3373 | ||
3374 | static int gfx_v6_0_hw_init(void *handle) | |
3375 | { | |
3376 | int r; | |
3377 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
3378 | ||
3379 | gfx_v6_0_gpu_init(adev); | |
3380 | ||
3381 | r = gfx_v6_0_rlc_resume(adev); | |
3382 | if (r) | |
3383 | return r; | |
3384 | ||
3385 | r = gfx_v6_0_cp_resume(adev); | |
3386 | if (r) | |
3387 | return r; | |
3388 | ||
3389 | adev->gfx.ce_ram_size = 0x8000; | |
3390 | ||
3391 | return r; | |
3392 | } | |
3393 | ||
3394 | static int gfx_v6_0_hw_fini(void *handle) | |
3395 | { | |
3396 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
3397 | ||
3398 | gfx_v6_0_cp_enable(adev, false); | |
3399 | gfx_v6_0_rlc_stop(adev); | |
3400 | gfx_v6_0_fini_pg(adev); | |
3401 | ||
3402 | return 0; | |
3403 | } | |
3404 | ||
3405 | static int gfx_v6_0_suspend(void *handle) | |
3406 | { | |
3407 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
3408 | ||
3409 | return gfx_v6_0_hw_fini(adev); | |
3410 | } | |
3411 | ||
3412 | static int gfx_v6_0_resume(void *handle) | |
3413 | { | |
3414 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
3415 | ||
3416 | return gfx_v6_0_hw_init(adev); | |
3417 | } | |
3418 | ||
3419 | static bool gfx_v6_0_is_idle(void *handle) | |
3420 | { | |
3421 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
3422 | ||
25069e06 | 3423 | if (RREG32(mmGRBM_STATUS) & GRBM_STATUS__GUI_ACTIVE_MASK) |
2cd46ad2 KW |
3424 | return false; |
3425 | else | |
3426 | return true; | |
3427 | } | |
3428 | ||
3429 | static int gfx_v6_0_wait_for_idle(void *handle) | |
3430 | { | |
3431 | unsigned i; | |
2cd46ad2 KW |
3432 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
3433 | ||
3434 | for (i = 0; i < adev->usec_timeout; i++) { | |
4aeacf0f | 3435 | if (gfx_v6_0_is_idle(handle)) |
2cd46ad2 KW |
3436 | return 0; |
3437 | udelay(1); | |
3438 | } | |
3439 | return -ETIMEDOUT; | |
3440 | } | |
3441 | ||
3442 | static int gfx_v6_0_soft_reset(void *handle) | |
3443 | { | |
3444 | return 0; | |
3445 | } | |
3446 | ||
3447 | static void gfx_v6_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev, | |
3448 | enum amdgpu_interrupt_state state) | |
3449 | { | |
3450 | u32 cp_int_cntl; | |
3451 | ||
3452 | switch (state) { | |
3453 | case AMDGPU_IRQ_STATE_DISABLE: | |
25069e06 TSD |
3454 | cp_int_cntl = RREG32(mmCP_INT_CNTL_RING0); |
3455 | cp_int_cntl &= ~CP_INT_CNTL_RING0__TIME_STAMP_INT_ENABLE_MASK; | |
3456 | WREG32(mmCP_INT_CNTL_RING0, cp_int_cntl); | |
2cd46ad2 KW |
3457 | break; |
3458 | case AMDGPU_IRQ_STATE_ENABLE: | |
25069e06 TSD |
3459 | cp_int_cntl = RREG32(mmCP_INT_CNTL_RING0); |
3460 | cp_int_cntl |= CP_INT_CNTL_RING0__TIME_STAMP_INT_ENABLE_MASK; | |
3461 | WREG32(mmCP_INT_CNTL_RING0, cp_int_cntl); | |
2cd46ad2 KW |
3462 | break; |
3463 | default: | |
3464 | break; | |
3465 | } | |
3466 | } | |
3467 | ||
3468 | static void gfx_v6_0_set_compute_eop_interrupt_state(struct amdgpu_device *adev, | |
3469 | int ring, | |
3470 | enum amdgpu_interrupt_state state) | |
3471 | { | |
3472 | u32 cp_int_cntl; | |
3473 | switch (state){ | |
3474 | case AMDGPU_IRQ_STATE_DISABLE: | |
3475 | if (ring == 0) { | |
25069e06 TSD |
3476 | cp_int_cntl = RREG32(mmCP_INT_CNTL_RING1); |
3477 | cp_int_cntl &= ~CP_INT_CNTL_RING1__TIME_STAMP_INT_ENABLE_MASK; | |
3478 | WREG32(mmCP_INT_CNTL_RING1, cp_int_cntl); | |
2cd46ad2 KW |
3479 | break; |
3480 | } else { | |
25069e06 TSD |
3481 | cp_int_cntl = RREG32(mmCP_INT_CNTL_RING2); |
3482 | cp_int_cntl &= ~CP_INT_CNTL_RING2__TIME_STAMP_INT_ENABLE_MASK; | |
3483 | WREG32(mmCP_INT_CNTL_RING2, cp_int_cntl); | |
2cd46ad2 KW |
3484 | break; |
3485 | ||
3486 | } | |
3487 | case AMDGPU_IRQ_STATE_ENABLE: | |
3488 | if (ring == 0) { | |
25069e06 TSD |
3489 | cp_int_cntl = RREG32(mmCP_INT_CNTL_RING1); |
3490 | cp_int_cntl |= CP_INT_CNTL_RING1__TIME_STAMP_INT_ENABLE_MASK; | |
3491 | WREG32(mmCP_INT_CNTL_RING1, cp_int_cntl); | |
2cd46ad2 KW |
3492 | break; |
3493 | } else { | |
25069e06 TSD |
3494 | cp_int_cntl = RREG32(mmCP_INT_CNTL_RING2); |
3495 | cp_int_cntl |= CP_INT_CNTL_RING2__TIME_STAMP_INT_ENABLE_MASK; | |
3496 | WREG32(mmCP_INT_CNTL_RING2, cp_int_cntl); | |
2cd46ad2 KW |
3497 | break; |
3498 | ||
3499 | } | |
3500 | ||
3501 | default: | |
3502 | BUG(); | |
3503 | break; | |
3504 | ||
3505 | } | |
3506 | } | |
3507 | ||
3508 | static int gfx_v6_0_set_priv_reg_fault_state(struct amdgpu_device *adev, | |
3509 | struct amdgpu_irq_src *src, | |
3510 | unsigned type, | |
3511 | enum amdgpu_interrupt_state state) | |
3512 | { | |
3513 | u32 cp_int_cntl; | |
3514 | ||
3515 | switch (state) { | |
3516 | case AMDGPU_IRQ_STATE_DISABLE: | |
25069e06 | 3517 | cp_int_cntl = RREG32(mmCP_INT_CNTL_RING0); |
2cd46ad2 | 3518 | cp_int_cntl &= ~CP_INT_CNTL_RING0__PRIV_REG_INT_ENABLE_MASK; |
25069e06 | 3519 | WREG32(mmCP_INT_CNTL_RING0, cp_int_cntl); |
2cd46ad2 KW |
3520 | break; |
3521 | case AMDGPU_IRQ_STATE_ENABLE: | |
25069e06 | 3522 | cp_int_cntl = RREG32(mmCP_INT_CNTL_RING0); |
2cd46ad2 | 3523 | cp_int_cntl |= CP_INT_CNTL_RING0__PRIV_REG_INT_ENABLE_MASK; |
25069e06 | 3524 | WREG32(mmCP_INT_CNTL_RING0, cp_int_cntl); |
2cd46ad2 KW |
3525 | break; |
3526 | default: | |
3527 | break; | |
3528 | } | |
3529 | ||
3530 | return 0; | |
3531 | } | |
3532 | ||
3533 | static int gfx_v6_0_set_priv_inst_fault_state(struct amdgpu_device *adev, | |
3534 | struct amdgpu_irq_src *src, | |
3535 | unsigned type, | |
3536 | enum amdgpu_interrupt_state state) | |
3537 | { | |
3538 | u32 cp_int_cntl; | |
3539 | ||
3540 | switch (state) { | |
3541 | case AMDGPU_IRQ_STATE_DISABLE: | |
25069e06 | 3542 | cp_int_cntl = RREG32(mmCP_INT_CNTL_RING0); |
2cd46ad2 | 3543 | cp_int_cntl &= ~CP_INT_CNTL_RING0__PRIV_INSTR_INT_ENABLE_MASK; |
25069e06 | 3544 | WREG32(mmCP_INT_CNTL_RING0, cp_int_cntl); |
2cd46ad2 KW |
3545 | break; |
3546 | case AMDGPU_IRQ_STATE_ENABLE: | |
25069e06 | 3547 | cp_int_cntl = RREG32(mmCP_INT_CNTL_RING0); |
2cd46ad2 | 3548 | cp_int_cntl |= CP_INT_CNTL_RING0__PRIV_INSTR_INT_ENABLE_MASK; |
25069e06 | 3549 | WREG32(mmCP_INT_CNTL_RING0, cp_int_cntl); |
2cd46ad2 KW |
3550 | break; |
3551 | default: | |
3552 | break; | |
3553 | } | |
3554 | ||
3555 | return 0; | |
3556 | } | |
3557 | ||
3558 | static int gfx_v6_0_set_eop_interrupt_state(struct amdgpu_device *adev, | |
3559 | struct amdgpu_irq_src *src, | |
3560 | unsigned type, | |
3561 | enum amdgpu_interrupt_state state) | |
3562 | { | |
3563 | switch (type) { | |
3564 | case AMDGPU_CP_IRQ_GFX_EOP: | |
3565 | gfx_v6_0_set_gfx_eop_interrupt_state(adev, state); | |
3566 | break; | |
3567 | case AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP: | |
3568 | gfx_v6_0_set_compute_eop_interrupt_state(adev, 0, state); | |
3569 | break; | |
3570 | case AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE1_EOP: | |
3571 | gfx_v6_0_set_compute_eop_interrupt_state(adev, 1, state); | |
3572 | break; | |
3573 | default: | |
3574 | break; | |
3575 | } | |
3576 | return 0; | |
3577 | } | |
3578 | ||
3579 | static int gfx_v6_0_eop_irq(struct amdgpu_device *adev, | |
3580 | struct amdgpu_irq_src *source, | |
3581 | struct amdgpu_iv_entry *entry) | |
3582 | { | |
3583 | switch (entry->ring_id) { | |
3584 | case 0: | |
3585 | amdgpu_fence_process(&adev->gfx.gfx_ring[0]); | |
3586 | break; | |
3587 | case 1: | |
3588 | case 2: | |
25069e06 | 3589 | amdgpu_fence_process(&adev->gfx.compute_ring[entry->ring_id - 1]); |
2cd46ad2 KW |
3590 | break; |
3591 | default: | |
3592 | break; | |
3593 | } | |
3594 | return 0; | |
3595 | } | |
3596 | ||
3597 | static int gfx_v6_0_priv_reg_irq(struct amdgpu_device *adev, | |
3598 | struct amdgpu_irq_src *source, | |
3599 | struct amdgpu_iv_entry *entry) | |
3600 | { | |
3601 | DRM_ERROR("Illegal register access in command stream\n"); | |
3602 | schedule_work(&adev->reset_work); | |
3603 | return 0; | |
3604 | } | |
3605 | ||
3606 | static int gfx_v6_0_priv_inst_irq(struct amdgpu_device *adev, | |
3607 | struct amdgpu_irq_src *source, | |
3608 | struct amdgpu_iv_entry *entry) | |
3609 | { | |
3610 | DRM_ERROR("Illegal instruction in command stream\n"); | |
3611 | schedule_work(&adev->reset_work); | |
3612 | return 0; | |
3613 | } | |
3614 | ||
3615 | static int gfx_v6_0_set_clockgating_state(void *handle, | |
3616 | enum amd_clockgating_state state) | |
3617 | { | |
3618 | bool gate = false; | |
3619 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
3620 | ||
3621 | if (state == AMD_CG_STATE_GATE) | |
3622 | gate = true; | |
3623 | ||
3624 | gfx_v6_0_enable_gui_idle_interrupt(adev, false); | |
3625 | if (gate) { | |
3626 | gfx_v6_0_enable_mgcg(adev, true); | |
3627 | gfx_v6_0_enable_cgcg(adev, true); | |
3628 | } else { | |
3629 | gfx_v6_0_enable_cgcg(adev, false); | |
3630 | gfx_v6_0_enable_mgcg(adev, false); | |
3631 | } | |
3632 | gfx_v6_0_enable_gui_idle_interrupt(adev, true); | |
3633 | ||
3634 | return 0; | |
3635 | } | |
3636 | ||
3637 | static int gfx_v6_0_set_powergating_state(void *handle, | |
3638 | enum amd_powergating_state state) | |
3639 | { | |
3640 | bool gate = false; | |
3641 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
3642 | ||
3643 | if (state == AMD_PG_STATE_GATE) | |
3644 | gate = true; | |
3645 | ||
3646 | if (adev->pg_flags & (AMD_PG_SUPPORT_GFX_PG | | |
3647 | AMD_PG_SUPPORT_GFX_SMG | | |
3648 | AMD_PG_SUPPORT_GFX_DMG | | |
3649 | AMD_PG_SUPPORT_CP | | |
3650 | AMD_PG_SUPPORT_GDS | | |
3651 | AMD_PG_SUPPORT_RLC_SMU_HS)) { | |
3652 | gfx_v6_0_update_gfx_pg(adev, gate); | |
3653 | if (adev->pg_flags & AMD_PG_SUPPORT_GFX_PG) { | |
3654 | gfx_v6_0_enable_cp_pg(adev, gate); | |
3655 | gfx_v6_0_enable_gds_pg(adev, gate); | |
3656 | } | |
3657 | } | |
3658 | ||
3659 | return 0; | |
3660 | } | |
3661 | ||
a1255107 | 3662 | static const struct amd_ip_funcs gfx_v6_0_ip_funcs = { |
2cd46ad2 KW |
3663 | .name = "gfx_v6_0", |
3664 | .early_init = gfx_v6_0_early_init, | |
3665 | .late_init = NULL, | |
3666 | .sw_init = gfx_v6_0_sw_init, | |
3667 | .sw_fini = gfx_v6_0_sw_fini, | |
3668 | .hw_init = gfx_v6_0_hw_init, | |
3669 | .hw_fini = gfx_v6_0_hw_fini, | |
3670 | .suspend = gfx_v6_0_suspend, | |
3671 | .resume = gfx_v6_0_resume, | |
3672 | .is_idle = gfx_v6_0_is_idle, | |
3673 | .wait_for_idle = gfx_v6_0_wait_for_idle, | |
3674 | .soft_reset = gfx_v6_0_soft_reset, | |
3675 | .set_clockgating_state = gfx_v6_0_set_clockgating_state, | |
3676 | .set_powergating_state = gfx_v6_0_set_powergating_state, | |
3677 | }; | |
3678 | ||
3679 | static const struct amdgpu_ring_funcs gfx_v6_0_ring_funcs_gfx = { | |
21cd942e | 3680 | .type = AMDGPU_RING_TYPE_GFX, |
79887142 CK |
3681 | .align_mask = 0xff, |
3682 | .nop = 0x80000000, | |
6f924e20 | 3683 | .get_rptr = gfx_v6_0_ring_get_rptr, |
832c6ef7 | 3684 | .get_wptr = gfx_v6_0_ring_get_wptr, |
2cd46ad2 | 3685 | .set_wptr = gfx_v6_0_ring_set_wptr_gfx, |
e12f3d7a CK |
3686 | .emit_frame_size = |
3687 | 5 + /* gfx_v6_0_ring_emit_hdp_flush */ | |
3688 | 5 + /* gfx_v6_0_ring_emit_hdp_invalidate */ | |
3689 | 14 + 14 + 14 + /* gfx_v6_0_ring_emit_fence x3 for user fence, vm fence */ | |
3690 | 7 + 4 + /* gfx_v6_0_ring_emit_pipeline_sync */ | |
3691 | 17 + 6 + /* gfx_v6_0_ring_emit_vm_flush */ | |
45682886 | 3692 | 3 + 2, /* gfx_v6_ring_emit_cntxcntl including vgt flush */ |
e12f3d7a | 3693 | .emit_ib_size = 6, /* gfx_v6_0_ring_emit_ib */ |
668f52c3 AD |
3694 | .emit_ib = gfx_v6_0_ring_emit_ib, |
3695 | .emit_fence = gfx_v6_0_ring_emit_fence, | |
2cd46ad2 KW |
3696 | .emit_pipeline_sync = gfx_v6_0_ring_emit_pipeline_sync, |
3697 | .emit_vm_flush = gfx_v6_0_ring_emit_vm_flush, | |
2cd46ad2 KW |
3698 | .emit_hdp_flush = gfx_v6_0_ring_emit_hdp_flush, |
3699 | .emit_hdp_invalidate = gfx_v6_0_ring_emit_hdp_invalidate, | |
3700 | .test_ring = gfx_v6_0_ring_test_ring, | |
3701 | .test_ib = gfx_v6_0_ring_test_ib, | |
3702 | .insert_nop = amdgpu_ring_insert_nop, | |
0f444c24 | 3703 | .emit_cntxcntl = gfx_v6_ring_emit_cntxcntl, |
2cd46ad2 KW |
3704 | }; |
3705 | ||
3706 | static const struct amdgpu_ring_funcs gfx_v6_0_ring_funcs_compute = { | |
21cd942e | 3707 | .type = AMDGPU_RING_TYPE_COMPUTE, |
79887142 CK |
3708 | .align_mask = 0xff, |
3709 | .nop = 0x80000000, | |
6f924e20 | 3710 | .get_rptr = gfx_v6_0_ring_get_rptr, |
832c6ef7 | 3711 | .get_wptr = gfx_v6_0_ring_get_wptr, |
2cd46ad2 | 3712 | .set_wptr = gfx_v6_0_ring_set_wptr_compute, |
e12f3d7a CK |
3713 | .emit_frame_size = |
3714 | 5 + /* gfx_v6_0_ring_emit_hdp_flush */ | |
3715 | 5 + /* gfx_v6_0_ring_emit_hdp_invalidate */ | |
3716 | 7 + /* gfx_v6_0_ring_emit_pipeline_sync */ | |
3717 | 17 + /* gfx_v6_0_ring_emit_vm_flush */ | |
3718 | 14 + 14 + 14, /* gfx_v6_0_ring_emit_fence x3 for user fence, vm fence */ | |
3719 | .emit_ib_size = 6, /* gfx_v6_0_ring_emit_ib */ | |
668f52c3 AD |
3720 | .emit_ib = gfx_v6_0_ring_emit_ib, |
3721 | .emit_fence = gfx_v6_0_ring_emit_fence, | |
2cd46ad2 KW |
3722 | .emit_pipeline_sync = gfx_v6_0_ring_emit_pipeline_sync, |
3723 | .emit_vm_flush = gfx_v6_0_ring_emit_vm_flush, | |
2cd46ad2 KW |
3724 | .emit_hdp_flush = gfx_v6_0_ring_emit_hdp_flush, |
3725 | .emit_hdp_invalidate = gfx_v6_0_ring_emit_hdp_invalidate, | |
3726 | .test_ring = gfx_v6_0_ring_test_ring, | |
3727 | .test_ib = gfx_v6_0_ring_test_ib, | |
3728 | .insert_nop = amdgpu_ring_insert_nop, | |
3729 | }; | |
3730 | ||
3731 | static void gfx_v6_0_set_ring_funcs(struct amdgpu_device *adev) | |
3732 | { | |
3733 | int i; | |
3734 | ||
3735 | for (i = 0; i < adev->gfx.num_gfx_rings; i++) | |
3736 | adev->gfx.gfx_ring[i].funcs = &gfx_v6_0_ring_funcs_gfx; | |
3737 | for (i = 0; i < adev->gfx.num_compute_rings; i++) | |
3738 | adev->gfx.compute_ring[i].funcs = &gfx_v6_0_ring_funcs_compute; | |
3739 | } | |
3740 | ||
3741 | static const struct amdgpu_irq_src_funcs gfx_v6_0_eop_irq_funcs = { | |
3742 | .set = gfx_v6_0_set_eop_interrupt_state, | |
3743 | .process = gfx_v6_0_eop_irq, | |
3744 | }; | |
3745 | ||
3746 | static const struct amdgpu_irq_src_funcs gfx_v6_0_priv_reg_irq_funcs = { | |
3747 | .set = gfx_v6_0_set_priv_reg_fault_state, | |
3748 | .process = gfx_v6_0_priv_reg_irq, | |
3749 | }; | |
3750 | ||
3751 | static const struct amdgpu_irq_src_funcs gfx_v6_0_priv_inst_irq_funcs = { | |
3752 | .set = gfx_v6_0_set_priv_inst_fault_state, | |
3753 | .process = gfx_v6_0_priv_inst_irq, | |
3754 | }; | |
3755 | ||
3756 | static void gfx_v6_0_set_irq_funcs(struct amdgpu_device *adev) | |
3757 | { | |
3758 | adev->gfx.eop_irq.num_types = AMDGPU_CP_IRQ_LAST; | |
3759 | adev->gfx.eop_irq.funcs = &gfx_v6_0_eop_irq_funcs; | |
3760 | ||
3761 | adev->gfx.priv_reg_irq.num_types = 1; | |
3762 | adev->gfx.priv_reg_irq.funcs = &gfx_v6_0_priv_reg_irq_funcs; | |
3763 | ||
3764 | adev->gfx.priv_inst_irq.num_types = 1; | |
3765 | adev->gfx.priv_inst_irq.funcs = &gfx_v6_0_priv_inst_irq_funcs; | |
3766 | } | |
3767 | ||
3768 | static void gfx_v6_0_get_cu_info(struct amdgpu_device *adev) | |
3769 | { | |
3770 | int i, j, k, counter, active_cu_number = 0; | |
3771 | u32 mask, bitmap, ao_bitmap, ao_cu_mask = 0; | |
3772 | struct amdgpu_cu_info *cu_info = &adev->gfx.cu_info; | |
3773 | ||
3774 | memset(cu_info, 0, sizeof(*cu_info)); | |
3775 | ||
2cd46ad2 KW |
3776 | for (i = 0; i < adev->gfx.config.max_shader_engines; i++) { |
3777 | for (j = 0; j < adev->gfx.config.max_sh_per_se; j++) { | |
3778 | mask = 1; | |
3779 | ao_bitmap = 0; | |
3780 | counter = 0; | |
2cd46ad2 KW |
3781 | bitmap = gfx_v6_0_get_cu_active_bitmap(adev, i, j); |
3782 | cu_info->bitmap[i][j] = bitmap; | |
3783 | ||
3784 | for (k = 0; k < adev->gfx.config.max_cu_per_sh; k ++) { | |
3785 | if (bitmap & mask) { | |
3786 | if (counter < 2) | |
3787 | ao_bitmap |= mask; | |
3788 | counter ++; | |
3789 | } | |
3790 | mask <<= 1; | |
3791 | } | |
3792 | active_cu_number += counter; | |
3793 | ao_cu_mask |= (ao_bitmap << (i * 16 + j * 8)); | |
3794 | } | |
3795 | } | |
2cd46ad2 KW |
3796 | |
3797 | cu_info->number = active_cu_number; | |
3798 | cu_info->ao_cu_mask = ao_cu_mask; | |
3799 | } | |
a1255107 AD |
3800 | |
3801 | const struct amdgpu_ip_block_version gfx_v6_0_ip_block = | |
3802 | { | |
3803 | .type = AMD_IP_BLOCK_TYPE_GFX, | |
3804 | .major = 6, | |
3805 | .minor = 0, | |
3806 | .rev = 0, | |
3807 | .funcs = &gfx_v6_0_ip_funcs, | |
3808 | }; |