blob: 3f2cc9e2e8d9a9f4a629361a2ea545c5f1b61f2c [file] [log] [blame]
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001/*
2 * Copyright 2008 Advanced Micro Devices, Inc.
3 * Copyright 2008 Red Hat Inc.
4 * Copyright 2009 Jerome Glisse.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * Authors: Dave Airlie
25 * Alex Deucher
26 * Jerome Glisse
27 */
28#include <linux/seq_file.h>
29#include "drmP.h"
30#include "drm.h"
31#include "radeon_reg.h"
32#include "radeon.h"
Dave Airliee024e112009-06-24 09:48:08 +100033#include "radeon_drm.h"
Dave Airlie551ebd82009-09-01 15:25:57 +100034#include "r100_track.h"
Jerome Glisse3ce0a232009-09-08 10:10:24 +100035#include "r300d.h"
Jerome Glisseca6ffc62009-10-01 10:20:52 +020036#include "rv350d.h"
Dave Airlie50f15302009-08-21 13:21:01 +100037#include "r300_reg_safe.h"
38
Jerome Glisse207bf9e2009-09-30 15:35:32 +020039/* This files gather functions specifics to: r300,r350,rv350,rv370,rv380 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +020040
41/*
42 * rv370,rv380 PCIE GART
43 */
Jerome Glisse207bf9e2009-09-30 15:35:32 +020044static int rv370_debugfs_pcie_gart_info_init(struct radeon_device *rdev);
45
Jerome Glisse771fe6b2009-06-05 14:42:42 +020046void rv370_pcie_gart_tlb_flush(struct radeon_device *rdev)
47{
48 uint32_t tmp;
49 int i;
50
51 /* Workaround HW bug do flush 2 times */
52 for (i = 0; i < 2; i++) {
53 tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_CNTL);
54 WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL, tmp | RADEON_PCIE_TX_GART_INVALIDATE_TLB);
55 (void)RREG32_PCIE(RADEON_PCIE_TX_GART_CNTL);
56 WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL, tmp);
Jerome Glisse771fe6b2009-06-05 14:42:42 +020057 }
Dave Airliede1b2892009-08-12 18:43:14 +100058 mb();
Jerome Glisse771fe6b2009-06-05 14:42:42 +020059}
60
Jerome Glisse4aac0472009-09-14 18:29:49 +020061int rv370_pcie_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr)
62{
63 void __iomem *ptr = (void *)rdev->gart.table.vram.ptr;
64
65 if (i < 0 || i > rdev->gart.num_gpu_pages) {
66 return -EINVAL;
67 }
68 addr = (lower_32_bits(addr) >> 8) |
69 ((upper_32_bits(addr) & 0xff) << 24) |
70 0xc;
71 /* on x86 we want this to be CPU endian, on powerpc
72 * on powerpc without HW swappers, it'll get swapped on way
73 * into VRAM - so no need for cpu_to_le32 on VRAM tables */
74 writel(addr, ((void __iomem *)ptr) + (i * 4));
75 return 0;
76}
77
78int rv370_pcie_gart_init(struct radeon_device *rdev)
79{
80 int r;
81
82 if (rdev->gart.table.vram.robj) {
83 WARN(1, "RV370 PCIE GART already initialized.\n");
84 return 0;
85 }
86 /* Initialize common gart structure */
87 r = radeon_gart_init(rdev);
88 if (r)
89 return r;
90 r = rv370_debugfs_pcie_gart_info_init(rdev);
91 if (r)
92 DRM_ERROR("Failed to register debugfs file for PCIE gart !\n");
93 rdev->gart.table_size = rdev->gart.num_gpu_pages * 4;
94 rdev->asic->gart_tlb_flush = &rv370_pcie_gart_tlb_flush;
95 rdev->asic->gart_set_page = &rv370_pcie_gart_set_page;
96 return radeon_gart_table_vram_alloc(rdev);
97}
98
Jerome Glisse771fe6b2009-06-05 14:42:42 +020099int rv370_pcie_gart_enable(struct radeon_device *rdev)
100{
101 uint32_t table_addr;
102 uint32_t tmp;
103 int r;
104
Jerome Glisse4aac0472009-09-14 18:29:49 +0200105 if (rdev->gart.table.vram.robj == NULL) {
106 dev_err(rdev->dev, "No VRAM object for PCIE GART.\n");
107 return -EINVAL;
108 }
109 r = radeon_gart_table_vram_pin(rdev);
110 if (r)
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200111 return r;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200112 /* discard memory request outside of configured range */
113 tmp = RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_DISCARD;
114 WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL, tmp);
115 WREG32_PCIE(RADEON_PCIE_TX_GART_START_LO, rdev->mc.gtt_location);
Matt Turnera77f1712009-10-14 00:34:41 -0400116 tmp = rdev->mc.gtt_location + rdev->mc.gtt_size - RADEON_GPU_PAGE_SIZE;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200117 WREG32_PCIE(RADEON_PCIE_TX_GART_END_LO, tmp);
118 WREG32_PCIE(RADEON_PCIE_TX_GART_START_HI, 0);
119 WREG32_PCIE(RADEON_PCIE_TX_GART_END_HI, 0);
120 table_addr = rdev->gart.table_addr;
121 WREG32_PCIE(RADEON_PCIE_TX_GART_BASE, table_addr);
122 /* FIXME: setup default page */
123 WREG32_PCIE(RADEON_PCIE_TX_DISCARD_RD_ADDR_LO, rdev->mc.vram_location);
124 WREG32_PCIE(RADEON_PCIE_TX_DISCARD_RD_ADDR_HI, 0);
125 /* Clear error */
126 WREG32_PCIE(0x18, 0);
127 tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_CNTL);
128 tmp |= RADEON_PCIE_TX_GART_EN;
129 tmp |= RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_DISCARD;
130 WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL, tmp);
131 rv370_pcie_gart_tlb_flush(rdev);
132 DRM_INFO("PCIE GART of %uM enabled (table at 0x%08X).\n",
Jerome Glisse3ce0a232009-09-08 10:10:24 +1000133 (unsigned)(rdev->mc.gtt_size >> 20), table_addr);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200134 rdev->gart.ready = true;
135 return 0;
136}
137
138void rv370_pcie_gart_disable(struct radeon_device *rdev)
139{
Jerome Glisse4c788672009-11-20 14:29:23 +0100140 u32 tmp;
141 int r;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200142
143 tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_CNTL);
144 tmp |= RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_DISCARD;
145 WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL, tmp & ~RADEON_PCIE_TX_GART_EN);
146 if (rdev->gart.table.vram.robj) {
Jerome Glisse4c788672009-11-20 14:29:23 +0100147 r = radeon_bo_reserve(rdev->gart.table.vram.robj, false);
148 if (likely(r == 0)) {
149 radeon_bo_kunmap(rdev->gart.table.vram.robj);
150 radeon_bo_unpin(rdev->gart.table.vram.robj);
151 radeon_bo_unreserve(rdev->gart.table.vram.robj);
152 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200153 }
154}
155
Jerome Glisse4aac0472009-09-14 18:29:49 +0200156void rv370_pcie_gart_fini(struct radeon_device *rdev)
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200157{
Jerome Glisse4aac0472009-09-14 18:29:49 +0200158 rv370_pcie_gart_disable(rdev);
159 radeon_gart_table_vram_free(rdev);
160 radeon_gart_fini(rdev);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200161}
162
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200163void r300_fence_ring_emit(struct radeon_device *rdev,
164 struct radeon_fence *fence)
165{
166 /* Who ever call radeon_fence_emit should call ring_lock and ask
167 * for enough space (today caller are ib schedule and buffer move) */
168 /* Write SC register so SC & US assert idle */
169 radeon_ring_write(rdev, PACKET0(0x43E0, 0));
170 radeon_ring_write(rdev, 0);
171 radeon_ring_write(rdev, PACKET0(0x43E4, 0));
172 radeon_ring_write(rdev, 0);
173 /* Flush 3D cache */
174 radeon_ring_write(rdev, PACKET0(0x4E4C, 0));
175 radeon_ring_write(rdev, (2 << 0));
176 radeon_ring_write(rdev, PACKET0(0x4F18, 0));
177 radeon_ring_write(rdev, (1 << 0));
178 /* Wait until IDLE & CLEAN */
179 radeon_ring_write(rdev, PACKET0(0x1720, 0));
180 radeon_ring_write(rdev, (1 << 17) | (1 << 16) | (1 << 9));
181 /* Emit fence sequence & fire IRQ */
182 radeon_ring_write(rdev, PACKET0(rdev->fence_drv.scratch_reg, 0));
183 radeon_ring_write(rdev, fence->seq);
184 radeon_ring_write(rdev, PACKET0(RADEON_GEN_INT_STATUS, 0));
185 radeon_ring_write(rdev, RADEON_SW_INT_FIRE);
186}
187
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200188int r300_copy_dma(struct radeon_device *rdev,
189 uint64_t src_offset,
190 uint64_t dst_offset,
191 unsigned num_pages,
192 struct radeon_fence *fence)
193{
194 uint32_t size;
195 uint32_t cur_size;
196 int i, num_loops;
197 int r = 0;
198
199 /* radeon pitch is /64 */
200 size = num_pages << PAGE_SHIFT;
201 num_loops = DIV_ROUND_UP(size, 0x1FFFFF);
202 r = radeon_ring_lock(rdev, num_loops * 4 + 64);
203 if (r) {
204 DRM_ERROR("radeon: moving bo (%d).\n", r);
205 return r;
206 }
207 /* Must wait for 2D idle & clean before DMA or hangs might happen */
Jerome Glisse068a1172009-06-17 13:28:30 +0200208 radeon_ring_write(rdev, PACKET0(RADEON_WAIT_UNTIL, 0 ));
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200209 radeon_ring_write(rdev, (1 << 16));
210 for (i = 0; i < num_loops; i++) {
211 cur_size = size;
212 if (cur_size > 0x1FFFFF) {
213 cur_size = 0x1FFFFF;
214 }
215 size -= cur_size;
216 radeon_ring_write(rdev, PACKET0(0x720, 2));
217 radeon_ring_write(rdev, src_offset);
218 radeon_ring_write(rdev, dst_offset);
219 radeon_ring_write(rdev, cur_size | (1 << 31) | (1 << 30));
220 src_offset += cur_size;
221 dst_offset += cur_size;
222 }
223 radeon_ring_write(rdev, PACKET0(RADEON_WAIT_UNTIL, 0));
224 radeon_ring_write(rdev, RADEON_WAIT_DMA_GUI_IDLE);
225 if (fence) {
226 r = radeon_fence_emit(rdev, fence);
227 }
228 radeon_ring_unlock_commit(rdev);
229 return r;
230}
231
232void r300_ring_start(struct radeon_device *rdev)
233{
234 unsigned gb_tile_config;
235 int r;
236
237 /* Sub pixel 1/12 so we can have 4K rendering according to doc */
238 gb_tile_config = (R300_ENABLE_TILING | R300_TILE_SIZE_16);
Jerome Glisse068a1172009-06-17 13:28:30 +0200239 switch(rdev->num_gb_pipes) {
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200240 case 2:
241 gb_tile_config |= R300_PIPE_COUNT_R300;
242 break;
243 case 3:
244 gb_tile_config |= R300_PIPE_COUNT_R420_3P;
245 break;
246 case 4:
247 gb_tile_config |= R300_PIPE_COUNT_R420;
248 break;
249 case 1:
250 default:
251 gb_tile_config |= R300_PIPE_COUNT_RV350;
252 break;
253 }
254
255 r = radeon_ring_lock(rdev, 64);
256 if (r) {
257 return;
258 }
259 radeon_ring_write(rdev, PACKET0(RADEON_ISYNC_CNTL, 0));
260 radeon_ring_write(rdev,
261 RADEON_ISYNC_ANY2D_IDLE3D |
262 RADEON_ISYNC_ANY3D_IDLE2D |
263 RADEON_ISYNC_WAIT_IDLEGUI |
264 RADEON_ISYNC_CPSCRATCH_IDLEGUI);
265 radeon_ring_write(rdev, PACKET0(R300_GB_TILE_CONFIG, 0));
266 radeon_ring_write(rdev, gb_tile_config);
267 radeon_ring_write(rdev, PACKET0(RADEON_WAIT_UNTIL, 0));
268 radeon_ring_write(rdev,
269 RADEON_WAIT_2D_IDLECLEAN |
270 RADEON_WAIT_3D_IDLECLEAN);
271 radeon_ring_write(rdev, PACKET0(0x170C, 0));
272 radeon_ring_write(rdev, 1 << 31);
273 radeon_ring_write(rdev, PACKET0(R300_GB_SELECT, 0));
274 radeon_ring_write(rdev, 0);
275 radeon_ring_write(rdev, PACKET0(R300_GB_ENABLE, 0));
276 radeon_ring_write(rdev, 0);
277 radeon_ring_write(rdev, PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0));
278 radeon_ring_write(rdev, R300_RB3D_DC_FLUSH | R300_RB3D_DC_FREE);
279 radeon_ring_write(rdev, PACKET0(R300_RB3D_ZCACHE_CTLSTAT, 0));
280 radeon_ring_write(rdev, R300_ZC_FLUSH | R300_ZC_FREE);
281 radeon_ring_write(rdev, PACKET0(RADEON_WAIT_UNTIL, 0));
282 radeon_ring_write(rdev,
283 RADEON_WAIT_2D_IDLECLEAN |
284 RADEON_WAIT_3D_IDLECLEAN);
285 radeon_ring_write(rdev, PACKET0(R300_GB_AA_CONFIG, 0));
286 radeon_ring_write(rdev, 0);
287 radeon_ring_write(rdev, PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0));
288 radeon_ring_write(rdev, R300_RB3D_DC_FLUSH | R300_RB3D_DC_FREE);
289 radeon_ring_write(rdev, PACKET0(R300_RB3D_ZCACHE_CTLSTAT, 0));
290 radeon_ring_write(rdev, R300_ZC_FLUSH | R300_ZC_FREE);
291 radeon_ring_write(rdev, PACKET0(R300_GB_MSPOS0, 0));
292 radeon_ring_write(rdev,
293 ((6 << R300_MS_X0_SHIFT) |
294 (6 << R300_MS_Y0_SHIFT) |
295 (6 << R300_MS_X1_SHIFT) |
296 (6 << R300_MS_Y1_SHIFT) |
297 (6 << R300_MS_X2_SHIFT) |
298 (6 << R300_MS_Y2_SHIFT) |
299 (6 << R300_MSBD0_Y_SHIFT) |
300 (6 << R300_MSBD0_X_SHIFT)));
301 radeon_ring_write(rdev, PACKET0(R300_GB_MSPOS1, 0));
302 radeon_ring_write(rdev,
303 ((6 << R300_MS_X3_SHIFT) |
304 (6 << R300_MS_Y3_SHIFT) |
305 (6 << R300_MS_X4_SHIFT) |
306 (6 << R300_MS_Y4_SHIFT) |
307 (6 << R300_MS_X5_SHIFT) |
308 (6 << R300_MS_Y5_SHIFT) |
309 (6 << R300_MSBD1_SHIFT)));
310 radeon_ring_write(rdev, PACKET0(R300_GA_ENHANCE, 0));
311 radeon_ring_write(rdev, R300_GA_DEADLOCK_CNTL | R300_GA_FASTSYNC_CNTL);
312 radeon_ring_write(rdev, PACKET0(R300_GA_POLY_MODE, 0));
313 radeon_ring_write(rdev,
314 R300_FRONT_PTYPE_TRIANGE | R300_BACK_PTYPE_TRIANGE);
315 radeon_ring_write(rdev, PACKET0(R300_GA_ROUND_MODE, 0));
316 radeon_ring_write(rdev,
317 R300_GEOMETRY_ROUND_NEAREST |
318 R300_COLOR_ROUND_NEAREST);
319 radeon_ring_unlock_commit(rdev);
320}
321
322void r300_errata(struct radeon_device *rdev)
323{
324 rdev->pll_errata = 0;
325
326 if (rdev->family == CHIP_R300 &&
327 (RREG32(RADEON_CONFIG_CNTL) & RADEON_CFG_ATI_REV_ID_MASK) == RADEON_CFG_ATI_REV_A11) {
328 rdev->pll_errata |= CHIP_ERRATA_R300_CG;
329 }
330}
331
332int r300_mc_wait_for_idle(struct radeon_device *rdev)
333{
334 unsigned i;
335 uint32_t tmp;
336
337 for (i = 0; i < rdev->usec_timeout; i++) {
338 /* read MC_STATUS */
339 tmp = RREG32(0x0150);
340 if (tmp & (1 << 4)) {
341 return 0;
342 }
343 DRM_UDELAY(1);
344 }
345 return -1;
346}
347
348void r300_gpu_init(struct radeon_device *rdev)
349{
350 uint32_t gb_tile_config, tmp;
351
352 r100_hdp_reset(rdev);
353 /* FIXME: rv380 one pipes ? */
354 if ((rdev->family == CHIP_R300) || (rdev->family == CHIP_R350)) {
355 /* r300,r350 */
356 rdev->num_gb_pipes = 2;
357 } else {
358 /* rv350,rv370,rv380 */
359 rdev->num_gb_pipes = 1;
360 }
Alex Deucherf779b3e2009-08-19 19:11:39 -0400361 rdev->num_z_pipes = 1;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200362 gb_tile_config = (R300_ENABLE_TILING | R300_TILE_SIZE_16);
363 switch (rdev->num_gb_pipes) {
364 case 2:
365 gb_tile_config |= R300_PIPE_COUNT_R300;
366 break;
367 case 3:
368 gb_tile_config |= R300_PIPE_COUNT_R420_3P;
369 break;
370 case 4:
371 gb_tile_config |= R300_PIPE_COUNT_R420;
372 break;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200373 default:
Jerome Glisse068a1172009-06-17 13:28:30 +0200374 case 1:
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200375 gb_tile_config |= R300_PIPE_COUNT_RV350;
376 break;
377 }
378 WREG32(R300_GB_TILE_CONFIG, gb_tile_config);
379
380 if (r100_gui_wait_for_idle(rdev)) {
381 printk(KERN_WARNING "Failed to wait GUI idle while "
382 "programming pipes. Bad things might happen.\n");
383 }
384
385 tmp = RREG32(0x170C);
386 WREG32(0x170C, tmp | (1 << 31));
387
388 WREG32(R300_RB2D_DSTCACHE_MODE,
389 R300_DC_AUTOFLUSH_ENABLE |
390 R300_DC_DC_DISABLE_IGNORE_PE);
391
392 if (r100_gui_wait_for_idle(rdev)) {
393 printk(KERN_WARNING "Failed to wait GUI idle while "
394 "programming pipes. Bad things might happen.\n");
395 }
396 if (r300_mc_wait_for_idle(rdev)) {
397 printk(KERN_WARNING "Failed to wait MC idle while "
398 "programming pipes. Bad things might happen.\n");
399 }
Alex Deucherf779b3e2009-08-19 19:11:39 -0400400 DRM_INFO("radeon: %d quad pipes, %d Z pipes initialized.\n",
401 rdev->num_gb_pipes, rdev->num_z_pipes);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200402}
403
404int r300_ga_reset(struct radeon_device *rdev)
405{
406 uint32_t tmp;
407 bool reinit_cp;
408 int i;
409
410 reinit_cp = rdev->cp.ready;
411 rdev->cp.ready = false;
412 for (i = 0; i < rdev->usec_timeout; i++) {
413 WREG32(RADEON_CP_CSQ_MODE, 0);
414 WREG32(RADEON_CP_CSQ_CNTL, 0);
415 WREG32(RADEON_RBBM_SOFT_RESET, 0x32005);
416 (void)RREG32(RADEON_RBBM_SOFT_RESET);
417 udelay(200);
418 WREG32(RADEON_RBBM_SOFT_RESET, 0);
419 /* Wait to prevent race in RBBM_STATUS */
420 mdelay(1);
421 tmp = RREG32(RADEON_RBBM_STATUS);
422 if (tmp & ((1 << 20) | (1 << 26))) {
423 DRM_ERROR("VAP & CP still busy (RBBM_STATUS=0x%08X)", tmp);
424 /* GA still busy soft reset it */
425 WREG32(0x429C, 0x200);
426 WREG32(R300_VAP_PVS_STATE_FLUSH_REG, 0);
427 WREG32(0x43E0, 0);
428 WREG32(0x43E4, 0);
429 WREG32(0x24AC, 0);
430 }
431 /* Wait to prevent race in RBBM_STATUS */
432 mdelay(1);
433 tmp = RREG32(RADEON_RBBM_STATUS);
434 if (!(tmp & ((1 << 20) | (1 << 26)))) {
435 break;
436 }
437 }
438 for (i = 0; i < rdev->usec_timeout; i++) {
439 tmp = RREG32(RADEON_RBBM_STATUS);
440 if (!(tmp & ((1 << 20) | (1 << 26)))) {
441 DRM_INFO("GA reset succeed (RBBM_STATUS=0x%08X)\n",
442 tmp);
443 if (reinit_cp) {
444 return r100_cp_init(rdev, rdev->cp.ring_size);
445 }
446 return 0;
447 }
448 DRM_UDELAY(1);
449 }
450 tmp = RREG32(RADEON_RBBM_STATUS);
451 DRM_ERROR("Failed to reset GA ! (RBBM_STATUS=0x%08X)\n", tmp);
452 return -1;
453}
454
455int r300_gpu_reset(struct radeon_device *rdev)
456{
457 uint32_t status;
458
459 /* reset order likely matter */
460 status = RREG32(RADEON_RBBM_STATUS);
461 /* reset HDP */
462 r100_hdp_reset(rdev);
463 /* reset rb2d */
464 if (status & ((1 << 17) | (1 << 18) | (1 << 27))) {
465 r100_rb2d_reset(rdev);
466 }
467 /* reset GA */
468 if (status & ((1 << 20) | (1 << 26))) {
469 r300_ga_reset(rdev);
470 }
471 /* reset CP */
472 status = RREG32(RADEON_RBBM_STATUS);
473 if (status & (1 << 16)) {
474 r100_cp_reset(rdev);
475 }
476 /* Check if GPU is idle */
477 status = RREG32(RADEON_RBBM_STATUS);
478 if (status & (1 << 31)) {
479 DRM_ERROR("Failed to reset GPU (RBBM_STATUS=0x%08X)\n", status);
480 return -1;
481 }
482 DRM_INFO("GPU reset succeed (RBBM_STATUS=0x%08X)\n", status);
483 return 0;
484}
485
486
487/*
488 * r300,r350,rv350,rv380 VRAM info
489 */
490void r300_vram_info(struct radeon_device *rdev)
491{
492 uint32_t tmp;
493
494 /* DDR for all card after R300 & IGP */
495 rdev->mc.vram_is_ddr = true;
496 tmp = RREG32(RADEON_MEM_CNTL);
497 if (tmp & R300_MEM_NUM_CHANNELS_MASK) {
498 rdev->mc.vram_width = 128;
499 } else {
500 rdev->mc.vram_width = 64;
501 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200502
Dave Airlie2a0f8912009-07-11 04:44:47 +1000503 r100_vram_init_sizes(rdev);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200504}
505
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200506void rv370_set_pcie_lanes(struct radeon_device *rdev, int lanes)
507{
508 uint32_t link_width_cntl, mask;
509
510 if (rdev->flags & RADEON_IS_IGP)
511 return;
512
513 if (!(rdev->flags & RADEON_IS_PCIE))
514 return;
515
516 /* FIXME wait for idle */
517
518 switch (lanes) {
519 case 0:
520 mask = RADEON_PCIE_LC_LINK_WIDTH_X0;
521 break;
522 case 1:
523 mask = RADEON_PCIE_LC_LINK_WIDTH_X1;
524 break;
525 case 2:
526 mask = RADEON_PCIE_LC_LINK_WIDTH_X2;
527 break;
528 case 4:
529 mask = RADEON_PCIE_LC_LINK_WIDTH_X4;
530 break;
531 case 8:
532 mask = RADEON_PCIE_LC_LINK_WIDTH_X8;
533 break;
534 case 12:
535 mask = RADEON_PCIE_LC_LINK_WIDTH_X12;
536 break;
537 case 16:
538 default:
539 mask = RADEON_PCIE_LC_LINK_WIDTH_X16;
540 break;
541 }
542
543 link_width_cntl = RREG32_PCIE(RADEON_PCIE_LC_LINK_WIDTH_CNTL);
544
545 if ((link_width_cntl & RADEON_PCIE_LC_LINK_WIDTH_RD_MASK) ==
546 (mask << RADEON_PCIE_LC_LINK_WIDTH_RD_SHIFT))
547 return;
548
549 link_width_cntl &= ~(RADEON_PCIE_LC_LINK_WIDTH_MASK |
550 RADEON_PCIE_LC_RECONFIG_NOW |
551 RADEON_PCIE_LC_RECONFIG_LATER |
552 RADEON_PCIE_LC_SHORT_RECONFIG_EN);
553 link_width_cntl |= mask;
554 WREG32_PCIE(RADEON_PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl);
555 WREG32_PCIE(RADEON_PCIE_LC_LINK_WIDTH_CNTL, (link_width_cntl |
556 RADEON_PCIE_LC_RECONFIG_NOW));
557
558 /* wait for lane set to complete */
559 link_width_cntl = RREG32_PCIE(RADEON_PCIE_LC_LINK_WIDTH_CNTL);
560 while (link_width_cntl == 0xffffffff)
561 link_width_cntl = RREG32_PCIE(RADEON_PCIE_LC_LINK_WIDTH_CNTL);
562
563}
564
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200565#if defined(CONFIG_DEBUG_FS)
566static int rv370_debugfs_pcie_gart_info(struct seq_file *m, void *data)
567{
568 struct drm_info_node *node = (struct drm_info_node *) m->private;
569 struct drm_device *dev = node->minor->dev;
570 struct radeon_device *rdev = dev->dev_private;
571 uint32_t tmp;
572
573 tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_CNTL);
574 seq_printf(m, "PCIE_TX_GART_CNTL 0x%08x\n", tmp);
575 tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_BASE);
576 seq_printf(m, "PCIE_TX_GART_BASE 0x%08x\n", tmp);
577 tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_START_LO);
578 seq_printf(m, "PCIE_TX_GART_START_LO 0x%08x\n", tmp);
579 tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_START_HI);
580 seq_printf(m, "PCIE_TX_GART_START_HI 0x%08x\n", tmp);
581 tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_END_LO);
582 seq_printf(m, "PCIE_TX_GART_END_LO 0x%08x\n", tmp);
583 tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_END_HI);
584 seq_printf(m, "PCIE_TX_GART_END_HI 0x%08x\n", tmp);
585 tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_ERROR);
586 seq_printf(m, "PCIE_TX_GART_ERROR 0x%08x\n", tmp);
587 return 0;
588}
589
590static struct drm_info_list rv370_pcie_gart_info_list[] = {
591 {"rv370_pcie_gart_info", rv370_debugfs_pcie_gart_info, 0, NULL},
592};
593#endif
594
Jerome Glisse207bf9e2009-09-30 15:35:32 +0200595static int rv370_debugfs_pcie_gart_info_init(struct radeon_device *rdev)
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200596{
597#if defined(CONFIG_DEBUG_FS)
598 return radeon_debugfs_add_files(rdev, rv370_pcie_gart_info_list, 1);
599#else
600 return 0;
601#endif
602}
603
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200604static int r300_packet0_check(struct radeon_cs_parser *p,
605 struct radeon_cs_packet *pkt,
606 unsigned idx, unsigned reg)
607{
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200608 struct radeon_cs_reloc *reloc;
Dave Airlie551ebd82009-09-01 15:25:57 +1000609 struct r100_cs_track *track;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200610 volatile uint32_t *ib;
Dave Airliee024e112009-06-24 09:48:08 +1000611 uint32_t tmp, tile_flags = 0;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200612 unsigned i;
613 int r;
Dave Airlie513bcb42009-09-23 16:56:27 +1000614 u32 idx_value;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200615
616 ib = p->ib->ptr;
Dave Airlie551ebd82009-09-01 15:25:57 +1000617 track = (struct r100_cs_track *)p->track;
Dave Airlie513bcb42009-09-23 16:56:27 +1000618 idx_value = radeon_get_ib_value(p, idx);
619
Jerome Glisse068a1172009-06-17 13:28:30 +0200620 switch(reg) {
Dave Airlie531369e2009-06-29 11:21:25 +1000621 case AVIVO_D1MODE_VLINE_START_END:
622 case RADEON_CRTC_GUI_TRIG_VLINE:
623 r = r100_cs_packet_parse_vline(p);
624 if (r) {
625 DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
626 idx, reg);
627 r100_cs_dump_packet(p, pkt);
628 return r;
629 }
630 break;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200631 case RADEON_DST_PITCH_OFFSET:
632 case RADEON_SRC_PITCH_OFFSET:
Dave Airlie551ebd82009-09-01 15:25:57 +1000633 r = r100_reloc_pitch_offset(p, pkt, idx, reg);
634 if (r)
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200635 return r;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200636 break;
637 case R300_RB3D_COLOROFFSET0:
638 case R300_RB3D_COLOROFFSET1:
639 case R300_RB3D_COLOROFFSET2:
640 case R300_RB3D_COLOROFFSET3:
641 i = (reg - R300_RB3D_COLOROFFSET0) >> 2;
642 r = r100_cs_packet_next_reloc(p, &reloc);
643 if (r) {
644 DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
645 idx, reg);
646 r100_cs_dump_packet(p, pkt);
647 return r;
648 }
649 track->cb[i].robj = reloc->robj;
Dave Airlie513bcb42009-09-23 16:56:27 +1000650 track->cb[i].offset = idx_value;
651 ib[idx] = idx_value + ((u32)reloc->lobj.gpu_offset);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200652 break;
653 case R300_ZB_DEPTHOFFSET:
654 r = r100_cs_packet_next_reloc(p, &reloc);
655 if (r) {
656 DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
657 idx, reg);
658 r100_cs_dump_packet(p, pkt);
659 return r;
660 }
661 track->zb.robj = reloc->robj;
Dave Airlie513bcb42009-09-23 16:56:27 +1000662 track->zb.offset = idx_value;
663 ib[idx] = idx_value + ((u32)reloc->lobj.gpu_offset);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200664 break;
665 case R300_TX_OFFSET_0:
666 case R300_TX_OFFSET_0+4:
667 case R300_TX_OFFSET_0+8:
668 case R300_TX_OFFSET_0+12:
669 case R300_TX_OFFSET_0+16:
670 case R300_TX_OFFSET_0+20:
671 case R300_TX_OFFSET_0+24:
672 case R300_TX_OFFSET_0+28:
673 case R300_TX_OFFSET_0+32:
674 case R300_TX_OFFSET_0+36:
675 case R300_TX_OFFSET_0+40:
676 case R300_TX_OFFSET_0+44:
677 case R300_TX_OFFSET_0+48:
678 case R300_TX_OFFSET_0+52:
679 case R300_TX_OFFSET_0+56:
680 case R300_TX_OFFSET_0+60:
Jerome Glisse068a1172009-06-17 13:28:30 +0200681 i = (reg - R300_TX_OFFSET_0) >> 2;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200682 r = r100_cs_packet_next_reloc(p, &reloc);
683 if (r) {
684 DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
685 idx, reg);
686 r100_cs_dump_packet(p, pkt);
687 return r;
688 }
Maciej Cencora6e726772009-12-15 23:13:08 +0100689
690 if (reloc->lobj.tiling_flags & RADEON_TILING_MACRO)
691 tile_flags |= R300_TXO_MACRO_TILE;
692 if (reloc->lobj.tiling_flags & RADEON_TILING_MICRO)
693 tile_flags |= R300_TXO_MICRO_TILE;
694
695 tmp = idx_value + ((u32)reloc->lobj.gpu_offset);
696 tmp |= tile_flags;
697 ib[idx] = tmp;
Jerome Glisse068a1172009-06-17 13:28:30 +0200698 track->textures[i].robj = reloc->robj;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200699 break;
700 /* Tracked registers */
Jerome Glisse068a1172009-06-17 13:28:30 +0200701 case 0x2084:
702 /* VAP_VF_CNTL */
Dave Airlie513bcb42009-09-23 16:56:27 +1000703 track->vap_vf_cntl = idx_value;
Jerome Glisse068a1172009-06-17 13:28:30 +0200704 break;
705 case 0x20B4:
706 /* VAP_VTX_SIZE */
Dave Airlie513bcb42009-09-23 16:56:27 +1000707 track->vtx_size = idx_value & 0x7F;
Jerome Glisse068a1172009-06-17 13:28:30 +0200708 break;
709 case 0x2134:
710 /* VAP_VF_MAX_VTX_INDX */
Dave Airlie513bcb42009-09-23 16:56:27 +1000711 track->max_indx = idx_value & 0x00FFFFFFUL;
Jerome Glisse068a1172009-06-17 13:28:30 +0200712 break;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200713 case 0x43E4:
714 /* SC_SCISSOR1 */
Dave Airlie513bcb42009-09-23 16:56:27 +1000715 track->maxy = ((idx_value >> 13) & 0x1FFF) + 1;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200716 if (p->rdev->family < CHIP_RV515) {
717 track->maxy -= 1440;
718 }
719 break;
720 case 0x4E00:
721 /* RB3D_CCTL */
Dave Airlie513bcb42009-09-23 16:56:27 +1000722 track->num_cb = ((idx_value >> 5) & 0x3) + 1;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200723 break;
724 case 0x4E38:
725 case 0x4E3C:
726 case 0x4E40:
727 case 0x4E44:
728 /* RB3D_COLORPITCH0 */
729 /* RB3D_COLORPITCH1 */
730 /* RB3D_COLORPITCH2 */
731 /* RB3D_COLORPITCH3 */
Dave Airliee024e112009-06-24 09:48:08 +1000732 r = r100_cs_packet_next_reloc(p, &reloc);
733 if (r) {
734 DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
735 idx, reg);
736 r100_cs_dump_packet(p, pkt);
737 return r;
738 }
739
740 if (reloc->lobj.tiling_flags & RADEON_TILING_MACRO)
741 tile_flags |= R300_COLOR_TILE_ENABLE;
742 if (reloc->lobj.tiling_flags & RADEON_TILING_MICRO)
743 tile_flags |= R300_COLOR_MICROTILE_ENABLE;
744
Dave Airlie513bcb42009-09-23 16:56:27 +1000745 tmp = idx_value & ~(0x7 << 16);
Dave Airliee024e112009-06-24 09:48:08 +1000746 tmp |= tile_flags;
747 ib[idx] = tmp;
748
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200749 i = (reg - 0x4E38) >> 2;
Dave Airlie513bcb42009-09-23 16:56:27 +1000750 track->cb[i].pitch = idx_value & 0x3FFE;
751 switch (((idx_value >> 21) & 0xF)) {
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200752 case 9:
753 case 11:
754 case 12:
755 track->cb[i].cpp = 1;
756 break;
757 case 3:
758 case 4:
759 case 13:
760 case 15:
761 track->cb[i].cpp = 2;
762 break;
763 case 6:
764 track->cb[i].cpp = 4;
765 break;
766 case 10:
767 track->cb[i].cpp = 8;
768 break;
769 case 7:
770 track->cb[i].cpp = 16;
771 break;
772 default:
773 DRM_ERROR("Invalid color buffer format (%d) !\n",
Dave Airlie513bcb42009-09-23 16:56:27 +1000774 ((idx_value >> 21) & 0xF));
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200775 return -EINVAL;
776 }
777 break;
778 case 0x4F00:
779 /* ZB_CNTL */
Dave Airlie513bcb42009-09-23 16:56:27 +1000780 if (idx_value & 2) {
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200781 track->z_enabled = true;
782 } else {
783 track->z_enabled = false;
784 }
785 break;
786 case 0x4F10:
787 /* ZB_FORMAT */
Dave Airlie513bcb42009-09-23 16:56:27 +1000788 switch ((idx_value & 0xF)) {
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200789 case 0:
790 case 1:
791 track->zb.cpp = 2;
792 break;
793 case 2:
794 track->zb.cpp = 4;
795 break;
796 default:
797 DRM_ERROR("Invalid z buffer format (%d) !\n",
Dave Airlie513bcb42009-09-23 16:56:27 +1000798 (idx_value & 0xF));
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200799 return -EINVAL;
800 }
801 break;
802 case 0x4F24:
803 /* ZB_DEPTHPITCH */
Dave Airliee024e112009-06-24 09:48:08 +1000804 r = r100_cs_packet_next_reloc(p, &reloc);
805 if (r) {
806 DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
807 idx, reg);
808 r100_cs_dump_packet(p, pkt);
809 return r;
810 }
811
812 if (reloc->lobj.tiling_flags & RADEON_TILING_MACRO)
813 tile_flags |= R300_DEPTHMACROTILE_ENABLE;
814 if (reloc->lobj.tiling_flags & RADEON_TILING_MICRO)
815 tile_flags |= R300_DEPTHMICROTILE_TILED;;
816
Dave Airlie513bcb42009-09-23 16:56:27 +1000817 tmp = idx_value & ~(0x7 << 16);
Dave Airliee024e112009-06-24 09:48:08 +1000818 tmp |= tile_flags;
819 ib[idx] = tmp;
820
Dave Airlie513bcb42009-09-23 16:56:27 +1000821 track->zb.pitch = idx_value & 0x3FFC;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200822 break;
Jerome Glisse068a1172009-06-17 13:28:30 +0200823 case 0x4104:
824 for (i = 0; i < 16; i++) {
825 bool enabled;
826
Dave Airlie513bcb42009-09-23 16:56:27 +1000827 enabled = !!(idx_value & (1 << i));
Jerome Glisse068a1172009-06-17 13:28:30 +0200828 track->textures[i].enabled = enabled;
829 }
830 break;
831 case 0x44C0:
832 case 0x44C4:
833 case 0x44C8:
834 case 0x44CC:
835 case 0x44D0:
836 case 0x44D4:
837 case 0x44D8:
838 case 0x44DC:
839 case 0x44E0:
840 case 0x44E4:
841 case 0x44E8:
842 case 0x44EC:
843 case 0x44F0:
844 case 0x44F4:
845 case 0x44F8:
846 case 0x44FC:
847 /* TX_FORMAT1_[0-15] */
848 i = (reg - 0x44C0) >> 2;
Dave Airlie513bcb42009-09-23 16:56:27 +1000849 tmp = (idx_value >> 25) & 0x3;
Jerome Glisse068a1172009-06-17 13:28:30 +0200850 track->textures[i].tex_coord_type = tmp;
Dave Airlie513bcb42009-09-23 16:56:27 +1000851 switch ((idx_value & 0x1F)) {
Dave Airlie551ebd82009-09-01 15:25:57 +1000852 case R300_TX_FORMAT_X8:
853 case R300_TX_FORMAT_Y4X4:
854 case R300_TX_FORMAT_Z3Y3X2:
Jerome Glisse068a1172009-06-17 13:28:30 +0200855 track->textures[i].cpp = 1;
856 break;
Dave Airlie551ebd82009-09-01 15:25:57 +1000857 case R300_TX_FORMAT_X16:
858 case R300_TX_FORMAT_Y8X8:
859 case R300_TX_FORMAT_Z5Y6X5:
860 case R300_TX_FORMAT_Z6Y5X5:
861 case R300_TX_FORMAT_W4Z4Y4X4:
862 case R300_TX_FORMAT_W1Z5Y5X5:
Dave Airlie551ebd82009-09-01 15:25:57 +1000863 case R300_TX_FORMAT_D3DMFT_CxV8U8:
864 case R300_TX_FORMAT_B8G8_B8G8:
865 case R300_TX_FORMAT_G8R8_G8B8:
Jerome Glisse068a1172009-06-17 13:28:30 +0200866 track->textures[i].cpp = 2;
867 break;
Dave Airlie551ebd82009-09-01 15:25:57 +1000868 case R300_TX_FORMAT_Y16X16:
869 case R300_TX_FORMAT_Z11Y11X10:
870 case R300_TX_FORMAT_Z10Y11X11:
871 case R300_TX_FORMAT_W8Z8Y8X8:
872 case R300_TX_FORMAT_W2Z10Y10X10:
873 case 0x17:
874 case R300_TX_FORMAT_FL_I32:
875 case 0x1e:
Jerome Glisse068a1172009-06-17 13:28:30 +0200876 track->textures[i].cpp = 4;
877 break;
Dave Airlie551ebd82009-09-01 15:25:57 +1000878 case R300_TX_FORMAT_W16Z16Y16X16:
879 case R300_TX_FORMAT_FL_R16G16B16A16:
880 case R300_TX_FORMAT_FL_I32A32:
Jerome Glisse068a1172009-06-17 13:28:30 +0200881 track->textures[i].cpp = 8;
882 break;
Dave Airlie551ebd82009-09-01 15:25:57 +1000883 case R300_TX_FORMAT_FL_R32G32B32A32:
Jerome Glisse068a1172009-06-17 13:28:30 +0200884 track->textures[i].cpp = 16;
885 break;
Dave Airlied785d782009-12-07 13:16:06 +1000886 case R300_TX_FORMAT_DXT1:
887 track->textures[i].cpp = 1;
888 track->textures[i].compress_format = R100_TRACK_COMP_DXT1;
889 break;
Marek Olšák512889f2009-12-19 00:23:00 +0100890 case R300_TX_FORMAT_ATI2N:
891 if (p->rdev->family < CHIP_R420) {
892 DRM_ERROR("Invalid texture format %u\n",
893 (idx_value & 0x1F));
894 return -EINVAL;
895 }
896 /* The same rules apply as for DXT3/5. */
897 /* Pass through. */
Dave Airlied785d782009-12-07 13:16:06 +1000898 case R300_TX_FORMAT_DXT3:
899 case R300_TX_FORMAT_DXT5:
900 track->textures[i].cpp = 1;
901 track->textures[i].compress_format = R100_TRACK_COMP_DXT35;
902 break;
Jerome Glisse068a1172009-06-17 13:28:30 +0200903 default:
904 DRM_ERROR("Invalid texture format %u\n",
Dave Airlie513bcb42009-09-23 16:56:27 +1000905 (idx_value & 0x1F));
Jerome Glisse068a1172009-06-17 13:28:30 +0200906 return -EINVAL;
907 break;
908 }
909 break;
910 case 0x4400:
911 case 0x4404:
912 case 0x4408:
913 case 0x440C:
914 case 0x4410:
915 case 0x4414:
916 case 0x4418:
917 case 0x441C:
918 case 0x4420:
919 case 0x4424:
920 case 0x4428:
921 case 0x442C:
922 case 0x4430:
923 case 0x4434:
924 case 0x4438:
925 case 0x443C:
926 /* TX_FILTER0_[0-15] */
927 i = (reg - 0x4400) >> 2;
Dave Airlie513bcb42009-09-23 16:56:27 +1000928 tmp = idx_value & 0x7;
Jerome Glisse068a1172009-06-17 13:28:30 +0200929 if (tmp == 2 || tmp == 4 || tmp == 6) {
930 track->textures[i].roundup_w = false;
931 }
Dave Airlie513bcb42009-09-23 16:56:27 +1000932 tmp = (idx_value >> 3) & 0x7;
Jerome Glisse068a1172009-06-17 13:28:30 +0200933 if (tmp == 2 || tmp == 4 || tmp == 6) {
934 track->textures[i].roundup_h = false;
935 }
936 break;
937 case 0x4500:
938 case 0x4504:
939 case 0x4508:
940 case 0x450C:
941 case 0x4510:
942 case 0x4514:
943 case 0x4518:
944 case 0x451C:
945 case 0x4520:
946 case 0x4524:
947 case 0x4528:
948 case 0x452C:
949 case 0x4530:
950 case 0x4534:
951 case 0x4538:
952 case 0x453C:
953 /* TX_FORMAT2_[0-15] */
954 i = (reg - 0x4500) >> 2;
Dave Airlie513bcb42009-09-23 16:56:27 +1000955 tmp = idx_value & 0x3FFF;
Jerome Glisse068a1172009-06-17 13:28:30 +0200956 track->textures[i].pitch = tmp + 1;
957 if (p->rdev->family >= CHIP_RV515) {
Dave Airlie513bcb42009-09-23 16:56:27 +1000958 tmp = ((idx_value >> 15) & 1) << 11;
Jerome Glisse068a1172009-06-17 13:28:30 +0200959 track->textures[i].width_11 = tmp;
Dave Airlie513bcb42009-09-23 16:56:27 +1000960 tmp = ((idx_value >> 16) & 1) << 11;
Jerome Glisse068a1172009-06-17 13:28:30 +0200961 track->textures[i].height_11 = tmp;
Marek Olšák512889f2009-12-19 00:23:00 +0100962
963 /* ATI1N */
964 if (idx_value & (1 << 14)) {
965 /* The same rules apply as for DXT1. */
966 track->textures[i].compress_format =
967 R100_TRACK_COMP_DXT1;
968 }
969 } else if (idx_value & (1 << 14)) {
970 DRM_ERROR("Forbidden bit TXFORMAT_MSB\n");
971 return -EINVAL;
Jerome Glisse068a1172009-06-17 13:28:30 +0200972 }
973 break;
974 case 0x4480:
975 case 0x4484:
976 case 0x4488:
977 case 0x448C:
978 case 0x4490:
979 case 0x4494:
980 case 0x4498:
981 case 0x449C:
982 case 0x44A0:
983 case 0x44A4:
984 case 0x44A8:
985 case 0x44AC:
986 case 0x44B0:
987 case 0x44B4:
988 case 0x44B8:
989 case 0x44BC:
990 /* TX_FORMAT0_[0-15] */
991 i = (reg - 0x4480) >> 2;
Dave Airlie513bcb42009-09-23 16:56:27 +1000992 tmp = idx_value & 0x7FF;
Jerome Glisse068a1172009-06-17 13:28:30 +0200993 track->textures[i].width = tmp + 1;
Dave Airlie513bcb42009-09-23 16:56:27 +1000994 tmp = (idx_value >> 11) & 0x7FF;
Jerome Glisse068a1172009-06-17 13:28:30 +0200995 track->textures[i].height = tmp + 1;
Dave Airlie513bcb42009-09-23 16:56:27 +1000996 tmp = (idx_value >> 26) & 0xF;
Jerome Glisse068a1172009-06-17 13:28:30 +0200997 track->textures[i].num_levels = tmp;
Dave Airlie513bcb42009-09-23 16:56:27 +1000998 tmp = idx_value & (1 << 31);
Jerome Glisse068a1172009-06-17 13:28:30 +0200999 track->textures[i].use_pitch = !!tmp;
Dave Airlie513bcb42009-09-23 16:56:27 +10001000 tmp = (idx_value >> 22) & 0xF;
Jerome Glisse068a1172009-06-17 13:28:30 +02001001 track->textures[i].txdepth = tmp;
1002 break;
Dave Airlie3f8befe2009-08-15 20:54:13 +10001003 case R300_ZB_ZPASS_ADDR:
1004 r = r100_cs_packet_next_reloc(p, &reloc);
1005 if (r) {
1006 DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
1007 idx, reg);
1008 r100_cs_dump_packet(p, pkt);
1009 return r;
1010 }
Dave Airlie513bcb42009-09-23 16:56:27 +10001011 ib[idx] = idx_value + ((u32)reloc->lobj.gpu_offset);
Dave Airlie3f8befe2009-08-15 20:54:13 +10001012 break;
Marek Olšák46c64d42009-12-17 06:02:28 +01001013 case 0x4e0c:
1014 /* RB3D_COLOR_CHANNEL_MASK */
1015 track->color_channel_mask = idx_value;
1016 break;
1017 case 0x4d1c:
1018 /* ZB_BW_CNTL */
1019 track->fastfill = !!(idx_value & (1 << 2));
1020 break;
1021 case 0x4e04:
1022 /* RB3D_BLENDCNTL */
1023 track->blend_read_enable = !!(idx_value & (1 << 2));
1024 break;
Dave Airlie3f8befe2009-08-15 20:54:13 +10001025 case 0x4be8:
1026 /* valid register only on RV530 */
1027 if (p->rdev->family == CHIP_RV530)
1028 break;
1029 /* fallthrough do not move */
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001030 default:
Jerome Glisse068a1172009-06-17 13:28:30 +02001031 printk(KERN_ERR "Forbidden register 0x%04X in cs at %d\n",
1032 reg, idx);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001033 return -EINVAL;
1034 }
1035 return 0;
1036}
1037
1038static int r300_packet3_check(struct radeon_cs_parser *p,
1039 struct radeon_cs_packet *pkt)
1040{
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001041 struct radeon_cs_reloc *reloc;
Dave Airlie551ebd82009-09-01 15:25:57 +10001042 struct r100_cs_track *track;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001043 volatile uint32_t *ib;
1044 unsigned idx;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001045 int r;
1046
1047 ib = p->ib->ptr;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001048 idx = pkt->idx + 1;
Dave Airlie551ebd82009-09-01 15:25:57 +10001049 track = (struct r100_cs_track *)p->track;
Jerome Glisse068a1172009-06-17 13:28:30 +02001050 switch(pkt->opcode) {
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001051 case PACKET3_3D_LOAD_VBPNTR:
Dave Airlie513bcb42009-09-23 16:56:27 +10001052 r = r100_packet3_load_vbpntr(p, pkt, idx);
1053 if (r)
1054 return r;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001055 break;
1056 case PACKET3_INDX_BUFFER:
1057 r = r100_cs_packet_next_reloc(p, &reloc);
1058 if (r) {
1059 DRM_ERROR("No reloc for packet3 %d\n", pkt->opcode);
1060 r100_cs_dump_packet(p, pkt);
1061 return r;
1062 }
Dave Airlie513bcb42009-09-23 16:56:27 +10001063 ib[idx+1] = radeon_get_ib_value(p, idx + 1) + ((u32)reloc->lobj.gpu_offset);
Jerome Glisse068a1172009-06-17 13:28:30 +02001064 r = r100_cs_track_check_pkt3_indx_buffer(p, pkt, reloc->robj);
1065 if (r) {
1066 return r;
1067 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001068 break;
1069 /* Draw packet */
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001070 case PACKET3_3D_DRAW_IMMD:
Jerome Glisse068a1172009-06-17 13:28:30 +02001071 /* Number of dwords is vtx_size * (num_vertices - 1)
1072 * PRIM_WALK must be equal to 3 vertex data in embedded
1073 * in cmd stream */
Dave Airlie513bcb42009-09-23 16:56:27 +10001074 if (((radeon_get_ib_value(p, idx + 1) >> 4) & 0x3) != 3) {
Jerome Glisse068a1172009-06-17 13:28:30 +02001075 DRM_ERROR("PRIM_WALK must be 3 for IMMD draw\n");
1076 return -EINVAL;
1077 }
Dave Airlie513bcb42009-09-23 16:56:27 +10001078 track->vap_vf_cntl = radeon_get_ib_value(p, idx + 1);
Jerome Glisse068a1172009-06-17 13:28:30 +02001079 track->immd_dwords = pkt->count - 1;
Dave Airlie551ebd82009-09-01 15:25:57 +10001080 r = r100_cs_track_check(p->rdev, track);
Jerome Glisse068a1172009-06-17 13:28:30 +02001081 if (r) {
1082 return r;
1083 }
1084 break;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001085 case PACKET3_3D_DRAW_IMMD_2:
Jerome Glisse068a1172009-06-17 13:28:30 +02001086 /* Number of dwords is vtx_size * (num_vertices - 1)
1087 * PRIM_WALK must be equal to 3 vertex data in embedded
1088 * in cmd stream */
Dave Airlie513bcb42009-09-23 16:56:27 +10001089 if (((radeon_get_ib_value(p, idx) >> 4) & 0x3) != 3) {
Jerome Glisse068a1172009-06-17 13:28:30 +02001090 DRM_ERROR("PRIM_WALK must be 3 for IMMD draw\n");
1091 return -EINVAL;
1092 }
Dave Airlie513bcb42009-09-23 16:56:27 +10001093 track->vap_vf_cntl = radeon_get_ib_value(p, idx);
Jerome Glisse068a1172009-06-17 13:28:30 +02001094 track->immd_dwords = pkt->count;
Dave Airlie551ebd82009-09-01 15:25:57 +10001095 r = r100_cs_track_check(p->rdev, track);
Jerome Glisse068a1172009-06-17 13:28:30 +02001096 if (r) {
1097 return r;
1098 }
1099 break;
1100 case PACKET3_3D_DRAW_VBUF:
Dave Airlie513bcb42009-09-23 16:56:27 +10001101 track->vap_vf_cntl = radeon_get_ib_value(p, idx + 1);
Dave Airlie551ebd82009-09-01 15:25:57 +10001102 r = r100_cs_track_check(p->rdev, track);
Jerome Glisse068a1172009-06-17 13:28:30 +02001103 if (r) {
1104 return r;
1105 }
1106 break;
1107 case PACKET3_3D_DRAW_VBUF_2:
Dave Airlie513bcb42009-09-23 16:56:27 +10001108 track->vap_vf_cntl = radeon_get_ib_value(p, idx);
Dave Airlie551ebd82009-09-01 15:25:57 +10001109 r = r100_cs_track_check(p->rdev, track);
Jerome Glisse068a1172009-06-17 13:28:30 +02001110 if (r) {
1111 return r;
1112 }
1113 break;
1114 case PACKET3_3D_DRAW_INDX:
Dave Airlie513bcb42009-09-23 16:56:27 +10001115 track->vap_vf_cntl = radeon_get_ib_value(p, idx + 1);
Dave Airlie551ebd82009-09-01 15:25:57 +10001116 r = r100_cs_track_check(p->rdev, track);
Jerome Glisse068a1172009-06-17 13:28:30 +02001117 if (r) {
1118 return r;
1119 }
1120 break;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001121 case PACKET3_3D_DRAW_INDX_2:
Dave Airlie513bcb42009-09-23 16:56:27 +10001122 track->vap_vf_cntl = radeon_get_ib_value(p, idx);
Dave Airlie551ebd82009-09-01 15:25:57 +10001123 r = r100_cs_track_check(p->rdev, track);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001124 if (r) {
1125 return r;
1126 }
1127 break;
1128 case PACKET3_NOP:
1129 break;
1130 default:
1131 DRM_ERROR("Packet3 opcode %x not supported\n", pkt->opcode);
1132 return -EINVAL;
1133 }
1134 return 0;
1135}
1136
1137int r300_cs_parse(struct radeon_cs_parser *p)
1138{
1139 struct radeon_cs_packet pkt;
Jerome Glisse9f022dd2009-09-11 15:35:22 +02001140 struct r100_cs_track *track;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001141 int r;
1142
Jerome Glisse9f022dd2009-09-11 15:35:22 +02001143 track = kzalloc(sizeof(*track), GFP_KERNEL);
1144 r100_cs_track_clear(p->rdev, track);
1145 p->track = track;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001146 do {
1147 r = r100_cs_packet_parse(p, &pkt, p->idx);
1148 if (r) {
1149 return r;
1150 }
1151 p->idx += pkt.count + 2;
1152 switch (pkt.type) {
1153 case PACKET_TYPE0:
1154 r = r100_cs_parse_packet0(p, &pkt,
Jerome Glisse068a1172009-06-17 13:28:30 +02001155 p->rdev->config.r300.reg_safe_bm,
1156 p->rdev->config.r300.reg_safe_bm_size,
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001157 &r300_packet0_check);
1158 break;
1159 case PACKET_TYPE2:
1160 break;
1161 case PACKET_TYPE3:
1162 r = r300_packet3_check(p, &pkt);
1163 break;
1164 default:
1165 DRM_ERROR("Unknown packet type %d !\n", pkt.type);
1166 return -EINVAL;
1167 }
1168 if (r) {
1169 return r;
1170 }
1171 } while (p->idx < p->chunks[p->chunk_ib_idx].length_dw);
1172 return 0;
1173}
Jerome Glisse068a1172009-06-17 13:28:30 +02001174
Jerome Glisse9f022dd2009-09-11 15:35:22 +02001175void r300_set_reg_safe(struct radeon_device *rdev)
Jerome Glisse068a1172009-06-17 13:28:30 +02001176{
1177 rdev->config.r300.reg_safe_bm = r300_reg_safe_bm;
1178 rdev->config.r300.reg_safe_bm_size = ARRAY_SIZE(r300_reg_safe_bm);
Jerome Glisse9f022dd2009-09-11 15:35:22 +02001179}
1180
Jerome Glisse9f022dd2009-09-11 15:35:22 +02001181void r300_mc_program(struct radeon_device *rdev)
1182{
1183 struct r100_mc_save save;
1184 int r;
1185
1186 r = r100_debugfs_mc_info_init(rdev);
1187 if (r) {
1188 dev_err(rdev->dev, "Failed to create r100_mc debugfs file.\n");
1189 }
1190
1191 /* Stops all mc clients */
1192 r100_mc_stop(rdev, &save);
Jerome Glisse9f022dd2009-09-11 15:35:22 +02001193 if (rdev->flags & RADEON_IS_AGP) {
1194 WREG32(R_00014C_MC_AGP_LOCATION,
1195 S_00014C_MC_AGP_START(rdev->mc.gtt_start >> 16) |
1196 S_00014C_MC_AGP_TOP(rdev->mc.gtt_end >> 16));
1197 WREG32(R_000170_AGP_BASE, lower_32_bits(rdev->mc.agp_base));
1198 WREG32(R_00015C_AGP_BASE_2,
1199 upper_32_bits(rdev->mc.agp_base) & 0xff);
1200 } else {
1201 WREG32(R_00014C_MC_AGP_LOCATION, 0x0FFFFFFF);
1202 WREG32(R_000170_AGP_BASE, 0);
1203 WREG32(R_00015C_AGP_BASE_2, 0);
1204 }
1205 /* Wait for mc idle */
1206 if (r300_mc_wait_for_idle(rdev))
1207 DRM_INFO("Failed to wait MC idle before programming MC.\n");
1208 /* Program MC, should be a 32bits limited address space */
1209 WREG32(R_000148_MC_FB_LOCATION,
1210 S_000148_MC_FB_START(rdev->mc.vram_start >> 16) |
1211 S_000148_MC_FB_TOP(rdev->mc.vram_end >> 16));
1212 r100_mc_resume(rdev, &save);
1213}
Jerome Glisseca6ffc62009-10-01 10:20:52 +02001214
1215void r300_clock_startup(struct radeon_device *rdev)
1216{
1217 u32 tmp;
1218
1219 if (radeon_dynclks != -1 && radeon_dynclks)
1220 radeon_legacy_set_clock_gating(rdev, 1);
1221 /* We need to force on some of the block */
1222 tmp = RREG32_PLL(R_00000D_SCLK_CNTL);
1223 tmp |= S_00000D_FORCE_CP(1) | S_00000D_FORCE_VIP(1);
1224 if ((rdev->family == CHIP_RV350) || (rdev->family == CHIP_RV380))
1225 tmp |= S_00000D_FORCE_VAP(1);
1226 WREG32_PLL(R_00000D_SCLK_CNTL, tmp);
1227}
Jerome Glisse207bf9e2009-09-30 15:35:32 +02001228
1229static int r300_startup(struct radeon_device *rdev)
1230{
1231 int r;
1232
Alex Deucher92cde002009-12-04 10:55:12 -05001233 /* set common regs */
1234 r100_set_common_regs(rdev);
1235 /* program mc */
Jerome Glisse207bf9e2009-09-30 15:35:32 +02001236 r300_mc_program(rdev);
1237 /* Resume clock */
1238 r300_clock_startup(rdev);
1239 /* Initialize GPU configuration (# pipes, ...) */
1240 r300_gpu_init(rdev);
1241 /* Initialize GART (initialize after TTM so we can allocate
1242 * memory through TTM but finalize after TTM) */
1243 if (rdev->flags & RADEON_IS_PCIE) {
1244 r = rv370_pcie_gart_enable(rdev);
1245 if (r)
1246 return r;
1247 }
Dave Airlie17e15b02009-11-05 15:36:53 +10001248
1249 if (rdev->family == CHIP_R300 ||
1250 rdev->family == CHIP_R350 ||
1251 rdev->family == CHIP_RV350)
1252 r100_enable_bm(rdev);
1253
Jerome Glisse207bf9e2009-09-30 15:35:32 +02001254 if (rdev->flags & RADEON_IS_PCI) {
1255 r = r100_pci_gart_enable(rdev);
1256 if (r)
1257 return r;
1258 }
1259 /* Enable IRQ */
Jerome Glisse207bf9e2009-09-30 15:35:32 +02001260 r100_irq_set(rdev);
1261 /* 1M ring buffer */
1262 r = r100_cp_init(rdev, 1024 * 1024);
1263 if (r) {
1264 dev_err(rdev->dev, "failled initializing CP (%d).\n", r);
1265 return r;
1266 }
1267 r = r100_wb_init(rdev);
1268 if (r)
1269 dev_err(rdev->dev, "failled initializing WB (%d).\n", r);
1270 r = r100_ib_init(rdev);
1271 if (r) {
1272 dev_err(rdev->dev, "failled initializing IB (%d).\n", r);
1273 return r;
1274 }
1275 return 0;
1276}
1277
1278int r300_resume(struct radeon_device *rdev)
1279{
1280 /* Make sur GART are not working */
1281 if (rdev->flags & RADEON_IS_PCIE)
1282 rv370_pcie_gart_disable(rdev);
1283 if (rdev->flags & RADEON_IS_PCI)
1284 r100_pci_gart_disable(rdev);
1285 /* Resume clock before doing reset */
1286 r300_clock_startup(rdev);
1287 /* Reset gpu before posting otherwise ATOM will enter infinite loop */
1288 if (radeon_gpu_reset(rdev)) {
1289 dev_warn(rdev->dev, "GPU reset failed ! (0xE40=0x%08X, 0x7C0=0x%08X)\n",
1290 RREG32(R_000E40_RBBM_STATUS),
1291 RREG32(R_0007C0_CP_STAT));
1292 }
1293 /* post */
1294 radeon_combios_asic_init(rdev->ddev);
1295 /* Resume clock after posting */
1296 r300_clock_startup(rdev);
Dave Airlie550e2d92009-12-09 14:15:38 +10001297 /* Initialize surface registers */
1298 radeon_surface_init(rdev);
Jerome Glisse207bf9e2009-09-30 15:35:32 +02001299 return r300_startup(rdev);
1300}
1301
1302int r300_suspend(struct radeon_device *rdev)
1303{
1304 r100_cp_disable(rdev);
1305 r100_wb_disable(rdev);
1306 r100_irq_disable(rdev);
1307 if (rdev->flags & RADEON_IS_PCIE)
1308 rv370_pcie_gart_disable(rdev);
1309 if (rdev->flags & RADEON_IS_PCI)
1310 r100_pci_gart_disable(rdev);
1311 return 0;
1312}
1313
1314void r300_fini(struct radeon_device *rdev)
1315{
1316 r300_suspend(rdev);
1317 r100_cp_fini(rdev);
1318 r100_wb_fini(rdev);
1319 r100_ib_fini(rdev);
1320 radeon_gem_fini(rdev);
1321 if (rdev->flags & RADEON_IS_PCIE)
1322 rv370_pcie_gart_fini(rdev);
1323 if (rdev->flags & RADEON_IS_PCI)
1324 r100_pci_gart_fini(rdev);
1325 radeon_irq_kms_fini(rdev);
1326 radeon_fence_driver_fini(rdev);
Jerome Glisse4c788672009-11-20 14:29:23 +01001327 radeon_bo_fini(rdev);
Jerome Glisse207bf9e2009-09-30 15:35:32 +02001328 radeon_atombios_fini(rdev);
1329 kfree(rdev->bios);
1330 rdev->bios = NULL;
1331}
1332
1333int r300_init(struct radeon_device *rdev)
1334{
1335 int r;
1336
Jerome Glisse207bf9e2009-09-30 15:35:32 +02001337 /* Disable VGA */
1338 r100_vga_render_disable(rdev);
1339 /* Initialize scratch registers */
1340 radeon_scratch_init(rdev);
1341 /* Initialize surface registers */
1342 radeon_surface_init(rdev);
1343 /* TODO: disable VGA need to use VGA request */
1344 /* BIOS*/
1345 if (!radeon_get_bios(rdev)) {
1346 if (ASIC_IS_AVIVO(rdev))
1347 return -EINVAL;
1348 }
1349 if (rdev->is_atom_bios) {
1350 dev_err(rdev->dev, "Expecting combios for RS400/RS480 GPU\n");
1351 return -EINVAL;
1352 } else {
1353 r = radeon_combios_init(rdev);
1354 if (r)
1355 return r;
1356 }
1357 /* Reset gpu before posting otherwise ATOM will enter infinite loop */
1358 if (radeon_gpu_reset(rdev)) {
1359 dev_warn(rdev->dev,
1360 "GPU reset failed ! (0xE40=0x%08X, 0x7C0=0x%08X)\n",
1361 RREG32(R_000E40_RBBM_STATUS),
1362 RREG32(R_0007C0_CP_STAT));
1363 }
1364 /* check if cards are posted or not */
Dave Airlie72542d72009-12-01 14:06:31 +10001365 if (radeon_boot_test_post_card(rdev) == false)
1366 return -EINVAL;
Jerome Glisse207bf9e2009-09-30 15:35:32 +02001367 /* Set asic errata */
1368 r300_errata(rdev);
1369 /* Initialize clocks */
1370 radeon_get_clock_info(rdev->ddev);
Rafał Miłecki62340772009-12-15 21:46:58 +01001371 /* Initialize power management */
1372 radeon_pm_init(rdev);
Jerome Glisse207bf9e2009-09-30 15:35:32 +02001373 /* Get vram informations */
1374 r300_vram_info(rdev);
1375 /* Initialize memory controller (also test AGP) */
1376 r = r420_mc_init(rdev);
1377 if (r)
1378 return r;
1379 /* Fence driver */
1380 r = radeon_fence_driver_init(rdev);
1381 if (r)
1382 return r;
1383 r = radeon_irq_kms_init(rdev);
1384 if (r)
1385 return r;
1386 /* Memory manager */
Jerome Glisse4c788672009-11-20 14:29:23 +01001387 r = radeon_bo_init(rdev);
Jerome Glisse207bf9e2009-09-30 15:35:32 +02001388 if (r)
1389 return r;
1390 if (rdev->flags & RADEON_IS_PCIE) {
1391 r = rv370_pcie_gart_init(rdev);
1392 if (r)
1393 return r;
1394 }
1395 if (rdev->flags & RADEON_IS_PCI) {
1396 r = r100_pci_gart_init(rdev);
1397 if (r)
1398 return r;
1399 }
1400 r300_set_reg_safe(rdev);
1401 rdev->accel_working = true;
1402 r = r300_startup(rdev);
1403 if (r) {
1404 /* Somethings want wront with the accel init stop accel */
1405 dev_err(rdev->dev, "Disabling GPU acceleration\n");
1406 r300_suspend(rdev);
1407 r100_cp_fini(rdev);
1408 r100_wb_fini(rdev);
1409 r100_ib_fini(rdev);
1410 if (rdev->flags & RADEON_IS_PCIE)
1411 rv370_pcie_gart_fini(rdev);
1412 if (rdev->flags & RADEON_IS_PCI)
1413 r100_pci_gart_fini(rdev);
1414 radeon_irq_kms_fini(rdev);
1415 rdev->accel_working = false;
1416 }
1417 return 0;
1418}