2 * Copyright 2008 Advanced Micro Devices, Inc.
3 * Copyright 2008 Red Hat Inc.
4 * Copyright 2009 Jerome Glisse.
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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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.
24 * Authors: Dave Airlie
28 #include <linux/seq_file.h>
29 #include <linux/firmware.h>
30 #include <linux/platform_device.h>
32 #include "radeon_drm.h"
34 #include "radeon_mode.h"
39 #define PFP_UCODE_SIZE 576
40 #define PM4_UCODE_SIZE 1792
41 #define R700_PFP_UCODE_SIZE 848
42 #define R700_PM4_UCODE_SIZE 1360
45 MODULE_FIRMWARE("radeon/R600_pfp.bin");
46 MODULE_FIRMWARE("radeon/R600_me.bin");
47 MODULE_FIRMWARE("radeon/RV610_pfp.bin");
48 MODULE_FIRMWARE("radeon/RV610_me.bin");
49 MODULE_FIRMWARE("radeon/RV630_pfp.bin");
50 MODULE_FIRMWARE("radeon/RV630_me.bin");
51 MODULE_FIRMWARE("radeon/RV620_pfp.bin");
52 MODULE_FIRMWARE("radeon/RV620_me.bin");
53 MODULE_FIRMWARE("radeon/RV635_pfp.bin");
54 MODULE_FIRMWARE("radeon/RV635_me.bin");
55 MODULE_FIRMWARE("radeon/RV670_pfp.bin");
56 MODULE_FIRMWARE("radeon/RV670_me.bin");
57 MODULE_FIRMWARE("radeon/RS780_pfp.bin");
58 MODULE_FIRMWARE("radeon/RS780_me.bin");
59 MODULE_FIRMWARE("radeon/RV770_pfp.bin");
60 MODULE_FIRMWARE("radeon/RV770_me.bin");
61 MODULE_FIRMWARE("radeon/RV730_pfp.bin");
62 MODULE_FIRMWARE("radeon/RV730_me.bin");
63 MODULE_FIRMWARE("radeon/RV710_pfp.bin");
64 MODULE_FIRMWARE("radeon/RV710_me.bin");
66 int r600_debugfs_mc_info_init(struct radeon_device
*rdev
);
68 /* r600,rv610,rv630,rv620,rv635,rv670 */
69 int r600_mc_wait_for_idle(struct radeon_device
*rdev
);
70 void r600_gpu_init(struct radeon_device
*rdev
);
71 void r600_fini(struct radeon_device
*rdev
);
76 int r600_gart_clear_page(struct radeon_device
*rdev
, int i
)
78 void __iomem
*ptr
= (void *)rdev
->gart
.table
.vram
.ptr
;
81 if (i
< 0 || i
> rdev
->gart
.num_gpu_pages
)
84 writeq(pte
, ((void __iomem
*)ptr
) + (i
* 8));
88 void r600_pcie_gart_tlb_flush(struct radeon_device
*rdev
)
93 WREG32(VM_CONTEXT0_INVALIDATION_LOW_ADDR
, rdev
->mc
.gtt_start
>> 12);
94 WREG32(VM_CONTEXT0_INVALIDATION_HIGH_ADDR
, (rdev
->mc
.gtt_end
- 1) >> 12);
95 WREG32(VM_CONTEXT0_REQUEST_RESPONSE
, REQUEST_TYPE(1));
96 for (i
= 0; i
< rdev
->usec_timeout
; i
++) {
98 tmp
= RREG32(VM_CONTEXT0_REQUEST_RESPONSE
);
99 tmp
= (tmp
& RESPONSE_TYPE_MASK
) >> RESPONSE_TYPE_SHIFT
;
101 printk(KERN_WARNING
"[drm] r600 flush TLB failed\n");
111 int r600_pcie_gart_init(struct radeon_device
*rdev
)
115 if (rdev
->gart
.table
.vram
.robj
) {
116 WARN(1, "R600 PCIE GART already initialized.\n");
119 /* Initialize common gart structure */
120 r
= radeon_gart_init(rdev
);
123 rdev
->gart
.table_size
= rdev
->gart
.num_gpu_pages
* 8;
124 return radeon_gart_table_vram_alloc(rdev
);
127 int r600_pcie_gart_enable(struct radeon_device
*rdev
)
132 if (rdev
->gart
.table
.vram
.robj
== NULL
) {
133 dev_err(rdev
->dev
, "No VRAM object for PCIE GART.\n");
136 r
= radeon_gart_table_vram_pin(rdev
);
141 WREG32(VM_L2_CNTL
, ENABLE_L2_CACHE
| ENABLE_L2_FRAGMENT_PROCESSING
|
142 ENABLE_L2_PTE_CACHE_LRU_UPDATE_BY_WRITE
|
143 EFFECTIVE_L2_QUEUE_SIZE(7));
144 WREG32(VM_L2_CNTL2
, 0);
145 WREG32(VM_L2_CNTL3
, BANK_SELECT_0(0) | BANK_SELECT_1(1));
146 /* Setup TLB control */
147 tmp
= ENABLE_L1_TLB
| ENABLE_L1_FRAGMENT_PROCESSING
|
148 SYSTEM_ACCESS_MODE_NOT_IN_SYS
|
149 EFFECTIVE_L1_TLB_SIZE(5) | EFFECTIVE_L1_QUEUE_SIZE(5) |
150 ENABLE_WAIT_L2_QUERY
;
151 WREG32(MC_VM_L1_TLB_MCB_RD_SYS_CNTL
, tmp
);
152 WREG32(MC_VM_L1_TLB_MCB_WR_SYS_CNTL
, tmp
);
153 WREG32(MC_VM_L1_TLB_MCB_RD_HDP_CNTL
, tmp
| ENABLE_L1_STRICT_ORDERING
);
154 WREG32(MC_VM_L1_TLB_MCB_WR_HDP_CNTL
, tmp
);
155 WREG32(MC_VM_L1_TLB_MCD_RD_A_CNTL
, tmp
);
156 WREG32(MC_VM_L1_TLB_MCD_WR_A_CNTL
, tmp
);
157 WREG32(MC_VM_L1_TLB_MCD_RD_B_CNTL
, tmp
);
158 WREG32(MC_VM_L1_TLB_MCD_WR_B_CNTL
, tmp
);
159 WREG32(MC_VM_L1_TLB_MCB_RD_GFX_CNTL
, tmp
);
160 WREG32(MC_VM_L1_TLB_MCB_WR_GFX_CNTL
, tmp
);
161 WREG32(MC_VM_L1_TLB_MCB_RD_PDMA_CNTL
, tmp
);
162 WREG32(MC_VM_L1_TLB_MCB_WR_PDMA_CNTL
, tmp
);
163 WREG32(MC_VM_L1_TLB_MCB_RD_SEM_CNTL
, tmp
| ENABLE_SEMAPHORE_MODE
);
164 WREG32(MC_VM_L1_TLB_MCB_WR_SEM_CNTL
, tmp
| ENABLE_SEMAPHORE_MODE
);
165 WREG32(VM_CONTEXT0_PAGE_TABLE_START_ADDR
, rdev
->mc
.gtt_start
>> 12);
166 WREG32(VM_CONTEXT0_PAGE_TABLE_END_ADDR
, rdev
->mc
.gtt_end
>> 12);
167 WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR
, rdev
->gart
.table_addr
>> 12);
168 WREG32(VM_CONTEXT0_CNTL
, ENABLE_CONTEXT
| PAGE_TABLE_DEPTH(0) |
169 RANGE_PROTECTION_FAULT_ENABLE_DEFAULT
);
170 WREG32(VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR
,
171 (u32
)(rdev
->dummy_page
.addr
>> 12));
172 for (i
= 1; i
< 7; i
++)
173 WREG32(VM_CONTEXT0_CNTL
+ (i
* 4), 0);
175 r600_pcie_gart_tlb_flush(rdev
);
176 rdev
->gart
.ready
= true;
180 void r600_pcie_gart_disable(struct radeon_device
*rdev
)
185 /* Disable all tables */
186 for (i
= 0; i
< 7; i
++)
187 WREG32(VM_CONTEXT0_CNTL
+ (i
* 4), 0);
189 /* Disable L2 cache */
190 WREG32(VM_L2_CNTL
, ENABLE_L2_FRAGMENT_PROCESSING
|
191 EFFECTIVE_L2_QUEUE_SIZE(7));
192 WREG32(VM_L2_CNTL3
, BANK_SELECT_0(0) | BANK_SELECT_1(1));
193 /* Setup L1 TLB control */
194 tmp
= EFFECTIVE_L1_TLB_SIZE(5) | EFFECTIVE_L1_QUEUE_SIZE(5) |
195 ENABLE_WAIT_L2_QUERY
;
196 WREG32(MC_VM_L1_TLB_MCD_RD_A_CNTL
, tmp
);
197 WREG32(MC_VM_L1_TLB_MCD_WR_A_CNTL
, tmp
);
198 WREG32(MC_VM_L1_TLB_MCD_RD_B_CNTL
, tmp
);
199 WREG32(MC_VM_L1_TLB_MCD_WR_B_CNTL
, tmp
);
200 WREG32(MC_VM_L1_TLB_MCB_RD_GFX_CNTL
, tmp
);
201 WREG32(MC_VM_L1_TLB_MCB_WR_GFX_CNTL
, tmp
);
202 WREG32(MC_VM_L1_TLB_MCB_RD_PDMA_CNTL
, tmp
);
203 WREG32(MC_VM_L1_TLB_MCB_WR_PDMA_CNTL
, tmp
);
204 WREG32(MC_VM_L1_TLB_MCB_RD_SEM_CNTL
, tmp
);
205 WREG32(MC_VM_L1_TLB_MCB_WR_SEM_CNTL
, tmp
);
206 WREG32(MC_VM_L1_TLB_MCB_RD_SYS_CNTL
, tmp
);
207 WREG32(MC_VM_L1_TLB_MCB_WR_SYS_CNTL
, tmp
);
208 WREG32(MC_VM_L1_TLB_MCB_RD_HDP_CNTL
, tmp
);
209 WREG32(MC_VM_L1_TLB_MCB_WR_HDP_CNTL
, tmp
);
210 if (rdev
->gart
.table
.vram
.robj
) {
211 radeon_object_kunmap(rdev
->gart
.table
.vram
.robj
);
212 radeon_object_unpin(rdev
->gart
.table
.vram
.robj
);
216 void r600_pcie_gart_fini(struct radeon_device
*rdev
)
218 r600_pcie_gart_disable(rdev
);
219 radeon_gart_table_vram_free(rdev
);
220 radeon_gart_fini(rdev
);
223 void r600_agp_enable(struct radeon_device
*rdev
)
229 WREG32(VM_L2_CNTL
, ENABLE_L2_CACHE
| ENABLE_L2_FRAGMENT_PROCESSING
|
230 ENABLE_L2_PTE_CACHE_LRU_UPDATE_BY_WRITE
|
231 EFFECTIVE_L2_QUEUE_SIZE(7));
232 WREG32(VM_L2_CNTL2
, 0);
233 WREG32(VM_L2_CNTL3
, BANK_SELECT_0(0) | BANK_SELECT_1(1));
234 /* Setup TLB control */
235 tmp
= ENABLE_L1_TLB
| ENABLE_L1_FRAGMENT_PROCESSING
|
236 SYSTEM_ACCESS_MODE_NOT_IN_SYS
|
237 EFFECTIVE_L1_TLB_SIZE(5) | EFFECTIVE_L1_QUEUE_SIZE(5) |
238 ENABLE_WAIT_L2_QUERY
;
239 WREG32(MC_VM_L1_TLB_MCB_RD_SYS_CNTL
, tmp
);
240 WREG32(MC_VM_L1_TLB_MCB_WR_SYS_CNTL
, tmp
);
241 WREG32(MC_VM_L1_TLB_MCB_RD_HDP_CNTL
, tmp
| ENABLE_L1_STRICT_ORDERING
);
242 WREG32(MC_VM_L1_TLB_MCB_WR_HDP_CNTL
, tmp
);
243 WREG32(MC_VM_L1_TLB_MCD_RD_A_CNTL
, tmp
);
244 WREG32(MC_VM_L1_TLB_MCD_WR_A_CNTL
, tmp
);
245 WREG32(MC_VM_L1_TLB_MCD_RD_B_CNTL
, tmp
);
246 WREG32(MC_VM_L1_TLB_MCD_WR_B_CNTL
, tmp
);
247 WREG32(MC_VM_L1_TLB_MCB_RD_GFX_CNTL
, tmp
);
248 WREG32(MC_VM_L1_TLB_MCB_WR_GFX_CNTL
, tmp
);
249 WREG32(MC_VM_L1_TLB_MCB_RD_PDMA_CNTL
, tmp
);
250 WREG32(MC_VM_L1_TLB_MCB_WR_PDMA_CNTL
, tmp
);
251 WREG32(MC_VM_L1_TLB_MCB_RD_SEM_CNTL
, tmp
| ENABLE_SEMAPHORE_MODE
);
252 WREG32(MC_VM_L1_TLB_MCB_WR_SEM_CNTL
, tmp
| ENABLE_SEMAPHORE_MODE
);
253 for (i
= 0; i
< 7; i
++)
254 WREG32(VM_CONTEXT0_CNTL
+ (i
* 4), 0);
257 int r600_mc_wait_for_idle(struct radeon_device
*rdev
)
262 for (i
= 0; i
< rdev
->usec_timeout
; i
++) {
264 tmp
= RREG32(R_000E50_SRBM_STATUS
) & 0x3F00;
272 static void r600_mc_program(struct radeon_device
*rdev
)
274 struct rv515_mc_save save
;
279 for (i
= 0, j
= 0; i
< 32; i
++, j
+= 0x18) {
280 WREG32((0x2c14 + j
), 0x00000000);
281 WREG32((0x2c18 + j
), 0x00000000);
282 WREG32((0x2c1c + j
), 0x00000000);
283 WREG32((0x2c20 + j
), 0x00000000);
284 WREG32((0x2c24 + j
), 0x00000000);
286 WREG32(HDP_REG_COHERENCY_FLUSH_CNTL
, 0);
288 rv515_mc_stop(rdev
, &save
);
289 if (r600_mc_wait_for_idle(rdev
)) {
290 dev_warn(rdev
->dev
, "Wait for MC idle timedout !\n");
292 /* Lockout access through VGA aperture (doesn't exist before R600) */
293 WREG32(VGA_HDP_CONTROL
, VGA_MEMORY_DISABLE
);
294 /* Update configuration */
295 if (rdev
->flags
& RADEON_IS_AGP
) {
296 if (rdev
->mc
.vram_start
< rdev
->mc
.gtt_start
) {
297 /* VRAM before AGP */
298 WREG32(MC_VM_SYSTEM_APERTURE_LOW_ADDR
,
299 rdev
->mc
.vram_start
>> 12);
300 WREG32(MC_VM_SYSTEM_APERTURE_HIGH_ADDR
,
301 rdev
->mc
.gtt_end
>> 12);
304 WREG32(MC_VM_SYSTEM_APERTURE_LOW_ADDR
,
305 rdev
->mc
.gtt_start
>> 12);
306 WREG32(MC_VM_SYSTEM_APERTURE_HIGH_ADDR
,
307 rdev
->mc
.vram_end
>> 12);
310 WREG32(MC_VM_SYSTEM_APERTURE_LOW_ADDR
, rdev
->mc
.vram_start
>> 12);
311 WREG32(MC_VM_SYSTEM_APERTURE_HIGH_ADDR
, rdev
->mc
.vram_end
>> 12);
313 WREG32(MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR
, 0);
314 tmp
= ((rdev
->mc
.vram_end
>> 24) & 0xFFFF) << 16;
315 tmp
|= ((rdev
->mc
.vram_start
>> 24) & 0xFFFF);
316 WREG32(MC_VM_FB_LOCATION
, tmp
);
317 WREG32(HDP_NONSURFACE_BASE
, (rdev
->mc
.vram_start
>> 8));
318 WREG32(HDP_NONSURFACE_INFO
, (2 << 7));
319 WREG32(HDP_NONSURFACE_SIZE
, rdev
->mc
.mc_vram_size
| 0x3FF);
320 if (rdev
->flags
& RADEON_IS_AGP
) {
321 WREG32(MC_VM_AGP_TOP
, rdev
->mc
.gtt_end
>> 22);
322 WREG32(MC_VM_AGP_BOT
, rdev
->mc
.gtt_start
>> 22);
323 WREG32(MC_VM_AGP_BASE
, rdev
->mc
.agp_base
>> 22);
325 WREG32(MC_VM_AGP_BASE
, 0);
326 WREG32(MC_VM_AGP_TOP
, 0x0FFFFFFF);
327 WREG32(MC_VM_AGP_BOT
, 0x0FFFFFFF);
329 if (r600_mc_wait_for_idle(rdev
)) {
330 dev_warn(rdev
->dev
, "Wait for MC idle timedout !\n");
332 rv515_mc_resume(rdev
, &save
);
333 /* we need to own VRAM, so turn off the VGA renderer here
334 * to stop it overwriting our objects */
335 rv515_vga_render_disable(rdev
);
338 int r600_mc_init(struct radeon_device
*rdev
)
342 int chansize
, numchan
;
345 /* Get VRAM informations */
346 rdev
->mc
.vram_is_ddr
= true;
347 tmp
= RREG32(RAMCFG
);
348 if (tmp
& CHANSIZE_OVERRIDE
) {
350 } else if (tmp
& CHANSIZE_MASK
) {
356 switch ((tmp
& NOOFCHAN_MASK
) >> NOOFCHAN_SHIFT
) {
371 rdev
->mc
.vram_width
= numchan
* chansize
;
372 /* Could aper size report 0 ? */
373 rdev
->mc
.aper_base
= drm_get_resource_start(rdev
->ddev
, 0);
374 rdev
->mc
.aper_size
= drm_get_resource_len(rdev
->ddev
, 0);
375 /* Setup GPU memory space */
376 rdev
->mc
.mc_vram_size
= RREG32(CONFIG_MEMSIZE
);
377 rdev
->mc
.real_vram_size
= RREG32(CONFIG_MEMSIZE
);
379 if (rdev
->mc
.mc_vram_size
> rdev
->mc
.aper_size
)
380 rdev
->mc
.mc_vram_size
= rdev
->mc
.aper_size
;
382 if (rdev
->mc
.real_vram_size
> rdev
->mc
.aper_size
)
383 rdev
->mc
.real_vram_size
= rdev
->mc
.aper_size
;
385 if (rdev
->flags
& RADEON_IS_AGP
) {
386 r
= radeon_agp_init(rdev
);
389 /* gtt_size is setup by radeon_agp_init */
390 rdev
->mc
.gtt_location
= rdev
->mc
.agp_base
;
391 tmp
= 0xFFFFFFFFUL
- rdev
->mc
.agp_base
- rdev
->mc
.gtt_size
;
392 /* Try to put vram before or after AGP because we
393 * we want SYSTEM_APERTURE to cover both VRAM and
394 * AGP so that GPU can catch out of VRAM/AGP access
396 if (rdev
->mc
.gtt_location
> rdev
->mc
.mc_vram_size
) {
397 /* Enought place before */
398 rdev
->mc
.vram_location
= rdev
->mc
.gtt_location
-
399 rdev
->mc
.mc_vram_size
;
400 } else if (tmp
> rdev
->mc
.mc_vram_size
) {
401 /* Enought place after */
402 rdev
->mc
.vram_location
= rdev
->mc
.gtt_location
+
405 /* Try to setup VRAM then AGP might not
406 * not work on some card
408 rdev
->mc
.vram_location
= 0x00000000UL
;
409 rdev
->mc
.gtt_location
= rdev
->mc
.mc_vram_size
;
412 rdev
->mc
.gtt_size
= radeon_gart_size
* 1024 * 1024;
413 rdev
->mc
.vram_location
= (RREG32(MC_VM_FB_LOCATION
) &
415 tmp
= rdev
->mc
.vram_location
+ rdev
->mc
.mc_vram_size
;
416 if ((0xFFFFFFFFUL
- tmp
) >= rdev
->mc
.gtt_size
) {
417 /* Enough place after vram */
418 rdev
->mc
.gtt_location
= tmp
;
419 } else if (rdev
->mc
.vram_location
>= rdev
->mc
.gtt_size
) {
420 /* Enough place before vram */
421 rdev
->mc
.gtt_location
= 0;
423 /* Not enough place after or before shrink
426 if (rdev
->mc
.vram_location
> (0xFFFFFFFFUL
- tmp
)) {
427 rdev
->mc
.gtt_location
= 0;
428 rdev
->mc
.gtt_size
= rdev
->mc
.vram_location
;
430 rdev
->mc
.gtt_location
= tmp
;
431 rdev
->mc
.gtt_size
= 0xFFFFFFFFUL
- tmp
;
434 rdev
->mc
.gtt_location
= rdev
->mc
.mc_vram_size
;
436 rdev
->mc
.vram_start
= rdev
->mc
.vram_location
;
437 rdev
->mc
.vram_end
= rdev
->mc
.vram_location
+ rdev
->mc
.mc_vram_size
- 1;
438 rdev
->mc
.gtt_start
= rdev
->mc
.gtt_location
;
439 rdev
->mc
.gtt_end
= rdev
->mc
.gtt_location
+ rdev
->mc
.gtt_size
- 1;
440 /* FIXME: we should enforce default clock in case GPU is not in
443 a
.full
= rfixed_const(100);
444 rdev
->pm
.sclk
.full
= rfixed_const(rdev
->clock
.default_sclk
);
445 rdev
->pm
.sclk
.full
= rfixed_div(rdev
->pm
.sclk
, a
);
449 /* We doesn't check that the GPU really needs a reset we simply do the
450 * reset, it's up to the caller to determine if the GPU needs one. We
451 * might add an helper function to check that.
453 int r600_gpu_soft_reset(struct radeon_device
*rdev
)
455 struct rv515_mc_save save
;
456 u32 grbm_busy_mask
= S_008010_VC_BUSY(1) | S_008010_VGT_BUSY_NO_DMA(1) |
457 S_008010_VGT_BUSY(1) | S_008010_TA03_BUSY(1) |
458 S_008010_TC_BUSY(1) | S_008010_SX_BUSY(1) |
459 S_008010_SH_BUSY(1) | S_008010_SPI03_BUSY(1) |
460 S_008010_SMX_BUSY(1) | S_008010_SC_BUSY(1) |
461 S_008010_PA_BUSY(1) | S_008010_DB03_BUSY(1) |
462 S_008010_CR_BUSY(1) | S_008010_CB03_BUSY(1) |
463 S_008010_GUI_ACTIVE(1);
464 u32 grbm2_busy_mask
= S_008014_SPI0_BUSY(1) | S_008014_SPI1_BUSY(1) |
465 S_008014_SPI2_BUSY(1) | S_008014_SPI3_BUSY(1) |
466 S_008014_TA0_BUSY(1) | S_008014_TA1_BUSY(1) |
467 S_008014_TA2_BUSY(1) | S_008014_TA3_BUSY(1) |
468 S_008014_DB0_BUSY(1) | S_008014_DB1_BUSY(1) |
469 S_008014_DB2_BUSY(1) | S_008014_DB3_BUSY(1) |
470 S_008014_CB0_BUSY(1) | S_008014_CB1_BUSY(1) |
471 S_008014_CB2_BUSY(1) | S_008014_CB3_BUSY(1);
475 dev_info(rdev
->dev
, "GPU softreset \n");
476 dev_info(rdev
->dev
, " R_008010_GRBM_STATUS=0x%08X\n",
477 RREG32(R_008010_GRBM_STATUS
));
478 dev_info(rdev
->dev
, " R_008014_GRBM_STATUS2=0x%08X\n",
479 RREG32(R_008014_GRBM_STATUS2
));
480 dev_info(rdev
->dev
, " R_000E50_SRBM_STATUS=0x%08X\n",
481 RREG32(R_000E50_SRBM_STATUS
));
482 rv515_mc_stop(rdev
, &save
);
483 if (r600_mc_wait_for_idle(rdev
)) {
484 dev_warn(rdev
->dev
, "Wait for MC idle timedout !\n");
486 /* Disable CP parsing/prefetching */
487 WREG32(R_0086D8_CP_ME_CNTL
, S_0086D8_CP_ME_HALT(0xff));
488 /* Check if any of the rendering block is busy and reset it */
489 if ((RREG32(R_008010_GRBM_STATUS
) & grbm_busy_mask
) ||
490 (RREG32(R_008014_GRBM_STATUS2
) & grbm2_busy_mask
)) {
491 tmp
= S_008020_SOFT_RESET_CR(1) |
492 S_008020_SOFT_RESET_DB(1) |
493 S_008020_SOFT_RESET_CB(1) |
494 S_008020_SOFT_RESET_PA(1) |
495 S_008020_SOFT_RESET_SC(1) |
496 S_008020_SOFT_RESET_SMX(1) |
497 S_008020_SOFT_RESET_SPI(1) |
498 S_008020_SOFT_RESET_SX(1) |
499 S_008020_SOFT_RESET_SH(1) |
500 S_008020_SOFT_RESET_TC(1) |
501 S_008020_SOFT_RESET_TA(1) |
502 S_008020_SOFT_RESET_VC(1) |
503 S_008020_SOFT_RESET_VGT(1);
504 dev_info(rdev
->dev
, " R_008020_GRBM_SOFT_RESET=0x%08X\n", tmp
);
505 WREG32(R_008020_GRBM_SOFT_RESET
, tmp
);
506 (void)RREG32(R_008020_GRBM_SOFT_RESET
);
508 WREG32(R_008020_GRBM_SOFT_RESET
, 0);
509 (void)RREG32(R_008020_GRBM_SOFT_RESET
);
511 /* Reset CP (we always reset CP) */
512 tmp
= S_008020_SOFT_RESET_CP(1);
513 dev_info(rdev
->dev
, "R_008020_GRBM_SOFT_RESET=0x%08X\n", tmp
);
514 WREG32(R_008020_GRBM_SOFT_RESET
, tmp
);
515 (void)RREG32(R_008020_GRBM_SOFT_RESET
);
517 WREG32(R_008020_GRBM_SOFT_RESET
, 0);
518 (void)RREG32(R_008020_GRBM_SOFT_RESET
);
519 /* Reset others GPU block if necessary */
520 if (G_000E50_RLC_BUSY(RREG32(R_000E50_SRBM_STATUS
)))
521 srbm_reset
|= S_000E60_SOFT_RESET_RLC(1);
522 if (G_000E50_GRBM_RQ_PENDING(RREG32(R_000E50_SRBM_STATUS
)))
523 srbm_reset
|= S_000E60_SOFT_RESET_GRBM(1);
524 if (G_000E50_HI_RQ_PENDING(RREG32(R_000E50_SRBM_STATUS
)))
525 srbm_reset
|= S_000E60_SOFT_RESET_IH(1);
526 if (G_000E50_VMC_BUSY(RREG32(R_000E50_SRBM_STATUS
)))
527 srbm_reset
|= S_000E60_SOFT_RESET_VMC(1);
528 if (G_000E50_MCB_BUSY(RREG32(R_000E50_SRBM_STATUS
)))
529 srbm_reset
|= S_000E60_SOFT_RESET_MC(1);
530 if (G_000E50_MCDZ_BUSY(RREG32(R_000E50_SRBM_STATUS
)))
531 srbm_reset
|= S_000E60_SOFT_RESET_MC(1);
532 if (G_000E50_MCDY_BUSY(RREG32(R_000E50_SRBM_STATUS
)))
533 srbm_reset
|= S_000E60_SOFT_RESET_MC(1);
534 if (G_000E50_MCDX_BUSY(RREG32(R_000E50_SRBM_STATUS
)))
535 srbm_reset
|= S_000E60_SOFT_RESET_MC(1);
536 if (G_000E50_MCDW_BUSY(RREG32(R_000E50_SRBM_STATUS
)))
537 srbm_reset
|= S_000E60_SOFT_RESET_MC(1);
538 if (G_000E50_RLC_BUSY(RREG32(R_000E50_SRBM_STATUS
)))
539 srbm_reset
|= S_000E60_SOFT_RESET_RLC(1);
540 if (G_000E50_SEM_BUSY(RREG32(R_000E50_SRBM_STATUS
)))
541 srbm_reset
|= S_000E60_SOFT_RESET_SEM(1);
542 if (G_000E50_BIF_BUSY(RREG32(R_000E50_SRBM_STATUS
)))
543 srbm_reset
|= S_000E60_SOFT_RESET_BIF(1);
544 dev_info(rdev
->dev
, " R_000E60_SRBM_SOFT_RESET=0x%08X\n", srbm_reset
);
545 WREG32(R_000E60_SRBM_SOFT_RESET
, srbm_reset
);
546 (void)RREG32(R_000E60_SRBM_SOFT_RESET
);
548 WREG32(R_000E60_SRBM_SOFT_RESET
, 0);
549 (void)RREG32(R_000E60_SRBM_SOFT_RESET
);
550 WREG32(R_000E60_SRBM_SOFT_RESET
, srbm_reset
);
551 (void)RREG32(R_000E60_SRBM_SOFT_RESET
);
553 WREG32(R_000E60_SRBM_SOFT_RESET
, 0);
554 (void)RREG32(R_000E60_SRBM_SOFT_RESET
);
555 /* Wait a little for things to settle down */
557 dev_info(rdev
->dev
, " R_008010_GRBM_STATUS=0x%08X\n",
558 RREG32(R_008010_GRBM_STATUS
));
559 dev_info(rdev
->dev
, " R_008014_GRBM_STATUS2=0x%08X\n",
560 RREG32(R_008014_GRBM_STATUS2
));
561 dev_info(rdev
->dev
, " R_000E50_SRBM_STATUS=0x%08X\n",
562 RREG32(R_000E50_SRBM_STATUS
));
563 /* After reset we need to reinit the asic as GPU often endup in an
566 atom_asic_init(rdev
->mode_info
.atom_context
);
567 rv515_mc_resume(rdev
, &save
);
571 int r600_gpu_reset(struct radeon_device
*rdev
)
573 return r600_gpu_soft_reset(rdev
);
576 static u32
r600_get_tile_pipe_to_backend_map(u32 num_tile_pipes
,
578 u32 backend_disable_mask
)
581 u32 enabled_backends_mask
;
582 u32 enabled_backends_count
;
584 u32 swizzle_pipe
[R6XX_MAX_PIPES
];
588 if (num_tile_pipes
> R6XX_MAX_PIPES
)
589 num_tile_pipes
= R6XX_MAX_PIPES
;
590 if (num_tile_pipes
< 1)
592 if (num_backends
> R6XX_MAX_BACKENDS
)
593 num_backends
= R6XX_MAX_BACKENDS
;
594 if (num_backends
< 1)
597 enabled_backends_mask
= 0;
598 enabled_backends_count
= 0;
599 for (i
= 0; i
< R6XX_MAX_BACKENDS
; ++i
) {
600 if (((backend_disable_mask
>> i
) & 1) == 0) {
601 enabled_backends_mask
|= (1 << i
);
602 ++enabled_backends_count
;
604 if (enabled_backends_count
== num_backends
)
608 if (enabled_backends_count
== 0) {
609 enabled_backends_mask
= 1;
610 enabled_backends_count
= 1;
613 if (enabled_backends_count
!= num_backends
)
614 num_backends
= enabled_backends_count
;
616 memset((uint8_t *)&swizzle_pipe
[0], 0, sizeof(u32
) * R6XX_MAX_PIPES
);
617 switch (num_tile_pipes
) {
673 for (cur_pipe
= 0; cur_pipe
< num_tile_pipes
; ++cur_pipe
) {
674 while (((1 << cur_backend
) & enabled_backends_mask
) == 0)
675 cur_backend
= (cur_backend
+ 1) % R6XX_MAX_BACKENDS
;
677 backend_map
|= (u32
)(((cur_backend
& 3) << (swizzle_pipe
[cur_pipe
] * 2)));
679 cur_backend
= (cur_backend
+ 1) % R6XX_MAX_BACKENDS
;
685 int r600_count_pipe_bits(uint32_t val
)
689 for (i
= 0; i
< 32; i
++) {
696 void r600_gpu_init(struct radeon_device
*rdev
)
703 u32 sq_gpr_resource_mgmt_1
= 0;
704 u32 sq_gpr_resource_mgmt_2
= 0;
705 u32 sq_thread_resource_mgmt
= 0;
706 u32 sq_stack_resource_mgmt_1
= 0;
707 u32 sq_stack_resource_mgmt_2
= 0;
709 /* FIXME: implement */
710 switch (rdev
->family
) {
712 rdev
->config
.r600
.max_pipes
= 4;
713 rdev
->config
.r600
.max_tile_pipes
= 8;
714 rdev
->config
.r600
.max_simds
= 4;
715 rdev
->config
.r600
.max_backends
= 4;
716 rdev
->config
.r600
.max_gprs
= 256;
717 rdev
->config
.r600
.max_threads
= 192;
718 rdev
->config
.r600
.max_stack_entries
= 256;
719 rdev
->config
.r600
.max_hw_contexts
= 8;
720 rdev
->config
.r600
.max_gs_threads
= 16;
721 rdev
->config
.r600
.sx_max_export_size
= 128;
722 rdev
->config
.r600
.sx_max_export_pos_size
= 16;
723 rdev
->config
.r600
.sx_max_export_smx_size
= 128;
724 rdev
->config
.r600
.sq_num_cf_insts
= 2;
728 rdev
->config
.r600
.max_pipes
= 2;
729 rdev
->config
.r600
.max_tile_pipes
= 2;
730 rdev
->config
.r600
.max_simds
= 3;
731 rdev
->config
.r600
.max_backends
= 1;
732 rdev
->config
.r600
.max_gprs
= 128;
733 rdev
->config
.r600
.max_threads
= 192;
734 rdev
->config
.r600
.max_stack_entries
= 128;
735 rdev
->config
.r600
.max_hw_contexts
= 8;
736 rdev
->config
.r600
.max_gs_threads
= 4;
737 rdev
->config
.r600
.sx_max_export_size
= 128;
738 rdev
->config
.r600
.sx_max_export_pos_size
= 16;
739 rdev
->config
.r600
.sx_max_export_smx_size
= 128;
740 rdev
->config
.r600
.sq_num_cf_insts
= 2;
746 rdev
->config
.r600
.max_pipes
= 1;
747 rdev
->config
.r600
.max_tile_pipes
= 1;
748 rdev
->config
.r600
.max_simds
= 2;
749 rdev
->config
.r600
.max_backends
= 1;
750 rdev
->config
.r600
.max_gprs
= 128;
751 rdev
->config
.r600
.max_threads
= 192;
752 rdev
->config
.r600
.max_stack_entries
= 128;
753 rdev
->config
.r600
.max_hw_contexts
= 4;
754 rdev
->config
.r600
.max_gs_threads
= 4;
755 rdev
->config
.r600
.sx_max_export_size
= 128;
756 rdev
->config
.r600
.sx_max_export_pos_size
= 16;
757 rdev
->config
.r600
.sx_max_export_smx_size
= 128;
758 rdev
->config
.r600
.sq_num_cf_insts
= 1;
761 rdev
->config
.r600
.max_pipes
= 4;
762 rdev
->config
.r600
.max_tile_pipes
= 4;
763 rdev
->config
.r600
.max_simds
= 4;
764 rdev
->config
.r600
.max_backends
= 4;
765 rdev
->config
.r600
.max_gprs
= 192;
766 rdev
->config
.r600
.max_threads
= 192;
767 rdev
->config
.r600
.max_stack_entries
= 256;
768 rdev
->config
.r600
.max_hw_contexts
= 8;
769 rdev
->config
.r600
.max_gs_threads
= 16;
770 rdev
->config
.r600
.sx_max_export_size
= 128;
771 rdev
->config
.r600
.sx_max_export_pos_size
= 16;
772 rdev
->config
.r600
.sx_max_export_smx_size
= 128;
773 rdev
->config
.r600
.sq_num_cf_insts
= 2;
780 for (i
= 0, j
= 0; i
< 32; i
++, j
+= 0x18) {
781 WREG32((0x2c14 + j
), 0x00000000);
782 WREG32((0x2c18 + j
), 0x00000000);
783 WREG32((0x2c1c + j
), 0x00000000);
784 WREG32((0x2c20 + j
), 0x00000000);
785 WREG32((0x2c24 + j
), 0x00000000);
788 WREG32(GRBM_CNTL
, GRBM_READ_TIMEOUT(0xff));
792 ramcfg
= RREG32(RAMCFG
);
793 switch (rdev
->config
.r600
.max_tile_pipes
) {
795 tiling_config
|= PIPE_TILING(0);
798 tiling_config
|= PIPE_TILING(1);
801 tiling_config
|= PIPE_TILING(2);
804 tiling_config
|= PIPE_TILING(3);
809 tiling_config
|= BANK_TILING((ramcfg
& NOOFBANK_MASK
) >> NOOFBANK_SHIFT
);
810 tiling_config
|= GROUP_SIZE(0);
811 tmp
= (ramcfg
& NOOFROWS_MASK
) >> NOOFROWS_SHIFT
;
813 tiling_config
|= ROW_TILING(3);
814 tiling_config
|= SAMPLE_SPLIT(3);
816 tiling_config
|= ROW_TILING(tmp
);
817 tiling_config
|= SAMPLE_SPLIT(tmp
);
819 tiling_config
|= BANK_SWAPS(1);
820 tmp
= r600_get_tile_pipe_to_backend_map(rdev
->config
.r600
.max_tile_pipes
,
821 rdev
->config
.r600
.max_backends
,
822 (0xff << rdev
->config
.r600
.max_backends
) & 0xff);
823 tiling_config
|= BACKEND_MAP(tmp
);
824 WREG32(GB_TILING_CONFIG
, tiling_config
);
825 WREG32(DCP_TILING_CONFIG
, tiling_config
& 0xffff);
826 WREG32(HDP_TILING_CONFIG
, tiling_config
& 0xffff);
828 tmp
= BACKEND_DISABLE((R6XX_MAX_BACKENDS_MASK
<< rdev
->config
.r600
.max_backends
) & R6XX_MAX_BACKENDS_MASK
);
829 WREG32(CC_RB_BACKEND_DISABLE
, tmp
);
832 tmp
= INACTIVE_QD_PIPES((R6XX_MAX_PIPES_MASK
<< rdev
->config
.r600
.max_pipes
) & R6XX_MAX_PIPES_MASK
);
833 tmp
|= INACTIVE_SIMDS((R6XX_MAX_SIMDS_MASK
<< rdev
->config
.r600
.max_simds
) & R6XX_MAX_SIMDS_MASK
);
834 WREG32(CC_GC_SHADER_PIPE_CONFIG
, tmp
);
835 WREG32(GC_USER_SHADER_PIPE_CONFIG
, tmp
);
837 tmp
= R6XX_MAX_BACKENDS
- r600_count_pipe_bits(tmp
& INACTIVE_QD_PIPES_MASK
);
838 WREG32(VGT_OUT_DEALLOC_CNTL
, (tmp
* 4) & DEALLOC_DIST_MASK
);
839 WREG32(VGT_VERTEX_REUSE_BLOCK_CNTL
, ((tmp
* 4) - 2) & VTX_REUSE_DEPTH_MASK
);
841 /* Setup some CP states */
842 WREG32(CP_QUEUE_THRESHOLDS
, (ROQ_IB1_START(0x16) | ROQ_IB2_START(0x2b)));
843 WREG32(CP_MEQ_THRESHOLDS
, (MEQ_END(0x40) | ROQ_END(0x40)));
845 WREG32(TA_CNTL_AUX
, (DISABLE_CUBE_ANISO
| SYNC_GRADIENT
|
846 SYNC_WALKER
| SYNC_ALIGNER
));
847 /* Setup various GPU states */
848 if (rdev
->family
== CHIP_RV670
)
849 WREG32(ARB_GDEC_RD_CNTL
, 0x00000021);
851 tmp
= RREG32(SX_DEBUG_1
);
852 tmp
|= SMX_EVENT_RELEASE
;
853 if ((rdev
->family
> CHIP_R600
))
854 tmp
|= ENABLE_NEW_SMX_ADDRESS
;
855 WREG32(SX_DEBUG_1
, tmp
);
857 if (((rdev
->family
) == CHIP_R600
) ||
858 ((rdev
->family
) == CHIP_RV630
) ||
859 ((rdev
->family
) == CHIP_RV610
) ||
860 ((rdev
->family
) == CHIP_RV620
) ||
861 ((rdev
->family
) == CHIP_RS780
) ||
862 ((rdev
->family
) == CHIP_RS880
)) {
863 WREG32(DB_DEBUG
, PREZ_MUST_WAIT_FOR_POSTZ_DONE
);
867 WREG32(DB_WATERMARKS
, (DEPTH_FREE(4) | DEPTH_CACHELINE_FREE(16) |
868 DEPTH_FLUSH(16) | DEPTH_PENDING_FREE(4)));
870 WREG32(PA_SC_MULTI_CHIP_CNTL
, 0);
871 WREG32(VGT_NUM_INSTANCES
, 0);
873 WREG32(SPI_CONFIG_CNTL
, GPR_WRITE_PRIORITY(0));
874 WREG32(SPI_CONFIG_CNTL_1
, VTX_DONE_DELAY(0));
876 tmp
= RREG32(SQ_MS_FIFO_SIZES
);
877 if (((rdev
->family
) == CHIP_RV610
) ||
878 ((rdev
->family
) == CHIP_RV620
) ||
879 ((rdev
->family
) == CHIP_RS780
) ||
880 ((rdev
->family
) == CHIP_RS880
)) {
881 tmp
= (CACHE_FIFO_SIZE(0xa) |
882 FETCH_FIFO_HIWATER(0xa) |
883 DONE_FIFO_HIWATER(0xe0) |
884 ALU_UPDATE_FIFO_HIWATER(0x8));
885 } else if (((rdev
->family
) == CHIP_R600
) ||
886 ((rdev
->family
) == CHIP_RV630
)) {
887 tmp
&= ~DONE_FIFO_HIWATER(0xff);
888 tmp
|= DONE_FIFO_HIWATER(0x4);
890 WREG32(SQ_MS_FIFO_SIZES
, tmp
);
892 /* SQ_CONFIG, SQ_GPR_RESOURCE_MGMT, SQ_THREAD_RESOURCE_MGMT, SQ_STACK_RESOURCE_MGMT
893 * should be adjusted as needed by the 2D/3D drivers. This just sets default values
895 sq_config
= RREG32(SQ_CONFIG
);
896 sq_config
&= ~(PS_PRIO(3) |
900 sq_config
|= (DX9_CONSTS
|
907 if ((rdev
->family
) == CHIP_R600
) {
908 sq_gpr_resource_mgmt_1
= (NUM_PS_GPRS(124) |
910 NUM_CLAUSE_TEMP_GPRS(4));
911 sq_gpr_resource_mgmt_2
= (NUM_GS_GPRS(0) |
913 sq_thread_resource_mgmt
= (NUM_PS_THREADS(136) |
917 sq_stack_resource_mgmt_1
= (NUM_PS_STACK_ENTRIES(128) |
918 NUM_VS_STACK_ENTRIES(128));
919 sq_stack_resource_mgmt_2
= (NUM_GS_STACK_ENTRIES(0) |
920 NUM_ES_STACK_ENTRIES(0));
921 } else if (((rdev
->family
) == CHIP_RV610
) ||
922 ((rdev
->family
) == CHIP_RV620
) ||
923 ((rdev
->family
) == CHIP_RS780
) ||
924 ((rdev
->family
) == CHIP_RS880
)) {
925 /* no vertex cache */
926 sq_config
&= ~VC_ENABLE
;
928 sq_gpr_resource_mgmt_1
= (NUM_PS_GPRS(44) |
930 NUM_CLAUSE_TEMP_GPRS(2));
931 sq_gpr_resource_mgmt_2
= (NUM_GS_GPRS(17) |
933 sq_thread_resource_mgmt
= (NUM_PS_THREADS(79) |
937 sq_stack_resource_mgmt_1
= (NUM_PS_STACK_ENTRIES(40) |
938 NUM_VS_STACK_ENTRIES(40));
939 sq_stack_resource_mgmt_2
= (NUM_GS_STACK_ENTRIES(32) |
940 NUM_ES_STACK_ENTRIES(16));
941 } else if (((rdev
->family
) == CHIP_RV630
) ||
942 ((rdev
->family
) == CHIP_RV635
)) {
943 sq_gpr_resource_mgmt_1
= (NUM_PS_GPRS(44) |
945 NUM_CLAUSE_TEMP_GPRS(2));
946 sq_gpr_resource_mgmt_2
= (NUM_GS_GPRS(18) |
948 sq_thread_resource_mgmt
= (NUM_PS_THREADS(79) |
952 sq_stack_resource_mgmt_1
= (NUM_PS_STACK_ENTRIES(40) |
953 NUM_VS_STACK_ENTRIES(40));
954 sq_stack_resource_mgmt_2
= (NUM_GS_STACK_ENTRIES(32) |
955 NUM_ES_STACK_ENTRIES(16));
956 } else if ((rdev
->family
) == CHIP_RV670
) {
957 sq_gpr_resource_mgmt_1
= (NUM_PS_GPRS(44) |
959 NUM_CLAUSE_TEMP_GPRS(2));
960 sq_gpr_resource_mgmt_2
= (NUM_GS_GPRS(17) |
962 sq_thread_resource_mgmt
= (NUM_PS_THREADS(79) |
966 sq_stack_resource_mgmt_1
= (NUM_PS_STACK_ENTRIES(64) |
967 NUM_VS_STACK_ENTRIES(64));
968 sq_stack_resource_mgmt_2
= (NUM_GS_STACK_ENTRIES(64) |
969 NUM_ES_STACK_ENTRIES(64));
972 WREG32(SQ_CONFIG
, sq_config
);
973 WREG32(SQ_GPR_RESOURCE_MGMT_1
, sq_gpr_resource_mgmt_1
);
974 WREG32(SQ_GPR_RESOURCE_MGMT_2
, sq_gpr_resource_mgmt_2
);
975 WREG32(SQ_THREAD_RESOURCE_MGMT
, sq_thread_resource_mgmt
);
976 WREG32(SQ_STACK_RESOURCE_MGMT_1
, sq_stack_resource_mgmt_1
);
977 WREG32(SQ_STACK_RESOURCE_MGMT_2
, sq_stack_resource_mgmt_2
);
979 if (((rdev
->family
) == CHIP_RV610
) ||
980 ((rdev
->family
) == CHIP_RV620
) ||
981 ((rdev
->family
) == CHIP_RS780
) ||
982 ((rdev
->family
) == CHIP_RS880
)) {
983 WREG32(VGT_CACHE_INVALIDATION
, CACHE_INVALIDATION(TC_ONLY
));
985 WREG32(VGT_CACHE_INVALIDATION
, CACHE_INVALIDATION(VC_AND_TC
));
988 /* More default values. 2D/3D driver should adjust as needed */
989 WREG32(PA_SC_AA_SAMPLE_LOCS_2S
, (S0_X(0xc) | S0_Y(0x4) |
990 S1_X(0x4) | S1_Y(0xc)));
991 WREG32(PA_SC_AA_SAMPLE_LOCS_4S
, (S0_X(0xe) | S0_Y(0xe) |
992 S1_X(0x2) | S1_Y(0x2) |
993 S2_X(0xa) | S2_Y(0x6) |
994 S3_X(0x6) | S3_Y(0xa)));
995 WREG32(PA_SC_AA_SAMPLE_LOCS_8S_WD0
, (S0_X(0xe) | S0_Y(0xb) |
996 S1_X(0x4) | S1_Y(0xc) |
997 S2_X(0x1) | S2_Y(0x6) |
998 S3_X(0xa) | S3_Y(0xe)));
999 WREG32(PA_SC_AA_SAMPLE_LOCS_8S_WD1
, (S4_X(0x6) | S4_Y(0x1) |
1000 S5_X(0x0) | S5_Y(0x0) |
1001 S6_X(0xb) | S6_Y(0x4) |
1002 S7_X(0x7) | S7_Y(0x8)));
1004 WREG32(VGT_STRMOUT_EN
, 0);
1005 tmp
= rdev
->config
.r600
.max_pipes
* 16;
1006 switch (rdev
->family
) {
1022 WREG32(VGT_ES_PER_GS
, 128);
1023 WREG32(VGT_GS_PER_ES
, tmp
);
1024 WREG32(VGT_GS_PER_VS
, 2);
1025 WREG32(VGT_GS_VERTEX_REUSE
, 16);
1027 /* more default values. 2D/3D driver should adjust as needed */
1028 WREG32(PA_SC_LINE_STIPPLE_STATE
, 0);
1029 WREG32(VGT_STRMOUT_EN
, 0);
1031 WREG32(PA_SC_MODE_CNTL
, 0);
1032 WREG32(PA_SC_AA_CONFIG
, 0);
1033 WREG32(PA_SC_LINE_STIPPLE
, 0);
1034 WREG32(SPI_INPUT_Z
, 0);
1035 WREG32(SPI_PS_IN_CONTROL_0
, NUM_INTERP(2));
1036 WREG32(CB_COLOR7_FRAG
, 0);
1038 /* Clear render buffer base addresses */
1039 WREG32(CB_COLOR0_BASE
, 0);
1040 WREG32(CB_COLOR1_BASE
, 0);
1041 WREG32(CB_COLOR2_BASE
, 0);
1042 WREG32(CB_COLOR3_BASE
, 0);
1043 WREG32(CB_COLOR4_BASE
, 0);
1044 WREG32(CB_COLOR5_BASE
, 0);
1045 WREG32(CB_COLOR6_BASE
, 0);
1046 WREG32(CB_COLOR7_BASE
, 0);
1047 WREG32(CB_COLOR7_FRAG
, 0);
1049 switch (rdev
->family
) {
1054 tmp
= TC_L2_SIZE(8);
1058 tmp
= TC_L2_SIZE(4);
1061 tmp
= TC_L2_SIZE(0) | L2_DISABLE_LATE_HIT
;
1064 tmp
= TC_L2_SIZE(0);
1067 WREG32(TC_CNTL
, tmp
);
1069 tmp
= RREG32(HDP_HOST_PATH_CNTL
);
1070 WREG32(HDP_HOST_PATH_CNTL
, tmp
);
1072 tmp
= RREG32(ARB_POP
);
1073 tmp
|= ENABLE_TC128
;
1074 WREG32(ARB_POP
, tmp
);
1076 WREG32(PA_SC_MULTI_CHIP_CNTL
, 0);
1077 WREG32(PA_CL_ENHANCE
, (CLIP_VTX_REORDER_ENA
|
1079 WREG32(PA_SC_ENHANCE
, FORCE_EOV_MAX_CLK_CNT(4095));
1084 * Indirect registers accessor
1086 u32
r600_pciep_rreg(struct radeon_device
*rdev
, u32 reg
)
1090 WREG32(PCIE_PORT_INDEX
, ((reg
) & 0xff));
1091 (void)RREG32(PCIE_PORT_INDEX
);
1092 r
= RREG32(PCIE_PORT_DATA
);
1096 void r600_pciep_wreg(struct radeon_device
*rdev
, u32 reg
, u32 v
)
1098 WREG32(PCIE_PORT_INDEX
, ((reg
) & 0xff));
1099 (void)RREG32(PCIE_PORT_INDEX
);
1100 WREG32(PCIE_PORT_DATA
, (v
));
1101 (void)RREG32(PCIE_PORT_DATA
);
1108 void r600_cp_stop(struct radeon_device
*rdev
)
1110 WREG32(R_0086D8_CP_ME_CNTL
, S_0086D8_CP_ME_HALT(1));
1113 int r600_cp_init_microcode(struct radeon_device
*rdev
)
1115 struct platform_device
*pdev
;
1116 const char *chip_name
;
1117 size_t pfp_req_size
, me_req_size
;
1123 pdev
= platform_device_register_simple("radeon_cp", 0, NULL
, 0);
1126 printk(KERN_ERR
"radeon_cp: Failed to register firmware\n");
1130 switch (rdev
->family
) {
1131 case CHIP_R600
: chip_name
= "R600"; break;
1132 case CHIP_RV610
: chip_name
= "RV610"; break;
1133 case CHIP_RV630
: chip_name
= "RV630"; break;
1134 case CHIP_RV620
: chip_name
= "RV620"; break;
1135 case CHIP_RV635
: chip_name
= "RV635"; break;
1136 case CHIP_RV670
: chip_name
= "RV670"; break;
1138 case CHIP_RS880
: chip_name
= "RS780"; break;
1139 case CHIP_RV770
: chip_name
= "RV770"; break;
1141 case CHIP_RV740
: chip_name
= "RV730"; break;
1142 case CHIP_RV710
: chip_name
= "RV710"; break;
1146 if (rdev
->family
>= CHIP_RV770
) {
1147 pfp_req_size
= R700_PFP_UCODE_SIZE
* 4;
1148 me_req_size
= R700_PM4_UCODE_SIZE
* 4;
1150 pfp_req_size
= PFP_UCODE_SIZE
* 4;
1151 me_req_size
= PM4_UCODE_SIZE
* 12;
1154 DRM_INFO("Loading %s CP Microcode\n", chip_name
);
1156 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_pfp.bin", chip_name
);
1157 err
= request_firmware(&rdev
->pfp_fw
, fw_name
, &pdev
->dev
);
1160 if (rdev
->pfp_fw
->size
!= pfp_req_size
) {
1162 "r600_cp: Bogus length %zu in firmware \"%s\"\n",
1163 rdev
->pfp_fw
->size
, fw_name
);
1168 snprintf(fw_name
, sizeof(fw_name
), "radeon/%s_me.bin", chip_name
);
1169 err
= request_firmware(&rdev
->me_fw
, fw_name
, &pdev
->dev
);
1172 if (rdev
->me_fw
->size
!= me_req_size
) {
1174 "r600_cp: Bogus length %zu in firmware \"%s\"\n",
1175 rdev
->me_fw
->size
, fw_name
);
1179 platform_device_unregister(pdev
);
1184 "r600_cp: Failed to load firmware \"%s\"\n",
1186 release_firmware(rdev
->pfp_fw
);
1187 rdev
->pfp_fw
= NULL
;
1188 release_firmware(rdev
->me_fw
);
1194 static int r600_cp_load_microcode(struct radeon_device
*rdev
)
1196 const __be32
*fw_data
;
1199 if (!rdev
->me_fw
|| !rdev
->pfp_fw
)
1204 WREG32(CP_RB_CNTL
, RB_NO_UPDATE
| RB_BLKSZ(15) | RB_BUFSZ(3));
1207 WREG32(GRBM_SOFT_RESET
, SOFT_RESET_CP
);
1208 RREG32(GRBM_SOFT_RESET
);
1210 WREG32(GRBM_SOFT_RESET
, 0);
1212 WREG32(CP_ME_RAM_WADDR
, 0);
1214 fw_data
= (const __be32
*)rdev
->me_fw
->data
;
1215 WREG32(CP_ME_RAM_WADDR
, 0);
1216 for (i
= 0; i
< PM4_UCODE_SIZE
* 3; i
++)
1217 WREG32(CP_ME_RAM_DATA
,
1218 be32_to_cpup(fw_data
++));
1220 fw_data
= (const __be32
*)rdev
->pfp_fw
->data
;
1221 WREG32(CP_PFP_UCODE_ADDR
, 0);
1222 for (i
= 0; i
< PFP_UCODE_SIZE
; i
++)
1223 WREG32(CP_PFP_UCODE_DATA
,
1224 be32_to_cpup(fw_data
++));
1226 WREG32(CP_PFP_UCODE_ADDR
, 0);
1227 WREG32(CP_ME_RAM_WADDR
, 0);
1228 WREG32(CP_ME_RAM_RADDR
, 0);
1232 int r600_cp_start(struct radeon_device
*rdev
)
1237 r
= radeon_ring_lock(rdev
, 7);
1239 DRM_ERROR("radeon: cp failed to lock ring (%d).\n", r
);
1242 radeon_ring_write(rdev
, PACKET3(PACKET3_ME_INITIALIZE
, 5));
1243 radeon_ring_write(rdev
, 0x1);
1244 if (rdev
->family
< CHIP_RV770
) {
1245 radeon_ring_write(rdev
, 0x3);
1246 radeon_ring_write(rdev
, rdev
->config
.r600
.max_hw_contexts
- 1);
1248 radeon_ring_write(rdev
, 0x0);
1249 radeon_ring_write(rdev
, rdev
->config
.rv770
.max_hw_contexts
- 1);
1251 radeon_ring_write(rdev
, PACKET3_ME_INITIALIZE_DEVICE_ID(1));
1252 radeon_ring_write(rdev
, 0);
1253 radeon_ring_write(rdev
, 0);
1254 radeon_ring_unlock_commit(rdev
);
1257 WREG32(R_0086D8_CP_ME_CNTL
, cp_me
);
1261 int r600_cp_resume(struct radeon_device
*rdev
)
1268 WREG32(GRBM_SOFT_RESET
, SOFT_RESET_CP
);
1269 RREG32(GRBM_SOFT_RESET
);
1271 WREG32(GRBM_SOFT_RESET
, 0);
1273 /* Set ring buffer size */
1274 rb_bufsz
= drm_order(rdev
->cp
.ring_size
/ 8);
1275 tmp
= RB_NO_UPDATE
| (drm_order(RADEON_GPU_PAGE_SIZE
/8) << 8) | rb_bufsz
;
1277 tmp
|= BUF_SWAP_32BIT
;
1279 WREG32(CP_RB_CNTL
, tmp
);
1280 WREG32(CP_SEM_WAIT_TIMER
, 0x4);
1282 /* Set the write pointer delay */
1283 WREG32(CP_RB_WPTR_DELAY
, 0);
1285 /* Initialize the ring buffer's read and write pointers */
1286 WREG32(CP_RB_CNTL
, tmp
| RB_RPTR_WR_ENA
);
1287 WREG32(CP_RB_RPTR_WR
, 0);
1288 WREG32(CP_RB_WPTR
, 0);
1289 WREG32(CP_RB_RPTR_ADDR
, rdev
->cp
.gpu_addr
& 0xFFFFFFFF);
1290 WREG32(CP_RB_RPTR_ADDR_HI
, upper_32_bits(rdev
->cp
.gpu_addr
));
1292 WREG32(CP_RB_CNTL
, tmp
);
1294 WREG32(CP_RB_BASE
, rdev
->cp
.gpu_addr
>> 8);
1295 WREG32(CP_DEBUG
, (1 << 27) | (1 << 28));
1297 rdev
->cp
.rptr
= RREG32(CP_RB_RPTR
);
1298 rdev
->cp
.wptr
= RREG32(CP_RB_WPTR
);
1300 r600_cp_start(rdev
);
1301 rdev
->cp
.ready
= true;
1302 r
= radeon_ring_test(rdev
);
1304 rdev
->cp
.ready
= false;
1310 void r600_cp_commit(struct radeon_device
*rdev
)
1312 WREG32(CP_RB_WPTR
, rdev
->cp
.wptr
);
1313 (void)RREG32(CP_RB_WPTR
);
1316 void r600_ring_init(struct radeon_device
*rdev
, unsigned ring_size
)
1320 /* Align ring size */
1321 rb_bufsz
= drm_order(ring_size
/ 8);
1322 ring_size
= (1 << (rb_bufsz
+ 1)) * 4;
1323 rdev
->cp
.ring_size
= ring_size
;
1324 rdev
->cp
.align_mask
= 16 - 1;
1329 * GPU scratch registers helpers function.
1331 void r600_scratch_init(struct radeon_device
*rdev
)
1335 rdev
->scratch
.num_reg
= 7;
1336 for (i
= 0; i
< rdev
->scratch
.num_reg
; i
++) {
1337 rdev
->scratch
.free
[i
] = true;
1338 rdev
->scratch
.reg
[i
] = SCRATCH_REG0
+ (i
* 4);
1342 int r600_ring_test(struct radeon_device
*rdev
)
1349 r
= radeon_scratch_get(rdev
, &scratch
);
1351 DRM_ERROR("radeon: cp failed to get scratch reg (%d).\n", r
);
1354 WREG32(scratch
, 0xCAFEDEAD);
1355 r
= radeon_ring_lock(rdev
, 3);
1357 DRM_ERROR("radeon: cp failed to lock ring (%d).\n", r
);
1358 radeon_scratch_free(rdev
, scratch
);
1361 radeon_ring_write(rdev
, PACKET3(PACKET3_SET_CONFIG_REG
, 1));
1362 radeon_ring_write(rdev
, ((scratch
- PACKET3_SET_CONFIG_REG_OFFSET
) >> 2));
1363 radeon_ring_write(rdev
, 0xDEADBEEF);
1364 radeon_ring_unlock_commit(rdev
);
1365 for (i
= 0; i
< rdev
->usec_timeout
; i
++) {
1366 tmp
= RREG32(scratch
);
1367 if (tmp
== 0xDEADBEEF)
1371 if (i
< rdev
->usec_timeout
) {
1372 DRM_INFO("ring test succeeded in %d usecs\n", i
);
1374 DRM_ERROR("radeon: ring test failed (scratch(0x%04X)=0x%08X)\n",
1378 radeon_scratch_free(rdev
, scratch
);
1382 void r600_wb_disable(struct radeon_device
*rdev
)
1384 WREG32(SCRATCH_UMSK
, 0);
1385 if (rdev
->wb
.wb_obj
) {
1386 radeon_object_kunmap(rdev
->wb
.wb_obj
);
1387 radeon_object_unpin(rdev
->wb
.wb_obj
);
1391 void r600_wb_fini(struct radeon_device
*rdev
)
1393 r600_wb_disable(rdev
);
1394 if (rdev
->wb
.wb_obj
) {
1395 radeon_object_unref(&rdev
->wb
.wb_obj
);
1397 rdev
->wb
.wb_obj
= NULL
;
1401 int r600_wb_enable(struct radeon_device
*rdev
)
1405 if (rdev
->wb
.wb_obj
== NULL
) {
1406 r
= radeon_object_create(rdev
, NULL
, RADEON_GPU_PAGE_SIZE
, true,
1407 RADEON_GEM_DOMAIN_GTT
, false, &rdev
->wb
.wb_obj
);
1409 dev_warn(rdev
->dev
, "failed to create WB buffer (%d).\n", r
);
1412 r
= radeon_object_pin(rdev
->wb
.wb_obj
, RADEON_GEM_DOMAIN_GTT
,
1413 &rdev
->wb
.gpu_addr
);
1415 dev_warn(rdev
->dev
, "failed to pin WB buffer (%d).\n", r
);
1419 r
= radeon_object_kmap(rdev
->wb
.wb_obj
, (void **)&rdev
->wb
.wb
);
1421 dev_warn(rdev
->dev
, "failed to map WB buffer (%d).\n", r
);
1426 WREG32(SCRATCH_ADDR
, (rdev
->wb
.gpu_addr
>> 8) & 0xFFFFFFFF);
1427 WREG32(CP_RB_RPTR_ADDR
, (rdev
->wb
.gpu_addr
+ 1024) & 0xFFFFFFFC);
1428 WREG32(CP_RB_RPTR_ADDR_HI
, upper_32_bits(rdev
->wb
.gpu_addr
+ 1024) & 0xFF);
1429 WREG32(SCRATCH_UMSK
, 0xff);
1433 void r600_fence_ring_emit(struct radeon_device
*rdev
,
1434 struct radeon_fence
*fence
)
1436 /* Emit fence sequence & fire IRQ */
1437 radeon_ring_write(rdev
, PACKET3(PACKET3_SET_CONFIG_REG
, 1));
1438 radeon_ring_write(rdev
, ((rdev
->fence_drv
.scratch_reg
- PACKET3_SET_CONFIG_REG_OFFSET
) >> 2));
1439 radeon_ring_write(rdev
, fence
->seq
);
1442 int r600_copy_dma(struct radeon_device
*rdev
,
1443 uint64_t src_offset
,
1444 uint64_t dst_offset
,
1446 struct radeon_fence
*fence
)
1448 /* FIXME: implement */
1452 int r600_copy_blit(struct radeon_device
*rdev
,
1453 uint64_t src_offset
, uint64_t dst_offset
,
1454 unsigned num_pages
, struct radeon_fence
*fence
)
1456 r600_blit_prepare_copy(rdev
, num_pages
* RADEON_GPU_PAGE_SIZE
);
1457 r600_kms_blit_copy(rdev
, src_offset
, dst_offset
, num_pages
* RADEON_GPU_PAGE_SIZE
);
1458 r600_blit_done_copy(rdev
, fence
);
1462 int r600_irq_process(struct radeon_device
*rdev
)
1464 /* FIXME: implement */
1468 int r600_irq_set(struct radeon_device
*rdev
)
1470 /* FIXME: implement */
1474 int r600_set_surface_reg(struct radeon_device
*rdev
, int reg
,
1475 uint32_t tiling_flags
, uint32_t pitch
,
1476 uint32_t offset
, uint32_t obj_size
)
1478 /* FIXME: implement */
1482 void r600_clear_surface_reg(struct radeon_device
*rdev
, int reg
)
1484 /* FIXME: implement */
1488 bool r600_card_posted(struct radeon_device
*rdev
)
1492 /* first check CRTCs */
1493 reg
= RREG32(D1CRTC_CONTROL
) |
1494 RREG32(D2CRTC_CONTROL
);
1498 /* then check MEM_SIZE, in case the crtcs are off */
1499 if (RREG32(CONFIG_MEMSIZE
))
1505 int r600_startup(struct radeon_device
*rdev
)
1509 r600_mc_program(rdev
);
1510 if (rdev
->flags
& RADEON_IS_AGP
) {
1511 r600_agp_enable(rdev
);
1513 r
= r600_pcie_gart_enable(rdev
);
1517 r600_gpu_init(rdev
);
1519 r
= radeon_object_pin(rdev
->r600_blit
.shader_obj
, RADEON_GEM_DOMAIN_VRAM
,
1520 &rdev
->r600_blit
.shader_gpu_addr
);
1522 DRM_ERROR("failed to pin blit object %d\n", r
);
1526 r
= radeon_ring_init(rdev
, rdev
->cp
.ring_size
);
1529 r
= r600_cp_load_microcode(rdev
);
1532 r
= r600_cp_resume(rdev
);
1535 /* write back buffer are not vital so don't worry about failure */
1536 r600_wb_enable(rdev
);
1540 void r600_vga_set_state(struct radeon_device
*rdev
, bool state
)
1544 temp
= RREG32(CONFIG_CNTL
);
1545 if (state
== false) {
1551 WREG32(CONFIG_CNTL
, temp
);
1554 int r600_resume(struct radeon_device
*rdev
)
1558 /* Do not reset GPU before posting, on r600 hw unlike on r500 hw,
1559 * posting will perform necessary task to bring back GPU into good
1563 atom_asic_init(rdev
->mode_info
.atom_context
);
1564 /* Initialize clocks */
1565 r
= radeon_clocks_init(rdev
);
1570 r
= r600_startup(rdev
);
1572 DRM_ERROR("r600 startup failed on resume\n");
1576 r
= r600_ib_test(rdev
);
1578 DRM_ERROR("radeon: failled testing IB (%d).\n", r
);
1584 int r600_suspend(struct radeon_device
*rdev
)
1586 /* FIXME: we should wait for ring to be empty */
1588 rdev
->cp
.ready
= false;
1589 r600_wb_disable(rdev
);
1590 r600_pcie_gart_disable(rdev
);
1591 /* unpin shaders bo */
1592 radeon_object_unpin(rdev
->r600_blit
.shader_obj
);
1596 /* Plan is to move initialization in that function and use
1597 * helper function so that radeon_device_init pretty much
1598 * do nothing more than calling asic specific function. This
1599 * should also allow to remove a bunch of callback function
1602 int r600_init(struct radeon_device
*rdev
)
1606 r
= radeon_dummy_page_init(rdev
);
1609 if (r600_debugfs_mc_info_init(rdev
)) {
1610 DRM_ERROR("Failed to register debugfs file for mc !\n");
1612 /* This don't do much */
1613 r
= radeon_gem_init(rdev
);
1617 if (!radeon_get_bios(rdev
)) {
1618 if (ASIC_IS_AVIVO(rdev
))
1621 /* Must be an ATOMBIOS */
1622 if (!rdev
->is_atom_bios
) {
1623 dev_err(rdev
->dev
, "Expecting atombios for R600 GPU\n");
1626 r
= radeon_atombios_init(rdev
);
1629 /* Post card if necessary */
1630 if (!r600_card_posted(rdev
) && rdev
->bios
) {
1631 DRM_INFO("GPU not posted. posting now...\n");
1632 atom_asic_init(rdev
->mode_info
.atom_context
);
1634 /* Initialize scratch registers */
1635 r600_scratch_init(rdev
);
1636 /* Initialize surface registers */
1637 radeon_surface_init(rdev
);
1638 /* Initialize clocks */
1639 radeon_get_clock_info(rdev
->ddev
);
1640 r
= radeon_clocks_init(rdev
);
1643 /* Initialize power management */
1644 radeon_pm_init(rdev
);
1646 r
= radeon_fence_driver_init(rdev
);
1649 r
= r600_mc_init(rdev
);
1652 /* Memory manager */
1653 r
= radeon_object_init(rdev
);
1656 rdev
->cp
.ring_obj
= NULL
;
1657 r600_ring_init(rdev
, 1024 * 1024);
1659 if (!rdev
->me_fw
|| !rdev
->pfp_fw
) {
1660 r
= r600_cp_init_microcode(rdev
);
1662 DRM_ERROR("Failed to load firmware!\n");
1667 r
= r600_pcie_gart_init(rdev
);
1671 rdev
->accel_working
= true;
1672 r
= r600_blit_init(rdev
);
1674 DRM_ERROR("radeon: failled blitter (%d).\n", r
);
1678 r
= r600_startup(rdev
);
1682 radeon_ring_fini(rdev
);
1683 r600_pcie_gart_fini(rdev
);
1684 rdev
->accel_working
= false;
1686 if (rdev
->accel_working
) {
1687 r
= radeon_ib_pool_init(rdev
);
1689 DRM_ERROR("radeon: failled initializing IB pool (%d).\n", r
);
1690 rdev
->accel_working
= false;
1692 r
= r600_ib_test(rdev
);
1694 DRM_ERROR("radeon: failled testing IB (%d).\n", r
);
1695 rdev
->accel_working
= false;
1701 void r600_fini(struct radeon_device
*rdev
)
1703 /* Suspend operations */
1706 r600_blit_fini(rdev
);
1707 radeon_ring_fini(rdev
);
1709 r600_pcie_gart_fini(rdev
);
1710 radeon_gem_fini(rdev
);
1711 radeon_fence_driver_fini(rdev
);
1712 radeon_clocks_fini(rdev
);
1713 if (rdev
->flags
& RADEON_IS_AGP
)
1714 radeon_agp_fini(rdev
);
1715 radeon_object_fini(rdev
);
1716 radeon_atombios_fini(rdev
);
1719 radeon_dummy_page_fini(rdev
);
1726 void r600_ring_ib_execute(struct radeon_device
*rdev
, struct radeon_ib
*ib
)
1728 /* FIXME: implement */
1729 radeon_ring_write(rdev
, PACKET3(PACKET3_INDIRECT_BUFFER
, 2));
1730 radeon_ring_write(rdev
, ib
->gpu_addr
& 0xFFFFFFFC);
1731 radeon_ring_write(rdev
, upper_32_bits(ib
->gpu_addr
) & 0xFF);
1732 radeon_ring_write(rdev
, ib
->length_dw
);
1735 int r600_ib_test(struct radeon_device
*rdev
)
1737 struct radeon_ib
*ib
;
1743 r
= radeon_scratch_get(rdev
, &scratch
);
1745 DRM_ERROR("radeon: failed to get scratch reg (%d).\n", r
);
1748 WREG32(scratch
, 0xCAFEDEAD);
1749 r
= radeon_ib_get(rdev
, &ib
);
1751 DRM_ERROR("radeon: failed to get ib (%d).\n", r
);
1754 ib
->ptr
[0] = PACKET3(PACKET3_SET_CONFIG_REG
, 1);
1755 ib
->ptr
[1] = ((scratch
- PACKET3_SET_CONFIG_REG_OFFSET
) >> 2);
1756 ib
->ptr
[2] = 0xDEADBEEF;
1757 ib
->ptr
[3] = PACKET2(0);
1758 ib
->ptr
[4] = PACKET2(0);
1759 ib
->ptr
[5] = PACKET2(0);
1760 ib
->ptr
[6] = PACKET2(0);
1761 ib
->ptr
[7] = PACKET2(0);
1762 ib
->ptr
[8] = PACKET2(0);
1763 ib
->ptr
[9] = PACKET2(0);
1764 ib
->ptr
[10] = PACKET2(0);
1765 ib
->ptr
[11] = PACKET2(0);
1766 ib
->ptr
[12] = PACKET2(0);
1767 ib
->ptr
[13] = PACKET2(0);
1768 ib
->ptr
[14] = PACKET2(0);
1769 ib
->ptr
[15] = PACKET2(0);
1771 r
= radeon_ib_schedule(rdev
, ib
);
1773 radeon_scratch_free(rdev
, scratch
);
1774 radeon_ib_free(rdev
, &ib
);
1775 DRM_ERROR("radeon: failed to schedule ib (%d).\n", r
);
1778 r
= radeon_fence_wait(ib
->fence
, false);
1780 DRM_ERROR("radeon: fence wait failed (%d).\n", r
);
1783 for (i
= 0; i
< rdev
->usec_timeout
; i
++) {
1784 tmp
= RREG32(scratch
);
1785 if (tmp
== 0xDEADBEEF)
1789 if (i
< rdev
->usec_timeout
) {
1790 DRM_INFO("ib test succeeded in %u usecs\n", i
);
1792 DRM_ERROR("radeon: ib test failed (sracth(0x%04X)=0x%08X)\n",
1796 radeon_scratch_free(rdev
, scratch
);
1797 radeon_ib_free(rdev
, &ib
);
1807 #if defined(CONFIG_DEBUG_FS)
1809 static int r600_debugfs_cp_ring_info(struct seq_file
*m
, void *data
)
1811 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1812 struct drm_device
*dev
= node
->minor
->dev
;
1813 struct radeon_device
*rdev
= dev
->dev_private
;
1815 unsigned count
, i
, j
;
1817 radeon_ring_free_size(rdev
);
1818 rdp
= RREG32(CP_RB_RPTR
);
1819 wdp
= RREG32(CP_RB_WPTR
);
1820 count
= (rdp
+ rdev
->cp
.ring_size
- wdp
) & rdev
->cp
.ptr_mask
;
1821 seq_printf(m
, "CP_STAT 0x%08x\n", RREG32(CP_STAT
));
1822 seq_printf(m
, "CP_RB_WPTR 0x%08x\n", wdp
);
1823 seq_printf(m
, "CP_RB_RPTR 0x%08x\n", rdp
);
1824 seq_printf(m
, "%u free dwords in ring\n", rdev
->cp
.ring_free_dw
);
1825 seq_printf(m
, "%u dwords in ring\n", count
);
1826 for (j
= 0; j
<= count
; j
++) {
1827 i
= (rdp
+ j
) & rdev
->cp
.ptr_mask
;
1828 seq_printf(m
, "r[%04d]=0x%08x\n", i
, rdev
->cp
.ring
[i
]);
1833 static int r600_debugfs_mc_info(struct seq_file
*m
, void *data
)
1835 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
1836 struct drm_device
*dev
= node
->minor
->dev
;
1837 struct radeon_device
*rdev
= dev
->dev_private
;
1839 DREG32_SYS(m
, rdev
, R_000E50_SRBM_STATUS
);
1840 DREG32_SYS(m
, rdev
, VM_L2_STATUS
);
1844 static struct drm_info_list r600_mc_info_list
[] = {
1845 {"r600_mc_info", r600_debugfs_mc_info
, 0, NULL
},
1846 {"r600_ring_info", r600_debugfs_cp_ring_info
, 0, NULL
},
1850 int r600_debugfs_mc_info_init(struct radeon_device
*rdev
)
1852 #if defined(CONFIG_DEBUG_FS)
1853 return radeon_debugfs_add_files(rdev
, r600_mc_info_list
, ARRAY_SIZE(r600_mc_info_list
));