26 #include <linux/slab.h>
27 #include <linux/module.h>
36 #define SI_PFP_UCODE_SIZE 2144
37 #define SI_PM4_UCODE_SIZE 2144
38 #define SI_CE_UCODE_SIZE 2144
39 #define SI_RLC_UCODE_SIZE 2048
40 #define SI_MC_UCODE_SIZE 7769
77 actual_temp = temp & 0x1ff;
79 actual_temp = (actual_temp * 1000);
84 #define TAHITI_IO_MC_REGS_SIZE 36
87 {0x0000006f, 0x03044000},
88 {0x00000070, 0x0480c018},
89 {0x00000071, 0x00000040},
90 {0x00000072, 0x01000000},
91 {0x00000074, 0x000000ff},
92 {0x00000075, 0x00143400},
93 {0x00000076, 0x08ec0800},
94 {0x00000077, 0x040000cc},
95 {0x00000079, 0x00000000},
96 {0x0000007a, 0x21000409},
97 {0x0000007c, 0x00000000},
98 {0x0000007d, 0xe8000000},
99 {0x0000007e, 0x044408a8},
100 {0x0000007f, 0x00000003},
101 {0x00000080, 0x00000000},
102 {0x00000081, 0x01000000},
103 {0x00000082, 0x02000000},
104 {0x00000083, 0x00000000},
105 {0x00000084, 0xe3f3e4f4},
106 {0x00000085, 0x00052024},
107 {0x00000087, 0x00000000},
108 {0x00000088, 0x66036603},
109 {0x00000089, 0x01000000},
110 {0x0000008b, 0x1c0a0000},
111 {0x0000008c, 0xff010000},
112 {0x0000008e, 0xffffefff},
113 {0x0000008f, 0xfff3efff},
114 {0x00000090, 0xfff3efbf},
115 {0x00000094, 0x00101101},
116 {0x00000095, 0x00000fff},
117 {0x00000096, 0x00116fff},
118 {0x00000097, 0x60010000},
119 {0x00000098, 0x10010000},
120 {0x00000099, 0x00006000},
121 {0x0000009a, 0x00001000},
122 {0x0000009f, 0x00a77400}
126 {0x0000006f, 0x03044000},
127 {0x00000070, 0x0480c018},
128 {0x00000071, 0x00000040},
129 {0x00000072, 0x01000000},
130 {0x00000074, 0x000000ff},
131 {0x00000075, 0x00143400},
132 {0x00000076, 0x08ec0800},
133 {0x00000077, 0x040000cc},
134 {0x00000079, 0x00000000},
135 {0x0000007a, 0x21000409},
136 {0x0000007c, 0x00000000},
137 {0x0000007d, 0xe8000000},
138 {0x0000007e, 0x044408a8},
139 {0x0000007f, 0x00000003},
140 {0x00000080, 0x00000000},
141 {0x00000081, 0x01000000},
142 {0x00000082, 0x02000000},
143 {0x00000083, 0x00000000},
144 {0x00000084, 0xe3f3e4f4},
145 {0x00000085, 0x00052024},
146 {0x00000087, 0x00000000},
147 {0x00000088, 0x66036603},
148 {0x00000089, 0x01000000},
149 {0x0000008b, 0x1c0a0000},
150 {0x0000008c, 0xff010000},
151 {0x0000008e, 0xffffefff},
152 {0x0000008f, 0xfff3efff},
153 {0x00000090, 0xfff3efbf},
154 {0x00000094, 0x00101101},
155 {0x00000095, 0x00000fff},
156 {0x00000096, 0x00116fff},
157 {0x00000097, 0x60010000},
158 {0x00000098, 0x10010000},
159 {0x00000099, 0x00006000},
160 {0x0000009a, 0x00001000},
161 {0x0000009f, 0x00a47400}
165 {0x0000006f, 0x03044000},
166 {0x00000070, 0x0480c018},
167 {0x00000071, 0x00000040},
168 {0x00000072, 0x01000000},
169 {0x00000074, 0x000000ff},
170 {0x00000075, 0x00143400},
171 {0x00000076, 0x08ec0800},
172 {0x00000077, 0x040000cc},
173 {0x00000079, 0x00000000},
174 {0x0000007a, 0x21000409},
175 {0x0000007c, 0x00000000},
176 {0x0000007d, 0xe8000000},
177 {0x0000007e, 0x044408a8},
178 {0x0000007f, 0x00000003},
179 {0x00000080, 0x00000000},
180 {0x00000081, 0x01000000},
181 {0x00000082, 0x02000000},
182 {0x00000083, 0x00000000},
183 {0x00000084, 0xe3f3e4f4},
184 {0x00000085, 0x00052024},
185 {0x00000087, 0x00000000},
186 {0x00000088, 0x66036603},
187 {0x00000089, 0x01000000},
188 {0x0000008b, 0x1c0a0000},
189 {0x0000008c, 0xff010000},
190 {0x0000008e, 0xffffefff},
191 {0x0000008f, 0xfff3efff},
192 {0x00000090, 0xfff3efbf},
193 {0x00000094, 0x00101101},
194 {0x00000095, 0x00000fff},
195 {0x00000096, 0x00116fff},
196 {0x00000097, 0x60010000},
197 {0x00000098, 0x10010000},
198 {0x00000099, 0x00006000},
199 {0x0000009a, 0x00001000},
200 {0x0000009f, 0x00a37400}
209 int i, ucode_size, regs_size;
216 io_mc_regs = (
u32 *)&tahiti_io_mc_regs;
221 io_mc_regs = (
u32 *)&pitcairn_io_mc_regs;
227 io_mc_regs = (
u32 *)&verde_io_mc_regs;
246 for (i = 0; i < regs_size; i++) {
252 for (i = 0; i < ucode_size; i++)
282 const char *chip_name;
283 const char *rlc_chip_name;
284 size_t pfp_req_size, me_req_size, ce_req_size, rlc_req_size, mc_req_size;
290 pdev = platform_device_register_simple(
"radeon_cp", 0,
NULL, 0);
299 chip_name =
"TAHITI";
300 rlc_chip_name =
"TAHITI";
308 chip_name =
"PITCAIRN";
309 rlc_chip_name =
"PITCAIRN";
318 rlc_chip_name =
"VERDE";
328 DRM_INFO(
"Loading %s Microcode\n", chip_name);
330 snprintf(fw_name,
sizeof(fw_name),
"radeon/%s_pfp.bin", chip_name);
334 if (rdev->
pfp_fw->size != pfp_req_size) {
336 "si_cp: Bogus length %zu in firmware \"%s\"\n",
337 rdev->
pfp_fw->size, fw_name);
342 snprintf(fw_name,
sizeof(fw_name),
"radeon/%s_me.bin", chip_name);
346 if (rdev->
me_fw->size != me_req_size) {
348 "si_cp: Bogus length %zu in firmware \"%s\"\n",
349 rdev->
me_fw->size, fw_name);
353 snprintf(fw_name,
sizeof(fw_name),
"radeon/%s_ce.bin", chip_name);
357 if (rdev->
ce_fw->size != ce_req_size) {
359 "si_cp: Bogus length %zu in firmware \"%s\"\n",
360 rdev->
ce_fw->size, fw_name);
364 snprintf(fw_name,
sizeof(fw_name),
"radeon/%s_rlc.bin", rlc_chip_name);
368 if (rdev->
rlc_fw->size != rlc_req_size) {
370 "si_rlc: Bogus length %zu in firmware \"%s\"\n",
371 rdev->
rlc_fw->size, fw_name);
375 snprintf(fw_name,
sizeof(fw_name),
"radeon/%s_mc.bin", chip_name);
379 if (rdev->
mc_fw->size != mc_req_size) {
381 "si_mc: Bogus length %zu in firmware \"%s\"\n",
382 rdev->
mc_fw->size, fw_name);
392 "si_cp: Failed to load firmware \"%s\"\n",
428 if (radeon_crtc->
base.enabled && mode) {
439 if (radeon_crtc->
base.enabled && mode) {
505 yclk.
full = dfixed_div(yclk, a);
509 dram_efficiency.
full = dfixed_div(dram_efficiency, a);
525 yclk.
full = dfixed_div(yclk, a);
529 disp_dram_allocation.
full = dfixed_div(disp_dram_allocation, a);
545 sclk.
full = dfixed_div(sclk, a);
548 return_efficiency.
full = dfixed_div(return_efficiency, a);
571 disp_clk.
full = dfixed_div(disp_clk, a);
577 sclk.
full = dfixed_div(sclk, a);
583 disp_clk_request_efficiency.
full = dfixed_div(disp_clk_request_efficiency, a);
596 u32 dram_bandwidth = dce6_dram_bandwidth(wm);
597 u32 data_return_bandwidth = dce6_data_return_bandwidth(wm);
598 u32 dmif_req_bandwidth = dce6_dmif_request_bandwidth(wm);
600 return min(dram_bandwidth,
min(data_return_bandwidth, dmif_req_bandwidth));
617 line_time.
full = dfixed_div(line_time, a);
622 bandwidth.
full = dfixed_div(bandwidth, line_time);
630 u32 mc_latency = 2000;
631 u32 available_bandwidth = dce6_available_bandwidth(wm);
632 u32 worst_chunk_return_time = (512 * 8 * 1000) / available_bandwidth;
633 u32 cursor_line_pair_return_time = (128 * 4 * 1000) / available_bandwidth;
635 u32 other_heads_data_return_time = ((wm->
num_heads + 1) * worst_chunk_return_time) +
636 (wm->
num_heads * cursor_line_pair_return_time);
637 u32 latency = mc_latency + other_heads_data_return_time + dc_latency;
638 u32 max_src_lines_per_dst_line, lb_fill_bw, line_fill_time;
639 u32 tmp, dmif_size = 12288;
651 max_src_lines_per_dst_line = 4;
653 max_src_lines_per_dst_line = 2;
657 a.
full = dfixed_div(a, b);
661 b.
full = dfixed_div(b, c);
664 b.
full = dfixed_div(c, b);
670 b.
full = dfixed_div(c, b);
679 b.
full = dfixed_div(c, b);
680 a.
full = dfixed_div(a, b);
683 if (line_fill_time < wm->active_time)
686 return latency + (line_fill_time - wm->
active_time);
690 static bool dce6_average_bandwidth_vs_dram_bandwidth_for_display(
struct dce6_wm_params *wm)
692 if (dce6_average_bandwidth(wm) <=
693 (dce6_dram_bandwidth_for_display(wm) / wm->
num_heads))
699 static bool dce6_average_bandwidth_vs_available_bandwidth(
struct dce6_wm_params *wm)
701 if (dce6_average_bandwidth(wm) <=
702 (dce6_available_bandwidth(wm) / wm->
num_heads))
712 u32 latency_tolerant_lines;
718 latency_tolerant_lines = 1;
720 if (lb_partitions <= (wm->
vtaps + 1))
721 latency_tolerant_lines = 1;
723 latency_tolerant_lines = 2;
726 latency_hiding = (latency_tolerant_lines * line_time + wm->
blank_time);
728 if (dce6_latency_watermark(wm) <= latency_hiding)
734 static void dce6_program_watermarks(
struct radeon_device *rdev,
735 struct radeon_crtc *radeon_crtc,
736 u32 lb_size,
u32 num_heads)
742 u32 latency_watermark_a = 0, latency_watermark_b = 0;
743 u32 priority_a_mark = 0, priority_b_mark = 0;
749 if (radeon_crtc->
base.enabled && num_heads && mode) {
750 pixel_period = 1000000 / (
u32)mode->
clock;
755 wm.
yclk = rdev->
pm.current_mclk * 10;
756 wm.
sclk = rdev->
pm.current_sclk * 10;
764 wm.
vsc = radeon_crtc->
vsc;
777 latency_watermark_a =
min(dce6_latency_watermark(&wm), (
u32)65535);
780 latency_watermark_b =
min(dce6_latency_watermark(&wm), (
u32)65535);
784 if (!dce6_average_bandwidth_vs_dram_bandwidth_for_display(&wm) ||
785 !dce6_average_bandwidth_vs_available_bandwidth(&wm) ||
786 !dce6_check_latency_hiding(&wm) ||
788 DRM_DEBUG_KMS(
"force priority to high\n");
795 b.
full = dfixed_div(b, a);
799 c.
full = dfixed_div(c, a);
801 c.
full = dfixed_div(c, a);
807 b.
full = dfixed_div(b, a);
811 c.
full = dfixed_div(c, a);
813 c.
full = dfixed_div(c, a);
848 u32 num_heads = 0, lb_size;
853 for (i = 0; i < rdev->
num_crtc; i++) {
854 if (rdev->
mode_info.crtcs[i]->base.enabled)
857 for (i = 0; i < rdev->
num_crtc; i += 2) {
859 mode1 = &rdev->
mode_info.crtcs[i+1]->base.mode;
860 lb_size = dce6_line_buffer_adjust(rdev, rdev->
mode_info.crtcs[i], mode0, mode1);
861 dce6_program_watermarks(rdev, rdev->
mode_info.crtcs[i], lb_size, num_heads);
862 lb_size = dce6_line_buffer_adjust(rdev, rdev->
mode_info.crtcs[i+1], mode1, mode0);
863 dce6_program_watermarks(rdev, rdev->
mode_info.crtcs[i+1], lb_size, num_heads);
870 static void si_tiling_mode_table_init(
struct radeon_device *rdev)
872 const u32 num_tile_mode_states = 32;
873 u32 reg_offset, gb_tile_moden, split_equal_to_row_size;
875 switch (rdev->
config.
si.mem_row_size_in_kb) {
890 for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++) {
891 switch (reg_offset) {
1129 for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++) {
1130 switch (reg_offset) {
1368 DRM_ERROR(
"unknown asic: 0x%x\n", rdev->
family);
1376 if ((se_num == 0xffffffff) && (sh_num == 0xffffffff))
1378 else if (se_num == 0xffffffff)
1380 else if (sh_num == 0xffffffff)
1411 mask = si_create_bitmask(cu_per_sh);
1413 return ~data &
mask;
1417 u32 se_num,
u32 sh_per_se,
1423 for (i = 0; i < se_num; i++) {
1424 for (j = 0; j < sh_per_se; j++) {
1425 si_select_se_sh(rdev, i, j);
1427 active_cu = si_get_cu_enabled(rdev, cu_per_sh);
1430 for (k = 0; k < 16; k++) {
1432 if (active_cu & mask) {
1440 si_select_se_sh(rdev, 0xffffffff, 0xffffffff);
1444 u32 max_rb_num,
u32 se_num,
1458 mask = si_create_bitmask(max_rb_num / se_num / sh_per_se);
1464 u32 se_num,
u32 sh_per_se,
1469 u32 disabled_rbs = 0;
1470 u32 enabled_rbs = 0;
1472 for (i = 0; i < se_num; i++) {
1473 for (j = 0; j < sh_per_se; j++) {
1474 si_select_se_sh(rdev, i, j);
1475 data = si_get_rb_disabled(rdev, max_rb_num, se_num, sh_per_se);
1479 si_select_se_sh(rdev, 0xffffffff, 0xffffffff);
1482 for (i = 0; i < max_rb_num; i++) {
1483 if (!(disabled_rbs & mask))
1484 enabled_rbs |=
mask;
1488 for (i = 0; i < se_num; i++) {
1489 si_select_se_sh(rdev, i, 0xffffffff);
1491 for (j = 0; j < sh_per_se; j++) {
1492 switch (enabled_rbs & 3) {
1508 si_select_se_sh(rdev, 0xffffffff, 0xffffffff);
1513 u32 gb_addr_config = 0;
1514 u32 mc_shared_chmap, mc_arb_ramcfg;
1516 u32 hdp_host_path_cntl;
1522 rdev->
config.
si.max_shader_engines = 2;
1523 rdev->
config.
si.max_tile_pipes = 12;
1526 rdev->
config.
si.max_backends_per_se = 4;
1527 rdev->
config.
si.max_texture_channel_caches = 12;
1529 rdev->
config.
si.max_gs_threads = 32;
1530 rdev->
config.
si.max_hw_contexts = 8;
1532 rdev->
config.
si.sc_prim_fifo_size_frontend = 0x20;
1533 rdev->
config.
si.sc_prim_fifo_size_backend = 0x100;
1534 rdev->
config.
si.sc_hiz_tile_fifo_size = 0x30;
1535 rdev->
config.
si.sc_earlyz_tile_fifo_size = 0x130;
1539 rdev->
config.
si.max_shader_engines = 2;
1540 rdev->
config.
si.max_tile_pipes = 8;
1543 rdev->
config.
si.max_backends_per_se = 4;
1544 rdev->
config.
si.max_texture_channel_caches = 8;
1546 rdev->
config.
si.max_gs_threads = 32;
1547 rdev->
config.
si.max_hw_contexts = 8;
1549 rdev->
config.
si.sc_prim_fifo_size_frontend = 0x20;
1550 rdev->
config.
si.sc_prim_fifo_size_backend = 0x100;
1551 rdev->
config.
si.sc_hiz_tile_fifo_size = 0x30;
1552 rdev->
config.
si.sc_earlyz_tile_fifo_size = 0x130;
1557 rdev->
config.
si.max_shader_engines = 1;
1558 rdev->
config.
si.max_tile_pipes = 4;
1561 rdev->
config.
si.max_backends_per_se = 4;
1562 rdev->
config.
si.max_texture_channel_caches = 4;
1564 rdev->
config.
si.max_gs_threads = 32;
1565 rdev->
config.
si.max_hw_contexts = 8;
1567 rdev->
config.
si.sc_prim_fifo_size_frontend = 0x20;
1568 rdev->
config.
si.sc_prim_fifo_size_backend = 0x40;
1569 rdev->
config.
si.sc_hiz_tile_fifo_size = 0x30;
1570 rdev->
config.
si.sc_earlyz_tile_fifo_size = 0x130;
1576 for (i = 0, j = 0; i < 32; i++, j += 0x18) {
1577 WREG32((0x2c14 + j), 0x00000000);
1578 WREG32((0x2c18 + j), 0x00000000);
1579 WREG32((0x2c1c + j), 0x00000000);
1580 WREG32((0x2c20 + j), 0x00000000);
1581 WREG32((0x2c24 + j), 0x00000000);
1594 rdev->
config.
si.mem_max_burst_length_bytes = 256;
1596 rdev->
config.
si.mem_row_size_in_kb = (4 * (1 << (8 +
tmp))) / 1024;
1597 if (rdev->
config.
si.mem_row_size_in_kb > 4)
1598 rdev->
config.
si.mem_row_size_in_kb = 4;
1600 rdev->
config.
si.shader_engine_tile_size = 32;
1602 rdev->
config.
si.multi_gpu_tile_size = 64;
1606 switch (rdev->
config.
si.mem_row_size_in_kb) {
1627 switch (rdev->
config.
si.num_tile_pipes) {
1629 rdev->
config.
si.tile_config |= (0 << 0);
1632 rdev->
config.
si.tile_config |= (1 << 0);
1635 rdev->
config.
si.tile_config |= (2 << 0);
1640 rdev->
config.
si.tile_config |= (3 << 0);
1645 rdev->
config.
si.tile_config |= 0 << 4;
1648 rdev->
config.
si.tile_config |= 1 << 4;
1652 rdev->
config.
si.tile_config |= 2 << 4;
1664 si_tiling_mode_table_init(rdev);
1666 si_setup_rb(rdev, rdev->
config.
si.max_shader_engines,
1668 rdev->
config.
si.max_backends_per_se);
1670 si_setup_spi(rdev, rdev->
config.
si.max_shader_engines,
1735 for (i = 0; i < rdev->
scratch.num_reg; i++) {
1785 next_rptr = ring->
wptr + 3 + 4 + 8;
1790 }
else if (rdev->
wb.enabled) {
1791 next_rptr = ring->
wptr + 5 + 4 + 8;
1810 (ib->
vm ? (ib->
vm->id << 24) : 0));
1851 si_cp_enable(rdev,
false);
1888 DRM_ERROR(
"radeon: cp failed to lock ring (%d).\n", r);
1907 si_cp_enable(rdev,
true);
1911 DRM_ERROR(
"radeon: cp failed to lock ring (%d).\n", r);
1937 ring = &rdev->
ring[
i];
1953 si_cp_enable(rdev,
false);
2014 if (rdev->
wb.enabled)
2107 u32 grbm_status, grbm_status2;
2108 u32 grbm_status_se0, grbm_status_se1;
2145 dev_warn(rdev->
dev,
"Wait for MC idle timedout !\n");
2165 dev_info(rdev->
dev,
" GRBM_SOFT_RESET=0x%08X\n", grbm_reset);
2189 return si_gpu_soft_reset(rdev);
2200 for (i = 0, j = 0; i < 32; i++, j += 0x18) {
2201 WREG32((0x2c14 + j), 0x00000000);
2202 WREG32((0x2c18 + j), 0x00000000);
2203 WREG32((0x2c1c + j), 0x00000000);
2204 WREG32((0x2c20 + j), 0x00000000);
2205 WREG32((0x2c24 + j), 0x00000000);
2211 dev_warn(rdev->
dev,
"Wait for MC idle timedout !\n");
2217 rdev->
mc.vram_start >> 12);
2219 rdev->
mc.vram_end >> 12);
2222 tmp = ((rdev->
mc.vram_end >> 24) & 0xFFFF) << 16;
2223 tmp |= ((rdev->
mc.vram_start >> 24) & 0xFFFF);
2233 dev_warn(rdev->
dev,
"Wait for MC idle timedout !\n");
2247 dev_warn(rdev->
dev,
"limiting VRAM to PCI aperture size\n");
2252 dev_info(rdev->
dev,
"VRAM: %lluM 0x%016llX - 0x%016llX (%lluM used)\n",
2259 u64 size_af, size_bf;
2263 if (size_bf > size_af) {
2277 dev_info(rdev->
dev,
"GTT: %lluM 0x%016llX - 0x%016llX\n",
2281 static void si_vram_gtt_location(
struct radeon_device *rdev,
2290 si_vram_location(rdev, &rdev->
mc, 0);
2291 rdev->
mc.gtt_base_align = 0;
2292 si_gtt_location(rdev, mc);
2298 int chansize, numchan;
2301 rdev->
mc.vram_is_ddr =
true;
2341 rdev->
mc.vram_width = numchan * chansize;
2348 rdev->
mc.visible_vram_size = rdev->
mc.aper_size;
2349 si_vram_gtt_location(rdev, &rdev->
mc);
2372 dev_err(rdev->
dev,
"No VRAM object for PCIE GART.\n");
2417 for (i = 1; i < 16; i++) {
2420 rdev->
gart.table_addr >> 12);
2423 rdev->
gart.table_addr >> 12);
2434 DRM_INFO(
"PCIE GART of %uM enabled (table at 0x%016llX).\n",
2435 (
unsigned)(rdev->
mc.gtt_size >> 20),
2436 (
unsigned long long)rdev->
gart.table_addr);
2437 rdev->
gart.ready =
true;
2441 static void si_pcie_gart_disable(
struct radeon_device *rdev)
2462 si_pcie_gart_disable(rdev);
2468 static bool si_vm_reg_valid(
u32 reg)
2504 DRM_ERROR(
"Invalid register 0x%x in CS\n", reg);
2509 static int si_vm_packet3_ce_check(
struct radeon_device *rdev,
2525 DRM_ERROR(
"Invalid CE packet3: 0x%x\n", pkt->
opcode);
2531 static int si_vm_packet3_gfx_check(
struct radeon_device *rdev,
2536 u32 start_reg, end_reg,
reg,
i;
2586 if ((idx_value & 0xf00) == 0) {
2587 reg = ib[idx + 3] * 4;
2588 if (!si_vm_reg_valid(reg))
2593 if ((idx_value & 0xf00) == 0) {
2594 start_reg = ib[idx + 1] * 4;
2595 if (idx_value & 0x10000) {
2596 if (!si_vm_reg_valid(start_reg))
2599 for (i = 0; i < (pkt->
count - 2); i++) {
2600 reg = start_reg + (4 *
i);
2601 if (!si_vm_reg_valid(reg))
2608 if (idx_value & 0x100) {
2609 reg = ib[idx + 5] * 4;
2610 if (!si_vm_reg_valid(reg))
2615 if (idx_value & 0x2) {
2616 reg = ib[idx + 3] * 4;
2617 if (!si_vm_reg_valid(reg))
2623 end_reg = 4 * pkt->
count + start_reg - 4;
2627 DRM_ERROR(
"bad PACKET3_SET_CONFIG_REG\n");
2630 for (i = 0; i < pkt->
count; i++) {
2631 reg = start_reg + (4 *
i);
2632 if (!si_vm_reg_valid(reg))
2637 DRM_ERROR(
"Invalid GFX packet3: 0x%x\n", pkt->
opcode);
2643 static int si_vm_packet3_compute_check(
struct radeon_device *rdev,
2683 if ((idx_value & 0xf00) == 0) {
2684 reg = ib[idx + 3] * 4;
2685 if (!si_vm_reg_valid(reg))
2690 if ((idx_value & 0xf00) == 0) {
2691 start_reg = ib[idx + 1] * 4;
2692 if (idx_value & 0x10000) {
2693 if (!si_vm_reg_valid(start_reg))
2696 for (i = 0; i < (pkt->
count - 2); i++) {
2697 reg = start_reg + (4 *
i);
2698 if (!si_vm_reg_valid(reg))
2705 if (idx_value & 0x100) {
2706 reg = ib[idx + 5] * 4;
2707 if (!si_vm_reg_valid(reg))
2712 if (idx_value & 0x2) {
2713 reg = ib[idx + 3] * 4;
2714 if (!si_vm_reg_valid(reg))
2719 DRM_ERROR(
"Invalid Compute packet3: 0x%x\n", pkt->
opcode);
2738 dev_err(rdev->
dev,
"Packet0 not allowed!\n");
2747 ret = si_vm_packet3_ce_check(rdev, ib->
ptr, &pkt);
2751 ret = si_vm_packet3_gfx_check(rdev, ib->
ptr, &pkt);
2755 ret = si_vm_packet3_compute_check(rdev, ib->
ptr, &pkt);
2763 idx += pkt.
count + 2;
2772 }
while (idx < ib->length_dw);
2814 unsigned ndw = 2 + count * 2;
2823 for (; ndw > 2; ndw -= 2, --
count, pe += 8) {
2827 value &= 0xFFFFFFFFFFFFF000ULL;
2833 value |= r600_flags;
2891 if (rdev->
rlc.save_restore_obj) {
2894 dev_warn(rdev->
dev,
"(%d) reserve RLC sr bo failed\n", r);
2896 radeon_bo_unreserve(rdev->
rlc.save_restore_obj);
2899 rdev->
rlc.save_restore_obj =
NULL;
2903 if (rdev->
rlc.clear_state_obj) {
2906 dev_warn(rdev->
dev,
"(%d) reserve RLC c bo failed\n", r);
2908 radeon_bo_unreserve(rdev->
rlc.clear_state_obj);
2911 rdev->
rlc.clear_state_obj =
NULL;
2920 if (rdev->
rlc.save_restore_obj ==
NULL) {
2923 &rdev->
rlc.save_restore_obj);
2925 dev_warn(rdev->
dev,
"(%d) create RLC sr bo failed\n", r);
2936 &rdev->
rlc.save_restore_gpu_addr);
2937 radeon_bo_unreserve(rdev->
rlc.save_restore_obj);
2939 dev_warn(rdev->
dev,
"(%d) pin RLC sr bo failed\n", r);
2945 if (rdev->
rlc.clear_state_obj ==
NULL) {
2948 &rdev->
rlc.clear_state_obj);
2950 dev_warn(rdev->
dev,
"(%d) create RLC c bo failed\n", r);
2961 &rdev->
rlc.clear_state_gpu_addr);
2962 radeon_bo_unreserve(rdev->
rlc.clear_state_obj);
2964 dev_warn(rdev->
dev,
"(%d) pin RLC c bo failed\n", r);
3016 static void si_enable_interrupts(
struct radeon_device *rdev)
3025 rdev->
ih.enabled =
true;
3028 static void si_disable_interrupts(
struct radeon_device *rdev)
3040 rdev->
ih.enabled =
false;
3044 static void si_disable_interrupt_state(
struct radeon_device *rdev)
3095 u32 interrupt_cntl, ih_cntl, ih_rb_cntl;
3103 si_disable_interrupts(rdev);
3106 ret = si_rlc_resume(rdev);
3131 if (rdev->
wb.enabled)
3152 si_disable_interrupt_state(rdev);
3157 si_enable_interrupts(rdev);
3165 u32 cp_int_cntl1 = 0, cp_int_cntl2 = 0;
3166 u32 crtc1 = 0, crtc2 = 0, crtc3 = 0, crtc4 = 0, crtc5 = 0, crtc6 = 0;
3167 u32 hpd1, hpd2, hpd3, hpd4, hpd5, hpd6;
3168 u32 grbm_int_cntl = 0;
3169 u32 grph1 = 0, grph2 = 0, grph3 = 0, grph4 = 0, grph5 = 0, grph6 = 0;
3171 if (!rdev->
irq.installed) {
3172 WARN(1,
"Can't enable IRQ/MSI because no handler is installed\n");
3176 if (!rdev->
ih.enabled) {
3177 si_disable_interrupts(rdev);
3179 si_disable_interrupt_state(rdev);
3192 DRM_DEBUG(
"si_irq_set: sw int gfx\n");
3196 DRM_DEBUG(
"si_irq_set: sw int cp1\n");
3200 DRM_DEBUG(
"si_irq_set: sw int cp2\n");
3203 if (rdev->
irq.crtc_vblank_int[0] ||
3205 DRM_DEBUG(
"si_irq_set: vblank 0\n");
3208 if (rdev->
irq.crtc_vblank_int[1] ||
3210 DRM_DEBUG(
"si_irq_set: vblank 1\n");
3213 if (rdev->
irq.crtc_vblank_int[2] ||
3215 DRM_DEBUG(
"si_irq_set: vblank 2\n");
3218 if (rdev->
irq.crtc_vblank_int[3] ||
3220 DRM_DEBUG(
"si_irq_set: vblank 3\n");
3223 if (rdev->
irq.crtc_vblank_int[4] ||
3225 DRM_DEBUG(
"si_irq_set: vblank 4\n");
3228 if (rdev->
irq.crtc_vblank_int[5] ||
3230 DRM_DEBUG(
"si_irq_set: vblank 5\n");
3233 if (rdev->
irq.hpd[0]) {
3234 DRM_DEBUG(
"si_irq_set: hpd 1\n");
3237 if (rdev->
irq.hpd[1]) {
3238 DRM_DEBUG(
"si_irq_set: hpd 2\n");
3241 if (rdev->
irq.hpd[2]) {
3242 DRM_DEBUG(
"si_irq_set: hpd 3\n");
3245 if (rdev->
irq.hpd[3]) {
3246 DRM_DEBUG(
"si_irq_set: hpd 4\n");
3249 if (rdev->
irq.hpd[4]) {
3250 DRM_DEBUG(
"si_irq_set: hpd 5\n");
3253 if (rdev->
irq.hpd[5]) {
3254 DRM_DEBUG(
"si_irq_set: hpd 6\n");
3394 si_disable_interrupts(rdev);
3398 si_disable_interrupt_state(rdev);
3403 si_irq_disable(rdev);
3409 si_irq_suspend(rdev);
3417 if (rdev->
wb.enabled)
3427 dev_warn(rdev->
dev,
"IH ring buffer overflow (0x%08X, %d, %d)\n",
3428 wptr, rdev->
ih.rptr, (wptr + 16) + rdev->
ih.ptr_mask);
3429 rdev->
ih.rptr = (wptr + 16) & rdev->
ih.ptr_mask;
3434 return (wptr & rdev->
ih.ptr_mask);
3451 u32 src_id, src_data, ring_id;
3453 bool queue_hotplug =
false;
3458 wptr = si_get_ih_wptr(rdev);
3465 rptr = rdev->
ih.rptr;
3466 DRM_DEBUG(
"si_irq_process start: rptr %d, wptr %d\n", rptr, wptr);
3474 while (rptr != wptr) {
3476 ring_index = rptr / 4;
3478 src_data =
le32_to_cpu(rdev->
ih.ring[ring_index + 1]) & 0xfffffff;
3479 ring_id =
le32_to_cpu(rdev->
ih.ring[ring_index + 2]) & 0xff;
3486 if (rdev->
irq.crtc_vblank_int[0]) {
3488 rdev->
pm.vblank_sync =
true;
3494 DRM_DEBUG(
"IH: D1 vblank\n");
3500 DRM_DEBUG(
"IH: D1 vline\n");
3504 DRM_DEBUG(
"Unhandled interrupt: %d %d\n", src_id, src_data);
3512 if (rdev->
irq.crtc_vblank_int[1]) {
3514 rdev->
pm.vblank_sync =
true;
3520 DRM_DEBUG(
"IH: D2 vblank\n");
3526 DRM_DEBUG(
"IH: D2 vline\n");
3530 DRM_DEBUG(
"Unhandled interrupt: %d %d\n", src_id, src_data);
3538 if (rdev->
irq.crtc_vblank_int[2]) {
3540 rdev->
pm.vblank_sync =
true;
3546 DRM_DEBUG(
"IH: D3 vblank\n");
3552 DRM_DEBUG(
"IH: D3 vline\n");
3556 DRM_DEBUG(
"Unhandled interrupt: %d %d\n", src_id, src_data);
3564 if (rdev->
irq.crtc_vblank_int[3]) {
3566 rdev->
pm.vblank_sync =
true;
3572 DRM_DEBUG(
"IH: D4 vblank\n");
3578 DRM_DEBUG(
"IH: D4 vline\n");
3582 DRM_DEBUG(
"Unhandled interrupt: %d %d\n", src_id, src_data);
3590 if (rdev->
irq.crtc_vblank_int[4]) {
3592 rdev->
pm.vblank_sync =
true;
3598 DRM_DEBUG(
"IH: D5 vblank\n");
3604 DRM_DEBUG(
"IH: D5 vline\n");
3608 DRM_DEBUG(
"Unhandled interrupt: %d %d\n", src_id, src_data);
3616 if (rdev->
irq.crtc_vblank_int[5]) {
3618 rdev->
pm.vblank_sync =
true;
3624 DRM_DEBUG(
"IH: D6 vblank\n");
3630 DRM_DEBUG(
"IH: D6 vline\n");
3634 DRM_DEBUG(
"Unhandled interrupt: %d %d\n", src_id, src_data);
3643 queue_hotplug =
true;
3644 DRM_DEBUG(
"IH: HPD1\n");
3650 queue_hotplug =
true;
3651 DRM_DEBUG(
"IH: HPD2\n");
3657 queue_hotplug =
true;
3658 DRM_DEBUG(
"IH: HPD3\n");
3664 queue_hotplug =
true;
3665 DRM_DEBUG(
"IH: HPD4\n");
3671 queue_hotplug =
true;
3672 DRM_DEBUG(
"IH: HPD5\n");
3678 queue_hotplug =
true;
3679 DRM_DEBUG(
"IH: HPD6\n");
3683 DRM_DEBUG(
"Unhandled interrupt: %d %d\n", src_id, src_data);
3697 DRM_DEBUG(
"IH: CP EOP\n");
3711 DRM_DEBUG(
"IH: GUI idle\n");
3714 DRM_DEBUG(
"Unhandled interrupt: %d %d\n", src_id, src_data);
3720 rptr &= rdev->
ih.ptr_mask;
3729 wptr = si_get_ih_wptr(rdev);
3746 r = si_init_microcode(rdev);
3748 DRM_ERROR(
"Failed to load firmware!\n");
3753 r = si_mc_load_microcode(rdev);
3755 DRM_ERROR(
"Failed to load MC firmware!\n");
3763 si_mc_program(rdev);
3764 r = si_pcie_gart_enable(rdev);
3774 dev_warn(rdev->
dev,
"failed blitter (%d) falling back to memcpy\n", r);
3780 DRM_ERROR(
"Failed to init rlc BOs!\n");
3791 dev_err(rdev->
dev,
"failed initializing CP fences (%d).\n", r);
3797 dev_err(rdev->
dev,
"failed initializing CP fences (%d).\n", r);
3803 dev_err(rdev->
dev,
"failed initializing CP fences (%d).\n", r);
3808 r = si_irq_init(rdev);
3810 DRM_ERROR(
"radeon: IH init failed (%d).\n", r);
3837 r = si_cp_load_microcode(rdev);
3840 r = si_cp_resume(rdev);
3846 dev_err(rdev->
dev,
"IB initialization failed (%d).\n", r);
3852 dev_err(rdev->
dev,
"vm manager initialization failed (%d).\n", r);
3871 r = si_startup(rdev);
3873 DRM_ERROR(
"si startup failed on resume\n");
3884 si_cp_enable(rdev,
false);
3888 si_irq_suspend(rdev);
3890 si_pcie_gart_disable(rdev);
3912 dev_err(rdev->
dev,
"Expecting atombios for cayman GPU\n");
3922 dev_err(rdev->
dev,
"Card not posted and no BIOS - ignoring\n");
3925 DRM_INFO(
"GPU not posted. posting now...\n");
3929 si_scratch_init(rdev);
3941 r = si_mc_init(rdev);
3965 rdev->
ih.ring_obj =
NULL;
3973 r = si_startup(rdev);
3975 dev_err(rdev->
dev,
"disabling GPU acceleration\n");
3983 si_pcie_gart_fini(rdev);
3992 DRM_ERROR(
"radeon: MC ucode required for NI+.\n");
4011 si_pcie_gart_fini(rdev);