2 * Copyright 2012 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.
22 * Authors: Alex Deucher
24 #include <linux/firmware.h>
25 #include <linux/slab.h>
26 #include <linux/module.h>
29 #include "radeon_asic.h"
30 #include "radeon_audio.h"
33 #include "cik_blit_shaders.h"
34 #include "radeon_ucode.h"
35 #include "clearstate_ci.h"
36 #include "radeon_kfd.h"
38 MODULE_FIRMWARE("radeon/BONAIRE_pfp.bin");
39 MODULE_FIRMWARE("radeon/BONAIRE_me.bin");
40 MODULE_FIRMWARE("radeon/BONAIRE_ce.bin");
41 MODULE_FIRMWARE("radeon/BONAIRE_mec.bin");
42 MODULE_FIRMWARE("radeon/BONAIRE_mc.bin");
43 MODULE_FIRMWARE("radeon/BONAIRE_mc2.bin");
44 MODULE_FIRMWARE("radeon/BONAIRE_rlc.bin");
45 MODULE_FIRMWARE("radeon/BONAIRE_sdma.bin");
46 MODULE_FIRMWARE("radeon/BONAIRE_smc.bin");
48 MODULE_FIRMWARE("radeon/bonaire_pfp.bin");
49 MODULE_FIRMWARE("radeon/bonaire_me.bin");
50 MODULE_FIRMWARE("radeon/bonaire_ce.bin");
51 MODULE_FIRMWARE("radeon/bonaire_mec.bin");
52 MODULE_FIRMWARE("radeon/bonaire_mc.bin");
53 MODULE_FIRMWARE("radeon/bonaire_rlc.bin");
54 MODULE_FIRMWARE("radeon/bonaire_sdma.bin");
55 MODULE_FIRMWARE("radeon/bonaire_smc.bin");
57 MODULE_FIRMWARE("radeon/HAWAII_pfp.bin");
58 MODULE_FIRMWARE("radeon/HAWAII_me.bin");
59 MODULE_FIRMWARE("radeon/HAWAII_ce.bin");
60 MODULE_FIRMWARE("radeon/HAWAII_mec.bin");
61 MODULE_FIRMWARE("radeon/HAWAII_mc.bin");
62 MODULE_FIRMWARE("radeon/HAWAII_mc2.bin");
63 MODULE_FIRMWARE("radeon/HAWAII_rlc.bin");
64 MODULE_FIRMWARE("radeon/HAWAII_sdma.bin");
65 MODULE_FIRMWARE("radeon/HAWAII_smc.bin");
67 MODULE_FIRMWARE("radeon/hawaii_pfp.bin");
68 MODULE_FIRMWARE("radeon/hawaii_me.bin");
69 MODULE_FIRMWARE("radeon/hawaii_ce.bin");
70 MODULE_FIRMWARE("radeon/hawaii_mec.bin");
71 MODULE_FIRMWARE("radeon/hawaii_mc.bin");
72 MODULE_FIRMWARE("radeon/hawaii_rlc.bin");
73 MODULE_FIRMWARE("radeon/hawaii_sdma.bin");
74 MODULE_FIRMWARE("radeon/hawaii_smc.bin");
76 MODULE_FIRMWARE("radeon/KAVERI_pfp.bin");
77 MODULE_FIRMWARE("radeon/KAVERI_me.bin");
78 MODULE_FIRMWARE("radeon/KAVERI_ce.bin");
79 MODULE_FIRMWARE("radeon/KAVERI_mec.bin");
80 MODULE_FIRMWARE("radeon/KAVERI_rlc.bin");
81 MODULE_FIRMWARE("radeon/KAVERI_sdma.bin");
83 MODULE_FIRMWARE("radeon/kaveri_pfp.bin");
84 MODULE_FIRMWARE("radeon/kaveri_me.bin");
85 MODULE_FIRMWARE("radeon/kaveri_ce.bin");
86 MODULE_FIRMWARE("radeon/kaveri_mec.bin");
87 MODULE_FIRMWARE("radeon/kaveri_mec2.bin");
88 MODULE_FIRMWARE("radeon/kaveri_rlc.bin");
89 MODULE_FIRMWARE("radeon/kaveri_sdma.bin");
91 MODULE_FIRMWARE("radeon/KABINI_pfp.bin");
92 MODULE_FIRMWARE("radeon/KABINI_me.bin");
93 MODULE_FIRMWARE("radeon/KABINI_ce.bin");
94 MODULE_FIRMWARE("radeon/KABINI_mec.bin");
95 MODULE_FIRMWARE("radeon/KABINI_rlc.bin");
96 MODULE_FIRMWARE("radeon/KABINI_sdma.bin");
98 MODULE_FIRMWARE("radeon/kabini_pfp.bin");
99 MODULE_FIRMWARE("radeon/kabini_me.bin");
100 MODULE_FIRMWARE("radeon/kabini_ce.bin");
101 MODULE_FIRMWARE("radeon/kabini_mec.bin");
102 MODULE_FIRMWARE("radeon/kabini_rlc.bin");
103 MODULE_FIRMWARE("radeon/kabini_sdma.bin");
105 MODULE_FIRMWARE("radeon/MULLINS_pfp.bin");
106 MODULE_FIRMWARE("radeon/MULLINS_me.bin");
107 MODULE_FIRMWARE("radeon/MULLINS_ce.bin");
108 MODULE_FIRMWARE("radeon/MULLINS_mec.bin");
109 MODULE_FIRMWARE("radeon/MULLINS_rlc.bin");
110 MODULE_FIRMWARE("radeon/MULLINS_sdma.bin");
112 MODULE_FIRMWARE("radeon/mullins_pfp.bin");
113 MODULE_FIRMWARE("radeon/mullins_me.bin");
114 MODULE_FIRMWARE("radeon/mullins_ce.bin");
115 MODULE_FIRMWARE("radeon/mullins_mec.bin");
116 MODULE_FIRMWARE("radeon/mullins_rlc.bin");
117 MODULE_FIRMWARE("radeon/mullins_sdma.bin");
119 extern int r600_ih_ring_alloc(struct radeon_device
*rdev
);
120 extern void r600_ih_ring_fini(struct radeon_device
*rdev
);
121 extern void evergreen_mc_stop(struct radeon_device
*rdev
, struct evergreen_mc_save
*save
);
122 extern void evergreen_mc_resume(struct radeon_device
*rdev
, struct evergreen_mc_save
*save
);
123 extern bool evergreen_is_display_hung(struct radeon_device
*rdev
);
124 extern void sumo_rlc_fini(struct radeon_device
*rdev
);
125 extern int sumo_rlc_init(struct radeon_device
*rdev
);
126 extern void si_vram_gtt_location(struct radeon_device
*rdev
, struct radeon_mc
*mc
);
127 extern void si_rlc_reset(struct radeon_device
*rdev
);
128 extern void si_init_uvd_internal_cg(struct radeon_device
*rdev
);
129 static u32
cik_get_cu_active_bitmap(struct radeon_device
*rdev
, u32 se
, u32 sh
);
130 extern int cik_sdma_resume(struct radeon_device
*rdev
);
131 extern void cik_sdma_enable(struct radeon_device
*rdev
, bool enable
);
132 extern void cik_sdma_fini(struct radeon_device
*rdev
);
133 extern void vce_v2_0_enable_mgcg(struct radeon_device
*rdev
, bool enable
);
134 static void cik_rlc_stop(struct radeon_device
*rdev
);
135 static void cik_pcie_gen3_enable(struct radeon_device
*rdev
);
136 static void cik_program_aspm(struct radeon_device
*rdev
);
137 static void cik_init_pg(struct radeon_device
*rdev
);
138 static void cik_init_cg(struct radeon_device
*rdev
);
139 static void cik_fini_pg(struct radeon_device
*rdev
);
140 static void cik_fini_cg(struct radeon_device
*rdev
);
141 static void cik_enable_gui_idle_interrupt(struct radeon_device
*rdev
,
145 * cik_get_allowed_info_register - fetch the register for the info ioctl
147 * @rdev: radeon_device pointer
148 * @reg: register offset in bytes
149 * @val: register value
151 * Returns 0 for success or -EINVAL for an invalid register
154 int cik_get_allowed_info_register(struct radeon_device
*rdev
,
160 case GRBM_STATUS_SE0
:
161 case GRBM_STATUS_SE1
:
162 case GRBM_STATUS_SE2
:
163 case GRBM_STATUS_SE3
:
166 case (SDMA0_STATUS_REG
+ SDMA0_REGISTER_OFFSET
):
167 case (SDMA0_STATUS_REG
+ SDMA1_REGISTER_OFFSET
):
178 * Indirect registers accessor
180 u32
cik_didt_rreg(struct radeon_device
*rdev
, u32 reg
)
185 spin_lock_irqsave(&rdev
->didt_idx_lock
, flags
);
186 WREG32(CIK_DIDT_IND_INDEX
, (reg
));
187 r
= RREG32(CIK_DIDT_IND_DATA
);
188 spin_unlock_irqrestore(&rdev
->didt_idx_lock
, flags
);
192 void cik_didt_wreg(struct radeon_device
*rdev
, u32 reg
, u32 v
)
196 spin_lock_irqsave(&rdev
->didt_idx_lock
, flags
);
197 WREG32(CIK_DIDT_IND_INDEX
, (reg
));
198 WREG32(CIK_DIDT_IND_DATA
, (v
));
199 spin_unlock_irqrestore(&rdev
->didt_idx_lock
, flags
);
202 /* get temperature in millidegrees */
203 int ci_get_temp(struct radeon_device
*rdev
)
208 temp
= (RREG32_SMC(CG_MULT_THERMAL_STATUS
) & CTF_TEMP_MASK
) >>
214 actual_temp
= temp
& 0x1ff;
216 actual_temp
= actual_temp
* 1000;
221 /* get temperature in millidegrees */
222 int kv_get_temp(struct radeon_device
*rdev
)
227 temp
= RREG32_SMC(0xC0300E0C);
230 actual_temp
= (temp
/ 8) - 49;
234 actual_temp
= actual_temp
* 1000;
240 * Indirect registers accessor
242 u32
cik_pciep_rreg(struct radeon_device
*rdev
, u32 reg
)
247 spin_lock_irqsave(&rdev
->pciep_idx_lock
, flags
);
248 WREG32(PCIE_INDEX
, reg
);
249 (void)RREG32(PCIE_INDEX
);
250 r
= RREG32(PCIE_DATA
);
251 spin_unlock_irqrestore(&rdev
->pciep_idx_lock
, flags
);
255 void cik_pciep_wreg(struct radeon_device
*rdev
, u32 reg
, u32 v
)
259 spin_lock_irqsave(&rdev
->pciep_idx_lock
, flags
);
260 WREG32(PCIE_INDEX
, reg
);
261 (void)RREG32(PCIE_INDEX
);
262 WREG32(PCIE_DATA
, v
);
263 (void)RREG32(PCIE_DATA
);
264 spin_unlock_irqrestore(&rdev
->pciep_idx_lock
, flags
);
267 static const u32 spectre_rlc_save_restore_register_list
[] =
269 (0x0e00 << 16) | (0xc12c >> 2),
271 (0x0e00 << 16) | (0xc140 >> 2),
273 (0x0e00 << 16) | (0xc150 >> 2),
275 (0x0e00 << 16) | (0xc15c >> 2),
277 (0x0e00 << 16) | (0xc168 >> 2),
279 (0x0e00 << 16) | (0xc170 >> 2),
281 (0x0e00 << 16) | (0xc178 >> 2),
283 (0x0e00 << 16) | (0xc204 >> 2),
285 (0x0e00 << 16) | (0xc2b4 >> 2),
287 (0x0e00 << 16) | (0xc2b8 >> 2),
289 (0x0e00 << 16) | (0xc2bc >> 2),
291 (0x0e00 << 16) | (0xc2c0 >> 2),
293 (0x0e00 << 16) | (0x8228 >> 2),
295 (0x0e00 << 16) | (0x829c >> 2),
297 (0x0e00 << 16) | (0x869c >> 2),
299 (0x0600 << 16) | (0x98f4 >> 2),
301 (0x0e00 << 16) | (0x98f8 >> 2),
303 (0x0e00 << 16) | (0x9900 >> 2),
305 (0x0e00 << 16) | (0xc260 >> 2),
307 (0x0e00 << 16) | (0x90e8 >> 2),
309 (0x0e00 << 16) | (0x3c000 >> 2),
311 (0x0e00 << 16) | (0x3c00c >> 2),
313 (0x0e00 << 16) | (0x8c1c >> 2),
315 (0x0e00 << 16) | (0x9700 >> 2),
317 (0x0e00 << 16) | (0xcd20 >> 2),
319 (0x4e00 << 16) | (0xcd20 >> 2),
321 (0x5e00 << 16) | (0xcd20 >> 2),
323 (0x6e00 << 16) | (0xcd20 >> 2),
325 (0x7e00 << 16) | (0xcd20 >> 2),
327 (0x8e00 << 16) | (0xcd20 >> 2),
329 (0x9e00 << 16) | (0xcd20 >> 2),
331 (0xae00 << 16) | (0xcd20 >> 2),
333 (0xbe00 << 16) | (0xcd20 >> 2),
335 (0x0e00 << 16) | (0x89bc >> 2),
337 (0x0e00 << 16) | (0x8900 >> 2),
340 (0x0e00 << 16) | (0xc130 >> 2),
342 (0x0e00 << 16) | (0xc134 >> 2),
344 (0x0e00 << 16) | (0xc1fc >> 2),
346 (0x0e00 << 16) | (0xc208 >> 2),
348 (0x0e00 << 16) | (0xc264 >> 2),
350 (0x0e00 << 16) | (0xc268 >> 2),
352 (0x0e00 << 16) | (0xc26c >> 2),
354 (0x0e00 << 16) | (0xc270 >> 2),
356 (0x0e00 << 16) | (0xc274 >> 2),
358 (0x0e00 << 16) | (0xc278 >> 2),
360 (0x0e00 << 16) | (0xc27c >> 2),
362 (0x0e00 << 16) | (0xc280 >> 2),
364 (0x0e00 << 16) | (0xc284 >> 2),
366 (0x0e00 << 16) | (0xc288 >> 2),
368 (0x0e00 << 16) | (0xc28c >> 2),
370 (0x0e00 << 16) | (0xc290 >> 2),
372 (0x0e00 << 16) | (0xc294 >> 2),
374 (0x0e00 << 16) | (0xc298 >> 2),
376 (0x0e00 << 16) | (0xc29c >> 2),
378 (0x0e00 << 16) | (0xc2a0 >> 2),
380 (0x0e00 << 16) | (0xc2a4 >> 2),
382 (0x0e00 << 16) | (0xc2a8 >> 2),
384 (0x0e00 << 16) | (0xc2ac >> 2),
386 (0x0e00 << 16) | (0xc2b0 >> 2),
388 (0x0e00 << 16) | (0x301d0 >> 2),
390 (0x0e00 << 16) | (0x30238 >> 2),
392 (0x0e00 << 16) | (0x30250 >> 2),
394 (0x0e00 << 16) | (0x30254 >> 2),
396 (0x0e00 << 16) | (0x30258 >> 2),
398 (0x0e00 << 16) | (0x3025c >> 2),
400 (0x4e00 << 16) | (0xc900 >> 2),
402 (0x5e00 << 16) | (0xc900 >> 2),
404 (0x6e00 << 16) | (0xc900 >> 2),
406 (0x7e00 << 16) | (0xc900 >> 2),
408 (0x8e00 << 16) | (0xc900 >> 2),
410 (0x9e00 << 16) | (0xc900 >> 2),
412 (0xae00 << 16) | (0xc900 >> 2),
414 (0xbe00 << 16) | (0xc900 >> 2),
416 (0x4e00 << 16) | (0xc904 >> 2),
418 (0x5e00 << 16) | (0xc904 >> 2),
420 (0x6e00 << 16) | (0xc904 >> 2),
422 (0x7e00 << 16) | (0xc904 >> 2),
424 (0x8e00 << 16) | (0xc904 >> 2),
426 (0x9e00 << 16) | (0xc904 >> 2),
428 (0xae00 << 16) | (0xc904 >> 2),
430 (0xbe00 << 16) | (0xc904 >> 2),
432 (0x4e00 << 16) | (0xc908 >> 2),
434 (0x5e00 << 16) | (0xc908 >> 2),
436 (0x6e00 << 16) | (0xc908 >> 2),
438 (0x7e00 << 16) | (0xc908 >> 2),
440 (0x8e00 << 16) | (0xc908 >> 2),
442 (0x9e00 << 16) | (0xc908 >> 2),
444 (0xae00 << 16) | (0xc908 >> 2),
446 (0xbe00 << 16) | (0xc908 >> 2),
448 (0x4e00 << 16) | (0xc90c >> 2),
450 (0x5e00 << 16) | (0xc90c >> 2),
452 (0x6e00 << 16) | (0xc90c >> 2),
454 (0x7e00 << 16) | (0xc90c >> 2),
456 (0x8e00 << 16) | (0xc90c >> 2),
458 (0x9e00 << 16) | (0xc90c >> 2),
460 (0xae00 << 16) | (0xc90c >> 2),
462 (0xbe00 << 16) | (0xc90c >> 2),
464 (0x4e00 << 16) | (0xc910 >> 2),
466 (0x5e00 << 16) | (0xc910 >> 2),
468 (0x6e00 << 16) | (0xc910 >> 2),
470 (0x7e00 << 16) | (0xc910 >> 2),
472 (0x8e00 << 16) | (0xc910 >> 2),
474 (0x9e00 << 16) | (0xc910 >> 2),
476 (0xae00 << 16) | (0xc910 >> 2),
478 (0xbe00 << 16) | (0xc910 >> 2),
480 (0x0e00 << 16) | (0xc99c >> 2),
482 (0x0e00 << 16) | (0x9834 >> 2),
484 (0x0000 << 16) | (0x30f00 >> 2),
486 (0x0001 << 16) | (0x30f00 >> 2),
488 (0x0000 << 16) | (0x30f04 >> 2),
490 (0x0001 << 16) | (0x30f04 >> 2),
492 (0x0000 << 16) | (0x30f08 >> 2),
494 (0x0001 << 16) | (0x30f08 >> 2),
496 (0x0000 << 16) | (0x30f0c >> 2),
498 (0x0001 << 16) | (0x30f0c >> 2),
500 (0x0600 << 16) | (0x9b7c >> 2),
502 (0x0e00 << 16) | (0x8a14 >> 2),
504 (0x0e00 << 16) | (0x8a18 >> 2),
506 (0x0600 << 16) | (0x30a00 >> 2),
508 (0x0e00 << 16) | (0x8bf0 >> 2),
510 (0x0e00 << 16) | (0x8bcc >> 2),
512 (0x0e00 << 16) | (0x8b24 >> 2),
514 (0x0e00 << 16) | (0x30a04 >> 2),
516 (0x0600 << 16) | (0x30a10 >> 2),
518 (0x0600 << 16) | (0x30a14 >> 2),
520 (0x0600 << 16) | (0x30a18 >> 2),
522 (0x0600 << 16) | (0x30a2c >> 2),
524 (0x0e00 << 16) | (0xc700 >> 2),
526 (0x0e00 << 16) | (0xc704 >> 2),
528 (0x0e00 << 16) | (0xc708 >> 2),
530 (0x0e00 << 16) | (0xc768 >> 2),
532 (0x0400 << 16) | (0xc770 >> 2),
534 (0x0400 << 16) | (0xc774 >> 2),
536 (0x0400 << 16) | (0xc778 >> 2),
538 (0x0400 << 16) | (0xc77c >> 2),
540 (0x0400 << 16) | (0xc780 >> 2),
542 (0x0400 << 16) | (0xc784 >> 2),
544 (0x0400 << 16) | (0xc788 >> 2),
546 (0x0400 << 16) | (0xc78c >> 2),
548 (0x0400 << 16) | (0xc798 >> 2),
550 (0x0400 << 16) | (0xc79c >> 2),
552 (0x0400 << 16) | (0xc7a0 >> 2),
554 (0x0400 << 16) | (0xc7a4 >> 2),
556 (0x0400 << 16) | (0xc7a8 >> 2),
558 (0x0400 << 16) | (0xc7ac >> 2),
560 (0x0400 << 16) | (0xc7b0 >> 2),
562 (0x0400 << 16) | (0xc7b4 >> 2),
564 (0x0e00 << 16) | (0x9100 >> 2),
566 (0x0e00 << 16) | (0x3c010 >> 2),
568 (0x0e00 << 16) | (0x92a8 >> 2),
570 (0x0e00 << 16) | (0x92ac >> 2),
572 (0x0e00 << 16) | (0x92b4 >> 2),
574 (0x0e00 << 16) | (0x92b8 >> 2),
576 (0x0e00 << 16) | (0x92bc >> 2),
578 (0x0e00 << 16) | (0x92c0 >> 2),
580 (0x0e00 << 16) | (0x92c4 >> 2),
582 (0x0e00 << 16) | (0x92c8 >> 2),
584 (0x0e00 << 16) | (0x92cc >> 2),
586 (0x0e00 << 16) | (0x92d0 >> 2),
588 (0x0e00 << 16) | (0x8c00 >> 2),
590 (0x0e00 << 16) | (0x8c04 >> 2),
592 (0x0e00 << 16) | (0x8c20 >> 2),
594 (0x0e00 << 16) | (0x8c38 >> 2),
596 (0x0e00 << 16) | (0x8c3c >> 2),
598 (0x0e00 << 16) | (0xae00 >> 2),
600 (0x0e00 << 16) | (0x9604 >> 2),
602 (0x0e00 << 16) | (0xac08 >> 2),
604 (0x0e00 << 16) | (0xac0c >> 2),
606 (0x0e00 << 16) | (0xac10 >> 2),
608 (0x0e00 << 16) | (0xac14 >> 2),
610 (0x0e00 << 16) | (0xac58 >> 2),
612 (0x0e00 << 16) | (0xac68 >> 2),
614 (0x0e00 << 16) | (0xac6c >> 2),
616 (0x0e00 << 16) | (0xac70 >> 2),
618 (0x0e00 << 16) | (0xac74 >> 2),
620 (0x0e00 << 16) | (0xac78 >> 2),
622 (0x0e00 << 16) | (0xac7c >> 2),
624 (0x0e00 << 16) | (0xac80 >> 2),
626 (0x0e00 << 16) | (0xac84 >> 2),
628 (0x0e00 << 16) | (0xac88 >> 2),
630 (0x0e00 << 16) | (0xac8c >> 2),
632 (0x0e00 << 16) | (0x970c >> 2),
634 (0x0e00 << 16) | (0x9714 >> 2),
636 (0x0e00 << 16) | (0x9718 >> 2),
638 (0x0e00 << 16) | (0x971c >> 2),
640 (0x0e00 << 16) | (0x31068 >> 2),
642 (0x4e00 << 16) | (0x31068 >> 2),
644 (0x5e00 << 16) | (0x31068 >> 2),
646 (0x6e00 << 16) | (0x31068 >> 2),
648 (0x7e00 << 16) | (0x31068 >> 2),
650 (0x8e00 << 16) | (0x31068 >> 2),
652 (0x9e00 << 16) | (0x31068 >> 2),
654 (0xae00 << 16) | (0x31068 >> 2),
656 (0xbe00 << 16) | (0x31068 >> 2),
658 (0x0e00 << 16) | (0xcd10 >> 2),
660 (0x0e00 << 16) | (0xcd14 >> 2),
662 (0x0e00 << 16) | (0x88b0 >> 2),
664 (0x0e00 << 16) | (0x88b4 >> 2),
666 (0x0e00 << 16) | (0x88b8 >> 2),
668 (0x0e00 << 16) | (0x88bc >> 2),
670 (0x0400 << 16) | (0x89c0 >> 2),
672 (0x0e00 << 16) | (0x88c4 >> 2),
674 (0x0e00 << 16) | (0x88c8 >> 2),
676 (0x0e00 << 16) | (0x88d0 >> 2),
678 (0x0e00 << 16) | (0x88d4 >> 2),
680 (0x0e00 << 16) | (0x88d8 >> 2),
682 (0x0e00 << 16) | (0x8980 >> 2),
684 (0x0e00 << 16) | (0x30938 >> 2),
686 (0x0e00 << 16) | (0x3093c >> 2),
688 (0x0e00 << 16) | (0x30940 >> 2),
690 (0x0e00 << 16) | (0x89a0 >> 2),
692 (0x0e00 << 16) | (0x30900 >> 2),
694 (0x0e00 << 16) | (0x30904 >> 2),
696 (0x0e00 << 16) | (0x89b4 >> 2),
698 (0x0e00 << 16) | (0x3c210 >> 2),
700 (0x0e00 << 16) | (0x3c214 >> 2),
702 (0x0e00 << 16) | (0x3c218 >> 2),
704 (0x0e00 << 16) | (0x8904 >> 2),
707 (0x0e00 << 16) | (0x8c28 >> 2),
708 (0x0e00 << 16) | (0x8c2c >> 2),
709 (0x0e00 << 16) | (0x8c30 >> 2),
710 (0x0e00 << 16) | (0x8c34 >> 2),
711 (0x0e00 << 16) | (0x9600 >> 2),
714 static const u32 kalindi_rlc_save_restore_register_list
[] =
716 (0x0e00 << 16) | (0xc12c >> 2),
718 (0x0e00 << 16) | (0xc140 >> 2),
720 (0x0e00 << 16) | (0xc150 >> 2),
722 (0x0e00 << 16) | (0xc15c >> 2),
724 (0x0e00 << 16) | (0xc168 >> 2),
726 (0x0e00 << 16) | (0xc170 >> 2),
728 (0x0e00 << 16) | (0xc204 >> 2),
730 (0x0e00 << 16) | (0xc2b4 >> 2),
732 (0x0e00 << 16) | (0xc2b8 >> 2),
734 (0x0e00 << 16) | (0xc2bc >> 2),
736 (0x0e00 << 16) | (0xc2c0 >> 2),
738 (0x0e00 << 16) | (0x8228 >> 2),
740 (0x0e00 << 16) | (0x829c >> 2),
742 (0x0e00 << 16) | (0x869c >> 2),
744 (0x0600 << 16) | (0x98f4 >> 2),
746 (0x0e00 << 16) | (0x98f8 >> 2),
748 (0x0e00 << 16) | (0x9900 >> 2),
750 (0x0e00 << 16) | (0xc260 >> 2),
752 (0x0e00 << 16) | (0x90e8 >> 2),
754 (0x0e00 << 16) | (0x3c000 >> 2),
756 (0x0e00 << 16) | (0x3c00c >> 2),
758 (0x0e00 << 16) | (0x8c1c >> 2),
760 (0x0e00 << 16) | (0x9700 >> 2),
762 (0x0e00 << 16) | (0xcd20 >> 2),
764 (0x4e00 << 16) | (0xcd20 >> 2),
766 (0x5e00 << 16) | (0xcd20 >> 2),
768 (0x6e00 << 16) | (0xcd20 >> 2),
770 (0x7e00 << 16) | (0xcd20 >> 2),
772 (0x0e00 << 16) | (0x89bc >> 2),
774 (0x0e00 << 16) | (0x8900 >> 2),
777 (0x0e00 << 16) | (0xc130 >> 2),
779 (0x0e00 << 16) | (0xc134 >> 2),
781 (0x0e00 << 16) | (0xc1fc >> 2),
783 (0x0e00 << 16) | (0xc208 >> 2),
785 (0x0e00 << 16) | (0xc264 >> 2),
787 (0x0e00 << 16) | (0xc268 >> 2),
789 (0x0e00 << 16) | (0xc26c >> 2),
791 (0x0e00 << 16) | (0xc270 >> 2),
793 (0x0e00 << 16) | (0xc274 >> 2),
795 (0x0e00 << 16) | (0xc28c >> 2),
797 (0x0e00 << 16) | (0xc290 >> 2),
799 (0x0e00 << 16) | (0xc294 >> 2),
801 (0x0e00 << 16) | (0xc298 >> 2),
803 (0x0e00 << 16) | (0xc2a0 >> 2),
805 (0x0e00 << 16) | (0xc2a4 >> 2),
807 (0x0e00 << 16) | (0xc2a8 >> 2),
809 (0x0e00 << 16) | (0xc2ac >> 2),
811 (0x0e00 << 16) | (0x301d0 >> 2),
813 (0x0e00 << 16) | (0x30238 >> 2),
815 (0x0e00 << 16) | (0x30250 >> 2),
817 (0x0e00 << 16) | (0x30254 >> 2),
819 (0x0e00 << 16) | (0x30258 >> 2),
821 (0x0e00 << 16) | (0x3025c >> 2),
823 (0x4e00 << 16) | (0xc900 >> 2),
825 (0x5e00 << 16) | (0xc900 >> 2),
827 (0x6e00 << 16) | (0xc900 >> 2),
829 (0x7e00 << 16) | (0xc900 >> 2),
831 (0x4e00 << 16) | (0xc904 >> 2),
833 (0x5e00 << 16) | (0xc904 >> 2),
835 (0x6e00 << 16) | (0xc904 >> 2),
837 (0x7e00 << 16) | (0xc904 >> 2),
839 (0x4e00 << 16) | (0xc908 >> 2),
841 (0x5e00 << 16) | (0xc908 >> 2),
843 (0x6e00 << 16) | (0xc908 >> 2),
845 (0x7e00 << 16) | (0xc908 >> 2),
847 (0x4e00 << 16) | (0xc90c >> 2),
849 (0x5e00 << 16) | (0xc90c >> 2),
851 (0x6e00 << 16) | (0xc90c >> 2),
853 (0x7e00 << 16) | (0xc90c >> 2),
855 (0x4e00 << 16) | (0xc910 >> 2),
857 (0x5e00 << 16) | (0xc910 >> 2),
859 (0x6e00 << 16) | (0xc910 >> 2),
861 (0x7e00 << 16) | (0xc910 >> 2),
863 (0x0e00 << 16) | (0xc99c >> 2),
865 (0x0e00 << 16) | (0x9834 >> 2),
867 (0x0000 << 16) | (0x30f00 >> 2),
869 (0x0000 << 16) | (0x30f04 >> 2),
871 (0x0000 << 16) | (0x30f08 >> 2),
873 (0x0000 << 16) | (0x30f0c >> 2),
875 (0x0600 << 16) | (0x9b7c >> 2),
877 (0x0e00 << 16) | (0x8a14 >> 2),
879 (0x0e00 << 16) | (0x8a18 >> 2),
881 (0x0600 << 16) | (0x30a00 >> 2),
883 (0x0e00 << 16) | (0x8bf0 >> 2),
885 (0x0e00 << 16) | (0x8bcc >> 2),
887 (0x0e00 << 16) | (0x8b24 >> 2),
889 (0x0e00 << 16) | (0x30a04 >> 2),
891 (0x0600 << 16) | (0x30a10 >> 2),
893 (0x0600 << 16) | (0x30a14 >> 2),
895 (0x0600 << 16) | (0x30a18 >> 2),
897 (0x0600 << 16) | (0x30a2c >> 2),
899 (0x0e00 << 16) | (0xc700 >> 2),
901 (0x0e00 << 16) | (0xc704 >> 2),
903 (0x0e00 << 16) | (0xc708 >> 2),
905 (0x0e00 << 16) | (0xc768 >> 2),
907 (0x0400 << 16) | (0xc770 >> 2),
909 (0x0400 << 16) | (0xc774 >> 2),
911 (0x0400 << 16) | (0xc798 >> 2),
913 (0x0400 << 16) | (0xc79c >> 2),
915 (0x0e00 << 16) | (0x9100 >> 2),
917 (0x0e00 << 16) | (0x3c010 >> 2),
919 (0x0e00 << 16) | (0x8c00 >> 2),
921 (0x0e00 << 16) | (0x8c04 >> 2),
923 (0x0e00 << 16) | (0x8c20 >> 2),
925 (0x0e00 << 16) | (0x8c38 >> 2),
927 (0x0e00 << 16) | (0x8c3c >> 2),
929 (0x0e00 << 16) | (0xae00 >> 2),
931 (0x0e00 << 16) | (0x9604 >> 2),
933 (0x0e00 << 16) | (0xac08 >> 2),
935 (0x0e00 << 16) | (0xac0c >> 2),
937 (0x0e00 << 16) | (0xac10 >> 2),
939 (0x0e00 << 16) | (0xac14 >> 2),
941 (0x0e00 << 16) | (0xac58 >> 2),
943 (0x0e00 << 16) | (0xac68 >> 2),
945 (0x0e00 << 16) | (0xac6c >> 2),
947 (0x0e00 << 16) | (0xac70 >> 2),
949 (0x0e00 << 16) | (0xac74 >> 2),
951 (0x0e00 << 16) | (0xac78 >> 2),
953 (0x0e00 << 16) | (0xac7c >> 2),
955 (0x0e00 << 16) | (0xac80 >> 2),
957 (0x0e00 << 16) | (0xac84 >> 2),
959 (0x0e00 << 16) | (0xac88 >> 2),
961 (0x0e00 << 16) | (0xac8c >> 2),
963 (0x0e00 << 16) | (0x970c >> 2),
965 (0x0e00 << 16) | (0x9714 >> 2),
967 (0x0e00 << 16) | (0x9718 >> 2),
969 (0x0e00 << 16) | (0x971c >> 2),
971 (0x0e00 << 16) | (0x31068 >> 2),
973 (0x4e00 << 16) | (0x31068 >> 2),
975 (0x5e00 << 16) | (0x31068 >> 2),
977 (0x6e00 << 16) | (0x31068 >> 2),
979 (0x7e00 << 16) | (0x31068 >> 2),
981 (0x0e00 << 16) | (0xcd10 >> 2),
983 (0x0e00 << 16) | (0xcd14 >> 2),
985 (0x0e00 << 16) | (0x88b0 >> 2),
987 (0x0e00 << 16) | (0x88b4 >> 2),
989 (0x0e00 << 16) | (0x88b8 >> 2),
991 (0x0e00 << 16) | (0x88bc >> 2),
993 (0x0400 << 16) | (0x89c0 >> 2),
995 (0x0e00 << 16) | (0x88c4 >> 2),
997 (0x0e00 << 16) | (0x88c8 >> 2),
999 (0x0e00 << 16) | (0x88d0 >> 2),
1001 (0x0e00 << 16) | (0x88d4 >> 2),
1003 (0x0e00 << 16) | (0x88d8 >> 2),
1005 (0x0e00 << 16) | (0x8980 >> 2),
1007 (0x0e00 << 16) | (0x30938 >> 2),
1009 (0x0e00 << 16) | (0x3093c >> 2),
1011 (0x0e00 << 16) | (0x30940 >> 2),
1013 (0x0e00 << 16) | (0x89a0 >> 2),
1015 (0x0e00 << 16) | (0x30900 >> 2),
1017 (0x0e00 << 16) | (0x30904 >> 2),
1019 (0x0e00 << 16) | (0x89b4 >> 2),
1021 (0x0e00 << 16) | (0x3e1fc >> 2),
1023 (0x0e00 << 16) | (0x3c210 >> 2),
1025 (0x0e00 << 16) | (0x3c214 >> 2),
1027 (0x0e00 << 16) | (0x3c218 >> 2),
1029 (0x0e00 << 16) | (0x8904 >> 2),
1032 (0x0e00 << 16) | (0x8c28 >> 2),
1033 (0x0e00 << 16) | (0x8c2c >> 2),
1034 (0x0e00 << 16) | (0x8c30 >> 2),
1035 (0x0e00 << 16) | (0x8c34 >> 2),
1036 (0x0e00 << 16) | (0x9600 >> 2),
1039 static const u32 bonaire_golden_spm_registers
[] =
1041 0x30800, 0xe0ffffff, 0xe0000000
1044 static const u32 bonaire_golden_common_registers
[] =
1046 0xc770, 0xffffffff, 0x00000800,
1047 0xc774, 0xffffffff, 0x00000800,
1048 0xc798, 0xffffffff, 0x00007fbf,
1049 0xc79c, 0xffffffff, 0x00007faf
1052 static const u32 bonaire_golden_registers
[] =
1054 0x3354, 0x00000333, 0x00000333,
1055 0x3350, 0x000c0fc0, 0x00040200,
1056 0x9a10, 0x00010000, 0x00058208,
1057 0x3c000, 0xffff1fff, 0x00140000,
1058 0x3c200, 0xfdfc0fff, 0x00000100,
1059 0x3c234, 0x40000000, 0x40000200,
1060 0x9830, 0xffffffff, 0x00000000,
1061 0x9834, 0xf00fffff, 0x00000400,
1062 0x9838, 0x0002021c, 0x00020200,
1063 0xc78, 0x00000080, 0x00000000,
1064 0x5bb0, 0x000000f0, 0x00000070,
1065 0x5bc0, 0xf0311fff, 0x80300000,
1066 0x98f8, 0x73773777, 0x12010001,
1067 0x350c, 0x00810000, 0x408af000,
1068 0x7030, 0x31000111, 0x00000011,
1069 0x2f48, 0x73773777, 0x12010001,
1070 0x220c, 0x00007fb6, 0x0021a1b1,
1071 0x2210, 0x00007fb6, 0x002021b1,
1072 0x2180, 0x00007fb6, 0x00002191,
1073 0x2218, 0x00007fb6, 0x002121b1,
1074 0x221c, 0x00007fb6, 0x002021b1,
1075 0x21dc, 0x00007fb6, 0x00002191,
1076 0x21e0, 0x00007fb6, 0x00002191,
1077 0x3628, 0x0000003f, 0x0000000a,
1078 0x362c, 0x0000003f, 0x0000000a,
1079 0x2ae4, 0x00073ffe, 0x000022a2,
1080 0x240c, 0x000007ff, 0x00000000,
1081 0x8a14, 0xf000003f, 0x00000007,
1082 0x8bf0, 0x00002001, 0x00000001,
1083 0x8b24, 0xffffffff, 0x00ffffff,
1084 0x30a04, 0x0000ff0f, 0x00000000,
1085 0x28a4c, 0x07ffffff, 0x06000000,
1086 0x4d8, 0x00000fff, 0x00000100,
1087 0x3e78, 0x00000001, 0x00000002,
1088 0x9100, 0x03000000, 0x0362c688,
1089 0x8c00, 0x000000ff, 0x00000001,
1090 0xe40, 0x00001fff, 0x00001fff,
1091 0x9060, 0x0000007f, 0x00000020,
1092 0x9508, 0x00010000, 0x00010000,
1093 0xac14, 0x000003ff, 0x000000f3,
1094 0xac0c, 0xffffffff, 0x00001032
1097 static const u32 bonaire_mgcg_cgcg_init
[] =
1099 0xc420, 0xffffffff, 0xfffffffc,
1100 0x30800, 0xffffffff, 0xe0000000,
1101 0x3c2a0, 0xffffffff, 0x00000100,
1102 0x3c208, 0xffffffff, 0x00000100,
1103 0x3c2c0, 0xffffffff, 0xc0000100,
1104 0x3c2c8, 0xffffffff, 0xc0000100,
1105 0x3c2c4, 0xffffffff, 0xc0000100,
1106 0x55e4, 0xffffffff, 0x00600100,
1107 0x3c280, 0xffffffff, 0x00000100,
1108 0x3c214, 0xffffffff, 0x06000100,
1109 0x3c220, 0xffffffff, 0x00000100,
1110 0x3c218, 0xffffffff, 0x06000100,
1111 0x3c204, 0xffffffff, 0x00000100,
1112 0x3c2e0, 0xffffffff, 0x00000100,
1113 0x3c224, 0xffffffff, 0x00000100,
1114 0x3c200, 0xffffffff, 0x00000100,
1115 0x3c230, 0xffffffff, 0x00000100,
1116 0x3c234, 0xffffffff, 0x00000100,
1117 0x3c250, 0xffffffff, 0x00000100,
1118 0x3c254, 0xffffffff, 0x00000100,
1119 0x3c258, 0xffffffff, 0x00000100,
1120 0x3c25c, 0xffffffff, 0x00000100,
1121 0x3c260, 0xffffffff, 0x00000100,
1122 0x3c27c, 0xffffffff, 0x00000100,
1123 0x3c278, 0xffffffff, 0x00000100,
1124 0x3c210, 0xffffffff, 0x06000100,
1125 0x3c290, 0xffffffff, 0x00000100,
1126 0x3c274, 0xffffffff, 0x00000100,
1127 0x3c2b4, 0xffffffff, 0x00000100,
1128 0x3c2b0, 0xffffffff, 0x00000100,
1129 0x3c270, 0xffffffff, 0x00000100,
1130 0x30800, 0xffffffff, 0xe0000000,
1131 0x3c020, 0xffffffff, 0x00010000,
1132 0x3c024, 0xffffffff, 0x00030002,
1133 0x3c028, 0xffffffff, 0x00040007,
1134 0x3c02c, 0xffffffff, 0x00060005,
1135 0x3c030, 0xffffffff, 0x00090008,
1136 0x3c034, 0xffffffff, 0x00010000,
1137 0x3c038, 0xffffffff, 0x00030002,
1138 0x3c03c, 0xffffffff, 0x00040007,
1139 0x3c040, 0xffffffff, 0x00060005,
1140 0x3c044, 0xffffffff, 0x00090008,
1141 0x3c048, 0xffffffff, 0x00010000,
1142 0x3c04c, 0xffffffff, 0x00030002,
1143 0x3c050, 0xffffffff, 0x00040007,
1144 0x3c054, 0xffffffff, 0x00060005,
1145 0x3c058, 0xffffffff, 0x00090008,
1146 0x3c05c, 0xffffffff, 0x00010000,
1147 0x3c060, 0xffffffff, 0x00030002,
1148 0x3c064, 0xffffffff, 0x00040007,
1149 0x3c068, 0xffffffff, 0x00060005,
1150 0x3c06c, 0xffffffff, 0x00090008,
1151 0x3c070, 0xffffffff, 0x00010000,
1152 0x3c074, 0xffffffff, 0x00030002,
1153 0x3c078, 0xffffffff, 0x00040007,
1154 0x3c07c, 0xffffffff, 0x00060005,
1155 0x3c080, 0xffffffff, 0x00090008,
1156 0x3c084, 0xffffffff, 0x00010000,
1157 0x3c088, 0xffffffff, 0x00030002,
1158 0x3c08c, 0xffffffff, 0x00040007,
1159 0x3c090, 0xffffffff, 0x00060005,
1160 0x3c094, 0xffffffff, 0x00090008,
1161 0x3c098, 0xffffffff, 0x00010000,
1162 0x3c09c, 0xffffffff, 0x00030002,
1163 0x3c0a0, 0xffffffff, 0x00040007,
1164 0x3c0a4, 0xffffffff, 0x00060005,
1165 0x3c0a8, 0xffffffff, 0x00090008,
1166 0x3c000, 0xffffffff, 0x96e00200,
1167 0x8708, 0xffffffff, 0x00900100,
1168 0xc424, 0xffffffff, 0x0020003f,
1169 0x38, 0xffffffff, 0x0140001c,
1170 0x3c, 0x000f0000, 0x000f0000,
1171 0x220, 0xffffffff, 0xC060000C,
1172 0x224, 0xc0000fff, 0x00000100,
1173 0xf90, 0xffffffff, 0x00000100,
1174 0xf98, 0x00000101, 0x00000000,
1175 0x20a8, 0xffffffff, 0x00000104,
1176 0x55e4, 0xff000fff, 0x00000100,
1177 0x30cc, 0xc0000fff, 0x00000104,
1178 0xc1e4, 0x00000001, 0x00000001,
1179 0xd00c, 0xff000ff0, 0x00000100,
1180 0xd80c, 0xff000ff0, 0x00000100
1183 static const u32 spectre_golden_spm_registers
[] =
1185 0x30800, 0xe0ffffff, 0xe0000000
1188 static const u32 spectre_golden_common_registers
[] =
1190 0xc770, 0xffffffff, 0x00000800,
1191 0xc774, 0xffffffff, 0x00000800,
1192 0xc798, 0xffffffff, 0x00007fbf,
1193 0xc79c, 0xffffffff, 0x00007faf
1196 static const u32 spectre_golden_registers
[] =
1198 0x3c000, 0xffff1fff, 0x96940200,
1199 0x3c00c, 0xffff0001, 0xff000000,
1200 0x3c200, 0xfffc0fff, 0x00000100,
1201 0x6ed8, 0x00010101, 0x00010000,
1202 0x9834, 0xf00fffff, 0x00000400,
1203 0x9838, 0xfffffffc, 0x00020200,
1204 0x5bb0, 0x000000f0, 0x00000070,
1205 0x5bc0, 0xf0311fff, 0x80300000,
1206 0x98f8, 0x73773777, 0x12010001,
1207 0x9b7c, 0x00ff0000, 0x00fc0000,
1208 0x2f48, 0x73773777, 0x12010001,
1209 0x8a14, 0xf000003f, 0x00000007,
1210 0x8b24, 0xffffffff, 0x00ffffff,
1211 0x28350, 0x3f3f3fff, 0x00000082,
1212 0x28354, 0x0000003f, 0x00000000,
1213 0x3e78, 0x00000001, 0x00000002,
1214 0x913c, 0xffff03df, 0x00000004,
1215 0xc768, 0x00000008, 0x00000008,
1216 0x8c00, 0x000008ff, 0x00000800,
1217 0x9508, 0x00010000, 0x00010000,
1218 0xac0c, 0xffffffff, 0x54763210,
1219 0x214f8, 0x01ff01ff, 0x00000002,
1220 0x21498, 0x007ff800, 0x00200000,
1221 0x2015c, 0xffffffff, 0x00000f40,
1222 0x30934, 0xffffffff, 0x00000001
1225 static const u32 spectre_mgcg_cgcg_init
[] =
1227 0xc420, 0xffffffff, 0xfffffffc,
1228 0x30800, 0xffffffff, 0xe0000000,
1229 0x3c2a0, 0xffffffff, 0x00000100,
1230 0x3c208, 0xffffffff, 0x00000100,
1231 0x3c2c0, 0xffffffff, 0x00000100,
1232 0x3c2c8, 0xffffffff, 0x00000100,
1233 0x3c2c4, 0xffffffff, 0x00000100,
1234 0x55e4, 0xffffffff, 0x00600100,
1235 0x3c280, 0xffffffff, 0x00000100,
1236 0x3c214, 0xffffffff, 0x06000100,
1237 0x3c220, 0xffffffff, 0x00000100,
1238 0x3c218, 0xffffffff, 0x06000100,
1239 0x3c204, 0xffffffff, 0x00000100,
1240 0x3c2e0, 0xffffffff, 0x00000100,
1241 0x3c224, 0xffffffff, 0x00000100,
1242 0x3c200, 0xffffffff, 0x00000100,
1243 0x3c230, 0xffffffff, 0x00000100,
1244 0x3c234, 0xffffffff, 0x00000100,
1245 0x3c250, 0xffffffff, 0x00000100,
1246 0x3c254, 0xffffffff, 0x00000100,
1247 0x3c258, 0xffffffff, 0x00000100,
1248 0x3c25c, 0xffffffff, 0x00000100,
1249 0x3c260, 0xffffffff, 0x00000100,
1250 0x3c27c, 0xffffffff, 0x00000100,
1251 0x3c278, 0xffffffff, 0x00000100,
1252 0x3c210, 0xffffffff, 0x06000100,
1253 0x3c290, 0xffffffff, 0x00000100,
1254 0x3c274, 0xffffffff, 0x00000100,
1255 0x3c2b4, 0xffffffff, 0x00000100,
1256 0x3c2b0, 0xffffffff, 0x00000100,
1257 0x3c270, 0xffffffff, 0x00000100,
1258 0x30800, 0xffffffff, 0xe0000000,
1259 0x3c020, 0xffffffff, 0x00010000,
1260 0x3c024, 0xffffffff, 0x00030002,
1261 0x3c028, 0xffffffff, 0x00040007,
1262 0x3c02c, 0xffffffff, 0x00060005,
1263 0x3c030, 0xffffffff, 0x00090008,
1264 0x3c034, 0xffffffff, 0x00010000,
1265 0x3c038, 0xffffffff, 0x00030002,
1266 0x3c03c, 0xffffffff, 0x00040007,
1267 0x3c040, 0xffffffff, 0x00060005,
1268 0x3c044, 0xffffffff, 0x00090008,
1269 0x3c048, 0xffffffff, 0x00010000,
1270 0x3c04c, 0xffffffff, 0x00030002,
1271 0x3c050, 0xffffffff, 0x00040007,
1272 0x3c054, 0xffffffff, 0x00060005,
1273 0x3c058, 0xffffffff, 0x00090008,
1274 0x3c05c, 0xffffffff, 0x00010000,
1275 0x3c060, 0xffffffff, 0x00030002,
1276 0x3c064, 0xffffffff, 0x00040007,
1277 0x3c068, 0xffffffff, 0x00060005,
1278 0x3c06c, 0xffffffff, 0x00090008,
1279 0x3c070, 0xffffffff, 0x00010000,
1280 0x3c074, 0xffffffff, 0x00030002,
1281 0x3c078, 0xffffffff, 0x00040007,
1282 0x3c07c, 0xffffffff, 0x00060005,
1283 0x3c080, 0xffffffff, 0x00090008,
1284 0x3c084, 0xffffffff, 0x00010000,
1285 0x3c088, 0xffffffff, 0x00030002,
1286 0x3c08c, 0xffffffff, 0x00040007,
1287 0x3c090, 0xffffffff, 0x00060005,
1288 0x3c094, 0xffffffff, 0x00090008,
1289 0x3c098, 0xffffffff, 0x00010000,
1290 0x3c09c, 0xffffffff, 0x00030002,
1291 0x3c0a0, 0xffffffff, 0x00040007,
1292 0x3c0a4, 0xffffffff, 0x00060005,
1293 0x3c0a8, 0xffffffff, 0x00090008,
1294 0x3c0ac, 0xffffffff, 0x00010000,
1295 0x3c0b0, 0xffffffff, 0x00030002,
1296 0x3c0b4, 0xffffffff, 0x00040007,
1297 0x3c0b8, 0xffffffff, 0x00060005,
1298 0x3c0bc, 0xffffffff, 0x00090008,
1299 0x3c000, 0xffffffff, 0x96e00200,
1300 0x8708, 0xffffffff, 0x00900100,
1301 0xc424, 0xffffffff, 0x0020003f,
1302 0x38, 0xffffffff, 0x0140001c,
1303 0x3c, 0x000f0000, 0x000f0000,
1304 0x220, 0xffffffff, 0xC060000C,
1305 0x224, 0xc0000fff, 0x00000100,
1306 0xf90, 0xffffffff, 0x00000100,
1307 0xf98, 0x00000101, 0x00000000,
1308 0x20a8, 0xffffffff, 0x00000104,
1309 0x55e4, 0xff000fff, 0x00000100,
1310 0x30cc, 0xc0000fff, 0x00000104,
1311 0xc1e4, 0x00000001, 0x00000001,
1312 0xd00c, 0xff000ff0, 0x00000100,
1313 0xd80c, 0xff000ff0, 0x00000100
1316 static const u32 kalindi_golden_spm_registers
[] =
1318 0x30800, 0xe0ffffff, 0xe0000000
1321 static const u32 kalindi_golden_common_registers
[] =
1323 0xc770, 0xffffffff, 0x00000800,
1324 0xc774, 0xffffffff, 0x00000800,
1325 0xc798, 0xffffffff, 0x00007fbf,
1326 0xc79c, 0xffffffff, 0x00007faf
1329 static const u32 kalindi_golden_registers
[] =
1331 0x3c000, 0xffffdfff, 0x6e944040,
1332 0x55e4, 0xff607fff, 0xfc000100,
1333 0x3c220, 0xff000fff, 0x00000100,
1334 0x3c224, 0xff000fff, 0x00000100,
1335 0x3c200, 0xfffc0fff, 0x00000100,
1336 0x6ed8, 0x00010101, 0x00010000,
1337 0x9830, 0xffffffff, 0x00000000,
1338 0x9834, 0xf00fffff, 0x00000400,
1339 0x5bb0, 0x000000f0, 0x00000070,
1340 0x5bc0, 0xf0311fff, 0x80300000,
1341 0x98f8, 0x73773777, 0x12010001,
1342 0x98fc, 0xffffffff, 0x00000010,
1343 0x9b7c, 0x00ff0000, 0x00fc0000,
1344 0x8030, 0x00001f0f, 0x0000100a,
1345 0x2f48, 0x73773777, 0x12010001,
1346 0x2408, 0x000fffff, 0x000c007f,
1347 0x8a14, 0xf000003f, 0x00000007,
1348 0x8b24, 0x3fff3fff, 0x00ffcfff,
1349 0x30a04, 0x0000ff0f, 0x00000000,
1350 0x28a4c, 0x07ffffff, 0x06000000,
1351 0x4d8, 0x00000fff, 0x00000100,
1352 0x3e78, 0x00000001, 0x00000002,
1353 0xc768, 0x00000008, 0x00000008,
1354 0x8c00, 0x000000ff, 0x00000003,
1355 0x214f8, 0x01ff01ff, 0x00000002,
1356 0x21498, 0x007ff800, 0x00200000,
1357 0x2015c, 0xffffffff, 0x00000f40,
1358 0x88c4, 0x001f3ae3, 0x00000082,
1359 0x88d4, 0x0000001f, 0x00000010,
1360 0x30934, 0xffffffff, 0x00000000
1363 static const u32 kalindi_mgcg_cgcg_init
[] =
1365 0xc420, 0xffffffff, 0xfffffffc,
1366 0x30800, 0xffffffff, 0xe0000000,
1367 0x3c2a0, 0xffffffff, 0x00000100,
1368 0x3c208, 0xffffffff, 0x00000100,
1369 0x3c2c0, 0xffffffff, 0x00000100,
1370 0x3c2c8, 0xffffffff, 0x00000100,
1371 0x3c2c4, 0xffffffff, 0x00000100,
1372 0x55e4, 0xffffffff, 0x00600100,
1373 0x3c280, 0xffffffff, 0x00000100,
1374 0x3c214, 0xffffffff, 0x06000100,
1375 0x3c220, 0xffffffff, 0x00000100,
1376 0x3c218, 0xffffffff, 0x06000100,
1377 0x3c204, 0xffffffff, 0x00000100,
1378 0x3c2e0, 0xffffffff, 0x00000100,
1379 0x3c224, 0xffffffff, 0x00000100,
1380 0x3c200, 0xffffffff, 0x00000100,
1381 0x3c230, 0xffffffff, 0x00000100,
1382 0x3c234, 0xffffffff, 0x00000100,
1383 0x3c250, 0xffffffff, 0x00000100,
1384 0x3c254, 0xffffffff, 0x00000100,
1385 0x3c258, 0xffffffff, 0x00000100,
1386 0x3c25c, 0xffffffff, 0x00000100,
1387 0x3c260, 0xffffffff, 0x00000100,
1388 0x3c27c, 0xffffffff, 0x00000100,
1389 0x3c278, 0xffffffff, 0x00000100,
1390 0x3c210, 0xffffffff, 0x06000100,
1391 0x3c290, 0xffffffff, 0x00000100,
1392 0x3c274, 0xffffffff, 0x00000100,
1393 0x3c2b4, 0xffffffff, 0x00000100,
1394 0x3c2b0, 0xffffffff, 0x00000100,
1395 0x3c270, 0xffffffff, 0x00000100,
1396 0x30800, 0xffffffff, 0xe0000000,
1397 0x3c020, 0xffffffff, 0x00010000,
1398 0x3c024, 0xffffffff, 0x00030002,
1399 0x3c028, 0xffffffff, 0x00040007,
1400 0x3c02c, 0xffffffff, 0x00060005,
1401 0x3c030, 0xffffffff, 0x00090008,
1402 0x3c034, 0xffffffff, 0x00010000,
1403 0x3c038, 0xffffffff, 0x00030002,
1404 0x3c03c, 0xffffffff, 0x00040007,
1405 0x3c040, 0xffffffff, 0x00060005,
1406 0x3c044, 0xffffffff, 0x00090008,
1407 0x3c000, 0xffffffff, 0x96e00200,
1408 0x8708, 0xffffffff, 0x00900100,
1409 0xc424, 0xffffffff, 0x0020003f,
1410 0x38, 0xffffffff, 0x0140001c,
1411 0x3c, 0x000f0000, 0x000f0000,
1412 0x220, 0xffffffff, 0xC060000C,
1413 0x224, 0xc0000fff, 0x00000100,
1414 0x20a8, 0xffffffff, 0x00000104,
1415 0x55e4, 0xff000fff, 0x00000100,
1416 0x30cc, 0xc0000fff, 0x00000104,
1417 0xc1e4, 0x00000001, 0x00000001,
1418 0xd00c, 0xff000ff0, 0x00000100,
1419 0xd80c, 0xff000ff0, 0x00000100
1422 static const u32 hawaii_golden_spm_registers
[] =
1424 0x30800, 0xe0ffffff, 0xe0000000
1427 static const u32 hawaii_golden_common_registers
[] =
1429 0x30800, 0xffffffff, 0xe0000000,
1430 0x28350, 0xffffffff, 0x3a00161a,
1431 0x28354, 0xffffffff, 0x0000002e,
1432 0x9a10, 0xffffffff, 0x00018208,
1433 0x98f8, 0xffffffff, 0x12011003
1436 static const u32 hawaii_golden_registers
[] =
1438 0x3354, 0x00000333, 0x00000333,
1439 0x9a10, 0x00010000, 0x00058208,
1440 0x9830, 0xffffffff, 0x00000000,
1441 0x9834, 0xf00fffff, 0x00000400,
1442 0x9838, 0x0002021c, 0x00020200,
1443 0xc78, 0x00000080, 0x00000000,
1444 0x5bb0, 0x000000f0, 0x00000070,
1445 0x5bc0, 0xf0311fff, 0x80300000,
1446 0x350c, 0x00810000, 0x408af000,
1447 0x7030, 0x31000111, 0x00000011,
1448 0x2f48, 0x73773777, 0x12010001,
1449 0x2120, 0x0000007f, 0x0000001b,
1450 0x21dc, 0x00007fb6, 0x00002191,
1451 0x3628, 0x0000003f, 0x0000000a,
1452 0x362c, 0x0000003f, 0x0000000a,
1453 0x2ae4, 0x00073ffe, 0x000022a2,
1454 0x240c, 0x000007ff, 0x00000000,
1455 0x8bf0, 0x00002001, 0x00000001,
1456 0x8b24, 0xffffffff, 0x00ffffff,
1457 0x30a04, 0x0000ff0f, 0x00000000,
1458 0x28a4c, 0x07ffffff, 0x06000000,
1459 0x3e78, 0x00000001, 0x00000002,
1460 0xc768, 0x00000008, 0x00000008,
1461 0xc770, 0x00000f00, 0x00000800,
1462 0xc774, 0x00000f00, 0x00000800,
1463 0xc798, 0x00ffffff, 0x00ff7fbf,
1464 0xc79c, 0x00ffffff, 0x00ff7faf,
1465 0x8c00, 0x000000ff, 0x00000800,
1466 0xe40, 0x00001fff, 0x00001fff,
1467 0x9060, 0x0000007f, 0x00000020,
1468 0x9508, 0x00010000, 0x00010000,
1469 0xae00, 0x00100000, 0x000ff07c,
1470 0xac14, 0x000003ff, 0x0000000f,
1471 0xac10, 0xffffffff, 0x7564fdec,
1472 0xac0c, 0xffffffff, 0x3120b9a8,
1473 0xac08, 0x20000000, 0x0f9c0000
1476 static const u32 hawaii_mgcg_cgcg_init
[] =
1478 0xc420, 0xffffffff, 0xfffffffd,
1479 0x30800, 0xffffffff, 0xe0000000,
1480 0x3c2a0, 0xffffffff, 0x00000100,
1481 0x3c208, 0xffffffff, 0x00000100,
1482 0x3c2c0, 0xffffffff, 0x00000100,
1483 0x3c2c8, 0xffffffff, 0x00000100,
1484 0x3c2c4, 0xffffffff, 0x00000100,
1485 0x55e4, 0xffffffff, 0x00200100,
1486 0x3c280, 0xffffffff, 0x00000100,
1487 0x3c214, 0xffffffff, 0x06000100,
1488 0x3c220, 0xffffffff, 0x00000100,
1489 0x3c218, 0xffffffff, 0x06000100,
1490 0x3c204, 0xffffffff, 0x00000100,
1491 0x3c2e0, 0xffffffff, 0x00000100,
1492 0x3c224, 0xffffffff, 0x00000100,
1493 0x3c200, 0xffffffff, 0x00000100,
1494 0x3c230, 0xffffffff, 0x00000100,
1495 0x3c234, 0xffffffff, 0x00000100,
1496 0x3c250, 0xffffffff, 0x00000100,
1497 0x3c254, 0xffffffff, 0x00000100,
1498 0x3c258, 0xffffffff, 0x00000100,
1499 0x3c25c, 0xffffffff, 0x00000100,
1500 0x3c260, 0xffffffff, 0x00000100,
1501 0x3c27c, 0xffffffff, 0x00000100,
1502 0x3c278, 0xffffffff, 0x00000100,
1503 0x3c210, 0xffffffff, 0x06000100,
1504 0x3c290, 0xffffffff, 0x00000100,
1505 0x3c274, 0xffffffff, 0x00000100,
1506 0x3c2b4, 0xffffffff, 0x00000100,
1507 0x3c2b0, 0xffffffff, 0x00000100,
1508 0x3c270, 0xffffffff, 0x00000100,
1509 0x30800, 0xffffffff, 0xe0000000,
1510 0x3c020, 0xffffffff, 0x00010000,
1511 0x3c024, 0xffffffff, 0x00030002,
1512 0x3c028, 0xffffffff, 0x00040007,
1513 0x3c02c, 0xffffffff, 0x00060005,
1514 0x3c030, 0xffffffff, 0x00090008,
1515 0x3c034, 0xffffffff, 0x00010000,
1516 0x3c038, 0xffffffff, 0x00030002,
1517 0x3c03c, 0xffffffff, 0x00040007,
1518 0x3c040, 0xffffffff, 0x00060005,
1519 0x3c044, 0xffffffff, 0x00090008,
1520 0x3c048, 0xffffffff, 0x00010000,
1521 0x3c04c, 0xffffffff, 0x00030002,
1522 0x3c050, 0xffffffff, 0x00040007,
1523 0x3c054, 0xffffffff, 0x00060005,
1524 0x3c058, 0xffffffff, 0x00090008,
1525 0x3c05c, 0xffffffff, 0x00010000,
1526 0x3c060, 0xffffffff, 0x00030002,
1527 0x3c064, 0xffffffff, 0x00040007,
1528 0x3c068, 0xffffffff, 0x00060005,
1529 0x3c06c, 0xffffffff, 0x00090008,
1530 0x3c070, 0xffffffff, 0x00010000,
1531 0x3c074, 0xffffffff, 0x00030002,
1532 0x3c078, 0xffffffff, 0x00040007,
1533 0x3c07c, 0xffffffff, 0x00060005,
1534 0x3c080, 0xffffffff, 0x00090008,
1535 0x3c084, 0xffffffff, 0x00010000,
1536 0x3c088, 0xffffffff, 0x00030002,
1537 0x3c08c, 0xffffffff, 0x00040007,
1538 0x3c090, 0xffffffff, 0x00060005,
1539 0x3c094, 0xffffffff, 0x00090008,
1540 0x3c098, 0xffffffff, 0x00010000,
1541 0x3c09c, 0xffffffff, 0x00030002,
1542 0x3c0a0, 0xffffffff, 0x00040007,
1543 0x3c0a4, 0xffffffff, 0x00060005,
1544 0x3c0a8, 0xffffffff, 0x00090008,
1545 0x3c0ac, 0xffffffff, 0x00010000,
1546 0x3c0b0, 0xffffffff, 0x00030002,
1547 0x3c0b4, 0xffffffff, 0x00040007,
1548 0x3c0b8, 0xffffffff, 0x00060005,
1549 0x3c0bc, 0xffffffff, 0x00090008,
1550 0x3c0c0, 0xffffffff, 0x00010000,
1551 0x3c0c4, 0xffffffff, 0x00030002,
1552 0x3c0c8, 0xffffffff, 0x00040007,
1553 0x3c0cc, 0xffffffff, 0x00060005,
1554 0x3c0d0, 0xffffffff, 0x00090008,
1555 0x3c0d4, 0xffffffff, 0x00010000,
1556 0x3c0d8, 0xffffffff, 0x00030002,
1557 0x3c0dc, 0xffffffff, 0x00040007,
1558 0x3c0e0, 0xffffffff, 0x00060005,
1559 0x3c0e4, 0xffffffff, 0x00090008,
1560 0x3c0e8, 0xffffffff, 0x00010000,
1561 0x3c0ec, 0xffffffff, 0x00030002,
1562 0x3c0f0, 0xffffffff, 0x00040007,
1563 0x3c0f4, 0xffffffff, 0x00060005,
1564 0x3c0f8, 0xffffffff, 0x00090008,
1565 0xc318, 0xffffffff, 0x00020200,
1566 0x3350, 0xffffffff, 0x00000200,
1567 0x15c0, 0xffffffff, 0x00000400,
1568 0x55e8, 0xffffffff, 0x00000000,
1569 0x2f50, 0xffffffff, 0x00000902,
1570 0x3c000, 0xffffffff, 0x96940200,
1571 0x8708, 0xffffffff, 0x00900100,
1572 0xc424, 0xffffffff, 0x0020003f,
1573 0x38, 0xffffffff, 0x0140001c,
1574 0x3c, 0x000f0000, 0x000f0000,
1575 0x220, 0xffffffff, 0xc060000c,
1576 0x224, 0xc0000fff, 0x00000100,
1577 0xf90, 0xffffffff, 0x00000100,
1578 0xf98, 0x00000101, 0x00000000,
1579 0x20a8, 0xffffffff, 0x00000104,
1580 0x55e4, 0xff000fff, 0x00000100,
1581 0x30cc, 0xc0000fff, 0x00000104,
1582 0xc1e4, 0x00000001, 0x00000001,
1583 0xd00c, 0xff000ff0, 0x00000100,
1584 0xd80c, 0xff000ff0, 0x00000100
1587 static const u32 godavari_golden_registers
[] =
1589 0x55e4, 0xff607fff, 0xfc000100,
1590 0x6ed8, 0x00010101, 0x00010000,
1591 0x9830, 0xffffffff, 0x00000000,
1592 0x98302, 0xf00fffff, 0x00000400,
1593 0x6130, 0xffffffff, 0x00010000,
1594 0x5bb0, 0x000000f0, 0x00000070,
1595 0x5bc0, 0xf0311fff, 0x80300000,
1596 0x98f8, 0x73773777, 0x12010001,
1597 0x98fc, 0xffffffff, 0x00000010,
1598 0x8030, 0x00001f0f, 0x0000100a,
1599 0x2f48, 0x73773777, 0x12010001,
1600 0x2408, 0x000fffff, 0x000c007f,
1601 0x8a14, 0xf000003f, 0x00000007,
1602 0x8b24, 0xffffffff, 0x00ff0fff,
1603 0x30a04, 0x0000ff0f, 0x00000000,
1604 0x28a4c, 0x07ffffff, 0x06000000,
1605 0x4d8, 0x00000fff, 0x00000100,
1606 0xd014, 0x00010000, 0x00810001,
1607 0xd814, 0x00010000, 0x00810001,
1608 0x3e78, 0x00000001, 0x00000002,
1609 0xc768, 0x00000008, 0x00000008,
1610 0xc770, 0x00000f00, 0x00000800,
1611 0xc774, 0x00000f00, 0x00000800,
1612 0xc798, 0x00ffffff, 0x00ff7fbf,
1613 0xc79c, 0x00ffffff, 0x00ff7faf,
1614 0x8c00, 0x000000ff, 0x00000001,
1615 0x214f8, 0x01ff01ff, 0x00000002,
1616 0x21498, 0x007ff800, 0x00200000,
1617 0x2015c, 0xffffffff, 0x00000f40,
1618 0x88c4, 0x001f3ae3, 0x00000082,
1619 0x88d4, 0x0000001f, 0x00000010,
1620 0x30934, 0xffffffff, 0x00000000
1624 static void cik_init_golden_registers(struct radeon_device
*rdev
)
1626 /* Some of the registers might be dependent on GRBM_GFX_INDEX */
1627 mutex_lock(&rdev
->grbm_idx_mutex
);
1628 switch (rdev
->family
) {
1630 radeon_program_register_sequence(rdev
,
1631 bonaire_mgcg_cgcg_init
,
1632 (const u32
)ARRAY_SIZE(bonaire_mgcg_cgcg_init
));
1633 radeon_program_register_sequence(rdev
,
1634 bonaire_golden_registers
,
1635 (const u32
)ARRAY_SIZE(bonaire_golden_registers
));
1636 radeon_program_register_sequence(rdev
,
1637 bonaire_golden_common_registers
,
1638 (const u32
)ARRAY_SIZE(bonaire_golden_common_registers
));
1639 radeon_program_register_sequence(rdev
,
1640 bonaire_golden_spm_registers
,
1641 (const u32
)ARRAY_SIZE(bonaire_golden_spm_registers
));
1644 radeon_program_register_sequence(rdev
,
1645 kalindi_mgcg_cgcg_init
,
1646 (const u32
)ARRAY_SIZE(kalindi_mgcg_cgcg_init
));
1647 radeon_program_register_sequence(rdev
,
1648 kalindi_golden_registers
,
1649 (const u32
)ARRAY_SIZE(kalindi_golden_registers
));
1650 radeon_program_register_sequence(rdev
,
1651 kalindi_golden_common_registers
,
1652 (const u32
)ARRAY_SIZE(kalindi_golden_common_registers
));
1653 radeon_program_register_sequence(rdev
,
1654 kalindi_golden_spm_registers
,
1655 (const u32
)ARRAY_SIZE(kalindi_golden_spm_registers
));
1658 radeon_program_register_sequence(rdev
,
1659 kalindi_mgcg_cgcg_init
,
1660 (const u32
)ARRAY_SIZE(kalindi_mgcg_cgcg_init
));
1661 radeon_program_register_sequence(rdev
,
1662 godavari_golden_registers
,
1663 (const u32
)ARRAY_SIZE(godavari_golden_registers
));
1664 radeon_program_register_sequence(rdev
,
1665 kalindi_golden_common_registers
,
1666 (const u32
)ARRAY_SIZE(kalindi_golden_common_registers
));
1667 radeon_program_register_sequence(rdev
,
1668 kalindi_golden_spm_registers
,
1669 (const u32
)ARRAY_SIZE(kalindi_golden_spm_registers
));
1672 radeon_program_register_sequence(rdev
,
1673 spectre_mgcg_cgcg_init
,
1674 (const u32
)ARRAY_SIZE(spectre_mgcg_cgcg_init
));
1675 radeon_program_register_sequence(rdev
,
1676 spectre_golden_registers
,
1677 (const u32
)ARRAY_SIZE(spectre_golden_registers
));
1678 radeon_program_register_sequence(rdev
,
1679 spectre_golden_common_registers
,
1680 (const u32
)ARRAY_SIZE(spectre_golden_common_registers
));
1681 radeon_program_register_sequence(rdev
,
1682 spectre_golden_spm_registers
,
1683 (const u32
)ARRAY_SIZE(spectre_golden_spm_registers
));
1686 radeon_program_register_sequence(rdev
,
1687 hawaii_mgcg_cgcg_init
,
1688 (const u32
)ARRAY_SIZE(hawaii_mgcg_cgcg_init
));
1689 radeon_program_register_sequence(rdev
,
1690 hawaii_golden_registers
,
1691 (const u32
)ARRAY_SIZE(hawaii_golden_registers
));
1692 radeon_program_register_sequence(rdev
,
1693 hawaii_golden_common_registers
,
1694 (const u32
)ARRAY_SIZE(hawaii_golden_common_registers
));
1695 radeon_program_register_sequence(rdev
,
1696 hawaii_golden_spm_registers
,
1697 (const u32
)ARRAY_SIZE(hawaii_golden_spm_registers
));
1702 mutex_unlock(&rdev
->grbm_idx_mutex
);
1706 * cik_get_xclk - get the xclk
1708 * @rdev: radeon_device pointer
1710 * Returns the reference clock used by the gfx engine
1713 u32
cik_get_xclk(struct radeon_device
*rdev
)
1715 u32 reference_clock
= rdev
->clock
.spll
.reference_freq
;
1717 if (rdev
->flags
& RADEON_IS_IGP
) {
1718 if (RREG32_SMC(GENERAL_PWRMGT
) & GPU_COUNTER_CLK
)
1719 return reference_clock
/ 2;
1721 if (RREG32_SMC(CG_CLKPIN_CNTL
) & XTALIN_DIVIDE
)
1722 return reference_clock
/ 4;
1724 return reference_clock
;
1728 * cik_mm_rdoorbell - read a doorbell dword
1730 * @rdev: radeon_device pointer
1731 * @index: doorbell index
1733 * Returns the value in the doorbell aperture at the
1734 * requested doorbell index (CIK).
1736 u32
cik_mm_rdoorbell(struct radeon_device
*rdev
, u32 index
)
1738 if (index
< rdev
->doorbell
.num_doorbells
) {
1739 return readl(rdev
->doorbell
.ptr
+ index
);
1741 DRM_ERROR("reading beyond doorbell aperture: 0x%08x!\n", index
);
1747 * cik_mm_wdoorbell - write a doorbell dword
1749 * @rdev: radeon_device pointer
1750 * @index: doorbell index
1751 * @v: value to write
1753 * Writes @v to the doorbell aperture at the
1754 * requested doorbell index (CIK).
1756 void cik_mm_wdoorbell(struct radeon_device
*rdev
, u32 index
, u32 v
)
1758 if (index
< rdev
->doorbell
.num_doorbells
) {
1759 writel(v
, rdev
->doorbell
.ptr
+ index
);
1761 DRM_ERROR("writing beyond doorbell aperture: 0x%08x!\n", index
);
1765 #define BONAIRE_IO_MC_REGS_SIZE 36
1767 static const u32 bonaire_io_mc_regs
[BONAIRE_IO_MC_REGS_SIZE
][2] =
1769 {0x00000070, 0x04400000},
1770 {0x00000071, 0x80c01803},
1771 {0x00000072, 0x00004004},
1772 {0x00000073, 0x00000100},
1773 {0x00000074, 0x00ff0000},
1774 {0x00000075, 0x34000000},
1775 {0x00000076, 0x08000014},
1776 {0x00000077, 0x00cc08ec},
1777 {0x00000078, 0x00000400},
1778 {0x00000079, 0x00000000},
1779 {0x0000007a, 0x04090000},
1780 {0x0000007c, 0x00000000},
1781 {0x0000007e, 0x4408a8e8},
1782 {0x0000007f, 0x00000304},
1783 {0x00000080, 0x00000000},
1784 {0x00000082, 0x00000001},
1785 {0x00000083, 0x00000002},
1786 {0x00000084, 0xf3e4f400},
1787 {0x00000085, 0x052024e3},
1788 {0x00000087, 0x00000000},
1789 {0x00000088, 0x01000000},
1790 {0x0000008a, 0x1c0a0000},
1791 {0x0000008b, 0xff010000},
1792 {0x0000008d, 0xffffefff},
1793 {0x0000008e, 0xfff3efff},
1794 {0x0000008f, 0xfff3efbf},
1795 {0x00000092, 0xf7ffffff},
1796 {0x00000093, 0xffffff7f},
1797 {0x00000095, 0x00101101},
1798 {0x00000096, 0x00000fff},
1799 {0x00000097, 0x00116fff},
1800 {0x00000098, 0x60010000},
1801 {0x00000099, 0x10010000},
1802 {0x0000009a, 0x00006000},
1803 {0x0000009b, 0x00001000},
1804 {0x0000009f, 0x00b48000}
1807 #define HAWAII_IO_MC_REGS_SIZE 22
1809 static const u32 hawaii_io_mc_regs
[HAWAII_IO_MC_REGS_SIZE
][2] =
1811 {0x0000007d, 0x40000000},
1812 {0x0000007e, 0x40180304},
1813 {0x0000007f, 0x0000ff00},
1814 {0x00000081, 0x00000000},
1815 {0x00000083, 0x00000800},
1816 {0x00000086, 0x00000000},
1817 {0x00000087, 0x00000100},
1818 {0x00000088, 0x00020100},
1819 {0x00000089, 0x00000000},
1820 {0x0000008b, 0x00040000},
1821 {0x0000008c, 0x00000100},
1822 {0x0000008e, 0xff010000},
1823 {0x00000090, 0xffffefff},
1824 {0x00000091, 0xfff3efff},
1825 {0x00000092, 0xfff3efbf},
1826 {0x00000093, 0xf7ffffff},
1827 {0x00000094, 0xffffff7f},
1828 {0x00000095, 0x00000fff},
1829 {0x00000096, 0x00116fff},
1830 {0x00000097, 0x60010000},
1831 {0x00000098, 0x10010000},
1832 {0x0000009f, 0x00c79000}
1837 * cik_srbm_select - select specific register instances
1839 * @rdev: radeon_device pointer
1840 * @me: selected ME (micro engine)
1845 * Switches the currently active registers instances. Some
1846 * registers are instanced per VMID, others are instanced per
1847 * me/pipe/queue combination.
1849 static void cik_srbm_select(struct radeon_device
*rdev
,
1850 u32 me
, u32 pipe
, u32 queue
, u32 vmid
)
1852 u32 srbm_gfx_cntl
= (PIPEID(pipe
& 0x3) |
1855 QUEUEID(queue
& 0x7));
1856 WREG32(SRBM_GFX_CNTL
, srbm_gfx_cntl
);
1861 * ci_mc_load_microcode - load MC ucode into the hw
1863 * @rdev: radeon_device pointer
1865 * Load the GDDR MC ucode into the hw (CIK).
1866 * Returns 0 on success, error on failure.
1868 int ci_mc_load_microcode(struct radeon_device
*rdev
)
1870 const __be32
*fw_data
= NULL
;
1871 const __le32
*new_fw_data
= NULL
;
1872 u32 running
, blackout
= 0, tmp
;
1873 u32
*io_mc_regs
= NULL
;
1874 const __le32
*new_io_mc_regs
= NULL
;
1875 int i
, regs_size
, ucode_size
;
1881 const struct mc_firmware_header_v1_0
*hdr
=
1882 (const struct mc_firmware_header_v1_0
*)rdev
->mc_fw
->data
;
1884 radeon_ucode_print_mc_hdr(&hdr
->header
);
1886 regs_size
= le32_to_cpu(hdr
->io_debug_size_bytes
) / (4 * 2);
1887 new_io_mc_regs
= (const __le32
*)
1888 (rdev
->mc_fw
->data
+ le32_to_cpu(hdr
->io_debug_array_offset_bytes
));
1889 ucode_size
= le32_to_cpu(hdr
->header
.ucode_size_bytes
) / 4;
1890 new_fw_data
= (const __le32
*)
1891 (rdev
->mc_fw
->data
+ le32_to_cpu(hdr
->header
.ucode_array_offset_bytes
));
1893 ucode_size
= rdev
->mc_fw
->size
/ 4;
1895 switch (rdev
->family
) {
1897 io_mc_regs
= (u32
*)&bonaire_io_mc_regs
;
1898 regs_size
= BONAIRE_IO_MC_REGS_SIZE
;
1901 io_mc_regs
= (u32
*)&hawaii_io_mc_regs
;
1902 regs_size
= HAWAII_IO_MC_REGS_SIZE
;
1907 fw_data
= (const __be32
*)rdev
->mc_fw
->data
;
1910 running
= RREG32(MC_SEQ_SUP_CNTL
) & RUN_MASK
;
1914 blackout
= RREG32(MC_SHARED_BLACKOUT_CNTL
);
1915 WREG32(MC_SHARED_BLACKOUT_CNTL
, blackout
| 1);
1918 /* reset the engine and set to writable */
1919 WREG32(MC_SEQ_SUP_CNTL
, 0x00000008);
1920 WREG32(MC_SEQ_SUP_CNTL
, 0x00000010);
1922 /* load mc io regs */
1923 for (i
= 0; i
< regs_size
; i
++) {
1925 WREG32(MC_SEQ_IO_DEBUG_INDEX
, le32_to_cpup(new_io_mc_regs
++));
1926 WREG32(MC_SEQ_IO_DEBUG_DATA
, le32_to_cpup(new_io_mc_regs
++));
1928 WREG32(MC_SEQ_IO_DEBUG_INDEX
, io_mc_regs
[(i
<< 1)]);
1929 WREG32(MC_SEQ_IO_DEBUG_DATA
, io_mc_regs
[(i
<< 1) + 1]);
1933 tmp
= RREG32(MC_SEQ_MISC0
);
1934 if ((rdev
->pdev
->device
== 0x6649) && ((tmp
& 0xff00) == 0x5600)) {
1935 WREG32(MC_SEQ_IO_DEBUG_INDEX
, 5);
1936 WREG32(MC_SEQ_IO_DEBUG_DATA
, 0x00000023);
1937 WREG32(MC_SEQ_IO_DEBUG_INDEX
, 9);
1938 WREG32(MC_SEQ_IO_DEBUG_DATA
, 0x000001f0);
1941 /* load the MC ucode */
1942 for (i
= 0; i
< ucode_size
; i
++) {
1944 WREG32(MC_SEQ_SUP_PGM
, le32_to_cpup(new_fw_data
++));
1946 WREG32(MC_SEQ_SUP_PGM
, be32_to_cpup(fw_data
++));
1949 /* put the engine back into the active state */
1950 WREG32(MC_SEQ_SUP_CNTL
, 0x00000008);
1951 WREG32(MC_SEQ_SUP_CNTL
, 0x00000004);
1952 WREG32(MC_SEQ_SUP_CNTL
, 0x00000001);
1954 /* wait for training to complete */
1955 for (i
= 0; i
< rdev
->usec_timeout
; i
++) {
1956 if (RREG32(MC_SEQ_TRAIN_WAKEUP_CNTL
) & TRAIN_DONE_D0
)
1960 for (i
= 0; i
< rdev
->usec_timeout
; i
++) {
1961 if (RREG32(MC_SEQ_TRAIN_WAKEUP_CNTL
) & TRAIN_DONE_D1
)
1967 WREG32(MC_SHARED_BLACKOUT_CNTL
, blackout
);
1974 * cik_init_microcode - load ucode images from disk
1976 * @rdev: radeon_device pointer
1978 * Use the firmware interface to load the ucode images into
1979 * the driver (not loaded into hw).
1980 * Returns 0 on success, error on failure.
1982 static int cik_init_microcode(struct radeon_device
*rdev
)
1984 const char *chip_name
;
1985 const char *new_chip_name
;
1986 size_t pfp_req_size
, me_req_size
, ce_req_size
,
1987 mec_req_size
, rlc_req_size
, mc_req_size
= 0,
1988 sdma_req_size
, smc_req_size
= 0, mc2_req_size
= 0;
1996 switch (rdev
->family
) {
1998 chip_name
= "BONAIRE";
1999 new_chip_name
= "bonaire";
2000 pfp_req_size
= CIK_PFP_UCODE_SIZE
* 4;
2001 me_req_size
= CIK_ME_UCODE_SIZE
* 4;
2002 ce_req_size
= CIK_CE_UCODE_SIZE
* 4;
2003 mec_req_size
= CIK_MEC_UCODE_SIZE
* 4;
2004 rlc_req_size
= BONAIRE_RLC_UCODE_SIZE
* 4;
2005 mc_req_size
= BONAIRE_MC_UCODE_SIZE
* 4;
2006 mc2_req_size
= BONAIRE_MC2_UCODE_SIZE
* 4;
2007 sdma_req_size
= CIK_SDMA_UCODE_SIZE
* 4;
2008 smc_req_size
= ALIGN(BONAIRE_SMC_UCODE_SIZE
, 4);
2012 chip_name
= "HAWAII";
2013 new_chip_name
= "hawaii";
2014 pfp_req_size
= CIK_PFP_UCODE_SIZE
* 4;
2015 me_req_size
= CIK_ME_UCODE_SIZE
* 4;
2016 ce_req_size
= CIK_CE_UCODE_SIZE
* 4;
2017 mec_req_size
= CIK_MEC_UCODE_SIZE
* 4;
2018 rlc_req_size
= BONAIRE_RLC_UCODE_SIZE
* 4;
2019 mc_req_size
= HAWAII_MC_UCODE_SIZE
* 4;
2020 mc2_req_size
= HAWAII_MC2_UCODE_SIZE
* 4;
2021 sdma_req_size
= CIK_SDMA_UCODE_SIZE
* 4;
2022 smc_req_size
= ALIGN(HAWAII_SMC_UCODE_SIZE
, 4);
2026 chip_name
= "KAVERI";
2027 new_chip_name
= "kaveri";
2028 pfp_req_size
= CIK_PFP_UCODE_SIZE
* 4;
2029 me_req_size
= CIK_ME_UCODE_SIZE
* 4;
2030 ce_req_size
= CIK_CE_UCODE_SIZE
* 4;
2031 mec_req_size
= CIK_MEC_UCODE_SIZE
* 4;
2032 rlc_req_size
= KV_RLC_UCODE_SIZE
* 4;
2033 sdma_req_size
= CIK_SDMA_UCODE_SIZE
* 4;
2037 chip_name
= "KABINI";
2038 new_chip_name
= "kabini";
2039 pfp_req_size
= CIK_PFP_UCODE_SIZE
* 4;
2040 me_req_size
= CIK_ME_UCODE_SIZE
* 4;
2041 ce_req_size
= CIK_CE_UCODE_SIZE
* 4;
2042 mec_req_size
= CIK_MEC_UCODE_SIZE
* 4;
2043 rlc_req_size
= KB_RLC_UCODE_SIZE
* 4;
2044 sdma_req_size
= CIK_SDMA_UCODE_SIZE
* 4;
2048 chip_name
= "MULLINS";
2049 new_chip_name
= "mullins";
2050 pfp_req_size
= CIK_PFP_UCODE_SIZE
* 4;
2051 me_req_size
= CIK_ME_UCODE_SIZE
* 4;
2052 ce_req_size
= CIK_CE_UCODE_SIZE
* 4;
2053 mec_req_size
= CIK_MEC_UCODE_SIZE
* 4;
2054 rlc_req_size
= ML_RLC_UCODE_SIZE
* 4;
2055 sdma_req_size
= CIK_SDMA_UCODE_SIZE
* 4;
2061 DRM_INFO("Loading %s Microcode\n", new_chip_name
);
2063 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_pfp.bin", new_chip_name
);
2064 err
= request_firmware(&rdev
->pfp_fw
, fw_name
, rdev
->dev
);
2066 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_pfp.bin", chip_name
);
2067 err
= request_firmware(&rdev
->pfp_fw
, fw_name
, rdev
->dev
);
2070 if (rdev
->pfp_fw
->size
!= pfp_req_size
) {
2072 "cik_cp: Bogus length %zu in firmware \"%s\"\n",
2073 rdev
->pfp_fw
->size
, fw_name
);
2078 err
= radeon_ucode_validate(rdev
->pfp_fw
);
2081 "cik_fw: validation failed for firmware \"%s\"\n",
2089 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_me.bin", new_chip_name
);
2090 err
= request_firmware(&rdev
->me_fw
, fw_name
, rdev
->dev
);
2092 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_me.bin", chip_name
);
2093 err
= request_firmware(&rdev
->me_fw
, fw_name
, rdev
->dev
);
2096 if (rdev
->me_fw
->size
!= me_req_size
) {
2098 "cik_cp: Bogus length %zu in firmware \"%s\"\n",
2099 rdev
->me_fw
->size
, fw_name
);
2103 err
= radeon_ucode_validate(rdev
->me_fw
);
2106 "cik_fw: validation failed for firmware \"%s\"\n",
2114 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_ce.bin", new_chip_name
);
2115 err
= request_firmware(&rdev
->ce_fw
, fw_name
, rdev
->dev
);
2117 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_ce.bin", chip_name
);
2118 err
= request_firmware(&rdev
->ce_fw
, fw_name
, rdev
->dev
);
2121 if (rdev
->ce_fw
->size
!= ce_req_size
) {
2123 "cik_cp: Bogus length %zu in firmware \"%s\"\n",
2124 rdev
->ce_fw
->size
, fw_name
);
2128 err
= radeon_ucode_validate(rdev
->ce_fw
);
2131 "cik_fw: validation failed for firmware \"%s\"\n",
2139 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_mec.bin", new_chip_name
);
2140 err
= request_firmware(&rdev
->mec_fw
, fw_name
, rdev
->dev
);
2142 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_mec.bin", chip_name
);
2143 err
= request_firmware(&rdev
->mec_fw
, fw_name
, rdev
->dev
);
2146 if (rdev
->mec_fw
->size
!= mec_req_size
) {
2148 "cik_cp: Bogus length %zu in firmware \"%s\"\n",
2149 rdev
->mec_fw
->size
, fw_name
);
2153 err
= radeon_ucode_validate(rdev
->mec_fw
);
2156 "cik_fw: validation failed for firmware \"%s\"\n",
2164 if (rdev
->family
== CHIP_KAVERI
) {
2165 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_mec2.bin", new_chip_name
);
2166 err
= request_firmware(&rdev
->mec2_fw
, fw_name
, rdev
->dev
);
2170 err
= radeon_ucode_validate(rdev
->mec2_fw
);
2179 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_rlc.bin", new_chip_name
);
2180 err
= request_firmware(&rdev
->rlc_fw
, fw_name
, rdev
->dev
);
2182 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_rlc.bin", chip_name
);
2183 err
= request_firmware(&rdev
->rlc_fw
, fw_name
, rdev
->dev
);
2186 if (rdev
->rlc_fw
->size
!= rlc_req_size
) {
2188 "cik_rlc: Bogus length %zu in firmware \"%s\"\n",
2189 rdev
->rlc_fw
->size
, fw_name
);
2193 err
= radeon_ucode_validate(rdev
->rlc_fw
);
2196 "cik_fw: validation failed for firmware \"%s\"\n",
2204 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_sdma.bin", new_chip_name
);
2205 err
= request_firmware(&rdev
->sdma_fw
, fw_name
, rdev
->dev
);
2207 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_sdma.bin", chip_name
);
2208 err
= request_firmware(&rdev
->sdma_fw
, fw_name
, rdev
->dev
);
2211 if (rdev
->sdma_fw
->size
!= sdma_req_size
) {
2213 "cik_sdma: Bogus length %zu in firmware \"%s\"\n",
2214 rdev
->sdma_fw
->size
, fw_name
);
2218 err
= radeon_ucode_validate(rdev
->sdma_fw
);
2221 "cik_fw: validation failed for firmware \"%s\"\n",
2229 /* No SMC, MC ucode on APUs */
2230 if (!(rdev
->flags
& RADEON_IS_IGP
)) {
2231 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_mc.bin", new_chip_name
);
2232 err
= request_firmware(&rdev
->mc_fw
, fw_name
, rdev
->dev
);
2234 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_mc2.bin", chip_name
);
2235 err
= request_firmware(&rdev
->mc_fw
, fw_name
, rdev
->dev
);
2237 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_mc.bin", chip_name
);
2238 err
= request_firmware(&rdev
->mc_fw
, fw_name
, rdev
->dev
);
2242 if ((rdev
->mc_fw
->size
!= mc_req_size
) &&
2243 (rdev
->mc_fw
->size
!= mc2_req_size
)){
2245 "cik_mc: Bogus length %zu in firmware \"%s\"\n",
2246 rdev
->mc_fw
->size
, fw_name
);
2249 DRM_INFO("%s: %zu bytes\n", fw_name
, rdev
->mc_fw
->size
);
2251 err
= radeon_ucode_validate(rdev
->mc_fw
);
2254 "cik_fw: validation failed for firmware \"%s\"\n",
2262 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_smc.bin", new_chip_name
);
2263 err
= request_firmware(&rdev
->smc_fw
, fw_name
, rdev
->dev
);
2265 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_smc.bin", chip_name
);
2266 err
= request_firmware(&rdev
->smc_fw
, fw_name
, rdev
->dev
);
2269 "smc: error loading firmware \"%s\"\n",
2271 release_firmware(rdev
->smc_fw
);
2272 rdev
->smc_fw
= NULL
;
2274 } else if (rdev
->smc_fw
->size
!= smc_req_size
) {
2276 "cik_smc: Bogus length %zu in firmware \"%s\"\n",
2277 rdev
->smc_fw
->size
, fw_name
);
2281 err
= radeon_ucode_validate(rdev
->smc_fw
);
2284 "cik_fw: validation failed for firmware \"%s\"\n",
2294 rdev
->new_fw
= false;
2295 } else if (new_fw
< num_fw
) {
2296 printk(KERN_ERR
"ci_fw: mixing new and old firmware!\n");
2299 rdev
->new_fw
= true;
2306 "cik_cp: Failed to load firmware \"%s\"\n",
2308 release_firmware(rdev
->pfp_fw
);
2309 rdev
->pfp_fw
= NULL
;
2310 release_firmware(rdev
->me_fw
);
2312 release_firmware(rdev
->ce_fw
);
2314 release_firmware(rdev
->mec_fw
);
2315 rdev
->mec_fw
= NULL
;
2316 release_firmware(rdev
->mec2_fw
);
2317 rdev
->mec2_fw
= NULL
;
2318 release_firmware(rdev
->rlc_fw
);
2319 rdev
->rlc_fw
= NULL
;
2320 release_firmware(rdev
->sdma_fw
);
2321 rdev
->sdma_fw
= NULL
;
2322 release_firmware(rdev
->mc_fw
);
2324 release_firmware(rdev
->smc_fw
);
2325 rdev
->smc_fw
= NULL
;
2334 * cik_tiling_mode_table_init - init the hw tiling table
2336 * @rdev: radeon_device pointer
2338 * Starting with SI, the tiling setup is done globally in a
2339 * set of 32 tiling modes. Rather than selecting each set of
2340 * parameters per surface as on older asics, we just select
2341 * which index in the tiling table we want to use, and the
2342 * surface uses those parameters (CIK).
2344 static void cik_tiling_mode_table_init(struct radeon_device
*rdev
)
2346 const u32 num_tile_mode_states
= 32;
2347 const u32 num_secondary_tile_mode_states
= 16;
2348 u32 reg_offset
, gb_tile_moden
, split_equal_to_row_size
;
2349 u32 num_pipe_configs
;
2350 u32 num_rbs
= rdev
->config
.cik
.max_backends_per_se
*
2351 rdev
->config
.cik
.max_shader_engines
;
2353 switch (rdev
->config
.cik
.mem_row_size_in_kb
) {
2355 split_equal_to_row_size
= ADDR_SURF_TILE_SPLIT_1KB
;
2359 split_equal_to_row_size
= ADDR_SURF_TILE_SPLIT_2KB
;
2362 split_equal_to_row_size
= ADDR_SURF_TILE_SPLIT_4KB
;
2366 num_pipe_configs
= rdev
->config
.cik
.max_tile_pipes
;
2367 if (num_pipe_configs
> 8)
2368 num_pipe_configs
= 16;
2370 if (num_pipe_configs
== 16) {
2371 for (reg_offset
= 0; reg_offset
< num_tile_mode_states
; reg_offset
++) {
2372 switch (reg_offset
) {
2374 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2375 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2376 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
2377 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B
));
2380 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2381 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2382 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
2383 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B
));
2386 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2387 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2388 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
2389 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B
));
2392 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2393 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2394 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
2395 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B
));
2398 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2399 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2400 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
2401 TILE_SPLIT(split_equal_to_row_size
));
2404 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
2405 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
2406 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
));
2409 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
2410 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2411 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
2412 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B
));
2415 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
2416 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2417 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
2418 TILE_SPLIT(split_equal_to_row_size
));
2421 gb_tile_moden
= (ARRAY_MODE(ARRAY_LINEAR_ALIGNED
) |
2422 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
));
2425 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
2426 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
2427 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
));
2430 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2431 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
) |
2432 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
2433 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2436 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
2437 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
) |
2438 PIPE_CONFIG(ADDR_SURF_P16_32x32_8x16
) |
2439 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2442 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
2443 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
) |
2444 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
2445 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2448 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
2449 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
2450 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
));
2453 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2454 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
2455 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
2456 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2459 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
2460 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
2461 PIPE_CONFIG(ADDR_SURF_P16_32x32_8x16
) |
2462 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2465 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
2466 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
2467 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
2468 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2471 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
2472 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
2473 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
));
2476 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2477 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
) |
2478 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
2479 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2482 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
2483 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
) |
2484 PIPE_CONFIG(ADDR_SURF_P16_32x32_8x16
) |
2485 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2488 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
2489 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
) |
2490 PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16
) |
2491 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2497 rdev
->config
.cik
.tile_mode_array
[reg_offset
] = gb_tile_moden
;
2498 WREG32(GB_TILE_MODE0
+ (reg_offset
* 4), gb_tile_moden
);
2500 for (reg_offset
= 0; reg_offset
< num_secondary_tile_mode_states
; reg_offset
++) {
2501 switch (reg_offset
) {
2503 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2504 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4
) |
2505 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
2506 NUM_BANKS(ADDR_SURF_16_BANK
));
2509 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2510 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2
) |
2511 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
2512 NUM_BANKS(ADDR_SURF_16_BANK
));
2515 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2516 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
2517 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
2518 NUM_BANKS(ADDR_SURF_16_BANK
));
2521 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2522 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
2523 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
2524 NUM_BANKS(ADDR_SURF_16_BANK
));
2527 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2528 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
2529 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
2530 NUM_BANKS(ADDR_SURF_8_BANK
));
2533 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2534 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
2535 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
2536 NUM_BANKS(ADDR_SURF_4_BANK
));
2539 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2540 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
2541 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
2542 NUM_BANKS(ADDR_SURF_2_BANK
));
2545 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2546 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4
) |
2547 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
2548 NUM_BANKS(ADDR_SURF_16_BANK
));
2551 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2552 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2
) |
2553 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
2554 NUM_BANKS(ADDR_SURF_16_BANK
));
2557 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2558 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
2559 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
2560 NUM_BANKS(ADDR_SURF_16_BANK
));
2563 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2564 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
2565 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
2566 NUM_BANKS(ADDR_SURF_8_BANK
));
2569 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2570 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
2571 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
2572 NUM_BANKS(ADDR_SURF_4_BANK
));
2575 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2576 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
2577 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
2578 NUM_BANKS(ADDR_SURF_2_BANK
));
2581 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2582 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
2583 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
2584 NUM_BANKS(ADDR_SURF_2_BANK
));
2590 rdev
->config
.cik
.macrotile_mode_array
[reg_offset
] = gb_tile_moden
;
2591 WREG32(GB_MACROTILE_MODE0
+ (reg_offset
* 4), gb_tile_moden
);
2593 } else if (num_pipe_configs
== 8) {
2594 for (reg_offset
= 0; reg_offset
< num_tile_mode_states
; reg_offset
++) {
2595 switch (reg_offset
) {
2597 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2598 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2599 PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16
) |
2600 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B
));
2603 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2604 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2605 PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16
) |
2606 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B
));
2609 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2610 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2611 PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16
) |
2612 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B
));
2615 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2616 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2617 PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16
) |
2618 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B
));
2621 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2622 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2623 PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16
) |
2624 TILE_SPLIT(split_equal_to_row_size
));
2627 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
2628 PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16
) |
2629 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
));
2632 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
2633 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2634 PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16
) |
2635 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B
));
2638 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
2639 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2640 PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16
) |
2641 TILE_SPLIT(split_equal_to_row_size
));
2644 gb_tile_moden
= (ARRAY_MODE(ARRAY_LINEAR_ALIGNED
) |
2645 PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16
));
2648 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
2649 PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16
) |
2650 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
));
2653 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2654 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
) |
2655 PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16
) |
2656 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2659 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
2660 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
) |
2661 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16
) |
2662 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2665 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
2666 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
) |
2667 PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16
) |
2668 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2671 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
2672 PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16
) |
2673 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
));
2676 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2677 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
2678 PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16
) |
2679 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2682 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
2683 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
2684 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16
) |
2685 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2688 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
2689 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
2690 PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16
) |
2691 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2694 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
2695 PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16
) |
2696 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
));
2699 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2700 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
) |
2701 PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16
) |
2702 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2705 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
2706 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
) |
2707 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16
) |
2708 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2711 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
2712 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
) |
2713 PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16
) |
2714 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2720 rdev
->config
.cik
.tile_mode_array
[reg_offset
] = gb_tile_moden
;
2721 WREG32(GB_TILE_MODE0
+ (reg_offset
* 4), gb_tile_moden
);
2723 for (reg_offset
= 0; reg_offset
< num_secondary_tile_mode_states
; reg_offset
++) {
2724 switch (reg_offset
) {
2726 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2727 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4
) |
2728 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
2729 NUM_BANKS(ADDR_SURF_16_BANK
));
2732 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2733 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2
) |
2734 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
2735 NUM_BANKS(ADDR_SURF_16_BANK
));
2738 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2739 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
2740 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
2741 NUM_BANKS(ADDR_SURF_16_BANK
));
2744 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2745 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
2746 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
2747 NUM_BANKS(ADDR_SURF_16_BANK
));
2750 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2751 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
2752 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
2753 NUM_BANKS(ADDR_SURF_8_BANK
));
2756 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2757 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
2758 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
2759 NUM_BANKS(ADDR_SURF_4_BANK
));
2762 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2763 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
2764 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
2765 NUM_BANKS(ADDR_SURF_2_BANK
));
2768 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2769 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_8
) |
2770 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
2771 NUM_BANKS(ADDR_SURF_16_BANK
));
2774 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2775 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4
) |
2776 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
2777 NUM_BANKS(ADDR_SURF_16_BANK
));
2780 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2781 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2
) |
2782 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
2783 NUM_BANKS(ADDR_SURF_16_BANK
));
2786 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2787 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
2788 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
2789 NUM_BANKS(ADDR_SURF_16_BANK
));
2792 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2793 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
2794 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
2795 NUM_BANKS(ADDR_SURF_8_BANK
));
2798 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2799 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
2800 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
2801 NUM_BANKS(ADDR_SURF_4_BANK
));
2804 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
2805 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
2806 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
2807 NUM_BANKS(ADDR_SURF_2_BANK
));
2813 rdev
->config
.cik
.macrotile_mode_array
[reg_offset
] = gb_tile_moden
;
2814 WREG32(GB_MACROTILE_MODE0
+ (reg_offset
* 4), gb_tile_moden
);
2816 } else if (num_pipe_configs
== 4) {
2818 for (reg_offset
= 0; reg_offset
< num_tile_mode_states
; reg_offset
++) {
2819 switch (reg_offset
) {
2821 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2822 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2823 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
2824 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B
));
2827 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2828 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2829 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
2830 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B
));
2833 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2834 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2835 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
2836 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B
));
2839 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2840 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2841 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
2842 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B
));
2845 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2846 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2847 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
2848 TILE_SPLIT(split_equal_to_row_size
));
2851 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
2852 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
2853 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
));
2856 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
2857 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2858 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
2859 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B
));
2862 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
2863 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2864 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
2865 TILE_SPLIT(split_equal_to_row_size
));
2868 gb_tile_moden
= (ARRAY_MODE(ARRAY_LINEAR_ALIGNED
) |
2869 PIPE_CONFIG(ADDR_SURF_P4_16x16
));
2872 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
2873 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
2874 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
));
2877 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2878 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
) |
2879 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
2880 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2883 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
2884 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
) |
2885 PIPE_CONFIG(ADDR_SURF_P4_8x16
) |
2886 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2889 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
2890 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
) |
2891 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
2892 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2895 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
2896 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
2897 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
));
2900 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2901 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
2902 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
2903 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2906 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
2907 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
2908 PIPE_CONFIG(ADDR_SURF_P4_8x16
) |
2909 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2912 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
2913 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
2914 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
2915 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2918 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
2919 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
2920 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
));
2923 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
2924 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
) |
2925 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
2926 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2929 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
2930 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
) |
2931 PIPE_CONFIG(ADDR_SURF_P4_8x16
) |
2932 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2935 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
2936 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
) |
2937 PIPE_CONFIG(ADDR_SURF_P4_16x16
) |
2938 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
2944 rdev
->config
.cik
.tile_mode_array
[reg_offset
] = gb_tile_moden
;
2945 WREG32(GB_TILE_MODE0
+ (reg_offset
* 4), gb_tile_moden
);
2947 } else if (num_rbs
< 4) {
2948 for (reg_offset
= 0; reg_offset
< num_tile_mode_states
; reg_offset
++) {
2949 switch (reg_offset
) {
2951 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2952 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2953 PIPE_CONFIG(ADDR_SURF_P4_8x16
) |
2954 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B
));
2957 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2958 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2959 PIPE_CONFIG(ADDR_SURF_P4_8x16
) |
2960 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B
));
2963 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2964 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2965 PIPE_CONFIG(ADDR_SURF_P4_8x16
) |
2966 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B
));
2969 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2970 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2971 PIPE_CONFIG(ADDR_SURF_P4_8x16
) |
2972 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B
));
2975 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
2976 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2977 PIPE_CONFIG(ADDR_SURF_P4_8x16
) |
2978 TILE_SPLIT(split_equal_to_row_size
));
2981 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
2982 PIPE_CONFIG(ADDR_SURF_P4_8x16
) |
2983 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
));
2986 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
2987 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2988 PIPE_CONFIG(ADDR_SURF_P4_8x16
) |
2989 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B
));
2992 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
2993 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
2994 PIPE_CONFIG(ADDR_SURF_P4_8x16
) |
2995 TILE_SPLIT(split_equal_to_row_size
));
2998 gb_tile_moden
= (ARRAY_MODE(ARRAY_LINEAR_ALIGNED
) |
2999 PIPE_CONFIG(ADDR_SURF_P4_8x16
));
3002 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
3003 PIPE_CONFIG(ADDR_SURF_P4_8x16
) |
3004 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
));
3007 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
3008 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
) |
3009 PIPE_CONFIG(ADDR_SURF_P4_8x16
) |
3010 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
3013 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
3014 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
) |
3015 PIPE_CONFIG(ADDR_SURF_P4_8x16
) |
3016 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
3019 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
3020 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
) |
3021 PIPE_CONFIG(ADDR_SURF_P4_8x16
) |
3022 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
3025 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
3026 PIPE_CONFIG(ADDR_SURF_P4_8x16
) |
3027 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
));
3030 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
3031 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
3032 PIPE_CONFIG(ADDR_SURF_P4_8x16
) |
3033 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
3036 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
3037 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
3038 PIPE_CONFIG(ADDR_SURF_P4_8x16
) |
3039 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
3042 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
3043 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
3044 PIPE_CONFIG(ADDR_SURF_P4_8x16
) |
3045 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
3048 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
3049 PIPE_CONFIG(ADDR_SURF_P4_8x16
) |
3050 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
));
3053 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
3054 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
) |
3055 PIPE_CONFIG(ADDR_SURF_P4_8x16
) |
3056 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
3059 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
3060 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
) |
3061 PIPE_CONFIG(ADDR_SURF_P4_8x16
) |
3062 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
3065 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
3066 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
) |
3067 PIPE_CONFIG(ADDR_SURF_P4_8x16
) |
3068 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
3074 rdev
->config
.cik
.tile_mode_array
[reg_offset
] = gb_tile_moden
;
3075 WREG32(GB_TILE_MODE0
+ (reg_offset
* 4), gb_tile_moden
);
3078 for (reg_offset
= 0; reg_offset
< num_secondary_tile_mode_states
; reg_offset
++) {
3079 switch (reg_offset
) {
3081 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
3082 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4
) |
3083 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
3084 NUM_BANKS(ADDR_SURF_16_BANK
));
3087 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
3088 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2
) |
3089 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
3090 NUM_BANKS(ADDR_SURF_16_BANK
));
3093 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
3094 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
3095 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
3096 NUM_BANKS(ADDR_SURF_16_BANK
));
3099 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
3100 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
3101 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
3102 NUM_BANKS(ADDR_SURF_16_BANK
));
3105 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
3106 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
3107 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
3108 NUM_BANKS(ADDR_SURF_16_BANK
));
3111 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
3112 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
3113 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
3114 NUM_BANKS(ADDR_SURF_8_BANK
));
3117 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
3118 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
3119 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
3120 NUM_BANKS(ADDR_SURF_4_BANK
));
3123 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2
) |
3124 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_8
) |
3125 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
3126 NUM_BANKS(ADDR_SURF_16_BANK
));
3129 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2
) |
3130 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4
) |
3131 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
3132 NUM_BANKS(ADDR_SURF_16_BANK
));
3135 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
3136 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4
) |
3137 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
3138 NUM_BANKS(ADDR_SURF_16_BANK
));
3141 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
3142 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2
) |
3143 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
3144 NUM_BANKS(ADDR_SURF_16_BANK
));
3147 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
3148 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
3149 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
3150 NUM_BANKS(ADDR_SURF_16_BANK
));
3153 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
3154 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
3155 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
3156 NUM_BANKS(ADDR_SURF_8_BANK
));
3159 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
3160 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
3161 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1
) |
3162 NUM_BANKS(ADDR_SURF_4_BANK
));
3168 rdev
->config
.cik
.macrotile_mode_array
[reg_offset
] = gb_tile_moden
;
3169 WREG32(GB_MACROTILE_MODE0
+ (reg_offset
* 4), gb_tile_moden
);
3171 } else if (num_pipe_configs
== 2) {
3172 for (reg_offset
= 0; reg_offset
< num_tile_mode_states
; reg_offset
++) {
3173 switch (reg_offset
) {
3175 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
3176 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
3177 PIPE_CONFIG(ADDR_SURF_P2
) |
3178 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B
));
3181 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
3182 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
3183 PIPE_CONFIG(ADDR_SURF_P2
) |
3184 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B
));
3187 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
3188 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
3189 PIPE_CONFIG(ADDR_SURF_P2
) |
3190 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B
));
3193 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
3194 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
3195 PIPE_CONFIG(ADDR_SURF_P2
) |
3196 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B
));
3199 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
3200 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
3201 PIPE_CONFIG(ADDR_SURF_P2
) |
3202 TILE_SPLIT(split_equal_to_row_size
));
3205 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
3206 PIPE_CONFIG(ADDR_SURF_P2
) |
3207 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
));
3210 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
3211 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
3212 PIPE_CONFIG(ADDR_SURF_P2
) |
3213 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B
));
3216 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
3217 MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING
) |
3218 PIPE_CONFIG(ADDR_SURF_P2
) |
3219 TILE_SPLIT(split_equal_to_row_size
));
3222 gb_tile_moden
= ARRAY_MODE(ARRAY_LINEAR_ALIGNED
) |
3223 PIPE_CONFIG(ADDR_SURF_P2
);
3226 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
3227 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
) |
3228 PIPE_CONFIG(ADDR_SURF_P2
));
3231 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
3232 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
) |
3233 PIPE_CONFIG(ADDR_SURF_P2
) |
3234 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
3237 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
3238 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
) |
3239 PIPE_CONFIG(ADDR_SURF_P2
) |
3240 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
3243 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
3244 MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING
) |
3245 PIPE_CONFIG(ADDR_SURF_P2
) |
3246 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
3249 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
3250 PIPE_CONFIG(ADDR_SURF_P2
) |
3251 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
));
3254 gb_tile_moden
= (ARRAY_MODE(ARRAY_2D_TILED_THIN1
) |
3255 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
3256 PIPE_CONFIG(ADDR_SURF_P2
) |
3257 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
3260 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
3261 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
3262 PIPE_CONFIG(ADDR_SURF_P2
) |
3263 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
3266 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
3267 MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING
) |
3268 PIPE_CONFIG(ADDR_SURF_P2
) |
3269 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
3272 gb_tile_moden
= (ARRAY_MODE(ARRAY_1D_TILED_THIN1
) |
3273 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
) |
3274 PIPE_CONFIG(ADDR_SURF_P2
));
3277 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
3278 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
) |
3279 PIPE_CONFIG(ADDR_SURF_P2
) |
3280 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
3283 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_TILED_THIN1
) |
3284 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
) |
3285 PIPE_CONFIG(ADDR_SURF_P2
) |
3286 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
3289 gb_tile_moden
= (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1
) |
3290 MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING
) |
3291 PIPE_CONFIG(ADDR_SURF_P2
) |
3292 SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2
));
3298 rdev
->config
.cik
.tile_mode_array
[reg_offset
] = gb_tile_moden
;
3299 WREG32(GB_TILE_MODE0
+ (reg_offset
* 4), gb_tile_moden
);
3301 for (reg_offset
= 0; reg_offset
< num_secondary_tile_mode_states
; reg_offset
++) {
3302 switch (reg_offset
) {
3304 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2
) |
3305 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4
) |
3306 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
3307 NUM_BANKS(ADDR_SURF_16_BANK
));
3310 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2
) |
3311 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2
) |
3312 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
3313 NUM_BANKS(ADDR_SURF_16_BANK
));
3316 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
3317 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2
) |
3318 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
3319 NUM_BANKS(ADDR_SURF_16_BANK
));
3322 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
3323 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
3324 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
3325 NUM_BANKS(ADDR_SURF_16_BANK
));
3328 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
3329 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
3330 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
3331 NUM_BANKS(ADDR_SURF_16_BANK
));
3334 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
3335 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
3336 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
3337 NUM_BANKS(ADDR_SURF_16_BANK
));
3340 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
3341 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
3342 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
3343 NUM_BANKS(ADDR_SURF_8_BANK
));
3346 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_4
) |
3347 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_8
) |
3348 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
3349 NUM_BANKS(ADDR_SURF_16_BANK
));
3352 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_4
) |
3353 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4
) |
3354 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
3355 NUM_BANKS(ADDR_SURF_16_BANK
));
3358 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2
) |
3359 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4
) |
3360 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
3361 NUM_BANKS(ADDR_SURF_16_BANK
));
3364 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2
) |
3365 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2
) |
3366 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
3367 NUM_BANKS(ADDR_SURF_16_BANK
));
3370 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
3371 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2
) |
3372 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
3373 NUM_BANKS(ADDR_SURF_16_BANK
));
3376 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
3377 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
3378 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4
) |
3379 NUM_BANKS(ADDR_SURF_16_BANK
));
3382 gb_tile_moden
= (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1
) |
3383 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1
) |
3384 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2
) |
3385 NUM_BANKS(ADDR_SURF_8_BANK
));
3391 rdev
->config
.cik
.macrotile_mode_array
[reg_offset
] = gb_tile_moden
;
3392 WREG32(GB_MACROTILE_MODE0
+ (reg_offset
* 4), gb_tile_moden
);
3395 DRM_ERROR("unknown num pipe config: 0x%x\n", num_pipe_configs
);
3399 * cik_select_se_sh - select which SE, SH to address
3401 * @rdev: radeon_device pointer
3402 * @se_num: shader engine to address
3403 * @sh_num: sh block to address
3405 * Select which SE, SH combinations to address. Certain
3406 * registers are instanced per SE or SH. 0xffffffff means
3407 * broadcast to all SEs or SHs (CIK).
3409 static void cik_select_se_sh(struct radeon_device
*rdev
,
3410 u32 se_num
, u32 sh_num
)
3412 u32 data
= INSTANCE_BROADCAST_WRITES
;
3414 if ((se_num
== 0xffffffff) && (sh_num
== 0xffffffff))
3415 data
|= SH_BROADCAST_WRITES
| SE_BROADCAST_WRITES
;
3416 else if (se_num
== 0xffffffff)
3417 data
|= SE_BROADCAST_WRITES
| SH_INDEX(sh_num
);
3418 else if (sh_num
== 0xffffffff)
3419 data
|= SH_BROADCAST_WRITES
| SE_INDEX(se_num
);
3421 data
|= SH_INDEX(sh_num
) | SE_INDEX(se_num
);
3422 WREG32(GRBM_GFX_INDEX
, data
);
3426 * cik_create_bitmask - create a bitmask
3428 * @bit_width: length of the mask
3430 * create a variable length bit mask (CIK).
3431 * Returns the bitmask.
3433 static u32
cik_create_bitmask(u32 bit_width
)
3437 for (i
= 0; i
< bit_width
; i
++) {
3445 * cik_get_rb_disabled - computes the mask of disabled RBs
3447 * @rdev: radeon_device pointer
3448 * @max_rb_num: max RBs (render backends) for the asic
3449 * @se_num: number of SEs (shader engines) for the asic
3450 * @sh_per_se: number of SH blocks per SE for the asic
3452 * Calculates the bitmask of disabled RBs (CIK).
3453 * Returns the disabled RB bitmask.
3455 static u32
cik_get_rb_disabled(struct radeon_device
*rdev
,
3456 u32 max_rb_num_per_se
,
3461 data
= RREG32(CC_RB_BACKEND_DISABLE
);
3463 data
&= BACKEND_DISABLE_MASK
;
3466 data
|= RREG32(GC_USER_RB_BACKEND_DISABLE
);
3468 data
>>= BACKEND_DISABLE_SHIFT
;
3470 mask
= cik_create_bitmask(max_rb_num_per_se
/ sh_per_se
);
3476 * cik_setup_rb - setup the RBs on the asic
3478 * @rdev: radeon_device pointer
3479 * @se_num: number of SEs (shader engines) for the asic
3480 * @sh_per_se: number of SH blocks per SE for the asic
3481 * @max_rb_num: max RBs (render backends) for the asic
3483 * Configures per-SE/SH RB registers (CIK).
3485 static void cik_setup_rb(struct radeon_device
*rdev
,
3486 u32 se_num
, u32 sh_per_se
,
3487 u32 max_rb_num_per_se
)
3491 u32 disabled_rbs
= 0;
3492 u32 enabled_rbs
= 0;
3494 mutex_lock(&rdev
->grbm_idx_mutex
);
3495 for (i
= 0; i
< se_num
; i
++) {
3496 for (j
= 0; j
< sh_per_se
; j
++) {
3497 cik_select_se_sh(rdev
, i
, j
);
3498 data
= cik_get_rb_disabled(rdev
, max_rb_num_per_se
, sh_per_se
);
3499 if (rdev
->family
== CHIP_HAWAII
)
3500 disabled_rbs
|= data
<< ((i
* sh_per_se
+ j
) * HAWAII_RB_BITMAP_WIDTH_PER_SH
);
3502 disabled_rbs
|= data
<< ((i
* sh_per_se
+ j
) * CIK_RB_BITMAP_WIDTH_PER_SH
);
3505 cik_select_se_sh(rdev
, 0xffffffff, 0xffffffff);
3506 mutex_unlock(&rdev
->grbm_idx_mutex
);
3509 for (i
= 0; i
< max_rb_num_per_se
* se_num
; i
++) {
3510 if (!(disabled_rbs
& mask
))
3511 enabled_rbs
|= mask
;
3515 rdev
->config
.cik
.backend_enable_mask
= enabled_rbs
;
3517 mutex_lock(&rdev
->grbm_idx_mutex
);
3518 for (i
= 0; i
< se_num
; i
++) {
3519 cik_select_se_sh(rdev
, i
, 0xffffffff);
3521 for (j
= 0; j
< sh_per_se
; j
++) {
3522 switch (enabled_rbs
& 3) {
3525 data
|= PKR_MAP(RASTER_CONFIG_RB_MAP_3
);
3527 data
|= PKR_MAP(RASTER_CONFIG_RB_MAP_0
);
3530 data
|= (RASTER_CONFIG_RB_MAP_0
<< (i
* sh_per_se
+ j
) * 2);
3533 data
|= (RASTER_CONFIG_RB_MAP_3
<< (i
* sh_per_se
+ j
) * 2);
3537 data
|= (RASTER_CONFIG_RB_MAP_2
<< (i
* sh_per_se
+ j
) * 2);
3542 WREG32(PA_SC_RASTER_CONFIG
, data
);
3544 cik_select_se_sh(rdev
, 0xffffffff, 0xffffffff);
3545 mutex_unlock(&rdev
->grbm_idx_mutex
);
3549 * cik_gpu_init - setup the 3D engine
3551 * @rdev: radeon_device pointer
3553 * Configures the 3D engine and tiling configuration
3554 * registers so that the 3D engine is usable.
3556 static void cik_gpu_init(struct radeon_device
*rdev
)
3558 u32 gb_addr_config
= RREG32(GB_ADDR_CONFIG
);
3559 u32 mc_shared_chmap
, mc_arb_ramcfg
;
3560 u32 hdp_host_path_cntl
;
3564 switch (rdev
->family
) {
3566 rdev
->config
.cik
.max_shader_engines
= 2;
3567 rdev
->config
.cik
.max_tile_pipes
= 4;
3568 rdev
->config
.cik
.max_cu_per_sh
= 7;
3569 rdev
->config
.cik
.max_sh_per_se
= 1;
3570 rdev
->config
.cik
.max_backends_per_se
= 2;
3571 rdev
->config
.cik
.max_texture_channel_caches
= 4;
3572 rdev
->config
.cik
.max_gprs
= 256;
3573 rdev
->config
.cik
.max_gs_threads
= 32;
3574 rdev
->config
.cik
.max_hw_contexts
= 8;
3576 rdev
->config
.cik
.sc_prim_fifo_size_frontend
= 0x20;
3577 rdev
->config
.cik
.sc_prim_fifo_size_backend
= 0x100;
3578 rdev
->config
.cik
.sc_hiz_tile_fifo_size
= 0x30;
3579 rdev
->config
.cik
.sc_earlyz_tile_fifo_size
= 0x130;
3580 gb_addr_config
= BONAIRE_GB_ADDR_CONFIG_GOLDEN
;
3583 rdev
->config
.cik
.max_shader_engines
= 4;
3584 rdev
->config
.cik
.max_tile_pipes
= 16;
3585 rdev
->config
.cik
.max_cu_per_sh
= 11;
3586 rdev
->config
.cik
.max_sh_per_se
= 1;
3587 rdev
->config
.cik
.max_backends_per_se
= 4;
3588 rdev
->config
.cik
.max_texture_channel_caches
= 16;
3589 rdev
->config
.cik
.max_gprs
= 256;
3590 rdev
->config
.cik
.max_gs_threads
= 32;
3591 rdev
->config
.cik
.max_hw_contexts
= 8;
3593 rdev
->config
.cik
.sc_prim_fifo_size_frontend
= 0x20;
3594 rdev
->config
.cik
.sc_prim_fifo_size_backend
= 0x100;
3595 rdev
->config
.cik
.sc_hiz_tile_fifo_size
= 0x30;
3596 rdev
->config
.cik
.sc_earlyz_tile_fifo_size
= 0x130;
3597 gb_addr_config
= HAWAII_GB_ADDR_CONFIG_GOLDEN
;
3600 rdev
->config
.cik
.max_shader_engines
= 1;
3601 rdev
->config
.cik
.max_tile_pipes
= 4;
3602 if ((rdev
->pdev
->device
== 0x1304) ||
3603 (rdev
->pdev
->device
== 0x1305) ||
3604 (rdev
->pdev
->device
== 0x130C) ||
3605 (rdev
->pdev
->device
== 0x130F) ||
3606 (rdev
->pdev
->device
== 0x1310) ||
3607 (rdev
->pdev
->device
== 0x1311) ||
3608 (rdev
->pdev
->device
== 0x131C)) {
3609 rdev
->config
.cik
.max_cu_per_sh
= 8;
3610 rdev
->config
.cik
.max_backends_per_se
= 2;
3611 } else if ((rdev
->pdev
->device
== 0x1309) ||
3612 (rdev
->pdev
->device
== 0x130A) ||
3613 (rdev
->pdev
->device
== 0x130D) ||
3614 (rdev
->pdev
->device
== 0x1313) ||
3615 (rdev
->pdev
->device
== 0x131D)) {
3616 rdev
->config
.cik
.max_cu_per_sh
= 6;
3617 rdev
->config
.cik
.max_backends_per_se
= 2;
3618 } else if ((rdev
->pdev
->device
== 0x1306) ||
3619 (rdev
->pdev
->device
== 0x1307) ||
3620 (rdev
->pdev
->device
== 0x130B) ||
3621 (rdev
->pdev
->device
== 0x130E) ||
3622 (rdev
->pdev
->device
== 0x1315) ||
3623 (rdev
->pdev
->device
== 0x1318) ||
3624 (rdev
->pdev
->device
== 0x131B)) {
3625 rdev
->config
.cik
.max_cu_per_sh
= 4;
3626 rdev
->config
.cik
.max_backends_per_se
= 1;
3628 rdev
->config
.cik
.max_cu_per_sh
= 3;
3629 rdev
->config
.cik
.max_backends_per_se
= 1;
3631 rdev
->config
.cik
.max_sh_per_se
= 1;
3632 rdev
->config
.cik
.max_texture_channel_caches
= 4;
3633 rdev
->config
.cik
.max_gprs
= 256;
3634 rdev
->config
.cik
.max_gs_threads
= 16;
3635 rdev
->config
.cik
.max_hw_contexts
= 8;
3637 rdev
->config
.cik
.sc_prim_fifo_size_frontend
= 0x20;
3638 rdev
->config
.cik
.sc_prim_fifo_size_backend
= 0x100;
3639 rdev
->config
.cik
.sc_hiz_tile_fifo_size
= 0x30;
3640 rdev
->config
.cik
.sc_earlyz_tile_fifo_size
= 0x130;
3641 gb_addr_config
= BONAIRE_GB_ADDR_CONFIG_GOLDEN
;
3646 rdev
->config
.cik
.max_shader_engines
= 1;
3647 rdev
->config
.cik
.max_tile_pipes
= 2;
3648 rdev
->config
.cik
.max_cu_per_sh
= 2;
3649 rdev
->config
.cik
.max_sh_per_se
= 1;
3650 rdev
->config
.cik
.max_backends_per_se
= 1;
3651 rdev
->config
.cik
.max_texture_channel_caches
= 2;
3652 rdev
->config
.cik
.max_gprs
= 256;
3653 rdev
->config
.cik
.max_gs_threads
= 16;
3654 rdev
->config
.cik
.max_hw_contexts
= 8;
3656 rdev
->config
.cik
.sc_prim_fifo_size_frontend
= 0x20;
3657 rdev
->config
.cik
.sc_prim_fifo_size_backend
= 0x100;
3658 rdev
->config
.cik
.sc_hiz_tile_fifo_size
= 0x30;
3659 rdev
->config
.cik
.sc_earlyz_tile_fifo_size
= 0x130;
3660 gb_addr_config
= BONAIRE_GB_ADDR_CONFIG_GOLDEN
;
3664 /* Initialize HDP */
3665 for (i
= 0, j
= 0; i
< 32; i
++, j
+= 0x18) {
3666 WREG32((0x2c14 + j
), 0x00000000);
3667 WREG32((0x2c18 + j
), 0x00000000);
3668 WREG32((0x2c1c + j
), 0x00000000);
3669 WREG32((0x2c20 + j
), 0x00000000);
3670 WREG32((0x2c24 + j
), 0x00000000);
3673 WREG32(GRBM_CNTL
, GRBM_READ_TIMEOUT(0xff));
3674 WREG32(SRBM_INT_CNTL
, 0x1);
3675 WREG32(SRBM_INT_ACK
, 0x1);
3677 WREG32(BIF_FB_EN
, FB_READ_EN
| FB_WRITE_EN
);
3679 mc_shared_chmap
= RREG32(MC_SHARED_CHMAP
);
3680 mc_arb_ramcfg
= RREG32(MC_ARB_RAMCFG
);
3682 rdev
->config
.cik
.num_tile_pipes
= rdev
->config
.cik
.max_tile_pipes
;
3683 rdev
->config
.cik
.mem_max_burst_length_bytes
= 256;
3684 tmp
= (mc_arb_ramcfg
& NOOFCOLS_MASK
) >> NOOFCOLS_SHIFT
;
3685 rdev
->config
.cik
.mem_row_size_in_kb
= (4 * (1 << (8 + tmp
))) / 1024;
3686 if (rdev
->config
.cik
.mem_row_size_in_kb
> 4)
3687 rdev
->config
.cik
.mem_row_size_in_kb
= 4;
3688 /* XXX use MC settings? */
3689 rdev
->config
.cik
.shader_engine_tile_size
= 32;
3690 rdev
->config
.cik
.num_gpus
= 1;
3691 rdev
->config
.cik
.multi_gpu_tile_size
= 64;
3693 /* fix up row size */
3694 gb_addr_config
&= ~ROW_SIZE_MASK
;
3695 switch (rdev
->config
.cik
.mem_row_size_in_kb
) {
3698 gb_addr_config
|= ROW_SIZE(0);
3701 gb_addr_config
|= ROW_SIZE(1);
3704 gb_addr_config
|= ROW_SIZE(2);
3708 /* setup tiling info dword. gb_addr_config is not adequate since it does
3709 * not have bank info, so create a custom tiling dword.
3710 * bits 3:0 num_pipes
3711 * bits 7:4 num_banks
3712 * bits 11:8 group_size
3713 * bits 15:12 row_size
3715 rdev
->config
.cik
.tile_config
= 0;
3716 switch (rdev
->config
.cik
.num_tile_pipes
) {
3718 rdev
->config
.cik
.tile_config
|= (0 << 0);
3721 rdev
->config
.cik
.tile_config
|= (1 << 0);
3724 rdev
->config
.cik
.tile_config
|= (2 << 0);
3728 /* XXX what about 12? */
3729 rdev
->config
.cik
.tile_config
|= (3 << 0);
3732 rdev
->config
.cik
.tile_config
|=
3733 ((mc_arb_ramcfg
& NOOFBANK_MASK
) >> NOOFBANK_SHIFT
) << 4;
3734 rdev
->config
.cik
.tile_config
|=
3735 ((gb_addr_config
& PIPE_INTERLEAVE_SIZE_MASK
) >> PIPE_INTERLEAVE_SIZE_SHIFT
) << 8;
3736 rdev
->config
.cik
.tile_config
|=
3737 ((gb_addr_config
& ROW_SIZE_MASK
) >> ROW_SIZE_SHIFT
) << 12;
3739 WREG32(GB_ADDR_CONFIG
, gb_addr_config
);
3740 WREG32(HDP_ADDR_CONFIG
, gb_addr_config
);
3741 WREG32(DMIF_ADDR_CALC
, gb_addr_config
);
3742 WREG32(SDMA0_TILING_CONFIG
+ SDMA0_REGISTER_OFFSET
, gb_addr_config
& 0x70);
3743 WREG32(SDMA0_TILING_CONFIG
+ SDMA1_REGISTER_OFFSET
, gb_addr_config
& 0x70);
3744 WREG32(UVD_UDEC_ADDR_CONFIG
, gb_addr_config
);
3745 WREG32(UVD_UDEC_DB_ADDR_CONFIG
, gb_addr_config
);
3746 WREG32(UVD_UDEC_DBW_ADDR_CONFIG
, gb_addr_config
);
3748 cik_tiling_mode_table_init(rdev
);
3750 cik_setup_rb(rdev
, rdev
->config
.cik
.max_shader_engines
,
3751 rdev
->config
.cik
.max_sh_per_se
,
3752 rdev
->config
.cik
.max_backends_per_se
);
3754 rdev
->config
.cik
.active_cus
= 0;
3755 for (i
= 0; i
< rdev
->config
.cik
.max_shader_engines
; i
++) {
3756 for (j
= 0; j
< rdev
->config
.cik
.max_sh_per_se
; j
++) {
3757 rdev
->config
.cik
.active_cus
+=
3758 hweight32(cik_get_cu_active_bitmap(rdev
, i
, j
));
3762 /* set HW defaults for 3D engine */
3763 WREG32(CP_MEQ_THRESHOLDS
, MEQ1_START(0x30) | MEQ2_START(0x60));
3765 mutex_lock(&rdev
->grbm_idx_mutex
);
3767 * making sure that the following register writes will be broadcasted
3768 * to all the shaders
3770 cik_select_se_sh(rdev
, 0xffffffff, 0xffffffff);
3771 WREG32(SX_DEBUG_1
, 0x20);
3773 WREG32(TA_CNTL_AUX
, 0x00010000);
3775 tmp
= RREG32(SPI_CONFIG_CNTL
);
3777 WREG32(SPI_CONFIG_CNTL
, tmp
);
3779 WREG32(SQ_CONFIG
, 1);
3781 WREG32(DB_DEBUG
, 0);
3783 tmp
= RREG32(DB_DEBUG2
) & ~0xf00fffff;
3785 WREG32(DB_DEBUG2
, tmp
);
3787 tmp
= RREG32(DB_DEBUG3
) & ~0x0002021c;
3789 WREG32(DB_DEBUG3
, tmp
);
3791 tmp
= RREG32(CB_HW_CONTROL
) & ~0x00010000;
3793 WREG32(CB_HW_CONTROL
, tmp
);
3795 WREG32(SPI_CONFIG_CNTL_1
, VTX_DONE_DELAY(4));
3797 WREG32(PA_SC_FIFO_SIZE
, (SC_FRONTEND_PRIM_FIFO_SIZE(rdev
->config
.cik
.sc_prim_fifo_size_frontend
) |
3798 SC_BACKEND_PRIM_FIFO_SIZE(rdev
->config
.cik
.sc_prim_fifo_size_backend
) |
3799 SC_HIZ_TILE_FIFO_SIZE(rdev
->config
.cik
.sc_hiz_tile_fifo_size
) |
3800 SC_EARLYZ_TILE_FIFO_SIZE(rdev
->config
.cik
.sc_earlyz_tile_fifo_size
)));
3802 WREG32(VGT_NUM_INSTANCES
, 1);
3804 WREG32(CP_PERFMON_CNTL
, 0);
3806 WREG32(SQ_CONFIG
, 0);
3808 WREG32(PA_SC_FORCE_EOV_MAX_CNTS
, (FORCE_EOV_MAX_CLK_CNT(4095) |
3809 FORCE_EOV_MAX_REZ_CNT(255)));
3811 WREG32(VGT_CACHE_INVALIDATION
, CACHE_INVALIDATION(VC_AND_TC
) |
3812 AUTO_INVLD_EN(ES_AND_GS_AUTO
));
3814 WREG32(VGT_GS_VERTEX_REUSE
, 16);
3815 WREG32(PA_SC_LINE_STIPPLE_STATE
, 0);
3817 tmp
= RREG32(HDP_MISC_CNTL
);
3818 tmp
|= HDP_FLUSH_INVALIDATE_CACHE
;
3819 WREG32(HDP_MISC_CNTL
, tmp
);
3821 hdp_host_path_cntl
= RREG32(HDP_HOST_PATH_CNTL
);
3822 WREG32(HDP_HOST_PATH_CNTL
, hdp_host_path_cntl
);
3824 WREG32(PA_CL_ENHANCE
, CLIP_VTX_REORDER_ENA
| NUM_CLIP_SEQ(3));
3825 WREG32(PA_SC_ENHANCE
, ENABLE_PA_SC_OUT_OF_ORDER
);
3826 mutex_unlock(&rdev
->grbm_idx_mutex
);
3832 * GPU scratch registers helpers function.
3835 * cik_scratch_init - setup driver info for CP scratch regs
3837 * @rdev: radeon_device pointer
3839 * Set up the number and offset of the CP scratch registers.
3840 * NOTE: use of CP scratch registers is a legacy inferface and
3841 * is not used by default on newer asics (r6xx+). On newer asics,
3842 * memory buffers are used for fences rather than scratch regs.
3844 static void cik_scratch_init(struct radeon_device
*rdev
)
3848 rdev
->scratch
.num_reg
= 7;
3849 rdev
->scratch
.reg_base
= SCRATCH_REG0
;
3850 for (i
= 0; i
< rdev
->scratch
.num_reg
; i
++) {
3851 rdev
->scratch
.free
[i
] = true;
3852 rdev
->scratch
.reg
[i
] = rdev
->scratch
.reg_base
+ (i
* 4);
3857 * cik_ring_test - basic gfx ring test
3859 * @rdev: radeon_device pointer
3860 * @ring: radeon_ring structure holding ring information
3862 * Allocate a scratch register and write to it using the gfx ring (CIK).
3863 * Provides a basic gfx ring test to verify that the ring is working.
3864 * Used by cik_cp_gfx_resume();
3865 * Returns 0 on success, error on failure.
3867 int cik_ring_test(struct radeon_device
*rdev
, struct radeon_ring
*ring
)
3874 r
= radeon_scratch_get(rdev
, &scratch
);
3876 DRM_ERROR("radeon: cp failed to get scratch reg (%d).\n", r
);
3879 WREG32(scratch
, 0xCAFEDEAD);
3880 r
= radeon_ring_lock(rdev
, ring
, 3);
3882 DRM_ERROR("radeon: cp failed to lock ring %d (%d).\n", ring
->idx
, r
);
3883 radeon_scratch_free(rdev
, scratch
);
3886 radeon_ring_write(ring
, PACKET3(PACKET3_SET_UCONFIG_REG
, 1));
3887 radeon_ring_write(ring
, ((scratch
- PACKET3_SET_UCONFIG_REG_START
) >> 2));
3888 radeon_ring_write(ring
, 0xDEADBEEF);
3889 radeon_ring_unlock_commit(rdev
, ring
, false);
3891 for (i
= 0; i
< rdev
->usec_timeout
; i
++) {
3892 tmp
= RREG32(scratch
);
3893 if (tmp
== 0xDEADBEEF)
3897 if (i
< rdev
->usec_timeout
) {
3898 DRM_INFO("ring test on %d succeeded in %d usecs\n", ring
->idx
, i
);
3900 DRM_ERROR("radeon: ring %d test failed (scratch(0x%04X)=0x%08X)\n",
3901 ring
->idx
, scratch
, tmp
);
3904 radeon_scratch_free(rdev
, scratch
);
3909 * cik_hdp_flush_cp_ring_emit - emit an hdp flush on the cp
3911 * @rdev: radeon_device pointer
3912 * @ridx: radeon ring index
3914 * Emits an hdp flush on the cp.
3916 static void cik_hdp_flush_cp_ring_emit(struct radeon_device
*rdev
,
3919 struct radeon_ring
*ring
= &rdev
->ring
[ridx
];
3922 switch (ring
->idx
) {
3923 case CAYMAN_RING_TYPE_CP1_INDEX
:
3924 case CAYMAN_RING_TYPE_CP2_INDEX
:
3928 ref_and_mask
= CP2
<< ring
->pipe
;
3931 ref_and_mask
= CP6
<< ring
->pipe
;
3937 case RADEON_RING_TYPE_GFX_INDEX
:
3942 radeon_ring_write(ring
, PACKET3(PACKET3_WAIT_REG_MEM
, 5));
3943 radeon_ring_write(ring
, (WAIT_REG_MEM_OPERATION(1) | /* write, wait, write */
3944 WAIT_REG_MEM_FUNCTION(3) | /* == */
3945 WAIT_REG_MEM_ENGINE(1))); /* pfp */
3946 radeon_ring_write(ring
, GPU_HDP_FLUSH_REQ
>> 2);
3947 radeon_ring_write(ring
, GPU_HDP_FLUSH_DONE
>> 2);
3948 radeon_ring_write(ring
, ref_and_mask
);
3949 radeon_ring_write(ring
, ref_and_mask
);
3950 radeon_ring_write(ring
, 0x20); /* poll interval */
3954 * cik_fence_gfx_ring_emit - emit a fence on the gfx ring
3956 * @rdev: radeon_device pointer
3957 * @fence: radeon fence object
3959 * Emits a fence sequnce number on the gfx ring and flushes
3962 void cik_fence_gfx_ring_emit(struct radeon_device
*rdev
,
3963 struct radeon_fence
*fence
)
3965 struct radeon_ring
*ring
= &rdev
->ring
[fence
->ring
];
3966 u64 addr
= rdev
->fence_drv
[fence
->ring
].gpu_addr
;
3968 /* Workaround for cache flush problems. First send a dummy EOP
3969 * event down the pipe with seq one below.
3971 radeon_ring_write(ring
, PACKET3(PACKET3_EVENT_WRITE_EOP
, 4));
3972 radeon_ring_write(ring
, (EOP_TCL1_ACTION_EN
|
3974 EVENT_TYPE(CACHE_FLUSH_AND_INV_TS_EVENT
) |
3976 radeon_ring_write(ring
, addr
& 0xfffffffc);
3977 radeon_ring_write(ring
, (upper_32_bits(addr
) & 0xffff) |
3978 DATA_SEL(1) | INT_SEL(0));
3979 radeon_ring_write(ring
, fence
->seq
- 1);
3980 radeon_ring_write(ring
, 0);
3982 /* Then send the real EOP event down the pipe. */
3983 radeon_ring_write(ring
, PACKET3(PACKET3_EVENT_WRITE_EOP
, 4));
3984 radeon_ring_write(ring
, (EOP_TCL1_ACTION_EN
|
3986 EVENT_TYPE(CACHE_FLUSH_AND_INV_TS_EVENT
) |
3988 radeon_ring_write(ring
, addr
& 0xfffffffc);
3989 radeon_ring_write(ring
, (upper_32_bits(addr
) & 0xffff) | DATA_SEL(1) | INT_SEL(2));
3990 radeon_ring_write(ring
, fence
->seq
);
3991 radeon_ring_write(ring
, 0);
3995 * cik_fence_compute_ring_emit - emit a fence on the compute ring
3997 * @rdev: radeon_device pointer
3998 * @fence: radeon fence object
4000 * Emits a fence sequnce number on the compute ring and flushes
4003 void cik_fence_compute_ring_emit(struct radeon_device
*rdev
,
4004 struct radeon_fence
*fence
)
4006 struct radeon_ring
*ring
= &rdev
->ring
[fence
->ring
];
4007 u64 addr
= rdev
->fence_drv
[fence
->ring
].gpu_addr
;
4009 /* RELEASE_MEM - flush caches, send int */
4010 radeon_ring_write(ring
, PACKET3(PACKET3_RELEASE_MEM
, 5));
4011 radeon_ring_write(ring
, (EOP_TCL1_ACTION_EN
|
4013 EVENT_TYPE(CACHE_FLUSH_AND_INV_TS_EVENT
) |
4015 radeon_ring_write(ring
, DATA_SEL(1) | INT_SEL(2));
4016 radeon_ring_write(ring
, addr
& 0xfffffffc);
4017 radeon_ring_write(ring
, upper_32_bits(addr
));
4018 radeon_ring_write(ring
, fence
->seq
);
4019 radeon_ring_write(ring
, 0);
4023 * cik_semaphore_ring_emit - emit a semaphore on the CP ring
4025 * @rdev: radeon_device pointer
4026 * @ring: radeon ring buffer object
4027 * @semaphore: radeon semaphore object
4028 * @emit_wait: Is this a sempahore wait?
4030 * Emits a semaphore signal/wait packet to the CP ring and prevents the PFP
4031 * from running ahead of semaphore waits.
4033 bool cik_semaphore_ring_emit(struct radeon_device
*rdev
,
4034 struct radeon_ring
*ring
,
4035 struct radeon_semaphore
*semaphore
,
4038 uint64_t addr
= semaphore
->gpu_addr
;
4039 unsigned sel
= emit_wait
? PACKET3_SEM_SEL_WAIT
: PACKET3_SEM_SEL_SIGNAL
;
4041 radeon_ring_write(ring
, PACKET3(PACKET3_MEM_SEMAPHORE
, 1));
4042 radeon_ring_write(ring
, lower_32_bits(addr
));
4043 radeon_ring_write(ring
, (upper_32_bits(addr
) & 0xffff) | sel
);
4045 if (emit_wait
&& ring
->idx
== RADEON_RING_TYPE_GFX_INDEX
) {
4046 /* Prevent the PFP from running ahead of the semaphore wait */
4047 radeon_ring_write(ring
, PACKET3(PACKET3_PFP_SYNC_ME
, 0));
4048 radeon_ring_write(ring
, 0x0);
4055 * cik_copy_cpdma - copy pages using the CP DMA engine
4057 * @rdev: radeon_device pointer
4058 * @src_offset: src GPU address
4059 * @dst_offset: dst GPU address
4060 * @num_gpu_pages: number of GPU pages to xfer
4061 * @resv: reservation object to sync to
4063 * Copy GPU paging using the CP DMA engine (CIK+).
4064 * Used by the radeon ttm implementation to move pages if
4065 * registered as the asic copy callback.
4067 struct radeon_fence
*cik_copy_cpdma(struct radeon_device
*rdev
,
4068 uint64_t src_offset
, uint64_t dst_offset
,
4069 unsigned num_gpu_pages
,
4070 struct reservation_object
*resv
)
4072 struct radeon_fence
*fence
;
4073 struct radeon_sync sync
;
4074 int ring_index
= rdev
->asic
->copy
.blit_ring_index
;
4075 struct radeon_ring
*ring
= &rdev
->ring
[ring_index
];
4076 u32 size_in_bytes
, cur_size_in_bytes
, control
;
4080 radeon_sync_create(&sync
);
4082 size_in_bytes
= (num_gpu_pages
<< RADEON_GPU_PAGE_SHIFT
);
4083 num_loops
= DIV_ROUND_UP(size_in_bytes
, 0x1fffff);
4084 r
= radeon_ring_lock(rdev
, ring
, num_loops
* 7 + 18);
4086 DRM_ERROR("radeon: moving bo (%d).\n", r
);
4087 radeon_sync_free(rdev
, &sync
, NULL
);
4091 radeon_sync_resv(rdev
, &sync
, resv
, false);
4092 radeon_sync_rings(rdev
, &sync
, ring
->idx
);
4094 for (i
= 0; i
< num_loops
; i
++) {
4095 cur_size_in_bytes
= size_in_bytes
;
4096 if (cur_size_in_bytes
> 0x1fffff)
4097 cur_size_in_bytes
= 0x1fffff;
4098 size_in_bytes
-= cur_size_in_bytes
;
4100 if (size_in_bytes
== 0)
4101 control
|= PACKET3_DMA_DATA_CP_SYNC
;
4102 radeon_ring_write(ring
, PACKET3(PACKET3_DMA_DATA
, 5));
4103 radeon_ring_write(ring
, control
);
4104 radeon_ring_write(ring
, lower_32_bits(src_offset
));
4105 radeon_ring_write(ring
, upper_32_bits(src_offset
));
4106 radeon_ring_write(ring
, lower_32_bits(dst_offset
));
4107 radeon_ring_write(ring
, upper_32_bits(dst_offset
));
4108 radeon_ring_write(ring
, cur_size_in_bytes
);
4109 src_offset
+= cur_size_in_bytes
;
4110 dst_offset
+= cur_size_in_bytes
;
4113 r
= radeon_fence_emit(rdev
, &fence
, ring
->idx
);
4115 radeon_ring_unlock_undo(rdev
, ring
);
4116 radeon_sync_free(rdev
, &sync
, NULL
);
4120 radeon_ring_unlock_commit(rdev
, ring
, false);
4121 radeon_sync_free(rdev
, &sync
, fence
);
4130 * cik_ring_ib_execute - emit an IB (Indirect Buffer) on the gfx ring
4132 * @rdev: radeon_device pointer
4133 * @ib: radeon indirect buffer object
4135 * Emits an DE (drawing engine) or CE (constant engine) IB
4136 * on the gfx ring. IBs are usually generated by userspace
4137 * acceleration drivers and submitted to the kernel for
4138 * sheduling on the ring. This function schedules the IB
4139 * on the gfx ring for execution by the GPU.
4141 void cik_ring_ib_execute(struct radeon_device
*rdev
, struct radeon_ib
*ib
)
4143 struct radeon_ring
*ring
= &rdev
->ring
[ib
->ring
];
4144 unsigned vm_id
= ib
->vm
? ib
->vm
->ids
[ib
->ring
].id
: 0;
4145 u32 header
, control
= INDIRECT_BUFFER_VALID
;
4147 if (ib
->is_const_ib
) {
4148 /* set switch buffer packet before const IB */
4149 radeon_ring_write(ring
, PACKET3(PACKET3_SWITCH_BUFFER
, 0));
4150 radeon_ring_write(ring
, 0);
4152 header
= PACKET3(PACKET3_INDIRECT_BUFFER_CONST
, 2);
4155 if (ring
->rptr_save_reg
) {
4156 next_rptr
= ring
->wptr
+ 3 + 4;
4157 radeon_ring_write(ring
, PACKET3(PACKET3_SET_UCONFIG_REG
, 1));
4158 radeon_ring_write(ring
, ((ring
->rptr_save_reg
-
4159 PACKET3_SET_UCONFIG_REG_START
) >> 2));
4160 radeon_ring_write(ring
, next_rptr
);
4161 } else if (rdev
->wb
.enabled
) {
4162 next_rptr
= ring
->wptr
+ 5 + 4;
4163 radeon_ring_write(ring
, PACKET3(PACKET3_WRITE_DATA
, 3));
4164 radeon_ring_write(ring
, WRITE_DATA_DST_SEL(1));
4165 radeon_ring_write(ring
, ring
->next_rptr_gpu_addr
& 0xfffffffc);
4166 radeon_ring_write(ring
, upper_32_bits(ring
->next_rptr_gpu_addr
));
4167 radeon_ring_write(ring
, next_rptr
);
4170 header
= PACKET3(PACKET3_INDIRECT_BUFFER
, 2);
4173 control
|= ib
->length_dw
| (vm_id
<< 24);
4175 radeon_ring_write(ring
, header
);
4176 radeon_ring_write(ring
,
4180 (ib
->gpu_addr
& 0xFFFFFFFC));
4181 radeon_ring_write(ring
, upper_32_bits(ib
->gpu_addr
) & 0xFFFF);
4182 radeon_ring_write(ring
, control
);
4186 * cik_ib_test - basic gfx ring IB test
4188 * @rdev: radeon_device pointer
4189 * @ring: radeon_ring structure holding ring information
4191 * Allocate an IB and execute it on the gfx ring (CIK).
4192 * Provides a basic gfx ring test to verify that IBs are working.
4193 * Returns 0 on success, error on failure.
4195 int cik_ib_test(struct radeon_device
*rdev
, struct radeon_ring
*ring
)
4197 struct radeon_ib ib
;
4203 r
= radeon_scratch_get(rdev
, &scratch
);
4205 DRM_ERROR("radeon: failed to get scratch reg (%d).\n", r
);
4208 WREG32(scratch
, 0xCAFEDEAD);
4209 r
= radeon_ib_get(rdev
, ring
->idx
, &ib
, NULL
, 256);
4211 DRM_ERROR("radeon: failed to get ib (%d).\n", r
);
4212 radeon_scratch_free(rdev
, scratch
);
4215 ib
.ptr
[0] = PACKET3(PACKET3_SET_UCONFIG_REG
, 1);
4216 ib
.ptr
[1] = ((scratch
- PACKET3_SET_UCONFIG_REG_START
) >> 2);
4217 ib
.ptr
[2] = 0xDEADBEEF;
4219 r
= radeon_ib_schedule(rdev
, &ib
, NULL
, false);
4221 radeon_scratch_free(rdev
, scratch
);
4222 radeon_ib_free(rdev
, &ib
);
4223 DRM_ERROR("radeon: failed to schedule ib (%d).\n", r
);
4226 r
= radeon_fence_wait(ib
.fence
, false);
4228 DRM_ERROR("radeon: fence wait failed (%d).\n", r
);
4229 radeon_scratch_free(rdev
, scratch
);
4230 radeon_ib_free(rdev
, &ib
);
4233 for (i
= 0; i
< rdev
->usec_timeout
; i
++) {
4234 tmp
= RREG32(scratch
);
4235 if (tmp
== 0xDEADBEEF)
4239 if (i
< rdev
->usec_timeout
) {
4240 DRM_INFO("ib test on ring %d succeeded in %u usecs\n", ib
.fence
->ring
, i
);
4242 DRM_ERROR("radeon: ib test failed (scratch(0x%04X)=0x%08X)\n",
4246 radeon_scratch_free(rdev
, scratch
);
4247 radeon_ib_free(rdev
, &ib
);
4253 * On CIK, gfx and compute now have independant command processors.
4256 * Gfx consists of a single ring and can process both gfx jobs and
4257 * compute jobs. The gfx CP consists of three microengines (ME):
4258 * PFP - Pre-Fetch Parser
4260 * CE - Constant Engine
4261 * The PFP and ME make up what is considered the Drawing Engine (DE).
4262 * The CE is an asynchronous engine used for updating buffer desciptors
4263 * used by the DE so that they can be loaded into cache in parallel
4264 * while the DE is processing state update packets.
4267 * The compute CP consists of two microengines (ME):
4268 * MEC1 - Compute MicroEngine 1
4269 * MEC2 - Compute MicroEngine 2
4270 * Each MEC supports 4 compute pipes and each pipe supports 8 queues.
4271 * The queues are exposed to userspace and are programmed directly
4272 * by the compute runtime.
4275 * cik_cp_gfx_enable - enable/disable the gfx CP MEs
4277 * @rdev: radeon_device pointer
4278 * @enable: enable or disable the MEs
4280 * Halts or unhalts the gfx MEs.
4282 static void cik_cp_gfx_enable(struct radeon_device
*rdev
, bool enable
)
4285 WREG32(CP_ME_CNTL
, 0);
4287 if (rdev
->asic
->copy
.copy_ring_index
== RADEON_RING_TYPE_GFX_INDEX
)
4288 radeon_ttm_set_active_vram_size(rdev
, rdev
->mc
.visible_vram_size
);
4289 WREG32(CP_ME_CNTL
, (CP_ME_HALT
| CP_PFP_HALT
| CP_CE_HALT
));
4290 rdev
->ring
[RADEON_RING_TYPE_GFX_INDEX
].ready
= false;
4296 * cik_cp_gfx_load_microcode - load the gfx CP ME ucode
4298 * @rdev: radeon_device pointer
4300 * Loads the gfx PFP, ME, and CE ucode.
4301 * Returns 0 for success, -EINVAL if the ucode is not available.
4303 static int cik_cp_gfx_load_microcode(struct radeon_device
*rdev
)
4307 if (!rdev
->me_fw
|| !rdev
->pfp_fw
|| !rdev
->ce_fw
)
4310 cik_cp_gfx_enable(rdev
, false);
4313 const struct gfx_firmware_header_v1_0
*pfp_hdr
=
4314 (const struct gfx_firmware_header_v1_0
*)rdev
->pfp_fw
->data
;
4315 const struct gfx_firmware_header_v1_0
*ce_hdr
=
4316 (const struct gfx_firmware_header_v1_0
*)rdev
->ce_fw
->data
;
4317 const struct gfx_firmware_header_v1_0
*me_hdr
=
4318 (const struct gfx_firmware_header_v1_0
*)rdev
->me_fw
->data
;
4319 const __le32
*fw_data
;
4322 radeon_ucode_print_gfx_hdr(&pfp_hdr
->header
);
4323 radeon_ucode_print_gfx_hdr(&ce_hdr
->header
);
4324 radeon_ucode_print_gfx_hdr(&me_hdr
->header
);
4327 fw_data
= (const __le32
*)
4328 (rdev
->pfp_fw
->data
+ le32_to_cpu(pfp_hdr
->header
.ucode_array_offset_bytes
));
4329 fw_size
= le32_to_cpu(pfp_hdr
->header
.ucode_size_bytes
) / 4;
4330 WREG32(CP_PFP_UCODE_ADDR
, 0);
4331 for (i
= 0; i
< fw_size
; i
++)
4332 WREG32(CP_PFP_UCODE_DATA
, le32_to_cpup(fw_data
++));
4333 WREG32(CP_PFP_UCODE_ADDR
, le32_to_cpu(pfp_hdr
->header
.ucode_version
));
4336 fw_data
= (const __le32
*)
4337 (rdev
->ce_fw
->data
+ le32_to_cpu(ce_hdr
->header
.ucode_array_offset_bytes
));
4338 fw_size
= le32_to_cpu(ce_hdr
->header
.ucode_size_bytes
) / 4;
4339 WREG32(CP_CE_UCODE_ADDR
, 0);
4340 for (i
= 0; i
< fw_size
; i
++)
4341 WREG32(CP_CE_UCODE_DATA
, le32_to_cpup(fw_data
++));
4342 WREG32(CP_CE_UCODE_ADDR
, le32_to_cpu(ce_hdr
->header
.ucode_version
));
4345 fw_data
= (const __be32
*)
4346 (rdev
->me_fw
->data
+ le32_to_cpu(me_hdr
->header
.ucode_array_offset_bytes
));
4347 fw_size
= le32_to_cpu(me_hdr
->header
.ucode_size_bytes
) / 4;
4348 WREG32(CP_ME_RAM_WADDR
, 0);
4349 for (i
= 0; i
< fw_size
; i
++)
4350 WREG32(CP_ME_RAM_DATA
, le32_to_cpup(fw_data
++));
4351 WREG32(CP_ME_RAM_WADDR
, le32_to_cpu(me_hdr
->header
.ucode_version
));
4352 WREG32(CP_ME_RAM_RADDR
, le32_to_cpu(me_hdr
->header
.ucode_version
));
4354 const __be32
*fw_data
;
4357 fw_data
= (const __be32
*)rdev
->pfp_fw
->data
;
4358 WREG32(CP_PFP_UCODE_ADDR
, 0);
4359 for (i
= 0; i
< CIK_PFP_UCODE_SIZE
; i
++)
4360 WREG32(CP_PFP_UCODE_DATA
, be32_to_cpup(fw_data
++));
4361 WREG32(CP_PFP_UCODE_ADDR
, 0);
4364 fw_data
= (const __be32
*)rdev
->ce_fw
->data
;
4365 WREG32(CP_CE_UCODE_ADDR
, 0);
4366 for (i
= 0; i
< CIK_CE_UCODE_SIZE
; i
++)
4367 WREG32(CP_CE_UCODE_DATA
, be32_to_cpup(fw_data
++));
4368 WREG32(CP_CE_UCODE_ADDR
, 0);
4371 fw_data
= (const __be32
*)rdev
->me_fw
->data
;
4372 WREG32(CP_ME_RAM_WADDR
, 0);
4373 for (i
= 0; i
< CIK_ME_UCODE_SIZE
; i
++)
4374 WREG32(CP_ME_RAM_DATA
, be32_to_cpup(fw_data
++));
4375 WREG32(CP_ME_RAM_WADDR
, 0);
4382 * cik_cp_gfx_start - start the gfx ring
4384 * @rdev: radeon_device pointer
4386 * Enables the ring and loads the clear state context and other
4387 * packets required to init the ring.
4388 * Returns 0 for success, error for failure.
4390 static int cik_cp_gfx_start(struct radeon_device
*rdev
)
4392 struct radeon_ring
*ring
= &rdev
->ring
[RADEON_RING_TYPE_GFX_INDEX
];
4396 WREG32(CP_MAX_CONTEXT
, rdev
->config
.cik
.max_hw_contexts
- 1);
4397 WREG32(CP_ENDIAN_SWAP
, 0);
4398 WREG32(CP_DEVICE_ID
, 1);
4400 cik_cp_gfx_enable(rdev
, true);
4402 r
= radeon_ring_lock(rdev
, ring
, cik_default_size
+ 17);
4404 DRM_ERROR("radeon: cp failed to lock ring (%d).\n", r
);
4408 /* init the CE partitions. CE only used for gfx on CIK */
4409 radeon_ring_write(ring
, PACKET3(PACKET3_SET_BASE
, 2));
4410 radeon_ring_write(ring
, PACKET3_BASE_INDEX(CE_PARTITION_BASE
));
4411 radeon_ring_write(ring
, 0x8000);
4412 radeon_ring_write(ring
, 0x8000);
4414 /* setup clear context state */
4415 radeon_ring_write(ring
, PACKET3(PACKET3_PREAMBLE_CNTL
, 0));
4416 radeon_ring_write(ring
, PACKET3_PREAMBLE_BEGIN_CLEAR_STATE
);
4418 radeon_ring_write(ring
, PACKET3(PACKET3_CONTEXT_CONTROL
, 1));
4419 radeon_ring_write(ring
, 0x80000000);
4420 radeon_ring_write(ring
, 0x80000000);
4422 for (i
= 0; i
< cik_default_size
; i
++)
4423 radeon_ring_write(ring
, cik_default_state
[i
]);
4425 radeon_ring_write(ring
, PACKET3(PACKET3_PREAMBLE_CNTL
, 0));
4426 radeon_ring_write(ring
, PACKET3_PREAMBLE_END_CLEAR_STATE
);
4428 /* set clear context state */
4429 radeon_ring_write(ring
, PACKET3(PACKET3_CLEAR_STATE
, 0));
4430 radeon_ring_write(ring
, 0);
4432 radeon_ring_write(ring
, PACKET3(PACKET3_SET_CONTEXT_REG
, 2));
4433 radeon_ring_write(ring
, 0x00000316);
4434 radeon_ring_write(ring
, 0x0000000e); /* VGT_VERTEX_REUSE_BLOCK_CNTL */
4435 radeon_ring_write(ring
, 0x00000010); /* VGT_OUT_DEALLOC_CNTL */
4437 radeon_ring_unlock_commit(rdev
, ring
, false);
4443 * cik_cp_gfx_fini - stop the gfx ring
4445 * @rdev: radeon_device pointer
4447 * Stop the gfx ring and tear down the driver ring
4450 static void cik_cp_gfx_fini(struct radeon_device
*rdev
)
4452 cik_cp_gfx_enable(rdev
, false);
4453 radeon_ring_fini(rdev
, &rdev
->ring
[RADEON_RING_TYPE_GFX_INDEX
]);
4457 * cik_cp_gfx_resume - setup the gfx ring buffer registers
4459 * @rdev: radeon_device pointer
4461 * Program the location and size of the gfx ring buffer
4462 * and test it to make sure it's working.
4463 * Returns 0 for success, error for failure.
4465 static int cik_cp_gfx_resume(struct radeon_device
*rdev
)
4467 struct radeon_ring
*ring
;
4473 WREG32(CP_SEM_WAIT_TIMER
, 0x0);
4474 if (rdev
->family
!= CHIP_HAWAII
)
4475 WREG32(CP_SEM_INCOMPLETE_TIMER_CNTL
, 0x0);
4477 /* Set the write pointer delay */
4478 WREG32(CP_RB_WPTR_DELAY
, 0);
4480 /* set the RB to use vmid 0 */
4481 WREG32(CP_RB_VMID
, 0);
4483 WREG32(SCRATCH_ADDR
, ((rdev
->wb
.gpu_addr
+ RADEON_WB_SCRATCH_OFFSET
) >> 8) & 0xFFFFFFFF);
4485 /* ring 0 - compute and gfx */
4486 /* Set ring buffer size */
4487 ring
= &rdev
->ring
[RADEON_RING_TYPE_GFX_INDEX
];
4488 rb_bufsz
= order_base_2(ring
->ring_size
/ 8);
4489 tmp
= (order_base_2(RADEON_GPU_PAGE_SIZE
/8) << 8) | rb_bufsz
;
4491 tmp
|= BUF_SWAP_32BIT
;
4493 WREG32(CP_RB0_CNTL
, tmp
);
4495 /* Initialize the ring buffer's read and write pointers */
4496 WREG32(CP_RB0_CNTL
, tmp
| RB_RPTR_WR_ENA
);
4498 WREG32(CP_RB0_WPTR
, ring
->wptr
);
4500 /* set the wb address wether it's enabled or not */
4501 WREG32(CP_RB0_RPTR_ADDR
, (rdev
->wb
.gpu_addr
+ RADEON_WB_CP_RPTR_OFFSET
) & 0xFFFFFFFC);
4502 WREG32(CP_RB0_RPTR_ADDR_HI
, upper_32_bits(rdev
->wb
.gpu_addr
+ RADEON_WB_CP_RPTR_OFFSET
) & 0xFF);
4504 /* scratch register shadowing is no longer supported */
4505 WREG32(SCRATCH_UMSK
, 0);
4507 if (!rdev
->wb
.enabled
)
4508 tmp
|= RB_NO_UPDATE
;
4511 WREG32(CP_RB0_CNTL
, tmp
);
4513 rb_addr
= ring
->gpu_addr
>> 8;
4514 WREG32(CP_RB0_BASE
, rb_addr
);
4515 WREG32(CP_RB0_BASE_HI
, upper_32_bits(rb_addr
));
4517 /* start the ring */
4518 cik_cp_gfx_start(rdev
);
4519 rdev
->ring
[RADEON_RING_TYPE_GFX_INDEX
].ready
= true;
4520 r
= radeon_ring_test(rdev
, RADEON_RING_TYPE_GFX_INDEX
, &rdev
->ring
[RADEON_RING_TYPE_GFX_INDEX
]);
4522 rdev
->ring
[RADEON_RING_TYPE_GFX_INDEX
].ready
= false;
4526 if (rdev
->asic
->copy
.copy_ring_index
== RADEON_RING_TYPE_GFX_INDEX
)
4527 radeon_ttm_set_active_vram_size(rdev
, rdev
->mc
.real_vram_size
);
4532 u32
cik_gfx_get_rptr(struct radeon_device
*rdev
,
4533 struct radeon_ring
*ring
)
4537 if (rdev
->wb
.enabled
)
4538 rptr
= rdev
->wb
.wb
[ring
->rptr_offs
/4];
4540 rptr
= RREG32(CP_RB0_RPTR
);
4545 u32
cik_gfx_get_wptr(struct radeon_device
*rdev
,
4546 struct radeon_ring
*ring
)
4550 wptr
= RREG32(CP_RB0_WPTR
);
4555 void cik_gfx_set_wptr(struct radeon_device
*rdev
,
4556 struct radeon_ring
*ring
)
4558 WREG32(CP_RB0_WPTR
, ring
->wptr
);
4559 (void)RREG32(CP_RB0_WPTR
);
4562 u32
cik_compute_get_rptr(struct radeon_device
*rdev
,
4563 struct radeon_ring
*ring
)
4567 if (rdev
->wb
.enabled
) {
4568 rptr
= rdev
->wb
.wb
[ring
->rptr_offs
/4];
4570 mutex_lock(&rdev
->srbm_mutex
);
4571 cik_srbm_select(rdev
, ring
->me
, ring
->pipe
, ring
->queue
, 0);
4572 rptr
= RREG32(CP_HQD_PQ_RPTR
);
4573 cik_srbm_select(rdev
, 0, 0, 0, 0);
4574 mutex_unlock(&rdev
->srbm_mutex
);
4580 u32
cik_compute_get_wptr(struct radeon_device
*rdev
,
4581 struct radeon_ring
*ring
)
4585 if (rdev
->wb
.enabled
) {
4586 /* XXX check if swapping is necessary on BE */
4587 wptr
= rdev
->wb
.wb
[ring
->wptr_offs
/4];
4589 mutex_lock(&rdev
->srbm_mutex
);
4590 cik_srbm_select(rdev
, ring
->me
, ring
->pipe
, ring
->queue
, 0);
4591 wptr
= RREG32(CP_HQD_PQ_WPTR
);
4592 cik_srbm_select(rdev
, 0, 0, 0, 0);
4593 mutex_unlock(&rdev
->srbm_mutex
);
4599 void cik_compute_set_wptr(struct radeon_device
*rdev
,
4600 struct radeon_ring
*ring
)
4602 /* XXX check if swapping is necessary on BE */
4603 rdev
->wb
.wb
[ring
->wptr_offs
/4] = ring
->wptr
;
4604 WDOORBELL32(ring
->doorbell_index
, ring
->wptr
);
4607 static void cik_compute_stop(struct radeon_device
*rdev
,
4608 struct radeon_ring
*ring
)
4612 cik_srbm_select(rdev
, ring
->me
, ring
->pipe
, ring
->queue
, 0);
4613 /* Disable wptr polling. */
4614 tmp
= RREG32(CP_PQ_WPTR_POLL_CNTL
);
4615 tmp
&= ~WPTR_POLL_EN
;
4616 WREG32(CP_PQ_WPTR_POLL_CNTL
, tmp
);
4618 if (RREG32(CP_HQD_ACTIVE
) & 1) {
4619 WREG32(CP_HQD_DEQUEUE_REQUEST
, 1);
4620 for (j
= 0; j
< rdev
->usec_timeout
; j
++) {
4621 if (!(RREG32(CP_HQD_ACTIVE
) & 1))
4625 WREG32(CP_HQD_DEQUEUE_REQUEST
, 0);
4626 WREG32(CP_HQD_PQ_RPTR
, 0);
4627 WREG32(CP_HQD_PQ_WPTR
, 0);
4629 cik_srbm_select(rdev
, 0, 0, 0, 0);
4633 * cik_cp_compute_enable - enable/disable the compute CP MEs
4635 * @rdev: radeon_device pointer
4636 * @enable: enable or disable the MEs
4638 * Halts or unhalts the compute MEs.
4640 static void cik_cp_compute_enable(struct radeon_device
*rdev
, bool enable
)
4643 WREG32(CP_MEC_CNTL
, 0);
4646 * To make hibernation reliable we need to clear compute ring
4647 * configuration before halting the compute ring.
4649 mutex_lock(&rdev
->srbm_mutex
);
4650 cik_compute_stop(rdev
,&rdev
->ring
[CAYMAN_RING_TYPE_CP1_INDEX
]);
4651 cik_compute_stop(rdev
,&rdev
->ring
[CAYMAN_RING_TYPE_CP2_INDEX
]);
4652 mutex_unlock(&rdev
->srbm_mutex
);
4654 WREG32(CP_MEC_CNTL
, (MEC_ME1_HALT
| MEC_ME2_HALT
));
4655 rdev
->ring
[CAYMAN_RING_TYPE_CP1_INDEX
].ready
= false;
4656 rdev
->ring
[CAYMAN_RING_TYPE_CP2_INDEX
].ready
= false;
4662 * cik_cp_compute_load_microcode - load the compute CP ME ucode
4664 * @rdev: radeon_device pointer
4666 * Loads the compute MEC1&2 ucode.
4667 * Returns 0 for success, -EINVAL if the ucode is not available.
4669 static int cik_cp_compute_load_microcode(struct radeon_device
*rdev
)
4676 cik_cp_compute_enable(rdev
, false);
4679 const struct gfx_firmware_header_v1_0
*mec_hdr
=
4680 (const struct gfx_firmware_header_v1_0
*)rdev
->mec_fw
->data
;
4681 const __le32
*fw_data
;
4684 radeon_ucode_print_gfx_hdr(&mec_hdr
->header
);
4687 fw_data
= (const __le32
*)
4688 (rdev
->mec_fw
->data
+ le32_to_cpu(mec_hdr
->header
.ucode_array_offset_bytes
));
4689 fw_size
= le32_to_cpu(mec_hdr
->header
.ucode_size_bytes
) / 4;
4690 WREG32(CP_MEC_ME1_UCODE_ADDR
, 0);
4691 for (i
= 0; i
< fw_size
; i
++)
4692 WREG32(CP_MEC_ME1_UCODE_DATA
, le32_to_cpup(fw_data
++));
4693 WREG32(CP_MEC_ME1_UCODE_ADDR
, le32_to_cpu(mec_hdr
->header
.ucode_version
));
4696 if (rdev
->family
== CHIP_KAVERI
) {
4697 const struct gfx_firmware_header_v1_0
*mec2_hdr
=
4698 (const struct gfx_firmware_header_v1_0
*)rdev
->mec2_fw
->data
;
4700 fw_data
= (const __le32
*)
4701 (rdev
->mec2_fw
->data
+
4702 le32_to_cpu(mec2_hdr
->header
.ucode_array_offset_bytes
));
4703 fw_size
= le32_to_cpu(mec2_hdr
->header
.ucode_size_bytes
) / 4;
4704 WREG32(CP_MEC_ME2_UCODE_ADDR
, 0);
4705 for (i
= 0; i
< fw_size
; i
++)
4706 WREG32(CP_MEC_ME2_UCODE_DATA
, le32_to_cpup(fw_data
++));
4707 WREG32(CP_MEC_ME2_UCODE_ADDR
, le32_to_cpu(mec2_hdr
->header
.ucode_version
));
4710 const __be32
*fw_data
;
4713 fw_data
= (const __be32
*)rdev
->mec_fw
->data
;
4714 WREG32(CP_MEC_ME1_UCODE_ADDR
, 0);
4715 for (i
= 0; i
< CIK_MEC_UCODE_SIZE
; i
++)
4716 WREG32(CP_MEC_ME1_UCODE_DATA
, be32_to_cpup(fw_data
++));
4717 WREG32(CP_MEC_ME1_UCODE_ADDR
, 0);
4719 if (rdev
->family
== CHIP_KAVERI
) {
4721 fw_data
= (const __be32
*)rdev
->mec_fw
->data
;
4722 WREG32(CP_MEC_ME2_UCODE_ADDR
, 0);
4723 for (i
= 0; i
< CIK_MEC_UCODE_SIZE
; i
++)
4724 WREG32(CP_MEC_ME2_UCODE_DATA
, be32_to_cpup(fw_data
++));
4725 WREG32(CP_MEC_ME2_UCODE_ADDR
, 0);
4733 * cik_cp_compute_start - start the compute queues
4735 * @rdev: radeon_device pointer
4737 * Enable the compute queues.
4738 * Returns 0 for success, error for failure.
4740 static int cik_cp_compute_start(struct radeon_device
*rdev
)
4742 cik_cp_compute_enable(rdev
, true);
4748 * cik_cp_compute_fini - stop the compute queues
4750 * @rdev: radeon_device pointer
4752 * Stop the compute queues and tear down the driver queue
4755 static void cik_cp_compute_fini(struct radeon_device
*rdev
)
4759 cik_cp_compute_enable(rdev
, false);
4761 for (i
= 0; i
< 2; i
++) {
4763 idx
= CAYMAN_RING_TYPE_CP1_INDEX
;
4765 idx
= CAYMAN_RING_TYPE_CP2_INDEX
;
4767 if (rdev
->ring
[idx
].mqd_obj
) {
4768 r
= radeon_bo_reserve(rdev
->ring
[idx
].mqd_obj
, false);
4769 if (unlikely(r
!= 0))
4770 dev_warn(rdev
->dev
, "(%d) reserve MQD bo failed\n", r
);
4772 radeon_bo_unpin(rdev
->ring
[idx
].mqd_obj
);
4773 radeon_bo_unreserve(rdev
->ring
[idx
].mqd_obj
);
4775 radeon_bo_unref(&rdev
->ring
[idx
].mqd_obj
);
4776 rdev
->ring
[idx
].mqd_obj
= NULL
;
4781 static void cik_mec_fini(struct radeon_device
*rdev
)
4785 if (rdev
->mec
.hpd_eop_obj
) {
4786 r
= radeon_bo_reserve(rdev
->mec
.hpd_eop_obj
, false);
4787 if (unlikely(r
!= 0))
4788 dev_warn(rdev
->dev
, "(%d) reserve HPD EOP bo failed\n", r
);
4789 radeon_bo_unpin(rdev
->mec
.hpd_eop_obj
);
4790 radeon_bo_unreserve(rdev
->mec
.hpd_eop_obj
);
4792 radeon_bo_unref(&rdev
->mec
.hpd_eop_obj
);
4793 rdev
->mec
.hpd_eop_obj
= NULL
;
4797 #define MEC_HPD_SIZE 2048
4799 static int cik_mec_init(struct radeon_device
*rdev
)
4805 * KV: 2 MEC, 4 Pipes/MEC, 8 Queues/Pipe - 64 Queues total
4806 * CI/KB: 1 MEC, 4 Pipes/MEC, 8 Queues/Pipe - 32 Queues total
4807 * Nonetheless, we assign only 1 pipe because all other pipes will
4810 rdev
->mec
.num_mec
= 1;
4811 rdev
->mec
.num_pipe
= 1;
4812 rdev
->mec
.num_queue
= rdev
->mec
.num_mec
* rdev
->mec
.num_pipe
* 8;
4814 if (rdev
->mec
.hpd_eop_obj
== NULL
) {
4815 r
= radeon_bo_create(rdev
,
4816 rdev
->mec
.num_mec
*rdev
->mec
.num_pipe
* MEC_HPD_SIZE
* 2,
4818 RADEON_GEM_DOMAIN_GTT
, 0, NULL
, NULL
,
4819 &rdev
->mec
.hpd_eop_obj
);
4821 dev_warn(rdev
->dev
, "(%d) create HDP EOP bo failed\n", r
);
4826 r
= radeon_bo_reserve(rdev
->mec
.hpd_eop_obj
, false);
4827 if (unlikely(r
!= 0)) {
4831 r
= radeon_bo_pin(rdev
->mec
.hpd_eop_obj
, RADEON_GEM_DOMAIN_GTT
,
4832 &rdev
->mec
.hpd_eop_gpu_addr
);
4834 dev_warn(rdev
->dev
, "(%d) pin HDP EOP bo failed\n", r
);
4838 r
= radeon_bo_kmap(rdev
->mec
.hpd_eop_obj
, (void **)&hpd
);
4840 dev_warn(rdev
->dev
, "(%d) map HDP EOP bo failed\n", r
);
4845 /* clear memory. Not sure if this is required or not */
4846 memset(hpd
, 0, rdev
->mec
.num_mec
*rdev
->mec
.num_pipe
* MEC_HPD_SIZE
* 2);
4848 radeon_bo_kunmap(rdev
->mec
.hpd_eop_obj
);
4849 radeon_bo_unreserve(rdev
->mec
.hpd_eop_obj
);
4854 struct hqd_registers
4856 u32 cp_mqd_base_addr
;
4857 u32 cp_mqd_base_addr_hi
;
4860 u32 cp_hqd_persistent_state
;
4861 u32 cp_hqd_pipe_priority
;
4862 u32 cp_hqd_queue_priority
;
4865 u32 cp_hqd_pq_base_hi
;
4867 u32 cp_hqd_pq_rptr_report_addr
;
4868 u32 cp_hqd_pq_rptr_report_addr_hi
;
4869 u32 cp_hqd_pq_wptr_poll_addr
;
4870 u32 cp_hqd_pq_wptr_poll_addr_hi
;
4871 u32 cp_hqd_pq_doorbell_control
;
4873 u32 cp_hqd_pq_control
;
4874 u32 cp_hqd_ib_base_addr
;
4875 u32 cp_hqd_ib_base_addr_hi
;
4877 u32 cp_hqd_ib_control
;
4878 u32 cp_hqd_iq_timer
;
4880 u32 cp_hqd_dequeue_request
;
4881 u32 cp_hqd_dma_offload
;
4882 u32 cp_hqd_sema_cmd
;
4883 u32 cp_hqd_msg_type
;
4884 u32 cp_hqd_atomic0_preop_lo
;
4885 u32 cp_hqd_atomic0_preop_hi
;
4886 u32 cp_hqd_atomic1_preop_lo
;
4887 u32 cp_hqd_atomic1_preop_hi
;
4888 u32 cp_hqd_hq_scheduler0
;
4889 u32 cp_hqd_hq_scheduler1
;
4896 u32 dispatch_initiator
;
4900 u32 pipeline_stat_enable
;
4901 u32 perf_counter_enable
;
4907 u32 resource_limits
;
4908 u32 static_thread_mgmt01
[2];
4910 u32 static_thread_mgmt23
[2];
4912 u32 thread_trace_enable
;
4915 u32 vgtcs_invoke_count
[2];
4916 struct hqd_registers queue_state
;
4918 u32 interrupt_queue
[64];
4922 * cik_cp_compute_resume - setup the compute queue registers
4924 * @rdev: radeon_device pointer
4926 * Program the compute queues and test them to make sure they
4928 * Returns 0 for success, error for failure.
4930 static int cik_cp_compute_resume(struct radeon_device
*rdev
)
4934 bool use_doorbell
= true;
4940 struct bonaire_mqd
*mqd
;
4942 r
= cik_cp_compute_start(rdev
);
4946 /* fix up chicken bits */
4947 tmp
= RREG32(CP_CPF_DEBUG
);
4949 WREG32(CP_CPF_DEBUG
, tmp
);
4951 /* init the pipes */
4952 mutex_lock(&rdev
->srbm_mutex
);
4954 eop_gpu_addr
= rdev
->mec
.hpd_eop_gpu_addr
;
4956 cik_srbm_select(rdev
, 0, 0, 0, 0);
4958 /* write the EOP addr */
4959 WREG32(CP_HPD_EOP_BASE_ADDR
, eop_gpu_addr
>> 8);
4960 WREG32(CP_HPD_EOP_BASE_ADDR_HI
, upper_32_bits(eop_gpu_addr
) >> 8);
4962 /* set the VMID assigned */
4963 WREG32(CP_HPD_EOP_VMID
, 0);
4965 /* set the EOP size, register value is 2^(EOP_SIZE+1) dwords */
4966 tmp
= RREG32(CP_HPD_EOP_CONTROL
);
4967 tmp
&= ~EOP_SIZE_MASK
;
4968 tmp
|= order_base_2(MEC_HPD_SIZE
/ 8);
4969 WREG32(CP_HPD_EOP_CONTROL
, tmp
);
4971 mutex_unlock(&rdev
->srbm_mutex
);
4973 /* init the queues. Just two for now. */
4974 for (i
= 0; i
< 2; i
++) {
4976 idx
= CAYMAN_RING_TYPE_CP1_INDEX
;
4978 idx
= CAYMAN_RING_TYPE_CP2_INDEX
;
4980 if (rdev
->ring
[idx
].mqd_obj
== NULL
) {
4981 r
= radeon_bo_create(rdev
,
4982 sizeof(struct bonaire_mqd
),
4984 RADEON_GEM_DOMAIN_GTT
, 0, NULL
,
4985 NULL
, &rdev
->ring
[idx
].mqd_obj
);
4987 dev_warn(rdev
->dev
, "(%d) create MQD bo failed\n", r
);
4992 r
= radeon_bo_reserve(rdev
->ring
[idx
].mqd_obj
, false);
4993 if (unlikely(r
!= 0)) {
4994 cik_cp_compute_fini(rdev
);
4997 r
= radeon_bo_pin(rdev
->ring
[idx
].mqd_obj
, RADEON_GEM_DOMAIN_GTT
,
5000 dev_warn(rdev
->dev
, "(%d) pin MQD bo failed\n", r
);
5001 cik_cp_compute_fini(rdev
);
5004 r
= radeon_bo_kmap(rdev
->ring
[idx
].mqd_obj
, (void **)&buf
);
5006 dev_warn(rdev
->dev
, "(%d) map MQD bo failed\n", r
);
5007 cik_cp_compute_fini(rdev
);
5011 /* init the mqd struct */
5012 memset(buf
, 0, sizeof(struct bonaire_mqd
));
5014 mqd
= (struct bonaire_mqd
*)buf
;
5015 mqd
->header
= 0xC0310800;
5016 mqd
->static_thread_mgmt01
[0] = 0xffffffff;
5017 mqd
->static_thread_mgmt01
[1] = 0xffffffff;
5018 mqd
->static_thread_mgmt23
[0] = 0xffffffff;
5019 mqd
->static_thread_mgmt23
[1] = 0xffffffff;
5021 mutex_lock(&rdev
->srbm_mutex
);
5022 cik_srbm_select(rdev
, rdev
->ring
[idx
].me
,
5023 rdev
->ring
[idx
].pipe
,
5024 rdev
->ring
[idx
].queue
, 0);
5026 /* disable wptr polling */
5027 tmp
= RREG32(CP_PQ_WPTR_POLL_CNTL
);
5028 tmp
&= ~WPTR_POLL_EN
;
5029 WREG32(CP_PQ_WPTR_POLL_CNTL
, tmp
);
5031 /* enable doorbell? */
5032 mqd
->queue_state
.cp_hqd_pq_doorbell_control
=
5033 RREG32(CP_HQD_PQ_DOORBELL_CONTROL
);
5035 mqd
->queue_state
.cp_hqd_pq_doorbell_control
|= DOORBELL_EN
;
5037 mqd
->queue_state
.cp_hqd_pq_doorbell_control
&= ~DOORBELL_EN
;
5038 WREG32(CP_HQD_PQ_DOORBELL_CONTROL
,
5039 mqd
->queue_state
.cp_hqd_pq_doorbell_control
);
5041 /* disable the queue if it's active */
5042 mqd
->queue_state
.cp_hqd_dequeue_request
= 0;
5043 mqd
->queue_state
.cp_hqd_pq_rptr
= 0;
5044 mqd
->queue_state
.cp_hqd_pq_wptr
= 0;
5045 if (RREG32(CP_HQD_ACTIVE
) & 1) {
5046 WREG32(CP_HQD_DEQUEUE_REQUEST
, 1);
5047 for (j
= 0; j
< rdev
->usec_timeout
; j
++) {
5048 if (!(RREG32(CP_HQD_ACTIVE
) & 1))
5052 WREG32(CP_HQD_DEQUEUE_REQUEST
, mqd
->queue_state
.cp_hqd_dequeue_request
);
5053 WREG32(CP_HQD_PQ_RPTR
, mqd
->queue_state
.cp_hqd_pq_rptr
);
5054 WREG32(CP_HQD_PQ_WPTR
, mqd
->queue_state
.cp_hqd_pq_wptr
);
5057 /* set the pointer to the MQD */
5058 mqd
->queue_state
.cp_mqd_base_addr
= mqd_gpu_addr
& 0xfffffffc;
5059 mqd
->queue_state
.cp_mqd_base_addr_hi
= upper_32_bits(mqd_gpu_addr
);
5060 WREG32(CP_MQD_BASE_ADDR
, mqd
->queue_state
.cp_mqd_base_addr
);
5061 WREG32(CP_MQD_BASE_ADDR_HI
, mqd
->queue_state
.cp_mqd_base_addr_hi
);
5062 /* set MQD vmid to 0 */
5063 mqd
->queue_state
.cp_mqd_control
= RREG32(CP_MQD_CONTROL
);
5064 mqd
->queue_state
.cp_mqd_control
&= ~MQD_VMID_MASK
;
5065 WREG32(CP_MQD_CONTROL
, mqd
->queue_state
.cp_mqd_control
);
5067 /* set the pointer to the HQD, this is similar CP_RB0_BASE/_HI */
5068 hqd_gpu_addr
= rdev
->ring
[idx
].gpu_addr
>> 8;
5069 mqd
->queue_state
.cp_hqd_pq_base
= hqd_gpu_addr
;
5070 mqd
->queue_state
.cp_hqd_pq_base_hi
= upper_32_bits(hqd_gpu_addr
);
5071 WREG32(CP_HQD_PQ_BASE
, mqd
->queue_state
.cp_hqd_pq_base
);
5072 WREG32(CP_HQD_PQ_BASE_HI
, mqd
->queue_state
.cp_hqd_pq_base_hi
);
5074 /* set up the HQD, this is similar to CP_RB0_CNTL */
5075 mqd
->queue_state
.cp_hqd_pq_control
= RREG32(CP_HQD_PQ_CONTROL
);
5076 mqd
->queue_state
.cp_hqd_pq_control
&=
5077 ~(QUEUE_SIZE_MASK
| RPTR_BLOCK_SIZE_MASK
);
5079 mqd
->queue_state
.cp_hqd_pq_control
|=
5080 order_base_2(rdev
->ring
[idx
].ring_size
/ 8);
5081 mqd
->queue_state
.cp_hqd_pq_control
|=
5082 (order_base_2(RADEON_GPU_PAGE_SIZE
/8) << 8);
5084 mqd
->queue_state
.cp_hqd_pq_control
|= BUF_SWAP_32BIT
;
5086 mqd
->queue_state
.cp_hqd_pq_control
&=
5087 ~(UNORD_DISPATCH
| ROQ_PQ_IB_FLIP
| PQ_VOLATILE
);
5088 mqd
->queue_state
.cp_hqd_pq_control
|=
5089 PRIV_STATE
| KMD_QUEUE
; /* assuming kernel queue control */
5090 WREG32(CP_HQD_PQ_CONTROL
, mqd
->queue_state
.cp_hqd_pq_control
);
5092 /* only used if CP_PQ_WPTR_POLL_CNTL.WPTR_POLL_EN=1 */
5094 wb_gpu_addr
= rdev
->wb
.gpu_addr
+ CIK_WB_CP1_WPTR_OFFSET
;
5096 wb_gpu_addr
= rdev
->wb
.gpu_addr
+ CIK_WB_CP2_WPTR_OFFSET
;
5097 mqd
->queue_state
.cp_hqd_pq_wptr_poll_addr
= wb_gpu_addr
& 0xfffffffc;
5098 mqd
->queue_state
.cp_hqd_pq_wptr_poll_addr_hi
= upper_32_bits(wb_gpu_addr
) & 0xffff;
5099 WREG32(CP_HQD_PQ_WPTR_POLL_ADDR
, mqd
->queue_state
.cp_hqd_pq_wptr_poll_addr
);
5100 WREG32(CP_HQD_PQ_WPTR_POLL_ADDR_HI
,
5101 mqd
->queue_state
.cp_hqd_pq_wptr_poll_addr_hi
);
5103 /* set the wb address wether it's enabled or not */
5105 wb_gpu_addr
= rdev
->wb
.gpu_addr
+ RADEON_WB_CP1_RPTR_OFFSET
;
5107 wb_gpu_addr
= rdev
->wb
.gpu_addr
+ RADEON_WB_CP2_RPTR_OFFSET
;
5108 mqd
->queue_state
.cp_hqd_pq_rptr_report_addr
= wb_gpu_addr
& 0xfffffffc;
5109 mqd
->queue_state
.cp_hqd_pq_rptr_report_addr_hi
=
5110 upper_32_bits(wb_gpu_addr
) & 0xffff;
5111 WREG32(CP_HQD_PQ_RPTR_REPORT_ADDR
,
5112 mqd
->queue_state
.cp_hqd_pq_rptr_report_addr
);
5113 WREG32(CP_HQD_PQ_RPTR_REPORT_ADDR_HI
,
5114 mqd
->queue_state
.cp_hqd_pq_rptr_report_addr_hi
);
5116 /* enable the doorbell if requested */
5118 mqd
->queue_state
.cp_hqd_pq_doorbell_control
=
5119 RREG32(CP_HQD_PQ_DOORBELL_CONTROL
);
5120 mqd
->queue_state
.cp_hqd_pq_doorbell_control
&= ~DOORBELL_OFFSET_MASK
;
5121 mqd
->queue_state
.cp_hqd_pq_doorbell_control
|=
5122 DOORBELL_OFFSET(rdev
->ring
[idx
].doorbell_index
);
5123 mqd
->queue_state
.cp_hqd_pq_doorbell_control
|= DOORBELL_EN
;
5124 mqd
->queue_state
.cp_hqd_pq_doorbell_control
&=
5125 ~(DOORBELL_SOURCE
| DOORBELL_HIT
);
5128 mqd
->queue_state
.cp_hqd_pq_doorbell_control
= 0;
5130 WREG32(CP_HQD_PQ_DOORBELL_CONTROL
,
5131 mqd
->queue_state
.cp_hqd_pq_doorbell_control
);
5133 /* read and write pointers, similar to CP_RB0_WPTR/_RPTR */
5134 rdev
->ring
[idx
].wptr
= 0;
5135 mqd
->queue_state
.cp_hqd_pq_wptr
= rdev
->ring
[idx
].wptr
;
5136 WREG32(CP_HQD_PQ_WPTR
, mqd
->queue_state
.cp_hqd_pq_wptr
);
5137 mqd
->queue_state
.cp_hqd_pq_rptr
= RREG32(CP_HQD_PQ_RPTR
);
5139 /* set the vmid for the queue */
5140 mqd
->queue_state
.cp_hqd_vmid
= 0;
5141 WREG32(CP_HQD_VMID
, mqd
->queue_state
.cp_hqd_vmid
);
5143 /* activate the queue */
5144 mqd
->queue_state
.cp_hqd_active
= 1;
5145 WREG32(CP_HQD_ACTIVE
, mqd
->queue_state
.cp_hqd_active
);
5147 cik_srbm_select(rdev
, 0, 0, 0, 0);
5148 mutex_unlock(&rdev
->srbm_mutex
);
5150 radeon_bo_kunmap(rdev
->ring
[idx
].mqd_obj
);
5151 radeon_bo_unreserve(rdev
->ring
[idx
].mqd_obj
);
5153 rdev
->ring
[idx
].ready
= true;
5154 r
= radeon_ring_test(rdev
, idx
, &rdev
->ring
[idx
]);
5156 rdev
->ring
[idx
].ready
= false;
5162 static void cik_cp_enable(struct radeon_device
*rdev
, bool enable
)
5164 cik_cp_gfx_enable(rdev
, enable
);
5165 cik_cp_compute_enable(rdev
, enable
);
5168 static int cik_cp_load_microcode(struct radeon_device
*rdev
)
5172 r
= cik_cp_gfx_load_microcode(rdev
);
5175 r
= cik_cp_compute_load_microcode(rdev
);
5182 static void cik_cp_fini(struct radeon_device
*rdev
)
5184 cik_cp_gfx_fini(rdev
);
5185 cik_cp_compute_fini(rdev
);
5188 static int cik_cp_resume(struct radeon_device
*rdev
)
5192 cik_enable_gui_idle_interrupt(rdev
, false);
5194 r
= cik_cp_load_microcode(rdev
);
5198 r
= cik_cp_gfx_resume(rdev
);
5201 r
= cik_cp_compute_resume(rdev
);
5205 cik_enable_gui_idle_interrupt(rdev
, true);
5210 static void cik_print_gpu_status_regs(struct radeon_device
*rdev
)
5212 dev_info(rdev
->dev
, " GRBM_STATUS=0x%08X\n",
5213 RREG32(GRBM_STATUS
));
5214 dev_info(rdev
->dev
, " GRBM_STATUS2=0x%08X\n",
5215 RREG32(GRBM_STATUS2
));
5216 dev_info(rdev
->dev
, " GRBM_STATUS_SE0=0x%08X\n",
5217 RREG32(GRBM_STATUS_SE0
));
5218 dev_info(rdev
->dev
, " GRBM_STATUS_SE1=0x%08X\n",
5219 RREG32(GRBM_STATUS_SE1
));
5220 dev_info(rdev
->dev
, " GRBM_STATUS_SE2=0x%08X\n",
5221 RREG32(GRBM_STATUS_SE2
));
5222 dev_info(rdev
->dev
, " GRBM_STATUS_SE3=0x%08X\n",
5223 RREG32(GRBM_STATUS_SE3
));
5224 dev_info(rdev
->dev
, " SRBM_STATUS=0x%08X\n",
5225 RREG32(SRBM_STATUS
));
5226 dev_info(rdev
->dev
, " SRBM_STATUS2=0x%08X\n",
5227 RREG32(SRBM_STATUS2
));
5228 dev_info(rdev
->dev
, " SDMA0_STATUS_REG = 0x%08X\n",
5229 RREG32(SDMA0_STATUS_REG
+ SDMA0_REGISTER_OFFSET
));
5230 dev_info(rdev
->dev
, " SDMA1_STATUS_REG = 0x%08X\n",
5231 RREG32(SDMA0_STATUS_REG
+ SDMA1_REGISTER_OFFSET
));
5232 dev_info(rdev
->dev
, " CP_STAT = 0x%08x\n", RREG32(CP_STAT
));
5233 dev_info(rdev
->dev
, " CP_STALLED_STAT1 = 0x%08x\n",
5234 RREG32(CP_STALLED_STAT1
));
5235 dev_info(rdev
->dev
, " CP_STALLED_STAT2 = 0x%08x\n",
5236 RREG32(CP_STALLED_STAT2
));
5237 dev_info(rdev
->dev
, " CP_STALLED_STAT3 = 0x%08x\n",
5238 RREG32(CP_STALLED_STAT3
));
5239 dev_info(rdev
->dev
, " CP_CPF_BUSY_STAT = 0x%08x\n",
5240 RREG32(CP_CPF_BUSY_STAT
));
5241 dev_info(rdev
->dev
, " CP_CPF_STALLED_STAT1 = 0x%08x\n",
5242 RREG32(CP_CPF_STALLED_STAT1
));
5243 dev_info(rdev
->dev
, " CP_CPF_STATUS = 0x%08x\n", RREG32(CP_CPF_STATUS
));
5244 dev_info(rdev
->dev
, " CP_CPC_BUSY_STAT = 0x%08x\n", RREG32(CP_CPC_BUSY_STAT
));
5245 dev_info(rdev
->dev
, " CP_CPC_STALLED_STAT1 = 0x%08x\n",
5246 RREG32(CP_CPC_STALLED_STAT1
));
5247 dev_info(rdev
->dev
, " CP_CPC_STATUS = 0x%08x\n", RREG32(CP_CPC_STATUS
));
5251 * cik_gpu_check_soft_reset - check which blocks are busy
5253 * @rdev: radeon_device pointer
5255 * Check which blocks are busy and return the relevant reset
5256 * mask to be used by cik_gpu_soft_reset().
5257 * Returns a mask of the blocks to be reset.
5259 u32
cik_gpu_check_soft_reset(struct radeon_device
*rdev
)
5265 tmp
= RREG32(GRBM_STATUS
);
5266 if (tmp
& (PA_BUSY
| SC_BUSY
|
5267 BCI_BUSY
| SX_BUSY
|
5268 TA_BUSY
| VGT_BUSY
|
5270 GDS_BUSY
| SPI_BUSY
|
5271 IA_BUSY
| IA_BUSY_NO_DMA
))
5272 reset_mask
|= RADEON_RESET_GFX
;
5274 if (tmp
& (CP_BUSY
| CP_COHERENCY_BUSY
))
5275 reset_mask
|= RADEON_RESET_CP
;
5278 tmp
= RREG32(GRBM_STATUS2
);
5280 reset_mask
|= RADEON_RESET_RLC
;
5282 /* SDMA0_STATUS_REG */
5283 tmp
= RREG32(SDMA0_STATUS_REG
+ SDMA0_REGISTER_OFFSET
);
5284 if (!(tmp
& SDMA_IDLE
))
5285 reset_mask
|= RADEON_RESET_DMA
;
5287 /* SDMA1_STATUS_REG */
5288 tmp
= RREG32(SDMA0_STATUS_REG
+ SDMA1_REGISTER_OFFSET
);
5289 if (!(tmp
& SDMA_IDLE
))
5290 reset_mask
|= RADEON_RESET_DMA1
;
5293 tmp
= RREG32(SRBM_STATUS2
);
5294 if (tmp
& SDMA_BUSY
)
5295 reset_mask
|= RADEON_RESET_DMA
;
5297 if (tmp
& SDMA1_BUSY
)
5298 reset_mask
|= RADEON_RESET_DMA1
;
5301 tmp
= RREG32(SRBM_STATUS
);
5304 reset_mask
|= RADEON_RESET_IH
;
5307 reset_mask
|= RADEON_RESET_SEM
;
5309 if (tmp
& GRBM_RQ_PENDING
)
5310 reset_mask
|= RADEON_RESET_GRBM
;
5313 reset_mask
|= RADEON_RESET_VMC
;
5315 if (tmp
& (MCB_BUSY
| MCB_NON_DISPLAY_BUSY
|
5316 MCC_BUSY
| MCD_BUSY
))
5317 reset_mask
|= RADEON_RESET_MC
;
5319 if (evergreen_is_display_hung(rdev
))
5320 reset_mask
|= RADEON_RESET_DISPLAY
;
5322 /* Skip MC reset as it's mostly likely not hung, just busy */
5323 if (reset_mask
& RADEON_RESET_MC
) {
5324 DRM_DEBUG("MC busy: 0x%08X, clearing.\n", reset_mask
);
5325 reset_mask
&= ~RADEON_RESET_MC
;
5332 * cik_gpu_soft_reset - soft reset GPU
5334 * @rdev: radeon_device pointer
5335 * @reset_mask: mask of which blocks to reset
5337 * Soft reset the blocks specified in @reset_mask.
5339 static void cik_gpu_soft_reset(struct radeon_device
*rdev
, u32 reset_mask
)
5341 struct evergreen_mc_save save
;
5342 u32 grbm_soft_reset
= 0, srbm_soft_reset
= 0;
5345 if (reset_mask
== 0)
5348 dev_info(rdev
->dev
, "GPU softreset: 0x%08X\n", reset_mask
);
5350 cik_print_gpu_status_regs(rdev
);
5351 dev_info(rdev
->dev
, " VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x%08X\n",
5352 RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR
));
5353 dev_info(rdev
->dev
, " VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n",
5354 RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS
));
5363 /* Disable GFX parsing/prefetching */
5364 WREG32(CP_ME_CNTL
, CP_ME_HALT
| CP_PFP_HALT
| CP_CE_HALT
);
5366 /* Disable MEC parsing/prefetching */
5367 WREG32(CP_MEC_CNTL
, MEC_ME1_HALT
| MEC_ME2_HALT
);
5369 if (reset_mask
& RADEON_RESET_DMA
) {
5371 tmp
= RREG32(SDMA0_ME_CNTL
+ SDMA0_REGISTER_OFFSET
);
5373 WREG32(SDMA0_ME_CNTL
+ SDMA0_REGISTER_OFFSET
, tmp
);
5375 if (reset_mask
& RADEON_RESET_DMA1
) {
5377 tmp
= RREG32(SDMA0_ME_CNTL
+ SDMA1_REGISTER_OFFSET
);
5379 WREG32(SDMA0_ME_CNTL
+ SDMA1_REGISTER_OFFSET
, tmp
);
5382 evergreen_mc_stop(rdev
, &save
);
5383 if (evergreen_mc_wait_for_idle(rdev
)) {
5384 dev_warn(rdev
->dev
, "Wait for MC idle timedout !\n");
5387 if (reset_mask
& (RADEON_RESET_GFX
| RADEON_RESET_COMPUTE
| RADEON_RESET_CP
))
5388 grbm_soft_reset
= SOFT_RESET_CP
| SOFT_RESET_GFX
;
5390 if (reset_mask
& RADEON_RESET_CP
) {
5391 grbm_soft_reset
|= SOFT_RESET_CP
;
5393 srbm_soft_reset
|= SOFT_RESET_GRBM
;
5396 if (reset_mask
& RADEON_RESET_DMA
)
5397 srbm_soft_reset
|= SOFT_RESET_SDMA
;
5399 if (reset_mask
& RADEON_RESET_DMA1
)
5400 srbm_soft_reset
|= SOFT_RESET_SDMA1
;
5402 if (reset_mask
& RADEON_RESET_DISPLAY
)
5403 srbm_soft_reset
|= SOFT_RESET_DC
;
5405 if (reset_mask
& RADEON_RESET_RLC
)
5406 grbm_soft_reset
|= SOFT_RESET_RLC
;
5408 if (reset_mask
& RADEON_RESET_SEM
)
5409 srbm_soft_reset
|= SOFT_RESET_SEM
;
5411 if (reset_mask
& RADEON_RESET_IH
)
5412 srbm_soft_reset
|= SOFT_RESET_IH
;
5414 if (reset_mask
& RADEON_RESET_GRBM
)
5415 srbm_soft_reset
|= SOFT_RESET_GRBM
;
5417 if (reset_mask
& RADEON_RESET_VMC
)
5418 srbm_soft_reset
|= SOFT_RESET_VMC
;
5420 if (!(rdev
->flags
& RADEON_IS_IGP
)) {
5421 if (reset_mask
& RADEON_RESET_MC
)
5422 srbm_soft_reset
|= SOFT_RESET_MC
;
5425 if (grbm_soft_reset
) {
5426 tmp
= RREG32(GRBM_SOFT_RESET
);
5427 tmp
|= grbm_soft_reset
;
5428 dev_info(rdev
->dev
, "GRBM_SOFT_RESET=0x%08X\n", tmp
);
5429 WREG32(GRBM_SOFT_RESET
, tmp
);
5430 tmp
= RREG32(GRBM_SOFT_RESET
);
5434 tmp
&= ~grbm_soft_reset
;
5435 WREG32(GRBM_SOFT_RESET
, tmp
);
5436 tmp
= RREG32(GRBM_SOFT_RESET
);
5439 if (srbm_soft_reset
) {
5440 tmp
= RREG32(SRBM_SOFT_RESET
);
5441 tmp
|= srbm_soft_reset
;
5442 dev_info(rdev
->dev
, "SRBM_SOFT_RESET=0x%08X\n", tmp
);
5443 WREG32(SRBM_SOFT_RESET
, tmp
);
5444 tmp
= RREG32(SRBM_SOFT_RESET
);
5448 tmp
&= ~srbm_soft_reset
;
5449 WREG32(SRBM_SOFT_RESET
, tmp
);
5450 tmp
= RREG32(SRBM_SOFT_RESET
);
5453 /* Wait a little for things to settle down */
5456 evergreen_mc_resume(rdev
, &save
);
5459 cik_print_gpu_status_regs(rdev
);
5462 struct kv_reset_save_regs
{
5463 u32 gmcon_reng_execute
;
5468 static void kv_save_regs_for_reset(struct radeon_device
*rdev
,
5469 struct kv_reset_save_regs
*save
)
5471 save
->gmcon_reng_execute
= RREG32(GMCON_RENG_EXECUTE
);
5472 save
->gmcon_misc
= RREG32(GMCON_MISC
);
5473 save
->gmcon_misc3
= RREG32(GMCON_MISC3
);
5475 WREG32(GMCON_RENG_EXECUTE
, save
->gmcon_reng_execute
& ~RENG_EXECUTE_ON_PWR_UP
);
5476 WREG32(GMCON_MISC
, save
->gmcon_misc
& ~(RENG_EXECUTE_ON_REG_UPDATE
|
5477 STCTRL_STUTTER_EN
));
5480 static void kv_restore_regs_for_reset(struct radeon_device
*rdev
,
5481 struct kv_reset_save_regs
*save
)
5485 WREG32(GMCON_PGFSM_WRITE
, 0);
5486 WREG32(GMCON_PGFSM_CONFIG
, 0x200010ff);
5488 for (i
= 0; i
< 5; i
++)
5489 WREG32(GMCON_PGFSM_WRITE
, 0);
5491 WREG32(GMCON_PGFSM_WRITE
, 0);
5492 WREG32(GMCON_PGFSM_CONFIG
, 0x300010ff);
5494 for (i
= 0; i
< 5; i
++)
5495 WREG32(GMCON_PGFSM_WRITE
, 0);
5497 WREG32(GMCON_PGFSM_WRITE
, 0x210000);
5498 WREG32(GMCON_PGFSM_CONFIG
, 0xa00010ff);
5500 for (i
= 0; i
< 5; i
++)
5501 WREG32(GMCON_PGFSM_WRITE
, 0);
5503 WREG32(GMCON_PGFSM_WRITE
, 0x21003);
5504 WREG32(GMCON_PGFSM_CONFIG
, 0xb00010ff);
5506 for (i
= 0; i
< 5; i
++)
5507 WREG32(GMCON_PGFSM_WRITE
, 0);
5509 WREG32(GMCON_PGFSM_WRITE
, 0x2b00);
5510 WREG32(GMCON_PGFSM_CONFIG
, 0xc00010ff);
5512 for (i
= 0; i
< 5; i
++)
5513 WREG32(GMCON_PGFSM_WRITE
, 0);
5515 WREG32(GMCON_PGFSM_WRITE
, 0);
5516 WREG32(GMCON_PGFSM_CONFIG
, 0xd00010ff);
5518 for (i
= 0; i
< 5; i
++)
5519 WREG32(GMCON_PGFSM_WRITE
, 0);
5521 WREG32(GMCON_PGFSM_WRITE
, 0x420000);
5522 WREG32(GMCON_PGFSM_CONFIG
, 0x100010ff);
5524 for (i
= 0; i
< 5; i
++)
5525 WREG32(GMCON_PGFSM_WRITE
, 0);
5527 WREG32(GMCON_PGFSM_WRITE
, 0x120202);
5528 WREG32(GMCON_PGFSM_CONFIG
, 0x500010ff);
5530 for (i
= 0; i
< 5; i
++)
5531 WREG32(GMCON_PGFSM_WRITE
, 0);
5533 WREG32(GMCON_PGFSM_WRITE
, 0x3e3e36);
5534 WREG32(GMCON_PGFSM_CONFIG
, 0x600010ff);
5536 for (i
= 0; i
< 5; i
++)
5537 WREG32(GMCON_PGFSM_WRITE
, 0);
5539 WREG32(GMCON_PGFSM_WRITE
, 0x373f3e);
5540 WREG32(GMCON_PGFSM_CONFIG
, 0x700010ff);
5542 for (i
= 0; i
< 5; i
++)
5543 WREG32(GMCON_PGFSM_WRITE
, 0);
5545 WREG32(GMCON_PGFSM_WRITE
, 0x3e1332);
5546 WREG32(GMCON_PGFSM_CONFIG
, 0xe00010ff);
5548 WREG32(GMCON_MISC3
, save
->gmcon_misc3
);
5549 WREG32(GMCON_MISC
, save
->gmcon_misc
);
5550 WREG32(GMCON_RENG_EXECUTE
, save
->gmcon_reng_execute
);
5553 static void cik_gpu_pci_config_reset(struct radeon_device
*rdev
)
5555 struct evergreen_mc_save save
;
5556 struct kv_reset_save_regs kv_save
= { 0 };
5559 dev_info(rdev
->dev
, "GPU pci config reset\n");
5567 /* Disable GFX parsing/prefetching */
5568 WREG32(CP_ME_CNTL
, CP_ME_HALT
| CP_PFP_HALT
| CP_CE_HALT
);
5570 /* Disable MEC parsing/prefetching */
5571 WREG32(CP_MEC_CNTL
, MEC_ME1_HALT
| MEC_ME2_HALT
);
5574 tmp
= RREG32(SDMA0_ME_CNTL
+ SDMA0_REGISTER_OFFSET
);
5576 WREG32(SDMA0_ME_CNTL
+ SDMA0_REGISTER_OFFSET
, tmp
);
5578 tmp
= RREG32(SDMA0_ME_CNTL
+ SDMA1_REGISTER_OFFSET
);
5580 WREG32(SDMA0_ME_CNTL
+ SDMA1_REGISTER_OFFSET
, tmp
);
5581 /* XXX other engines? */
5583 /* halt the rlc, disable cp internal ints */
5588 /* disable mem access */
5589 evergreen_mc_stop(rdev
, &save
);
5590 if (evergreen_mc_wait_for_idle(rdev
)) {
5591 dev_warn(rdev
->dev
, "Wait for MC idle timed out !\n");
5594 if (rdev
->flags
& RADEON_IS_IGP
)
5595 kv_save_regs_for_reset(rdev
, &kv_save
);
5598 pci_clear_master(rdev
->pdev
);
5600 radeon_pci_config_reset(rdev
);
5604 /* wait for asic to come out of reset */
5605 for (i
= 0; i
< rdev
->usec_timeout
; i
++) {
5606 if (RREG32(CONFIG_MEMSIZE
) != 0xffffffff)
5611 /* does asic init need to be run first??? */
5612 if (rdev
->flags
& RADEON_IS_IGP
)
5613 kv_restore_regs_for_reset(rdev
, &kv_save
);
5617 * cik_asic_reset - soft reset GPU
5619 * @rdev: radeon_device pointer
5621 * Look up which blocks are hung and attempt
5623 * Returns 0 for success.
5625 int cik_asic_reset(struct radeon_device
*rdev
)
5629 reset_mask
= cik_gpu_check_soft_reset(rdev
);
5632 r600_set_bios_scratch_engine_hung(rdev
, true);
5634 /* try soft reset */
5635 cik_gpu_soft_reset(rdev
, reset_mask
);
5637 reset_mask
= cik_gpu_check_soft_reset(rdev
);
5639 /* try pci config reset */
5640 if (reset_mask
&& radeon_hard_reset
)
5641 cik_gpu_pci_config_reset(rdev
);
5643 reset_mask
= cik_gpu_check_soft_reset(rdev
);
5646 r600_set_bios_scratch_engine_hung(rdev
, false);
5652 * cik_gfx_is_lockup - check if the 3D engine is locked up
5654 * @rdev: radeon_device pointer
5655 * @ring: radeon_ring structure holding ring information
5657 * Check if the 3D engine is locked up (CIK).
5658 * Returns true if the engine is locked, false if not.
5660 bool cik_gfx_is_lockup(struct radeon_device
*rdev
, struct radeon_ring
*ring
)
5662 u32 reset_mask
= cik_gpu_check_soft_reset(rdev
);
5664 if (!(reset_mask
& (RADEON_RESET_GFX
|
5665 RADEON_RESET_COMPUTE
|
5666 RADEON_RESET_CP
))) {
5667 radeon_ring_lockup_update(rdev
, ring
);
5670 return radeon_ring_test_lockup(rdev
, ring
);
5675 * cik_mc_program - program the GPU memory controller
5677 * @rdev: radeon_device pointer
5679 * Set the location of vram, gart, and AGP in the GPU's
5680 * physical address space (CIK).
5682 static void cik_mc_program(struct radeon_device
*rdev
)
5684 struct evergreen_mc_save save
;
5688 /* Initialize HDP */
5689 for (i
= 0, j
= 0; i
< 32; i
++, j
+= 0x18) {
5690 WREG32((0x2c14 + j
), 0x00000000);
5691 WREG32((0x2c18 + j
), 0x00000000);
5692 WREG32((0x2c1c + j
), 0x00000000);
5693 WREG32((0x2c20 + j
), 0x00000000);
5694 WREG32((0x2c24 + j
), 0x00000000);
5696 WREG32(HDP_REG_COHERENCY_FLUSH_CNTL
, 0);
5698 evergreen_mc_stop(rdev
, &save
);
5699 if (radeon_mc_wait_for_idle(rdev
)) {
5700 dev_warn(rdev
->dev
, "Wait for MC idle timedout !\n");
5702 /* Lockout access through VGA aperture*/
5703 WREG32(VGA_HDP_CONTROL
, VGA_MEMORY_DISABLE
);
5704 /* Update configuration */
5705 WREG32(MC_VM_SYSTEM_APERTURE_LOW_ADDR
,
5706 rdev
->mc
.vram_start
>> 12);
5707 WREG32(MC_VM_SYSTEM_APERTURE_HIGH_ADDR
,
5708 rdev
->mc
.vram_end
>> 12);
5709 WREG32(MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR
,
5710 rdev
->vram_scratch
.gpu_addr
>> 12);
5711 tmp
= ((rdev
->mc
.vram_end
>> 24) & 0xFFFF) << 16;
5712 tmp
|= ((rdev
->mc
.vram_start
>> 24) & 0xFFFF);
5713 WREG32(MC_VM_FB_LOCATION
, tmp
);
5714 /* XXX double check these! */
5715 WREG32(HDP_NONSURFACE_BASE
, (rdev
->mc
.vram_start
>> 8));
5716 WREG32(HDP_NONSURFACE_INFO
, (2 << 7) | (1 << 30));
5717 WREG32(HDP_NONSURFACE_SIZE
, 0x3FFFFFFF);
5718 WREG32(MC_VM_AGP_BASE
, 0);
5719 WREG32(MC_VM_AGP_TOP
, 0x0FFFFFFF);
5720 WREG32(MC_VM_AGP_BOT
, 0x0FFFFFFF);
5721 if (radeon_mc_wait_for_idle(rdev
)) {
5722 dev_warn(rdev
->dev
, "Wait for MC idle timedout !\n");
5724 evergreen_mc_resume(rdev
, &save
);
5725 /* we need to own VRAM, so turn off the VGA renderer here
5726 * to stop it overwriting our objects */
5727 rv515_vga_render_disable(rdev
);
5731 * cik_mc_init - initialize the memory controller driver params
5733 * @rdev: radeon_device pointer
5735 * Look up the amount of vram, vram width, and decide how to place
5736 * vram and gart within the GPU's physical address space (CIK).
5737 * Returns 0 for success.
5739 static int cik_mc_init(struct radeon_device
*rdev
)
5742 int chansize
, numchan
;
5744 /* Get VRAM informations */
5745 rdev
->mc
.vram_is_ddr
= true;
5746 tmp
= RREG32(MC_ARB_RAMCFG
);
5747 if (tmp
& CHANSIZE_MASK
) {
5752 tmp
= RREG32(MC_SHARED_CHMAP
);
5753 switch ((tmp
& NOOFCHAN_MASK
) >> NOOFCHAN_SHIFT
) {
5783 rdev
->mc
.vram_width
= numchan
* chansize
;
5784 /* Could aper size report 0 ? */
5785 rdev
->mc
.aper_base
= pci_resource_start(rdev
->pdev
, 0);
5786 rdev
->mc
.aper_size
= pci_resource_len(rdev
->pdev
, 0);
5787 /* size in MB on si */
5788 rdev
->mc
.mc_vram_size
= RREG32(CONFIG_MEMSIZE
) * 1024ULL * 1024ULL;
5789 rdev
->mc
.real_vram_size
= RREG32(CONFIG_MEMSIZE
) * 1024ULL * 1024ULL;
5790 rdev
->mc
.visible_vram_size
= rdev
->mc
.aper_size
;
5791 si_vram_gtt_location(rdev
, &rdev
->mc
);
5792 radeon_update_bandwidth_info(rdev
);
5799 * VMID 0 is the physical GPU addresses as used by the kernel.
5800 * VMIDs 1-15 are used for userspace clients and are handled
5801 * by the radeon vm/hsa code.
5804 * cik_pcie_gart_tlb_flush - gart tlb flush callback
5806 * @rdev: radeon_device pointer
5808 * Flush the TLB for the VMID 0 page table (CIK).
5810 void cik_pcie_gart_tlb_flush(struct radeon_device
*rdev
)
5812 /* flush hdp cache */
5813 WREG32(HDP_MEM_COHERENCY_FLUSH_CNTL
, 0);
5815 /* bits 0-15 are the VM contexts0-15 */
5816 WREG32(VM_INVALIDATE_REQUEST
, 0x1);
5819 static void cik_pcie_init_compute_vmid(struct radeon_device
*rdev
)
5822 uint32_t sh_mem_bases
, sh_mem_config
;
5824 sh_mem_bases
= 0x6000 | 0x6000 << 16;
5825 sh_mem_config
= ALIGNMENT_MODE(SH_MEM_ALIGNMENT_MODE_UNALIGNED
);
5826 sh_mem_config
|= DEFAULT_MTYPE(MTYPE_NONCACHED
);
5828 mutex_lock(&rdev
->srbm_mutex
);
5829 for (i
= 8; i
< 16; i
++) {
5830 cik_srbm_select(rdev
, 0, 0, 0, i
);
5831 /* CP and shaders */
5832 WREG32(SH_MEM_CONFIG
, sh_mem_config
);
5833 WREG32(SH_MEM_APE1_BASE
, 1);
5834 WREG32(SH_MEM_APE1_LIMIT
, 0);
5835 WREG32(SH_MEM_BASES
, sh_mem_bases
);
5837 cik_srbm_select(rdev
, 0, 0, 0, 0);
5838 mutex_unlock(&rdev
->srbm_mutex
);
5842 * cik_pcie_gart_enable - gart enable
5844 * @rdev: radeon_device pointer
5846 * This sets up the TLBs, programs the page tables for VMID0,
5847 * sets up the hw for VMIDs 1-15 which are allocated on
5848 * demand, and sets up the global locations for the LDS, GDS,
5849 * and GPUVM for FSA64 clients (CIK).
5850 * Returns 0 for success, errors for failure.
5852 static int cik_pcie_gart_enable(struct radeon_device
*rdev
)
5856 if (rdev
->gart
.robj
== NULL
) {
5857 dev_err(rdev
->dev
, "No VRAM object for PCIE GART.\n");
5860 r
= radeon_gart_table_vram_pin(rdev
);
5863 /* Setup TLB control */
5864 WREG32(MC_VM_MX_L1_TLB_CNTL
,
5867 ENABLE_L1_FRAGMENT_PROCESSING
|
5868 SYSTEM_ACCESS_MODE_NOT_IN_SYS
|
5869 ENABLE_ADVANCED_DRIVER_MODEL
|
5870 SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU
);
5871 /* Setup L2 cache */
5872 WREG32(VM_L2_CNTL
, ENABLE_L2_CACHE
|
5873 ENABLE_L2_FRAGMENT_PROCESSING
|
5874 ENABLE_L2_PTE_CACHE_LRU_UPDATE_BY_WRITE
|
5875 ENABLE_L2_PDE0_CACHE_LRU_UPDATE_BY_WRITE
|
5876 EFFECTIVE_L2_QUEUE_SIZE(7) |
5877 CONTEXT1_IDENTITY_ACCESS_MODE(1));
5878 WREG32(VM_L2_CNTL2
, INVALIDATE_ALL_L1_TLBS
| INVALIDATE_L2_CACHE
);
5879 WREG32(VM_L2_CNTL3
, L2_CACHE_BIGK_ASSOCIATIVITY
|
5881 L2_CACHE_BIGK_FRAGMENT_SIZE(4));
5882 /* setup context0 */
5883 WREG32(VM_CONTEXT0_PAGE_TABLE_START_ADDR
, rdev
->mc
.gtt_start
>> 12);
5884 WREG32(VM_CONTEXT0_PAGE_TABLE_END_ADDR
, rdev
->mc
.gtt_end
>> 12);
5885 WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR
, rdev
->gart
.table_addr
>> 12);
5886 WREG32(VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR
,
5887 (u32
)(rdev
->dummy_page
.addr
>> 12));
5888 WREG32(VM_CONTEXT0_CNTL2
, 0);
5889 WREG32(VM_CONTEXT0_CNTL
, (ENABLE_CONTEXT
| PAGE_TABLE_DEPTH(0) |
5890 RANGE_PROTECTION_FAULT_ENABLE_DEFAULT
));
5896 /* restore context1-15 */
5897 /* set vm size, must be a multiple of 4 */
5898 WREG32(VM_CONTEXT1_PAGE_TABLE_START_ADDR
, 0);
5899 WREG32(VM_CONTEXT1_PAGE_TABLE_END_ADDR
, rdev
->vm_manager
.max_pfn
- 1);
5900 for (i
= 1; i
< 16; i
++) {
5902 WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR
+ (i
<< 2),
5903 rdev
->vm_manager
.saved_table_addr
[i
]);
5905 WREG32(VM_CONTEXT8_PAGE_TABLE_BASE_ADDR
+ ((i
- 8) << 2),
5906 rdev
->vm_manager
.saved_table_addr
[i
]);
5909 /* enable context1-15 */
5910 WREG32(VM_CONTEXT1_PROTECTION_FAULT_DEFAULT_ADDR
,
5911 (u32
)(rdev
->dummy_page
.addr
>> 12));
5912 WREG32(VM_CONTEXT1_CNTL2
, 4);
5913 WREG32(VM_CONTEXT1_CNTL
, ENABLE_CONTEXT
| PAGE_TABLE_DEPTH(1) |
5914 PAGE_TABLE_BLOCK_SIZE(radeon_vm_block_size
- 9) |
5915 RANGE_PROTECTION_FAULT_ENABLE_INTERRUPT
|
5916 RANGE_PROTECTION_FAULT_ENABLE_DEFAULT
|
5917 DUMMY_PAGE_PROTECTION_FAULT_ENABLE_INTERRUPT
|
5918 DUMMY_PAGE_PROTECTION_FAULT_ENABLE_DEFAULT
|
5919 PDE0_PROTECTION_FAULT_ENABLE_INTERRUPT
|
5920 PDE0_PROTECTION_FAULT_ENABLE_DEFAULT
|
5921 VALID_PROTECTION_FAULT_ENABLE_INTERRUPT
|
5922 VALID_PROTECTION_FAULT_ENABLE_DEFAULT
|
5923 READ_PROTECTION_FAULT_ENABLE_INTERRUPT
|
5924 READ_PROTECTION_FAULT_ENABLE_DEFAULT
|
5925 WRITE_PROTECTION_FAULT_ENABLE_INTERRUPT
|
5926 WRITE_PROTECTION_FAULT_ENABLE_DEFAULT
);
5928 if (rdev
->family
== CHIP_KAVERI
) {
5929 u32 tmp
= RREG32(CHUB_CONTROL
);
5931 WREG32(CHUB_CONTROL
, tmp
);
5934 /* XXX SH_MEM regs */
5935 /* where to put LDS, scratch, GPUVM in FSA64 space */
5936 mutex_lock(&rdev
->srbm_mutex
);
5937 for (i
= 0; i
< 16; i
++) {
5938 cik_srbm_select(rdev
, 0, 0, 0, i
);
5939 /* CP and shaders */
5940 WREG32(SH_MEM_CONFIG
, 0);
5941 WREG32(SH_MEM_APE1_BASE
, 1);
5942 WREG32(SH_MEM_APE1_LIMIT
, 0);
5943 WREG32(SH_MEM_BASES
, 0);
5945 WREG32(SDMA0_GFX_VIRTUAL_ADDR
+ SDMA0_REGISTER_OFFSET
, 0);
5946 WREG32(SDMA0_GFX_APE1_CNTL
+ SDMA0_REGISTER_OFFSET
, 0);
5947 WREG32(SDMA0_GFX_VIRTUAL_ADDR
+ SDMA1_REGISTER_OFFSET
, 0);
5948 WREG32(SDMA0_GFX_APE1_CNTL
+ SDMA1_REGISTER_OFFSET
, 0);
5949 /* XXX SDMA RLC - todo */
5951 cik_srbm_select(rdev
, 0, 0, 0, 0);
5952 mutex_unlock(&rdev
->srbm_mutex
);
5954 cik_pcie_init_compute_vmid(rdev
);
5956 cik_pcie_gart_tlb_flush(rdev
);
5957 DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
5958 (unsigned)(rdev
->mc
.gtt_size
>> 20),
5959 (unsigned long long)rdev
->gart
.table_addr
);
5960 rdev
->gart
.ready
= true;
5965 * cik_pcie_gart_disable - gart disable
5967 * @rdev: radeon_device pointer
5969 * This disables all VM page table (CIK).
5971 static void cik_pcie_gart_disable(struct radeon_device
*rdev
)
5975 for (i
= 1; i
< 16; ++i
) {
5978 reg
= VM_CONTEXT0_PAGE_TABLE_BASE_ADDR
+ (i
<< 2);
5980 reg
= VM_CONTEXT8_PAGE_TABLE_BASE_ADDR
+ ((i
- 8) << 2);
5981 rdev
->vm_manager
.saved_table_addr
[i
] = RREG32(reg
);
5984 /* Disable all tables */
5985 WREG32(VM_CONTEXT0_CNTL
, 0);
5986 WREG32(VM_CONTEXT1_CNTL
, 0);
5987 /* Setup TLB control */
5988 WREG32(MC_VM_MX_L1_TLB_CNTL
, SYSTEM_ACCESS_MODE_NOT_IN_SYS
|
5989 SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU
);
5990 /* Setup L2 cache */
5992 ENABLE_L2_FRAGMENT_PROCESSING
|
5993 ENABLE_L2_PTE_CACHE_LRU_UPDATE_BY_WRITE
|
5994 ENABLE_L2_PDE0_CACHE_LRU_UPDATE_BY_WRITE
|
5995 EFFECTIVE_L2_QUEUE_SIZE(7) |
5996 CONTEXT1_IDENTITY_ACCESS_MODE(1));
5997 WREG32(VM_L2_CNTL2
, 0);
5998 WREG32(VM_L2_CNTL3
, L2_CACHE_BIGK_ASSOCIATIVITY
|
5999 L2_CACHE_BIGK_FRAGMENT_SIZE(6));
6000 radeon_gart_table_vram_unpin(rdev
);
6004 * cik_pcie_gart_fini - vm fini callback
6006 * @rdev: radeon_device pointer
6008 * Tears down the driver GART/VM setup (CIK).
6010 static void cik_pcie_gart_fini(struct radeon_device
*rdev
)
6012 cik_pcie_gart_disable(rdev
);
6013 radeon_gart_table_vram_free(rdev
);
6014 radeon_gart_fini(rdev
);
6019 * cik_ib_parse - vm ib_parse callback
6021 * @rdev: radeon_device pointer
6022 * @ib: indirect buffer pointer
6024 * CIK uses hw IB checking so this is a nop (CIK).
6026 int cik_ib_parse(struct radeon_device
*rdev
, struct radeon_ib
*ib
)
6033 * VMID 0 is the physical GPU addresses as used by the kernel.
6034 * VMIDs 1-15 are used for userspace clients and are handled
6035 * by the radeon vm/hsa code.
6038 * cik_vm_init - cik vm init callback
6040 * @rdev: radeon_device pointer
6042 * Inits cik specific vm parameters (number of VMs, base of vram for
6043 * VMIDs 1-15) (CIK).
6044 * Returns 0 for success.
6046 int cik_vm_init(struct radeon_device
*rdev
)
6050 * VMID 0 is reserved for System
6051 * radeon graphics/compute will use VMIDs 1-7
6052 * amdkfd will use VMIDs 8-15
6054 rdev
->vm_manager
.nvm
= RADEON_NUM_OF_VMIDS
;
6055 /* base offset of vram pages */
6056 if (rdev
->flags
& RADEON_IS_IGP
) {
6057 u64 tmp
= RREG32(MC_VM_FB_OFFSET
);
6059 rdev
->vm_manager
.vram_base_offset
= tmp
;
6061 rdev
->vm_manager
.vram_base_offset
= 0;
6067 * cik_vm_fini - cik vm fini callback
6069 * @rdev: radeon_device pointer
6071 * Tear down any asic specific VM setup (CIK).
6073 void cik_vm_fini(struct radeon_device
*rdev
)
6078 * cik_vm_decode_fault - print human readable fault info
6080 * @rdev: radeon_device pointer
6081 * @status: VM_CONTEXT1_PROTECTION_FAULT_STATUS register value
6082 * @addr: VM_CONTEXT1_PROTECTION_FAULT_ADDR register value
6084 * Print human readable fault information (CIK).
6086 static void cik_vm_decode_fault(struct radeon_device
*rdev
,
6087 u32 status
, u32 addr
, u32 mc_client
)
6090 u32 vmid
= (status
& FAULT_VMID_MASK
) >> FAULT_VMID_SHIFT
;
6091 u32 protections
= (status
& PROTECTIONS_MASK
) >> PROTECTIONS_SHIFT
;
6092 char block
[5] = { mc_client
>> 24, (mc_client
>> 16) & 0xff,
6093 (mc_client
>> 8) & 0xff, mc_client
& 0xff, 0 };
6095 if (rdev
->family
== CHIP_HAWAII
)
6096 mc_id
= (status
& HAWAII_MEMORY_CLIENT_ID_MASK
) >> MEMORY_CLIENT_ID_SHIFT
;
6098 mc_id
= (status
& MEMORY_CLIENT_ID_MASK
) >> MEMORY_CLIENT_ID_SHIFT
;
6100 printk("VM fault (0x%02x, vmid %d) at page %u, %s from '%s' (0x%08x) (%d)\n",
6101 protections
, vmid
, addr
,
6102 (status
& MEMORY_CLIENT_RW_MASK
) ? "write" : "read",
6103 block
, mc_client
, mc_id
);
6107 * cik_vm_flush - cik vm flush using the CP
6109 * @rdev: radeon_device pointer
6111 * Update the page table base and flush the VM TLB
6112 * using the CP (CIK).
6114 void cik_vm_flush(struct radeon_device
*rdev
, struct radeon_ring
*ring
,
6115 unsigned vm_id
, uint64_t pd_addr
)
6117 int usepfp
= (ring
->idx
== RADEON_RING_TYPE_GFX_INDEX
);
6119 radeon_ring_write(ring
, PACKET3(PACKET3_WRITE_DATA
, 3));
6120 radeon_ring_write(ring
, (WRITE_DATA_ENGINE_SEL(usepfp
) |
6121 WRITE_DATA_DST_SEL(0)));
6123 radeon_ring_write(ring
,
6124 (VM_CONTEXT0_PAGE_TABLE_BASE_ADDR
+ (vm_id
<< 2)) >> 2);
6126 radeon_ring_write(ring
,
6127 (VM_CONTEXT8_PAGE_TABLE_BASE_ADDR
+ ((vm_id
- 8) << 2)) >> 2);
6129 radeon_ring_write(ring
, 0);
6130 radeon_ring_write(ring
, pd_addr
>> 12);
6132 /* update SH_MEM_* regs */
6133 radeon_ring_write(ring
, PACKET3(PACKET3_WRITE_DATA
, 3));
6134 radeon_ring_write(ring
, (WRITE_DATA_ENGINE_SEL(usepfp
) |
6135 WRITE_DATA_DST_SEL(0)));
6136 radeon_ring_write(ring
, SRBM_GFX_CNTL
>> 2);
6137 radeon_ring_write(ring
, 0);
6138 radeon_ring_write(ring
, VMID(vm_id
));
6140 radeon_ring_write(ring
, PACKET3(PACKET3_WRITE_DATA
, 6));
6141 radeon_ring_write(ring
, (WRITE_DATA_ENGINE_SEL(usepfp
) |
6142 WRITE_DATA_DST_SEL(0)));
6143 radeon_ring_write(ring
, SH_MEM_BASES
>> 2);
6144 radeon_ring_write(ring
, 0);
6146 radeon_ring_write(ring
, 0); /* SH_MEM_BASES */
6147 radeon_ring_write(ring
, 0); /* SH_MEM_CONFIG */
6148 radeon_ring_write(ring
, 1); /* SH_MEM_APE1_BASE */
6149 radeon_ring_write(ring
, 0); /* SH_MEM_APE1_LIMIT */
6151 radeon_ring_write(ring
, PACKET3(PACKET3_WRITE_DATA
, 3));
6152 radeon_ring_write(ring
, (WRITE_DATA_ENGINE_SEL(usepfp
) |
6153 WRITE_DATA_DST_SEL(0)));
6154 radeon_ring_write(ring
, SRBM_GFX_CNTL
>> 2);
6155 radeon_ring_write(ring
, 0);
6156 radeon_ring_write(ring
, VMID(0));
6159 cik_hdp_flush_cp_ring_emit(rdev
, ring
->idx
);
6161 /* bits 0-15 are the VM contexts0-15 */
6162 radeon_ring_write(ring
, PACKET3(PACKET3_WRITE_DATA
, 3));
6163 radeon_ring_write(ring
, (WRITE_DATA_ENGINE_SEL(usepfp
) |
6164 WRITE_DATA_DST_SEL(0)));
6165 radeon_ring_write(ring
, VM_INVALIDATE_REQUEST
>> 2);
6166 radeon_ring_write(ring
, 0);
6167 radeon_ring_write(ring
, 1 << vm_id
);
6169 /* wait for the invalidate to complete */
6170 radeon_ring_write(ring
, PACKET3(PACKET3_WAIT_REG_MEM
, 5));
6171 radeon_ring_write(ring
, (WAIT_REG_MEM_OPERATION(0) | /* wait */
6172 WAIT_REG_MEM_FUNCTION(0) | /* always */
6173 WAIT_REG_MEM_ENGINE(0))); /* me */
6174 radeon_ring_write(ring
, VM_INVALIDATE_REQUEST
>> 2);
6175 radeon_ring_write(ring
, 0);
6176 radeon_ring_write(ring
, 0); /* ref */
6177 radeon_ring_write(ring
, 0); /* mask */
6178 radeon_ring_write(ring
, 0x20); /* poll interval */
6180 /* compute doesn't have PFP */
6182 /* sync PFP to ME, otherwise we might get invalid PFP reads */
6183 radeon_ring_write(ring
, PACKET3(PACKET3_PFP_SYNC_ME
, 0));
6184 radeon_ring_write(ring
, 0x0);
6190 * The RLC is a multi-purpose microengine that handles a
6191 * variety of functions, the most important of which is
6192 * the interrupt controller.
6194 static void cik_enable_gui_idle_interrupt(struct radeon_device
*rdev
,
6197 u32 tmp
= RREG32(CP_INT_CNTL_RING0
);
6200 tmp
|= (CNTX_BUSY_INT_ENABLE
| CNTX_EMPTY_INT_ENABLE
);
6202 tmp
&= ~(CNTX_BUSY_INT_ENABLE
| CNTX_EMPTY_INT_ENABLE
);
6203 WREG32(CP_INT_CNTL_RING0
, tmp
);
6206 static void cik_enable_lbpw(struct radeon_device
*rdev
, bool enable
)
6210 tmp
= RREG32(RLC_LB_CNTL
);
6212 tmp
|= LOAD_BALANCE_ENABLE
;
6214 tmp
&= ~LOAD_BALANCE_ENABLE
;
6215 WREG32(RLC_LB_CNTL
, tmp
);
6218 static void cik_wait_for_rlc_serdes(struct radeon_device
*rdev
)
6223 mutex_lock(&rdev
->grbm_idx_mutex
);
6224 for (i
= 0; i
< rdev
->config
.cik
.max_shader_engines
; i
++) {
6225 for (j
= 0; j
< rdev
->config
.cik
.max_sh_per_se
; j
++) {
6226 cik_select_se_sh(rdev
, i
, j
);
6227 for (k
= 0; k
< rdev
->usec_timeout
; k
++) {
6228 if (RREG32(RLC_SERDES_CU_MASTER_BUSY
) == 0)
6234 cik_select_se_sh(rdev
, 0xffffffff, 0xffffffff);
6235 mutex_unlock(&rdev
->grbm_idx_mutex
);
6237 mask
= SE_MASTER_BUSY_MASK
| GC_MASTER_BUSY
| TC0_MASTER_BUSY
| TC1_MASTER_BUSY
;
6238 for (k
= 0; k
< rdev
->usec_timeout
; k
++) {
6239 if ((RREG32(RLC_SERDES_NONCU_MASTER_BUSY
) & mask
) == 0)
6245 static void cik_update_rlc(struct radeon_device
*rdev
, u32 rlc
)
6249 tmp
= RREG32(RLC_CNTL
);
6251 WREG32(RLC_CNTL
, rlc
);
6254 static u32
cik_halt_rlc(struct radeon_device
*rdev
)
6258 orig
= data
= RREG32(RLC_CNTL
);
6260 if (data
& RLC_ENABLE
) {
6263 data
&= ~RLC_ENABLE
;
6264 WREG32(RLC_CNTL
, data
);
6266 for (i
= 0; i
< rdev
->usec_timeout
; i
++) {
6267 if ((RREG32(RLC_GPM_STAT
) & RLC_GPM_BUSY
) == 0)
6272 cik_wait_for_rlc_serdes(rdev
);
6278 void cik_enter_rlc_safe_mode(struct radeon_device
*rdev
)
6282 tmp
= REQ
| MESSAGE(MSG_ENTER_RLC_SAFE_MODE
);
6283 WREG32(RLC_GPR_REG2
, tmp
);
6285 mask
= GFX_POWER_STATUS
| GFX_CLOCK_STATUS
;
6286 for (i
= 0; i
< rdev
->usec_timeout
; i
++) {
6287 if ((RREG32(RLC_GPM_STAT
) & mask
) == mask
)
6292 for (i
= 0; i
< rdev
->usec_timeout
; i
++) {
6293 if ((RREG32(RLC_GPR_REG2
) & REQ
) == 0)
6299 void cik_exit_rlc_safe_mode(struct radeon_device
*rdev
)
6303 tmp
= REQ
| MESSAGE(MSG_EXIT_RLC_SAFE_MODE
);
6304 WREG32(RLC_GPR_REG2
, tmp
);
6308 * cik_rlc_stop - stop the RLC ME
6310 * @rdev: radeon_device pointer
6312 * Halt the RLC ME (MicroEngine) (CIK).
6314 static void cik_rlc_stop(struct radeon_device
*rdev
)
6316 WREG32(RLC_CNTL
, 0);
6318 cik_enable_gui_idle_interrupt(rdev
, false);
6320 cik_wait_for_rlc_serdes(rdev
);
6324 * cik_rlc_start - start the RLC ME
6326 * @rdev: radeon_device pointer
6328 * Unhalt the RLC ME (MicroEngine) (CIK).
6330 static void cik_rlc_start(struct radeon_device
*rdev
)
6332 WREG32(RLC_CNTL
, RLC_ENABLE
);
6334 cik_enable_gui_idle_interrupt(rdev
, true);
6340 * cik_rlc_resume - setup the RLC hw
6342 * @rdev: radeon_device pointer
6344 * Initialize the RLC registers, load the ucode,
6345 * and start the RLC (CIK).
6346 * Returns 0 for success, -EINVAL if the ucode is not available.
6348 static int cik_rlc_resume(struct radeon_device
*rdev
)
6358 tmp
= RREG32(RLC_CGCG_CGLS_CTRL
) & 0xfffffffc;
6359 WREG32(RLC_CGCG_CGLS_CTRL
, tmp
);
6367 WREG32(RLC_LB_CNTR_INIT
, 0);
6368 WREG32(RLC_LB_CNTR_MAX
, 0x00008000);
6370 mutex_lock(&rdev
->grbm_idx_mutex
);
6371 cik_select_se_sh(rdev
, 0xffffffff, 0xffffffff);
6372 WREG32(RLC_LB_INIT_CU_MASK
, 0xffffffff);
6373 WREG32(RLC_LB_PARAMS
, 0x00600408);
6374 WREG32(RLC_LB_CNTL
, 0x80000004);
6375 mutex_unlock(&rdev
->grbm_idx_mutex
);
6377 WREG32(RLC_MC_CNTL
, 0);
6378 WREG32(RLC_UCODE_CNTL
, 0);
6381 const struct rlc_firmware_header_v1_0
*hdr
=
6382 (const struct rlc_firmware_header_v1_0
*)rdev
->rlc_fw
->data
;
6383 const __le32
*fw_data
= (const __le32
*)
6384 (rdev
->rlc_fw
->data
+ le32_to_cpu(hdr
->header
.ucode_array_offset_bytes
));
6386 radeon_ucode_print_rlc_hdr(&hdr
->header
);
6388 size
= le32_to_cpu(hdr
->header
.ucode_size_bytes
) / 4;
6389 WREG32(RLC_GPM_UCODE_ADDR
, 0);
6390 for (i
= 0; i
< size
; i
++)
6391 WREG32(RLC_GPM_UCODE_DATA
, le32_to_cpup(fw_data
++));
6392 WREG32(RLC_GPM_UCODE_ADDR
, le32_to_cpu(hdr
->header
.ucode_version
));
6394 const __be32
*fw_data
;
6396 switch (rdev
->family
) {
6400 size
= BONAIRE_RLC_UCODE_SIZE
;
6403 size
= KV_RLC_UCODE_SIZE
;
6406 size
= KB_RLC_UCODE_SIZE
;
6409 size
= ML_RLC_UCODE_SIZE
;
6413 fw_data
= (const __be32
*)rdev
->rlc_fw
->data
;
6414 WREG32(RLC_GPM_UCODE_ADDR
, 0);
6415 for (i
= 0; i
< size
; i
++)
6416 WREG32(RLC_GPM_UCODE_DATA
, be32_to_cpup(fw_data
++));
6417 WREG32(RLC_GPM_UCODE_ADDR
, 0);
6420 /* XXX - find out what chips support lbpw */
6421 cik_enable_lbpw(rdev
, false);
6423 if (rdev
->family
== CHIP_BONAIRE
)
6424 WREG32(RLC_DRIVER_DMA_STATUS
, 0);
6426 cik_rlc_start(rdev
);
6431 static void cik_enable_cgcg(struct radeon_device
*rdev
, bool enable
)
6433 u32 data
, orig
, tmp
, tmp2
;
6435 orig
= data
= RREG32(RLC_CGCG_CGLS_CTRL
);
6437 if (enable
&& (rdev
->cg_flags
& RADEON_CG_SUPPORT_GFX_CGCG
)) {
6438 cik_enable_gui_idle_interrupt(rdev
, true);
6440 tmp
= cik_halt_rlc(rdev
);
6442 mutex_lock(&rdev
->grbm_idx_mutex
);
6443 cik_select_se_sh(rdev
, 0xffffffff, 0xffffffff);
6444 WREG32(RLC_SERDES_WR_CU_MASTER_MASK
, 0xffffffff);
6445 WREG32(RLC_SERDES_WR_NONCU_MASTER_MASK
, 0xffffffff);
6446 tmp2
= BPM_ADDR_MASK
| CGCG_OVERRIDE_0
| CGLS_ENABLE
;
6447 WREG32(RLC_SERDES_WR_CTRL
, tmp2
);
6448 mutex_unlock(&rdev
->grbm_idx_mutex
);
6450 cik_update_rlc(rdev
, tmp
);
6452 data
|= CGCG_EN
| CGLS_EN
;
6454 cik_enable_gui_idle_interrupt(rdev
, false);
6456 RREG32(CB_CGTT_SCLK_CTRL
);
6457 RREG32(CB_CGTT_SCLK_CTRL
);
6458 RREG32(CB_CGTT_SCLK_CTRL
);
6459 RREG32(CB_CGTT_SCLK_CTRL
);
6461 data
&= ~(CGCG_EN
| CGLS_EN
);
6465 WREG32(RLC_CGCG_CGLS_CTRL
, data
);
6469 static void cik_enable_mgcg(struct radeon_device
*rdev
, bool enable
)
6471 u32 data
, orig
, tmp
= 0;
6473 if (enable
&& (rdev
->cg_flags
& RADEON_CG_SUPPORT_GFX_MGCG
)) {
6474 if (rdev
->cg_flags
& RADEON_CG_SUPPORT_GFX_MGLS
) {
6475 if (rdev
->cg_flags
& RADEON_CG_SUPPORT_GFX_CP_LS
) {
6476 orig
= data
= RREG32(CP_MEM_SLP_CNTL
);
6477 data
|= CP_MEM_LS_EN
;
6479 WREG32(CP_MEM_SLP_CNTL
, data
);
6483 orig
= data
= RREG32(RLC_CGTT_MGCG_OVERRIDE
);
6487 WREG32(RLC_CGTT_MGCG_OVERRIDE
, data
);
6489 tmp
= cik_halt_rlc(rdev
);
6491 mutex_lock(&rdev
->grbm_idx_mutex
);
6492 cik_select_se_sh(rdev
, 0xffffffff, 0xffffffff);
6493 WREG32(RLC_SERDES_WR_CU_MASTER_MASK
, 0xffffffff);
6494 WREG32(RLC_SERDES_WR_NONCU_MASTER_MASK
, 0xffffffff);
6495 data
= BPM_ADDR_MASK
| MGCG_OVERRIDE_0
;
6496 WREG32(RLC_SERDES_WR_CTRL
, data
);
6497 mutex_unlock(&rdev
->grbm_idx_mutex
);
6499 cik_update_rlc(rdev
, tmp
);
6501 if (rdev
->cg_flags
& RADEON_CG_SUPPORT_GFX_CGTS
) {
6502 orig
= data
= RREG32(CGTS_SM_CTRL_REG
);
6503 data
&= ~SM_MODE_MASK
;
6504 data
|= SM_MODE(0x2);
6505 data
|= SM_MODE_ENABLE
;
6506 data
&= ~CGTS_OVERRIDE
;
6507 if ((rdev
->cg_flags
& RADEON_CG_SUPPORT_GFX_MGLS
) &&
6508 (rdev
->cg_flags
& RADEON_CG_SUPPORT_GFX_CGTS_LS
))
6509 data
&= ~CGTS_LS_OVERRIDE
;
6510 data
&= ~ON_MONITOR_ADD_MASK
;
6511 data
|= ON_MONITOR_ADD_EN
;
6512 data
|= ON_MONITOR_ADD(0x96);
6514 WREG32(CGTS_SM_CTRL_REG
, data
);
6517 orig
= data
= RREG32(RLC_CGTT_MGCG_OVERRIDE
);
6520 WREG32(RLC_CGTT_MGCG_OVERRIDE
, data
);
6522 data
= RREG32(RLC_MEM_SLP_CNTL
);
6523 if (data
& RLC_MEM_LS_EN
) {
6524 data
&= ~RLC_MEM_LS_EN
;
6525 WREG32(RLC_MEM_SLP_CNTL
, data
);
6528 data
= RREG32(CP_MEM_SLP_CNTL
);
6529 if (data
& CP_MEM_LS_EN
) {
6530 data
&= ~CP_MEM_LS_EN
;
6531 WREG32(CP_MEM_SLP_CNTL
, data
);
6534 orig
= data
= RREG32(CGTS_SM_CTRL_REG
);
6535 data
|= CGTS_OVERRIDE
| CGTS_LS_OVERRIDE
;
6537 WREG32(CGTS_SM_CTRL_REG
, data
);
6539 tmp
= cik_halt_rlc(rdev
);
6541 mutex_lock(&rdev
->grbm_idx_mutex
);
6542 cik_select_se_sh(rdev
, 0xffffffff, 0xffffffff);
6543 WREG32(RLC_SERDES_WR_CU_MASTER_MASK
, 0xffffffff);
6544 WREG32(RLC_SERDES_WR_NONCU_MASTER_MASK
, 0xffffffff);
6545 data
= BPM_ADDR_MASK
| MGCG_OVERRIDE_1
;
6546 WREG32(RLC_SERDES_WR_CTRL
, data
);
6547 mutex_unlock(&rdev
->grbm_idx_mutex
);
6549 cik_update_rlc(rdev
, tmp
);
6553 static const u32 mc_cg_registers
[] =
6566 static void cik_enable_mc_ls(struct radeon_device
*rdev
,
6572 for (i
= 0; i
< ARRAY_SIZE(mc_cg_registers
); i
++) {
6573 orig
= data
= RREG32(mc_cg_registers
[i
]);
6574 if (enable
&& (rdev
->cg_flags
& RADEON_CG_SUPPORT_MC_LS
))
6575 data
|= MC_LS_ENABLE
;
6577 data
&= ~MC_LS_ENABLE
;
6579 WREG32(mc_cg_registers
[i
], data
);
6583 static void cik_enable_mc_mgcg(struct radeon_device
*rdev
,
6589 for (i
= 0; i
< ARRAY_SIZE(mc_cg_registers
); i
++) {
6590 orig
= data
= RREG32(mc_cg_registers
[i
]);
6591 if (enable
&& (rdev
->cg_flags
& RADEON_CG_SUPPORT_MC_MGCG
))
6592 data
|= MC_CG_ENABLE
;
6594 data
&= ~MC_CG_ENABLE
;
6596 WREG32(mc_cg_registers
[i
], data
);
6600 static void cik_enable_sdma_mgcg(struct radeon_device
*rdev
,
6605 if (enable
&& (rdev
->cg_flags
& RADEON_CG_SUPPORT_SDMA_MGCG
)) {
6606 WREG32(SDMA0_CLK_CTRL
+ SDMA0_REGISTER_OFFSET
, 0x00000100);
6607 WREG32(SDMA0_CLK_CTRL
+ SDMA1_REGISTER_OFFSET
, 0x00000100);
6609 orig
= data
= RREG32(SDMA0_CLK_CTRL
+ SDMA0_REGISTER_OFFSET
);
6612 WREG32(SDMA0_CLK_CTRL
+ SDMA0_REGISTER_OFFSET
, data
);
6614 orig
= data
= RREG32(SDMA0_CLK_CTRL
+ SDMA1_REGISTER_OFFSET
);
6617 WREG32(SDMA0_CLK_CTRL
+ SDMA1_REGISTER_OFFSET
, data
);
6621 static void cik_enable_sdma_mgls(struct radeon_device
*rdev
,
6626 if (enable
&& (rdev
->cg_flags
& RADEON_CG_SUPPORT_SDMA_LS
)) {
6627 orig
= data
= RREG32(SDMA0_POWER_CNTL
+ SDMA0_REGISTER_OFFSET
);
6630 WREG32(SDMA0_POWER_CNTL
+ SDMA0_REGISTER_OFFSET
, data
);
6632 orig
= data
= RREG32(SDMA0_POWER_CNTL
+ SDMA1_REGISTER_OFFSET
);
6635 WREG32(SDMA0_POWER_CNTL
+ SDMA1_REGISTER_OFFSET
, data
);
6637 orig
= data
= RREG32(SDMA0_POWER_CNTL
+ SDMA0_REGISTER_OFFSET
);
6640 WREG32(SDMA0_POWER_CNTL
+ SDMA0_REGISTER_OFFSET
, data
);
6642 orig
= data
= RREG32(SDMA0_POWER_CNTL
+ SDMA1_REGISTER_OFFSET
);
6645 WREG32(SDMA0_POWER_CNTL
+ SDMA1_REGISTER_OFFSET
, data
);
6649 static void cik_enable_uvd_mgcg(struct radeon_device
*rdev
,
6654 if (enable
&& (rdev
->cg_flags
& RADEON_CG_SUPPORT_UVD_MGCG
)) {
6655 data
= RREG32_UVD_CTX(UVD_CGC_MEM_CTRL
);
6657 WREG32_UVD_CTX(UVD_CGC_MEM_CTRL
, data
);
6659 orig
= data
= RREG32(UVD_CGC_CTRL
);
6662 WREG32(UVD_CGC_CTRL
, data
);
6664 data
= RREG32_UVD_CTX(UVD_CGC_MEM_CTRL
);
6666 WREG32_UVD_CTX(UVD_CGC_MEM_CTRL
, data
);
6668 orig
= data
= RREG32(UVD_CGC_CTRL
);
6671 WREG32(UVD_CGC_CTRL
, data
);
6675 static void cik_enable_bif_mgls(struct radeon_device
*rdev
,
6680 orig
= data
= RREG32_PCIE_PORT(PCIE_CNTL2
);
6682 if (enable
&& (rdev
->cg_flags
& RADEON_CG_SUPPORT_BIF_LS
))
6683 data
|= SLV_MEM_LS_EN
| MST_MEM_LS_EN
|
6684 REPLAY_MEM_LS_EN
| SLV_MEM_AGGRESSIVE_LS_EN
;
6686 data
&= ~(SLV_MEM_LS_EN
| MST_MEM_LS_EN
|
6687 REPLAY_MEM_LS_EN
| SLV_MEM_AGGRESSIVE_LS_EN
);
6690 WREG32_PCIE_PORT(PCIE_CNTL2
, data
);
6693 static void cik_enable_hdp_mgcg(struct radeon_device
*rdev
,
6698 orig
= data
= RREG32(HDP_HOST_PATH_CNTL
);
6700 if (enable
&& (rdev
->cg_flags
& RADEON_CG_SUPPORT_HDP_MGCG
))
6701 data
&= ~CLOCK_GATING_DIS
;
6703 data
|= CLOCK_GATING_DIS
;
6706 WREG32(HDP_HOST_PATH_CNTL
, data
);
6709 static void cik_enable_hdp_ls(struct radeon_device
*rdev
,
6714 orig
= data
= RREG32(HDP_MEM_POWER_LS
);
6716 if (enable
&& (rdev
->cg_flags
& RADEON_CG_SUPPORT_HDP_LS
))
6717 data
|= HDP_LS_ENABLE
;
6719 data
&= ~HDP_LS_ENABLE
;
6722 WREG32(HDP_MEM_POWER_LS
, data
);
6725 void cik_update_cg(struct radeon_device
*rdev
,
6726 u32 block
, bool enable
)
6729 if (block
& RADEON_CG_BLOCK_GFX
) {
6730 cik_enable_gui_idle_interrupt(rdev
, false);
6731 /* order matters! */
6733 cik_enable_mgcg(rdev
, true);
6734 cik_enable_cgcg(rdev
, true);
6736 cik_enable_cgcg(rdev
, false);
6737 cik_enable_mgcg(rdev
, false);
6739 cik_enable_gui_idle_interrupt(rdev
, true);
6742 if (block
& RADEON_CG_BLOCK_MC
) {
6743 if (!(rdev
->flags
& RADEON_IS_IGP
)) {
6744 cik_enable_mc_mgcg(rdev
, enable
);
6745 cik_enable_mc_ls(rdev
, enable
);
6749 if (block
& RADEON_CG_BLOCK_SDMA
) {
6750 cik_enable_sdma_mgcg(rdev
, enable
);
6751 cik_enable_sdma_mgls(rdev
, enable
);
6754 if (block
& RADEON_CG_BLOCK_BIF
) {
6755 cik_enable_bif_mgls(rdev
, enable
);
6758 if (block
& RADEON_CG_BLOCK_UVD
) {
6760 cik_enable_uvd_mgcg(rdev
, enable
);
6763 if (block
& RADEON_CG_BLOCK_HDP
) {
6764 cik_enable_hdp_mgcg(rdev
, enable
);
6765 cik_enable_hdp_ls(rdev
, enable
);
6768 if (block
& RADEON_CG_BLOCK_VCE
) {
6769 vce_v2_0_enable_mgcg(rdev
, enable
);
6773 static void cik_init_cg(struct radeon_device
*rdev
)
6776 cik_update_cg(rdev
, RADEON_CG_BLOCK_GFX
, true);
6779 si_init_uvd_internal_cg(rdev
);
6781 cik_update_cg(rdev
, (RADEON_CG_BLOCK_MC
|
6782 RADEON_CG_BLOCK_SDMA
|
6783 RADEON_CG_BLOCK_BIF
|
6784 RADEON_CG_BLOCK_UVD
|
6785 RADEON_CG_BLOCK_HDP
), true);
6788 static void cik_fini_cg(struct radeon_device
*rdev
)
6790 cik_update_cg(rdev
, (RADEON_CG_BLOCK_MC
|
6791 RADEON_CG_BLOCK_SDMA
|
6792 RADEON_CG_BLOCK_BIF
|
6793 RADEON_CG_BLOCK_UVD
|
6794 RADEON_CG_BLOCK_HDP
), false);
6796 cik_update_cg(rdev
, RADEON_CG_BLOCK_GFX
, false);
6799 static void cik_enable_sck_slowdown_on_pu(struct radeon_device
*rdev
,
6804 orig
= data
= RREG32(RLC_PG_CNTL
);
6805 if (enable
&& (rdev
->pg_flags
& RADEON_PG_SUPPORT_RLC_SMU_HS
))
6806 data
|= SMU_CLK_SLOWDOWN_ON_PU_ENABLE
;
6808 data
&= ~SMU_CLK_SLOWDOWN_ON_PU_ENABLE
;
6810 WREG32(RLC_PG_CNTL
, data
);
6813 static void cik_enable_sck_slowdown_on_pd(struct radeon_device
*rdev
,
6818 orig
= data
= RREG32(RLC_PG_CNTL
);
6819 if (enable
&& (rdev
->pg_flags
& RADEON_PG_SUPPORT_RLC_SMU_HS
))
6820 data
|= SMU_CLK_SLOWDOWN_ON_PD_ENABLE
;
6822 data
&= ~SMU_CLK_SLOWDOWN_ON_PD_ENABLE
;
6824 WREG32(RLC_PG_CNTL
, data
);
6827 static void cik_enable_cp_pg(struct radeon_device
*rdev
, bool enable
)
6831 orig
= data
= RREG32(RLC_PG_CNTL
);
6832 if (enable
&& (rdev
->pg_flags
& RADEON_PG_SUPPORT_CP
))
6833 data
&= ~DISABLE_CP_PG
;
6835 data
|= DISABLE_CP_PG
;
6837 WREG32(RLC_PG_CNTL
, data
);
6840 static void cik_enable_gds_pg(struct radeon_device
*rdev
, bool enable
)
6844 orig
= data
= RREG32(RLC_PG_CNTL
);
6845 if (enable
&& (rdev
->pg_flags
& RADEON_PG_SUPPORT_GDS
))
6846 data
&= ~DISABLE_GDS_PG
;
6848 data
|= DISABLE_GDS_PG
;
6850 WREG32(RLC_PG_CNTL
, data
);
6853 #define CP_ME_TABLE_SIZE 96
6854 #define CP_ME_TABLE_OFFSET 2048
6855 #define CP_MEC_TABLE_OFFSET 4096
6857 void cik_init_cp_pg_table(struct radeon_device
*rdev
)
6859 volatile u32
*dst_ptr
;
6860 int me
, i
, max_me
= 4;
6862 u32 table_offset
, table_size
;
6864 if (rdev
->family
== CHIP_KAVERI
)
6867 if (rdev
->rlc
.cp_table_ptr
== NULL
)
6870 /* write the cp table buffer */
6871 dst_ptr
= rdev
->rlc
.cp_table_ptr
;
6872 for (me
= 0; me
< max_me
; me
++) {
6874 const __le32
*fw_data
;
6875 const struct gfx_firmware_header_v1_0
*hdr
;
6878 hdr
= (const struct gfx_firmware_header_v1_0
*)rdev
->ce_fw
->data
;
6879 fw_data
= (const __le32
*)
6880 (rdev
->ce_fw
->data
+ le32_to_cpu(hdr
->header
.ucode_array_offset_bytes
));
6881 table_offset
= le32_to_cpu(hdr
->jt_offset
);
6882 table_size
= le32_to_cpu(hdr
->jt_size
);
6883 } else if (me
== 1) {
6884 hdr
= (const struct gfx_firmware_header_v1_0
*)rdev
->pfp_fw
->data
;
6885 fw_data
= (const __le32
*)
6886 (rdev
->pfp_fw
->data
+ le32_to_cpu(hdr
->header
.ucode_array_offset_bytes
));
6887 table_offset
= le32_to_cpu(hdr
->jt_offset
);
6888 table_size
= le32_to_cpu(hdr
->jt_size
);
6889 } else if (me
== 2) {
6890 hdr
= (const struct gfx_firmware_header_v1_0
*)rdev
->me_fw
->data
;
6891 fw_data
= (const __le32
*)
6892 (rdev
->me_fw
->data
+ le32_to_cpu(hdr
->header
.ucode_array_offset_bytes
));
6893 table_offset
= le32_to_cpu(hdr
->jt_offset
);
6894 table_size
= le32_to_cpu(hdr
->jt_size
);
6895 } else if (me
== 3) {
6896 hdr
= (const struct gfx_firmware_header_v1_0
*)rdev
->mec_fw
->data
;
6897 fw_data
= (const __le32
*)
6898 (rdev
->mec_fw
->data
+ le32_to_cpu(hdr
->header
.ucode_array_offset_bytes
));
6899 table_offset
= le32_to_cpu(hdr
->jt_offset
);
6900 table_size
= le32_to_cpu(hdr
->jt_size
);
6902 hdr
= (const struct gfx_firmware_header_v1_0
*)rdev
->mec2_fw
->data
;
6903 fw_data
= (const __le32
*)
6904 (rdev
->mec2_fw
->data
+ le32_to_cpu(hdr
->header
.ucode_array_offset_bytes
));
6905 table_offset
= le32_to_cpu(hdr
->jt_offset
);
6906 table_size
= le32_to_cpu(hdr
->jt_size
);
6909 for (i
= 0; i
< table_size
; i
++) {
6910 dst_ptr
[bo_offset
+ i
] =
6911 cpu_to_le32(le32_to_cpu(fw_data
[table_offset
+ i
]));
6913 bo_offset
+= table_size
;
6915 const __be32
*fw_data
;
6916 table_size
= CP_ME_TABLE_SIZE
;
6919 fw_data
= (const __be32
*)rdev
->ce_fw
->data
;
6920 table_offset
= CP_ME_TABLE_OFFSET
;
6921 } else if (me
== 1) {
6922 fw_data
= (const __be32
*)rdev
->pfp_fw
->data
;
6923 table_offset
= CP_ME_TABLE_OFFSET
;
6924 } else if (me
== 2) {
6925 fw_data
= (const __be32
*)rdev
->me_fw
->data
;
6926 table_offset
= CP_ME_TABLE_OFFSET
;
6928 fw_data
= (const __be32
*)rdev
->mec_fw
->data
;
6929 table_offset
= CP_MEC_TABLE_OFFSET
;
6932 for (i
= 0; i
< table_size
; i
++) {
6933 dst_ptr
[bo_offset
+ i
] =
6934 cpu_to_le32(be32_to_cpu(fw_data
[table_offset
+ i
]));
6936 bo_offset
+= table_size
;
6941 static void cik_enable_gfx_cgpg(struct radeon_device
*rdev
,
6946 if (enable
&& (rdev
->pg_flags
& RADEON_PG_SUPPORT_GFX_PG
)) {
6947 orig
= data
= RREG32(RLC_PG_CNTL
);
6948 data
|= GFX_PG_ENABLE
;
6950 WREG32(RLC_PG_CNTL
, data
);
6952 orig
= data
= RREG32(RLC_AUTO_PG_CTRL
);
6955 WREG32(RLC_AUTO_PG_CTRL
, data
);
6957 orig
= data
= RREG32(RLC_PG_CNTL
);
6958 data
&= ~GFX_PG_ENABLE
;
6960 WREG32(RLC_PG_CNTL
, data
);
6962 orig
= data
= RREG32(RLC_AUTO_PG_CTRL
);
6963 data
&= ~AUTO_PG_EN
;
6965 WREG32(RLC_AUTO_PG_CTRL
, data
);
6967 data
= RREG32(DB_RENDER_CONTROL
);
6971 static u32
cik_get_cu_active_bitmap(struct radeon_device
*rdev
, u32 se
, u32 sh
)
6973 u32 mask
= 0, tmp
, tmp1
;
6976 mutex_lock(&rdev
->grbm_idx_mutex
);
6977 cik_select_se_sh(rdev
, se
, sh
);
6978 tmp
= RREG32(CC_GC_SHADER_ARRAY_CONFIG
);
6979 tmp1
= RREG32(GC_USER_SHADER_ARRAY_CONFIG
);
6980 cik_select_se_sh(rdev
, 0xffffffff, 0xffffffff);
6981 mutex_unlock(&rdev
->grbm_idx_mutex
);
6988 for (i
= 0; i
< rdev
->config
.cik
.max_cu_per_sh
; i
++) {
6993 return (~tmp
) & mask
;
6996 static void cik_init_ao_cu_mask(struct radeon_device
*rdev
)
6998 u32 i
, j
, k
, active_cu_number
= 0;
6999 u32 mask
, counter
, cu_bitmap
;
7002 for (i
= 0; i
< rdev
->config
.cik
.max_shader_engines
; i
++) {
7003 for (j
= 0; j
< rdev
->config
.cik
.max_sh_per_se
; j
++) {
7007 for (k
= 0; k
< rdev
->config
.cik
.max_cu_per_sh
; k
++) {
7008 if (cik_get_cu_active_bitmap(rdev
, i
, j
) & mask
) {
7016 active_cu_number
+= counter
;
7017 tmp
|= (cu_bitmap
<< (i
* 16 + j
* 8));
7021 WREG32(RLC_PG_AO_CU_MASK
, tmp
);
7023 tmp
= RREG32(RLC_MAX_PG_CU
);
7024 tmp
&= ~MAX_PU_CU_MASK
;
7025 tmp
|= MAX_PU_CU(active_cu_number
);
7026 WREG32(RLC_MAX_PG_CU
, tmp
);
7029 static void cik_enable_gfx_static_mgpg(struct radeon_device
*rdev
,
7034 orig
= data
= RREG32(RLC_PG_CNTL
);
7035 if (enable
&& (rdev
->pg_flags
& RADEON_PG_SUPPORT_GFX_SMG
))
7036 data
|= STATIC_PER_CU_PG_ENABLE
;
7038 data
&= ~STATIC_PER_CU_PG_ENABLE
;
7040 WREG32(RLC_PG_CNTL
, data
);
7043 static void cik_enable_gfx_dynamic_mgpg(struct radeon_device
*rdev
,
7048 orig
= data
= RREG32(RLC_PG_CNTL
);
7049 if (enable
&& (rdev
->pg_flags
& RADEON_PG_SUPPORT_GFX_DMG
))
7050 data
|= DYN_PER_CU_PG_ENABLE
;
7052 data
&= ~DYN_PER_CU_PG_ENABLE
;
7054 WREG32(RLC_PG_CNTL
, data
);
7057 #define RLC_SAVE_AND_RESTORE_STARTING_OFFSET 0x90
7058 #define RLC_CLEAR_STATE_DESCRIPTOR_OFFSET 0x3D
7060 static void cik_init_gfx_cgpg(struct radeon_device
*rdev
)
7065 if (rdev
->rlc
.cs_data
) {
7066 WREG32(RLC_GPM_SCRATCH_ADDR
, RLC_CLEAR_STATE_DESCRIPTOR_OFFSET
);
7067 WREG32(RLC_GPM_SCRATCH_DATA
, upper_32_bits(rdev
->rlc
.clear_state_gpu_addr
));
7068 WREG32(RLC_GPM_SCRATCH_DATA
, lower_32_bits(rdev
->rlc
.clear_state_gpu_addr
));
7069 WREG32(RLC_GPM_SCRATCH_DATA
, rdev
->rlc
.clear_state_size
);
7071 WREG32(RLC_GPM_SCRATCH_ADDR
, RLC_CLEAR_STATE_DESCRIPTOR_OFFSET
);
7072 for (i
= 0; i
< 3; i
++)
7073 WREG32(RLC_GPM_SCRATCH_DATA
, 0);
7075 if (rdev
->rlc
.reg_list
) {
7076 WREG32(RLC_GPM_SCRATCH_ADDR
, RLC_SAVE_AND_RESTORE_STARTING_OFFSET
);
7077 for (i
= 0; i
< rdev
->rlc
.reg_list_size
; i
++)
7078 WREG32(RLC_GPM_SCRATCH_DATA
, rdev
->rlc
.reg_list
[i
]);
7081 orig
= data
= RREG32(RLC_PG_CNTL
);
7084 WREG32(RLC_PG_CNTL
, data
);
7086 WREG32(RLC_SAVE_AND_RESTORE_BASE
, rdev
->rlc
.save_restore_gpu_addr
>> 8);
7087 WREG32(RLC_CP_TABLE_RESTORE
, rdev
->rlc
.cp_table_gpu_addr
>> 8);
7089 data
= RREG32(CP_RB_WPTR_POLL_CNTL
);
7090 data
&= ~IDLE_POLL_COUNT_MASK
;
7091 data
|= IDLE_POLL_COUNT(0x60);
7092 WREG32(CP_RB_WPTR_POLL_CNTL
, data
);
7095 WREG32(RLC_PG_DELAY
, data
);
7097 data
= RREG32(RLC_PG_DELAY_2
);
7100 WREG32(RLC_PG_DELAY_2
, data
);
7102 data
= RREG32(RLC_AUTO_PG_CTRL
);
7103 data
&= ~GRBM_REG_SGIT_MASK
;
7104 data
|= GRBM_REG_SGIT(0x700);
7105 WREG32(RLC_AUTO_PG_CTRL
, data
);
7109 static void cik_update_gfx_pg(struct radeon_device
*rdev
, bool enable
)
7111 cik_enable_gfx_cgpg(rdev
, enable
);
7112 cik_enable_gfx_static_mgpg(rdev
, enable
);
7113 cik_enable_gfx_dynamic_mgpg(rdev
, enable
);
7116 u32
cik_get_csb_size(struct radeon_device
*rdev
)
7119 const struct cs_section_def
*sect
= NULL
;
7120 const struct cs_extent_def
*ext
= NULL
;
7122 if (rdev
->rlc
.cs_data
== NULL
)
7125 /* begin clear state */
7127 /* context control state */
7130 for (sect
= rdev
->rlc
.cs_data
; sect
->section
!= NULL
; ++sect
) {
7131 for (ext
= sect
->section
; ext
->extent
!= NULL
; ++ext
) {
7132 if (sect
->id
== SECT_CONTEXT
)
7133 count
+= 2 + ext
->reg_count
;
7138 /* pa_sc_raster_config/pa_sc_raster_config1 */
7140 /* end clear state */
7148 void cik_get_csb_buffer(struct radeon_device
*rdev
, volatile u32
*buffer
)
7151 const struct cs_section_def
*sect
= NULL
;
7152 const struct cs_extent_def
*ext
= NULL
;
7154 if (rdev
->rlc
.cs_data
== NULL
)
7159 buffer
[count
++] = cpu_to_le32(PACKET3(PACKET3_PREAMBLE_CNTL
, 0));
7160 buffer
[count
++] = cpu_to_le32(PACKET3_PREAMBLE_BEGIN_CLEAR_STATE
);
7162 buffer
[count
++] = cpu_to_le32(PACKET3(PACKET3_CONTEXT_CONTROL
, 1));
7163 buffer
[count
++] = cpu_to_le32(0x80000000);
7164 buffer
[count
++] = cpu_to_le32(0x80000000);
7166 for (sect
= rdev
->rlc
.cs_data
; sect
->section
!= NULL
; ++sect
) {
7167 for (ext
= sect
->section
; ext
->extent
!= NULL
; ++ext
) {
7168 if (sect
->id
== SECT_CONTEXT
) {
7170 cpu_to_le32(PACKET3(PACKET3_SET_CONTEXT_REG
, ext
->reg_count
));
7171 buffer
[count
++] = cpu_to_le32(ext
->reg_index
- 0xa000);
7172 for (i
= 0; i
< ext
->reg_count
; i
++)
7173 buffer
[count
++] = cpu_to_le32(ext
->extent
[i
]);
7180 buffer
[count
++] = cpu_to_le32(PACKET3(PACKET3_SET_CONTEXT_REG
, 2));
7181 buffer
[count
++] = cpu_to_le32(PA_SC_RASTER_CONFIG
- PACKET3_SET_CONTEXT_REG_START
);
7182 switch (rdev
->family
) {
7184 buffer
[count
++] = cpu_to_le32(0x16000012);
7185 buffer
[count
++] = cpu_to_le32(0x00000000);
7188 buffer
[count
++] = cpu_to_le32(0x00000000); /* XXX */
7189 buffer
[count
++] = cpu_to_le32(0x00000000);
7193 buffer
[count
++] = cpu_to_le32(0x00000000); /* XXX */
7194 buffer
[count
++] = cpu_to_le32(0x00000000);
7197 buffer
[count
++] = cpu_to_le32(0x3a00161a);
7198 buffer
[count
++] = cpu_to_le32(0x0000002e);
7201 buffer
[count
++] = cpu_to_le32(0x00000000);
7202 buffer
[count
++] = cpu_to_le32(0x00000000);
7206 buffer
[count
++] = cpu_to_le32(PACKET3(PACKET3_PREAMBLE_CNTL
, 0));
7207 buffer
[count
++] = cpu_to_le32(PACKET3_PREAMBLE_END_CLEAR_STATE
);
7209 buffer
[count
++] = cpu_to_le32(PACKET3(PACKET3_CLEAR_STATE
, 0));
7210 buffer
[count
++] = cpu_to_le32(0);
7213 static void cik_init_pg(struct radeon_device
*rdev
)
7215 if (rdev
->pg_flags
) {
7216 cik_enable_sck_slowdown_on_pu(rdev
, true);
7217 cik_enable_sck_slowdown_on_pd(rdev
, true);
7218 if (rdev
->pg_flags
& RADEON_PG_SUPPORT_GFX_PG
) {
7219 cik_init_gfx_cgpg(rdev
);
7220 cik_enable_cp_pg(rdev
, true);
7221 cik_enable_gds_pg(rdev
, true);
7223 cik_init_ao_cu_mask(rdev
);
7224 cik_update_gfx_pg(rdev
, true);
7228 static void cik_fini_pg(struct radeon_device
*rdev
)
7230 if (rdev
->pg_flags
) {
7231 cik_update_gfx_pg(rdev
, false);
7232 if (rdev
->pg_flags
& RADEON_PG_SUPPORT_GFX_PG
) {
7233 cik_enable_cp_pg(rdev
, false);
7234 cik_enable_gds_pg(rdev
, false);
7241 * Starting with r6xx, interrupts are handled via a ring buffer.
7242 * Ring buffers are areas of GPU accessible memory that the GPU
7243 * writes interrupt vectors into and the host reads vectors out of.
7244 * There is a rptr (read pointer) that determines where the
7245 * host is currently reading, and a wptr (write pointer)
7246 * which determines where the GPU has written. When the
7247 * pointers are equal, the ring is idle. When the GPU
7248 * writes vectors to the ring buffer, it increments the
7249 * wptr. When there is an interrupt, the host then starts
7250 * fetching commands and processing them until the pointers are
7251 * equal again at which point it updates the rptr.
7255 * cik_enable_interrupts - Enable the interrupt ring buffer
7257 * @rdev: radeon_device pointer
7259 * Enable the interrupt ring buffer (CIK).
7261 static void cik_enable_interrupts(struct radeon_device
*rdev
)
7263 u32 ih_cntl
= RREG32(IH_CNTL
);
7264 u32 ih_rb_cntl
= RREG32(IH_RB_CNTL
);
7266 ih_cntl
|= ENABLE_INTR
;
7267 ih_rb_cntl
|= IH_RB_ENABLE
;
7268 WREG32(IH_CNTL
, ih_cntl
);
7269 WREG32(IH_RB_CNTL
, ih_rb_cntl
);
7270 rdev
->ih
.enabled
= true;
7274 * cik_disable_interrupts - Disable the interrupt ring buffer
7276 * @rdev: radeon_device pointer
7278 * Disable the interrupt ring buffer (CIK).
7280 static void cik_disable_interrupts(struct radeon_device
*rdev
)
7282 u32 ih_rb_cntl
= RREG32(IH_RB_CNTL
);
7283 u32 ih_cntl
= RREG32(IH_CNTL
);
7285 ih_rb_cntl
&= ~IH_RB_ENABLE
;
7286 ih_cntl
&= ~ENABLE_INTR
;
7287 WREG32(IH_RB_CNTL
, ih_rb_cntl
);
7288 WREG32(IH_CNTL
, ih_cntl
);
7289 /* set rptr, wptr to 0 */
7290 WREG32(IH_RB_RPTR
, 0);
7291 WREG32(IH_RB_WPTR
, 0);
7292 rdev
->ih
.enabled
= false;
7297 * cik_disable_interrupt_state - Disable all interrupt sources
7299 * @rdev: radeon_device pointer
7301 * Clear all interrupt enable bits used by the driver (CIK).
7303 static void cik_disable_interrupt_state(struct radeon_device
*rdev
)
7308 tmp
= RREG32(CP_INT_CNTL_RING0
) &
7309 (CNTX_BUSY_INT_ENABLE
| CNTX_EMPTY_INT_ENABLE
);
7310 WREG32(CP_INT_CNTL_RING0
, tmp
);
7312 tmp
= RREG32(SDMA0_CNTL
+ SDMA0_REGISTER_OFFSET
) & ~TRAP_ENABLE
;
7313 WREG32(SDMA0_CNTL
+ SDMA0_REGISTER_OFFSET
, tmp
);
7314 tmp
= RREG32(SDMA0_CNTL
+ SDMA1_REGISTER_OFFSET
) & ~TRAP_ENABLE
;
7315 WREG32(SDMA0_CNTL
+ SDMA1_REGISTER_OFFSET
, tmp
);
7316 /* compute queues */
7317 WREG32(CP_ME1_PIPE0_INT_CNTL
, 0);
7318 WREG32(CP_ME1_PIPE1_INT_CNTL
, 0);
7319 WREG32(CP_ME1_PIPE2_INT_CNTL
, 0);
7320 WREG32(CP_ME1_PIPE3_INT_CNTL
, 0);
7321 WREG32(CP_ME2_PIPE0_INT_CNTL
, 0);
7322 WREG32(CP_ME2_PIPE1_INT_CNTL
, 0);
7323 WREG32(CP_ME2_PIPE2_INT_CNTL
, 0);
7324 WREG32(CP_ME2_PIPE3_INT_CNTL
, 0);
7326 WREG32(GRBM_INT_CNTL
, 0);
7328 WREG32(SRBM_INT_CNTL
, 0);
7329 /* vline/vblank, etc. */
7330 WREG32(LB_INTERRUPT_MASK
+ EVERGREEN_CRTC0_REGISTER_OFFSET
, 0);
7331 WREG32(LB_INTERRUPT_MASK
+ EVERGREEN_CRTC1_REGISTER_OFFSET
, 0);
7332 if (rdev
->num_crtc
>= 4) {
7333 WREG32(LB_INTERRUPT_MASK
+ EVERGREEN_CRTC2_REGISTER_OFFSET
, 0);
7334 WREG32(LB_INTERRUPT_MASK
+ EVERGREEN_CRTC3_REGISTER_OFFSET
, 0);
7336 if (rdev
->num_crtc
>= 6) {
7337 WREG32(LB_INTERRUPT_MASK
+ EVERGREEN_CRTC4_REGISTER_OFFSET
, 0);
7338 WREG32(LB_INTERRUPT_MASK
+ EVERGREEN_CRTC5_REGISTER_OFFSET
, 0);
7341 if (rdev
->num_crtc
>= 2) {
7342 WREG32(GRPH_INT_CONTROL
+ EVERGREEN_CRTC0_REGISTER_OFFSET
, 0);
7343 WREG32(GRPH_INT_CONTROL
+ EVERGREEN_CRTC1_REGISTER_OFFSET
, 0);
7345 if (rdev
->num_crtc
>= 4) {
7346 WREG32(GRPH_INT_CONTROL
+ EVERGREEN_CRTC2_REGISTER_OFFSET
, 0);
7347 WREG32(GRPH_INT_CONTROL
+ EVERGREEN_CRTC3_REGISTER_OFFSET
, 0);
7349 if (rdev
->num_crtc
>= 6) {
7350 WREG32(GRPH_INT_CONTROL
+ EVERGREEN_CRTC4_REGISTER_OFFSET
, 0);
7351 WREG32(GRPH_INT_CONTROL
+ EVERGREEN_CRTC5_REGISTER_OFFSET
, 0);
7355 WREG32(DAC_AUTODETECT_INT_CONTROL
, 0);
7357 /* digital hotplug */
7358 tmp
= RREG32(DC_HPD1_INT_CONTROL
) & DC_HPDx_INT_POLARITY
;
7359 WREG32(DC_HPD1_INT_CONTROL
, tmp
);
7360 tmp
= RREG32(DC_HPD2_INT_CONTROL
) & DC_HPDx_INT_POLARITY
;
7361 WREG32(DC_HPD2_INT_CONTROL
, tmp
);
7362 tmp
= RREG32(DC_HPD3_INT_CONTROL
) & DC_HPDx_INT_POLARITY
;
7363 WREG32(DC_HPD3_INT_CONTROL
, tmp
);
7364 tmp
= RREG32(DC_HPD4_INT_CONTROL
) & DC_HPDx_INT_POLARITY
;
7365 WREG32(DC_HPD4_INT_CONTROL
, tmp
);
7366 tmp
= RREG32(DC_HPD5_INT_CONTROL
) & DC_HPDx_INT_POLARITY
;
7367 WREG32(DC_HPD5_INT_CONTROL
, tmp
);
7368 tmp
= RREG32(DC_HPD6_INT_CONTROL
) & DC_HPDx_INT_POLARITY
;
7369 WREG32(DC_HPD6_INT_CONTROL
, tmp
);
7374 * cik_irq_init - init and enable the interrupt ring
7376 * @rdev: radeon_device pointer
7378 * Allocate a ring buffer for the interrupt controller,
7379 * enable the RLC, disable interrupts, enable the IH
7380 * ring buffer and enable it (CIK).
7381 * Called at device load and reume.
7382 * Returns 0 for success, errors for failure.
7384 static int cik_irq_init(struct radeon_device
*rdev
)
7388 u32 interrupt_cntl
, ih_cntl
, ih_rb_cntl
;
7391 ret
= r600_ih_ring_alloc(rdev
);
7396 cik_disable_interrupts(rdev
);
7399 ret
= cik_rlc_resume(rdev
);
7401 r600_ih_ring_fini(rdev
);
7405 /* setup interrupt control */
7406 /* XXX this should actually be a bus address, not an MC address. same on older asics */
7407 WREG32(INTERRUPT_CNTL2
, rdev
->ih
.gpu_addr
>> 8);
7408 interrupt_cntl
= RREG32(INTERRUPT_CNTL
);
7409 /* IH_DUMMY_RD_OVERRIDE=0 - dummy read disabled with msi, enabled without msi
7410 * IH_DUMMY_RD_OVERRIDE=1 - dummy read controlled by IH_DUMMY_RD_EN
7412 interrupt_cntl
&= ~IH_DUMMY_RD_OVERRIDE
;
7413 /* IH_REQ_NONSNOOP_EN=1 if ring is in non-cacheable memory, e.g., vram */
7414 interrupt_cntl
&= ~IH_REQ_NONSNOOP_EN
;
7415 WREG32(INTERRUPT_CNTL
, interrupt_cntl
);
7417 WREG32(IH_RB_BASE
, rdev
->ih
.gpu_addr
>> 8);
7418 rb_bufsz
= order_base_2(rdev
->ih
.ring_size
/ 4);
7420 ih_rb_cntl
= (IH_WPTR_OVERFLOW_ENABLE
|
7421 IH_WPTR_OVERFLOW_CLEAR
|
7424 if (rdev
->wb
.enabled
)
7425 ih_rb_cntl
|= IH_WPTR_WRITEBACK_ENABLE
;
7427 /* set the writeback address whether it's enabled or not */
7428 WREG32(IH_RB_WPTR_ADDR_LO
, (rdev
->wb
.gpu_addr
+ R600_WB_IH_WPTR_OFFSET
) & 0xFFFFFFFC);
7429 WREG32(IH_RB_WPTR_ADDR_HI
, upper_32_bits(rdev
->wb
.gpu_addr
+ R600_WB_IH_WPTR_OFFSET
) & 0xFF);
7431 WREG32(IH_RB_CNTL
, ih_rb_cntl
);
7433 /* set rptr, wptr to 0 */
7434 WREG32(IH_RB_RPTR
, 0);
7435 WREG32(IH_RB_WPTR
, 0);
7437 /* Default settings for IH_CNTL (disabled at first) */
7438 ih_cntl
= MC_WRREQ_CREDIT(0x10) | MC_WR_CLEAN_CNT(0x10) | MC_VMID(0);
7439 /* RPTR_REARM only works if msi's are enabled */
7440 if (rdev
->msi_enabled
)
7441 ih_cntl
|= RPTR_REARM
;
7442 WREG32(IH_CNTL
, ih_cntl
);
7444 /* force the active interrupt state to all disabled */
7445 cik_disable_interrupt_state(rdev
);
7447 pci_set_master(rdev
->pdev
);
7450 cik_enable_interrupts(rdev
);
7456 * cik_irq_set - enable/disable interrupt sources
7458 * @rdev: radeon_device pointer
7460 * Enable interrupt sources on the GPU (vblanks, hpd,
7462 * Returns 0 for success, errors for failure.
7464 int cik_irq_set(struct radeon_device
*rdev
)
7468 u32 crtc1
= 0, crtc2
= 0, crtc3
= 0, crtc4
= 0, crtc5
= 0, crtc6
= 0;
7469 u32 hpd1
, hpd2
, hpd3
, hpd4
, hpd5
, hpd6
;
7470 u32 grbm_int_cntl
= 0;
7471 u32 dma_cntl
, dma_cntl1
;
7473 if (!rdev
->irq
.installed
) {
7474 WARN(1, "Can't enable IRQ/MSI because no handler is installed\n");
7477 /* don't enable anything if the ih is disabled */
7478 if (!rdev
->ih
.enabled
) {
7479 cik_disable_interrupts(rdev
);
7480 /* force the active interrupt state to all disabled */
7481 cik_disable_interrupt_state(rdev
);
7485 cp_int_cntl
= RREG32(CP_INT_CNTL_RING0
) &
7486 (CNTX_BUSY_INT_ENABLE
| CNTX_EMPTY_INT_ENABLE
);
7487 cp_int_cntl
|= PRIV_INSTR_INT_ENABLE
| PRIV_REG_INT_ENABLE
;
7489 hpd1
= RREG32(DC_HPD1_INT_CONTROL
) & ~(DC_HPDx_INT_EN
| DC_HPDx_RX_INT_EN
);
7490 hpd2
= RREG32(DC_HPD2_INT_CONTROL
) & ~(DC_HPDx_INT_EN
| DC_HPDx_RX_INT_EN
);
7491 hpd3
= RREG32(DC_HPD3_INT_CONTROL
) & ~(DC_HPDx_INT_EN
| DC_HPDx_RX_INT_EN
);
7492 hpd4
= RREG32(DC_HPD4_INT_CONTROL
) & ~(DC_HPDx_INT_EN
| DC_HPDx_RX_INT_EN
);
7493 hpd5
= RREG32(DC_HPD5_INT_CONTROL
) & ~(DC_HPDx_INT_EN
| DC_HPDx_RX_INT_EN
);
7494 hpd6
= RREG32(DC_HPD6_INT_CONTROL
) & ~(DC_HPDx_INT_EN
| DC_HPDx_RX_INT_EN
);
7496 dma_cntl
= RREG32(SDMA0_CNTL
+ SDMA0_REGISTER_OFFSET
) & ~TRAP_ENABLE
;
7497 dma_cntl1
= RREG32(SDMA0_CNTL
+ SDMA1_REGISTER_OFFSET
) & ~TRAP_ENABLE
;
7499 cp_m1p0
= RREG32(CP_ME1_PIPE0_INT_CNTL
) & ~TIME_STAMP_INT_ENABLE
;
7501 /* enable CP interrupts on all rings */
7502 if (atomic_read(&rdev
->irq
.ring_int
[RADEON_RING_TYPE_GFX_INDEX
])) {
7503 DRM_DEBUG("cik_irq_set: sw int gfx\n");
7504 cp_int_cntl
|= TIME_STAMP_INT_ENABLE
;
7506 if (atomic_read(&rdev
->irq
.ring_int
[CAYMAN_RING_TYPE_CP1_INDEX
])) {
7507 struct radeon_ring
*ring
= &rdev
->ring
[CAYMAN_RING_TYPE_CP1_INDEX
];
7508 DRM_DEBUG("si_irq_set: sw int cp1\n");
7509 if (ring
->me
== 1) {
7510 switch (ring
->pipe
) {
7512 cp_m1p0
|= TIME_STAMP_INT_ENABLE
;
7515 DRM_DEBUG("si_irq_set: sw int cp1 invalid pipe %d\n", ring
->pipe
);
7519 DRM_DEBUG("si_irq_set: sw int cp1 invalid me %d\n", ring
->me
);
7522 if (atomic_read(&rdev
->irq
.ring_int
[CAYMAN_RING_TYPE_CP2_INDEX
])) {
7523 struct radeon_ring
*ring
= &rdev
->ring
[CAYMAN_RING_TYPE_CP2_INDEX
];
7524 DRM_DEBUG("si_irq_set: sw int cp2\n");
7525 if (ring
->me
== 1) {
7526 switch (ring
->pipe
) {
7528 cp_m1p0
|= TIME_STAMP_INT_ENABLE
;
7531 DRM_DEBUG("si_irq_set: sw int cp2 invalid pipe %d\n", ring
->pipe
);
7535 DRM_DEBUG("si_irq_set: sw int cp2 invalid me %d\n", ring
->me
);
7539 if (atomic_read(&rdev
->irq
.ring_int
[R600_RING_TYPE_DMA_INDEX
])) {
7540 DRM_DEBUG("cik_irq_set: sw int dma\n");
7541 dma_cntl
|= TRAP_ENABLE
;
7544 if (atomic_read(&rdev
->irq
.ring_int
[CAYMAN_RING_TYPE_DMA1_INDEX
])) {
7545 DRM_DEBUG("cik_irq_set: sw int dma1\n");
7546 dma_cntl1
|= TRAP_ENABLE
;
7549 if (rdev
->irq
.crtc_vblank_int
[0] ||
7550 atomic_read(&rdev
->irq
.pflip
[0])) {
7551 DRM_DEBUG("cik_irq_set: vblank 0\n");
7552 crtc1
|= VBLANK_INTERRUPT_MASK
;
7554 if (rdev
->irq
.crtc_vblank_int
[1] ||
7555 atomic_read(&rdev
->irq
.pflip
[1])) {
7556 DRM_DEBUG("cik_irq_set: vblank 1\n");
7557 crtc2
|= VBLANK_INTERRUPT_MASK
;
7559 if (rdev
->irq
.crtc_vblank_int
[2] ||
7560 atomic_read(&rdev
->irq
.pflip
[2])) {
7561 DRM_DEBUG("cik_irq_set: vblank 2\n");
7562 crtc3
|= VBLANK_INTERRUPT_MASK
;
7564 if (rdev
->irq
.crtc_vblank_int
[3] ||
7565 atomic_read(&rdev
->irq
.pflip
[3])) {
7566 DRM_DEBUG("cik_irq_set: vblank 3\n");
7567 crtc4
|= VBLANK_INTERRUPT_MASK
;
7569 if (rdev
->irq
.crtc_vblank_int
[4] ||
7570 atomic_read(&rdev
->irq
.pflip
[4])) {
7571 DRM_DEBUG("cik_irq_set: vblank 4\n");
7572 crtc5
|= VBLANK_INTERRUPT_MASK
;
7574 if (rdev
->irq
.crtc_vblank_int
[5] ||
7575 atomic_read(&rdev
->irq
.pflip
[5])) {
7576 DRM_DEBUG("cik_irq_set: vblank 5\n");
7577 crtc6
|= VBLANK_INTERRUPT_MASK
;
7579 if (rdev
->irq
.hpd
[0]) {
7580 DRM_DEBUG("cik_irq_set: hpd 1\n");
7581 hpd1
|= DC_HPDx_INT_EN
| DC_HPDx_RX_INT_EN
;
7583 if (rdev
->irq
.hpd
[1]) {
7584 DRM_DEBUG("cik_irq_set: hpd 2\n");
7585 hpd2
|= DC_HPDx_INT_EN
| DC_HPDx_RX_INT_EN
;
7587 if (rdev
->irq
.hpd
[2]) {
7588 DRM_DEBUG("cik_irq_set: hpd 3\n");
7589 hpd3
|= DC_HPDx_INT_EN
| DC_HPDx_RX_INT_EN
;
7591 if (rdev
->irq
.hpd
[3]) {
7592 DRM_DEBUG("cik_irq_set: hpd 4\n");
7593 hpd4
|= DC_HPDx_INT_EN
| DC_HPDx_RX_INT_EN
;
7595 if (rdev
->irq
.hpd
[4]) {
7596 DRM_DEBUG("cik_irq_set: hpd 5\n");
7597 hpd5
|= DC_HPDx_INT_EN
| DC_HPDx_RX_INT_EN
;
7599 if (rdev
->irq
.hpd
[5]) {
7600 DRM_DEBUG("cik_irq_set: hpd 6\n");
7601 hpd6
|= DC_HPDx_INT_EN
| DC_HPDx_RX_INT_EN
;
7604 WREG32(CP_INT_CNTL_RING0
, cp_int_cntl
);
7606 WREG32(SDMA0_CNTL
+ SDMA0_REGISTER_OFFSET
, dma_cntl
);
7607 WREG32(SDMA0_CNTL
+ SDMA1_REGISTER_OFFSET
, dma_cntl1
);
7609 WREG32(CP_ME1_PIPE0_INT_CNTL
, cp_m1p0
);
7611 WREG32(GRBM_INT_CNTL
, grbm_int_cntl
);
7613 WREG32(LB_INTERRUPT_MASK
+ EVERGREEN_CRTC0_REGISTER_OFFSET
, crtc1
);
7614 WREG32(LB_INTERRUPT_MASK
+ EVERGREEN_CRTC1_REGISTER_OFFSET
, crtc2
);
7615 if (rdev
->num_crtc
>= 4) {
7616 WREG32(LB_INTERRUPT_MASK
+ EVERGREEN_CRTC2_REGISTER_OFFSET
, crtc3
);
7617 WREG32(LB_INTERRUPT_MASK
+ EVERGREEN_CRTC3_REGISTER_OFFSET
, crtc4
);
7619 if (rdev
->num_crtc
>= 6) {
7620 WREG32(LB_INTERRUPT_MASK
+ EVERGREEN_CRTC4_REGISTER_OFFSET
, crtc5
);
7621 WREG32(LB_INTERRUPT_MASK
+ EVERGREEN_CRTC5_REGISTER_OFFSET
, crtc6
);
7624 if (rdev
->num_crtc
>= 2) {
7625 WREG32(GRPH_INT_CONTROL
+ EVERGREEN_CRTC0_REGISTER_OFFSET
,
7626 GRPH_PFLIP_INT_MASK
);
7627 WREG32(GRPH_INT_CONTROL
+ EVERGREEN_CRTC1_REGISTER_OFFSET
,
7628 GRPH_PFLIP_INT_MASK
);
7630 if (rdev
->num_crtc
>= 4) {
7631 WREG32(GRPH_INT_CONTROL
+ EVERGREEN_CRTC2_REGISTER_OFFSET
,
7632 GRPH_PFLIP_INT_MASK
);
7633 WREG32(GRPH_INT_CONTROL
+ EVERGREEN_CRTC3_REGISTER_OFFSET
,
7634 GRPH_PFLIP_INT_MASK
);
7636 if (rdev
->num_crtc
>= 6) {
7637 WREG32(GRPH_INT_CONTROL
+ EVERGREEN_CRTC4_REGISTER_OFFSET
,
7638 GRPH_PFLIP_INT_MASK
);
7639 WREG32(GRPH_INT_CONTROL
+ EVERGREEN_CRTC5_REGISTER_OFFSET
,
7640 GRPH_PFLIP_INT_MASK
);
7643 WREG32(DC_HPD1_INT_CONTROL
, hpd1
);
7644 WREG32(DC_HPD2_INT_CONTROL
, hpd2
);
7645 WREG32(DC_HPD3_INT_CONTROL
, hpd3
);
7646 WREG32(DC_HPD4_INT_CONTROL
, hpd4
);
7647 WREG32(DC_HPD5_INT_CONTROL
, hpd5
);
7648 WREG32(DC_HPD6_INT_CONTROL
, hpd6
);
7651 RREG32(SRBM_STATUS
);
7657 * cik_irq_ack - ack interrupt sources
7659 * @rdev: radeon_device pointer
7661 * Ack interrupt sources on the GPU (vblanks, hpd,
7662 * etc.) (CIK). Certain interrupts sources are sw
7663 * generated and do not require an explicit ack.
7665 static inline void cik_irq_ack(struct radeon_device
*rdev
)
7669 rdev
->irq
.stat_regs
.cik
.disp_int
= RREG32(DISP_INTERRUPT_STATUS
);
7670 rdev
->irq
.stat_regs
.cik
.disp_int_cont
= RREG32(DISP_INTERRUPT_STATUS_CONTINUE
);
7671 rdev
->irq
.stat_regs
.cik
.disp_int_cont2
= RREG32(DISP_INTERRUPT_STATUS_CONTINUE2
);
7672 rdev
->irq
.stat_regs
.cik
.disp_int_cont3
= RREG32(DISP_INTERRUPT_STATUS_CONTINUE3
);
7673 rdev
->irq
.stat_regs
.cik
.disp_int_cont4
= RREG32(DISP_INTERRUPT_STATUS_CONTINUE4
);
7674 rdev
->irq
.stat_regs
.cik
.disp_int_cont5
= RREG32(DISP_INTERRUPT_STATUS_CONTINUE5
);
7675 rdev
->irq
.stat_regs
.cik
.disp_int_cont6
= RREG32(DISP_INTERRUPT_STATUS_CONTINUE6
);
7677 rdev
->irq
.stat_regs
.cik
.d1grph_int
= RREG32(GRPH_INT_STATUS
+
7678 EVERGREEN_CRTC0_REGISTER_OFFSET
);
7679 rdev
->irq
.stat_regs
.cik
.d2grph_int
= RREG32(GRPH_INT_STATUS
+
7680 EVERGREEN_CRTC1_REGISTER_OFFSET
);
7681 if (rdev
->num_crtc
>= 4) {
7682 rdev
->irq
.stat_regs
.cik
.d3grph_int
= RREG32(GRPH_INT_STATUS
+
7683 EVERGREEN_CRTC2_REGISTER_OFFSET
);
7684 rdev
->irq
.stat_regs
.cik
.d4grph_int
= RREG32(GRPH_INT_STATUS
+
7685 EVERGREEN_CRTC3_REGISTER_OFFSET
);
7687 if (rdev
->num_crtc
>= 6) {
7688 rdev
->irq
.stat_regs
.cik
.d5grph_int
= RREG32(GRPH_INT_STATUS
+
7689 EVERGREEN_CRTC4_REGISTER_OFFSET
);
7690 rdev
->irq
.stat_regs
.cik
.d6grph_int
= RREG32(GRPH_INT_STATUS
+
7691 EVERGREEN_CRTC5_REGISTER_OFFSET
);
7694 if (rdev
->irq
.stat_regs
.cik
.d1grph_int
& GRPH_PFLIP_INT_OCCURRED
)
7695 WREG32(GRPH_INT_STATUS
+ EVERGREEN_CRTC0_REGISTER_OFFSET
,
7696 GRPH_PFLIP_INT_CLEAR
);
7697 if (rdev
->irq
.stat_regs
.cik
.d2grph_int
& GRPH_PFLIP_INT_OCCURRED
)
7698 WREG32(GRPH_INT_STATUS
+ EVERGREEN_CRTC1_REGISTER_OFFSET
,
7699 GRPH_PFLIP_INT_CLEAR
);
7700 if (rdev
->irq
.stat_regs
.cik
.disp_int
& LB_D1_VBLANK_INTERRUPT
)
7701 WREG32(LB_VBLANK_STATUS
+ EVERGREEN_CRTC0_REGISTER_OFFSET
, VBLANK_ACK
);
7702 if (rdev
->irq
.stat_regs
.cik
.disp_int
& LB_D1_VLINE_INTERRUPT
)
7703 WREG32(LB_VLINE_STATUS
+ EVERGREEN_CRTC0_REGISTER_OFFSET
, VLINE_ACK
);
7704 if (rdev
->irq
.stat_regs
.cik
.disp_int_cont
& LB_D2_VBLANK_INTERRUPT
)
7705 WREG32(LB_VBLANK_STATUS
+ EVERGREEN_CRTC1_REGISTER_OFFSET
, VBLANK_ACK
);
7706 if (rdev
->irq
.stat_regs
.cik
.disp_int_cont
& LB_D2_VLINE_INTERRUPT
)
7707 WREG32(LB_VLINE_STATUS
+ EVERGREEN_CRTC1_REGISTER_OFFSET
, VLINE_ACK
);
7709 if (rdev
->num_crtc
>= 4) {
7710 if (rdev
->irq
.stat_regs
.cik
.d3grph_int
& GRPH_PFLIP_INT_OCCURRED
)
7711 WREG32(GRPH_INT_STATUS
+ EVERGREEN_CRTC2_REGISTER_OFFSET
,
7712 GRPH_PFLIP_INT_CLEAR
);
7713 if (rdev
->irq
.stat_regs
.cik
.d4grph_int
& GRPH_PFLIP_INT_OCCURRED
)
7714 WREG32(GRPH_INT_STATUS
+ EVERGREEN_CRTC3_REGISTER_OFFSET
,
7715 GRPH_PFLIP_INT_CLEAR
);
7716 if (rdev
->irq
.stat_regs
.cik
.disp_int_cont2
& LB_D3_VBLANK_INTERRUPT
)
7717 WREG32(LB_VBLANK_STATUS
+ EVERGREEN_CRTC2_REGISTER_OFFSET
, VBLANK_ACK
);
7718 if (rdev
->irq
.stat_regs
.cik
.disp_int_cont2
& LB_D3_VLINE_INTERRUPT
)
7719 WREG32(LB_VLINE_STATUS
+ EVERGREEN_CRTC2_REGISTER_OFFSET
, VLINE_ACK
);
7720 if (rdev
->irq
.stat_regs
.cik
.disp_int_cont3
& LB_D4_VBLANK_INTERRUPT
)
7721 WREG32(LB_VBLANK_STATUS
+ EVERGREEN_CRTC3_REGISTER_OFFSET
, VBLANK_ACK
);
7722 if (rdev
->irq
.stat_regs
.cik
.disp_int_cont3
& LB_D4_VLINE_INTERRUPT
)
7723 WREG32(LB_VLINE_STATUS
+ EVERGREEN_CRTC3_REGISTER_OFFSET
, VLINE_ACK
);
7726 if (rdev
->num_crtc
>= 6) {
7727 if (rdev
->irq
.stat_regs
.cik
.d5grph_int
& GRPH_PFLIP_INT_OCCURRED
)
7728 WREG32(GRPH_INT_STATUS
+ EVERGREEN_CRTC4_REGISTER_OFFSET
,
7729 GRPH_PFLIP_INT_CLEAR
);
7730 if (rdev
->irq
.stat_regs
.cik
.d6grph_int
& GRPH_PFLIP_INT_OCCURRED
)
7731 WREG32(GRPH_INT_STATUS
+ EVERGREEN_CRTC5_REGISTER_OFFSET
,
7732 GRPH_PFLIP_INT_CLEAR
);
7733 if (rdev
->irq
.stat_regs
.cik
.disp_int_cont4
& LB_D5_VBLANK_INTERRUPT
)
7734 WREG32(LB_VBLANK_STATUS
+ EVERGREEN_CRTC4_REGISTER_OFFSET
, VBLANK_ACK
);
7735 if (rdev
->irq
.stat_regs
.cik
.disp_int_cont4
& LB_D5_VLINE_INTERRUPT
)
7736 WREG32(LB_VLINE_STATUS
+ EVERGREEN_CRTC4_REGISTER_OFFSET
, VLINE_ACK
);
7737 if (rdev
->irq
.stat_regs
.cik
.disp_int_cont5
& LB_D6_VBLANK_INTERRUPT
)
7738 WREG32(LB_VBLANK_STATUS
+ EVERGREEN_CRTC5_REGISTER_OFFSET
, VBLANK_ACK
);
7739 if (rdev
->irq
.stat_regs
.cik
.disp_int_cont5
& LB_D6_VLINE_INTERRUPT
)
7740 WREG32(LB_VLINE_STATUS
+ EVERGREEN_CRTC5_REGISTER_OFFSET
, VLINE_ACK
);
7743 if (rdev
->irq
.stat_regs
.cik
.disp_int
& DC_HPD1_INTERRUPT
) {
7744 tmp
= RREG32(DC_HPD1_INT_CONTROL
);
7745 tmp
|= DC_HPDx_INT_ACK
;
7746 WREG32(DC_HPD1_INT_CONTROL
, tmp
);
7748 if (rdev
->irq
.stat_regs
.cik
.disp_int_cont
& DC_HPD2_INTERRUPT
) {
7749 tmp
= RREG32(DC_HPD2_INT_CONTROL
);
7750 tmp
|= DC_HPDx_INT_ACK
;
7751 WREG32(DC_HPD2_INT_CONTROL
, tmp
);
7753 if (rdev
->irq
.stat_regs
.cik
.disp_int_cont2
& DC_HPD3_INTERRUPT
) {
7754 tmp
= RREG32(DC_HPD3_INT_CONTROL
);
7755 tmp
|= DC_HPDx_INT_ACK
;
7756 WREG32(DC_HPD3_INT_CONTROL
, tmp
);
7758 if (rdev
->irq
.stat_regs
.cik
.disp_int_cont3
& DC_HPD4_INTERRUPT
) {
7759 tmp
= RREG32(DC_HPD4_INT_CONTROL
);
7760 tmp
|= DC_HPDx_INT_ACK
;
7761 WREG32(DC_HPD4_INT_CONTROL
, tmp
);
7763 if (rdev
->irq
.stat_regs
.cik
.disp_int_cont4
& DC_HPD5_INTERRUPT
) {
7764 tmp
= RREG32(DC_HPD5_INT_CONTROL
);
7765 tmp
|= DC_HPDx_INT_ACK
;
7766 WREG32(DC_HPD5_INT_CONTROL
, tmp
);
7768 if (rdev
->irq
.stat_regs
.cik
.disp_int_cont5
& DC_HPD6_INTERRUPT
) {
7769 tmp
= RREG32(DC_HPD5_INT_CONTROL
);
7770 tmp
|= DC_HPDx_INT_ACK
;
7771 WREG32(DC_HPD6_INT_CONTROL
, tmp
);
7773 if (rdev
->irq
.stat_regs
.cik
.disp_int
& DC_HPD1_RX_INTERRUPT
) {
7774 tmp
= RREG32(DC_HPD1_INT_CONTROL
);
7775 tmp
|= DC_HPDx_RX_INT_ACK
;
7776 WREG32(DC_HPD1_INT_CONTROL
, tmp
);
7778 if (rdev
->irq
.stat_regs
.cik
.disp_int_cont
& DC_HPD2_RX_INTERRUPT
) {
7779 tmp
= RREG32(DC_HPD2_INT_CONTROL
);
7780 tmp
|= DC_HPDx_RX_INT_ACK
;
7781 WREG32(DC_HPD2_INT_CONTROL
, tmp
);
7783 if (rdev
->irq
.stat_regs
.cik
.disp_int_cont2
& DC_HPD3_RX_INTERRUPT
) {
7784 tmp
= RREG32(DC_HPD3_INT_CONTROL
);
7785 tmp
|= DC_HPDx_RX_INT_ACK
;
7786 WREG32(DC_HPD3_INT_CONTROL
, tmp
);
7788 if (rdev
->irq
.stat_regs
.cik
.disp_int_cont3
& DC_HPD4_RX_INTERRUPT
) {
7789 tmp
= RREG32(DC_HPD4_INT_CONTROL
);
7790 tmp
|= DC_HPDx_RX_INT_ACK
;
7791 WREG32(DC_HPD4_INT_CONTROL
, tmp
);
7793 if (rdev
->irq
.stat_regs
.cik
.disp_int_cont4
& DC_HPD5_RX_INTERRUPT
) {
7794 tmp
= RREG32(DC_HPD5_INT_CONTROL
);
7795 tmp
|= DC_HPDx_RX_INT_ACK
;
7796 WREG32(DC_HPD5_INT_CONTROL
, tmp
);
7798 if (rdev
->irq
.stat_regs
.cik
.disp_int_cont5
& DC_HPD6_RX_INTERRUPT
) {
7799 tmp
= RREG32(DC_HPD5_INT_CONTROL
);
7800 tmp
|= DC_HPDx_RX_INT_ACK
;
7801 WREG32(DC_HPD6_INT_CONTROL
, tmp
);
7806 * cik_irq_disable - disable interrupts
7808 * @rdev: radeon_device pointer
7810 * Disable interrupts on the hw (CIK).
7812 static void cik_irq_disable(struct radeon_device
*rdev
)
7814 cik_disable_interrupts(rdev
);
7815 /* Wait and acknowledge irq */
7818 cik_disable_interrupt_state(rdev
);
7822 * cik_irq_disable - disable interrupts for suspend
7824 * @rdev: radeon_device pointer
7826 * Disable interrupts and stop the RLC (CIK).
7829 static void cik_irq_suspend(struct radeon_device
*rdev
)
7831 cik_irq_disable(rdev
);
7836 * cik_irq_fini - tear down interrupt support
7838 * @rdev: radeon_device pointer
7840 * Disable interrupts on the hw and free the IH ring
7842 * Used for driver unload.
7844 static void cik_irq_fini(struct radeon_device
*rdev
)
7846 cik_irq_suspend(rdev
);
7847 r600_ih_ring_fini(rdev
);
7851 * cik_get_ih_wptr - get the IH ring buffer wptr
7853 * @rdev: radeon_device pointer
7855 * Get the IH ring buffer wptr from either the register
7856 * or the writeback memory buffer (CIK). Also check for
7857 * ring buffer overflow and deal with it.
7858 * Used by cik_irq_process().
7859 * Returns the value of the wptr.
7861 static inline u32
cik_get_ih_wptr(struct radeon_device
*rdev
)
7865 if (rdev
->wb
.enabled
)
7866 wptr
= le32_to_cpu(rdev
->wb
.wb
[R600_WB_IH_WPTR_OFFSET
/4]);
7868 wptr
= RREG32(IH_RB_WPTR
);
7870 if (wptr
& RB_OVERFLOW
) {
7871 wptr
&= ~RB_OVERFLOW
;
7872 /* When a ring buffer overflow happen start parsing interrupt
7873 * from the last not overwritten vector (wptr + 16). Hopefully
7874 * this should allow us to catchup.
7876 dev_warn(rdev
->dev
, "IH ring buffer overflow (0x%08X, 0x%08X, 0x%08X)\n",
7877 wptr
, rdev
->ih
.rptr
, (wptr
+ 16) & rdev
->ih
.ptr_mask
);
7878 rdev
->ih
.rptr
= (wptr
+ 16) & rdev
->ih
.ptr_mask
;
7879 tmp
= RREG32(IH_RB_CNTL
);
7880 tmp
|= IH_WPTR_OVERFLOW_CLEAR
;
7881 WREG32(IH_RB_CNTL
, tmp
);
7883 return (wptr
& rdev
->ih
.ptr_mask
);
7887 * Each IV ring entry is 128 bits:
7888 * [7:0] - interrupt source id
7890 * [59:32] - interrupt source data
7891 * [63:60] - reserved
7894 * ME_ID [1:0], PIPE_ID[1:0], QUEUE_ID[2:0]
7895 * QUEUE_ID - for compute, which of the 8 queues owned by the dispatcher
7896 * - for gfx, hw shader state (0=PS...5=LS, 6=CS)
7897 * ME_ID - 0 = gfx, 1 = first 4 CS pipes, 2 = second 4 CS pipes
7898 * PIPE_ID - ME0 0=3D
7899 * - ME1&2 compute dispatcher (4 pipes each)
7901 * INSTANCE_ID [1:0], QUEUE_ID[1:0]
7902 * INSTANCE_ID - 0 = sdma0, 1 = sdma1
7903 * QUEUE_ID - 0 = gfx, 1 = rlc0, 2 = rlc1
7906 * [127:96] - reserved
7909 * cik_irq_process - interrupt handler
7911 * @rdev: radeon_device pointer
7913 * Interrupt hander (CIK). Walk the IH ring,
7914 * ack interrupts and schedule work to handle
7916 * Returns irq process return code.
7918 int cik_irq_process(struct radeon_device
*rdev
)
7920 struct radeon_ring
*cp1_ring
= &rdev
->ring
[CAYMAN_RING_TYPE_CP1_INDEX
];
7921 struct radeon_ring
*cp2_ring
= &rdev
->ring
[CAYMAN_RING_TYPE_CP2_INDEX
];
7924 u32 src_id
, src_data
, ring_id
;
7925 u8 me_id
, pipe_id
, queue_id
;
7927 bool queue_hotplug
= false;
7928 bool queue_dp
= false;
7929 bool queue_reset
= false;
7930 u32 addr
, status
, mc_client
;
7931 bool queue_thermal
= false;
7933 if (!rdev
->ih
.enabled
|| rdev
->shutdown
)
7936 wptr
= cik_get_ih_wptr(rdev
);
7939 /* is somebody else already processing irqs? */
7940 if (atomic_xchg(&rdev
->ih
.lock
, 1))
7943 rptr
= rdev
->ih
.rptr
;
7944 DRM_DEBUG("cik_irq_process start: rptr %d, wptr %d\n", rptr
, wptr
);
7946 /* Order reading of wptr vs. reading of IH ring data */
7949 /* display interrupts */
7952 while (rptr
!= wptr
) {
7953 /* wptr/rptr are in bytes! */
7954 ring_index
= rptr
/ 4;
7956 radeon_kfd_interrupt(rdev
,
7957 (const void *) &rdev
->ih
.ring
[ring_index
]);
7959 src_id
= le32_to_cpu(rdev
->ih
.ring
[ring_index
]) & 0xff;
7960 src_data
= le32_to_cpu(rdev
->ih
.ring
[ring_index
+ 1]) & 0xfffffff;
7961 ring_id
= le32_to_cpu(rdev
->ih
.ring
[ring_index
+ 2]) & 0xff;
7964 case 1: /* D1 vblank/vline */
7966 case 0: /* D1 vblank */
7967 if (!(rdev
->irq
.stat_regs
.cik
.disp_int
& LB_D1_VBLANK_INTERRUPT
))
7968 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
7970 if (rdev
->irq
.crtc_vblank_int
[0]) {
7971 drm_handle_vblank(rdev
->ddev
, 0);
7972 rdev
->pm
.vblank_sync
= true;
7973 wake_up(&rdev
->irq
.vblank_queue
);
7975 if (atomic_read(&rdev
->irq
.pflip
[0]))
7976 radeon_crtc_handle_vblank(rdev
, 0);
7977 rdev
->irq
.stat_regs
.cik
.disp_int
&= ~LB_D1_VBLANK_INTERRUPT
;
7978 DRM_DEBUG("IH: D1 vblank\n");
7981 case 1: /* D1 vline */
7982 if (!(rdev
->irq
.stat_regs
.cik
.disp_int
& LB_D1_VLINE_INTERRUPT
))
7983 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
7985 rdev
->irq
.stat_regs
.cik
.disp_int
&= ~LB_D1_VLINE_INTERRUPT
;
7986 DRM_DEBUG("IH: D1 vline\n");
7990 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id
, src_data
);
7994 case 2: /* D2 vblank/vline */
7996 case 0: /* D2 vblank */
7997 if (!(rdev
->irq
.stat_regs
.cik
.disp_int_cont
& LB_D2_VBLANK_INTERRUPT
))
7998 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
8000 if (rdev
->irq
.crtc_vblank_int
[1]) {
8001 drm_handle_vblank(rdev
->ddev
, 1);
8002 rdev
->pm
.vblank_sync
= true;
8003 wake_up(&rdev
->irq
.vblank_queue
);
8005 if (atomic_read(&rdev
->irq
.pflip
[1]))
8006 radeon_crtc_handle_vblank(rdev
, 1);
8007 rdev
->irq
.stat_regs
.cik
.disp_int_cont
&= ~LB_D2_VBLANK_INTERRUPT
;
8008 DRM_DEBUG("IH: D2 vblank\n");
8011 case 1: /* D2 vline */
8012 if (!(rdev
->irq
.stat_regs
.cik
.disp_int_cont
& LB_D2_VLINE_INTERRUPT
))
8013 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
8015 rdev
->irq
.stat_regs
.cik
.disp_int_cont
&= ~LB_D2_VLINE_INTERRUPT
;
8016 DRM_DEBUG("IH: D2 vline\n");
8020 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id
, src_data
);
8024 case 3: /* D3 vblank/vline */
8026 case 0: /* D3 vblank */
8027 if (!(rdev
->irq
.stat_regs
.cik
.disp_int_cont2
& LB_D3_VBLANK_INTERRUPT
))
8028 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
8030 if (rdev
->irq
.crtc_vblank_int
[2]) {
8031 drm_handle_vblank(rdev
->ddev
, 2);
8032 rdev
->pm
.vblank_sync
= true;
8033 wake_up(&rdev
->irq
.vblank_queue
);
8035 if (atomic_read(&rdev
->irq
.pflip
[2]))
8036 radeon_crtc_handle_vblank(rdev
, 2);
8037 rdev
->irq
.stat_regs
.cik
.disp_int_cont2
&= ~LB_D3_VBLANK_INTERRUPT
;
8038 DRM_DEBUG("IH: D3 vblank\n");
8041 case 1: /* D3 vline */
8042 if (!(rdev
->irq
.stat_regs
.cik
.disp_int_cont2
& LB_D3_VLINE_INTERRUPT
))
8043 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
8045 rdev
->irq
.stat_regs
.cik
.disp_int_cont2
&= ~LB_D3_VLINE_INTERRUPT
;
8046 DRM_DEBUG("IH: D3 vline\n");
8050 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id
, src_data
);
8054 case 4: /* D4 vblank/vline */
8056 case 0: /* D4 vblank */
8057 if (!(rdev
->irq
.stat_regs
.cik
.disp_int_cont3
& LB_D4_VBLANK_INTERRUPT
))
8058 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
8060 if (rdev
->irq
.crtc_vblank_int
[3]) {
8061 drm_handle_vblank(rdev
->ddev
, 3);
8062 rdev
->pm
.vblank_sync
= true;
8063 wake_up(&rdev
->irq
.vblank_queue
);
8065 if (atomic_read(&rdev
->irq
.pflip
[3]))
8066 radeon_crtc_handle_vblank(rdev
, 3);
8067 rdev
->irq
.stat_regs
.cik
.disp_int_cont3
&= ~LB_D4_VBLANK_INTERRUPT
;
8068 DRM_DEBUG("IH: D4 vblank\n");
8071 case 1: /* D4 vline */
8072 if (!(rdev
->irq
.stat_regs
.cik
.disp_int_cont3
& LB_D4_VLINE_INTERRUPT
))
8073 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
8075 rdev
->irq
.stat_regs
.cik
.disp_int_cont3
&= ~LB_D4_VLINE_INTERRUPT
;
8076 DRM_DEBUG("IH: D4 vline\n");
8080 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id
, src_data
);
8084 case 5: /* D5 vblank/vline */
8086 case 0: /* D5 vblank */
8087 if (!(rdev
->irq
.stat_regs
.cik
.disp_int_cont4
& LB_D5_VBLANK_INTERRUPT
))
8088 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
8090 if (rdev
->irq
.crtc_vblank_int
[4]) {
8091 drm_handle_vblank(rdev
->ddev
, 4);
8092 rdev
->pm
.vblank_sync
= true;
8093 wake_up(&rdev
->irq
.vblank_queue
);
8095 if (atomic_read(&rdev
->irq
.pflip
[4]))
8096 radeon_crtc_handle_vblank(rdev
, 4);
8097 rdev
->irq
.stat_regs
.cik
.disp_int_cont4
&= ~LB_D5_VBLANK_INTERRUPT
;
8098 DRM_DEBUG("IH: D5 vblank\n");
8101 case 1: /* D5 vline */
8102 if (!(rdev
->irq
.stat_regs
.cik
.disp_int_cont4
& LB_D5_VLINE_INTERRUPT
))
8103 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
8105 rdev
->irq
.stat_regs
.cik
.disp_int_cont4
&= ~LB_D5_VLINE_INTERRUPT
;
8106 DRM_DEBUG("IH: D5 vline\n");
8110 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id
, src_data
);
8114 case 6: /* D6 vblank/vline */
8116 case 0: /* D6 vblank */
8117 if (!(rdev
->irq
.stat_regs
.cik
.disp_int_cont5
& LB_D6_VBLANK_INTERRUPT
))
8118 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
8120 if (rdev
->irq
.crtc_vblank_int
[5]) {
8121 drm_handle_vblank(rdev
->ddev
, 5);
8122 rdev
->pm
.vblank_sync
= true;
8123 wake_up(&rdev
->irq
.vblank_queue
);
8125 if (atomic_read(&rdev
->irq
.pflip
[5]))
8126 radeon_crtc_handle_vblank(rdev
, 5);
8127 rdev
->irq
.stat_regs
.cik
.disp_int_cont5
&= ~LB_D6_VBLANK_INTERRUPT
;
8128 DRM_DEBUG("IH: D6 vblank\n");
8131 case 1: /* D6 vline */
8132 if (!(rdev
->irq
.stat_regs
.cik
.disp_int_cont5
& LB_D6_VLINE_INTERRUPT
))
8133 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
8135 rdev
->irq
.stat_regs
.cik
.disp_int_cont5
&= ~LB_D6_VLINE_INTERRUPT
;
8136 DRM_DEBUG("IH: D6 vline\n");
8140 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id
, src_data
);
8144 case 8: /* D1 page flip */
8145 case 10: /* D2 page flip */
8146 case 12: /* D3 page flip */
8147 case 14: /* D4 page flip */
8148 case 16: /* D5 page flip */
8149 case 18: /* D6 page flip */
8150 DRM_DEBUG("IH: D%d flip\n", ((src_id
- 8) >> 1) + 1);
8151 if (radeon_use_pflipirq
> 0)
8152 radeon_crtc_handle_flip(rdev
, (src_id
- 8) >> 1);
8154 case 42: /* HPD hotplug */
8157 if (!(rdev
->irq
.stat_regs
.cik
.disp_int
& DC_HPD1_INTERRUPT
))
8158 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
8160 rdev
->irq
.stat_regs
.cik
.disp_int
&= ~DC_HPD1_INTERRUPT
;
8161 queue_hotplug
= true;
8162 DRM_DEBUG("IH: HPD1\n");
8166 if (!(rdev
->irq
.stat_regs
.cik
.disp_int_cont
& DC_HPD2_INTERRUPT
))
8167 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
8169 rdev
->irq
.stat_regs
.cik
.disp_int_cont
&= ~DC_HPD2_INTERRUPT
;
8170 queue_hotplug
= true;
8171 DRM_DEBUG("IH: HPD2\n");
8175 if (!(rdev
->irq
.stat_regs
.cik
.disp_int_cont2
& DC_HPD3_INTERRUPT
))
8176 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
8178 rdev
->irq
.stat_regs
.cik
.disp_int_cont2
&= ~DC_HPD3_INTERRUPT
;
8179 queue_hotplug
= true;
8180 DRM_DEBUG("IH: HPD3\n");
8184 if (!(rdev
->irq
.stat_regs
.cik
.disp_int_cont3
& DC_HPD4_INTERRUPT
))
8185 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
8187 rdev
->irq
.stat_regs
.cik
.disp_int_cont3
&= ~DC_HPD4_INTERRUPT
;
8188 queue_hotplug
= true;
8189 DRM_DEBUG("IH: HPD4\n");
8193 if (!(rdev
->irq
.stat_regs
.cik
.disp_int_cont4
& DC_HPD5_INTERRUPT
))
8194 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
8196 rdev
->irq
.stat_regs
.cik
.disp_int_cont4
&= ~DC_HPD5_INTERRUPT
;
8197 queue_hotplug
= true;
8198 DRM_DEBUG("IH: HPD5\n");
8202 if (!(rdev
->irq
.stat_regs
.cik
.disp_int_cont5
& DC_HPD6_INTERRUPT
))
8203 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
8205 rdev
->irq
.stat_regs
.cik
.disp_int_cont5
&= ~DC_HPD6_INTERRUPT
;
8206 queue_hotplug
= true;
8207 DRM_DEBUG("IH: HPD6\n");
8211 if (!(rdev
->irq
.stat_regs
.cik
.disp_int
& DC_HPD1_RX_INTERRUPT
))
8212 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
8214 rdev
->irq
.stat_regs
.cik
.disp_int
&= ~DC_HPD1_RX_INTERRUPT
;
8216 DRM_DEBUG("IH: HPD_RX 1\n");
8220 if (!(rdev
->irq
.stat_regs
.cik
.disp_int_cont
& DC_HPD2_RX_INTERRUPT
))
8221 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
8223 rdev
->irq
.stat_regs
.cik
.disp_int_cont
&= ~DC_HPD2_RX_INTERRUPT
;
8225 DRM_DEBUG("IH: HPD_RX 2\n");
8229 if (!(rdev
->irq
.stat_regs
.cik
.disp_int_cont2
& DC_HPD3_RX_INTERRUPT
))
8230 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
8232 rdev
->irq
.stat_regs
.cik
.disp_int_cont2
&= ~DC_HPD3_RX_INTERRUPT
;
8234 DRM_DEBUG("IH: HPD_RX 3\n");
8238 if (!(rdev
->irq
.stat_regs
.cik
.disp_int_cont3
& DC_HPD4_RX_INTERRUPT
))
8239 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
8241 rdev
->irq
.stat_regs
.cik
.disp_int_cont3
&= ~DC_HPD4_RX_INTERRUPT
;
8243 DRM_DEBUG("IH: HPD_RX 4\n");
8247 if (!(rdev
->irq
.stat_regs
.cik
.disp_int_cont4
& DC_HPD5_RX_INTERRUPT
))
8248 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
8250 rdev
->irq
.stat_regs
.cik
.disp_int_cont4
&= ~DC_HPD5_RX_INTERRUPT
;
8252 DRM_DEBUG("IH: HPD_RX 5\n");
8256 if (!(rdev
->irq
.stat_regs
.cik
.disp_int_cont5
& DC_HPD6_RX_INTERRUPT
))
8257 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
8259 rdev
->irq
.stat_regs
.cik
.disp_int_cont5
&= ~DC_HPD6_RX_INTERRUPT
;
8261 DRM_DEBUG("IH: HPD_RX 6\n");
8265 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id
, src_data
);
8270 DRM_ERROR("SRBM_READ_ERROR: 0x%x\n", RREG32(SRBM_READ_ERROR
));
8271 WREG32(SRBM_INT_ACK
, 0x1);
8274 DRM_DEBUG("IH: UVD int: 0x%08x\n", src_data
);
8275 radeon_fence_process(rdev
, R600_RING_TYPE_UVD_INDEX
);
8279 addr
= RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR
);
8280 status
= RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS
);
8281 mc_client
= RREG32(VM_CONTEXT1_PROTECTION_FAULT_MCCLIENT
);
8282 /* reset addr and status */
8283 WREG32_P(VM_CONTEXT1_CNTL2
, 1, ~1);
8284 if (addr
== 0x0 && status
== 0x0)
8286 dev_err(rdev
->dev
, "GPU fault detected: %d 0x%08x\n", src_id
, src_data
);
8287 dev_err(rdev
->dev
, " VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x%08X\n",
8289 dev_err(rdev
->dev
, " VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n",
8291 cik_vm_decode_fault(rdev
, status
, addr
, mc_client
);
8294 DRM_DEBUG("IH: VCE int: 0x%08x\n", src_data
);
8297 radeon_fence_process(rdev
, TN_RING_TYPE_VCE1_INDEX
);
8300 radeon_fence_process(rdev
, TN_RING_TYPE_VCE2_INDEX
);
8303 DRM_ERROR("Unhandled interrupt: %d %d\n", src_id
, src_data
);
8307 case 176: /* GFX RB CP_INT */
8308 case 177: /* GFX IB CP_INT */
8309 radeon_fence_process(rdev
, RADEON_RING_TYPE_GFX_INDEX
);
8311 case 181: /* CP EOP event */
8312 DRM_DEBUG("IH: CP EOP\n");
8313 /* XXX check the bitfield order! */
8314 me_id
= (ring_id
& 0x60) >> 5;
8315 pipe_id
= (ring_id
& 0x18) >> 3;
8316 queue_id
= (ring_id
& 0x7) >> 0;
8319 radeon_fence_process(rdev
, RADEON_RING_TYPE_GFX_INDEX
);
8323 if ((cp1_ring
->me
== me_id
) & (cp1_ring
->pipe
== pipe_id
))
8324 radeon_fence_process(rdev
, CAYMAN_RING_TYPE_CP1_INDEX
);
8325 if ((cp2_ring
->me
== me_id
) & (cp2_ring
->pipe
== pipe_id
))
8326 radeon_fence_process(rdev
, CAYMAN_RING_TYPE_CP2_INDEX
);
8330 case 184: /* CP Privileged reg access */
8331 DRM_ERROR("Illegal register access in command stream\n");
8332 /* XXX check the bitfield order! */
8333 me_id
= (ring_id
& 0x60) >> 5;
8334 pipe_id
= (ring_id
& 0x18) >> 3;
8335 queue_id
= (ring_id
& 0x7) >> 0;
8338 /* This results in a full GPU reset, but all we need to do is soft
8339 * reset the CP for gfx
8353 case 185: /* CP Privileged inst */
8354 DRM_ERROR("Illegal instruction in command stream\n");
8355 /* XXX check the bitfield order! */
8356 me_id
= (ring_id
& 0x60) >> 5;
8357 pipe_id
= (ring_id
& 0x18) >> 3;
8358 queue_id
= (ring_id
& 0x7) >> 0;
8361 /* This results in a full GPU reset, but all we need to do is soft
8362 * reset the CP for gfx
8376 case 224: /* SDMA trap event */
8377 /* XXX check the bitfield order! */
8378 me_id
= (ring_id
& 0x3) >> 0;
8379 queue_id
= (ring_id
& 0xc) >> 2;
8380 DRM_DEBUG("IH: SDMA trap\n");
8385 radeon_fence_process(rdev
, R600_RING_TYPE_DMA_INDEX
);
8398 radeon_fence_process(rdev
, CAYMAN_RING_TYPE_DMA1_INDEX
);
8410 case 230: /* thermal low to high */
8411 DRM_DEBUG("IH: thermal low to high\n");
8412 rdev
->pm
.dpm
.thermal
.high_to_low
= false;
8413 queue_thermal
= true;
8415 case 231: /* thermal high to low */
8416 DRM_DEBUG("IH: thermal high to low\n");
8417 rdev
->pm
.dpm
.thermal
.high_to_low
= true;
8418 queue_thermal
= true;
8420 case 233: /* GUI IDLE */
8421 DRM_DEBUG("IH: GUI idle\n");
8423 case 241: /* SDMA Privileged inst */
8424 case 247: /* SDMA Privileged inst */
8425 DRM_ERROR("Illegal instruction in SDMA command stream\n");
8426 /* XXX check the bitfield order! */
8427 me_id
= (ring_id
& 0x3) >> 0;
8428 queue_id
= (ring_id
& 0xc) >> 2;
8463 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id
, src_data
);
8467 /* wptr/rptr are in bytes! */
8469 rptr
&= rdev
->ih
.ptr_mask
;
8470 WREG32(IH_RB_RPTR
, rptr
);
8473 schedule_work(&rdev
->dp_work
);
8475 schedule_work(&rdev
->hotplug_work
);
8477 rdev
->needs_reset
= true;
8478 wake_up_all(&rdev
->fence_queue
);
8481 schedule_work(&rdev
->pm
.dpm
.thermal
.work
);
8482 rdev
->ih
.rptr
= rptr
;
8483 atomic_set(&rdev
->ih
.lock
, 0);
8485 /* make sure wptr hasn't changed while processing */
8486 wptr
= cik_get_ih_wptr(rdev
);
8494 * startup/shutdown callbacks
8497 * cik_startup - program the asic to a functional state
8499 * @rdev: radeon_device pointer
8501 * Programs the asic to a functional state (CIK).
8502 * Called by cik_init() and cik_resume().
8503 * Returns 0 for success, error for failure.
8505 static int cik_startup(struct radeon_device
*rdev
)
8507 struct radeon_ring
*ring
;
8511 /* enable pcie gen2/3 link */
8512 cik_pcie_gen3_enable(rdev
);
8514 cik_program_aspm(rdev
);
8516 /* scratch needs to be initialized before MC */
8517 r
= r600_vram_scratch_init(rdev
);
8521 cik_mc_program(rdev
);
8523 if (!(rdev
->flags
& RADEON_IS_IGP
) && !rdev
->pm
.dpm_enabled
) {
8524 r
= ci_mc_load_microcode(rdev
);
8526 DRM_ERROR("Failed to load MC firmware!\n");
8531 r
= cik_pcie_gart_enable(rdev
);
8536 /* allocate rlc buffers */
8537 if (rdev
->flags
& RADEON_IS_IGP
) {
8538 if (rdev
->family
== CHIP_KAVERI
) {
8539 rdev
->rlc
.reg_list
= spectre_rlc_save_restore_register_list
;
8540 rdev
->rlc
.reg_list_size
=
8541 (u32
)ARRAY_SIZE(spectre_rlc_save_restore_register_list
);
8543 rdev
->rlc
.reg_list
= kalindi_rlc_save_restore_register_list
;
8544 rdev
->rlc
.reg_list_size
=
8545 (u32
)ARRAY_SIZE(kalindi_rlc_save_restore_register_list
);
8548 rdev
->rlc
.cs_data
= ci_cs_data
;
8549 rdev
->rlc
.cp_table_size
= CP_ME_TABLE_SIZE
* 5 * 4;
8550 r
= sumo_rlc_init(rdev
);
8552 DRM_ERROR("Failed to init rlc BOs!\n");
8556 /* allocate wb buffer */
8557 r
= radeon_wb_init(rdev
);
8561 /* allocate mec buffers */
8562 r
= cik_mec_init(rdev
);
8564 DRM_ERROR("Failed to init MEC BOs!\n");
8568 r
= radeon_fence_driver_start_ring(rdev
, RADEON_RING_TYPE_GFX_INDEX
);
8570 dev_err(rdev
->dev
, "failed initializing CP fences (%d).\n", r
);
8574 r
= radeon_fence_driver_start_ring(rdev
, CAYMAN_RING_TYPE_CP1_INDEX
);
8576 dev_err(rdev
->dev
, "failed initializing CP fences (%d).\n", r
);
8580 r
= radeon_fence_driver_start_ring(rdev
, CAYMAN_RING_TYPE_CP2_INDEX
);
8582 dev_err(rdev
->dev
, "failed initializing CP fences (%d).\n", r
);
8586 r
= radeon_fence_driver_start_ring(rdev
, R600_RING_TYPE_DMA_INDEX
);
8588 dev_err(rdev
->dev
, "failed initializing DMA fences (%d).\n", r
);
8592 r
= radeon_fence_driver_start_ring(rdev
, CAYMAN_RING_TYPE_DMA1_INDEX
);
8594 dev_err(rdev
->dev
, "failed initializing DMA fences (%d).\n", r
);
8598 r
= radeon_uvd_resume(rdev
);
8600 r
= uvd_v4_2_resume(rdev
);
8602 r
= radeon_fence_driver_start_ring(rdev
,
8603 R600_RING_TYPE_UVD_INDEX
);
8605 dev_err(rdev
->dev
, "UVD fences init error (%d).\n", r
);
8609 rdev
->ring
[R600_RING_TYPE_UVD_INDEX
].ring_size
= 0;
8611 r
= radeon_vce_resume(rdev
);
8613 r
= vce_v2_0_resume(rdev
);
8615 r
= radeon_fence_driver_start_ring(rdev
,
8616 TN_RING_TYPE_VCE1_INDEX
);
8618 r
= radeon_fence_driver_start_ring(rdev
,
8619 TN_RING_TYPE_VCE2_INDEX
);
8622 dev_err(rdev
->dev
, "VCE init error (%d).\n", r
);
8623 rdev
->ring
[TN_RING_TYPE_VCE1_INDEX
].ring_size
= 0;
8624 rdev
->ring
[TN_RING_TYPE_VCE2_INDEX
].ring_size
= 0;
8628 if (!rdev
->irq
.installed
) {
8629 r
= radeon_irq_kms_init(rdev
);
8634 r
= cik_irq_init(rdev
);
8636 DRM_ERROR("radeon: IH init failed (%d).\n", r
);
8637 radeon_irq_kms_fini(rdev
);
8642 if (rdev
->family
== CHIP_HAWAII
) {
8644 nop
= PACKET3(PACKET3_NOP
, 0x3FFF);
8646 nop
= RADEON_CP_PACKET2
;
8648 nop
= PACKET3(PACKET3_NOP
, 0x3FFF);
8651 ring
= &rdev
->ring
[RADEON_RING_TYPE_GFX_INDEX
];
8652 r
= radeon_ring_init(rdev
, ring
, ring
->ring_size
, RADEON_WB_CP_RPTR_OFFSET
,
8657 /* set up the compute queues */
8658 /* type-2 packets are deprecated on MEC, use type-3 instead */
8659 ring
= &rdev
->ring
[CAYMAN_RING_TYPE_CP1_INDEX
];
8660 r
= radeon_ring_init(rdev
, ring
, ring
->ring_size
, RADEON_WB_CP1_RPTR_OFFSET
,
8664 ring
->me
= 1; /* first MEC */
8665 ring
->pipe
= 0; /* first pipe */
8666 ring
->queue
= 0; /* first queue */
8667 ring
->wptr_offs
= CIK_WB_CP1_WPTR_OFFSET
;
8669 /* type-2 packets are deprecated on MEC, use type-3 instead */
8670 ring
= &rdev
->ring
[CAYMAN_RING_TYPE_CP2_INDEX
];
8671 r
= radeon_ring_init(rdev
, ring
, ring
->ring_size
, RADEON_WB_CP2_RPTR_OFFSET
,
8675 /* dGPU only have 1 MEC */
8676 ring
->me
= 1; /* first MEC */
8677 ring
->pipe
= 0; /* first pipe */
8678 ring
->queue
= 1; /* second queue */
8679 ring
->wptr_offs
= CIK_WB_CP2_WPTR_OFFSET
;
8681 ring
= &rdev
->ring
[R600_RING_TYPE_DMA_INDEX
];
8682 r
= radeon_ring_init(rdev
, ring
, ring
->ring_size
, R600_WB_DMA_RPTR_OFFSET
,
8683 SDMA_PACKET(SDMA_OPCODE_NOP
, 0, 0));
8687 ring
= &rdev
->ring
[CAYMAN_RING_TYPE_DMA1_INDEX
];
8688 r
= radeon_ring_init(rdev
, ring
, ring
->ring_size
, CAYMAN_WB_DMA1_RPTR_OFFSET
,
8689 SDMA_PACKET(SDMA_OPCODE_NOP
, 0, 0));
8693 r
= cik_cp_resume(rdev
);
8697 r
= cik_sdma_resume(rdev
);
8701 ring
= &rdev
->ring
[R600_RING_TYPE_UVD_INDEX
];
8702 if (ring
->ring_size
) {
8703 r
= radeon_ring_init(rdev
, ring
, ring
->ring_size
, 0,
8706 r
= uvd_v1_0_init(rdev
);
8708 DRM_ERROR("radeon: failed initializing UVD (%d).\n", r
);
8713 ring
= &rdev
->ring
[TN_RING_TYPE_VCE1_INDEX
];
8714 if (ring
->ring_size
)
8715 r
= radeon_ring_init(rdev
, ring
, ring
->ring_size
, 0,
8718 ring
= &rdev
->ring
[TN_RING_TYPE_VCE2_INDEX
];
8719 if (ring
->ring_size
)
8720 r
= radeon_ring_init(rdev
, ring
, ring
->ring_size
, 0,
8724 r
= vce_v1_0_init(rdev
);
8725 else if (r
!= -ENOENT
)
8726 DRM_ERROR("radeon: failed initializing VCE (%d).\n", r
);
8728 r
= radeon_ib_pool_init(rdev
);
8730 dev_err(rdev
->dev
, "IB initialization failed (%d).\n", r
);
8734 r
= radeon_vm_manager_init(rdev
);
8736 dev_err(rdev
->dev
, "vm manager initialization failed (%d).\n", r
);
8740 r
= radeon_audio_init(rdev
);
8744 r
= radeon_kfd_resume(rdev
);
8752 * cik_resume - resume the asic to a functional state
8754 * @rdev: radeon_device pointer
8756 * Programs the asic to a functional state (CIK).
8758 * Returns 0 for success, error for failure.
8760 int cik_resume(struct radeon_device
*rdev
)
8765 atom_asic_init(rdev
->mode_info
.atom_context
);
8767 /* init golden registers */
8768 cik_init_golden_registers(rdev
);
8770 if (rdev
->pm
.pm_method
== PM_METHOD_DPM
)
8771 radeon_pm_resume(rdev
);
8773 rdev
->accel_working
= true;
8774 r
= cik_startup(rdev
);
8776 DRM_ERROR("cik startup failed on resume\n");
8777 rdev
->accel_working
= false;
8786 * cik_suspend - suspend the asic
8788 * @rdev: radeon_device pointer
8790 * Bring the chip into a state suitable for suspend (CIK).
8791 * Called at suspend.
8792 * Returns 0 for success.
8794 int cik_suspend(struct radeon_device
*rdev
)
8796 radeon_kfd_suspend(rdev
);
8797 radeon_pm_suspend(rdev
);
8798 radeon_audio_fini(rdev
);
8799 radeon_vm_manager_fini(rdev
);
8800 cik_cp_enable(rdev
, false);
8801 cik_sdma_enable(rdev
, false);
8802 uvd_v1_0_fini(rdev
);
8803 radeon_uvd_suspend(rdev
);
8804 radeon_vce_suspend(rdev
);
8807 cik_irq_suspend(rdev
);
8808 radeon_wb_disable(rdev
);
8809 cik_pcie_gart_disable(rdev
);
8813 /* Plan is to move initialization in that function and use
8814 * helper function so that radeon_device_init pretty much
8815 * do nothing more than calling asic specific function. This
8816 * should also allow to remove a bunch of callback function
8820 * cik_init - asic specific driver and hw init
8822 * @rdev: radeon_device pointer
8824 * Setup asic specific driver variables and program the hw
8825 * to a functional state (CIK).
8826 * Called at driver startup.
8827 * Returns 0 for success, errors for failure.
8829 int cik_init(struct radeon_device
*rdev
)
8831 struct radeon_ring
*ring
;
8835 if (!radeon_get_bios(rdev
)) {
8836 if (ASIC_IS_AVIVO(rdev
))
8839 /* Must be an ATOMBIOS */
8840 if (!rdev
->is_atom_bios
) {
8841 dev_err(rdev
->dev
, "Expecting atombios for cayman GPU\n");
8844 r
= radeon_atombios_init(rdev
);
8848 /* Post card if necessary */
8849 if (!radeon_card_posted(rdev
)) {
8851 dev_err(rdev
->dev
, "Card not posted and no BIOS - ignoring\n");
8854 DRM_INFO("GPU not posted. posting now...\n");
8855 atom_asic_init(rdev
->mode_info
.atom_context
);
8857 /* init golden registers */
8858 cik_init_golden_registers(rdev
);
8859 /* Initialize scratch registers */
8860 cik_scratch_init(rdev
);
8861 /* Initialize surface registers */
8862 radeon_surface_init(rdev
);
8863 /* Initialize clocks */
8864 radeon_get_clock_info(rdev
->ddev
);
8867 r
= radeon_fence_driver_init(rdev
);
8871 /* initialize memory controller */
8872 r
= cik_mc_init(rdev
);
8875 /* Memory manager */
8876 r
= radeon_bo_init(rdev
);
8880 if (rdev
->flags
& RADEON_IS_IGP
) {
8881 if (!rdev
->me_fw
|| !rdev
->pfp_fw
|| !rdev
->ce_fw
||
8882 !rdev
->mec_fw
|| !rdev
->sdma_fw
|| !rdev
->rlc_fw
) {
8883 r
= cik_init_microcode(rdev
);
8885 DRM_ERROR("Failed to load firmware!\n");
8890 if (!rdev
->me_fw
|| !rdev
->pfp_fw
|| !rdev
->ce_fw
||
8891 !rdev
->mec_fw
|| !rdev
->sdma_fw
|| !rdev
->rlc_fw
||
8893 r
= cik_init_microcode(rdev
);
8895 DRM_ERROR("Failed to load firmware!\n");
8901 /* Initialize power management */
8902 radeon_pm_init(rdev
);
8904 ring
= &rdev
->ring
[RADEON_RING_TYPE_GFX_INDEX
];
8905 ring
->ring_obj
= NULL
;
8906 r600_ring_init(rdev
, ring
, 1024 * 1024);
8908 ring
= &rdev
->ring
[CAYMAN_RING_TYPE_CP1_INDEX
];
8909 ring
->ring_obj
= NULL
;
8910 r600_ring_init(rdev
, ring
, 1024 * 1024);
8911 r
= radeon_doorbell_get(rdev
, &ring
->doorbell_index
);
8915 ring
= &rdev
->ring
[CAYMAN_RING_TYPE_CP2_INDEX
];
8916 ring
->ring_obj
= NULL
;
8917 r600_ring_init(rdev
, ring
, 1024 * 1024);
8918 r
= radeon_doorbell_get(rdev
, &ring
->doorbell_index
);
8922 ring
= &rdev
->ring
[R600_RING_TYPE_DMA_INDEX
];
8923 ring
->ring_obj
= NULL
;
8924 r600_ring_init(rdev
, ring
, 256 * 1024);
8926 ring
= &rdev
->ring
[CAYMAN_RING_TYPE_DMA1_INDEX
];
8927 ring
->ring_obj
= NULL
;
8928 r600_ring_init(rdev
, ring
, 256 * 1024);
8930 r
= radeon_uvd_init(rdev
);
8932 ring
= &rdev
->ring
[R600_RING_TYPE_UVD_INDEX
];
8933 ring
->ring_obj
= NULL
;
8934 r600_ring_init(rdev
, ring
, 4096);
8937 r
= radeon_vce_init(rdev
);
8939 ring
= &rdev
->ring
[TN_RING_TYPE_VCE1_INDEX
];
8940 ring
->ring_obj
= NULL
;
8941 r600_ring_init(rdev
, ring
, 4096);
8943 ring
= &rdev
->ring
[TN_RING_TYPE_VCE2_INDEX
];
8944 ring
->ring_obj
= NULL
;
8945 r600_ring_init(rdev
, ring
, 4096);
8948 rdev
->ih
.ring_obj
= NULL
;
8949 r600_ih_ring_init(rdev
, 64 * 1024);
8951 r
= r600_pcie_gart_init(rdev
);
8955 rdev
->accel_working
= true;
8956 r
= cik_startup(rdev
);
8958 dev_err(rdev
->dev
, "disabling GPU acceleration\n");
8960 cik_sdma_fini(rdev
);
8962 sumo_rlc_fini(rdev
);
8964 radeon_wb_fini(rdev
);
8965 radeon_ib_pool_fini(rdev
);
8966 radeon_vm_manager_fini(rdev
);
8967 radeon_irq_kms_fini(rdev
);
8968 cik_pcie_gart_fini(rdev
);
8969 rdev
->accel_working
= false;
8972 /* Don't start up if the MC ucode is missing.
8973 * The default clocks and voltages before the MC ucode
8974 * is loaded are not suffient for advanced operations.
8976 if (!rdev
->mc_fw
&& !(rdev
->flags
& RADEON_IS_IGP
)) {
8977 DRM_ERROR("radeon: MC ucode required for NI+.\n");
8985 * cik_fini - asic specific driver and hw fini
8987 * @rdev: radeon_device pointer
8989 * Tear down the asic specific driver variables and program the hw
8990 * to an idle state (CIK).
8991 * Called at driver unload.
8993 void cik_fini(struct radeon_device
*rdev
)
8995 radeon_pm_fini(rdev
);
8997 cik_sdma_fini(rdev
);
9001 sumo_rlc_fini(rdev
);
9003 radeon_wb_fini(rdev
);
9004 radeon_vm_manager_fini(rdev
);
9005 radeon_ib_pool_fini(rdev
);
9006 radeon_irq_kms_fini(rdev
);
9007 uvd_v1_0_fini(rdev
);
9008 radeon_uvd_fini(rdev
);
9009 radeon_vce_fini(rdev
);
9010 cik_pcie_gart_fini(rdev
);
9011 r600_vram_scratch_fini(rdev
);
9012 radeon_gem_fini(rdev
);
9013 radeon_fence_driver_fini(rdev
);
9014 radeon_bo_fini(rdev
);
9015 radeon_atombios_fini(rdev
);
9020 void dce8_program_fmt(struct drm_encoder
*encoder
)
9022 struct drm_device
*dev
= encoder
->dev
;
9023 struct radeon_device
*rdev
= dev
->dev_private
;
9024 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
9025 struct radeon_crtc
*radeon_crtc
= to_radeon_crtc(encoder
->crtc
);
9026 struct drm_connector
*connector
= radeon_get_connector_for_encoder(encoder
);
9029 enum radeon_connector_dither dither
= RADEON_FMT_DITHER_DISABLE
;
9032 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
9033 bpc
= radeon_get_monitor_bpc(connector
);
9034 dither
= radeon_connector
->dither
;
9037 /* LVDS/eDP FMT is set up by atom */
9038 if (radeon_encoder
->devices
& ATOM_DEVICE_LCD_SUPPORT
)
9041 /* not needed for analog */
9042 if ((radeon_encoder
->encoder_id
== ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1
) ||
9043 (radeon_encoder
->encoder_id
== ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2
))
9051 if (dither
== RADEON_FMT_DITHER_ENABLE
)
9052 /* XXX sort out optimal dither settings */
9053 tmp
|= (FMT_FRAME_RANDOM_ENABLE
| FMT_HIGHPASS_RANDOM_ENABLE
|
9054 FMT_SPATIAL_DITHER_EN
| FMT_SPATIAL_DITHER_DEPTH(0));
9056 tmp
|= (FMT_TRUNCATE_EN
| FMT_TRUNCATE_DEPTH(0));
9059 if (dither
== RADEON_FMT_DITHER_ENABLE
)
9060 /* XXX sort out optimal dither settings */
9061 tmp
|= (FMT_FRAME_RANDOM_ENABLE
| FMT_HIGHPASS_RANDOM_ENABLE
|
9062 FMT_RGB_RANDOM_ENABLE
|
9063 FMT_SPATIAL_DITHER_EN
| FMT_SPATIAL_DITHER_DEPTH(1));
9065 tmp
|= (FMT_TRUNCATE_EN
| FMT_TRUNCATE_DEPTH(1));
9068 if (dither
== RADEON_FMT_DITHER_ENABLE
)
9069 /* XXX sort out optimal dither settings */
9070 tmp
|= (FMT_FRAME_RANDOM_ENABLE
| FMT_HIGHPASS_RANDOM_ENABLE
|
9071 FMT_RGB_RANDOM_ENABLE
|
9072 FMT_SPATIAL_DITHER_EN
| FMT_SPATIAL_DITHER_DEPTH(2));
9074 tmp
|= (FMT_TRUNCATE_EN
| FMT_TRUNCATE_DEPTH(2));
9081 WREG32(FMT_BIT_DEPTH_CONTROL
+ radeon_crtc
->crtc_offset
, tmp
);
9084 /* display watermark setup */
9086 * dce8_line_buffer_adjust - Set up the line buffer
9088 * @rdev: radeon_device pointer
9089 * @radeon_crtc: the selected display controller
9090 * @mode: the current display mode on the selected display
9093 * Setup up the line buffer allocation for
9094 * the selected display controller (CIK).
9095 * Returns the line buffer size in pixels.
9097 static u32
dce8_line_buffer_adjust(struct radeon_device
*rdev
,
9098 struct radeon_crtc
*radeon_crtc
,
9099 struct drm_display_mode
*mode
)
9101 u32 tmp
, buffer_alloc
, i
;
9102 u32 pipe_offset
= radeon_crtc
->crtc_id
* 0x20;
9105 * There are 6 line buffers, one for each display controllers.
9106 * There are 3 partitions per LB. Select the number of partitions
9107 * to enable based on the display width. For display widths larger
9108 * than 4096, you need use to use 2 display controllers and combine
9109 * them using the stereo blender.
9111 if (radeon_crtc
->base
.enabled
&& mode
) {
9112 if (mode
->crtc_hdisplay
< 1920) {
9115 } else if (mode
->crtc_hdisplay
< 2560) {
9118 } else if (mode
->crtc_hdisplay
< 4096) {
9120 buffer_alloc
= (rdev
->flags
& RADEON_IS_IGP
) ? 2 : 4;
9122 DRM_DEBUG_KMS("Mode too big for LB!\n");
9124 buffer_alloc
= (rdev
->flags
& RADEON_IS_IGP
) ? 2 : 4;
9131 WREG32(LB_MEMORY_CTRL
+ radeon_crtc
->crtc_offset
,
9132 LB_MEMORY_CONFIG(tmp
) | LB_MEMORY_SIZE(0x6B0));
9134 WREG32(PIPE0_DMIF_BUFFER_CONTROL
+ pipe_offset
,
9135 DMIF_BUFFERS_ALLOCATED(buffer_alloc
));
9136 for (i
= 0; i
< rdev
->usec_timeout
; i
++) {
9137 if (RREG32(PIPE0_DMIF_BUFFER_CONTROL
+ pipe_offset
) &
9138 DMIF_BUFFERS_ALLOCATED_COMPLETED
)
9143 if (radeon_crtc
->base
.enabled
&& mode
) {
9155 /* controller not enabled, so no lb used */
9160 * cik_get_number_of_dram_channels - get the number of dram channels
9162 * @rdev: radeon_device pointer
9164 * Look up the number of video ram channels (CIK).
9165 * Used for display watermark bandwidth calculations
9166 * Returns the number of dram channels
9168 static u32
cik_get_number_of_dram_channels(struct radeon_device
*rdev
)
9170 u32 tmp
= RREG32(MC_SHARED_CHMAP
);
9172 switch ((tmp
& NOOFCHAN_MASK
) >> NOOFCHAN_SHIFT
) {
9195 struct dce8_wm_params
{
9196 u32 dram_channels
; /* number of dram channels */
9197 u32 yclk
; /* bandwidth per dram data pin in kHz */
9198 u32 sclk
; /* engine clock in kHz */
9199 u32 disp_clk
; /* display clock in kHz */
9200 u32 src_width
; /* viewport width */
9201 u32 active_time
; /* active display time in ns */
9202 u32 blank_time
; /* blank time in ns */
9203 bool interlaced
; /* mode is interlaced */
9204 fixed20_12 vsc
; /* vertical scale ratio */
9205 u32 num_heads
; /* number of active crtcs */
9206 u32 bytes_per_pixel
; /* bytes per pixel display + overlay */
9207 u32 lb_size
; /* line buffer allocated to pipe */
9208 u32 vtaps
; /* vertical scaler taps */
9212 * dce8_dram_bandwidth - get the dram bandwidth
9214 * @wm: watermark calculation data
9216 * Calculate the raw dram bandwidth (CIK).
9217 * Used for display watermark bandwidth calculations
9218 * Returns the dram bandwidth in MBytes/s
9220 static u32
dce8_dram_bandwidth(struct dce8_wm_params
*wm
)
9222 /* Calculate raw DRAM Bandwidth */
9223 fixed20_12 dram_efficiency
; /* 0.7 */
9224 fixed20_12 yclk
, dram_channels
, bandwidth
;
9227 a
.full
= dfixed_const(1000);
9228 yclk
.full
= dfixed_const(wm
->yclk
);
9229 yclk
.full
= dfixed_div(yclk
, a
);
9230 dram_channels
.full
= dfixed_const(wm
->dram_channels
* 4);
9231 a
.full
= dfixed_const(10);
9232 dram_efficiency
.full
= dfixed_const(7);
9233 dram_efficiency
.full
= dfixed_div(dram_efficiency
, a
);
9234 bandwidth
.full
= dfixed_mul(dram_channels
, yclk
);
9235 bandwidth
.full
= dfixed_mul(bandwidth
, dram_efficiency
);
9237 return dfixed_trunc(bandwidth
);
9241 * dce8_dram_bandwidth_for_display - get the dram bandwidth for display
9243 * @wm: watermark calculation data
9245 * Calculate the dram bandwidth used for display (CIK).
9246 * Used for display watermark bandwidth calculations
9247 * Returns the dram bandwidth for display in MBytes/s
9249 static u32
dce8_dram_bandwidth_for_display(struct dce8_wm_params
*wm
)
9251 /* Calculate DRAM Bandwidth and the part allocated to display. */
9252 fixed20_12 disp_dram_allocation
; /* 0.3 to 0.7 */
9253 fixed20_12 yclk
, dram_channels
, bandwidth
;
9256 a
.full
= dfixed_const(1000);
9257 yclk
.full
= dfixed_const(wm
->yclk
);
9258 yclk
.full
= dfixed_div(yclk
, a
);
9259 dram_channels
.full
= dfixed_const(wm
->dram_channels
* 4);
9260 a
.full
= dfixed_const(10);
9261 disp_dram_allocation
.full
= dfixed_const(3); /* XXX worse case value 0.3 */
9262 disp_dram_allocation
.full
= dfixed_div(disp_dram_allocation
, a
);
9263 bandwidth
.full
= dfixed_mul(dram_channels
, yclk
);
9264 bandwidth
.full
= dfixed_mul(bandwidth
, disp_dram_allocation
);
9266 return dfixed_trunc(bandwidth
);
9270 * dce8_data_return_bandwidth - get the data return bandwidth
9272 * @wm: watermark calculation data
9274 * Calculate the data return bandwidth used for display (CIK).
9275 * Used for display watermark bandwidth calculations
9276 * Returns the data return bandwidth in MBytes/s
9278 static u32
dce8_data_return_bandwidth(struct dce8_wm_params
*wm
)
9280 /* Calculate the display Data return Bandwidth */
9281 fixed20_12 return_efficiency
; /* 0.8 */
9282 fixed20_12 sclk
, bandwidth
;
9285 a
.full
= dfixed_const(1000);
9286 sclk
.full
= dfixed_const(wm
->sclk
);
9287 sclk
.full
= dfixed_div(sclk
, a
);
9288 a
.full
= dfixed_const(10);
9289 return_efficiency
.full
= dfixed_const(8);
9290 return_efficiency
.full
= dfixed_div(return_efficiency
, a
);
9291 a
.full
= dfixed_const(32);
9292 bandwidth
.full
= dfixed_mul(a
, sclk
);
9293 bandwidth
.full
= dfixed_mul(bandwidth
, return_efficiency
);
9295 return dfixed_trunc(bandwidth
);
9299 * dce8_dmif_request_bandwidth - get the dmif bandwidth
9301 * @wm: watermark calculation data
9303 * Calculate the dmif bandwidth used for display (CIK).
9304 * Used for display watermark bandwidth calculations
9305 * Returns the dmif bandwidth in MBytes/s
9307 static u32
dce8_dmif_request_bandwidth(struct dce8_wm_params
*wm
)
9309 /* Calculate the DMIF Request Bandwidth */
9310 fixed20_12 disp_clk_request_efficiency
; /* 0.8 */
9311 fixed20_12 disp_clk
, bandwidth
;
9314 a
.full
= dfixed_const(1000);
9315 disp_clk
.full
= dfixed_const(wm
->disp_clk
);
9316 disp_clk
.full
= dfixed_div(disp_clk
, a
);
9317 a
.full
= dfixed_const(32);
9318 b
.full
= dfixed_mul(a
, disp_clk
);
9320 a
.full
= dfixed_const(10);
9321 disp_clk_request_efficiency
.full
= dfixed_const(8);
9322 disp_clk_request_efficiency
.full
= dfixed_div(disp_clk_request_efficiency
, a
);
9324 bandwidth
.full
= dfixed_mul(b
, disp_clk_request_efficiency
);
9326 return dfixed_trunc(bandwidth
);
9330 * dce8_available_bandwidth - get the min available bandwidth
9332 * @wm: watermark calculation data
9334 * Calculate the min available bandwidth used for display (CIK).
9335 * Used for display watermark bandwidth calculations
9336 * Returns the min available bandwidth in MBytes/s
9338 static u32
dce8_available_bandwidth(struct dce8_wm_params
*wm
)
9340 /* Calculate the Available bandwidth. Display can use this temporarily but not in average. */
9341 u32 dram_bandwidth
= dce8_dram_bandwidth(wm
);
9342 u32 data_return_bandwidth
= dce8_data_return_bandwidth(wm
);
9343 u32 dmif_req_bandwidth
= dce8_dmif_request_bandwidth(wm
);
9345 return min(dram_bandwidth
, min(data_return_bandwidth
, dmif_req_bandwidth
));
9349 * dce8_average_bandwidth - get the average available bandwidth
9351 * @wm: watermark calculation data
9353 * Calculate the average available bandwidth used for display (CIK).
9354 * Used for display watermark bandwidth calculations
9355 * Returns the average available bandwidth in MBytes/s
9357 static u32
dce8_average_bandwidth(struct dce8_wm_params
*wm
)
9359 /* Calculate the display mode Average Bandwidth
9360 * DisplayMode should contain the source and destination dimensions,
9364 fixed20_12 line_time
;
9365 fixed20_12 src_width
;
9366 fixed20_12 bandwidth
;
9369 a
.full
= dfixed_const(1000);
9370 line_time
.full
= dfixed_const(wm
->active_time
+ wm
->blank_time
);
9371 line_time
.full
= dfixed_div(line_time
, a
);
9372 bpp
.full
= dfixed_const(wm
->bytes_per_pixel
);
9373 src_width
.full
= dfixed_const(wm
->src_width
);
9374 bandwidth
.full
= dfixed_mul(src_width
, bpp
);
9375 bandwidth
.full
= dfixed_mul(bandwidth
, wm
->vsc
);
9376 bandwidth
.full
= dfixed_div(bandwidth
, line_time
);
9378 return dfixed_trunc(bandwidth
);
9382 * dce8_latency_watermark - get the latency watermark
9384 * @wm: watermark calculation data
9386 * Calculate the latency watermark (CIK).
9387 * Used for display watermark bandwidth calculations
9388 * Returns the latency watermark in ns
9390 static u32
dce8_latency_watermark(struct dce8_wm_params
*wm
)
9392 /* First calculate the latency in ns */
9393 u32 mc_latency
= 2000; /* 2000 ns. */
9394 u32 available_bandwidth
= dce8_available_bandwidth(wm
);
9395 u32 worst_chunk_return_time
= (512 * 8 * 1000) / available_bandwidth
;
9396 u32 cursor_line_pair_return_time
= (128 * 4 * 1000) / available_bandwidth
;
9397 u32 dc_latency
= 40000000 / wm
->disp_clk
; /* dc pipe latency */
9398 u32 other_heads_data_return_time
= ((wm
->num_heads
+ 1) * worst_chunk_return_time
) +
9399 (wm
->num_heads
* cursor_line_pair_return_time
);
9400 u32 latency
= mc_latency
+ other_heads_data_return_time
+ dc_latency
;
9401 u32 max_src_lines_per_dst_line
, lb_fill_bw
, line_fill_time
;
9402 u32 tmp
, dmif_size
= 12288;
9405 if (wm
->num_heads
== 0)
9408 a
.full
= dfixed_const(2);
9409 b
.full
= dfixed_const(1);
9410 if ((wm
->vsc
.full
> a
.full
) ||
9411 ((wm
->vsc
.full
> b
.full
) && (wm
->vtaps
>= 3)) ||
9413 ((wm
->vsc
.full
>= a
.full
) && wm
->interlaced
))
9414 max_src_lines_per_dst_line
= 4;
9416 max_src_lines_per_dst_line
= 2;
9418 a
.full
= dfixed_const(available_bandwidth
);
9419 b
.full
= dfixed_const(wm
->num_heads
);
9420 a
.full
= dfixed_div(a
, b
);
9422 b
.full
= dfixed_const(mc_latency
+ 512);
9423 c
.full
= dfixed_const(wm
->disp_clk
);
9424 b
.full
= dfixed_div(b
, c
);
9426 c
.full
= dfixed_const(dmif_size
);
9427 b
.full
= dfixed_div(c
, b
);
9429 tmp
= min(dfixed_trunc(a
), dfixed_trunc(b
));
9431 b
.full
= dfixed_const(1000);
9432 c
.full
= dfixed_const(wm
->disp_clk
);
9433 b
.full
= dfixed_div(c
, b
);
9434 c
.full
= dfixed_const(wm
->bytes_per_pixel
);
9435 b
.full
= dfixed_mul(b
, c
);
9437 lb_fill_bw
= min(tmp
, dfixed_trunc(b
));
9439 a
.full
= dfixed_const(max_src_lines_per_dst_line
* wm
->src_width
* wm
->bytes_per_pixel
);
9440 b
.full
= dfixed_const(1000);
9441 c
.full
= dfixed_const(lb_fill_bw
);
9442 b
.full
= dfixed_div(c
, b
);
9443 a
.full
= dfixed_div(a
, b
);
9444 line_fill_time
= dfixed_trunc(a
);
9446 if (line_fill_time
< wm
->active_time
)
9449 return latency
+ (line_fill_time
- wm
->active_time
);
9454 * dce8_average_bandwidth_vs_dram_bandwidth_for_display - check
9455 * average and available dram bandwidth
9457 * @wm: watermark calculation data
9459 * Check if the display average bandwidth fits in the display
9460 * dram bandwidth (CIK).
9461 * Used for display watermark bandwidth calculations
9462 * Returns true if the display fits, false if not.
9464 static bool dce8_average_bandwidth_vs_dram_bandwidth_for_display(struct dce8_wm_params
*wm
)
9466 if (dce8_average_bandwidth(wm
) <=
9467 (dce8_dram_bandwidth_for_display(wm
) / wm
->num_heads
))
9474 * dce8_average_bandwidth_vs_available_bandwidth - check
9475 * average and available bandwidth
9477 * @wm: watermark calculation data
9479 * Check if the display average bandwidth fits in the display
9480 * available bandwidth (CIK).
9481 * Used for display watermark bandwidth calculations
9482 * Returns true if the display fits, false if not.
9484 static bool dce8_average_bandwidth_vs_available_bandwidth(struct dce8_wm_params
*wm
)
9486 if (dce8_average_bandwidth(wm
) <=
9487 (dce8_available_bandwidth(wm
) / wm
->num_heads
))
9494 * dce8_check_latency_hiding - check latency hiding
9496 * @wm: watermark calculation data
9498 * Check latency hiding (CIK).
9499 * Used for display watermark bandwidth calculations
9500 * Returns true if the display fits, false if not.
9502 static bool dce8_check_latency_hiding(struct dce8_wm_params
*wm
)
9504 u32 lb_partitions
= wm
->lb_size
/ wm
->src_width
;
9505 u32 line_time
= wm
->active_time
+ wm
->blank_time
;
9506 u32 latency_tolerant_lines
;
9510 a
.full
= dfixed_const(1);
9511 if (wm
->vsc
.full
> a
.full
)
9512 latency_tolerant_lines
= 1;
9514 if (lb_partitions
<= (wm
->vtaps
+ 1))
9515 latency_tolerant_lines
= 1;
9517 latency_tolerant_lines
= 2;
9520 latency_hiding
= (latency_tolerant_lines
* line_time
+ wm
->blank_time
);
9522 if (dce8_latency_watermark(wm
) <= latency_hiding
)
9529 * dce8_program_watermarks - program display watermarks
9531 * @rdev: radeon_device pointer
9532 * @radeon_crtc: the selected display controller
9533 * @lb_size: line buffer size
9534 * @num_heads: number of display controllers in use
9536 * Calculate and program the display watermarks for the
9537 * selected display controller (CIK).
9539 static void dce8_program_watermarks(struct radeon_device
*rdev
,
9540 struct radeon_crtc
*radeon_crtc
,
9541 u32 lb_size
, u32 num_heads
)
9543 struct drm_display_mode
*mode
= &radeon_crtc
->base
.mode
;
9544 struct dce8_wm_params wm_low
, wm_high
;
9547 u32 latency_watermark_a
= 0, latency_watermark_b
= 0;
9550 if (radeon_crtc
->base
.enabled
&& num_heads
&& mode
) {
9551 pixel_period
= 1000000 / (u32
)mode
->clock
;
9552 line_time
= min((u32
)mode
->crtc_htotal
* pixel_period
, (u32
)65535);
9554 /* watermark for high clocks */
9555 if ((rdev
->pm
.pm_method
== PM_METHOD_DPM
) &&
9556 rdev
->pm
.dpm_enabled
) {
9558 radeon_dpm_get_mclk(rdev
, false) * 10;
9560 radeon_dpm_get_sclk(rdev
, false) * 10;
9562 wm_high
.yclk
= rdev
->pm
.current_mclk
* 10;
9563 wm_high
.sclk
= rdev
->pm
.current_sclk
* 10;
9566 wm_high
.disp_clk
= mode
->clock
;
9567 wm_high
.src_width
= mode
->crtc_hdisplay
;
9568 wm_high
.active_time
= mode
->crtc_hdisplay
* pixel_period
;
9569 wm_high
.blank_time
= line_time
- wm_high
.active_time
;
9570 wm_high
.interlaced
= false;
9571 if (mode
->flags
& DRM_MODE_FLAG_INTERLACE
)
9572 wm_high
.interlaced
= true;
9573 wm_high
.vsc
= radeon_crtc
->vsc
;
9575 if (radeon_crtc
->rmx_type
!= RMX_OFF
)
9577 wm_high
.bytes_per_pixel
= 4; /* XXX: get this from fb config */
9578 wm_high
.lb_size
= lb_size
;
9579 wm_high
.dram_channels
= cik_get_number_of_dram_channels(rdev
);
9580 wm_high
.num_heads
= num_heads
;
9582 /* set for high clocks */
9583 latency_watermark_a
= min(dce8_latency_watermark(&wm_high
), (u32
)65535);
9585 /* possibly force display priority to high */
9586 /* should really do this at mode validation time... */
9587 if (!dce8_average_bandwidth_vs_dram_bandwidth_for_display(&wm_high
) ||
9588 !dce8_average_bandwidth_vs_available_bandwidth(&wm_high
) ||
9589 !dce8_check_latency_hiding(&wm_high
) ||
9590 (rdev
->disp_priority
== 2)) {
9591 DRM_DEBUG_KMS("force priority to high\n");
9594 /* watermark for low clocks */
9595 if ((rdev
->pm
.pm_method
== PM_METHOD_DPM
) &&
9596 rdev
->pm
.dpm_enabled
) {
9598 radeon_dpm_get_mclk(rdev
, true) * 10;
9600 radeon_dpm_get_sclk(rdev
, true) * 10;
9602 wm_low
.yclk
= rdev
->pm
.current_mclk
* 10;
9603 wm_low
.sclk
= rdev
->pm
.current_sclk
* 10;
9606 wm_low
.disp_clk
= mode
->clock
;
9607 wm_low
.src_width
= mode
->crtc_hdisplay
;
9608 wm_low
.active_time
= mode
->crtc_hdisplay
* pixel_period
;
9609 wm_low
.blank_time
= line_time
- wm_low
.active_time
;
9610 wm_low
.interlaced
= false;
9611 if (mode
->flags
& DRM_MODE_FLAG_INTERLACE
)
9612 wm_low
.interlaced
= true;
9613 wm_low
.vsc
= radeon_crtc
->vsc
;
9615 if (radeon_crtc
->rmx_type
!= RMX_OFF
)
9617 wm_low
.bytes_per_pixel
= 4; /* XXX: get this from fb config */
9618 wm_low
.lb_size
= lb_size
;
9619 wm_low
.dram_channels
= cik_get_number_of_dram_channels(rdev
);
9620 wm_low
.num_heads
= num_heads
;
9622 /* set for low clocks */
9623 latency_watermark_b
= min(dce8_latency_watermark(&wm_low
), (u32
)65535);
9625 /* possibly force display priority to high */
9626 /* should really do this at mode validation time... */
9627 if (!dce8_average_bandwidth_vs_dram_bandwidth_for_display(&wm_low
) ||
9628 !dce8_average_bandwidth_vs_available_bandwidth(&wm_low
) ||
9629 !dce8_check_latency_hiding(&wm_low
) ||
9630 (rdev
->disp_priority
== 2)) {
9631 DRM_DEBUG_KMS("force priority to high\n");
9636 wm_mask
= RREG32(DPG_WATERMARK_MASK_CONTROL
+ radeon_crtc
->crtc_offset
);
9638 tmp
&= ~LATENCY_WATERMARK_MASK(3);
9639 tmp
|= LATENCY_WATERMARK_MASK(1);
9640 WREG32(DPG_WATERMARK_MASK_CONTROL
+ radeon_crtc
->crtc_offset
, tmp
);
9641 WREG32(DPG_PIPE_LATENCY_CONTROL
+ radeon_crtc
->crtc_offset
,
9642 (LATENCY_LOW_WATERMARK(latency_watermark_a
) |
9643 LATENCY_HIGH_WATERMARK(line_time
)));
9645 tmp
= RREG32(DPG_WATERMARK_MASK_CONTROL
+ radeon_crtc
->crtc_offset
);
9646 tmp
&= ~LATENCY_WATERMARK_MASK(3);
9647 tmp
|= LATENCY_WATERMARK_MASK(2);
9648 WREG32(DPG_WATERMARK_MASK_CONTROL
+ radeon_crtc
->crtc_offset
, tmp
);
9649 WREG32(DPG_PIPE_LATENCY_CONTROL
+ radeon_crtc
->crtc_offset
,
9650 (LATENCY_LOW_WATERMARK(latency_watermark_b
) |
9651 LATENCY_HIGH_WATERMARK(line_time
)));
9652 /* restore original selection */
9653 WREG32(DPG_WATERMARK_MASK_CONTROL
+ radeon_crtc
->crtc_offset
, wm_mask
);
9655 /* save values for DPM */
9656 radeon_crtc
->line_time
= line_time
;
9657 radeon_crtc
->wm_high
= latency_watermark_a
;
9658 radeon_crtc
->wm_low
= latency_watermark_b
;
9662 * dce8_bandwidth_update - program display watermarks
9664 * @rdev: radeon_device pointer
9666 * Calculate and program the display watermarks and line
9667 * buffer allocation (CIK).
9669 void dce8_bandwidth_update(struct radeon_device
*rdev
)
9671 struct drm_display_mode
*mode
= NULL
;
9672 u32 num_heads
= 0, lb_size
;
9675 if (!rdev
->mode_info
.mode_config_initialized
)
9678 radeon_update_display_priority(rdev
);
9680 for (i
= 0; i
< rdev
->num_crtc
; i
++) {
9681 if (rdev
->mode_info
.crtcs
[i
]->base
.enabled
)
9684 for (i
= 0; i
< rdev
->num_crtc
; i
++) {
9685 mode
= &rdev
->mode_info
.crtcs
[i
]->base
.mode
;
9686 lb_size
= dce8_line_buffer_adjust(rdev
, rdev
->mode_info
.crtcs
[i
], mode
);
9687 dce8_program_watermarks(rdev
, rdev
->mode_info
.crtcs
[i
], lb_size
, num_heads
);
9692 * cik_get_gpu_clock_counter - return GPU clock counter snapshot
9694 * @rdev: radeon_device pointer
9696 * Fetches a GPU clock counter snapshot (SI).
9697 * Returns the 64 bit clock counter snapshot.
9699 uint64_t cik_get_gpu_clock_counter(struct radeon_device
*rdev
)
9703 mutex_lock(&rdev
->gpu_clock_mutex
);
9704 WREG32(RLC_CAPTURE_GPU_CLOCK_COUNT
, 1);
9705 clock
= (uint64_t)RREG32(RLC_GPU_CLOCK_COUNT_LSB
) |
9706 ((uint64_t)RREG32(RLC_GPU_CLOCK_COUNT_MSB
) << 32ULL);
9707 mutex_unlock(&rdev
->gpu_clock_mutex
);
9711 static int cik_set_uvd_clock(struct radeon_device
*rdev
, u32 clock
,
9712 u32 cntl_reg
, u32 status_reg
)
9715 struct atom_clock_dividers dividers
;
9718 r
= radeon_atom_get_clock_dividers(rdev
, COMPUTE_GPUCLK_INPUT_FLAG_DEFAULT_GPUCLK
,
9719 clock
, false, ÷rs
);
9723 tmp
= RREG32_SMC(cntl_reg
);
9724 tmp
&= ~(DCLK_DIR_CNTL_EN
|DCLK_DIVIDER_MASK
);
9725 tmp
|= dividers
.post_divider
;
9726 WREG32_SMC(cntl_reg
, tmp
);
9728 for (i
= 0; i
< 100; i
++) {
9729 if (RREG32_SMC(status_reg
) & DCLK_STATUS
)
9739 int cik_set_uvd_clocks(struct radeon_device
*rdev
, u32 vclk
, u32 dclk
)
9743 r
= cik_set_uvd_clock(rdev
, vclk
, CG_VCLK_CNTL
, CG_VCLK_STATUS
);
9747 r
= cik_set_uvd_clock(rdev
, dclk
, CG_DCLK_CNTL
, CG_DCLK_STATUS
);
9751 int cik_set_vce_clocks(struct radeon_device
*rdev
, u32 evclk
, u32 ecclk
)
9754 struct atom_clock_dividers dividers
;
9757 r
= radeon_atom_get_clock_dividers(rdev
, COMPUTE_GPUCLK_INPUT_FLAG_DEFAULT_GPUCLK
,
9758 ecclk
, false, ÷rs
);
9762 for (i
= 0; i
< 100; i
++) {
9763 if (RREG32_SMC(CG_ECLK_STATUS
) & ECLK_STATUS
)
9770 tmp
= RREG32_SMC(CG_ECLK_CNTL
);
9771 tmp
&= ~(ECLK_DIR_CNTL_EN
|ECLK_DIVIDER_MASK
);
9772 tmp
|= dividers
.post_divider
;
9773 WREG32_SMC(CG_ECLK_CNTL
, tmp
);
9775 for (i
= 0; i
< 100; i
++) {
9776 if (RREG32_SMC(CG_ECLK_STATUS
) & ECLK_STATUS
)
9786 static void cik_pcie_gen3_enable(struct radeon_device
*rdev
)
9788 struct pci_dev
*root
= rdev
->pdev
->bus
->self
;
9789 int bridge_pos
, gpu_pos
;
9790 u32 speed_cntl
, mask
, current_data_rate
;
9794 if (pci_is_root_bus(rdev
->pdev
->bus
))
9797 if (radeon_pcie_gen2
== 0)
9800 if (rdev
->flags
& RADEON_IS_IGP
)
9803 if (!(rdev
->flags
& RADEON_IS_PCIE
))
9806 ret
= drm_pcie_get_speed_cap_mask(rdev
->ddev
, &mask
);
9810 if (!(mask
& (DRM_PCIE_SPEED_50
| DRM_PCIE_SPEED_80
)))
9813 speed_cntl
= RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL
);
9814 current_data_rate
= (speed_cntl
& LC_CURRENT_DATA_RATE_MASK
) >>
9815 LC_CURRENT_DATA_RATE_SHIFT
;
9816 if (mask
& DRM_PCIE_SPEED_80
) {
9817 if (current_data_rate
== 2) {
9818 DRM_INFO("PCIE gen 3 link speeds already enabled\n");
9821 DRM_INFO("enabling PCIE gen 3 link speeds, disable with radeon.pcie_gen2=0\n");
9822 } else if (mask
& DRM_PCIE_SPEED_50
) {
9823 if (current_data_rate
== 1) {
9824 DRM_INFO("PCIE gen 2 link speeds already enabled\n");
9827 DRM_INFO("enabling PCIE gen 2 link speeds, disable with radeon.pcie_gen2=0\n");
9830 bridge_pos
= pci_pcie_cap(root
);
9834 gpu_pos
= pci_pcie_cap(rdev
->pdev
);
9838 if (mask
& DRM_PCIE_SPEED_80
) {
9839 /* re-try equalization if gen3 is not already enabled */
9840 if (current_data_rate
!= 2) {
9841 u16 bridge_cfg
, gpu_cfg
;
9842 u16 bridge_cfg2
, gpu_cfg2
;
9843 u32 max_lw
, current_lw
, tmp
;
9845 pci_read_config_word(root
, bridge_pos
+ PCI_EXP_LNKCTL
, &bridge_cfg
);
9846 pci_read_config_word(rdev
->pdev
, gpu_pos
+ PCI_EXP_LNKCTL
, &gpu_cfg
);
9848 tmp16
= bridge_cfg
| PCI_EXP_LNKCTL_HAWD
;
9849 pci_write_config_word(root
, bridge_pos
+ PCI_EXP_LNKCTL
, tmp16
);
9851 tmp16
= gpu_cfg
| PCI_EXP_LNKCTL_HAWD
;
9852 pci_write_config_word(rdev
->pdev
, gpu_pos
+ PCI_EXP_LNKCTL
, tmp16
);
9854 tmp
= RREG32_PCIE_PORT(PCIE_LC_STATUS1
);
9855 max_lw
= (tmp
& LC_DETECTED_LINK_WIDTH_MASK
) >> LC_DETECTED_LINK_WIDTH_SHIFT
;
9856 current_lw
= (tmp
& LC_OPERATING_LINK_WIDTH_MASK
) >> LC_OPERATING_LINK_WIDTH_SHIFT
;
9858 if (current_lw
< max_lw
) {
9859 tmp
= RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL
);
9860 if (tmp
& LC_RENEGOTIATION_SUPPORT
) {
9861 tmp
&= ~(LC_LINK_WIDTH_MASK
| LC_UPCONFIGURE_DIS
);
9862 tmp
|= (max_lw
<< LC_LINK_WIDTH_SHIFT
);
9863 tmp
|= LC_UPCONFIGURE_SUPPORT
| LC_RENEGOTIATE_EN
| LC_RECONFIG_NOW
;
9864 WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL
, tmp
);
9868 for (i
= 0; i
< 10; i
++) {
9870 pci_read_config_word(rdev
->pdev
, gpu_pos
+ PCI_EXP_DEVSTA
, &tmp16
);
9871 if (tmp16
& PCI_EXP_DEVSTA_TRPND
)
9874 pci_read_config_word(root
, bridge_pos
+ PCI_EXP_LNKCTL
, &bridge_cfg
);
9875 pci_read_config_word(rdev
->pdev
, gpu_pos
+ PCI_EXP_LNKCTL
, &gpu_cfg
);
9877 pci_read_config_word(root
, bridge_pos
+ PCI_EXP_LNKCTL2
, &bridge_cfg2
);
9878 pci_read_config_word(rdev
->pdev
, gpu_pos
+ PCI_EXP_LNKCTL2
, &gpu_cfg2
);
9880 tmp
= RREG32_PCIE_PORT(PCIE_LC_CNTL4
);
9881 tmp
|= LC_SET_QUIESCE
;
9882 WREG32_PCIE_PORT(PCIE_LC_CNTL4
, tmp
);
9884 tmp
= RREG32_PCIE_PORT(PCIE_LC_CNTL4
);
9886 WREG32_PCIE_PORT(PCIE_LC_CNTL4
, tmp
);
9891 pci_read_config_word(root
, bridge_pos
+ PCI_EXP_LNKCTL
, &tmp16
);
9892 tmp16
&= ~PCI_EXP_LNKCTL_HAWD
;
9893 tmp16
|= (bridge_cfg
& PCI_EXP_LNKCTL_HAWD
);
9894 pci_write_config_word(root
, bridge_pos
+ PCI_EXP_LNKCTL
, tmp16
);
9896 pci_read_config_word(rdev
->pdev
, gpu_pos
+ PCI_EXP_LNKCTL
, &tmp16
);
9897 tmp16
&= ~PCI_EXP_LNKCTL_HAWD
;
9898 tmp16
|= (gpu_cfg
& PCI_EXP_LNKCTL_HAWD
);
9899 pci_write_config_word(rdev
->pdev
, gpu_pos
+ PCI_EXP_LNKCTL
, tmp16
);
9902 pci_read_config_word(root
, bridge_pos
+ PCI_EXP_LNKCTL2
, &tmp16
);
9903 tmp16
&= ~((1 << 4) | (7 << 9));
9904 tmp16
|= (bridge_cfg2
& ((1 << 4) | (7 << 9)));
9905 pci_write_config_word(root
, bridge_pos
+ PCI_EXP_LNKCTL2
, tmp16
);
9907 pci_read_config_word(rdev
->pdev
, gpu_pos
+ PCI_EXP_LNKCTL2
, &tmp16
);
9908 tmp16
&= ~((1 << 4) | (7 << 9));
9909 tmp16
|= (gpu_cfg2
& ((1 << 4) | (7 << 9)));
9910 pci_write_config_word(rdev
->pdev
, gpu_pos
+ PCI_EXP_LNKCTL2
, tmp16
);
9912 tmp
= RREG32_PCIE_PORT(PCIE_LC_CNTL4
);
9913 tmp
&= ~LC_SET_QUIESCE
;
9914 WREG32_PCIE_PORT(PCIE_LC_CNTL4
, tmp
);
9919 /* set the link speed */
9920 speed_cntl
|= LC_FORCE_EN_SW_SPEED_CHANGE
| LC_FORCE_DIS_HW_SPEED_CHANGE
;
9921 speed_cntl
&= ~LC_FORCE_DIS_SW_SPEED_CHANGE
;
9922 WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL
, speed_cntl
);
9924 pci_read_config_word(rdev
->pdev
, gpu_pos
+ PCI_EXP_LNKCTL2
, &tmp16
);
9926 if (mask
& DRM_PCIE_SPEED_80
)
9927 tmp16
|= 3; /* gen3 */
9928 else if (mask
& DRM_PCIE_SPEED_50
)
9929 tmp16
|= 2; /* gen2 */
9931 tmp16
|= 1; /* gen1 */
9932 pci_write_config_word(rdev
->pdev
, gpu_pos
+ PCI_EXP_LNKCTL2
, tmp16
);
9934 speed_cntl
= RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL
);
9935 speed_cntl
|= LC_INITIATE_LINK_SPEED_CHANGE
;
9936 WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL
, speed_cntl
);
9938 for (i
= 0; i
< rdev
->usec_timeout
; i
++) {
9939 speed_cntl
= RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL
);
9940 if ((speed_cntl
& LC_INITIATE_LINK_SPEED_CHANGE
) == 0)
9946 static void cik_program_aspm(struct radeon_device
*rdev
)
9949 bool disable_l0s
= false, disable_l1
= false, disable_plloff_in_l1
= false;
9950 bool disable_clkreq
= false;
9952 if (radeon_aspm
== 0)
9955 /* XXX double check IGPs */
9956 if (rdev
->flags
& RADEON_IS_IGP
)
9959 if (!(rdev
->flags
& RADEON_IS_PCIE
))
9962 orig
= data
= RREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL
);
9963 data
&= ~LC_XMIT_N_FTS_MASK
;
9964 data
|= LC_XMIT_N_FTS(0x24) | LC_XMIT_N_FTS_OVERRIDE_EN
;
9966 WREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL
, data
);
9968 orig
= data
= RREG32_PCIE_PORT(PCIE_LC_CNTL3
);
9969 data
|= LC_GO_TO_RECOVERY
;
9971 WREG32_PCIE_PORT(PCIE_LC_CNTL3
, data
);
9973 orig
= data
= RREG32_PCIE_PORT(PCIE_P_CNTL
);
9974 data
|= P_IGNORE_EDB_ERR
;
9976 WREG32_PCIE_PORT(PCIE_P_CNTL
, data
);
9978 orig
= data
= RREG32_PCIE_PORT(PCIE_LC_CNTL
);
9979 data
&= ~(LC_L0S_INACTIVITY_MASK
| LC_L1_INACTIVITY_MASK
);
9980 data
|= LC_PMI_TO_L1_DIS
;
9982 data
|= LC_L0S_INACTIVITY(7);
9985 data
|= LC_L1_INACTIVITY(7);
9986 data
&= ~LC_PMI_TO_L1_DIS
;
9988 WREG32_PCIE_PORT(PCIE_LC_CNTL
, data
);
9990 if (!disable_plloff_in_l1
) {
9991 bool clk_req_support
;
9993 orig
= data
= RREG32_PCIE_PORT(PB0_PIF_PWRDOWN_0
);
9994 data
&= ~(PLL_POWER_STATE_IN_OFF_0_MASK
| PLL_POWER_STATE_IN_TXS2_0_MASK
);
9995 data
|= PLL_POWER_STATE_IN_OFF_0(7) | PLL_POWER_STATE_IN_TXS2_0(7);
9997 WREG32_PCIE_PORT(PB0_PIF_PWRDOWN_0
, data
);
9999 orig
= data
= RREG32_PCIE_PORT(PB0_PIF_PWRDOWN_1
);
10000 data
&= ~(PLL_POWER_STATE_IN_OFF_1_MASK
| PLL_POWER_STATE_IN_TXS2_1_MASK
);
10001 data
|= PLL_POWER_STATE_IN_OFF_1(7) | PLL_POWER_STATE_IN_TXS2_1(7);
10003 WREG32_PCIE_PORT(PB0_PIF_PWRDOWN_1
, data
);
10005 orig
= data
= RREG32_PCIE_PORT(PB1_PIF_PWRDOWN_0
);
10006 data
&= ~(PLL_POWER_STATE_IN_OFF_0_MASK
| PLL_POWER_STATE_IN_TXS2_0_MASK
);
10007 data
|= PLL_POWER_STATE_IN_OFF_0(7) | PLL_POWER_STATE_IN_TXS2_0(7);
10009 WREG32_PCIE_PORT(PB1_PIF_PWRDOWN_0
, data
);
10011 orig
= data
= RREG32_PCIE_PORT(PB1_PIF_PWRDOWN_1
);
10012 data
&= ~(PLL_POWER_STATE_IN_OFF_1_MASK
| PLL_POWER_STATE_IN_TXS2_1_MASK
);
10013 data
|= PLL_POWER_STATE_IN_OFF_1(7) | PLL_POWER_STATE_IN_TXS2_1(7);
10015 WREG32_PCIE_PORT(PB1_PIF_PWRDOWN_1
, data
);
10017 orig
= data
= RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL
);
10018 data
&= ~LC_DYN_LANES_PWR_STATE_MASK
;
10019 data
|= LC_DYN_LANES_PWR_STATE(3);
10021 WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL
, data
);
10023 if (!disable_clkreq
&&
10024 !pci_is_root_bus(rdev
->pdev
->bus
)) {
10025 struct pci_dev
*root
= rdev
->pdev
->bus
->self
;
10028 clk_req_support
= false;
10029 pcie_capability_read_dword(root
, PCI_EXP_LNKCAP
, &lnkcap
);
10030 if (lnkcap
& PCI_EXP_LNKCAP_CLKPM
)
10031 clk_req_support
= true;
10033 clk_req_support
= false;
10036 if (clk_req_support
) {
10037 orig
= data
= RREG32_PCIE_PORT(PCIE_LC_CNTL2
);
10038 data
|= LC_ALLOW_PDWN_IN_L1
| LC_ALLOW_PDWN_IN_L23
;
10040 WREG32_PCIE_PORT(PCIE_LC_CNTL2
, data
);
10042 orig
= data
= RREG32_SMC(THM_CLK_CNTL
);
10043 data
&= ~(CMON_CLK_SEL_MASK
| TMON_CLK_SEL_MASK
);
10044 data
|= CMON_CLK_SEL(1) | TMON_CLK_SEL(1);
10046 WREG32_SMC(THM_CLK_CNTL
, data
);
10048 orig
= data
= RREG32_SMC(MISC_CLK_CTRL
);
10049 data
&= ~(DEEP_SLEEP_CLK_SEL_MASK
| ZCLK_SEL_MASK
);
10050 data
|= DEEP_SLEEP_CLK_SEL(1) | ZCLK_SEL(1);
10052 WREG32_SMC(MISC_CLK_CTRL
, data
);
10054 orig
= data
= RREG32_SMC(CG_CLKPIN_CNTL
);
10055 data
&= ~BCLK_AS_XCLK
;
10057 WREG32_SMC(CG_CLKPIN_CNTL
, data
);
10059 orig
= data
= RREG32_SMC(CG_CLKPIN_CNTL_2
);
10060 data
&= ~FORCE_BIF_REFCLK_EN
;
10062 WREG32_SMC(CG_CLKPIN_CNTL_2
, data
);
10064 orig
= data
= RREG32_SMC(MPLL_BYPASSCLK_SEL
);
10065 data
&= ~MPLL_CLKOUT_SEL_MASK
;
10066 data
|= MPLL_CLKOUT_SEL(4);
10068 WREG32_SMC(MPLL_BYPASSCLK_SEL
, data
);
10073 WREG32_PCIE_PORT(PCIE_LC_CNTL
, data
);
10076 orig
= data
= RREG32_PCIE_PORT(PCIE_CNTL2
);
10077 data
|= SLV_MEM_LS_EN
| MST_MEM_LS_EN
| REPLAY_MEM_LS_EN
;
10079 WREG32_PCIE_PORT(PCIE_CNTL2
, data
);
10081 if (!disable_l0s
) {
10082 data
= RREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL
);
10083 if((data
& LC_N_FTS_MASK
) == LC_N_FTS_MASK
) {
10084 data
= RREG32_PCIE_PORT(PCIE_LC_STATUS1
);
10085 if ((data
& LC_REVERSE_XMIT
) && (data
& LC_REVERSE_RCVR
)) {
10086 orig
= data
= RREG32_PCIE_PORT(PCIE_LC_CNTL
);
10087 data
&= ~LC_L0S_INACTIVITY_MASK
;
10089 WREG32_PCIE_PORT(PCIE_LC_CNTL
, data
);