2 * Copyright 2014 Advanced Micro Devices, Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
23 #include <linux/firmware.h>
26 #include "amdgpu_ih.h"
27 #include "amdgpu_gfx.h"
31 #include "amdgpu_ucode.h"
32 #include "clearstate_ci.h"
34 #include "uvd/uvd_4_2_d.h"
36 #include "dce/dce_8_0_d.h"
37 #include "dce/dce_8_0_sh_mask.h"
39 #include "bif/bif_4_1_d.h"
40 #include "bif/bif_4_1_sh_mask.h"
42 #include "gca/gfx_7_0_d.h"
43 #include "gca/gfx_7_2_enum.h"
44 #include "gca/gfx_7_2_sh_mask.h"
46 #include "gmc/gmc_7_0_d.h"
47 #include "gmc/gmc_7_0_sh_mask.h"
49 #include "oss/oss_2_0_d.h"
50 #include "oss/oss_2_0_sh_mask.h"
52 #define GFX7_NUM_GFX_RINGS 1
53 #define GFX7_NUM_COMPUTE_RINGS 8
55 static void gfx_v7_0_set_ring_funcs(struct amdgpu_device
*adev
);
56 static void gfx_v7_0_set_irq_funcs(struct amdgpu_device
*adev
);
57 static void gfx_v7_0_set_gds_init(struct amdgpu_device
*adev
);
58 int gfx_v7_0_get_cu_info(struct amdgpu_device
*, struct amdgpu_cu_info
*);
60 MODULE_FIRMWARE("radeon/bonaire_pfp.bin");
61 MODULE_FIRMWARE("radeon/bonaire_me.bin");
62 MODULE_FIRMWARE("radeon/bonaire_ce.bin");
63 MODULE_FIRMWARE("radeon/bonaire_rlc.bin");
64 MODULE_FIRMWARE("radeon/bonaire_mec.bin");
66 MODULE_FIRMWARE("radeon/hawaii_pfp.bin");
67 MODULE_FIRMWARE("radeon/hawaii_me.bin");
68 MODULE_FIRMWARE("radeon/hawaii_ce.bin");
69 MODULE_FIRMWARE("radeon/hawaii_rlc.bin");
70 MODULE_FIRMWARE("radeon/hawaii_mec.bin");
72 MODULE_FIRMWARE("radeon/kaveri_pfp.bin");
73 MODULE_FIRMWARE("radeon/kaveri_me.bin");
74 MODULE_FIRMWARE("radeon/kaveri_ce.bin");
75 MODULE_FIRMWARE("radeon/kaveri_rlc.bin");
76 MODULE_FIRMWARE("radeon/kaveri_mec.bin");
77 MODULE_FIRMWARE("radeon/kaveri_mec2.bin");
79 MODULE_FIRMWARE("radeon/kabini_pfp.bin");
80 MODULE_FIRMWARE("radeon/kabini_me.bin");
81 MODULE_FIRMWARE("radeon/kabini_ce.bin");
82 MODULE_FIRMWARE("radeon/kabini_rlc.bin");
83 MODULE_FIRMWARE("radeon/kabini_mec.bin");
85 MODULE_FIRMWARE("radeon/mullins_pfp.bin");
86 MODULE_FIRMWARE("radeon/mullins_me.bin");
87 MODULE_FIRMWARE("radeon/mullins_ce.bin");
88 MODULE_FIRMWARE("radeon/mullins_rlc.bin");
89 MODULE_FIRMWARE("radeon/mullins_mec.bin");
91 static const struct amdgpu_gds_reg_offset amdgpu_gds_reg_offset
[] =
93 {mmGDS_VMID0_BASE
, mmGDS_VMID0_SIZE
, mmGDS_GWS_VMID0
, mmGDS_OA_VMID0
},
94 {mmGDS_VMID1_BASE
, mmGDS_VMID1_SIZE
, mmGDS_GWS_VMID1
, mmGDS_OA_VMID1
},
95 {mmGDS_VMID2_BASE
, mmGDS_VMID2_SIZE
, mmGDS_GWS_VMID2
, mmGDS_OA_VMID2
},
96 {mmGDS_VMID3_BASE
, mmGDS_VMID3_SIZE
, mmGDS_GWS_VMID3
, mmGDS_OA_VMID3
},
97 {mmGDS_VMID4_BASE
, mmGDS_VMID4_SIZE
, mmGDS_GWS_VMID4
, mmGDS_OA_VMID4
},
98 {mmGDS_VMID5_BASE
, mmGDS_VMID5_SIZE
, mmGDS_GWS_VMID5
, mmGDS_OA_VMID5
},
99 {mmGDS_VMID6_BASE
, mmGDS_VMID6_SIZE
, mmGDS_GWS_VMID6
, mmGDS_OA_VMID6
},
100 {mmGDS_VMID7_BASE
, mmGDS_VMID7_SIZE
, mmGDS_GWS_VMID7
, mmGDS_OA_VMID7
},
101 {mmGDS_VMID8_BASE
, mmGDS_VMID8_SIZE
, mmGDS_GWS_VMID8
, mmGDS_OA_VMID8
},
102 {mmGDS_VMID9_BASE
, mmGDS_VMID9_SIZE
, mmGDS_GWS_VMID9
, mmGDS_OA_VMID9
},
103 {mmGDS_VMID10_BASE
, mmGDS_VMID10_SIZE
, mmGDS_GWS_VMID10
, mmGDS_OA_VMID10
},
104 {mmGDS_VMID11_BASE
, mmGDS_VMID11_SIZE
, mmGDS_GWS_VMID11
, mmGDS_OA_VMID11
},
105 {mmGDS_VMID12_BASE
, mmGDS_VMID12_SIZE
, mmGDS_GWS_VMID12
, mmGDS_OA_VMID12
},
106 {mmGDS_VMID13_BASE
, mmGDS_VMID13_SIZE
, mmGDS_GWS_VMID13
, mmGDS_OA_VMID13
},
107 {mmGDS_VMID14_BASE
, mmGDS_VMID14_SIZE
, mmGDS_GWS_VMID14
, mmGDS_OA_VMID14
},
108 {mmGDS_VMID15_BASE
, mmGDS_VMID15_SIZE
, mmGDS_GWS_VMID15
, mmGDS_OA_VMID15
}
111 static const u32 spectre_rlc_save_restore_register_list
[] =
113 (0x0e00 << 16) | (0xc12c >> 2),
115 (0x0e00 << 16) | (0xc140 >> 2),
117 (0x0e00 << 16) | (0xc150 >> 2),
119 (0x0e00 << 16) | (0xc15c >> 2),
121 (0x0e00 << 16) | (0xc168 >> 2),
123 (0x0e00 << 16) | (0xc170 >> 2),
125 (0x0e00 << 16) | (0xc178 >> 2),
127 (0x0e00 << 16) | (0xc204 >> 2),
129 (0x0e00 << 16) | (0xc2b4 >> 2),
131 (0x0e00 << 16) | (0xc2b8 >> 2),
133 (0x0e00 << 16) | (0xc2bc >> 2),
135 (0x0e00 << 16) | (0xc2c0 >> 2),
137 (0x0e00 << 16) | (0x8228 >> 2),
139 (0x0e00 << 16) | (0x829c >> 2),
141 (0x0e00 << 16) | (0x869c >> 2),
143 (0x0600 << 16) | (0x98f4 >> 2),
145 (0x0e00 << 16) | (0x98f8 >> 2),
147 (0x0e00 << 16) | (0x9900 >> 2),
149 (0x0e00 << 16) | (0xc260 >> 2),
151 (0x0e00 << 16) | (0x90e8 >> 2),
153 (0x0e00 << 16) | (0x3c000 >> 2),
155 (0x0e00 << 16) | (0x3c00c >> 2),
157 (0x0e00 << 16) | (0x8c1c >> 2),
159 (0x0e00 << 16) | (0x9700 >> 2),
161 (0x0e00 << 16) | (0xcd20 >> 2),
163 (0x4e00 << 16) | (0xcd20 >> 2),
165 (0x5e00 << 16) | (0xcd20 >> 2),
167 (0x6e00 << 16) | (0xcd20 >> 2),
169 (0x7e00 << 16) | (0xcd20 >> 2),
171 (0x8e00 << 16) | (0xcd20 >> 2),
173 (0x9e00 << 16) | (0xcd20 >> 2),
175 (0xae00 << 16) | (0xcd20 >> 2),
177 (0xbe00 << 16) | (0xcd20 >> 2),
179 (0x0e00 << 16) | (0x89bc >> 2),
181 (0x0e00 << 16) | (0x8900 >> 2),
184 (0x0e00 << 16) | (0xc130 >> 2),
186 (0x0e00 << 16) | (0xc134 >> 2),
188 (0x0e00 << 16) | (0xc1fc >> 2),
190 (0x0e00 << 16) | (0xc208 >> 2),
192 (0x0e00 << 16) | (0xc264 >> 2),
194 (0x0e00 << 16) | (0xc268 >> 2),
196 (0x0e00 << 16) | (0xc26c >> 2),
198 (0x0e00 << 16) | (0xc270 >> 2),
200 (0x0e00 << 16) | (0xc274 >> 2),
202 (0x0e00 << 16) | (0xc278 >> 2),
204 (0x0e00 << 16) | (0xc27c >> 2),
206 (0x0e00 << 16) | (0xc280 >> 2),
208 (0x0e00 << 16) | (0xc284 >> 2),
210 (0x0e00 << 16) | (0xc288 >> 2),
212 (0x0e00 << 16) | (0xc28c >> 2),
214 (0x0e00 << 16) | (0xc290 >> 2),
216 (0x0e00 << 16) | (0xc294 >> 2),
218 (0x0e00 << 16) | (0xc298 >> 2),
220 (0x0e00 << 16) | (0xc29c >> 2),
222 (0x0e00 << 16) | (0xc2a0 >> 2),
224 (0x0e00 << 16) | (0xc2a4 >> 2),
226 (0x0e00 << 16) | (0xc2a8 >> 2),
228 (0x0e00 << 16) | (0xc2ac >> 2),
230 (0x0e00 << 16) | (0xc2b0 >> 2),
232 (0x0e00 << 16) | (0x301d0 >> 2),
234 (0x0e00 << 16) | (0x30238 >> 2),
236 (0x0e00 << 16) | (0x30250 >> 2),
238 (0x0e00 << 16) | (0x30254 >> 2),
240 (0x0e00 << 16) | (0x30258 >> 2),
242 (0x0e00 << 16) | (0x3025c >> 2),
244 (0x4e00 << 16) | (0xc900 >> 2),
246 (0x5e00 << 16) | (0xc900 >> 2),
248 (0x6e00 << 16) | (0xc900 >> 2),
250 (0x7e00 << 16) | (0xc900 >> 2),
252 (0x8e00 << 16) | (0xc900 >> 2),
254 (0x9e00 << 16) | (0xc900 >> 2),
256 (0xae00 << 16) | (0xc900 >> 2),
258 (0xbe00 << 16) | (0xc900 >> 2),
260 (0x4e00 << 16) | (0xc904 >> 2),
262 (0x5e00 << 16) | (0xc904 >> 2),
264 (0x6e00 << 16) | (0xc904 >> 2),
266 (0x7e00 << 16) | (0xc904 >> 2),
268 (0x8e00 << 16) | (0xc904 >> 2),
270 (0x9e00 << 16) | (0xc904 >> 2),
272 (0xae00 << 16) | (0xc904 >> 2),
274 (0xbe00 << 16) | (0xc904 >> 2),
276 (0x4e00 << 16) | (0xc908 >> 2),
278 (0x5e00 << 16) | (0xc908 >> 2),
280 (0x6e00 << 16) | (0xc908 >> 2),
282 (0x7e00 << 16) | (0xc908 >> 2),
284 (0x8e00 << 16) | (0xc908 >> 2),
286 (0x9e00 << 16) | (0xc908 >> 2),
288 (0xae00 << 16) | (0xc908 >> 2),
290 (0xbe00 << 16) | (0xc908 >> 2),
292 (0x4e00 << 16) | (0xc90c >> 2),
294 (0x5e00 << 16) | (0xc90c >> 2),
296 (0x6e00 << 16) | (0xc90c >> 2),
298 (0x7e00 << 16) | (0xc90c >> 2),
300 (0x8e00 << 16) | (0xc90c >> 2),
302 (0x9e00 << 16) | (0xc90c >> 2),
304 (0xae00 << 16) | (0xc90c >> 2),
306 (0xbe00 << 16) | (0xc90c >> 2),
308 (0x4e00 << 16) | (0xc910 >> 2),
310 (0x5e00 << 16) | (0xc910 >> 2),
312 (0x6e00 << 16) | (0xc910 >> 2),
314 (0x7e00 << 16) | (0xc910 >> 2),
316 (0x8e00 << 16) | (0xc910 >> 2),
318 (0x9e00 << 16) | (0xc910 >> 2),
320 (0xae00 << 16) | (0xc910 >> 2),
322 (0xbe00 << 16) | (0xc910 >> 2),
324 (0x0e00 << 16) | (0xc99c >> 2),
326 (0x0e00 << 16) | (0x9834 >> 2),
328 (0x0000 << 16) | (0x30f00 >> 2),
330 (0x0001 << 16) | (0x30f00 >> 2),
332 (0x0000 << 16) | (0x30f04 >> 2),
334 (0x0001 << 16) | (0x30f04 >> 2),
336 (0x0000 << 16) | (0x30f08 >> 2),
338 (0x0001 << 16) | (0x30f08 >> 2),
340 (0x0000 << 16) | (0x30f0c >> 2),
342 (0x0001 << 16) | (0x30f0c >> 2),
344 (0x0600 << 16) | (0x9b7c >> 2),
346 (0x0e00 << 16) | (0x8a14 >> 2),
348 (0x0e00 << 16) | (0x8a18 >> 2),
350 (0x0600 << 16) | (0x30a00 >> 2),
352 (0x0e00 << 16) | (0x8bf0 >> 2),
354 (0x0e00 << 16) | (0x8bcc >> 2),
356 (0x0e00 << 16) | (0x8b24 >> 2),
358 (0x0e00 << 16) | (0x30a04 >> 2),
360 (0x0600 << 16) | (0x30a10 >> 2),
362 (0x0600 << 16) | (0x30a14 >> 2),
364 (0x0600 << 16) | (0x30a18 >> 2),
366 (0x0600 << 16) | (0x30a2c >> 2),
368 (0x0e00 << 16) | (0xc700 >> 2),
370 (0x0e00 << 16) | (0xc704 >> 2),
372 (0x0e00 << 16) | (0xc708 >> 2),
374 (0x0e00 << 16) | (0xc768 >> 2),
376 (0x0400 << 16) | (0xc770 >> 2),
378 (0x0400 << 16) | (0xc774 >> 2),
380 (0x0400 << 16) | (0xc778 >> 2),
382 (0x0400 << 16) | (0xc77c >> 2),
384 (0x0400 << 16) | (0xc780 >> 2),
386 (0x0400 << 16) | (0xc784 >> 2),
388 (0x0400 << 16) | (0xc788 >> 2),
390 (0x0400 << 16) | (0xc78c >> 2),
392 (0x0400 << 16) | (0xc798 >> 2),
394 (0x0400 << 16) | (0xc79c >> 2),
396 (0x0400 << 16) | (0xc7a0 >> 2),
398 (0x0400 << 16) | (0xc7a4 >> 2),
400 (0x0400 << 16) | (0xc7a8 >> 2),
402 (0x0400 << 16) | (0xc7ac >> 2),
404 (0x0400 << 16) | (0xc7b0 >> 2),
406 (0x0400 << 16) | (0xc7b4 >> 2),
408 (0x0e00 << 16) | (0x9100 >> 2),
410 (0x0e00 << 16) | (0x3c010 >> 2),
412 (0x0e00 << 16) | (0x92a8 >> 2),
414 (0x0e00 << 16) | (0x92ac >> 2),
416 (0x0e00 << 16) | (0x92b4 >> 2),
418 (0x0e00 << 16) | (0x92b8 >> 2),
420 (0x0e00 << 16) | (0x92bc >> 2),
422 (0x0e00 << 16) | (0x92c0 >> 2),
424 (0x0e00 << 16) | (0x92c4 >> 2),
426 (0x0e00 << 16) | (0x92c8 >> 2),
428 (0x0e00 << 16) | (0x92cc >> 2),
430 (0x0e00 << 16) | (0x92d0 >> 2),
432 (0x0e00 << 16) | (0x8c00 >> 2),
434 (0x0e00 << 16) | (0x8c04 >> 2),
436 (0x0e00 << 16) | (0x8c20 >> 2),
438 (0x0e00 << 16) | (0x8c38 >> 2),
440 (0x0e00 << 16) | (0x8c3c >> 2),
442 (0x0e00 << 16) | (0xae00 >> 2),
444 (0x0e00 << 16) | (0x9604 >> 2),
446 (0x0e00 << 16) | (0xac08 >> 2),
448 (0x0e00 << 16) | (0xac0c >> 2),
450 (0x0e00 << 16) | (0xac10 >> 2),
452 (0x0e00 << 16) | (0xac14 >> 2),
454 (0x0e00 << 16) | (0xac58 >> 2),
456 (0x0e00 << 16) | (0xac68 >> 2),
458 (0x0e00 << 16) | (0xac6c >> 2),
460 (0x0e00 << 16) | (0xac70 >> 2),
462 (0x0e00 << 16) | (0xac74 >> 2),
464 (0x0e00 << 16) | (0xac78 >> 2),
466 (0x0e00 << 16) | (0xac7c >> 2),
468 (0x0e00 << 16) | (0xac80 >> 2),
470 (0x0e00 << 16) | (0xac84 >> 2),
472 (0x0e00 << 16) | (0xac88 >> 2),
474 (0x0e00 << 16) | (0xac8c >> 2),
476 (0x0e00 << 16) | (0x970c >> 2),
478 (0x0e00 << 16) | (0x9714 >> 2),
480 (0x0e00 << 16) | (0x9718 >> 2),
482 (0x0e00 << 16) | (0x971c >> 2),
484 (0x0e00 << 16) | (0x31068 >> 2),
486 (0x4e00 << 16) | (0x31068 >> 2),
488 (0x5e00 << 16) | (0x31068 >> 2),
490 (0x6e00 << 16) | (0x31068 >> 2),
492 (0x7e00 << 16) | (0x31068 >> 2),
494 (0x8e00 << 16) | (0x31068 >> 2),
496 (0x9e00 << 16) | (0x31068 >> 2),
498 (0xae00 << 16) | (0x31068 >> 2),
500 (0xbe00 << 16) | (0x31068 >> 2),
502 (0x0e00 << 16) | (0xcd10 >> 2),
504 (0x0e00 << 16) | (0xcd14 >> 2),
506 (0x0e00 << 16) | (0x88b0 >> 2),
508 (0x0e00 << 16) | (0x88b4 >> 2),
510 (0x0e00 << 16) | (0x88b8 >> 2),
512 (0x0e00 << 16) | (0x88bc >> 2),
514 (0x0400 << 16) | (0x89c0 >> 2),
516 (0x0e00 << 16) | (0x88c4 >> 2),
518 (0x0e00 << 16) | (0x88c8 >> 2),
520 (0x0e00 << 16) | (0x88d0 >> 2),
522 (0x0e00 << 16) | (0x88d4 >> 2),
524 (0x0e00 << 16) | (0x88d8 >> 2),
526 (0x0e00 << 16) | (0x8980 >> 2),
528 (0x0e00 << 16) | (0x30938 >> 2),
530 (0x0e00 << 16) | (0x3093c >> 2),
532 (0x0e00 << 16) | (0x30940 >> 2),
534 (0x0e00 << 16) | (0x89a0 >> 2),
536 (0x0e00 << 16) | (0x30900 >> 2),
538 (0x0e00 << 16) | (0x30904 >> 2),
540 (0x0e00 << 16) | (0x89b4 >> 2),
542 (0x0e00 << 16) | (0x3c210 >> 2),
544 (0x0e00 << 16) | (0x3c214 >> 2),
546 (0x0e00 << 16) | (0x3c218 >> 2),
548 (0x0e00 << 16) | (0x8904 >> 2),
551 (0x0e00 << 16) | (0x8c28 >> 2),
552 (0x0e00 << 16) | (0x8c2c >> 2),
553 (0x0e00 << 16) | (0x8c30 >> 2),
554 (0x0e00 << 16) | (0x8c34 >> 2),
555 (0x0e00 << 16) | (0x9600 >> 2),
558 static const u32 kalindi_rlc_save_restore_register_list
[] =
560 (0x0e00 << 16) | (0xc12c >> 2),
562 (0x0e00 << 16) | (0xc140 >> 2),
564 (0x0e00 << 16) | (0xc150 >> 2),
566 (0x0e00 << 16) | (0xc15c >> 2),
568 (0x0e00 << 16) | (0xc168 >> 2),
570 (0x0e00 << 16) | (0xc170 >> 2),
572 (0x0e00 << 16) | (0xc204 >> 2),
574 (0x0e00 << 16) | (0xc2b4 >> 2),
576 (0x0e00 << 16) | (0xc2b8 >> 2),
578 (0x0e00 << 16) | (0xc2bc >> 2),
580 (0x0e00 << 16) | (0xc2c0 >> 2),
582 (0x0e00 << 16) | (0x8228 >> 2),
584 (0x0e00 << 16) | (0x829c >> 2),
586 (0x0e00 << 16) | (0x869c >> 2),
588 (0x0600 << 16) | (0x98f4 >> 2),
590 (0x0e00 << 16) | (0x98f8 >> 2),
592 (0x0e00 << 16) | (0x9900 >> 2),
594 (0x0e00 << 16) | (0xc260 >> 2),
596 (0x0e00 << 16) | (0x90e8 >> 2),
598 (0x0e00 << 16) | (0x3c000 >> 2),
600 (0x0e00 << 16) | (0x3c00c >> 2),
602 (0x0e00 << 16) | (0x8c1c >> 2),
604 (0x0e00 << 16) | (0x9700 >> 2),
606 (0x0e00 << 16) | (0xcd20 >> 2),
608 (0x4e00 << 16) | (0xcd20 >> 2),
610 (0x5e00 << 16) | (0xcd20 >> 2),
612 (0x6e00 << 16) | (0xcd20 >> 2),
614 (0x7e00 << 16) | (0xcd20 >> 2),
616 (0x0e00 << 16) | (0x89bc >> 2),
618 (0x0e00 << 16) | (0x8900 >> 2),
621 (0x0e00 << 16) | (0xc130 >> 2),
623 (0x0e00 << 16) | (0xc134 >> 2),
625 (0x0e00 << 16) | (0xc1fc >> 2),
627 (0x0e00 << 16) | (0xc208 >> 2),
629 (0x0e00 << 16) | (0xc264 >> 2),
631 (0x0e00 << 16) | (0xc268 >> 2),
633 (0x0e00 << 16) | (0xc26c >> 2),
635 (0x0e00 << 16) | (0xc270 >> 2),
637 (0x0e00 << 16) | (0xc274 >> 2),
639 (0x0e00 << 16) | (0xc28c >> 2),
641 (0x0e00 << 16) | (0xc290 >> 2),
643 (0x0e00 << 16) | (0xc294 >> 2),
645 (0x0e00 << 16) | (0xc298 >> 2),
647 (0x0e00 << 16) | (0xc2a0 >> 2),
649 (0x0e00 << 16) | (0xc2a4 >> 2),
651 (0x0e00 << 16) | (0xc2a8 >> 2),
653 (0x0e00 << 16) | (0xc2ac >> 2),
655 (0x0e00 << 16) | (0x301d0 >> 2),
657 (0x0e00 << 16) | (0x30238 >> 2),
659 (0x0e00 << 16) | (0x30250 >> 2),
661 (0x0e00 << 16) | (0x30254 >> 2),
663 (0x0e00 << 16) | (0x30258 >> 2),
665 (0x0e00 << 16) | (0x3025c >> 2),
667 (0x4e00 << 16) | (0xc900 >> 2),
669 (0x5e00 << 16) | (0xc900 >> 2),
671 (0x6e00 << 16) | (0xc900 >> 2),
673 (0x7e00 << 16) | (0xc900 >> 2),
675 (0x4e00 << 16) | (0xc904 >> 2),
677 (0x5e00 << 16) | (0xc904 >> 2),
679 (0x6e00 << 16) | (0xc904 >> 2),
681 (0x7e00 << 16) | (0xc904 >> 2),
683 (0x4e00 << 16) | (0xc908 >> 2),
685 (0x5e00 << 16) | (0xc908 >> 2),
687 (0x6e00 << 16) | (0xc908 >> 2),
689 (0x7e00 << 16) | (0xc908 >> 2),
691 (0x4e00 << 16) | (0xc90c >> 2),
693 (0x5e00 << 16) | (0xc90c >> 2),
695 (0x6e00 << 16) | (0xc90c >> 2),
697 (0x7e00 << 16) | (0xc90c >> 2),
699 (0x4e00 << 16) | (0xc910 >> 2),
701 (0x5e00 << 16) | (0xc910 >> 2),
703 (0x6e00 << 16) | (0xc910 >> 2),
705 (0x7e00 << 16) | (0xc910 >> 2),
707 (0x0e00 << 16) | (0xc99c >> 2),
709 (0x0e00 << 16) | (0x9834 >> 2),
711 (0x0000 << 16) | (0x30f00 >> 2),
713 (0x0000 << 16) | (0x30f04 >> 2),
715 (0x0000 << 16) | (0x30f08 >> 2),
717 (0x0000 << 16) | (0x30f0c >> 2),
719 (0x0600 << 16) | (0x9b7c >> 2),
721 (0x0e00 << 16) | (0x8a14 >> 2),
723 (0x0e00 << 16) | (0x8a18 >> 2),
725 (0x0600 << 16) | (0x30a00 >> 2),
727 (0x0e00 << 16) | (0x8bf0 >> 2),
729 (0x0e00 << 16) | (0x8bcc >> 2),
731 (0x0e00 << 16) | (0x8b24 >> 2),
733 (0x0e00 << 16) | (0x30a04 >> 2),
735 (0x0600 << 16) | (0x30a10 >> 2),
737 (0x0600 << 16) | (0x30a14 >> 2),
739 (0x0600 << 16) | (0x30a18 >> 2),
741 (0x0600 << 16) | (0x30a2c >> 2),
743 (0x0e00 << 16) | (0xc700 >> 2),
745 (0x0e00 << 16) | (0xc704 >> 2),
747 (0x0e00 << 16) | (0xc708 >> 2),
749 (0x0e00 << 16) | (0xc768 >> 2),
751 (0x0400 << 16) | (0xc770 >> 2),
753 (0x0400 << 16) | (0xc774 >> 2),
755 (0x0400 << 16) | (0xc798 >> 2),
757 (0x0400 << 16) | (0xc79c >> 2),
759 (0x0e00 << 16) | (0x9100 >> 2),
761 (0x0e00 << 16) | (0x3c010 >> 2),
763 (0x0e00 << 16) | (0x8c00 >> 2),
765 (0x0e00 << 16) | (0x8c04 >> 2),
767 (0x0e00 << 16) | (0x8c20 >> 2),
769 (0x0e00 << 16) | (0x8c38 >> 2),
771 (0x0e00 << 16) | (0x8c3c >> 2),
773 (0x0e00 << 16) | (0xae00 >> 2),
775 (0x0e00 << 16) | (0x9604 >> 2),
777 (0x0e00 << 16) | (0xac08 >> 2),
779 (0x0e00 << 16) | (0xac0c >> 2),
781 (0x0e00 << 16) | (0xac10 >> 2),
783 (0x0e00 << 16) | (0xac14 >> 2),
785 (0x0e00 << 16) | (0xac58 >> 2),
787 (0x0e00 << 16) | (0xac68 >> 2),
789 (0x0e00 << 16) | (0xac6c >> 2),
791 (0x0e00 << 16) | (0xac70 >> 2),
793 (0x0e00 << 16) | (0xac74 >> 2),
795 (0x0e00 << 16) | (0xac78 >> 2),
797 (0x0e00 << 16) | (0xac7c >> 2),
799 (0x0e00 << 16) | (0xac80 >> 2),
801 (0x0e00 << 16) | (0xac84 >> 2),
803 (0x0e00 << 16) | (0xac88 >> 2),
805 (0x0e00 << 16) | (0xac8c >> 2),
807 (0x0e00 << 16) | (0x970c >> 2),
809 (0x0e00 << 16) | (0x9714 >> 2),
811 (0x0e00 << 16) | (0x9718 >> 2),
813 (0x0e00 << 16) | (0x971c >> 2),
815 (0x0e00 << 16) | (0x31068 >> 2),
817 (0x4e00 << 16) | (0x31068 >> 2),
819 (0x5e00 << 16) | (0x31068 >> 2),
821 (0x6e00 << 16) | (0x31068 >> 2),
823 (0x7e00 << 16) | (0x31068 >> 2),
825 (0x0e00 << 16) | (0xcd10 >> 2),
827 (0x0e00 << 16) | (0xcd14 >> 2),
829 (0x0e00 << 16) | (0x88b0 >> 2),
831 (0x0e00 << 16) | (0x88b4 >> 2),
833 (0x0e00 << 16) | (0x88b8 >> 2),
835 (0x0e00 << 16) | (0x88bc >> 2),
837 (0x0400 << 16) | (0x89c0 >> 2),
839 (0x0e00 << 16) | (0x88c4 >> 2),
841 (0x0e00 << 16) | (0x88c8 >> 2),
843 (0x0e00 << 16) | (0x88d0 >> 2),
845 (0x0e00 << 16) | (0x88d4 >> 2),
847 (0x0e00 << 16) | (0x88d8 >> 2),
849 (0x0e00 << 16) | (0x8980 >> 2),
851 (0x0e00 << 16) | (0x30938 >> 2),
853 (0x0e00 << 16) | (0x3093c >> 2),
855 (0x0e00 << 16) | (0x30940 >> 2),
857 (0x0e00 << 16) | (0x89a0 >> 2),
859 (0x0e00 << 16) | (0x30900 >> 2),
861 (0x0e00 << 16) | (0x30904 >> 2),
863 (0x0e00 << 16) | (0x89b4 >> 2),
865 (0x0e00 << 16) | (0x3e1fc >> 2),
867 (0x0e00 << 16) | (0x3c210 >> 2),
869 (0x0e00 << 16) | (0x3c214 >> 2),
871 (0x0e00 << 16) | (0x3c218 >> 2),
873 (0x0e00 << 16) | (0x8904 >> 2),
876 (0x0e00 << 16) | (0x8c28 >> 2),
877 (0x0e00 << 16) | (0x8c2c >> 2),
878 (0x0e00 << 16) | (0x8c30 >> 2),
879 (0x0e00 << 16) | (0x8c34 >> 2),
880 (0x0e00 << 16) | (0x9600 >> 2),
883 static u32
gfx_v7_0_get_csb_size(struct amdgpu_device
*adev
);
884 static void gfx_v7_0_get_csb_buffer(struct amdgpu_device
*adev
, volatile u32
*buffer
);
885 static void gfx_v7_0_init_cp_pg_table(struct amdgpu_device
*adev
);
886 static void gfx_v7_0_init_pg(struct amdgpu_device
*adev
);
892 * gfx_v7_0_init_microcode - load ucode images from disk
894 * @adev: amdgpu_device pointer
896 * Use the firmware interface to load the ucode images into
897 * the driver (not loaded into hw).
898 * Returns 0 on success, error on failure.
900 static int gfx_v7_0_init_microcode(struct amdgpu_device
*adev
)
902 const char *chip_name
;
908 switch (adev
->asic_type
) {
910 chip_name
= "bonaire";
913 chip_name
= "hawaii";
916 chip_name
= "kaveri";
919 chip_name
= "kabini";
922 chip_name
= "mullins";
927 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_pfp.bin", chip_name
);
928 err
= request_firmware(&adev
->gfx
.pfp_fw
, fw_name
, adev
->dev
);
931 err
= amdgpu_ucode_validate(adev
->gfx
.pfp_fw
);
935 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_me.bin", chip_name
);
936 err
= request_firmware(&adev
->gfx
.me_fw
, fw_name
, adev
->dev
);
939 err
= amdgpu_ucode_validate(adev
->gfx
.me_fw
);
943 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_ce.bin", chip_name
);
944 err
= request_firmware(&adev
->gfx
.ce_fw
, fw_name
, adev
->dev
);
947 err
= amdgpu_ucode_validate(adev
->gfx
.ce_fw
);
951 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_mec.bin", chip_name
);
952 err
= request_firmware(&adev
->gfx
.mec_fw
, fw_name
, adev
->dev
);
955 err
= amdgpu_ucode_validate(adev
->gfx
.mec_fw
);
959 if (adev
->asic_type
== CHIP_KAVERI
) {
960 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_mec2.bin", chip_name
);
961 err
= request_firmware(&adev
->gfx
.mec2_fw
, fw_name
, adev
->dev
);
964 err
= amdgpu_ucode_validate(adev
->gfx
.mec2_fw
);
969 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_rlc.bin", chip_name
);
970 err
= request_firmware(&adev
->gfx
.rlc_fw
, fw_name
, adev
->dev
);
973 err
= amdgpu_ucode_validate(adev
->gfx
.rlc_fw
);
978 "gfx7: Failed to load firmware \"%s\"\n",
980 release_firmware(adev
->gfx
.pfp_fw
);
981 adev
->gfx
.pfp_fw
= NULL
;
982 release_firmware(adev
->gfx
.me_fw
);
983 adev
->gfx
.me_fw
= NULL
;
984 release_firmware(adev
->gfx
.ce_fw
);
985 adev
->gfx
.ce_fw
= NULL
;
986 release_firmware(adev
->gfx
.mec_fw
);
987 adev
->gfx
.mec_fw
= NULL
;
988 release_firmware(adev
->gfx
.mec2_fw
);
989 adev
->gfx
.mec2_fw
= NULL
;
990 release_firmware(adev
->gfx
.rlc_fw
);
991 adev
->gfx
.rlc_fw
= NULL
;
997 * gfx_v7_0_tiling_mode_table_init - init the hw tiling table
999 * @adev: amdgpu_device pointer
1001 * Starting with SI, the tiling setup is done globally in a
1002 * set of 32 tiling modes. Rather than selecting each set of
1003 * parameters per surface as on older asics, we just select
1004 * which index in the tiling table we want to use, and the
1005 * surface uses those parameters (CIK).
1007 static void gfx_v7_0_tiling_mode_table_init(struct amdgpu_device
*adev
)
1009 const u32 num_tile_mode_states
= 32;
1010 const u32 num_secondary_tile_mode_states
= 16;
1011 u32 reg_offset
, gb_tile_moden
, split_equal_to_row_size
;
1013 switch (adev
->gfx
.config
.mem_row_size_in_kb
) {
1015 split_equal_to_row_size
= ADDR_SURF_TILE_SPLIT_1KB
;
1019 split_equal_to_row_size
= ADDR_SURF_TILE_SPLIT_2KB
;
1022 split_equal_to_row_size
= ADDR_SURF_TILE_SPLIT_4KB
;
1026 switch (adev
->asic_type
) {
1028 for (reg_offset
= 0; reg_offset
< num_tile_mode_states
; reg_offset
++) {
1029 switch (reg_offset
) {
1031 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
1032 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1033 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B
) |
1034 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
));
1037 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
1038 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1039 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B
) |
1040 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
));
1043 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
1044 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1045 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B
) |
1046 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
));
1049 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
1050 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1051 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B
) |
1052 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
));
1055 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
1056 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1057 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
1058 TILE_SPLIT(split_equal_to_row_size
));
1061 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
1062 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1063 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
));
1066 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
1067 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1068 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
1069 TILE_SPLIT(split_equal_to_row_size
));
1072 gb_tile_moden
= (TILE_SPLIT(split_equal_to_row_size
));
1076 gb_tile_moden
= (ARRAY_MODE(ARRAY_LINEAR_ALIGNED
) |
1077 PIPE_CONFIG(ADDR_SURF_P4_16x16
));
1080 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
1081 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1082 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
));
1085 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
1086 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1087 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
) |
1088 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
1091 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
1092 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1093 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
) |
1094 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8
));
1097 gb_tile_moden
= (TILE_SPLIT(split_equal_to_row_size
));
1100 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
1101 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1102 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
));
1105 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
1106 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1107 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
1108 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
1111 gb_tile_moden
= (ARRAY_MODE(ARRAY_3D_TILED_THIN1
) |
1112 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1113 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
1114 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
1117 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
1118 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1119 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
1120 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8
));
1123 gb_tile_moden
= (TILE_SPLIT(split_equal_to_row_size
));
1126 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THICK
) |
1127 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1128 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
1129 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1
));
1132 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THICK
) |
1133 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1134 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
));
1137 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THICK
) |
1138 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1139 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
1140 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1
));
1143 gb_tile_moden
= (ARRAY_MODE(ARRAY_3D_TILED_THICK
) |
1144 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1145 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
1146 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1
));
1149 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THICK
) |
1150 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1151 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
1152 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1
));
1155 gb_tile_moden
= (TILE_SPLIT(split_equal_to_row_size
));
1158 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THICK
) |
1159 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1160 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
1161 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1
));
1164 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_XTHICK
) |
1165 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1166 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
1167 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1
));
1170 gb_tile_moden
= (ARRAY_MODE(ARRAY_3D_TILED_XTHICK
) |
1171 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1172 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
1173 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1
));
1176 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
1177 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1178 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
));
1181 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
1182 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1183 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
) |
1184 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
1187 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
1188 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1189 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
) |
1190 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8
));
1193 gb_tile_moden
= (TILE_SPLIT(split_equal_to_row_size
));
1199 adev
->gfx
.config
.tile_mode_array
[reg_offset
] = gb_tile_moden
;
1200 WREG32(mmGB_TILE_MODE0
+ reg_offset
, gb_tile_moden
);
1202 for (reg_offset
= 0; reg_offset
< num_secondary_tile_mode_states
; reg_offset
++) {
1203 switch (reg_offset
) {
1205 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1206 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4
) |
1207 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
1208 NUM_BANKS(ADDR_SURF_16_BANK
));
1211 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1212 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2
) |
1213 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
1214 NUM_BANKS(ADDR_SURF_16_BANK
));
1217 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1218 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
1219 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
1220 NUM_BANKS(ADDR_SURF_16_BANK
));
1223 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1224 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
1225 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
1226 NUM_BANKS(ADDR_SURF_16_BANK
));
1229 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1230 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
1231 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
1232 NUM_BANKS(ADDR_SURF_16_BANK
));
1235 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1236 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
1237 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
1238 NUM_BANKS(ADDR_SURF_8_BANK
));
1241 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1242 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
1243 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
1244 NUM_BANKS(ADDR_SURF_4_BANK
));
1247 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2
) |
1248 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_8
) |
1249 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
1250 NUM_BANKS(ADDR_SURF_16_BANK
));
1253 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2
) |
1254 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4
) |
1255 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
1256 NUM_BANKS(ADDR_SURF_16_BANK
));
1259 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1260 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4
) |
1261 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
1262 NUM_BANKS(ADDR_SURF_16_BANK
));
1265 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1266 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2
) |
1267 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
1268 NUM_BANKS(ADDR_SURF_16_BANK
));
1271 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1272 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
1273 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
1274 NUM_BANKS(ADDR_SURF_16_BANK
));
1277 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1278 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
1279 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
1280 NUM_BANKS(ADDR_SURF_8_BANK
));
1283 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1284 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
1285 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
1286 NUM_BANKS(ADDR_SURF_4_BANK
));
1292 adev
->gfx
.config
.macrotile_mode_array
[reg_offset
] = gb_tile_moden
;
1293 WREG32(mmGB_MACROTILE_MODE0
+ reg_offset
, gb_tile_moden
);
1297 for (reg_offset
= 0; reg_offset
< num_tile_mode_states
; reg_offset
++) {
1298 switch (reg_offset
) {
1300 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
1301 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1302 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B
) |
1303 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
));
1306 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
1307 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1308 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B
) |
1309 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
));
1312 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
1313 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1314 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B
) |
1315 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
));
1318 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
1319 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1320 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B
) |
1321 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
));
1324 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
1325 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1326 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
1327 TILE_SPLIT(split_equal_to_row_size
));
1330 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
1331 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1332 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
1333 TILE_SPLIT(split_equal_to_row_size
));
1336 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
1337 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1338 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
1339 TILE_SPLIT(split_equal_to_row_size
));
1342 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
1343 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1344 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
1345 TILE_SPLIT(split_equal_to_row_size
));
1349 gb_tile_moden
= (ARRAY_MODE(ARRAY_LINEAR_ALIGNED
) |
1350 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
));
1353 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
1354 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1355 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
));
1358 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
1359 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1360 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
) |
1361 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
1364 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
1365 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1366 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
) |
1367 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8
));
1370 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
1371 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1372 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
) |
1373 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8
));
1376 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
1377 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1378 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
));
1381 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
1382 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1383 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
1384 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
1387 gb_tile_moden
= (ARRAY_MODE(ARRAY_3D_TILED_THIN1
) |
1388 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1389 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
1390 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
1393 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
1394 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1395 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
1396 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8
));
1399 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
1400 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1401 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
1402 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8
));
1405 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THICK
) |
1406 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1407 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
1408 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1
));
1411 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THICK
) |
1412 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1413 MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING
));
1416 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THICK
) |
1417 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1418 MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING
) |
1419 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1
));
1422 gb_tile_moden
= (ARRAY_MODE(ARRAY_3D_TILED_THICK
) |
1423 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1424 MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING
) |
1425 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1
));
1428 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THICK
) |
1429 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1430 MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING
) |
1431 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1
));
1434 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THICK
) |
1435 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1436 MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING
) |
1437 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1
));
1440 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THICK
) |
1441 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1442 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
1443 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1
));
1446 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_XTHICK
) |
1447 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1448 MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING
) |
1449 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1
));
1452 gb_tile_moden
= (ARRAY_MODE(ARRAY_3D_TILED_XTHICK
) |
1453 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1454 MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING
) |
1455 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1
));
1458 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
1459 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1460 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
));
1463 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
1464 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1465 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
) |
1466 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
1469 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
1470 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
1471 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
) |
1472 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8
));
1475 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
1476 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
1477 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
) |
1478 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8
));
1484 adev
->gfx
.config
.tile_mode_array
[reg_offset
] = gb_tile_moden
;
1485 WREG32(mmGB_TILE_MODE0
+ reg_offset
, gb_tile_moden
);
1487 for (reg_offset
= 0; reg_offset
< num_secondary_tile_mode_states
; reg_offset
++) {
1488 switch (reg_offset
) {
1490 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1491 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4
) |
1492 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
1493 NUM_BANKS(ADDR_SURF_16_BANK
));
1496 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1497 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2
) |
1498 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
1499 NUM_BANKS(ADDR_SURF_16_BANK
));
1502 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1503 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
1504 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
1505 NUM_BANKS(ADDR_SURF_16_BANK
));
1508 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1509 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
1510 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
1511 NUM_BANKS(ADDR_SURF_16_BANK
));
1514 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1515 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
1516 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
1517 NUM_BANKS(ADDR_SURF_8_BANK
));
1520 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1521 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
1522 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
1523 NUM_BANKS(ADDR_SURF_4_BANK
));
1526 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1527 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
1528 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
1529 NUM_BANKS(ADDR_SURF_4_BANK
));
1532 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1533 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4
) |
1534 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
1535 NUM_BANKS(ADDR_SURF_16_BANK
));
1538 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1539 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2
) |
1540 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
1541 NUM_BANKS(ADDR_SURF_16_BANK
));
1544 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1545 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
1546 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
1547 NUM_BANKS(ADDR_SURF_16_BANK
));
1550 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1551 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
1552 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
1553 NUM_BANKS(ADDR_SURF_8_BANK
));
1556 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1557 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
1558 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
1559 NUM_BANKS(ADDR_SURF_16_BANK
));
1562 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1563 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
1564 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
1565 NUM_BANKS(ADDR_SURF_8_BANK
));
1568 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1569 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
1570 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
1571 NUM_BANKS(ADDR_SURF_4_BANK
));
1577 adev
->gfx
.config
.macrotile_mode_array
[reg_offset
] = gb_tile_moden
;
1578 WREG32(mmGB_MACROTILE_MODE0
+ reg_offset
, gb_tile_moden
);
1585 for (reg_offset
= 0; reg_offset
< num_tile_mode_states
; reg_offset
++) {
1586 switch (reg_offset
) {
1588 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
1589 PIPE_CONFIG(ADDR_SURF_P2
) |
1590 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B
) |
1591 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
));
1594 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
1595 PIPE_CONFIG(ADDR_SURF_P2
) |
1596 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B
) |
1597 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
));
1600 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
1601 PIPE_CONFIG(ADDR_SURF_P2
) |
1602 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B
) |
1603 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
));
1606 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
1607 PIPE_CONFIG(ADDR_SURF_P2
) |
1608 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B
) |
1609 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
));
1612 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
1613 PIPE_CONFIG(ADDR_SURF_P2
) |
1614 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
1615 TILE_SPLIT(split_equal_to_row_size
));
1618 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
1619 PIPE_CONFIG(ADDR_SURF_P2
) |
1620 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
));
1623 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
1624 PIPE_CONFIG(ADDR_SURF_P2
) |
1625 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
1626 TILE_SPLIT(split_equal_to_row_size
));
1629 gb_tile_moden
= (TILE_SPLIT(split_equal_to_row_size
));
1633 gb_tile_moden
= (ARRAY_MODE(ARRAY_LINEAR_ALIGNED
) |
1634 PIPE_CONFIG(ADDR_SURF_P2
));
1637 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
1638 PIPE_CONFIG(ADDR_SURF_P2
) |
1639 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
));
1642 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
1643 PIPE_CONFIG(ADDR_SURF_P2
) |
1644 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
) |
1645 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
1648 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
1649 PIPE_CONFIG(ADDR_SURF_P2
) |
1650 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
) |
1651 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8
));
1654 gb_tile_moden
= (TILE_SPLIT(split_equal_to_row_size
));
1657 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
1658 PIPE_CONFIG(ADDR_SURF_P2
) |
1659 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
));
1662 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
1663 PIPE_CONFIG(ADDR_SURF_P2
) |
1664 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
1665 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
1668 gb_tile_moden
= (ARRAY_MODE(ARRAY_3D_TILED_THIN1
) |
1669 PIPE_CONFIG(ADDR_SURF_P2
) |
1670 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
1671 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
1674 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
1675 PIPE_CONFIG(ADDR_SURF_P2
) |
1676 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
1677 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8
));
1680 gb_tile_moden
= (TILE_SPLIT(split_equal_to_row_size
));
1683 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THICK
) |
1684 PIPE_CONFIG(ADDR_SURF_P2
) |
1685 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
1686 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1
));
1689 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THICK
) |
1690 PIPE_CONFIG(ADDR_SURF_P2
) |
1691 MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING
));
1694 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THICK
) |
1695 PIPE_CONFIG(ADDR_SURF_P2
) |
1696 MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING
) |
1697 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1
));
1700 gb_tile_moden
= (ARRAY_MODE(ARRAY_3D_TILED_THICK
) |
1701 PIPE_CONFIG(ADDR_SURF_P2
) |
1702 MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING
) |
1703 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1
));
1706 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THICK
) |
1707 PIPE_CONFIG(ADDR_SURF_P2
) |
1708 MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING
) |
1709 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1
));
1712 gb_tile_moden
= (TILE_SPLIT(split_equal_to_row_size
));
1715 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THICK
) |
1716 PIPE_CONFIG(ADDR_SURF_P2
) |
1717 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
1718 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1
));
1721 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_XTHICK
) |
1722 PIPE_CONFIG(ADDR_SURF_P2
) |
1723 MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING
) |
1724 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1
));
1727 gb_tile_moden
= (ARRAY_MODE(ARRAY_3D_TILED_XTHICK
) |
1728 PIPE_CONFIG(ADDR_SURF_P2
) |
1729 MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING
) |
1730 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1
));
1733 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
1734 PIPE_CONFIG(ADDR_SURF_P2
) |
1735 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
));
1738 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
1739 PIPE_CONFIG(ADDR_SURF_P2
) |
1740 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
) |
1741 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
1744 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
1745 PIPE_CONFIG(ADDR_SURF_P2
) |
1746 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
) |
1747 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8
));
1750 gb_tile_moden
= (TILE_SPLIT(split_equal_to_row_size
));
1756 adev
->gfx
.config
.tile_mode_array
[reg_offset
] = gb_tile_moden
;
1757 WREG32(mmGB_TILE_MODE0
+ reg_offset
, gb_tile_moden
);
1759 for (reg_offset
= 0; reg_offset
< num_secondary_tile_mode_states
; reg_offset
++) {
1760 switch (reg_offset
) {
1762 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1763 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4
) |
1764 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
1765 NUM_BANKS(ADDR_SURF_8_BANK
));
1768 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1769 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2
) |
1770 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
1771 NUM_BANKS(ADDR_SURF_8_BANK
));
1774 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1775 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2
) |
1776 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
1777 NUM_BANKS(ADDR_SURF_8_BANK
));
1780 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1781 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
1782 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
1783 NUM_BANKS(ADDR_SURF_8_BANK
));
1786 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1787 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
1788 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
1789 NUM_BANKS(ADDR_SURF_8_BANK
));
1792 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1793 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
1794 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
1795 NUM_BANKS(ADDR_SURF_8_BANK
));
1798 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1799 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
1800 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
1801 NUM_BANKS(ADDR_SURF_8_BANK
));
1804 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_4
) |
1805 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_8
) |
1806 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
1807 NUM_BANKS(ADDR_SURF_16_BANK
));
1810 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_4
) |
1811 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4
) |
1812 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
1813 NUM_BANKS(ADDR_SURF_16_BANK
));
1816 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2
) |
1817 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4
) |
1818 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
1819 NUM_BANKS(ADDR_SURF_16_BANK
));
1822 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2
) |
1823 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2
) |
1824 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
1825 NUM_BANKS(ADDR_SURF_16_BANK
));
1828 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1829 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2
) |
1830 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
1831 NUM_BANKS(ADDR_SURF_16_BANK
));
1834 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1835 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
1836 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
1837 NUM_BANKS(ADDR_SURF_16_BANK
));
1840 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
1841 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
1842 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
1843 NUM_BANKS(ADDR_SURF_8_BANK
));
1849 adev
->gfx
.config
.macrotile_mode_array
[reg_offset
] = gb_tile_moden
;
1850 WREG32(mmGB_MACROTILE_MODE0
+ reg_offset
, gb_tile_moden
);
1857 * gfx_v7_0_select_se_sh - select which SE, SH to address
1859 * @adev: amdgpu_device pointer
1860 * @se_num: shader engine to address
1861 * @sh_num: sh block to address
1863 * Select which SE, SH combinations to address. Certain
1864 * registers are instanced per SE or SH. 0xffffffff means
1865 * broadcast to all SEs or SHs (CIK).
1867 void gfx_v7_0_select_se_sh(struct amdgpu_device
*adev
, u32 se_num
, u32 sh_num
)
1869 u32 data
= GRBM_GFX_INDEX__INSTANCE_BROADCAST_WRITES_MASK
;
1871 if ((se_num
== 0xffffffff) && (sh_num
== 0xffffffff))
1872 data
|= GRBM_GFX_INDEX__SH_BROADCAST_WRITES_MASK
|
1873 GRBM_GFX_INDEX__SE_BROADCAST_WRITES_MASK
;
1874 else if (se_num
== 0xffffffff)
1875 data
|= GRBM_GFX_INDEX__SE_BROADCAST_WRITES_MASK
|
1876 (sh_num
<< GRBM_GFX_INDEX__SH_INDEX__SHIFT
);
1877 else if (sh_num
== 0xffffffff)
1878 data
|= GRBM_GFX_INDEX__SH_BROADCAST_WRITES_MASK
|
1879 (se_num
<< GRBM_GFX_INDEX__SE_INDEX__SHIFT
);
1881 data
|= (sh_num
<< GRBM_GFX_INDEX__SH_INDEX__SHIFT
) |
1882 (se_num
<< GRBM_GFX_INDEX__SE_INDEX__SHIFT
);
1883 WREG32(mmGRBM_GFX_INDEX
, data
);
1887 * gfx_v7_0_create_bitmask - create a bitmask
1889 * @bit_width: length of the mask
1891 * create a variable length bit mask (CIK).
1892 * Returns the bitmask.
1894 static u32
gfx_v7_0_create_bitmask(u32 bit_width
)
1898 for (i
= 0; i
< bit_width
; i
++) {
1906 * gfx_v7_0_get_rb_disabled - computes the mask of disabled RBs
1908 * @adev: amdgpu_device pointer
1909 * @max_rb_num: max RBs (render backends) for the asic
1910 * @se_num: number of SEs (shader engines) for the asic
1911 * @sh_per_se: number of SH blocks per SE for the asic
1913 * Calculates the bitmask of disabled RBs (CIK).
1914 * Returns the disabled RB bitmask.
1916 static u32
gfx_v7_0_get_rb_disabled(struct amdgpu_device
*adev
,
1917 u32 max_rb_num_per_se
,
1922 data
= RREG32(mmCC_RB_BACKEND_DISABLE
);
1924 data
&= CC_RB_BACKEND_DISABLE__BACKEND_DISABLE_MASK
;
1928 data
|= RREG32(mmGC_USER_RB_BACKEND_DISABLE
);
1930 data
>>= GC_USER_RB_BACKEND_DISABLE__BACKEND_DISABLE__SHIFT
;
1932 mask
= gfx_v7_0_create_bitmask(max_rb_num_per_se
/ sh_per_se
);
1938 * gfx_v7_0_setup_rb - setup the RBs on the asic
1940 * @adev: amdgpu_device pointer
1941 * @se_num: number of SEs (shader engines) for the asic
1942 * @sh_per_se: number of SH blocks per SE for the asic
1943 * @max_rb_num: max RBs (render backends) for the asic
1945 * Configures per-SE/SH RB registers (CIK).
1947 static void gfx_v7_0_setup_rb(struct amdgpu_device
*adev
,
1948 u32 se_num
, u32 sh_per_se
,
1949 u32 max_rb_num_per_se
)
1953 u32 disabled_rbs
= 0;
1954 u32 enabled_rbs
= 0;
1956 mutex_lock(&adev
->grbm_idx_mutex
);
1957 for (i
= 0; i
< se_num
; i
++) {
1958 for (j
= 0; j
< sh_per_se
; j
++) {
1959 gfx_v7_0_select_se_sh(adev
, i
, j
);
1960 data
= gfx_v7_0_get_rb_disabled(adev
, max_rb_num_per_se
, sh_per_se
);
1961 if (adev
->asic_type
== CHIP_HAWAII
)
1962 disabled_rbs
|= data
<< ((i
* sh_per_se
+ j
) * HAWAII_RB_BITMAP_WIDTH_PER_SH
);
1964 disabled_rbs
|= data
<< ((i
* sh_per_se
+ j
) * CIK_RB_BITMAP_WIDTH_PER_SH
);
1967 gfx_v7_0_select_se_sh(adev
, 0xffffffff, 0xffffffff);
1968 mutex_unlock(&adev
->grbm_idx_mutex
);
1971 for (i
= 0; i
< max_rb_num_per_se
* se_num
; i
++) {
1972 if (!(disabled_rbs
& mask
))
1973 enabled_rbs
|= mask
;
1977 adev
->gfx
.config
.backend_enable_mask
= enabled_rbs
;
1979 mutex_lock(&adev
->grbm_idx_mutex
);
1980 for (i
= 0; i
< se_num
; i
++) {
1981 gfx_v7_0_select_se_sh(adev
, i
, 0xffffffff);
1983 for (j
= 0; j
< sh_per_se
; j
++) {
1984 switch (enabled_rbs
& 3) {
1987 data
|= (RASTER_CONFIG_RB_MAP_3
<<
1988 PA_SC_RASTER_CONFIG__PKR_MAP__SHIFT
);
1990 data
|= (RASTER_CONFIG_RB_MAP_0
<<
1991 PA_SC_RASTER_CONFIG__PKR_MAP__SHIFT
);
1994 data
|= (RASTER_CONFIG_RB_MAP_0
<< (i
* sh_per_se
+ j
) * 2);
1997 data
|= (RASTER_CONFIG_RB_MAP_3
<< (i
* sh_per_se
+ j
) * 2);
2001 data
|= (RASTER_CONFIG_RB_MAP_2
<< (i
* sh_per_se
+ j
) * 2);
2006 WREG32(mmPA_SC_RASTER_CONFIG
, data
);
2008 gfx_v7_0_select_se_sh(adev
, 0xffffffff, 0xffffffff);
2009 mutex_unlock(&adev
->grbm_idx_mutex
);
2013 * gmc_v7_0_init_compute_vmid - gart enable
2015 * @rdev: amdgpu_device pointer
2017 * Initialize compute vmid sh_mem registers
2020 #define DEFAULT_SH_MEM_BASES (0x6000)
2021 #define FIRST_COMPUTE_VMID (8)
2022 #define LAST_COMPUTE_VMID (16)
2023 static void gmc_v7_0_init_compute_vmid(struct amdgpu_device
*adev
)
2026 uint32_t sh_mem_config
;
2027 uint32_t sh_mem_bases
;
2030 * Configure apertures:
2031 * LDS: 0x60000000'00000000 - 0x60000001'00000000 (4GB)
2032 * Scratch: 0x60000001'00000000 - 0x60000002'00000000 (4GB)
2033 * GPUVM: 0x60010000'00000000 - 0x60020000'00000000 (1TB)
2035 sh_mem_bases
= DEFAULT_SH_MEM_BASES
| (DEFAULT_SH_MEM_BASES
<< 16);
2036 sh_mem_config
= SH_MEM_ALIGNMENT_MODE_UNALIGNED
<<
2037 SH_MEM_CONFIG__ALIGNMENT_MODE__SHIFT
;
2038 sh_mem_config
|= MTYPE_NONCACHED
<< SH_MEM_CONFIG__DEFAULT_MTYPE__SHIFT
;
2039 mutex_lock(&adev
->srbm_mutex
);
2040 for (i
= FIRST_COMPUTE_VMID
; i
< LAST_COMPUTE_VMID
; i
++) {
2041 cik_srbm_select(adev
, 0, 0, 0, i
);
2042 /* CP and shaders */
2043 WREG32(mmSH_MEM_CONFIG
, sh_mem_config
);
2044 WREG32(mmSH_MEM_APE1_BASE
, 1);
2045 WREG32(mmSH_MEM_APE1_LIMIT
, 0);
2046 WREG32(mmSH_MEM_BASES
, sh_mem_bases
);
2048 cik_srbm_select(adev
, 0, 0, 0, 0);
2049 mutex_unlock(&adev
->srbm_mutex
);
2053 * gfx_v7_0_gpu_init - setup the 3D engine
2055 * @adev: amdgpu_device pointer
2057 * Configures the 3D engine and tiling configuration
2058 * registers so that the 3D engine is usable.
2060 static void gfx_v7_0_gpu_init(struct amdgpu_device
*adev
)
2063 u32 mc_shared_chmap
, mc_arb_ramcfg
;
2064 u32 dimm00_addr_map
, dimm01_addr_map
, dimm10_addr_map
, dimm11_addr_map
;
2069 switch (adev
->asic_type
) {
2071 adev
->gfx
.config
.max_shader_engines
= 2;
2072 adev
->gfx
.config
.max_tile_pipes
= 4;
2073 adev
->gfx
.config
.max_cu_per_sh
= 7;
2074 adev
->gfx
.config
.max_sh_per_se
= 1;
2075 adev
->gfx
.config
.max_backends_per_se
= 2;
2076 adev
->gfx
.config
.max_texture_channel_caches
= 4;
2077 adev
->gfx
.config
.max_gprs
= 256;
2078 adev
->gfx
.config
.max_gs_threads
= 32;
2079 adev
->gfx
.config
.max_hw_contexts
= 8;
2081 adev
->gfx
.config
.sc_prim_fifo_size_frontend
= 0x20;
2082 adev
->gfx
.config
.sc_prim_fifo_size_backend
= 0x100;
2083 adev
->gfx
.config
.sc_hiz_tile_fifo_size
= 0x30;
2084 adev
->gfx
.config
.sc_earlyz_tile_fifo_size
= 0x130;
2085 gb_addr_config
= BONAIRE_GB_ADDR_CONFIG_GOLDEN
;
2088 adev
->gfx
.config
.max_shader_engines
= 4;
2089 adev
->gfx
.config
.max_tile_pipes
= 16;
2090 adev
->gfx
.config
.max_cu_per_sh
= 11;
2091 adev
->gfx
.config
.max_sh_per_se
= 1;
2092 adev
->gfx
.config
.max_backends_per_se
= 4;
2093 adev
->gfx
.config
.max_texture_channel_caches
= 16;
2094 adev
->gfx
.config
.max_gprs
= 256;
2095 adev
->gfx
.config
.max_gs_threads
= 32;
2096 adev
->gfx
.config
.max_hw_contexts
= 8;
2098 adev
->gfx
.config
.sc_prim_fifo_size_frontend
= 0x20;
2099 adev
->gfx
.config
.sc_prim_fifo_size_backend
= 0x100;
2100 adev
->gfx
.config
.sc_hiz_tile_fifo_size
= 0x30;
2101 adev
->gfx
.config
.sc_earlyz_tile_fifo_size
= 0x130;
2102 gb_addr_config
= HAWAII_GB_ADDR_CONFIG_GOLDEN
;
2105 adev
->gfx
.config
.max_shader_engines
= 1;
2106 adev
->gfx
.config
.max_tile_pipes
= 4;
2107 if ((adev
->pdev
->device
== 0x1304) ||
2108 (adev
->pdev
->device
== 0x1305) ||
2109 (adev
->pdev
->device
== 0x130C) ||
2110 (adev
->pdev
->device
== 0x130F) ||
2111 (adev
->pdev
->device
== 0x1310) ||
2112 (adev
->pdev
->device
== 0x1311) ||
2113 (adev
->pdev
->device
== 0x131C)) {
2114 adev
->gfx
.config
.max_cu_per_sh
= 8;
2115 adev
->gfx
.config
.max_backends_per_se
= 2;
2116 } else if ((adev
->pdev
->device
== 0x1309) ||
2117 (adev
->pdev
->device
== 0x130A) ||
2118 (adev
->pdev
->device
== 0x130D) ||
2119 (adev
->pdev
->device
== 0x1313) ||
2120 (adev
->pdev
->device
== 0x131D)) {
2121 adev
->gfx
.config
.max_cu_per_sh
= 6;
2122 adev
->gfx
.config
.max_backends_per_se
= 2;
2123 } else if ((adev
->pdev
->device
== 0x1306) ||
2124 (adev
->pdev
->device
== 0x1307) ||
2125 (adev
->pdev
->device
== 0x130B) ||
2126 (adev
->pdev
->device
== 0x130E) ||
2127 (adev
->pdev
->device
== 0x1315) ||
2128 (adev
->pdev
->device
== 0x131B)) {
2129 adev
->gfx
.config
.max_cu_per_sh
= 4;
2130 adev
->gfx
.config
.max_backends_per_se
= 1;
2132 adev
->gfx
.config
.max_cu_per_sh
= 3;
2133 adev
->gfx
.config
.max_backends_per_se
= 1;
2135 adev
->gfx
.config
.max_sh_per_se
= 1;
2136 adev
->gfx
.config
.max_texture_channel_caches
= 4;
2137 adev
->gfx
.config
.max_gprs
= 256;
2138 adev
->gfx
.config
.max_gs_threads
= 16;
2139 adev
->gfx
.config
.max_hw_contexts
= 8;
2141 adev
->gfx
.config
.sc_prim_fifo_size_frontend
= 0x20;
2142 adev
->gfx
.config
.sc_prim_fifo_size_backend
= 0x100;
2143 adev
->gfx
.config
.sc_hiz_tile_fifo_size
= 0x30;
2144 adev
->gfx
.config
.sc_earlyz_tile_fifo_size
= 0x130;
2145 gb_addr_config
= BONAIRE_GB_ADDR_CONFIG_GOLDEN
;
2150 adev
->gfx
.config
.max_shader_engines
= 1;
2151 adev
->gfx
.config
.max_tile_pipes
= 2;
2152 adev
->gfx
.config
.max_cu_per_sh
= 2;
2153 adev
->gfx
.config
.max_sh_per_se
= 1;
2154 adev
->gfx
.config
.max_backends_per_se
= 1;
2155 adev
->gfx
.config
.max_texture_channel_caches
= 2;
2156 adev
->gfx
.config
.max_gprs
= 256;
2157 adev
->gfx
.config
.max_gs_threads
= 16;
2158 adev
->gfx
.config
.max_hw_contexts
= 8;
2160 adev
->gfx
.config
.sc_prim_fifo_size_frontend
= 0x20;
2161 adev
->gfx
.config
.sc_prim_fifo_size_backend
= 0x100;
2162 adev
->gfx
.config
.sc_hiz_tile_fifo_size
= 0x30;
2163 adev
->gfx
.config
.sc_earlyz_tile_fifo_size
= 0x130;
2164 gb_addr_config
= BONAIRE_GB_ADDR_CONFIG_GOLDEN
;
2168 WREG32(mmGRBM_CNTL
, (0xff << GRBM_CNTL__READ_TIMEOUT__SHIFT
));
2170 mc_shared_chmap
= RREG32(mmMC_SHARED_CHMAP
);
2171 adev
->gfx
.config
.mc_arb_ramcfg
= RREG32(mmMC_ARB_RAMCFG
);
2172 mc_arb_ramcfg
= adev
->gfx
.config
.mc_arb_ramcfg
;
2174 adev
->gfx
.config
.num_tile_pipes
= adev
->gfx
.config
.max_tile_pipes
;
2175 adev
->gfx
.config
.mem_max_burst_length_bytes
= 256;
2176 if (adev
->flags
& AMD_IS_APU
) {
2177 /* Get memory bank mapping mode. */
2178 tmp
= RREG32(mmMC_FUS_DRAM0_BANK_ADDR_MAPPING
);
2179 dimm00_addr_map
= REG_GET_FIELD(tmp
, MC_FUS_DRAM0_BANK_ADDR_MAPPING
, DIMM0ADDRMAP
);
2180 dimm01_addr_map
= REG_GET_FIELD(tmp
, MC_FUS_DRAM0_BANK_ADDR_MAPPING
, DIMM1ADDRMAP
);
2182 tmp
= RREG32(mmMC_FUS_DRAM1_BANK_ADDR_MAPPING
);
2183 dimm10_addr_map
= REG_GET_FIELD(tmp
, MC_FUS_DRAM1_BANK_ADDR_MAPPING
, DIMM0ADDRMAP
);
2184 dimm11_addr_map
= REG_GET_FIELD(tmp
, MC_FUS_DRAM1_BANK_ADDR_MAPPING
, DIMM1ADDRMAP
);
2186 /* Validate settings in case only one DIMM installed. */
2187 if ((dimm00_addr_map
== 0) || (dimm00_addr_map
== 3) || (dimm00_addr_map
== 4) || (dimm00_addr_map
> 12))
2188 dimm00_addr_map
= 0;
2189 if ((dimm01_addr_map
== 0) || (dimm01_addr_map
== 3) || (dimm01_addr_map
== 4) || (dimm01_addr_map
> 12))
2190 dimm01_addr_map
= 0;
2191 if ((dimm10_addr_map
== 0) || (dimm10_addr_map
== 3) || (dimm10_addr_map
== 4) || (dimm10_addr_map
> 12))
2192 dimm10_addr_map
= 0;
2193 if ((dimm11_addr_map
== 0) || (dimm11_addr_map
== 3) || (dimm11_addr_map
== 4) || (dimm11_addr_map
> 12))
2194 dimm11_addr_map
= 0;
2196 /* If DIMM Addr map is 8GB, ROW size should be 2KB. Otherwise 1KB. */
2197 /* If ROW size(DIMM1) != ROW size(DMIMM0), ROW size should be larger one. */
2198 if ((dimm00_addr_map
== 11) || (dimm01_addr_map
== 11) || (dimm10_addr_map
== 11) || (dimm11_addr_map
== 11))
2199 adev
->gfx
.config
.mem_row_size_in_kb
= 2;
2201 adev
->gfx
.config
.mem_row_size_in_kb
= 1;
2203 tmp
= (mc_arb_ramcfg
& MC_ARB_RAMCFG__NOOFCOLS_MASK
) >> MC_ARB_RAMCFG__NOOFCOLS__SHIFT
;
2204 adev
->gfx
.config
.mem_row_size_in_kb
= (4 * (1 << (8 + tmp
))) / 1024;
2205 if (adev
->gfx
.config
.mem_row_size_in_kb
> 4)
2206 adev
->gfx
.config
.mem_row_size_in_kb
= 4;
2208 /* XXX use MC settings? */
2209 adev
->gfx
.config
.shader_engine_tile_size
= 32;
2210 adev
->gfx
.config
.num_gpus
= 1;
2211 adev
->gfx
.config
.multi_gpu_tile_size
= 64;
2213 /* fix up row size */
2214 gb_addr_config
&= ~GB_ADDR_CONFIG__ROW_SIZE_MASK
;
2215 switch (adev
->gfx
.config
.mem_row_size_in_kb
) {
2218 gb_addr_config
|= (0 << GB_ADDR_CONFIG__ROW_SIZE__SHIFT
);
2221 gb_addr_config
|= (1 << GB_ADDR_CONFIG__ROW_SIZE__SHIFT
);
2224 gb_addr_config
|= (2 << GB_ADDR_CONFIG__ROW_SIZE__SHIFT
);
2227 adev
->gfx
.config
.gb_addr_config
= gb_addr_config
;
2229 WREG32(mmGB_ADDR_CONFIG
, gb_addr_config
);
2230 WREG32(mmHDP_ADDR_CONFIG
, gb_addr_config
);
2231 WREG32(mmDMIF_ADDR_CALC
, gb_addr_config
);
2232 WREG32(mmSDMA0_TILING_CONFIG
+ SDMA0_REGISTER_OFFSET
, gb_addr_config
& 0x70);
2233 WREG32(mmSDMA0_TILING_CONFIG
+ SDMA1_REGISTER_OFFSET
, gb_addr_config
& 0x70);
2234 WREG32(mmUVD_UDEC_ADDR_CONFIG
, gb_addr_config
);
2235 WREG32(mmUVD_UDEC_DB_ADDR_CONFIG
, gb_addr_config
);
2236 WREG32(mmUVD_UDEC_DBW_ADDR_CONFIG
, gb_addr_config
);
2238 gfx_v7_0_tiling_mode_table_init(adev
);
2240 gfx_v7_0_setup_rb(adev
, adev
->gfx
.config
.max_shader_engines
,
2241 adev
->gfx
.config
.max_sh_per_se
,
2242 adev
->gfx
.config
.max_backends_per_se
);
2244 /* set HW defaults for 3D engine */
2245 WREG32(mmCP_MEQ_THRESHOLDS
,
2246 (0x30 << CP_MEQ_THRESHOLDS__MEQ1_START__SHIFT
) |
2247 (0x60 << CP_MEQ_THRESHOLDS__MEQ2_START__SHIFT
));
2249 mutex_lock(&adev
->grbm_idx_mutex
);
2251 * making sure that the following register writes will be broadcasted
2252 * to all the shaders
2254 gfx_v7_0_select_se_sh(adev
, 0xffffffff, 0xffffffff);
2256 /* XXX SH_MEM regs */
2257 /* where to put LDS, scratch, GPUVM in FSA64 space */
2258 sh_mem_cfg
= REG_SET_FIELD(0, SH_MEM_CONFIG
, ALIGNMENT_MODE
,
2259 SH_MEM_ALIGNMENT_MODE_UNALIGNED
);
2261 mutex_lock(&adev
->srbm_mutex
);
2262 for (i
= 0; i
< 16; i
++) {
2263 cik_srbm_select(adev
, 0, 0, 0, i
);
2264 /* CP and shaders */
2265 WREG32(mmSH_MEM_CONFIG
, sh_mem_cfg
);
2266 WREG32(mmSH_MEM_APE1_BASE
, 1);
2267 WREG32(mmSH_MEM_APE1_LIMIT
, 0);
2268 WREG32(mmSH_MEM_BASES
, 0);
2270 cik_srbm_select(adev
, 0, 0, 0, 0);
2271 mutex_unlock(&adev
->srbm_mutex
);
2273 gmc_v7_0_init_compute_vmid(adev
);
2275 WREG32(mmSX_DEBUG_1
, 0x20);
2277 WREG32(mmTA_CNTL_AUX
, 0x00010000);
2279 tmp
= RREG32(mmSPI_CONFIG_CNTL
);
2281 WREG32(mmSPI_CONFIG_CNTL
, tmp
);
2283 WREG32(mmSQ_CONFIG
, 1);
2285 WREG32(mmDB_DEBUG
, 0);
2287 tmp
= RREG32(mmDB_DEBUG2
) & ~0xf00fffff;
2289 WREG32(mmDB_DEBUG2
, tmp
);
2291 tmp
= RREG32(mmDB_DEBUG3
) & ~0x0002021c;
2293 WREG32(mmDB_DEBUG3
, tmp
);
2295 tmp
= RREG32(mmCB_HW_CONTROL
) & ~0x00010000;
2297 WREG32(mmCB_HW_CONTROL
, tmp
);
2299 WREG32(mmSPI_CONFIG_CNTL_1
, (4 << SPI_CONFIG_CNTL_1__VTX_DONE_DELAY__SHIFT
));
2301 WREG32(mmPA_SC_FIFO_SIZE
,
2302 ((adev
->gfx
.config
.sc_prim_fifo_size_frontend
<< PA_SC_FIFO_SIZE__SC_FRONTEND_PRIM_FIFO_SIZE__SHIFT
) |
2303 (adev
->gfx
.config
.sc_prim_fifo_size_backend
<< PA_SC_FIFO_SIZE__SC_BACKEND_PRIM_FIFO_SIZE__SHIFT
) |
2304 (adev
->gfx
.config
.sc_hiz_tile_fifo_size
<< PA_SC_FIFO_SIZE__SC_HIZ_TILE_FIFO_SIZE__SHIFT
) |
2305 (adev
->gfx
.config
.sc_earlyz_tile_fifo_size
<< PA_SC_FIFO_SIZE__SC_EARLYZ_TILE_FIFO_SIZE__SHIFT
)));
2307 WREG32(mmVGT_NUM_INSTANCES
, 1);
2309 WREG32(mmCP_PERFMON_CNTL
, 0);
2311 WREG32(mmSQ_CONFIG
, 0);
2313 WREG32(mmPA_SC_FORCE_EOV_MAX_CNTS
,
2314 ((4095 << PA_SC_FORCE_EOV_MAX_CNTS__FORCE_EOV_MAX_CLK_CNT__SHIFT
) |
2315 (255 << PA_SC_FORCE_EOV_MAX_CNTS__FORCE_EOV_MAX_REZ_CNT__SHIFT
)));
2317 WREG32(mmVGT_CACHE_INVALIDATION
,
2318 (VC_AND_TC
<< VGT_CACHE_INVALIDATION__CACHE_INVALIDATION__SHIFT
) |
2319 (ES_AND_GS_AUTO
<< VGT_CACHE_INVALIDATION__AUTO_INVLD_EN__SHIFT
));
2321 WREG32(mmVGT_GS_VERTEX_REUSE
, 16);
2322 WREG32(mmPA_SC_LINE_STIPPLE_STATE
, 0);
2324 WREG32(mmPA_CL_ENHANCE
, PA_CL_ENHANCE__CLIP_VTX_REORDER_ENA_MASK
|
2325 (3 << PA_CL_ENHANCE__NUM_CLIP_SEQ__SHIFT
));
2326 WREG32(mmPA_SC_ENHANCE
, PA_SC_ENHANCE__ENABLE_PA_SC_OUT_OF_ORDER_MASK
);
2327 mutex_unlock(&adev
->grbm_idx_mutex
);
2333 * GPU scratch registers helpers function.
2336 * gfx_v7_0_scratch_init - setup driver info for CP scratch regs
2338 * @adev: amdgpu_device pointer
2340 * Set up the number and offset of the CP scratch registers.
2341 * NOTE: use of CP scratch registers is a legacy inferface and
2342 * is not used by default on newer asics (r6xx+). On newer asics,
2343 * memory buffers are used for fences rather than scratch regs.
2345 static void gfx_v7_0_scratch_init(struct amdgpu_device
*adev
)
2349 adev
->gfx
.scratch
.num_reg
= 7;
2350 adev
->gfx
.scratch
.reg_base
= mmSCRATCH_REG0
;
2351 for (i
= 0; i
< adev
->gfx
.scratch
.num_reg
; i
++) {
2352 adev
->gfx
.scratch
.free
[i
] = true;
2353 adev
->gfx
.scratch
.reg
[i
] = adev
->gfx
.scratch
.reg_base
+ i
;
2358 * gfx_v7_0_ring_test_ring - basic gfx ring test
2360 * @adev: amdgpu_device pointer
2361 * @ring: amdgpu_ring structure holding ring information
2363 * Allocate a scratch register and write to it using the gfx ring (CIK).
2364 * Provides a basic gfx ring test to verify that the ring is working.
2365 * Used by gfx_v7_0_cp_gfx_resume();
2366 * Returns 0 on success, error on failure.
2368 static int gfx_v7_0_ring_test_ring(struct amdgpu_ring
*ring
)
2370 struct amdgpu_device
*adev
= ring
->adev
;
2376 r
= amdgpu_gfx_scratch_get(adev
, &scratch
);
2378 DRM_ERROR("amdgpu: cp failed to get scratch reg (%d).\n", r
);
2381 WREG32(scratch
, 0xCAFEDEAD);
2382 r
= amdgpu_ring_lock(ring
, 3);
2384 DRM_ERROR("amdgpu: cp failed to lock ring %d (%d).\n", ring
->idx
, r
);
2385 amdgpu_gfx_scratch_free(adev
, scratch
);
2388 amdgpu_ring_write(ring
, PACKET3(PACKET3_SET_UCONFIG_REG
, 1));
2389 amdgpu_ring_write(ring
, (scratch
- PACKET3_SET_UCONFIG_REG_START
));
2390 amdgpu_ring_write(ring
, 0xDEADBEEF);
2391 amdgpu_ring_unlock_commit(ring
);
2393 for (i
= 0; i
< adev
->usec_timeout
; i
++) {
2394 tmp
= RREG32(scratch
);
2395 if (tmp
== 0xDEADBEEF)
2399 if (i
< adev
->usec_timeout
) {
2400 DRM_INFO("ring test on %d succeeded in %d usecs\n", ring
->idx
, i
);
2402 DRM_ERROR("amdgpu: ring %d test failed (scratch(0x%04X)=0x%08X)\n",
2403 ring
->idx
, scratch
, tmp
);
2406 amdgpu_gfx_scratch_free(adev
, scratch
);
2411 * gfx_v7_0_ring_emit_hdp - emit an hdp flush on the cp
2413 * @adev: amdgpu_device pointer
2414 * @ridx: amdgpu ring index
2416 * Emits an hdp flush on the cp.
2418 static void gfx_v7_0_ring_emit_hdp_flush(struct amdgpu_ring
*ring
)
2421 int usepfp
= ring
->type
== AMDGPU_RING_TYPE_COMPUTE
? 0 : 1;
2423 if (ring
->type
== AMDGPU_RING_TYPE_COMPUTE
) {
2426 ref_and_mask
= GPU_HDP_FLUSH_DONE__CP2_MASK
<< ring
->pipe
;
2429 ref_and_mask
= GPU_HDP_FLUSH_DONE__CP6_MASK
<< ring
->pipe
;
2435 ref_and_mask
= GPU_HDP_FLUSH_DONE__CP0_MASK
;
2438 amdgpu_ring_write(ring
, PACKET3(PACKET3_WAIT_REG_MEM
, 5));
2439 amdgpu_ring_write(ring
, (WAIT_REG_MEM_OPERATION(1) | /* write, wait, write */
2440 WAIT_REG_MEM_FUNCTION(3) | /* == */
2441 WAIT_REG_MEM_ENGINE(usepfp
))); /* pfp or me */
2442 amdgpu_ring_write(ring
, mmGPU_HDP_FLUSH_REQ
);
2443 amdgpu_ring_write(ring
, mmGPU_HDP_FLUSH_DONE
);
2444 amdgpu_ring_write(ring
, ref_and_mask
);
2445 amdgpu_ring_write(ring
, ref_and_mask
);
2446 amdgpu_ring_write(ring
, 0x20); /* poll interval */
2450 * gfx_v7_0_ring_emit_fence_gfx - emit a fence on the gfx ring
2452 * @adev: amdgpu_device pointer
2453 * @fence: amdgpu fence object
2455 * Emits a fence sequnce number on the gfx ring and flushes
2458 static void gfx_v7_0_ring_emit_fence_gfx(struct amdgpu_ring
*ring
, u64 addr
,
2459 u64 seq
, unsigned flags
)
2461 bool write64bit
= flags
& AMDGPU_FENCE_FLAG_64BIT
;
2462 bool int_sel
= flags
& AMDGPU_FENCE_FLAG_INT
;
2463 /* Workaround for cache flush problems. First send a dummy EOP
2464 * event down the pipe with seq one below.
2466 amdgpu_ring_write(ring
, PACKET3(PACKET3_EVENT_WRITE_EOP
, 4));
2467 amdgpu_ring_write(ring
, (EOP_TCL1_ACTION_EN
|
2469 EVENT_TYPE(CACHE_FLUSH_AND_INV_TS_EVENT
) |
2471 amdgpu_ring_write(ring
, addr
& 0xfffffffc);
2472 amdgpu_ring_write(ring
, (upper_32_bits(addr
) & 0xffff) |
2473 DATA_SEL(1) | INT_SEL(0));
2474 amdgpu_ring_write(ring
, lower_32_bits(seq
- 1));
2475 amdgpu_ring_write(ring
, upper_32_bits(seq
- 1));
2477 /* Then send the real EOP event down the pipe. */
2478 amdgpu_ring_write(ring
, PACKET3(PACKET3_EVENT_WRITE_EOP
, 4));
2479 amdgpu_ring_write(ring
, (EOP_TCL1_ACTION_EN
|
2481 EVENT_TYPE(CACHE_FLUSH_AND_INV_TS_EVENT
) |
2483 amdgpu_ring_write(ring
, addr
& 0xfffffffc);
2484 amdgpu_ring_write(ring
, (upper_32_bits(addr
) & 0xffff) |
2485 DATA_SEL(write64bit
? 2 : 1) | INT_SEL(int_sel
? 2 : 0));
2486 amdgpu_ring_write(ring
, lower_32_bits(seq
));
2487 amdgpu_ring_write(ring
, upper_32_bits(seq
));
2491 * gfx_v7_0_ring_emit_fence_compute - emit a fence on the compute ring
2493 * @adev: amdgpu_device pointer
2494 * @fence: amdgpu fence object
2496 * Emits a fence sequnce number on the compute ring and flushes
2499 static void gfx_v7_0_ring_emit_fence_compute(struct amdgpu_ring
*ring
,
2503 bool write64bit
= flags
& AMDGPU_FENCE_FLAG_64BIT
;
2504 bool int_sel
= flags
& AMDGPU_FENCE_FLAG_INT
;
2506 /* RELEASE_MEM - flush caches, send int */
2507 amdgpu_ring_write(ring
, PACKET3(PACKET3_RELEASE_MEM
, 5));
2508 amdgpu_ring_write(ring
, (EOP_TCL1_ACTION_EN
|
2510 EVENT_TYPE(CACHE_FLUSH_AND_INV_TS_EVENT
) |
2512 amdgpu_ring_write(ring
, DATA_SEL(write64bit
? 2 : 1) | INT_SEL(int_sel
? 2 : 0));
2513 amdgpu_ring_write(ring
, addr
& 0xfffffffc);
2514 amdgpu_ring_write(ring
, upper_32_bits(addr
));
2515 amdgpu_ring_write(ring
, lower_32_bits(seq
));
2516 amdgpu_ring_write(ring
, upper_32_bits(seq
));
2520 * gfx_v7_0_ring_emit_semaphore - emit a semaphore on the CP ring
2522 * @ring: amdgpu ring buffer object
2523 * @semaphore: amdgpu semaphore object
2524 * @emit_wait: Is this a sempahore wait?
2526 * Emits a semaphore signal/wait packet to the CP ring and prevents the PFP
2527 * from running ahead of semaphore waits.
2529 static bool gfx_v7_0_ring_emit_semaphore(struct amdgpu_ring
*ring
,
2530 struct amdgpu_semaphore
*semaphore
,
2533 uint64_t addr
= semaphore
->gpu_addr
;
2534 unsigned sel
= emit_wait
? PACKET3_SEM_SEL_WAIT
: PACKET3_SEM_SEL_SIGNAL
;
2536 amdgpu_ring_write(ring
, PACKET3(PACKET3_MEM_SEMAPHORE
, 1));
2537 amdgpu_ring_write(ring
, addr
& 0xffffffff);
2538 amdgpu_ring_write(ring
, (upper_32_bits(addr
) & 0xffff) | sel
);
2540 if (emit_wait
&& (ring
->type
== AMDGPU_RING_TYPE_GFX
)) {
2541 /* Prevent the PFP from running ahead of the semaphore wait */
2542 amdgpu_ring_write(ring
, PACKET3(PACKET3_PFP_SYNC_ME
, 0));
2543 amdgpu_ring_write(ring
, 0x0);
2553 * gfx_v7_0_ring_emit_ib - emit an IB (Indirect Buffer) on the ring
2555 * @ring: amdgpu_ring structure holding ring information
2556 * @ib: amdgpu indirect buffer object
2558 * Emits an DE (drawing engine) or CE (constant engine) IB
2559 * on the gfx ring. IBs are usually generated by userspace
2560 * acceleration drivers and submitted to the kernel for
2561 * sheduling on the ring. This function schedules the IB
2562 * on the gfx ring for execution by the GPU.
2564 static void gfx_v7_0_ring_emit_ib_gfx(struct amdgpu_ring
*ring
,
2565 struct amdgpu_ib
*ib
)
2567 bool need_ctx_switch
= ring
->current_ctx
!= ib
->ctx
;
2568 u32 header
, control
= 0;
2569 u32 next_rptr
= ring
->wptr
+ 5;
2571 /* drop the CE preamble IB for the same context */
2572 if ((ib
->flags
& AMDGPU_IB_FLAG_PREAMBLE
) && !need_ctx_switch
)
2575 if (need_ctx_switch
)
2579 amdgpu_ring_write(ring
, PACKET3(PACKET3_WRITE_DATA
, 3));
2580 amdgpu_ring_write(ring
, WRITE_DATA_DST_SEL(5) | WR_CONFIRM
);
2581 amdgpu_ring_write(ring
, ring
->next_rptr_gpu_addr
& 0xfffffffc);
2582 amdgpu_ring_write(ring
, upper_32_bits(ring
->next_rptr_gpu_addr
) & 0xffffffff);
2583 amdgpu_ring_write(ring
, next_rptr
);
2585 /* insert SWITCH_BUFFER packet before first IB in the ring frame */
2586 if (need_ctx_switch
) {
2587 amdgpu_ring_write(ring
, PACKET3(PACKET3_SWITCH_BUFFER
, 0));
2588 amdgpu_ring_write(ring
, 0);
2591 if (ib
->flags
& AMDGPU_IB_FLAG_CE
)
2592 header
= PACKET3(PACKET3_INDIRECT_BUFFER_CONST
, 2);
2594 header
= PACKET3(PACKET3_INDIRECT_BUFFER
, 2);
2596 control
|= ib
->length_dw
|
2597 (ib
->vm
? (ib
->vm
->ids
[ring
->idx
].id
<< 24) : 0);
2599 amdgpu_ring_write(ring
, header
);
2600 amdgpu_ring_write(ring
,
2604 (ib
->gpu_addr
& 0xFFFFFFFC));
2605 amdgpu_ring_write(ring
, upper_32_bits(ib
->gpu_addr
) & 0xFFFF);
2606 amdgpu_ring_write(ring
, control
);
2609 static void gfx_v7_0_ring_emit_ib_compute(struct amdgpu_ring
*ring
,
2610 struct amdgpu_ib
*ib
)
2612 u32 header
, control
= 0;
2613 u32 next_rptr
= ring
->wptr
+ 5;
2615 control
|= INDIRECT_BUFFER_VALID
;
2617 amdgpu_ring_write(ring
, PACKET3(PACKET3_WRITE_DATA
, 3));
2618 amdgpu_ring_write(ring
, WRITE_DATA_DST_SEL(5) | WR_CONFIRM
);
2619 amdgpu_ring_write(ring
, ring
->next_rptr_gpu_addr
& 0xfffffffc);
2620 amdgpu_ring_write(ring
, upper_32_bits(ring
->next_rptr_gpu_addr
) & 0xffffffff);
2621 amdgpu_ring_write(ring
, next_rptr
);
2623 header
= PACKET3(PACKET3_INDIRECT_BUFFER
, 2);
2625 control
|= ib
->length_dw
|
2626 (ib
->vm
? (ib
->vm
->ids
[ring
->idx
].id
<< 24) : 0);
2628 amdgpu_ring_write(ring
, header
);
2629 amdgpu_ring_write(ring
,
2633 (ib
->gpu_addr
& 0xFFFFFFFC));
2634 amdgpu_ring_write(ring
, upper_32_bits(ib
->gpu_addr
) & 0xFFFF);
2635 amdgpu_ring_write(ring
, control
);
2639 * gfx_v7_0_ring_test_ib - basic ring IB test
2641 * @ring: amdgpu_ring structure holding ring information
2643 * Allocate an IB and execute it on the gfx ring (CIK).
2644 * Provides a basic gfx ring test to verify that IBs are working.
2645 * Returns 0 on success, error on failure.
2647 static int gfx_v7_0_ring_test_ib(struct amdgpu_ring
*ring
)
2649 struct amdgpu_device
*adev
= ring
->adev
;
2650 struct amdgpu_ib ib
;
2651 struct fence
*f
= NULL
;
2657 r
= amdgpu_gfx_scratch_get(adev
, &scratch
);
2659 DRM_ERROR("amdgpu: failed to get scratch reg (%d).\n", r
);
2662 WREG32(scratch
, 0xCAFEDEAD);
2663 memset(&ib
, 0, sizeof(ib
));
2664 r
= amdgpu_ib_get(ring
, NULL
, 256, &ib
);
2666 DRM_ERROR("amdgpu: failed to get ib (%d).\n", r
);
2669 ib
.ptr
[0] = PACKET3(PACKET3_SET_UCONFIG_REG
, 1);
2670 ib
.ptr
[1] = ((scratch
- PACKET3_SET_UCONFIG_REG_START
));
2671 ib
.ptr
[2] = 0xDEADBEEF;
2674 r
= amdgpu_sched_ib_submit_kernel_helper(adev
, ring
, &ib
, 1, NULL
,
2675 AMDGPU_FENCE_OWNER_UNDEFINED
,
2680 r
= fence_wait(f
, false);
2682 DRM_ERROR("amdgpu: fence wait failed (%d).\n", r
);
2685 for (i
= 0; i
< adev
->usec_timeout
; i
++) {
2686 tmp
= RREG32(scratch
);
2687 if (tmp
== 0xDEADBEEF)
2691 if (i
< adev
->usec_timeout
) {
2692 DRM_INFO("ib test on ring %d succeeded in %u usecs\n",
2696 DRM_ERROR("amdgpu: ib test failed (scratch(0x%04X)=0x%08X)\n",
2703 amdgpu_ib_free(adev
, &ib
);
2705 amdgpu_gfx_scratch_free(adev
, scratch
);
2711 * On CIK, gfx and compute now have independant command processors.
2714 * Gfx consists of a single ring and can process both gfx jobs and
2715 * compute jobs. The gfx CP consists of three microengines (ME):
2716 * PFP - Pre-Fetch Parser
2718 * CE - Constant Engine
2719 * The PFP and ME make up what is considered the Drawing Engine (DE).
2720 * The CE is an asynchronous engine used for updating buffer desciptors
2721 * used by the DE so that they can be loaded into cache in parallel
2722 * while the DE is processing state update packets.
2725 * The compute CP consists of two microengines (ME):
2726 * MEC1 - Compute MicroEngine 1
2727 * MEC2 - Compute MicroEngine 2
2728 * Each MEC supports 4 compute pipes and each pipe supports 8 queues.
2729 * The queues are exposed to userspace and are programmed directly
2730 * by the compute runtime.
2733 * gfx_v7_0_cp_gfx_enable - enable/disable the gfx CP MEs
2735 * @adev: amdgpu_device pointer
2736 * @enable: enable or disable the MEs
2738 * Halts or unhalts the gfx MEs.
2740 static void gfx_v7_0_cp_gfx_enable(struct amdgpu_device
*adev
, bool enable
)
2745 WREG32(mmCP_ME_CNTL
, 0);
2747 WREG32(mmCP_ME_CNTL
, (CP_ME_CNTL__ME_HALT_MASK
| CP_ME_CNTL__PFP_HALT_MASK
| CP_ME_CNTL__CE_HALT_MASK
));
2748 for (i
= 0; i
< adev
->gfx
.num_gfx_rings
; i
++)
2749 adev
->gfx
.gfx_ring
[i
].ready
= false;
2755 * gfx_v7_0_cp_gfx_load_microcode - load the gfx CP ME ucode
2757 * @adev: amdgpu_device pointer
2759 * Loads the gfx PFP, ME, and CE ucode.
2760 * Returns 0 for success, -EINVAL if the ucode is not available.
2762 static int gfx_v7_0_cp_gfx_load_microcode(struct amdgpu_device
*adev
)
2764 const struct gfx_firmware_header_v1_0
*pfp_hdr
;
2765 const struct gfx_firmware_header_v1_0
*ce_hdr
;
2766 const struct gfx_firmware_header_v1_0
*me_hdr
;
2767 const __le32
*fw_data
;
2768 unsigned i
, fw_size
;
2770 if (!adev
->gfx
.me_fw
|| !adev
->gfx
.pfp_fw
|| !adev
->gfx
.ce_fw
)
2773 pfp_hdr
= (const struct gfx_firmware_header_v1_0
*)adev
->gfx
.pfp_fw
->data
;
2774 ce_hdr
= (const struct gfx_firmware_header_v1_0
*)adev
->gfx
.ce_fw
->data
;
2775 me_hdr
= (const struct gfx_firmware_header_v1_0
*)adev
->gfx
.me_fw
->data
;
2777 amdgpu_ucode_print_gfx_hdr(&pfp_hdr
->header
);
2778 amdgpu_ucode_print_gfx_hdr(&ce_hdr
->header
);
2779 amdgpu_ucode_print_gfx_hdr(&me_hdr
->header
);
2780 adev
->gfx
.pfp_fw_version
= le32_to_cpu(pfp_hdr
->header
.ucode_version
);
2781 adev
->gfx
.ce_fw_version
= le32_to_cpu(ce_hdr
->header
.ucode_version
);
2782 adev
->gfx
.me_fw_version
= le32_to_cpu(me_hdr
->header
.ucode_version
);
2783 adev
->gfx
.me_feature_version
= le32_to_cpu(me_hdr
->ucode_feature_version
);
2784 adev
->gfx
.ce_feature_version
= le32_to_cpu(ce_hdr
->ucode_feature_version
);
2785 adev
->gfx
.pfp_feature_version
= le32_to_cpu(pfp_hdr
->ucode_feature_version
);
2787 gfx_v7_0_cp_gfx_enable(adev
, false);
2790 fw_data
= (const __le32
*)
2791 (adev
->gfx
.pfp_fw
->data
+
2792 le32_to_cpu(pfp_hdr
->header
.ucode_array_offset_bytes
));
2793 fw_size
= le32_to_cpu(pfp_hdr
->header
.ucode_size_bytes
) / 4;
2794 WREG32(mmCP_PFP_UCODE_ADDR
, 0);
2795 for (i
= 0; i
< fw_size
; i
++)
2796 WREG32(mmCP_PFP_UCODE_DATA
, le32_to_cpup(fw_data
++));
2797 WREG32(mmCP_PFP_UCODE_ADDR
, adev
->gfx
.pfp_fw_version
);
2800 fw_data
= (const __le32
*)
2801 (adev
->gfx
.ce_fw
->data
+
2802 le32_to_cpu(ce_hdr
->header
.ucode_array_offset_bytes
));
2803 fw_size
= le32_to_cpu(ce_hdr
->header
.ucode_size_bytes
) / 4;
2804 WREG32(mmCP_CE_UCODE_ADDR
, 0);
2805 for (i
= 0; i
< fw_size
; i
++)
2806 WREG32(mmCP_CE_UCODE_DATA
, le32_to_cpup(fw_data
++));
2807 WREG32(mmCP_CE_UCODE_ADDR
, adev
->gfx
.ce_fw_version
);
2810 fw_data
= (const __le32
*)
2811 (adev
->gfx
.me_fw
->data
+
2812 le32_to_cpu(me_hdr
->header
.ucode_array_offset_bytes
));
2813 fw_size
= le32_to_cpu(me_hdr
->header
.ucode_size_bytes
) / 4;
2814 WREG32(mmCP_ME_RAM_WADDR
, 0);
2815 for (i
= 0; i
< fw_size
; i
++)
2816 WREG32(mmCP_ME_RAM_DATA
, le32_to_cpup(fw_data
++));
2817 WREG32(mmCP_ME_RAM_WADDR
, adev
->gfx
.me_fw_version
);
2823 * gfx_v7_0_cp_gfx_start - start the gfx ring
2825 * @adev: amdgpu_device pointer
2827 * Enables the ring and loads the clear state context and other
2828 * packets required to init the ring.
2829 * Returns 0 for success, error for failure.
2831 static int gfx_v7_0_cp_gfx_start(struct amdgpu_device
*adev
)
2833 struct amdgpu_ring
*ring
= &adev
->gfx
.gfx_ring
[0];
2834 const struct cs_section_def
*sect
= NULL
;
2835 const struct cs_extent_def
*ext
= NULL
;
2839 WREG32(mmCP_MAX_CONTEXT
, adev
->gfx
.config
.max_hw_contexts
- 1);
2840 WREG32(mmCP_ENDIAN_SWAP
, 0);
2841 WREG32(mmCP_DEVICE_ID
, 1);
2843 gfx_v7_0_cp_gfx_enable(adev
, true);
2845 r
= amdgpu_ring_lock(ring
, gfx_v7_0_get_csb_size(adev
) + 8);
2847 DRM_ERROR("amdgpu: cp failed to lock ring (%d).\n", r
);
2851 /* init the CE partitions. CE only used for gfx on CIK */
2852 amdgpu_ring_write(ring
, PACKET3(PACKET3_SET_BASE
, 2));
2853 amdgpu_ring_write(ring
, PACKET3_BASE_INDEX(CE_PARTITION_BASE
));
2854 amdgpu_ring_write(ring
, 0x8000);
2855 amdgpu_ring_write(ring
, 0x8000);
2857 /* clear state buffer */
2858 amdgpu_ring_write(ring
, PACKET3(PACKET3_PREAMBLE_CNTL
, 0));
2859 amdgpu_ring_write(ring
, PACKET3_PREAMBLE_BEGIN_CLEAR_STATE
);
2861 amdgpu_ring_write(ring
, PACKET3(PACKET3_CONTEXT_CONTROL
, 1));
2862 amdgpu_ring_write(ring
, 0x80000000);
2863 amdgpu_ring_write(ring
, 0x80000000);
2865 for (sect
= adev
->gfx
.rlc
.cs_data
; sect
->section
!= NULL
; ++sect
) {
2866 for (ext
= sect
->section
; ext
->extent
!= NULL
; ++ext
) {
2867 if (sect
->id
== SECT_CONTEXT
) {
2868 amdgpu_ring_write(ring
,
2869 PACKET3(PACKET3_SET_CONTEXT_REG
, ext
->reg_count
));
2870 amdgpu_ring_write(ring
, ext
->reg_index
- PACKET3_SET_CONTEXT_REG_START
);
2871 for (i
= 0; i
< ext
->reg_count
; i
++)
2872 amdgpu_ring_write(ring
, ext
->extent
[i
]);
2877 amdgpu_ring_write(ring
, PACKET3(PACKET3_SET_CONTEXT_REG
, 2));
2878 amdgpu_ring_write(ring
, mmPA_SC_RASTER_CONFIG
- PACKET3_SET_CONTEXT_REG_START
);
2879 switch (adev
->asic_type
) {
2881 amdgpu_ring_write(ring
, 0x16000012);
2882 amdgpu_ring_write(ring
, 0x00000000);
2885 amdgpu_ring_write(ring
, 0x00000000); /* XXX */
2886 amdgpu_ring_write(ring
, 0x00000000);
2890 amdgpu_ring_write(ring
, 0x00000000); /* XXX */
2891 amdgpu_ring_write(ring
, 0x00000000);
2894 amdgpu_ring_write(ring
, 0x3a00161a);
2895 amdgpu_ring_write(ring
, 0x0000002e);
2898 amdgpu_ring_write(ring
, 0x00000000);
2899 amdgpu_ring_write(ring
, 0x00000000);
2903 amdgpu_ring_write(ring
, PACKET3(PACKET3_PREAMBLE_CNTL
, 0));
2904 amdgpu_ring_write(ring
, PACKET3_PREAMBLE_END_CLEAR_STATE
);
2906 amdgpu_ring_write(ring
, PACKET3(PACKET3_CLEAR_STATE
, 0));
2907 amdgpu_ring_write(ring
, 0);
2909 amdgpu_ring_write(ring
, PACKET3(PACKET3_SET_CONTEXT_REG
, 2));
2910 amdgpu_ring_write(ring
, 0x00000316);
2911 amdgpu_ring_write(ring
, 0x0000000e); /* VGT_VERTEX_REUSE_BLOCK_CNTL */
2912 amdgpu_ring_write(ring
, 0x00000010); /* VGT_OUT_DEALLOC_CNTL */
2914 amdgpu_ring_unlock_commit(ring
);
2920 * gfx_v7_0_cp_gfx_resume - setup the gfx ring buffer registers
2922 * @adev: amdgpu_device pointer
2924 * Program the location and size of the gfx ring buffer
2925 * and test it to make sure it's working.
2926 * Returns 0 for success, error for failure.
2928 static int gfx_v7_0_cp_gfx_resume(struct amdgpu_device
*adev
)
2930 struct amdgpu_ring
*ring
;
2933 u64 rb_addr
, rptr_addr
;
2936 WREG32(mmCP_SEM_WAIT_TIMER
, 0x0);
2937 if (adev
->asic_type
!= CHIP_HAWAII
)
2938 WREG32(mmCP_SEM_INCOMPLETE_TIMER_CNTL
, 0x0);
2940 /* Set the write pointer delay */
2941 WREG32(mmCP_RB_WPTR_DELAY
, 0);
2943 /* set the RB to use vmid 0 */
2944 WREG32(mmCP_RB_VMID
, 0);
2946 WREG32(mmSCRATCH_ADDR
, 0);
2948 /* ring 0 - compute and gfx */
2949 /* Set ring buffer size */
2950 ring
= &adev
->gfx
.gfx_ring
[0];
2951 rb_bufsz
= order_base_2(ring
->ring_size
/ 8);
2952 tmp
= (order_base_2(AMDGPU_GPU_PAGE_SIZE
/8) << 8) | rb_bufsz
;
2954 tmp
|= 2 << CP_RB0_CNTL__BUF_SWAP__SHIFT
;
2956 WREG32(mmCP_RB0_CNTL
, tmp
);
2958 /* Initialize the ring buffer's read and write pointers */
2959 WREG32(mmCP_RB0_CNTL
, tmp
| CP_RB0_CNTL__RB_RPTR_WR_ENA_MASK
);
2961 WREG32(mmCP_RB0_WPTR
, ring
->wptr
);
2963 /* set the wb address wether it's enabled or not */
2964 rptr_addr
= adev
->wb
.gpu_addr
+ (ring
->rptr_offs
* 4);
2965 WREG32(mmCP_RB0_RPTR_ADDR
, lower_32_bits(rptr_addr
));
2966 WREG32(mmCP_RB0_RPTR_ADDR_HI
, upper_32_bits(rptr_addr
) & 0xFF);
2968 /* scratch register shadowing is no longer supported */
2969 WREG32(mmSCRATCH_UMSK
, 0);
2972 WREG32(mmCP_RB0_CNTL
, tmp
);
2974 rb_addr
= ring
->gpu_addr
>> 8;
2975 WREG32(mmCP_RB0_BASE
, rb_addr
);
2976 WREG32(mmCP_RB0_BASE_HI
, upper_32_bits(rb_addr
));
2978 /* start the ring */
2979 gfx_v7_0_cp_gfx_start(adev
);
2981 r
= amdgpu_ring_test_ring(ring
);
2983 ring
->ready
= false;
2990 static u32
gfx_v7_0_ring_get_rptr_gfx(struct amdgpu_ring
*ring
)
2994 rptr
= ring
->adev
->wb
.wb
[ring
->rptr_offs
];
2999 static u32
gfx_v7_0_ring_get_wptr_gfx(struct amdgpu_ring
*ring
)
3001 struct amdgpu_device
*adev
= ring
->adev
;
3004 wptr
= RREG32(mmCP_RB0_WPTR
);
3009 static void gfx_v7_0_ring_set_wptr_gfx(struct amdgpu_ring
*ring
)
3011 struct amdgpu_device
*adev
= ring
->adev
;
3013 WREG32(mmCP_RB0_WPTR
, ring
->wptr
);
3014 (void)RREG32(mmCP_RB0_WPTR
);
3017 static u32
gfx_v7_0_ring_get_rptr_compute(struct amdgpu_ring
*ring
)
3021 rptr
= ring
->adev
->wb
.wb
[ring
->rptr_offs
];
3026 static u32
gfx_v7_0_ring_get_wptr_compute(struct amdgpu_ring
*ring
)
3030 /* XXX check if swapping is necessary on BE */
3031 wptr
= ring
->adev
->wb
.wb
[ring
->wptr_offs
];
3036 static void gfx_v7_0_ring_set_wptr_compute(struct amdgpu_ring
*ring
)
3038 struct amdgpu_device
*adev
= ring
->adev
;
3040 /* XXX check if swapping is necessary on BE */
3041 adev
->wb
.wb
[ring
->wptr_offs
] = ring
->wptr
;
3042 WDOORBELL32(ring
->doorbell_index
, ring
->wptr
);
3046 * gfx_v7_0_cp_compute_enable - enable/disable the compute CP MEs
3048 * @adev: amdgpu_device pointer
3049 * @enable: enable or disable the MEs
3051 * Halts or unhalts the compute MEs.
3053 static void gfx_v7_0_cp_compute_enable(struct amdgpu_device
*adev
, bool enable
)
3058 WREG32(mmCP_MEC_CNTL
, 0);
3060 WREG32(mmCP_MEC_CNTL
, (CP_MEC_CNTL__MEC_ME1_HALT_MASK
| CP_MEC_CNTL__MEC_ME2_HALT_MASK
));
3061 for (i
= 0; i
< adev
->gfx
.num_compute_rings
; i
++)
3062 adev
->gfx
.compute_ring
[i
].ready
= false;
3068 * gfx_v7_0_cp_compute_load_microcode - load the compute CP ME ucode
3070 * @adev: amdgpu_device pointer
3072 * Loads the compute MEC1&2 ucode.
3073 * Returns 0 for success, -EINVAL if the ucode is not available.
3075 static int gfx_v7_0_cp_compute_load_microcode(struct amdgpu_device
*adev
)
3077 const struct gfx_firmware_header_v1_0
*mec_hdr
;
3078 const __le32
*fw_data
;
3079 unsigned i
, fw_size
;
3081 if (!adev
->gfx
.mec_fw
)
3084 mec_hdr
= (const struct gfx_firmware_header_v1_0
*)adev
->gfx
.mec_fw
->data
;
3085 amdgpu_ucode_print_gfx_hdr(&mec_hdr
->header
);
3086 adev
->gfx
.mec_fw_version
= le32_to_cpu(mec_hdr
->header
.ucode_version
);
3087 adev
->gfx
.mec_feature_version
= le32_to_cpu(
3088 mec_hdr
->ucode_feature_version
);
3090 gfx_v7_0_cp_compute_enable(adev
, false);
3093 fw_data
= (const __le32
*)
3094 (adev
->gfx
.mec_fw
->data
+
3095 le32_to_cpu(mec_hdr
->header
.ucode_array_offset_bytes
));
3096 fw_size
= le32_to_cpu(mec_hdr
->header
.ucode_size_bytes
) / 4;
3097 WREG32(mmCP_MEC_ME1_UCODE_ADDR
, 0);
3098 for (i
= 0; i
< fw_size
; i
++)
3099 WREG32(mmCP_MEC_ME1_UCODE_DATA
, le32_to_cpup(fw_data
++));
3100 WREG32(mmCP_MEC_ME1_UCODE_ADDR
, 0);
3102 if (adev
->asic_type
== CHIP_KAVERI
) {
3103 const struct gfx_firmware_header_v1_0
*mec2_hdr
;
3105 if (!adev
->gfx
.mec2_fw
)
3108 mec2_hdr
= (const struct gfx_firmware_header_v1_0
*)adev
->gfx
.mec2_fw
->data
;
3109 amdgpu_ucode_print_gfx_hdr(&mec2_hdr
->header
);
3110 adev
->gfx
.mec2_fw_version
= le32_to_cpu(mec2_hdr
->header
.ucode_version
);
3111 adev
->gfx
.mec2_feature_version
= le32_to_cpu(
3112 mec2_hdr
->ucode_feature_version
);
3115 fw_data
= (const __le32
*)
3116 (adev
->gfx
.mec2_fw
->data
+
3117 le32_to_cpu(mec2_hdr
->header
.ucode_array_offset_bytes
));
3118 fw_size
= le32_to_cpu(mec2_hdr
->header
.ucode_size_bytes
) / 4;
3119 WREG32(mmCP_MEC_ME2_UCODE_ADDR
, 0);
3120 for (i
= 0; i
< fw_size
; i
++)
3121 WREG32(mmCP_MEC_ME2_UCODE_DATA
, le32_to_cpup(fw_data
++));
3122 WREG32(mmCP_MEC_ME2_UCODE_ADDR
, 0);
3129 * gfx_v7_0_cp_compute_start - start the compute queues
3131 * @adev: amdgpu_device pointer
3133 * Enable the compute queues.
3134 * Returns 0 for success, error for failure.
3136 static int gfx_v7_0_cp_compute_start(struct amdgpu_device
*adev
)
3138 gfx_v7_0_cp_compute_enable(adev
, true);
3144 * gfx_v7_0_cp_compute_fini - stop the compute queues
3146 * @adev: amdgpu_device pointer
3148 * Stop the compute queues and tear down the driver queue
3151 static void gfx_v7_0_cp_compute_fini(struct amdgpu_device
*adev
)
3155 for (i
= 0; i
< adev
->gfx
.num_compute_rings
; i
++) {
3156 struct amdgpu_ring
*ring
= &adev
->gfx
.compute_ring
[i
];
3158 if (ring
->mqd_obj
) {
3159 r
= amdgpu_bo_reserve(ring
->mqd_obj
, false);
3160 if (unlikely(r
!= 0))
3161 dev_warn(adev
->dev
, "(%d) reserve MQD bo failed\n", r
);
3163 amdgpu_bo_unpin(ring
->mqd_obj
);
3164 amdgpu_bo_unreserve(ring
->mqd_obj
);
3166 amdgpu_bo_unref(&ring
->mqd_obj
);
3167 ring
->mqd_obj
= NULL
;
3172 static void gfx_v7_0_mec_fini(struct amdgpu_device
*adev
)
3176 if (adev
->gfx
.mec
.hpd_eop_obj
) {
3177 r
= amdgpu_bo_reserve(adev
->gfx
.mec
.hpd_eop_obj
, false);
3178 if (unlikely(r
!= 0))
3179 dev_warn(adev
->dev
, "(%d) reserve HPD EOP bo failed\n", r
);
3180 amdgpu_bo_unpin(adev
->gfx
.mec
.hpd_eop_obj
);
3181 amdgpu_bo_unreserve(adev
->gfx
.mec
.hpd_eop_obj
);
3183 amdgpu_bo_unref(&adev
->gfx
.mec
.hpd_eop_obj
);
3184 adev
->gfx
.mec
.hpd_eop_obj
= NULL
;
3188 #define MEC_HPD_SIZE 2048
3190 static int gfx_v7_0_mec_init(struct amdgpu_device
*adev
)
3196 * KV: 2 MEC, 4 Pipes/MEC, 8 Queues/Pipe - 64 Queues total
3197 * CI/KB: 1 MEC, 4 Pipes/MEC, 8 Queues/Pipe - 32 Queues total
3198 * Nonetheless, we assign only 1 pipe because all other pipes will
3201 adev
->gfx
.mec
.num_mec
= 1;
3202 adev
->gfx
.mec
.num_pipe
= 1;
3203 adev
->gfx
.mec
.num_queue
= adev
->gfx
.mec
.num_mec
* adev
->gfx
.mec
.num_pipe
* 8;
3205 if (adev
->gfx
.mec
.hpd_eop_obj
== NULL
) {
3206 r
= amdgpu_bo_create(adev
,
3207 adev
->gfx
.mec
.num_mec
*adev
->gfx
.mec
.num_pipe
* MEC_HPD_SIZE
* 2,
3209 AMDGPU_GEM_DOMAIN_GTT
, 0, NULL
, NULL
,
3210 &adev
->gfx
.mec
.hpd_eop_obj
);
3212 dev_warn(adev
->dev
, "(%d) create HDP EOP bo failed\n", r
);
3217 r
= amdgpu_bo_reserve(adev
->gfx
.mec
.hpd_eop_obj
, false);
3218 if (unlikely(r
!= 0)) {
3219 gfx_v7_0_mec_fini(adev
);
3222 r
= amdgpu_bo_pin(adev
->gfx
.mec
.hpd_eop_obj
, AMDGPU_GEM_DOMAIN_GTT
,
3223 &adev
->gfx
.mec
.hpd_eop_gpu_addr
);
3225 dev_warn(adev
->dev
, "(%d) pin HDP EOP bo failed\n", r
);
3226 gfx_v7_0_mec_fini(adev
);
3229 r
= amdgpu_bo_kmap(adev
->gfx
.mec
.hpd_eop_obj
, (void **)&hpd
);
3231 dev_warn(adev
->dev
, "(%d) map HDP EOP bo failed\n", r
);
3232 gfx_v7_0_mec_fini(adev
);
3236 /* clear memory. Not sure if this is required or not */
3237 memset(hpd
, 0, adev
->gfx
.mec
.num_mec
*adev
->gfx
.mec
.num_pipe
* MEC_HPD_SIZE
* 2);
3239 amdgpu_bo_kunmap(adev
->gfx
.mec
.hpd_eop_obj
);
3240 amdgpu_bo_unreserve(adev
->gfx
.mec
.hpd_eop_obj
);
3245 struct hqd_registers
3247 u32 cp_mqd_base_addr
;
3248 u32 cp_mqd_base_addr_hi
;
3251 u32 cp_hqd_persistent_state
;
3252 u32 cp_hqd_pipe_priority
;
3253 u32 cp_hqd_queue_priority
;
3256 u32 cp_hqd_pq_base_hi
;
3258 u32 cp_hqd_pq_rptr_report_addr
;
3259 u32 cp_hqd_pq_rptr_report_addr_hi
;
3260 u32 cp_hqd_pq_wptr_poll_addr
;
3261 u32 cp_hqd_pq_wptr_poll_addr_hi
;
3262 u32 cp_hqd_pq_doorbell_control
;
3264 u32 cp_hqd_pq_control
;
3265 u32 cp_hqd_ib_base_addr
;
3266 u32 cp_hqd_ib_base_addr_hi
;
3268 u32 cp_hqd_ib_control
;
3269 u32 cp_hqd_iq_timer
;
3271 u32 cp_hqd_dequeue_request
;
3272 u32 cp_hqd_dma_offload
;
3273 u32 cp_hqd_sema_cmd
;
3274 u32 cp_hqd_msg_type
;
3275 u32 cp_hqd_atomic0_preop_lo
;
3276 u32 cp_hqd_atomic0_preop_hi
;
3277 u32 cp_hqd_atomic1_preop_lo
;
3278 u32 cp_hqd_atomic1_preop_hi
;
3279 u32 cp_hqd_hq_scheduler0
;
3280 u32 cp_hqd_hq_scheduler1
;
3287 u32 dispatch_initiator
;
3291 u32 pipeline_stat_enable
;
3292 u32 perf_counter_enable
;
3298 u32 resource_limits
;
3299 u32 static_thread_mgmt01
[2];
3301 u32 static_thread_mgmt23
[2];
3303 u32 thread_trace_enable
;
3306 u32 vgtcs_invoke_count
[2];
3307 struct hqd_registers queue_state
;
3309 u32 interrupt_queue
[64];
3313 * gfx_v7_0_cp_compute_resume - setup the compute queue registers
3315 * @adev: amdgpu_device pointer
3317 * Program the compute queues and test them to make sure they
3319 * Returns 0 for success, error for failure.
3321 static int gfx_v7_0_cp_compute_resume(struct amdgpu_device
*adev
)
3325 bool use_doorbell
= true;
3331 struct bonaire_mqd
*mqd
;
3333 r
= gfx_v7_0_cp_compute_start(adev
);
3337 /* fix up chicken bits */
3338 tmp
= RREG32(mmCP_CPF_DEBUG
);
3340 WREG32(mmCP_CPF_DEBUG
, tmp
);
3342 /* init the pipes */
3343 mutex_lock(&adev
->srbm_mutex
);
3344 for (i
= 0; i
< (adev
->gfx
.mec
.num_pipe
* adev
->gfx
.mec
.num_mec
); i
++) {
3345 int me
= (i
< 4) ? 1 : 2;
3346 int pipe
= (i
< 4) ? i
: (i
- 4);
3348 eop_gpu_addr
= adev
->gfx
.mec
.hpd_eop_gpu_addr
+ (i
* MEC_HPD_SIZE
* 2);
3350 cik_srbm_select(adev
, me
, pipe
, 0, 0);
3352 /* write the EOP addr */
3353 WREG32(mmCP_HPD_EOP_BASE_ADDR
, eop_gpu_addr
>> 8);
3354 WREG32(mmCP_HPD_EOP_BASE_ADDR_HI
, upper_32_bits(eop_gpu_addr
) >> 8);
3356 /* set the VMID assigned */
3357 WREG32(mmCP_HPD_EOP_VMID
, 0);
3359 /* set the EOP size, register value is 2^(EOP_SIZE+1) dwords */
3360 tmp
= RREG32(mmCP_HPD_EOP_CONTROL
);
3361 tmp
&= ~CP_HPD_EOP_CONTROL__EOP_SIZE_MASK
;
3362 tmp
|= order_base_2(MEC_HPD_SIZE
/ 8);
3363 WREG32(mmCP_HPD_EOP_CONTROL
, tmp
);
3365 cik_srbm_select(adev
, 0, 0, 0, 0);
3366 mutex_unlock(&adev
->srbm_mutex
);
3368 /* init the queues. Just two for now. */
3369 for (i
= 0; i
< adev
->gfx
.num_compute_rings
; i
++) {
3370 struct amdgpu_ring
*ring
= &adev
->gfx
.compute_ring
[i
];
3372 if (ring
->mqd_obj
== NULL
) {
3373 r
= amdgpu_bo_create(adev
,
3374 sizeof(struct bonaire_mqd
),
3376 AMDGPU_GEM_DOMAIN_GTT
, 0, NULL
, NULL
,
3379 dev_warn(adev
->dev
, "(%d) create MQD bo failed\n", r
);
3384 r
= amdgpu_bo_reserve(ring
->mqd_obj
, false);
3385 if (unlikely(r
!= 0)) {
3386 gfx_v7_0_cp_compute_fini(adev
);
3389 r
= amdgpu_bo_pin(ring
->mqd_obj
, AMDGPU_GEM_DOMAIN_GTT
,
3392 dev_warn(adev
->dev
, "(%d) pin MQD bo failed\n", r
);
3393 gfx_v7_0_cp_compute_fini(adev
);
3396 r
= amdgpu_bo_kmap(ring
->mqd_obj
, (void **)&buf
);
3398 dev_warn(adev
->dev
, "(%d) map MQD bo failed\n", r
);
3399 gfx_v7_0_cp_compute_fini(adev
);
3403 /* init the mqd struct */
3404 memset(buf
, 0, sizeof(struct bonaire_mqd
));
3406 mqd
= (struct bonaire_mqd
*)buf
;
3407 mqd
->header
= 0xC0310800;
3408 mqd
->static_thread_mgmt01
[0] = 0xffffffff;
3409 mqd
->static_thread_mgmt01
[1] = 0xffffffff;
3410 mqd
->static_thread_mgmt23
[0] = 0xffffffff;
3411 mqd
->static_thread_mgmt23
[1] = 0xffffffff;
3413 mutex_lock(&adev
->srbm_mutex
);
3414 cik_srbm_select(adev
, ring
->me
,
3418 /* disable wptr polling */
3419 tmp
= RREG32(mmCP_PQ_WPTR_POLL_CNTL
);
3420 tmp
&= ~CP_PQ_WPTR_POLL_CNTL__EN_MASK
;
3421 WREG32(mmCP_PQ_WPTR_POLL_CNTL
, tmp
);
3423 /* enable doorbell? */
3424 mqd
->queue_state
.cp_hqd_pq_doorbell_control
=
3425 RREG32(mmCP_HQD_PQ_DOORBELL_CONTROL
);
3427 mqd
->queue_state
.cp_hqd_pq_doorbell_control
|= CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_EN_MASK
;
3429 mqd
->queue_state
.cp_hqd_pq_doorbell_control
&= ~CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_EN_MASK
;
3430 WREG32(mmCP_HQD_PQ_DOORBELL_CONTROL
,
3431 mqd
->queue_state
.cp_hqd_pq_doorbell_control
);
3433 /* disable the queue if it's active */
3434 mqd
->queue_state
.cp_hqd_dequeue_request
= 0;
3435 mqd
->queue_state
.cp_hqd_pq_rptr
= 0;
3436 mqd
->queue_state
.cp_hqd_pq_wptr
= 0;
3437 if (RREG32(mmCP_HQD_ACTIVE
) & 1) {
3438 WREG32(mmCP_HQD_DEQUEUE_REQUEST
, 1);
3439 for (j
= 0; j
< adev
->usec_timeout
; j
++) {
3440 if (!(RREG32(mmCP_HQD_ACTIVE
) & 1))
3444 WREG32(mmCP_HQD_DEQUEUE_REQUEST
, mqd
->queue_state
.cp_hqd_dequeue_request
);
3445 WREG32(mmCP_HQD_PQ_RPTR
, mqd
->queue_state
.cp_hqd_pq_rptr
);
3446 WREG32(mmCP_HQD_PQ_WPTR
, mqd
->queue_state
.cp_hqd_pq_wptr
);
3449 /* set the pointer to the MQD */
3450 mqd
->queue_state
.cp_mqd_base_addr
= mqd_gpu_addr
& 0xfffffffc;
3451 mqd
->queue_state
.cp_mqd_base_addr_hi
= upper_32_bits(mqd_gpu_addr
);
3452 WREG32(mmCP_MQD_BASE_ADDR
, mqd
->queue_state
.cp_mqd_base_addr
);
3453 WREG32(mmCP_MQD_BASE_ADDR_HI
, mqd
->queue_state
.cp_mqd_base_addr_hi
);
3454 /* set MQD vmid to 0 */
3455 mqd
->queue_state
.cp_mqd_control
= RREG32(mmCP_MQD_CONTROL
);
3456 mqd
->queue_state
.cp_mqd_control
&= ~CP_MQD_CONTROL__VMID_MASK
;
3457 WREG32(mmCP_MQD_CONTROL
, mqd
->queue_state
.cp_mqd_control
);
3459 /* set the pointer to the HQD, this is similar CP_RB0_BASE/_HI */
3460 hqd_gpu_addr
= ring
->gpu_addr
>> 8;
3461 mqd
->queue_state
.cp_hqd_pq_base
= hqd_gpu_addr
;
3462 mqd
->queue_state
.cp_hqd_pq_base_hi
= upper_32_bits(hqd_gpu_addr
);
3463 WREG32(mmCP_HQD_PQ_BASE
, mqd
->queue_state
.cp_hqd_pq_base
);
3464 WREG32(mmCP_HQD_PQ_BASE_HI
, mqd
->queue_state
.cp_hqd_pq_base_hi
);
3466 /* set up the HQD, this is similar to CP_RB0_CNTL */
3467 mqd
->queue_state
.cp_hqd_pq_control
= RREG32(mmCP_HQD_PQ_CONTROL
);
3468 mqd
->queue_state
.cp_hqd_pq_control
&=
3469 ~(CP_HQD_PQ_CONTROL__QUEUE_SIZE_MASK
|
3470 CP_HQD_PQ_CONTROL__RPTR_BLOCK_SIZE_MASK
);
3472 mqd
->queue_state
.cp_hqd_pq_control
|=
3473 order_base_2(ring
->ring_size
/ 8);
3474 mqd
->queue_state
.cp_hqd_pq_control
|=
3475 (order_base_2(AMDGPU_GPU_PAGE_SIZE
/8) << 8);
3477 mqd
->queue_state
.cp_hqd_pq_control
|=
3478 2 << CP_HQD_PQ_CONTROL__ENDIAN_SWAP__SHIFT
;
3480 mqd
->queue_state
.cp_hqd_pq_control
&=
3481 ~(CP_HQD_PQ_CONTROL__UNORD_DISPATCH_MASK
|
3482 CP_HQD_PQ_CONTROL__ROQ_PQ_IB_FLIP_MASK
|
3483 CP_HQD_PQ_CONTROL__PQ_VOLATILE_MASK
);
3484 mqd
->queue_state
.cp_hqd_pq_control
|=
3485 CP_HQD_PQ_CONTROL__PRIV_STATE_MASK
|
3486 CP_HQD_PQ_CONTROL__KMD_QUEUE_MASK
; /* assuming kernel queue control */
3487 WREG32(mmCP_HQD_PQ_CONTROL
, mqd
->queue_state
.cp_hqd_pq_control
);
3489 /* only used if CP_PQ_WPTR_POLL_CNTL.CP_PQ_WPTR_POLL_CNTL__EN_MASK=1 */
3490 wb_gpu_addr
= adev
->wb
.gpu_addr
+ (ring
->wptr_offs
* 4);
3491 mqd
->queue_state
.cp_hqd_pq_wptr_poll_addr
= wb_gpu_addr
& 0xfffffffc;
3492 mqd
->queue_state
.cp_hqd_pq_wptr_poll_addr_hi
= upper_32_bits(wb_gpu_addr
) & 0xffff;
3493 WREG32(mmCP_HQD_PQ_WPTR_POLL_ADDR
, mqd
->queue_state
.cp_hqd_pq_wptr_poll_addr
);
3494 WREG32(mmCP_HQD_PQ_WPTR_POLL_ADDR_HI
,
3495 mqd
->queue_state
.cp_hqd_pq_wptr_poll_addr_hi
);
3497 /* set the wb address wether it's enabled or not */
3498 wb_gpu_addr
= adev
->wb
.gpu_addr
+ (ring
->rptr_offs
* 4);
3499 mqd
->queue_state
.cp_hqd_pq_rptr_report_addr
= wb_gpu_addr
& 0xfffffffc;
3500 mqd
->queue_state
.cp_hqd_pq_rptr_report_addr_hi
=
3501 upper_32_bits(wb_gpu_addr
) & 0xffff;
3502 WREG32(mmCP_HQD_PQ_RPTR_REPORT_ADDR
,
3503 mqd
->queue_state
.cp_hqd_pq_rptr_report_addr
);
3504 WREG32(mmCP_HQD_PQ_RPTR_REPORT_ADDR_HI
,
3505 mqd
->queue_state
.cp_hqd_pq_rptr_report_addr_hi
);
3507 /* enable the doorbell if requested */
3509 mqd
->queue_state
.cp_hqd_pq_doorbell_control
=
3510 RREG32(mmCP_HQD_PQ_DOORBELL_CONTROL
);
3511 mqd
->queue_state
.cp_hqd_pq_doorbell_control
&=
3512 ~CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_OFFSET_MASK
;
3513 mqd
->queue_state
.cp_hqd_pq_doorbell_control
|=
3514 (ring
->doorbell_index
<<
3515 CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_OFFSET__SHIFT
);
3516 mqd
->queue_state
.cp_hqd_pq_doorbell_control
|=
3517 CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_EN_MASK
;
3518 mqd
->queue_state
.cp_hqd_pq_doorbell_control
&=
3519 ~(CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_SOURCE_MASK
|
3520 CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_HIT_MASK
);
3523 mqd
->queue_state
.cp_hqd_pq_doorbell_control
= 0;
3525 WREG32(mmCP_HQD_PQ_DOORBELL_CONTROL
,
3526 mqd
->queue_state
.cp_hqd_pq_doorbell_control
);
3528 /* read and write pointers, similar to CP_RB0_WPTR/_RPTR */
3530 mqd
->queue_state
.cp_hqd_pq_wptr
= ring
->wptr
;
3531 WREG32(mmCP_HQD_PQ_WPTR
, mqd
->queue_state
.cp_hqd_pq_wptr
);
3532 mqd
->queue_state
.cp_hqd_pq_rptr
= RREG32(mmCP_HQD_PQ_RPTR
);
3534 /* set the vmid for the queue */
3535 mqd
->queue_state
.cp_hqd_vmid
= 0;
3536 WREG32(mmCP_HQD_VMID
, mqd
->queue_state
.cp_hqd_vmid
);
3538 /* activate the queue */
3539 mqd
->queue_state
.cp_hqd_active
= 1;
3540 WREG32(mmCP_HQD_ACTIVE
, mqd
->queue_state
.cp_hqd_active
);
3542 cik_srbm_select(adev
, 0, 0, 0, 0);
3543 mutex_unlock(&adev
->srbm_mutex
);
3545 amdgpu_bo_kunmap(ring
->mqd_obj
);
3546 amdgpu_bo_unreserve(ring
->mqd_obj
);
3549 r
= amdgpu_ring_test_ring(ring
);
3551 ring
->ready
= false;
3557 static void gfx_v7_0_cp_enable(struct amdgpu_device
*adev
, bool enable
)
3559 gfx_v7_0_cp_gfx_enable(adev
, enable
);
3560 gfx_v7_0_cp_compute_enable(adev
, enable
);
3563 static int gfx_v7_0_cp_load_microcode(struct amdgpu_device
*adev
)
3567 r
= gfx_v7_0_cp_gfx_load_microcode(adev
);
3570 r
= gfx_v7_0_cp_compute_load_microcode(adev
);
3577 static void gfx_v7_0_enable_gui_idle_interrupt(struct amdgpu_device
*adev
,
3580 u32 tmp
= RREG32(mmCP_INT_CNTL_RING0
);
3583 tmp
|= (CP_INT_CNTL_RING0__CNTX_BUSY_INT_ENABLE_MASK
|
3584 CP_INT_CNTL_RING0__CNTX_EMPTY_INT_ENABLE_MASK
);
3586 tmp
&= ~(CP_INT_CNTL_RING0__CNTX_BUSY_INT_ENABLE_MASK
|
3587 CP_INT_CNTL_RING0__CNTX_EMPTY_INT_ENABLE_MASK
);
3588 WREG32(mmCP_INT_CNTL_RING0
, tmp
);
3591 static int gfx_v7_0_cp_resume(struct amdgpu_device
*adev
)
3595 gfx_v7_0_enable_gui_idle_interrupt(adev
, false);
3597 r
= gfx_v7_0_cp_load_microcode(adev
);
3601 r
= gfx_v7_0_cp_gfx_resume(adev
);
3604 r
= gfx_v7_0_cp_compute_resume(adev
);
3608 gfx_v7_0_enable_gui_idle_interrupt(adev
, true);
3615 * VMID 0 is the physical GPU addresses as used by the kernel.
3616 * VMIDs 1-15 are used for userspace clients and are handled
3617 * by the amdgpu vm/hsa code.
3620 * gfx_v7_0_ring_emit_vm_flush - cik vm flush using the CP
3622 * @adev: amdgpu_device pointer
3624 * Update the page table base and flush the VM TLB
3625 * using the CP (CIK).
3627 static void gfx_v7_0_ring_emit_vm_flush(struct amdgpu_ring
*ring
,
3628 unsigned vm_id
, uint64_t pd_addr
)
3630 int usepfp
= (ring
->type
== AMDGPU_RING_TYPE_GFX
);
3632 /* synce CE with ME to prevent CE fetch CEIB before context switch done */
3633 amdgpu_ring_write(ring
, PACKET3(PACKET3_SWITCH_BUFFER
, 0));
3634 amdgpu_ring_write(ring
, 0);
3635 amdgpu_ring_write(ring
, PACKET3(PACKET3_SWITCH_BUFFER
, 0));
3636 amdgpu_ring_write(ring
, 0);
3639 amdgpu_ring_write(ring
, PACKET3(PACKET3_WRITE_DATA
, 3));
3640 amdgpu_ring_write(ring
, (WRITE_DATA_ENGINE_SEL(usepfp
) |
3641 WRITE_DATA_DST_SEL(0)));
3643 amdgpu_ring_write(ring
,
3644 (mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR
+ vm_id
));
3646 amdgpu_ring_write(ring
,
3647 (mmVM_CONTEXT8_PAGE_TABLE_BASE_ADDR
+ vm_id
- 8));
3649 amdgpu_ring_write(ring
, 0);
3650 amdgpu_ring_write(ring
, pd_addr
>> 12);
3652 /* bits 0-15 are the VM contexts0-15 */
3653 amdgpu_ring_write(ring
, PACKET3(PACKET3_WRITE_DATA
, 3));
3654 amdgpu_ring_write(ring
, (WRITE_DATA_ENGINE_SEL(0) |
3655 WRITE_DATA_DST_SEL(0)));
3656 amdgpu_ring_write(ring
, mmVM_INVALIDATE_REQUEST
);
3657 amdgpu_ring_write(ring
, 0);
3658 amdgpu_ring_write(ring
, 1 << vm_id
);
3660 /* wait for the invalidate to complete */
3661 amdgpu_ring_write(ring
, PACKET3(PACKET3_WAIT_REG_MEM
, 5));
3662 amdgpu_ring_write(ring
, (WAIT_REG_MEM_OPERATION(0) | /* wait */
3663 WAIT_REG_MEM_FUNCTION(0) | /* always */
3664 WAIT_REG_MEM_ENGINE(0))); /* me */
3665 amdgpu_ring_write(ring
, mmVM_INVALIDATE_REQUEST
);
3666 amdgpu_ring_write(ring
, 0);
3667 amdgpu_ring_write(ring
, 0); /* ref */
3668 amdgpu_ring_write(ring
, 0); /* mask */
3669 amdgpu_ring_write(ring
, 0x20); /* poll interval */
3671 /* compute doesn't have PFP */
3673 /* sync PFP to ME, otherwise we might get invalid PFP reads */
3674 amdgpu_ring_write(ring
, PACKET3(PACKET3_PFP_SYNC_ME
, 0));
3675 amdgpu_ring_write(ring
, 0x0);
3677 /* synce CE with ME to prevent CE fetch CEIB before context switch done */
3678 amdgpu_ring_write(ring
, PACKET3(PACKET3_SWITCH_BUFFER
, 0));
3679 amdgpu_ring_write(ring
, 0);
3680 amdgpu_ring_write(ring
, PACKET3(PACKET3_SWITCH_BUFFER
, 0));
3681 amdgpu_ring_write(ring
, 0);
3687 * The RLC is a multi-purpose microengine that handles a
3688 * variety of functions.
3690 static void gfx_v7_0_rlc_fini(struct amdgpu_device
*adev
)
3694 /* save restore block */
3695 if (adev
->gfx
.rlc
.save_restore_obj
) {
3696 r
= amdgpu_bo_reserve(adev
->gfx
.rlc
.save_restore_obj
, false);
3697 if (unlikely(r
!= 0))
3698 dev_warn(adev
->dev
, "(%d) reserve RLC sr bo failed\n", r
);
3699 amdgpu_bo_unpin(adev
->gfx
.rlc
.save_restore_obj
);
3700 amdgpu_bo_unreserve(adev
->gfx
.rlc
.save_restore_obj
);
3702 amdgpu_bo_unref(&adev
->gfx
.rlc
.save_restore_obj
);
3703 adev
->gfx
.rlc
.save_restore_obj
= NULL
;
3706 /* clear state block */
3707 if (adev
->gfx
.rlc
.clear_state_obj
) {
3708 r
= amdgpu_bo_reserve(adev
->gfx
.rlc
.clear_state_obj
, false);
3709 if (unlikely(r
!= 0))
3710 dev_warn(adev
->dev
, "(%d) reserve RLC c bo failed\n", r
);
3711 amdgpu_bo_unpin(adev
->gfx
.rlc
.clear_state_obj
);
3712 amdgpu_bo_unreserve(adev
->gfx
.rlc
.clear_state_obj
);
3714 amdgpu_bo_unref(&adev
->gfx
.rlc
.clear_state_obj
);
3715 adev
->gfx
.rlc
.clear_state_obj
= NULL
;
3718 /* clear state block */
3719 if (adev
->gfx
.rlc
.cp_table_obj
) {
3720 r
= amdgpu_bo_reserve(adev
->gfx
.rlc
.cp_table_obj
, false);
3721 if (unlikely(r
!= 0))
3722 dev_warn(adev
->dev
, "(%d) reserve RLC cp table bo failed\n", r
);
3723 amdgpu_bo_unpin(adev
->gfx
.rlc
.cp_table_obj
);
3724 amdgpu_bo_unreserve(adev
->gfx
.rlc
.cp_table_obj
);
3726 amdgpu_bo_unref(&adev
->gfx
.rlc
.cp_table_obj
);
3727 adev
->gfx
.rlc
.cp_table_obj
= NULL
;
3731 static int gfx_v7_0_rlc_init(struct amdgpu_device
*adev
)
3734 volatile u32
*dst_ptr
;
3736 const struct cs_section_def
*cs_data
;
3739 /* allocate rlc buffers */
3740 if (adev
->flags
& AMD_IS_APU
) {
3741 if (adev
->asic_type
== CHIP_KAVERI
) {
3742 adev
->gfx
.rlc
.reg_list
= spectre_rlc_save_restore_register_list
;
3743 adev
->gfx
.rlc
.reg_list_size
=
3744 (u32
)ARRAY_SIZE(spectre_rlc_save_restore_register_list
);
3746 adev
->gfx
.rlc
.reg_list
= kalindi_rlc_save_restore_register_list
;
3747 adev
->gfx
.rlc
.reg_list_size
=
3748 (u32
)ARRAY_SIZE(kalindi_rlc_save_restore_register_list
);
3751 adev
->gfx
.rlc
.cs_data
= ci_cs_data
;
3752 adev
->gfx
.rlc
.cp_table_size
= CP_ME_TABLE_SIZE
* 5 * 4;
3754 src_ptr
= adev
->gfx
.rlc
.reg_list
;
3755 dws
= adev
->gfx
.rlc
.reg_list_size
;
3756 dws
+= (5 * 16) + 48 + 48 + 64;
3758 cs_data
= adev
->gfx
.rlc
.cs_data
;
3761 /* save restore block */
3762 if (adev
->gfx
.rlc
.save_restore_obj
== NULL
) {
3763 r
= amdgpu_bo_create(adev
, dws
* 4, PAGE_SIZE
, true,
3764 AMDGPU_GEM_DOMAIN_VRAM
,
3765 AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED
,
3767 &adev
->gfx
.rlc
.save_restore_obj
);
3769 dev_warn(adev
->dev
, "(%d) create RLC sr bo failed\n", r
);
3774 r
= amdgpu_bo_reserve(adev
->gfx
.rlc
.save_restore_obj
, false);
3775 if (unlikely(r
!= 0)) {
3776 gfx_v7_0_rlc_fini(adev
);
3779 r
= amdgpu_bo_pin(adev
->gfx
.rlc
.save_restore_obj
, AMDGPU_GEM_DOMAIN_VRAM
,
3780 &adev
->gfx
.rlc
.save_restore_gpu_addr
);
3782 amdgpu_bo_unreserve(adev
->gfx
.rlc
.save_restore_obj
);
3783 dev_warn(adev
->dev
, "(%d) pin RLC sr bo failed\n", r
);
3784 gfx_v7_0_rlc_fini(adev
);
3788 r
= amdgpu_bo_kmap(adev
->gfx
.rlc
.save_restore_obj
, (void **)&adev
->gfx
.rlc
.sr_ptr
);
3790 dev_warn(adev
->dev
, "(%d) map RLC sr bo failed\n", r
);
3791 gfx_v7_0_rlc_fini(adev
);
3794 /* write the sr buffer */
3795 dst_ptr
= adev
->gfx
.rlc
.sr_ptr
;
3796 for (i
= 0; i
< adev
->gfx
.rlc
.reg_list_size
; i
++)
3797 dst_ptr
[i
] = cpu_to_le32(src_ptr
[i
]);
3798 amdgpu_bo_kunmap(adev
->gfx
.rlc
.save_restore_obj
);
3799 amdgpu_bo_unreserve(adev
->gfx
.rlc
.save_restore_obj
);
3803 /* clear state block */
3804 adev
->gfx
.rlc
.clear_state_size
= dws
= gfx_v7_0_get_csb_size(adev
);
3806 if (adev
->gfx
.rlc
.clear_state_obj
== NULL
) {
3807 r
= amdgpu_bo_create(adev
, dws
* 4, PAGE_SIZE
, true,
3808 AMDGPU_GEM_DOMAIN_VRAM
,
3809 AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED
,
3811 &adev
->gfx
.rlc
.clear_state_obj
);
3813 dev_warn(adev
->dev
, "(%d) create RLC c bo failed\n", r
);
3814 gfx_v7_0_rlc_fini(adev
);
3818 r
= amdgpu_bo_reserve(adev
->gfx
.rlc
.clear_state_obj
, false);
3819 if (unlikely(r
!= 0)) {
3820 gfx_v7_0_rlc_fini(adev
);
3823 r
= amdgpu_bo_pin(adev
->gfx
.rlc
.clear_state_obj
, AMDGPU_GEM_DOMAIN_VRAM
,
3824 &adev
->gfx
.rlc
.clear_state_gpu_addr
);
3826 amdgpu_bo_unreserve(adev
->gfx
.rlc
.clear_state_obj
);
3827 dev_warn(adev
->dev
, "(%d) pin RLC c bo failed\n", r
);
3828 gfx_v7_0_rlc_fini(adev
);
3832 r
= amdgpu_bo_kmap(adev
->gfx
.rlc
.clear_state_obj
, (void **)&adev
->gfx
.rlc
.cs_ptr
);
3834 dev_warn(adev
->dev
, "(%d) map RLC c bo failed\n", r
);
3835 gfx_v7_0_rlc_fini(adev
);
3838 /* set up the cs buffer */
3839 dst_ptr
= adev
->gfx
.rlc
.cs_ptr
;
3840 gfx_v7_0_get_csb_buffer(adev
, dst_ptr
);
3841 amdgpu_bo_kunmap(adev
->gfx
.rlc
.clear_state_obj
);
3842 amdgpu_bo_unreserve(adev
->gfx
.rlc
.clear_state_obj
);
3845 if (adev
->gfx
.rlc
.cp_table_size
) {
3846 if (adev
->gfx
.rlc
.cp_table_obj
== NULL
) {
3847 r
= amdgpu_bo_create(adev
, adev
->gfx
.rlc
.cp_table_size
, PAGE_SIZE
, true,
3848 AMDGPU_GEM_DOMAIN_VRAM
,
3849 AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED
,
3851 &adev
->gfx
.rlc
.cp_table_obj
);
3853 dev_warn(adev
->dev
, "(%d) create RLC cp table bo failed\n", r
);
3854 gfx_v7_0_rlc_fini(adev
);
3859 r
= amdgpu_bo_reserve(adev
->gfx
.rlc
.cp_table_obj
, false);
3860 if (unlikely(r
!= 0)) {
3861 dev_warn(adev
->dev
, "(%d) reserve RLC cp table bo failed\n", r
);
3862 gfx_v7_0_rlc_fini(adev
);
3865 r
= amdgpu_bo_pin(adev
->gfx
.rlc
.cp_table_obj
, AMDGPU_GEM_DOMAIN_VRAM
,
3866 &adev
->gfx
.rlc
.cp_table_gpu_addr
);
3868 amdgpu_bo_unreserve(adev
->gfx
.rlc
.cp_table_obj
);
3869 dev_warn(adev
->dev
, "(%d) pin RLC cp_table bo failed\n", r
);
3870 gfx_v7_0_rlc_fini(adev
);
3873 r
= amdgpu_bo_kmap(adev
->gfx
.rlc
.cp_table_obj
, (void **)&adev
->gfx
.rlc
.cp_table_ptr
);
3875 dev_warn(adev
->dev
, "(%d) map RLC cp table bo failed\n", r
);
3876 gfx_v7_0_rlc_fini(adev
);
3880 gfx_v7_0_init_cp_pg_table(adev
);
3882 amdgpu_bo_kunmap(adev
->gfx
.rlc
.cp_table_obj
);
3883 amdgpu_bo_unreserve(adev
->gfx
.rlc
.cp_table_obj
);
3890 static void gfx_v7_0_enable_lbpw(struct amdgpu_device
*adev
, bool enable
)
3894 tmp
= RREG32(mmRLC_LB_CNTL
);
3896 tmp
|= RLC_LB_CNTL__LOAD_BALANCE_ENABLE_MASK
;
3898 tmp
&= ~RLC_LB_CNTL__LOAD_BALANCE_ENABLE_MASK
;
3899 WREG32(mmRLC_LB_CNTL
, tmp
);
3902 static void gfx_v7_0_wait_for_rlc_serdes(struct amdgpu_device
*adev
)
3907 mutex_lock(&adev
->grbm_idx_mutex
);
3908 for (i
= 0; i
< adev
->gfx
.config
.max_shader_engines
; i
++) {
3909 for (j
= 0; j
< adev
->gfx
.config
.max_sh_per_se
; j
++) {
3910 gfx_v7_0_select_se_sh(adev
, i
, j
);
3911 for (k
= 0; k
< adev
->usec_timeout
; k
++) {
3912 if (RREG32(mmRLC_SERDES_CU_MASTER_BUSY
) == 0)
3918 gfx_v7_0_select_se_sh(adev
, 0xffffffff, 0xffffffff);
3919 mutex_unlock(&adev
->grbm_idx_mutex
);
3921 mask
= RLC_SERDES_NONCU_MASTER_BUSY__SE_MASTER_BUSY_MASK
|
3922 RLC_SERDES_NONCU_MASTER_BUSY__GC_MASTER_BUSY_MASK
|
3923 RLC_SERDES_NONCU_MASTER_BUSY__TC0_MASTER_BUSY_MASK
|
3924 RLC_SERDES_NONCU_MASTER_BUSY__TC1_MASTER_BUSY_MASK
;
3925 for (k
= 0; k
< adev
->usec_timeout
; k
++) {
3926 if ((RREG32(mmRLC_SERDES_NONCU_MASTER_BUSY
) & mask
) == 0)
3932 static void gfx_v7_0_update_rlc(struct amdgpu_device
*adev
, u32 rlc
)
3936 tmp
= RREG32(mmRLC_CNTL
);
3938 WREG32(mmRLC_CNTL
, rlc
);
3941 static u32
gfx_v7_0_halt_rlc(struct amdgpu_device
*adev
)
3945 orig
= data
= RREG32(mmRLC_CNTL
);
3947 if (data
& RLC_CNTL__RLC_ENABLE_F32_MASK
) {
3950 data
&= ~RLC_CNTL__RLC_ENABLE_F32_MASK
;
3951 WREG32(mmRLC_CNTL
, data
);
3953 for (i
= 0; i
< adev
->usec_timeout
; i
++) {
3954 if ((RREG32(mmRLC_GPM_STAT
) & RLC_GPM_STAT__RLC_BUSY_MASK
) == 0)
3959 gfx_v7_0_wait_for_rlc_serdes(adev
);
3965 void gfx_v7_0_enter_rlc_safe_mode(struct amdgpu_device
*adev
)
3969 tmp
= 0x1 | (1 << 1);
3970 WREG32(mmRLC_GPR_REG2
, tmp
);
3972 mask
= RLC_GPM_STAT__GFX_POWER_STATUS_MASK
|
3973 RLC_GPM_STAT__GFX_CLOCK_STATUS_MASK
;
3974 for (i
= 0; i
< adev
->usec_timeout
; i
++) {
3975 if ((RREG32(mmRLC_GPM_STAT
) & mask
) == mask
)
3980 for (i
= 0; i
< adev
->usec_timeout
; i
++) {
3981 if ((RREG32(mmRLC_GPR_REG2
) & 0x1) == 0)
3987 void gfx_v7_0_exit_rlc_safe_mode(struct amdgpu_device
*adev
)
3991 tmp
= 0x1 | (0 << 1);
3992 WREG32(mmRLC_GPR_REG2
, tmp
);
3996 * gfx_v7_0_rlc_stop - stop the RLC ME
3998 * @adev: amdgpu_device pointer
4000 * Halt the RLC ME (MicroEngine) (CIK).
4002 void gfx_v7_0_rlc_stop(struct amdgpu_device
*adev
)
4004 WREG32(mmRLC_CNTL
, 0);
4006 gfx_v7_0_enable_gui_idle_interrupt(adev
, false);
4008 gfx_v7_0_wait_for_rlc_serdes(adev
);
4012 * gfx_v7_0_rlc_start - start the RLC ME
4014 * @adev: amdgpu_device pointer
4016 * Unhalt the RLC ME (MicroEngine) (CIK).
4018 static void gfx_v7_0_rlc_start(struct amdgpu_device
*adev
)
4020 WREG32(mmRLC_CNTL
, RLC_CNTL__RLC_ENABLE_F32_MASK
);
4022 gfx_v7_0_enable_gui_idle_interrupt(adev
, true);
4027 static void gfx_v7_0_rlc_reset(struct amdgpu_device
*adev
)
4029 u32 tmp
= RREG32(mmGRBM_SOFT_RESET
);
4031 tmp
|= GRBM_SOFT_RESET__SOFT_RESET_RLC_MASK
;
4032 WREG32(mmGRBM_SOFT_RESET
, tmp
);
4034 tmp
&= ~GRBM_SOFT_RESET__SOFT_RESET_RLC_MASK
;
4035 WREG32(mmGRBM_SOFT_RESET
, tmp
);
4040 * gfx_v7_0_rlc_resume - setup the RLC hw
4042 * @adev: amdgpu_device pointer
4044 * Initialize the RLC registers, load the ucode,
4045 * and start the RLC (CIK).
4046 * Returns 0 for success, -EINVAL if the ucode is not available.
4048 static int gfx_v7_0_rlc_resume(struct amdgpu_device
*adev
)
4050 const struct rlc_firmware_header_v1_0
*hdr
;
4051 const __le32
*fw_data
;
4052 unsigned i
, fw_size
;
4055 if (!adev
->gfx
.rlc_fw
)
4058 hdr
= (const struct rlc_firmware_header_v1_0
*)adev
->gfx
.rlc_fw
->data
;
4059 amdgpu_ucode_print_rlc_hdr(&hdr
->header
);
4060 adev
->gfx
.rlc_fw_version
= le32_to_cpu(hdr
->header
.ucode_version
);
4061 adev
->gfx
.rlc_feature_version
= le32_to_cpu(
4062 hdr
->ucode_feature_version
);
4064 gfx_v7_0_rlc_stop(adev
);
4067 tmp
= RREG32(mmRLC_CGCG_CGLS_CTRL
) & 0xfffffffc;
4068 WREG32(mmRLC_CGCG_CGLS_CTRL
, tmp
);
4070 gfx_v7_0_rlc_reset(adev
);
4072 gfx_v7_0_init_pg(adev
);
4074 WREG32(mmRLC_LB_CNTR_INIT
, 0);
4075 WREG32(mmRLC_LB_CNTR_MAX
, 0x00008000);
4077 mutex_lock(&adev
->grbm_idx_mutex
);
4078 gfx_v7_0_select_se_sh(adev
, 0xffffffff, 0xffffffff);
4079 WREG32(mmRLC_LB_INIT_CU_MASK
, 0xffffffff);
4080 WREG32(mmRLC_LB_PARAMS
, 0x00600408);
4081 WREG32(mmRLC_LB_CNTL
, 0x80000004);
4082 mutex_unlock(&adev
->grbm_idx_mutex
);
4084 WREG32(mmRLC_MC_CNTL
, 0);
4085 WREG32(mmRLC_UCODE_CNTL
, 0);
4087 fw_data
= (const __le32
*)
4088 (adev
->gfx
.rlc_fw
->data
+ le32_to_cpu(hdr
->header
.ucode_array_offset_bytes
));
4089 fw_size
= le32_to_cpu(hdr
->header
.ucode_size_bytes
) / 4;
4090 WREG32(mmRLC_GPM_UCODE_ADDR
, 0);
4091 for (i
= 0; i
< fw_size
; i
++)
4092 WREG32(mmRLC_GPM_UCODE_DATA
, le32_to_cpup(fw_data
++));
4093 WREG32(mmRLC_GPM_UCODE_ADDR
, adev
->gfx
.rlc_fw_version
);
4095 /* XXX - find out what chips support lbpw */
4096 gfx_v7_0_enable_lbpw(adev
, false);
4098 if (adev
->asic_type
== CHIP_BONAIRE
)
4099 WREG32(mmRLC_DRIVER_CPDMA_STATUS
, 0);
4101 gfx_v7_0_rlc_start(adev
);
4106 static void gfx_v7_0_enable_cgcg(struct amdgpu_device
*adev
, bool enable
)
4108 u32 data
, orig
, tmp
, tmp2
;
4110 orig
= data
= RREG32(mmRLC_CGCG_CGLS_CTRL
);
4112 if (enable
&& (adev
->cg_flags
& AMDGPU_CG_SUPPORT_GFX_CGCG
)) {
4113 gfx_v7_0_enable_gui_idle_interrupt(adev
, true);
4115 tmp
= gfx_v7_0_halt_rlc(adev
);
4117 mutex_lock(&adev
->grbm_idx_mutex
);
4118 gfx_v7_0_select_se_sh(adev
, 0xffffffff, 0xffffffff);
4119 WREG32(mmRLC_SERDES_WR_CU_MASTER_MASK
, 0xffffffff);
4120 WREG32(mmRLC_SERDES_WR_NONCU_MASTER_MASK
, 0xffffffff);
4121 tmp2
= RLC_SERDES_WR_CTRL__BPM_ADDR_MASK
|
4122 RLC_SERDES_WR_CTRL__CGCG_OVERRIDE_0_MASK
|
4123 RLC_SERDES_WR_CTRL__CGLS_ENABLE_MASK
;
4124 WREG32(mmRLC_SERDES_WR_CTRL
, tmp2
);
4125 mutex_unlock(&adev
->grbm_idx_mutex
);
4127 gfx_v7_0_update_rlc(adev
, tmp
);
4129 data
|= RLC_CGCG_CGLS_CTRL__CGCG_EN_MASK
| RLC_CGCG_CGLS_CTRL__CGLS_EN_MASK
;
4131 gfx_v7_0_enable_gui_idle_interrupt(adev
, false);
4133 RREG32(mmCB_CGTT_SCLK_CTRL
);
4134 RREG32(mmCB_CGTT_SCLK_CTRL
);
4135 RREG32(mmCB_CGTT_SCLK_CTRL
);
4136 RREG32(mmCB_CGTT_SCLK_CTRL
);
4138 data
&= ~(RLC_CGCG_CGLS_CTRL__CGCG_EN_MASK
| RLC_CGCG_CGLS_CTRL__CGLS_EN_MASK
);
4142 WREG32(mmRLC_CGCG_CGLS_CTRL
, data
);
4146 static void gfx_v7_0_enable_mgcg(struct amdgpu_device
*adev
, bool enable
)
4148 u32 data
, orig
, tmp
= 0;
4150 if (enable
&& (adev
->cg_flags
& AMDGPU_CG_SUPPORT_GFX_MGCG
)) {
4151 if (adev
->cg_flags
& AMDGPU_CG_SUPPORT_GFX_MGLS
) {
4152 if (adev
->cg_flags
& AMDGPU_CG_SUPPORT_GFX_CP_LS
) {
4153 orig
= data
= RREG32(mmCP_MEM_SLP_CNTL
);
4154 data
|= CP_MEM_SLP_CNTL__CP_MEM_LS_EN_MASK
;
4156 WREG32(mmCP_MEM_SLP_CNTL
, data
);
4160 orig
= data
= RREG32(mmRLC_CGTT_MGCG_OVERRIDE
);
4164 WREG32(mmRLC_CGTT_MGCG_OVERRIDE
, data
);
4166 tmp
= gfx_v7_0_halt_rlc(adev
);
4168 mutex_lock(&adev
->grbm_idx_mutex
);
4169 gfx_v7_0_select_se_sh(adev
, 0xffffffff, 0xffffffff);
4170 WREG32(mmRLC_SERDES_WR_CU_MASTER_MASK
, 0xffffffff);
4171 WREG32(mmRLC_SERDES_WR_NONCU_MASTER_MASK
, 0xffffffff);
4172 data
= RLC_SERDES_WR_CTRL__BPM_ADDR_MASK
|
4173 RLC_SERDES_WR_CTRL__MGCG_OVERRIDE_0_MASK
;
4174 WREG32(mmRLC_SERDES_WR_CTRL
, data
);
4175 mutex_unlock(&adev
->grbm_idx_mutex
);
4177 gfx_v7_0_update_rlc(adev
, tmp
);
4179 if (adev
->cg_flags
& AMDGPU_CG_SUPPORT_GFX_CGTS
) {
4180 orig
= data
= RREG32(mmCGTS_SM_CTRL_REG
);
4181 data
&= ~CGTS_SM_CTRL_REG__SM_MODE_MASK
;
4182 data
|= (0x2 << CGTS_SM_CTRL_REG__SM_MODE__SHIFT
);
4183 data
|= CGTS_SM_CTRL_REG__SM_MODE_ENABLE_MASK
;
4184 data
&= ~CGTS_SM_CTRL_REG__OVERRIDE_MASK
;
4185 if ((adev
->cg_flags
& AMDGPU_CG_SUPPORT_GFX_MGLS
) &&
4186 (adev
->cg_flags
& AMDGPU_CG_SUPPORT_GFX_CGTS_LS
))
4187 data
&= ~CGTS_SM_CTRL_REG__LS_OVERRIDE_MASK
;
4188 data
&= ~CGTS_SM_CTRL_REG__ON_MONITOR_ADD_MASK
;
4189 data
|= CGTS_SM_CTRL_REG__ON_MONITOR_ADD_EN_MASK
;
4190 data
|= (0x96 << CGTS_SM_CTRL_REG__ON_MONITOR_ADD__SHIFT
);
4192 WREG32(mmCGTS_SM_CTRL_REG
, data
);
4195 orig
= data
= RREG32(mmRLC_CGTT_MGCG_OVERRIDE
);
4198 WREG32(mmRLC_CGTT_MGCG_OVERRIDE
, data
);
4200 data
= RREG32(mmRLC_MEM_SLP_CNTL
);
4201 if (data
& RLC_MEM_SLP_CNTL__RLC_MEM_LS_EN_MASK
) {
4202 data
&= ~RLC_MEM_SLP_CNTL__RLC_MEM_LS_EN_MASK
;
4203 WREG32(mmRLC_MEM_SLP_CNTL
, data
);
4206 data
= RREG32(mmCP_MEM_SLP_CNTL
);
4207 if (data
& CP_MEM_SLP_CNTL__CP_MEM_LS_EN_MASK
) {
4208 data
&= ~CP_MEM_SLP_CNTL__CP_MEM_LS_EN_MASK
;
4209 WREG32(mmCP_MEM_SLP_CNTL
, data
);
4212 orig
= data
= RREG32(mmCGTS_SM_CTRL_REG
);
4213 data
|= CGTS_SM_CTRL_REG__OVERRIDE_MASK
| CGTS_SM_CTRL_REG__LS_OVERRIDE_MASK
;
4215 WREG32(mmCGTS_SM_CTRL_REG
, data
);
4217 tmp
= gfx_v7_0_halt_rlc(adev
);
4219 mutex_lock(&adev
->grbm_idx_mutex
);
4220 gfx_v7_0_select_se_sh(adev
, 0xffffffff, 0xffffffff);
4221 WREG32(mmRLC_SERDES_WR_CU_MASTER_MASK
, 0xffffffff);
4222 WREG32(mmRLC_SERDES_WR_NONCU_MASTER_MASK
, 0xffffffff);
4223 data
= RLC_SERDES_WR_CTRL__BPM_ADDR_MASK
| RLC_SERDES_WR_CTRL__MGCG_OVERRIDE_1_MASK
;
4224 WREG32(mmRLC_SERDES_WR_CTRL
, data
);
4225 mutex_unlock(&adev
->grbm_idx_mutex
);
4227 gfx_v7_0_update_rlc(adev
, tmp
);
4231 static void gfx_v7_0_update_cg(struct amdgpu_device
*adev
,
4234 gfx_v7_0_enable_gui_idle_interrupt(adev
, false);
4235 /* order matters! */
4237 gfx_v7_0_enable_mgcg(adev
, true);
4238 gfx_v7_0_enable_cgcg(adev
, true);
4240 gfx_v7_0_enable_cgcg(adev
, false);
4241 gfx_v7_0_enable_mgcg(adev
, false);
4243 gfx_v7_0_enable_gui_idle_interrupt(adev
, true);
4246 static void gfx_v7_0_enable_sclk_slowdown_on_pu(struct amdgpu_device
*adev
,
4251 orig
= data
= RREG32(mmRLC_PG_CNTL
);
4252 if (enable
&& (adev
->pg_flags
& AMDGPU_PG_SUPPORT_RLC_SMU_HS
))
4253 data
|= RLC_PG_CNTL__SMU_CLK_SLOWDOWN_ON_PU_ENABLE_MASK
;
4255 data
&= ~RLC_PG_CNTL__SMU_CLK_SLOWDOWN_ON_PU_ENABLE_MASK
;
4257 WREG32(mmRLC_PG_CNTL
, data
);
4260 static void gfx_v7_0_enable_sclk_slowdown_on_pd(struct amdgpu_device
*adev
,
4265 orig
= data
= RREG32(mmRLC_PG_CNTL
);
4266 if (enable
&& (adev
->pg_flags
& AMDGPU_PG_SUPPORT_RLC_SMU_HS
))
4267 data
|= RLC_PG_CNTL__SMU_CLK_SLOWDOWN_ON_PD_ENABLE_MASK
;
4269 data
&= ~RLC_PG_CNTL__SMU_CLK_SLOWDOWN_ON_PD_ENABLE_MASK
;
4271 WREG32(mmRLC_PG_CNTL
, data
);
4274 static void gfx_v7_0_enable_cp_pg(struct amdgpu_device
*adev
, bool enable
)
4278 orig
= data
= RREG32(mmRLC_PG_CNTL
);
4279 if (enable
&& (adev
->pg_flags
& AMDGPU_PG_SUPPORT_CP
))
4284 WREG32(mmRLC_PG_CNTL
, data
);
4287 static void gfx_v7_0_enable_gds_pg(struct amdgpu_device
*adev
, bool enable
)
4291 orig
= data
= RREG32(mmRLC_PG_CNTL
);
4292 if (enable
&& (adev
->pg_flags
& AMDGPU_PG_SUPPORT_GDS
))
4297 WREG32(mmRLC_PG_CNTL
, data
);
4300 static void gfx_v7_0_init_cp_pg_table(struct amdgpu_device
*adev
)
4302 const __le32
*fw_data
;
4303 volatile u32
*dst_ptr
;
4304 int me
, i
, max_me
= 4;
4306 u32 table_offset
, table_size
;
4308 if (adev
->asic_type
== CHIP_KAVERI
)
4311 if (adev
->gfx
.rlc
.cp_table_ptr
== NULL
)
4314 /* write the cp table buffer */
4315 dst_ptr
= adev
->gfx
.rlc
.cp_table_ptr
;
4316 for (me
= 0; me
< max_me
; me
++) {
4318 const struct gfx_firmware_header_v1_0
*hdr
=
4319 (const struct gfx_firmware_header_v1_0
*)adev
->gfx
.ce_fw
->data
;
4320 fw_data
= (const __le32
*)
4321 (adev
->gfx
.ce_fw
->data
+
4322 le32_to_cpu(hdr
->header
.ucode_array_offset_bytes
));
4323 table_offset
= le32_to_cpu(hdr
->jt_offset
);
4324 table_size
= le32_to_cpu(hdr
->jt_size
);
4325 } else if (me
== 1) {
4326 const struct gfx_firmware_header_v1_0
*hdr
=
4327 (const struct gfx_firmware_header_v1_0
*)adev
->gfx
.pfp_fw
->data
;
4328 fw_data
= (const __le32
*)
4329 (adev
->gfx
.pfp_fw
->data
+
4330 le32_to_cpu(hdr
->header
.ucode_array_offset_bytes
));
4331 table_offset
= le32_to_cpu(hdr
->jt_offset
);
4332 table_size
= le32_to_cpu(hdr
->jt_size
);
4333 } else if (me
== 2) {
4334 const struct gfx_firmware_header_v1_0
*hdr
=
4335 (const struct gfx_firmware_header_v1_0
*)adev
->gfx
.me_fw
->data
;
4336 fw_data
= (const __le32
*)
4337 (adev
->gfx
.me_fw
->data
+
4338 le32_to_cpu(hdr
->header
.ucode_array_offset_bytes
));
4339 table_offset
= le32_to_cpu(hdr
->jt_offset
);
4340 table_size
= le32_to_cpu(hdr
->jt_size
);
4341 } else if (me
== 3) {
4342 const struct gfx_firmware_header_v1_0
*hdr
=
4343 (const struct gfx_firmware_header_v1_0
*)adev
->gfx
.mec_fw
->data
;
4344 fw_data
= (const __le32
*)
4345 (adev
->gfx
.mec_fw
->data
+
4346 le32_to_cpu(hdr
->header
.ucode_array_offset_bytes
));
4347 table_offset
= le32_to_cpu(hdr
->jt_offset
);
4348 table_size
= le32_to_cpu(hdr
->jt_size
);
4350 const struct gfx_firmware_header_v1_0
*hdr
=
4351 (const struct gfx_firmware_header_v1_0
*)adev
->gfx
.mec2_fw
->data
;
4352 fw_data
= (const __le32
*)
4353 (adev
->gfx
.mec2_fw
->data
+
4354 le32_to_cpu(hdr
->header
.ucode_array_offset_bytes
));
4355 table_offset
= le32_to_cpu(hdr
->jt_offset
);
4356 table_size
= le32_to_cpu(hdr
->jt_size
);
4359 for (i
= 0; i
< table_size
; i
++) {
4360 dst_ptr
[bo_offset
+ i
] =
4361 cpu_to_le32(le32_to_cpu(fw_data
[table_offset
+ i
]));
4364 bo_offset
+= table_size
;
4368 static void gfx_v7_0_enable_gfx_cgpg(struct amdgpu_device
*adev
,
4373 if (enable
&& (adev
->pg_flags
& AMDGPU_PG_SUPPORT_GFX_PG
)) {
4374 orig
= data
= RREG32(mmRLC_PG_CNTL
);
4375 data
|= RLC_PG_CNTL__GFX_POWER_GATING_ENABLE_MASK
;
4377 WREG32(mmRLC_PG_CNTL
, data
);
4379 orig
= data
= RREG32(mmRLC_AUTO_PG_CTRL
);
4380 data
|= RLC_AUTO_PG_CTRL__AUTO_PG_EN_MASK
;
4382 WREG32(mmRLC_AUTO_PG_CTRL
, data
);
4384 orig
= data
= RREG32(mmRLC_PG_CNTL
);
4385 data
&= ~RLC_PG_CNTL__GFX_POWER_GATING_ENABLE_MASK
;
4387 WREG32(mmRLC_PG_CNTL
, data
);
4389 orig
= data
= RREG32(mmRLC_AUTO_PG_CTRL
);
4390 data
&= ~RLC_AUTO_PG_CTRL__AUTO_PG_EN_MASK
;
4392 WREG32(mmRLC_AUTO_PG_CTRL
, data
);
4394 data
= RREG32(mmDB_RENDER_CONTROL
);
4398 static u32
gfx_v7_0_get_cu_active_bitmap(struct amdgpu_device
*adev
,
4401 u32 mask
= 0, tmp
, tmp1
;
4404 gfx_v7_0_select_se_sh(adev
, se
, sh
);
4405 tmp
= RREG32(mmCC_GC_SHADER_ARRAY_CONFIG
);
4406 tmp1
= RREG32(mmGC_USER_SHADER_ARRAY_CONFIG
);
4407 gfx_v7_0_select_se_sh(adev
, 0xffffffff, 0xffffffff);
4414 for (i
= 0; i
< adev
->gfx
.config
.max_cu_per_sh
; i
++) {
4419 return (~tmp
) & mask
;
4422 static void gfx_v7_0_init_ao_cu_mask(struct amdgpu_device
*adev
)
4424 uint32_t tmp
, active_cu_number
;
4425 struct amdgpu_cu_info cu_info
;
4427 gfx_v7_0_get_cu_info(adev
, &cu_info
);
4428 tmp
= cu_info
.ao_cu_mask
;
4429 active_cu_number
= cu_info
.number
;
4431 WREG32(mmRLC_PG_ALWAYS_ON_CU_MASK
, tmp
);
4433 tmp
= RREG32(mmRLC_MAX_PG_CU
);
4434 tmp
&= ~RLC_MAX_PG_CU__MAX_POWERED_UP_CU_MASK
;
4435 tmp
|= (active_cu_number
<< RLC_MAX_PG_CU__MAX_POWERED_UP_CU__SHIFT
);
4436 WREG32(mmRLC_MAX_PG_CU
, tmp
);
4439 static void gfx_v7_0_enable_gfx_static_mgpg(struct amdgpu_device
*adev
,
4444 orig
= data
= RREG32(mmRLC_PG_CNTL
);
4445 if (enable
&& (adev
->pg_flags
& AMDGPU_PG_SUPPORT_GFX_SMG
))
4446 data
|= RLC_PG_CNTL__STATIC_PER_CU_PG_ENABLE_MASK
;
4448 data
&= ~RLC_PG_CNTL__STATIC_PER_CU_PG_ENABLE_MASK
;
4450 WREG32(mmRLC_PG_CNTL
, data
);
4453 static void gfx_v7_0_enable_gfx_dynamic_mgpg(struct amdgpu_device
*adev
,
4458 orig
= data
= RREG32(mmRLC_PG_CNTL
);
4459 if (enable
&& (adev
->pg_flags
& AMDGPU_PG_SUPPORT_GFX_DMG
))
4460 data
|= RLC_PG_CNTL__DYN_PER_CU_PG_ENABLE_MASK
;
4462 data
&= ~RLC_PG_CNTL__DYN_PER_CU_PG_ENABLE_MASK
;
4464 WREG32(mmRLC_PG_CNTL
, data
);
4467 #define RLC_SAVE_AND_RESTORE_STARTING_OFFSET 0x90
4468 #define RLC_CLEAR_STATE_DESCRIPTOR_OFFSET 0x3D
4470 static void gfx_v7_0_init_gfx_cgpg(struct amdgpu_device
*adev
)
4475 if (adev
->gfx
.rlc
.cs_data
) {
4476 WREG32(mmRLC_GPM_SCRATCH_ADDR
, RLC_CLEAR_STATE_DESCRIPTOR_OFFSET
);
4477 WREG32(mmRLC_GPM_SCRATCH_DATA
, upper_32_bits(adev
->gfx
.rlc
.clear_state_gpu_addr
));
4478 WREG32(mmRLC_GPM_SCRATCH_DATA
, lower_32_bits(adev
->gfx
.rlc
.clear_state_gpu_addr
));
4479 WREG32(mmRLC_GPM_SCRATCH_DATA
, adev
->gfx
.rlc
.clear_state_size
);
4481 WREG32(mmRLC_GPM_SCRATCH_ADDR
, RLC_CLEAR_STATE_DESCRIPTOR_OFFSET
);
4482 for (i
= 0; i
< 3; i
++)
4483 WREG32(mmRLC_GPM_SCRATCH_DATA
, 0);
4485 if (adev
->gfx
.rlc
.reg_list
) {
4486 WREG32(mmRLC_GPM_SCRATCH_ADDR
, RLC_SAVE_AND_RESTORE_STARTING_OFFSET
);
4487 for (i
= 0; i
< adev
->gfx
.rlc
.reg_list_size
; i
++)
4488 WREG32(mmRLC_GPM_SCRATCH_DATA
, adev
->gfx
.rlc
.reg_list
[i
]);
4491 orig
= data
= RREG32(mmRLC_PG_CNTL
);
4492 data
|= RLC_PG_CNTL__GFX_POWER_GATING_SRC_MASK
;
4494 WREG32(mmRLC_PG_CNTL
, data
);
4496 WREG32(mmRLC_SAVE_AND_RESTORE_BASE
, adev
->gfx
.rlc
.save_restore_gpu_addr
>> 8);
4497 WREG32(mmRLC_JUMP_TABLE_RESTORE
, adev
->gfx
.rlc
.cp_table_gpu_addr
>> 8);
4499 data
= RREG32(mmCP_RB_WPTR_POLL_CNTL
);
4500 data
&= ~CP_RB_WPTR_POLL_CNTL__IDLE_POLL_COUNT_MASK
;
4501 data
|= (0x60 << CP_RB_WPTR_POLL_CNTL__IDLE_POLL_COUNT__SHIFT
);
4502 WREG32(mmCP_RB_WPTR_POLL_CNTL
, data
);
4505 WREG32(mmRLC_PG_DELAY
, data
);
4507 data
= RREG32(mmRLC_PG_DELAY_2
);
4510 WREG32(mmRLC_PG_DELAY_2
, data
);
4512 data
= RREG32(mmRLC_AUTO_PG_CTRL
);
4513 data
&= ~RLC_AUTO_PG_CTRL__GRBM_REG_SAVE_GFX_IDLE_THRESHOLD_MASK
;
4514 data
|= (0x700 << RLC_AUTO_PG_CTRL__GRBM_REG_SAVE_GFX_IDLE_THRESHOLD__SHIFT
);
4515 WREG32(mmRLC_AUTO_PG_CTRL
, data
);
4519 static void gfx_v7_0_update_gfx_pg(struct amdgpu_device
*adev
, bool enable
)
4521 gfx_v7_0_enable_gfx_cgpg(adev
, enable
);
4522 gfx_v7_0_enable_gfx_static_mgpg(adev
, enable
);
4523 gfx_v7_0_enable_gfx_dynamic_mgpg(adev
, enable
);
4526 static u32
gfx_v7_0_get_csb_size(struct amdgpu_device
*adev
)
4529 const struct cs_section_def
*sect
= NULL
;
4530 const struct cs_extent_def
*ext
= NULL
;
4532 if (adev
->gfx
.rlc
.cs_data
== NULL
)
4535 /* begin clear state */
4537 /* context control state */
4540 for (sect
= adev
->gfx
.rlc
.cs_data
; sect
->section
!= NULL
; ++sect
) {
4541 for (ext
= sect
->section
; ext
->extent
!= NULL
; ++ext
) {
4542 if (sect
->id
== SECT_CONTEXT
)
4543 count
+= 2 + ext
->reg_count
;
4548 /* pa_sc_raster_config/pa_sc_raster_config1 */
4550 /* end clear state */
4558 static void gfx_v7_0_get_csb_buffer(struct amdgpu_device
*adev
,
4559 volatile u32
*buffer
)
4562 const struct cs_section_def
*sect
= NULL
;
4563 const struct cs_extent_def
*ext
= NULL
;
4565 if (adev
->gfx
.rlc
.cs_data
== NULL
)
4570 buffer
[count
++] = cpu_to_le32(PACKET3(PACKET3_PREAMBLE_CNTL
, 0));
4571 buffer
[count
++] = cpu_to_le32(PACKET3_PREAMBLE_BEGIN_CLEAR_STATE
);
4573 buffer
[count
++] = cpu_to_le32(PACKET3(PACKET3_CONTEXT_CONTROL
, 1));
4574 buffer
[count
++] = cpu_to_le32(0x80000000);
4575 buffer
[count
++] = cpu_to_le32(0x80000000);
4577 for (sect
= adev
->gfx
.rlc
.cs_data
; sect
->section
!= NULL
; ++sect
) {
4578 for (ext
= sect
->section
; ext
->extent
!= NULL
; ++ext
) {
4579 if (sect
->id
== SECT_CONTEXT
) {
4581 cpu_to_le32(PACKET3(PACKET3_SET_CONTEXT_REG
, ext
->reg_count
));
4582 buffer
[count
++] = cpu_to_le32(ext
->reg_index
- PACKET3_SET_CONTEXT_REG_START
);
4583 for (i
= 0; i
< ext
->reg_count
; i
++)
4584 buffer
[count
++] = cpu_to_le32(ext
->extent
[i
]);
4591 buffer
[count
++] = cpu_to_le32(PACKET3(PACKET3_SET_CONTEXT_REG
, 2));
4592 buffer
[count
++] = cpu_to_le32(mmPA_SC_RASTER_CONFIG
- PACKET3_SET_CONTEXT_REG_START
);
4593 switch (adev
->asic_type
) {
4595 buffer
[count
++] = cpu_to_le32(0x16000012);
4596 buffer
[count
++] = cpu_to_le32(0x00000000);
4599 buffer
[count
++] = cpu_to_le32(0x00000000); /* XXX */
4600 buffer
[count
++] = cpu_to_le32(0x00000000);
4604 buffer
[count
++] = cpu_to_le32(0x00000000); /* XXX */
4605 buffer
[count
++] = cpu_to_le32(0x00000000);
4608 buffer
[count
++] = cpu_to_le32(0x3a00161a);
4609 buffer
[count
++] = cpu_to_le32(0x0000002e);
4612 buffer
[count
++] = cpu_to_le32(0x00000000);
4613 buffer
[count
++] = cpu_to_le32(0x00000000);
4617 buffer
[count
++] = cpu_to_le32(PACKET3(PACKET3_PREAMBLE_CNTL
, 0));
4618 buffer
[count
++] = cpu_to_le32(PACKET3_PREAMBLE_END_CLEAR_STATE
);
4620 buffer
[count
++] = cpu_to_le32(PACKET3(PACKET3_CLEAR_STATE
, 0));
4621 buffer
[count
++] = cpu_to_le32(0);
4624 static void gfx_v7_0_init_pg(struct amdgpu_device
*adev
)
4626 if (adev
->pg_flags
& (AMDGPU_PG_SUPPORT_GFX_PG
|
4627 AMDGPU_PG_SUPPORT_GFX_SMG
|
4628 AMDGPU_PG_SUPPORT_GFX_DMG
|
4629 AMDGPU_PG_SUPPORT_CP
|
4630 AMDGPU_PG_SUPPORT_GDS
|
4631 AMDGPU_PG_SUPPORT_RLC_SMU_HS
)) {
4632 gfx_v7_0_enable_sclk_slowdown_on_pu(adev
, true);
4633 gfx_v7_0_enable_sclk_slowdown_on_pd(adev
, true);
4634 if (adev
->pg_flags
& AMDGPU_PG_SUPPORT_GFX_PG
) {
4635 gfx_v7_0_init_gfx_cgpg(adev
);
4636 gfx_v7_0_enable_cp_pg(adev
, true);
4637 gfx_v7_0_enable_gds_pg(adev
, true);
4639 gfx_v7_0_init_ao_cu_mask(adev
);
4640 gfx_v7_0_update_gfx_pg(adev
, true);
4644 static void gfx_v7_0_fini_pg(struct amdgpu_device
*adev
)
4646 if (adev
->pg_flags
& (AMDGPU_PG_SUPPORT_GFX_PG
|
4647 AMDGPU_PG_SUPPORT_GFX_SMG
|
4648 AMDGPU_PG_SUPPORT_GFX_DMG
|
4649 AMDGPU_PG_SUPPORT_CP
|
4650 AMDGPU_PG_SUPPORT_GDS
|
4651 AMDGPU_PG_SUPPORT_RLC_SMU_HS
)) {
4652 gfx_v7_0_update_gfx_pg(adev
, false);
4653 if (adev
->pg_flags
& AMDGPU_PG_SUPPORT_GFX_PG
) {
4654 gfx_v7_0_enable_cp_pg(adev
, false);
4655 gfx_v7_0_enable_gds_pg(adev
, false);
4661 * gfx_v7_0_get_gpu_clock_counter - return GPU clock counter snapshot
4663 * @adev: amdgpu_device pointer
4665 * Fetches a GPU clock counter snapshot (SI).
4666 * Returns the 64 bit clock counter snapshot.
4668 uint64_t gfx_v7_0_get_gpu_clock_counter(struct amdgpu_device
*adev
)
4672 mutex_lock(&adev
->gfx
.gpu_clock_mutex
);
4673 WREG32(mmRLC_CAPTURE_GPU_CLOCK_COUNT
, 1);
4674 clock
= (uint64_t)RREG32(mmRLC_GPU_CLOCK_COUNT_LSB
) |
4675 ((uint64_t)RREG32(mmRLC_GPU_CLOCK_COUNT_MSB
) << 32ULL);
4676 mutex_unlock(&adev
->gfx
.gpu_clock_mutex
);
4680 static void gfx_v7_0_ring_emit_gds_switch(struct amdgpu_ring
*ring
,
4682 uint32_t gds_base
, uint32_t gds_size
,
4683 uint32_t gws_base
, uint32_t gws_size
,
4684 uint32_t oa_base
, uint32_t oa_size
)
4686 gds_base
= gds_base
>> AMDGPU_GDS_SHIFT
;
4687 gds_size
= gds_size
>> AMDGPU_GDS_SHIFT
;
4689 gws_base
= gws_base
>> AMDGPU_GWS_SHIFT
;
4690 gws_size
= gws_size
>> AMDGPU_GWS_SHIFT
;
4692 oa_base
= oa_base
>> AMDGPU_OA_SHIFT
;
4693 oa_size
= oa_size
>> AMDGPU_OA_SHIFT
;
4696 amdgpu_ring_write(ring
, PACKET3(PACKET3_WRITE_DATA
, 3));
4697 amdgpu_ring_write(ring
, (WRITE_DATA_ENGINE_SEL(0) |
4698 WRITE_DATA_DST_SEL(0)));
4699 amdgpu_ring_write(ring
, amdgpu_gds_reg_offset
[vmid
].mem_base
);
4700 amdgpu_ring_write(ring
, 0);
4701 amdgpu_ring_write(ring
, gds_base
);
4704 amdgpu_ring_write(ring
, PACKET3(PACKET3_WRITE_DATA
, 3));
4705 amdgpu_ring_write(ring
, (WRITE_DATA_ENGINE_SEL(0) |
4706 WRITE_DATA_DST_SEL(0)));
4707 amdgpu_ring_write(ring
, amdgpu_gds_reg_offset
[vmid
].mem_size
);
4708 amdgpu_ring_write(ring
, 0);
4709 amdgpu_ring_write(ring
, gds_size
);
4712 amdgpu_ring_write(ring
, PACKET3(PACKET3_WRITE_DATA
, 3));
4713 amdgpu_ring_write(ring
, (WRITE_DATA_ENGINE_SEL(0) |
4714 WRITE_DATA_DST_SEL(0)));
4715 amdgpu_ring_write(ring
, amdgpu_gds_reg_offset
[vmid
].gws
);
4716 amdgpu_ring_write(ring
, 0);
4717 amdgpu_ring_write(ring
, gws_size
<< GDS_GWS_VMID0__SIZE__SHIFT
| gws_base
);
4720 amdgpu_ring_write(ring
, PACKET3(PACKET3_WRITE_DATA
, 3));
4721 amdgpu_ring_write(ring
, (WRITE_DATA_ENGINE_SEL(0) |
4722 WRITE_DATA_DST_SEL(0)));
4723 amdgpu_ring_write(ring
, amdgpu_gds_reg_offset
[vmid
].oa
);
4724 amdgpu_ring_write(ring
, 0);
4725 amdgpu_ring_write(ring
, (1 << (oa_size
+ oa_base
)) - (1 << oa_base
));
4728 static int gfx_v7_0_early_init(void *handle
)
4730 struct amdgpu_device
*adev
= (struct amdgpu_device
*)handle
;
4732 adev
->gfx
.num_gfx_rings
= GFX7_NUM_GFX_RINGS
;
4733 adev
->gfx
.num_compute_rings
= GFX7_NUM_COMPUTE_RINGS
;
4734 gfx_v7_0_set_ring_funcs(adev
);
4735 gfx_v7_0_set_irq_funcs(adev
);
4736 gfx_v7_0_set_gds_init(adev
);
4741 static int gfx_v7_0_sw_init(void *handle
)
4743 struct amdgpu_ring
*ring
;
4744 struct amdgpu_device
*adev
= (struct amdgpu_device
*)handle
;
4748 r
= amdgpu_irq_add_id(adev
, 181, &adev
->gfx
.eop_irq
);
4752 /* Privileged reg */
4753 r
= amdgpu_irq_add_id(adev
, 184, &adev
->gfx
.priv_reg_irq
);
4757 /* Privileged inst */
4758 r
= amdgpu_irq_add_id(adev
, 185, &adev
->gfx
.priv_inst_irq
);
4762 gfx_v7_0_scratch_init(adev
);
4764 r
= gfx_v7_0_init_microcode(adev
);
4766 DRM_ERROR("Failed to load gfx firmware!\n");
4770 r
= gfx_v7_0_rlc_init(adev
);
4772 DRM_ERROR("Failed to init rlc BOs!\n");
4776 /* allocate mec buffers */
4777 r
= gfx_v7_0_mec_init(adev
);
4779 DRM_ERROR("Failed to init MEC BOs!\n");
4783 for (i
= 0; i
< adev
->gfx
.num_gfx_rings
; i
++) {
4784 ring
= &adev
->gfx
.gfx_ring
[i
];
4785 ring
->ring_obj
= NULL
;
4786 sprintf(ring
->name
, "gfx");
4787 r
= amdgpu_ring_init(adev
, ring
, 1024 * 1024,
4788 PACKET3(PACKET3_NOP
, 0x3FFF), 0xf,
4789 &adev
->gfx
.eop_irq
, AMDGPU_CP_IRQ_GFX_EOP
,
4790 AMDGPU_RING_TYPE_GFX
);
4795 /* set up the compute queues */
4796 for (i
= 0; i
< adev
->gfx
.num_compute_rings
; i
++) {
4799 /* max 32 queues per MEC */
4800 if ((i
>= 32) || (i
>= AMDGPU_MAX_COMPUTE_RINGS
)) {
4801 DRM_ERROR("Too many (%d) compute rings!\n", i
);
4804 ring
= &adev
->gfx
.compute_ring
[i
];
4805 ring
->ring_obj
= NULL
;
4806 ring
->use_doorbell
= true;
4807 ring
->doorbell_index
= AMDGPU_DOORBELL_MEC_RING0
+ i
;
4808 ring
->me
= 1; /* first MEC */
4810 ring
->queue
= i
% 8;
4811 sprintf(ring
->name
, "comp %d.%d.%d", ring
->me
, ring
->pipe
, ring
->queue
);
4812 irq_type
= AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP
+ ring
->pipe
;
4813 /* type-2 packets are deprecated on MEC, use type-3 instead */
4814 r
= amdgpu_ring_init(adev
, ring
, 1024 * 1024,
4815 PACKET3(PACKET3_NOP
, 0x3FFF), 0xf,
4816 &adev
->gfx
.eop_irq
, irq_type
,
4817 AMDGPU_RING_TYPE_COMPUTE
);
4822 /* reserve GDS, GWS and OA resource for gfx */
4823 r
= amdgpu_bo_create(adev
, adev
->gds
.mem
.gfx_partition_size
,
4825 AMDGPU_GEM_DOMAIN_GDS
, 0,
4826 NULL
, NULL
, &adev
->gds
.gds_gfx_bo
);
4830 r
= amdgpu_bo_create(adev
, adev
->gds
.gws
.gfx_partition_size
,
4832 AMDGPU_GEM_DOMAIN_GWS
, 0,
4833 NULL
, NULL
, &adev
->gds
.gws_gfx_bo
);
4837 r
= amdgpu_bo_create(adev
, adev
->gds
.oa
.gfx_partition_size
,
4839 AMDGPU_GEM_DOMAIN_OA
, 0,
4840 NULL
, NULL
, &adev
->gds
.oa_gfx_bo
);
4847 static int gfx_v7_0_sw_fini(void *handle
)
4850 struct amdgpu_device
*adev
= (struct amdgpu_device
*)handle
;
4852 amdgpu_bo_unref(&adev
->gds
.oa_gfx_bo
);
4853 amdgpu_bo_unref(&adev
->gds
.gws_gfx_bo
);
4854 amdgpu_bo_unref(&adev
->gds
.gds_gfx_bo
);
4856 for (i
= 0; i
< adev
->gfx
.num_gfx_rings
; i
++)
4857 amdgpu_ring_fini(&adev
->gfx
.gfx_ring
[i
]);
4858 for (i
= 0; i
< adev
->gfx
.num_compute_rings
; i
++)
4859 amdgpu_ring_fini(&adev
->gfx
.compute_ring
[i
]);
4861 gfx_v7_0_cp_compute_fini(adev
);
4862 gfx_v7_0_rlc_fini(adev
);
4863 gfx_v7_0_mec_fini(adev
);
4868 static int gfx_v7_0_hw_init(void *handle
)
4871 struct amdgpu_device
*adev
= (struct amdgpu_device
*)handle
;
4873 gfx_v7_0_gpu_init(adev
);
4876 r
= gfx_v7_0_rlc_resume(adev
);
4880 r
= gfx_v7_0_cp_resume(adev
);
4884 adev
->gfx
.ce_ram_size
= 0x8000;
4889 static int gfx_v7_0_hw_fini(void *handle
)
4891 struct amdgpu_device
*adev
= (struct amdgpu_device
*)handle
;
4893 gfx_v7_0_cp_enable(adev
, false);
4894 gfx_v7_0_rlc_stop(adev
);
4895 gfx_v7_0_fini_pg(adev
);
4900 static int gfx_v7_0_suspend(void *handle
)
4902 struct amdgpu_device
*adev
= (struct amdgpu_device
*)handle
;
4904 return gfx_v7_0_hw_fini(adev
);
4907 static int gfx_v7_0_resume(void *handle
)
4909 struct amdgpu_device
*adev
= (struct amdgpu_device
*)handle
;
4911 return gfx_v7_0_hw_init(adev
);
4914 static bool gfx_v7_0_is_idle(void *handle
)
4916 struct amdgpu_device
*adev
= (struct amdgpu_device
*)handle
;
4918 if (RREG32(mmGRBM_STATUS
) & GRBM_STATUS__GUI_ACTIVE_MASK
)
4924 static int gfx_v7_0_wait_for_idle(void *handle
)
4928 struct amdgpu_device
*adev
= (struct amdgpu_device
*)handle
;
4930 for (i
= 0; i
< adev
->usec_timeout
; i
++) {
4931 /* read MC_STATUS */
4932 tmp
= RREG32(mmGRBM_STATUS
) & GRBM_STATUS__GUI_ACTIVE_MASK
;
4941 static void gfx_v7_0_print_status(void *handle
)
4944 struct amdgpu_device
*adev
= (struct amdgpu_device
*)handle
;
4946 dev_info(adev
->dev
, "GFX 7.x registers\n");
4947 dev_info(adev
->dev
, " GRBM_STATUS=0x%08X\n",
4948 RREG32(mmGRBM_STATUS
));
4949 dev_info(adev
->dev
, " GRBM_STATUS2=0x%08X\n",
4950 RREG32(mmGRBM_STATUS2
));
4951 dev_info(adev
->dev
, " GRBM_STATUS_SE0=0x%08X\n",
4952 RREG32(mmGRBM_STATUS_SE0
));
4953 dev_info(adev
->dev
, " GRBM_STATUS_SE1=0x%08X\n",
4954 RREG32(mmGRBM_STATUS_SE1
));
4955 dev_info(adev
->dev
, " GRBM_STATUS_SE2=0x%08X\n",
4956 RREG32(mmGRBM_STATUS_SE2
));
4957 dev_info(adev
->dev
, " GRBM_STATUS_SE3=0x%08X\n",
4958 RREG32(mmGRBM_STATUS_SE3
));
4959 dev_info(adev
->dev
, " CP_STAT = 0x%08x\n", RREG32(mmCP_STAT
));
4960 dev_info(adev
->dev
, " CP_STALLED_STAT1 = 0x%08x\n",
4961 RREG32(mmCP_STALLED_STAT1
));
4962 dev_info(adev
->dev
, " CP_STALLED_STAT2 = 0x%08x\n",
4963 RREG32(mmCP_STALLED_STAT2
));
4964 dev_info(adev
->dev
, " CP_STALLED_STAT3 = 0x%08x\n",
4965 RREG32(mmCP_STALLED_STAT3
));
4966 dev_info(adev
->dev
, " CP_CPF_BUSY_STAT = 0x%08x\n",
4967 RREG32(mmCP_CPF_BUSY_STAT
));
4968 dev_info(adev
->dev
, " CP_CPF_STALLED_STAT1 = 0x%08x\n",
4969 RREG32(mmCP_CPF_STALLED_STAT1
));
4970 dev_info(adev
->dev
, " CP_CPF_STATUS = 0x%08x\n", RREG32(mmCP_CPF_STATUS
));
4971 dev_info(adev
->dev
, " CP_CPC_BUSY_STAT = 0x%08x\n", RREG32(mmCP_CPC_BUSY_STAT
));
4972 dev_info(adev
->dev
, " CP_CPC_STALLED_STAT1 = 0x%08x\n",
4973 RREG32(mmCP_CPC_STALLED_STAT1
));
4974 dev_info(adev
->dev
, " CP_CPC_STATUS = 0x%08x\n", RREG32(mmCP_CPC_STATUS
));
4976 for (i
= 0; i
< 32; i
++) {
4977 dev_info(adev
->dev
, " GB_TILE_MODE%d=0x%08X\n",
4978 i
, RREG32(mmGB_TILE_MODE0
+ (i
* 4)));
4980 for (i
= 0; i
< 16; i
++) {
4981 dev_info(adev
->dev
, " GB_MACROTILE_MODE%d=0x%08X\n",
4982 i
, RREG32(mmGB_MACROTILE_MODE0
+ (i
* 4)));
4984 for (i
= 0; i
< adev
->gfx
.config
.max_shader_engines
; i
++) {
4985 dev_info(adev
->dev
, " se: %d\n", i
);
4986 gfx_v7_0_select_se_sh(adev
, i
, 0xffffffff);
4987 dev_info(adev
->dev
, " PA_SC_RASTER_CONFIG=0x%08X\n",
4988 RREG32(mmPA_SC_RASTER_CONFIG
));
4989 dev_info(adev
->dev
, " PA_SC_RASTER_CONFIG_1=0x%08X\n",
4990 RREG32(mmPA_SC_RASTER_CONFIG_1
));
4992 gfx_v7_0_select_se_sh(adev
, 0xffffffff, 0xffffffff);
4994 dev_info(adev
->dev
, " GB_ADDR_CONFIG=0x%08X\n",
4995 RREG32(mmGB_ADDR_CONFIG
));
4996 dev_info(adev
->dev
, " HDP_ADDR_CONFIG=0x%08X\n",
4997 RREG32(mmHDP_ADDR_CONFIG
));
4998 dev_info(adev
->dev
, " DMIF_ADDR_CALC=0x%08X\n",
4999 RREG32(mmDMIF_ADDR_CALC
));
5000 dev_info(adev
->dev
, " SDMA0_TILING_CONFIG=0x%08X\n",
5001 RREG32(mmSDMA0_TILING_CONFIG
+ SDMA0_REGISTER_OFFSET
));
5002 dev_info(adev
->dev
, " SDMA1_TILING_CONFIG=0x%08X\n",
5003 RREG32(mmSDMA0_TILING_CONFIG
+ SDMA1_REGISTER_OFFSET
));
5004 dev_info(adev
->dev
, " UVD_UDEC_ADDR_CONFIG=0x%08X\n",
5005 RREG32(mmUVD_UDEC_ADDR_CONFIG
));
5006 dev_info(adev
->dev
, " UVD_UDEC_DB_ADDR_CONFIG=0x%08X\n",
5007 RREG32(mmUVD_UDEC_DB_ADDR_CONFIG
));
5008 dev_info(adev
->dev
, " UVD_UDEC_DBW_ADDR_CONFIG=0x%08X\n",
5009 RREG32(mmUVD_UDEC_DBW_ADDR_CONFIG
));
5011 dev_info(adev
->dev
, " CP_MEQ_THRESHOLDS=0x%08X\n",
5012 RREG32(mmCP_MEQ_THRESHOLDS
));
5013 dev_info(adev
->dev
, " SX_DEBUG_1=0x%08X\n",
5014 RREG32(mmSX_DEBUG_1
));
5015 dev_info(adev
->dev
, " TA_CNTL_AUX=0x%08X\n",
5016 RREG32(mmTA_CNTL_AUX
));
5017 dev_info(adev
->dev
, " SPI_CONFIG_CNTL=0x%08X\n",
5018 RREG32(mmSPI_CONFIG_CNTL
));
5019 dev_info(adev
->dev
, " SQ_CONFIG=0x%08X\n",
5020 RREG32(mmSQ_CONFIG
));
5021 dev_info(adev
->dev
, " DB_DEBUG=0x%08X\n",
5022 RREG32(mmDB_DEBUG
));
5023 dev_info(adev
->dev
, " DB_DEBUG2=0x%08X\n",
5024 RREG32(mmDB_DEBUG2
));
5025 dev_info(adev
->dev
, " DB_DEBUG3=0x%08X\n",
5026 RREG32(mmDB_DEBUG3
));
5027 dev_info(adev
->dev
, " CB_HW_CONTROL=0x%08X\n",
5028 RREG32(mmCB_HW_CONTROL
));
5029 dev_info(adev
->dev
, " SPI_CONFIG_CNTL_1=0x%08X\n",
5030 RREG32(mmSPI_CONFIG_CNTL_1
));
5031 dev_info(adev
->dev
, " PA_SC_FIFO_SIZE=0x%08X\n",
5032 RREG32(mmPA_SC_FIFO_SIZE
));
5033 dev_info(adev
->dev
, " VGT_NUM_INSTANCES=0x%08X\n",
5034 RREG32(mmVGT_NUM_INSTANCES
));
5035 dev_info(adev
->dev
, " CP_PERFMON_CNTL=0x%08X\n",
5036 RREG32(mmCP_PERFMON_CNTL
));
5037 dev_info(adev
->dev
, " PA_SC_FORCE_EOV_MAX_CNTS=0x%08X\n",
5038 RREG32(mmPA_SC_FORCE_EOV_MAX_CNTS
));
5039 dev_info(adev
->dev
, " VGT_CACHE_INVALIDATION=0x%08X\n",
5040 RREG32(mmVGT_CACHE_INVALIDATION
));
5041 dev_info(adev
->dev
, " VGT_GS_VERTEX_REUSE=0x%08X\n",
5042 RREG32(mmVGT_GS_VERTEX_REUSE
));
5043 dev_info(adev
->dev
, " PA_SC_LINE_STIPPLE_STATE=0x%08X\n",
5044 RREG32(mmPA_SC_LINE_STIPPLE_STATE
));
5045 dev_info(adev
->dev
, " PA_CL_ENHANCE=0x%08X\n",
5046 RREG32(mmPA_CL_ENHANCE
));
5047 dev_info(adev
->dev
, " PA_SC_ENHANCE=0x%08X\n",
5048 RREG32(mmPA_SC_ENHANCE
));
5050 dev_info(adev
->dev
, " CP_ME_CNTL=0x%08X\n",
5051 RREG32(mmCP_ME_CNTL
));
5052 dev_info(adev
->dev
, " CP_MAX_CONTEXT=0x%08X\n",
5053 RREG32(mmCP_MAX_CONTEXT
));
5054 dev_info(adev
->dev
, " CP_ENDIAN_SWAP=0x%08X\n",
5055 RREG32(mmCP_ENDIAN_SWAP
));
5056 dev_info(adev
->dev
, " CP_DEVICE_ID=0x%08X\n",
5057 RREG32(mmCP_DEVICE_ID
));
5059 dev_info(adev
->dev
, " CP_SEM_WAIT_TIMER=0x%08X\n",
5060 RREG32(mmCP_SEM_WAIT_TIMER
));
5061 if (adev
->asic_type
!= CHIP_HAWAII
)
5062 dev_info(adev
->dev
, " CP_SEM_INCOMPLETE_TIMER_CNTL=0x%08X\n",
5063 RREG32(mmCP_SEM_INCOMPLETE_TIMER_CNTL
));
5065 dev_info(adev
->dev
, " CP_RB_WPTR_DELAY=0x%08X\n",
5066 RREG32(mmCP_RB_WPTR_DELAY
));
5067 dev_info(adev
->dev
, " CP_RB_VMID=0x%08X\n",
5068 RREG32(mmCP_RB_VMID
));
5069 dev_info(adev
->dev
, " CP_RB0_CNTL=0x%08X\n",
5070 RREG32(mmCP_RB0_CNTL
));
5071 dev_info(adev
->dev
, " CP_RB0_WPTR=0x%08X\n",
5072 RREG32(mmCP_RB0_WPTR
));
5073 dev_info(adev
->dev
, " CP_RB0_RPTR_ADDR=0x%08X\n",
5074 RREG32(mmCP_RB0_RPTR_ADDR
));
5075 dev_info(adev
->dev
, " CP_RB0_RPTR_ADDR_HI=0x%08X\n",
5076 RREG32(mmCP_RB0_RPTR_ADDR_HI
));
5077 dev_info(adev
->dev
, " CP_RB0_CNTL=0x%08X\n",
5078 RREG32(mmCP_RB0_CNTL
));
5079 dev_info(adev
->dev
, " CP_RB0_BASE=0x%08X\n",
5080 RREG32(mmCP_RB0_BASE
));
5081 dev_info(adev
->dev
, " CP_RB0_BASE_HI=0x%08X\n",
5082 RREG32(mmCP_RB0_BASE_HI
));
5083 dev_info(adev
->dev
, " CP_MEC_CNTL=0x%08X\n",
5084 RREG32(mmCP_MEC_CNTL
));
5085 dev_info(adev
->dev
, " CP_CPF_DEBUG=0x%08X\n",
5086 RREG32(mmCP_CPF_DEBUG
));
5088 dev_info(adev
->dev
, " SCRATCH_ADDR=0x%08X\n",
5089 RREG32(mmSCRATCH_ADDR
));
5090 dev_info(adev
->dev
, " SCRATCH_UMSK=0x%08X\n",
5091 RREG32(mmSCRATCH_UMSK
));
5093 /* init the pipes */
5094 mutex_lock(&adev
->srbm_mutex
);
5095 for (i
= 0; i
< (adev
->gfx
.mec
.num_pipe
* adev
->gfx
.mec
.num_mec
); i
++) {
5096 int me
= (i
< 4) ? 1 : 2;
5097 int pipe
= (i
< 4) ? i
: (i
- 4);
5100 dev_info(adev
->dev
, " me: %d, pipe: %d\n", me
, pipe
);
5101 cik_srbm_select(adev
, me
, pipe
, 0, 0);
5102 dev_info(adev
->dev
, " CP_HPD_EOP_BASE_ADDR=0x%08X\n",
5103 RREG32(mmCP_HPD_EOP_BASE_ADDR
));
5104 dev_info(adev
->dev
, " CP_HPD_EOP_BASE_ADDR_HI=0x%08X\n",
5105 RREG32(mmCP_HPD_EOP_BASE_ADDR_HI
));
5106 dev_info(adev
->dev
, " CP_HPD_EOP_VMID=0x%08X\n",
5107 RREG32(mmCP_HPD_EOP_VMID
));
5108 dev_info(adev
->dev
, " CP_HPD_EOP_CONTROL=0x%08X\n",
5109 RREG32(mmCP_HPD_EOP_CONTROL
));
5111 for (queue
= 0; queue
< 8; queue
++) {
5112 cik_srbm_select(adev
, me
, pipe
, queue
, 0);
5113 dev_info(adev
->dev
, " queue: %d\n", queue
);
5114 dev_info(adev
->dev
, " CP_PQ_WPTR_POLL_CNTL=0x%08X\n",
5115 RREG32(mmCP_PQ_WPTR_POLL_CNTL
));
5116 dev_info(adev
->dev
, " CP_HQD_PQ_DOORBELL_CONTROL=0x%08X\n",
5117 RREG32(mmCP_HQD_PQ_DOORBELL_CONTROL
));
5118 dev_info(adev
->dev
, " CP_HQD_ACTIVE=0x%08X\n",
5119 RREG32(mmCP_HQD_ACTIVE
));
5120 dev_info(adev
->dev
, " CP_HQD_DEQUEUE_REQUEST=0x%08X\n",
5121 RREG32(mmCP_HQD_DEQUEUE_REQUEST
));
5122 dev_info(adev
->dev
, " CP_HQD_PQ_RPTR=0x%08X\n",
5123 RREG32(mmCP_HQD_PQ_RPTR
));
5124 dev_info(adev
->dev
, " CP_HQD_PQ_WPTR=0x%08X\n",
5125 RREG32(mmCP_HQD_PQ_WPTR
));
5126 dev_info(adev
->dev
, " CP_HQD_PQ_BASE=0x%08X\n",
5127 RREG32(mmCP_HQD_PQ_BASE
));
5128 dev_info(adev
->dev
, " CP_HQD_PQ_BASE_HI=0x%08X\n",
5129 RREG32(mmCP_HQD_PQ_BASE_HI
));
5130 dev_info(adev
->dev
, " CP_HQD_PQ_CONTROL=0x%08X\n",
5131 RREG32(mmCP_HQD_PQ_CONTROL
));
5132 dev_info(adev
->dev
, " CP_HQD_PQ_WPTR_POLL_ADDR=0x%08X\n",
5133 RREG32(mmCP_HQD_PQ_WPTR_POLL_ADDR
));
5134 dev_info(adev
->dev
, " CP_HQD_PQ_WPTR_POLL_ADDR_HI=0x%08X\n",
5135 RREG32(mmCP_HQD_PQ_WPTR_POLL_ADDR_HI
));
5136 dev_info(adev
->dev
, " CP_HQD_PQ_RPTR_REPORT_ADDR=0x%08X\n",
5137 RREG32(mmCP_HQD_PQ_RPTR_REPORT_ADDR
));
5138 dev_info(adev
->dev
, " CP_HQD_PQ_RPTR_REPORT_ADDR_HI=0x%08X\n",
5139 RREG32(mmCP_HQD_PQ_RPTR_REPORT_ADDR_HI
));
5140 dev_info(adev
->dev
, " CP_HQD_PQ_DOORBELL_CONTROL=0x%08X\n",
5141 RREG32(mmCP_HQD_PQ_DOORBELL_CONTROL
));
5142 dev_info(adev
->dev
, " CP_HQD_PQ_WPTR=0x%08X\n",
5143 RREG32(mmCP_HQD_PQ_WPTR
));
5144 dev_info(adev
->dev
, " CP_HQD_VMID=0x%08X\n",
5145 RREG32(mmCP_HQD_VMID
));
5146 dev_info(adev
->dev
, " CP_MQD_BASE_ADDR=0x%08X\n",
5147 RREG32(mmCP_MQD_BASE_ADDR
));
5148 dev_info(adev
->dev
, " CP_MQD_BASE_ADDR_HI=0x%08X\n",
5149 RREG32(mmCP_MQD_BASE_ADDR_HI
));
5150 dev_info(adev
->dev
, " CP_MQD_CONTROL=0x%08X\n",
5151 RREG32(mmCP_MQD_CONTROL
));
5154 cik_srbm_select(adev
, 0, 0, 0, 0);
5155 mutex_unlock(&adev
->srbm_mutex
);
5157 dev_info(adev
->dev
, " CP_INT_CNTL_RING0=0x%08X\n",
5158 RREG32(mmCP_INT_CNTL_RING0
));
5159 dev_info(adev
->dev
, " RLC_LB_CNTL=0x%08X\n",
5160 RREG32(mmRLC_LB_CNTL
));
5161 dev_info(adev
->dev
, " RLC_CNTL=0x%08X\n",
5162 RREG32(mmRLC_CNTL
));
5163 dev_info(adev
->dev
, " RLC_CGCG_CGLS_CTRL=0x%08X\n",
5164 RREG32(mmRLC_CGCG_CGLS_CTRL
));
5165 dev_info(adev
->dev
, " RLC_LB_CNTR_INIT=0x%08X\n",
5166 RREG32(mmRLC_LB_CNTR_INIT
));
5167 dev_info(adev
->dev
, " RLC_LB_CNTR_MAX=0x%08X\n",
5168 RREG32(mmRLC_LB_CNTR_MAX
));
5169 dev_info(adev
->dev
, " RLC_LB_INIT_CU_MASK=0x%08X\n",
5170 RREG32(mmRLC_LB_INIT_CU_MASK
));
5171 dev_info(adev
->dev
, " RLC_LB_PARAMS=0x%08X\n",
5172 RREG32(mmRLC_LB_PARAMS
));
5173 dev_info(adev
->dev
, " RLC_LB_CNTL=0x%08X\n",
5174 RREG32(mmRLC_LB_CNTL
));
5175 dev_info(adev
->dev
, " RLC_MC_CNTL=0x%08X\n",
5176 RREG32(mmRLC_MC_CNTL
));
5177 dev_info(adev
->dev
, " RLC_UCODE_CNTL=0x%08X\n",
5178 RREG32(mmRLC_UCODE_CNTL
));
5180 if (adev
->asic_type
== CHIP_BONAIRE
)
5181 dev_info(adev
->dev
, " RLC_DRIVER_CPDMA_STATUS=0x%08X\n",
5182 RREG32(mmRLC_DRIVER_CPDMA_STATUS
));
5184 mutex_lock(&adev
->srbm_mutex
);
5185 for (i
= 0; i
< 16; i
++) {
5186 cik_srbm_select(adev
, 0, 0, 0, i
);
5187 dev_info(adev
->dev
, " VM %d:\n", i
);
5188 dev_info(adev
->dev
, " SH_MEM_CONFIG=0x%08X\n",
5189 RREG32(mmSH_MEM_CONFIG
));
5190 dev_info(adev
->dev
, " SH_MEM_APE1_BASE=0x%08X\n",
5191 RREG32(mmSH_MEM_APE1_BASE
));
5192 dev_info(adev
->dev
, " SH_MEM_APE1_LIMIT=0x%08X\n",
5193 RREG32(mmSH_MEM_APE1_LIMIT
));
5194 dev_info(adev
->dev
, " SH_MEM_BASES=0x%08X\n",
5195 RREG32(mmSH_MEM_BASES
));
5197 cik_srbm_select(adev
, 0, 0, 0, 0);
5198 mutex_unlock(&adev
->srbm_mutex
);
5201 static int gfx_v7_0_soft_reset(void *handle
)
5203 u32 grbm_soft_reset
= 0, srbm_soft_reset
= 0;
5205 struct amdgpu_device
*adev
= (struct amdgpu_device
*)handle
;
5208 tmp
= RREG32(mmGRBM_STATUS
);
5209 if (tmp
& (GRBM_STATUS__PA_BUSY_MASK
| GRBM_STATUS__SC_BUSY_MASK
|
5210 GRBM_STATUS__BCI_BUSY_MASK
| GRBM_STATUS__SX_BUSY_MASK
|
5211 GRBM_STATUS__TA_BUSY_MASK
| GRBM_STATUS__VGT_BUSY_MASK
|
5212 GRBM_STATUS__DB_BUSY_MASK
| GRBM_STATUS__CB_BUSY_MASK
|
5213 GRBM_STATUS__GDS_BUSY_MASK
| GRBM_STATUS__SPI_BUSY_MASK
|
5214 GRBM_STATUS__IA_BUSY_MASK
| GRBM_STATUS__IA_BUSY_NO_DMA_MASK
))
5215 grbm_soft_reset
|= GRBM_SOFT_RESET__SOFT_RESET_CP_MASK
|
5216 GRBM_SOFT_RESET__SOFT_RESET_GFX_MASK
;
5218 if (tmp
& (GRBM_STATUS__CP_BUSY_MASK
| GRBM_STATUS__CP_COHERENCY_BUSY_MASK
)) {
5219 grbm_soft_reset
|= GRBM_SOFT_RESET__SOFT_RESET_CP_MASK
;
5220 srbm_soft_reset
|= SRBM_SOFT_RESET__SOFT_RESET_GRBM_MASK
;
5224 tmp
= RREG32(mmGRBM_STATUS2
);
5225 if (tmp
& GRBM_STATUS2__RLC_BUSY_MASK
)
5226 grbm_soft_reset
|= GRBM_SOFT_RESET__SOFT_RESET_RLC_MASK
;
5229 tmp
= RREG32(mmSRBM_STATUS
);
5230 if (tmp
& SRBM_STATUS__GRBM_RQ_PENDING_MASK
)
5231 srbm_soft_reset
|= SRBM_SOFT_RESET__SOFT_RESET_GRBM_MASK
;
5233 if (grbm_soft_reset
|| srbm_soft_reset
) {
5234 gfx_v7_0_print_status((void *)adev
);
5236 gfx_v7_0_fini_pg(adev
);
5237 gfx_v7_0_update_cg(adev
, false);
5240 gfx_v7_0_rlc_stop(adev
);
5242 /* Disable GFX parsing/prefetching */
5243 WREG32(mmCP_ME_CNTL
, CP_ME_CNTL__ME_HALT_MASK
| CP_ME_CNTL__PFP_HALT_MASK
| CP_ME_CNTL__CE_HALT_MASK
);
5245 /* Disable MEC parsing/prefetching */
5246 WREG32(mmCP_MEC_CNTL
, CP_MEC_CNTL__MEC_ME1_HALT_MASK
| CP_MEC_CNTL__MEC_ME2_HALT_MASK
);
5248 if (grbm_soft_reset
) {
5249 tmp
= RREG32(mmGRBM_SOFT_RESET
);
5250 tmp
|= grbm_soft_reset
;
5251 dev_info(adev
->dev
, "GRBM_SOFT_RESET=0x%08X\n", tmp
);
5252 WREG32(mmGRBM_SOFT_RESET
, tmp
);
5253 tmp
= RREG32(mmGRBM_SOFT_RESET
);
5257 tmp
&= ~grbm_soft_reset
;
5258 WREG32(mmGRBM_SOFT_RESET
, tmp
);
5259 tmp
= RREG32(mmGRBM_SOFT_RESET
);
5262 if (srbm_soft_reset
) {
5263 tmp
= RREG32(mmSRBM_SOFT_RESET
);
5264 tmp
|= srbm_soft_reset
;
5265 dev_info(adev
->dev
, "SRBM_SOFT_RESET=0x%08X\n", tmp
);
5266 WREG32(mmSRBM_SOFT_RESET
, tmp
);
5267 tmp
= RREG32(mmSRBM_SOFT_RESET
);
5271 tmp
&= ~srbm_soft_reset
;
5272 WREG32(mmSRBM_SOFT_RESET
, tmp
);
5273 tmp
= RREG32(mmSRBM_SOFT_RESET
);
5275 /* Wait a little for things to settle down */
5277 gfx_v7_0_print_status((void *)adev
);
5282 static void gfx_v7_0_set_gfx_eop_interrupt_state(struct amdgpu_device
*adev
,
5283 enum amdgpu_interrupt_state state
)
5288 case AMDGPU_IRQ_STATE_DISABLE
:
5289 cp_int_cntl
= RREG32(mmCP_INT_CNTL_RING0
);
5290 cp_int_cntl
&= ~CP_INT_CNTL_RING0__TIME_STAMP_INT_ENABLE_MASK
;
5291 WREG32(mmCP_INT_CNTL_RING0
, cp_int_cntl
);
5293 case AMDGPU_IRQ_STATE_ENABLE
:
5294 cp_int_cntl
= RREG32(mmCP_INT_CNTL_RING0
);
5295 cp_int_cntl
|= CP_INT_CNTL_RING0__TIME_STAMP_INT_ENABLE_MASK
;
5296 WREG32(mmCP_INT_CNTL_RING0
, cp_int_cntl
);
5303 static void gfx_v7_0_set_compute_eop_interrupt_state(struct amdgpu_device
*adev
,
5305 enum amdgpu_interrupt_state state
)
5307 u32 mec_int_cntl
, mec_int_cntl_reg
;
5310 * amdgpu controls only pipe 0 of MEC1. That's why this function only
5311 * handles the setting of interrupts for this specific pipe. All other
5312 * pipes' interrupts are set by amdkfd.
5318 mec_int_cntl_reg
= mmCP_ME1_PIPE0_INT_CNTL
;
5321 DRM_DEBUG("invalid pipe %d\n", pipe
);
5325 DRM_DEBUG("invalid me %d\n", me
);
5330 case AMDGPU_IRQ_STATE_DISABLE
:
5331 mec_int_cntl
= RREG32(mec_int_cntl_reg
);
5332 mec_int_cntl
&= ~CP_INT_CNTL_RING0__TIME_STAMP_INT_ENABLE_MASK
;
5333 WREG32(mec_int_cntl_reg
, mec_int_cntl
);
5335 case AMDGPU_IRQ_STATE_ENABLE
:
5336 mec_int_cntl
= RREG32(mec_int_cntl_reg
);
5337 mec_int_cntl
|= CP_INT_CNTL_RING0__TIME_STAMP_INT_ENABLE_MASK
;
5338 WREG32(mec_int_cntl_reg
, mec_int_cntl
);
5345 static int gfx_v7_0_set_priv_reg_fault_state(struct amdgpu_device
*adev
,
5346 struct amdgpu_irq_src
*src
,
5348 enum amdgpu_interrupt_state state
)
5353 case AMDGPU_IRQ_STATE_DISABLE
:
5354 cp_int_cntl
= RREG32(mmCP_INT_CNTL_RING0
);
5355 cp_int_cntl
&= ~CP_INT_CNTL_RING0__PRIV_REG_INT_ENABLE_MASK
;
5356 WREG32(mmCP_INT_CNTL_RING0
, cp_int_cntl
);
5358 case AMDGPU_IRQ_STATE_ENABLE
:
5359 cp_int_cntl
= RREG32(mmCP_INT_CNTL_RING0
);
5360 cp_int_cntl
|= CP_INT_CNTL_RING0__PRIV_REG_INT_ENABLE_MASK
;
5361 WREG32(mmCP_INT_CNTL_RING0
, cp_int_cntl
);
5370 static int gfx_v7_0_set_priv_inst_fault_state(struct amdgpu_device
*adev
,
5371 struct amdgpu_irq_src
*src
,
5373 enum amdgpu_interrupt_state state
)
5378 case AMDGPU_IRQ_STATE_DISABLE
:
5379 cp_int_cntl
= RREG32(mmCP_INT_CNTL_RING0
);
5380 cp_int_cntl
&= ~CP_INT_CNTL_RING0__PRIV_INSTR_INT_ENABLE_MASK
;
5381 WREG32(mmCP_INT_CNTL_RING0
, cp_int_cntl
);
5383 case AMDGPU_IRQ_STATE_ENABLE
:
5384 cp_int_cntl
= RREG32(mmCP_INT_CNTL_RING0
);
5385 cp_int_cntl
|= CP_INT_CNTL_RING0__PRIV_INSTR_INT_ENABLE_MASK
;
5386 WREG32(mmCP_INT_CNTL_RING0
, cp_int_cntl
);
5395 static int gfx_v7_0_set_eop_interrupt_state(struct amdgpu_device
*adev
,
5396 struct amdgpu_irq_src
*src
,
5398 enum amdgpu_interrupt_state state
)
5401 case AMDGPU_CP_IRQ_GFX_EOP
:
5402 gfx_v7_0_set_gfx_eop_interrupt_state(adev
, state
);
5404 case AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP
:
5405 gfx_v7_0_set_compute_eop_interrupt_state(adev
, 1, 0, state
);
5407 case AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE1_EOP
:
5408 gfx_v7_0_set_compute_eop_interrupt_state(adev
, 1, 1, state
);
5410 case AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE2_EOP
:
5411 gfx_v7_0_set_compute_eop_interrupt_state(adev
, 1, 2, state
);
5413 case AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE3_EOP
:
5414 gfx_v7_0_set_compute_eop_interrupt_state(adev
, 1, 3, state
);
5416 case AMDGPU_CP_IRQ_COMPUTE_MEC2_PIPE0_EOP
:
5417 gfx_v7_0_set_compute_eop_interrupt_state(adev
, 2, 0, state
);
5419 case AMDGPU_CP_IRQ_COMPUTE_MEC2_PIPE1_EOP
:
5420 gfx_v7_0_set_compute_eop_interrupt_state(adev
, 2, 1, state
);
5422 case AMDGPU_CP_IRQ_COMPUTE_MEC2_PIPE2_EOP
:
5423 gfx_v7_0_set_compute_eop_interrupt_state(adev
, 2, 2, state
);
5425 case AMDGPU_CP_IRQ_COMPUTE_MEC2_PIPE3_EOP
:
5426 gfx_v7_0_set_compute_eop_interrupt_state(adev
, 2, 3, state
);
5434 static int gfx_v7_0_eop_irq(struct amdgpu_device
*adev
,
5435 struct amdgpu_irq_src
*source
,
5436 struct amdgpu_iv_entry
*entry
)
5439 struct amdgpu_ring
*ring
;
5442 DRM_DEBUG("IH: CP EOP\n");
5443 me_id
= (entry
->ring_id
& 0x0c) >> 2;
5444 pipe_id
= (entry
->ring_id
& 0x03) >> 0;
5447 amdgpu_fence_process(&adev
->gfx
.gfx_ring
[0]);
5451 for (i
= 0; i
< adev
->gfx
.num_compute_rings
; i
++) {
5452 ring
= &adev
->gfx
.compute_ring
[i
];
5453 if ((ring
->me
== me_id
) & (ring
->pipe
== pipe_id
))
5454 amdgpu_fence_process(ring
);
5461 static int gfx_v7_0_priv_reg_irq(struct amdgpu_device
*adev
,
5462 struct amdgpu_irq_src
*source
,
5463 struct amdgpu_iv_entry
*entry
)
5465 DRM_ERROR("Illegal register access in command stream\n");
5466 schedule_work(&adev
->reset_work
);
5470 static int gfx_v7_0_priv_inst_irq(struct amdgpu_device
*adev
,
5471 struct amdgpu_irq_src
*source
,
5472 struct amdgpu_iv_entry
*entry
)
5474 DRM_ERROR("Illegal instruction in command stream\n");
5475 // XXX soft reset the gfx block only
5476 schedule_work(&adev
->reset_work
);
5480 static int gfx_v7_0_set_clockgating_state(void *handle
,
5481 enum amd_clockgating_state state
)
5484 struct amdgpu_device
*adev
= (struct amdgpu_device
*)handle
;
5486 if (state
== AMD_CG_STATE_GATE
)
5489 gfx_v7_0_enable_gui_idle_interrupt(adev
, false);
5490 /* order matters! */
5492 gfx_v7_0_enable_mgcg(adev
, true);
5493 gfx_v7_0_enable_cgcg(adev
, true);
5495 gfx_v7_0_enable_cgcg(adev
, false);
5496 gfx_v7_0_enable_mgcg(adev
, false);
5498 gfx_v7_0_enable_gui_idle_interrupt(adev
, true);
5503 static int gfx_v7_0_set_powergating_state(void *handle
,
5504 enum amd_powergating_state state
)
5507 struct amdgpu_device
*adev
= (struct amdgpu_device
*)handle
;
5509 if (state
== AMD_PG_STATE_GATE
)
5512 if (adev
->pg_flags
& (AMDGPU_PG_SUPPORT_GFX_PG
|
5513 AMDGPU_PG_SUPPORT_GFX_SMG
|
5514 AMDGPU_PG_SUPPORT_GFX_DMG
|
5515 AMDGPU_PG_SUPPORT_CP
|
5516 AMDGPU_PG_SUPPORT_GDS
|
5517 AMDGPU_PG_SUPPORT_RLC_SMU_HS
)) {
5518 gfx_v7_0_update_gfx_pg(adev
, gate
);
5519 if (adev
->pg_flags
& AMDGPU_PG_SUPPORT_GFX_PG
) {
5520 gfx_v7_0_enable_cp_pg(adev
, gate
);
5521 gfx_v7_0_enable_gds_pg(adev
, gate
);
5528 const struct amd_ip_funcs gfx_v7_0_ip_funcs
= {
5529 .early_init
= gfx_v7_0_early_init
,
5531 .sw_init
= gfx_v7_0_sw_init
,
5532 .sw_fini
= gfx_v7_0_sw_fini
,
5533 .hw_init
= gfx_v7_0_hw_init
,
5534 .hw_fini
= gfx_v7_0_hw_fini
,
5535 .suspend
= gfx_v7_0_suspend
,
5536 .resume
= gfx_v7_0_resume
,
5537 .is_idle
= gfx_v7_0_is_idle
,
5538 .wait_for_idle
= gfx_v7_0_wait_for_idle
,
5539 .soft_reset
= gfx_v7_0_soft_reset
,
5540 .print_status
= gfx_v7_0_print_status
,
5541 .set_clockgating_state
= gfx_v7_0_set_clockgating_state
,
5542 .set_powergating_state
= gfx_v7_0_set_powergating_state
,
5545 static const struct amdgpu_ring_funcs gfx_v7_0_ring_funcs_gfx
= {
5546 .get_rptr
= gfx_v7_0_ring_get_rptr_gfx
,
5547 .get_wptr
= gfx_v7_0_ring_get_wptr_gfx
,
5548 .set_wptr
= gfx_v7_0_ring_set_wptr_gfx
,
5550 .emit_ib
= gfx_v7_0_ring_emit_ib_gfx
,
5551 .emit_fence
= gfx_v7_0_ring_emit_fence_gfx
,
5552 .emit_semaphore
= gfx_v7_0_ring_emit_semaphore
,
5553 .emit_vm_flush
= gfx_v7_0_ring_emit_vm_flush
,
5554 .emit_gds_switch
= gfx_v7_0_ring_emit_gds_switch
,
5555 .emit_hdp_flush
= gfx_v7_0_ring_emit_hdp_flush
,
5556 .test_ring
= gfx_v7_0_ring_test_ring
,
5557 .test_ib
= gfx_v7_0_ring_test_ib
,
5558 .insert_nop
= amdgpu_ring_insert_nop
,
5561 static const struct amdgpu_ring_funcs gfx_v7_0_ring_funcs_compute
= {
5562 .get_rptr
= gfx_v7_0_ring_get_rptr_compute
,
5563 .get_wptr
= gfx_v7_0_ring_get_wptr_compute
,
5564 .set_wptr
= gfx_v7_0_ring_set_wptr_compute
,
5566 .emit_ib
= gfx_v7_0_ring_emit_ib_compute
,
5567 .emit_fence
= gfx_v7_0_ring_emit_fence_compute
,
5568 .emit_semaphore
= gfx_v7_0_ring_emit_semaphore
,
5569 .emit_vm_flush
= gfx_v7_0_ring_emit_vm_flush
,
5570 .emit_gds_switch
= gfx_v7_0_ring_emit_gds_switch
,
5571 .emit_hdp_flush
= gfx_v7_0_ring_emit_hdp_flush
,
5572 .test_ring
= gfx_v7_0_ring_test_ring
,
5573 .test_ib
= gfx_v7_0_ring_test_ib
,
5574 .insert_nop
= amdgpu_ring_insert_nop
,
5577 static void gfx_v7_0_set_ring_funcs(struct amdgpu_device
*adev
)
5581 for (i
= 0; i
< adev
->gfx
.num_gfx_rings
; i
++)
5582 adev
->gfx
.gfx_ring
[i
].funcs
= &gfx_v7_0_ring_funcs_gfx
;
5583 for (i
= 0; i
< adev
->gfx
.num_compute_rings
; i
++)
5584 adev
->gfx
.compute_ring
[i
].funcs
= &gfx_v7_0_ring_funcs_compute
;
5587 static const struct amdgpu_irq_src_funcs gfx_v7_0_eop_irq_funcs
= {
5588 .set
= gfx_v7_0_set_eop_interrupt_state
,
5589 .process
= gfx_v7_0_eop_irq
,
5592 static const struct amdgpu_irq_src_funcs gfx_v7_0_priv_reg_irq_funcs
= {
5593 .set
= gfx_v7_0_set_priv_reg_fault_state
,
5594 .process
= gfx_v7_0_priv_reg_irq
,
5597 static const struct amdgpu_irq_src_funcs gfx_v7_0_priv_inst_irq_funcs
= {
5598 .set
= gfx_v7_0_set_priv_inst_fault_state
,
5599 .process
= gfx_v7_0_priv_inst_irq
,
5602 static void gfx_v7_0_set_irq_funcs(struct amdgpu_device
*adev
)
5604 adev
->gfx
.eop_irq
.num_types
= AMDGPU_CP_IRQ_LAST
;
5605 adev
->gfx
.eop_irq
.funcs
= &gfx_v7_0_eop_irq_funcs
;
5607 adev
->gfx
.priv_reg_irq
.num_types
= 1;
5608 adev
->gfx
.priv_reg_irq
.funcs
= &gfx_v7_0_priv_reg_irq_funcs
;
5610 adev
->gfx
.priv_inst_irq
.num_types
= 1;
5611 adev
->gfx
.priv_inst_irq
.funcs
= &gfx_v7_0_priv_inst_irq_funcs
;
5614 static void gfx_v7_0_set_gds_init(struct amdgpu_device
*adev
)
5616 /* init asci gds info */
5617 adev
->gds
.mem
.total_size
= RREG32(mmGDS_VMID0_SIZE
);
5618 adev
->gds
.gws
.total_size
= 64;
5619 adev
->gds
.oa
.total_size
= 16;
5621 if (adev
->gds
.mem
.total_size
== 64 * 1024) {
5622 adev
->gds
.mem
.gfx_partition_size
= 4096;
5623 adev
->gds
.mem
.cs_partition_size
= 4096;
5625 adev
->gds
.gws
.gfx_partition_size
= 4;
5626 adev
->gds
.gws
.cs_partition_size
= 4;
5628 adev
->gds
.oa
.gfx_partition_size
= 4;
5629 adev
->gds
.oa
.cs_partition_size
= 1;
5631 adev
->gds
.mem
.gfx_partition_size
= 1024;
5632 adev
->gds
.mem
.cs_partition_size
= 1024;
5634 adev
->gds
.gws
.gfx_partition_size
= 16;
5635 adev
->gds
.gws
.cs_partition_size
= 16;
5637 adev
->gds
.oa
.gfx_partition_size
= 4;
5638 adev
->gds
.oa
.cs_partition_size
= 4;
5643 int gfx_v7_0_get_cu_info(struct amdgpu_device
*adev
,
5644 struct amdgpu_cu_info
*cu_info
)
5646 int i
, j
, k
, counter
, active_cu_number
= 0;
5647 u32 mask
, bitmap
, ao_bitmap
, ao_cu_mask
= 0;
5649 if (!adev
|| !cu_info
)
5652 mutex_lock(&adev
->grbm_idx_mutex
);
5653 for (i
= 0; i
< adev
->gfx
.config
.max_shader_engines
; i
++) {
5654 for (j
= 0; j
< adev
->gfx
.config
.max_sh_per_se
; j
++) {
5658 bitmap
= gfx_v7_0_get_cu_active_bitmap(adev
, i
, j
);
5659 cu_info
->bitmap
[i
][j
] = bitmap
;
5661 for (k
= 0; k
< adev
->gfx
.config
.max_cu_per_sh
; k
++) {
5662 if (bitmap
& mask
) {
5669 active_cu_number
+= counter
;
5670 ao_cu_mask
|= (ao_bitmap
<< (i
* 16 + j
* 8));
5674 cu_info
->number
= active_cu_number
;
5675 cu_info
->ao_cu_mask
= ao_cu_mask
;
5676 mutex_unlock(&adev
->grbm_idx_mutex
);