aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon/ni.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-07-26 17:18:18 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-26 17:18:18 -0400
commitbd22dc17e49973d3d4925970260e9e37f7580a9f (patch)
tree581a7c7527f628aa91eb2e0680b765a9673bc974 /drivers/gpu/drm/radeon/ni.c
parent548ed10228093f1036297a333d1c1064f4daefdc (diff)
parent98c7b42375011ec37251e6fc85a0471cfe499eea (diff)
Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux
Pull drm updates from Dave Airlie: "One of the smaller drm -next pulls in ages! Ben (nouveau) has a rewrite in progress but we decided to leave it stew for another cycle, so just some fixes from him. - radeon: lots of documentation work, fixes, more ring and locking changes, pcie gen2, more dp fixes. - i915: haswell features, gpu reset fixes, /dev/agpgart removal on machines that we never used it on, more VGA/HDP fix., more DP fixes - drm core: cleanups from Daniel, sis 64-bit fixes, range allocator colouring. but yeah fairly quiet merge this time, probably because I missed half of it!" Trivial add-add conflict in include/linux/pci_regs.h * 'drm-next' of git://people.freedesktop.org/~airlied/linux: (255 commits) drm/nouveau: init vblank requests list drm/nv50: extend vblank semaphore to generic dmaobj + offset pair drm/nouveau: mark most of our ioctls as deprecated, move to compat layer drm/nouveau: move current gpuobj code out of nouveau_object.c drm/nouveau/gem: fix object reference leak in a failure path drm/nv50: rename INVALID_QUERY_OR_TEXTURE error to INVALID_OPERATION drm/nv84: decode PCRYPT errors drm/nouveau: dcb table quirk for fdo#50830 nouveau: Fix alignment requirements on src and dst addresses drm/i915: unbreak lastclose for failed driver init drm/i915: Set the context before setting up regs for the context. drm/i915: constify mode in crtc_mode_fixup drm/i915/lvds: ditch ->prepare special case drm/i915: dereferencing an error pointer drm/i915: fix invalid reference handling of the default ctx obj drm/i915: Add -EIO to the list of known errors for __wait_seqno drm/i915: Flush the context object from the CPU caches upon switching drm/radeon: fix dpms on/off on trinity/aruba v2 drm/radeon: on hotplug force link training to happen (v2) drm/radeon: fix hotplug of DP to DVI|HDMI passive adapters (v2) ...
Diffstat (limited to 'drivers/gpu/drm/radeon/ni.c')
-rw-r--r--drivers/gpu/drm/radeon/ni.c198
1 files changed, 95 insertions, 103 deletions
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index b7bf18e40215..9945d86d9001 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -850,11 +850,20 @@ void cayman_fence_ring_emit(struct radeon_device *rdev,
850 850
851void cayman_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib) 851void cayman_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib)
852{ 852{
853 struct radeon_ring *ring = &rdev->ring[ib->fence->ring]; 853 struct radeon_ring *ring = &rdev->ring[ib->ring];
854 854
855 /* set to DX10/11 mode */ 855 /* set to DX10/11 mode */
856 radeon_ring_write(ring, PACKET3(PACKET3_MODE_CONTROL, 0)); 856 radeon_ring_write(ring, PACKET3(PACKET3_MODE_CONTROL, 0));
857 radeon_ring_write(ring, 1); 857 radeon_ring_write(ring, 1);
858
859 if (ring->rptr_save_reg) {
860 uint32_t next_rptr = ring->wptr + 3 + 4 + 8;
861 radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1));
862 radeon_ring_write(ring, ((ring->rptr_save_reg -
863 PACKET3_SET_CONFIG_REG_START) >> 2));
864 radeon_ring_write(ring, next_rptr);
865 }
866
858 radeon_ring_write(ring, PACKET3(PACKET3_INDIRECT_BUFFER, 2)); 867 radeon_ring_write(ring, PACKET3(PACKET3_INDIRECT_BUFFER, 2));
859 radeon_ring_write(ring, 868 radeon_ring_write(ring,
860#ifdef __BIG_ENDIAN 869#ifdef __BIG_ENDIAN
@@ -981,16 +990,41 @@ static int cayman_cp_start(struct radeon_device *rdev)
981 990
982static void cayman_cp_fini(struct radeon_device *rdev) 991static void cayman_cp_fini(struct radeon_device *rdev)
983{ 992{
993 struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
984 cayman_cp_enable(rdev, false); 994 cayman_cp_enable(rdev, false);
985 radeon_ring_fini(rdev, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]); 995 radeon_ring_fini(rdev, ring);
996 radeon_scratch_free(rdev, ring->rptr_save_reg);
986} 997}
987 998
988int cayman_cp_resume(struct radeon_device *rdev) 999int cayman_cp_resume(struct radeon_device *rdev)
989{ 1000{
1001 static const int ridx[] = {
1002 RADEON_RING_TYPE_GFX_INDEX,
1003 CAYMAN_RING_TYPE_CP1_INDEX,
1004 CAYMAN_RING_TYPE_CP2_INDEX
1005 };
1006 static const unsigned cp_rb_cntl[] = {
1007 CP_RB0_CNTL,
1008 CP_RB1_CNTL,
1009 CP_RB2_CNTL,
1010 };
1011 static const unsigned cp_rb_rptr_addr[] = {
1012 CP_RB0_RPTR_ADDR,
1013 CP_RB1_RPTR_ADDR,
1014 CP_RB2_RPTR_ADDR
1015 };
1016 static const unsigned cp_rb_rptr_addr_hi[] = {
1017 CP_RB0_RPTR_ADDR_HI,
1018 CP_RB1_RPTR_ADDR_HI,
1019 CP_RB2_RPTR_ADDR_HI
1020 };
1021 static const unsigned cp_rb_base[] = {
1022 CP_RB0_BASE,
1023 CP_RB1_BASE,
1024 CP_RB2_BASE
1025 };
990 struct radeon_ring *ring; 1026 struct radeon_ring *ring;
991 u32 tmp; 1027 int i, r;
992 u32 rb_bufsz;
993 int r;
994 1028
995 /* Reset cp; if cp is reset, then PA, SH, VGT also need to be reset */ 1029 /* Reset cp; if cp is reset, then PA, SH, VGT also need to be reset */
996 WREG32(GRBM_SOFT_RESET, (SOFT_RESET_CP | 1030 WREG32(GRBM_SOFT_RESET, (SOFT_RESET_CP |
@@ -1012,91 +1046,47 @@ int cayman_cp_resume(struct radeon_device *rdev)
1012 1046
1013 WREG32(CP_DEBUG, (1 << 27)); 1047 WREG32(CP_DEBUG, (1 << 27));
1014 1048
1015 /* ring 0 - compute and gfx */
1016 /* Set ring buffer size */
1017 ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
1018 rb_bufsz = drm_order(ring->ring_size / 8);
1019 tmp = (drm_order(RADEON_GPU_PAGE_SIZE/8) << 8) | rb_bufsz;
1020#ifdef __BIG_ENDIAN
1021 tmp |= BUF_SWAP_32BIT;
1022#endif
1023 WREG32(CP_RB0_CNTL, tmp);
1024
1025 /* Initialize the ring buffer's read and write pointers */
1026 WREG32(CP_RB0_CNTL, tmp | RB_RPTR_WR_ENA);
1027 ring->wptr = 0;
1028 WREG32(CP_RB0_WPTR, ring->wptr);
1029
1030 /* set the wb address wether it's enabled or not */ 1049 /* set the wb address wether it's enabled or not */
1031 WREG32(CP_RB0_RPTR_ADDR, (rdev->wb.gpu_addr + RADEON_WB_CP_RPTR_OFFSET) & 0xFFFFFFFC);
1032 WREG32(CP_RB0_RPTR_ADDR_HI, upper_32_bits(rdev->wb.gpu_addr + RADEON_WB_CP_RPTR_OFFSET) & 0xFF);
1033 WREG32(SCRATCH_ADDR, ((rdev->wb.gpu_addr + RADEON_WB_SCRATCH_OFFSET) >> 8) & 0xFFFFFFFF); 1050 WREG32(SCRATCH_ADDR, ((rdev->wb.gpu_addr + RADEON_WB_SCRATCH_OFFSET) >> 8) & 0xFFFFFFFF);
1051 WREG32(SCRATCH_UMSK, 0xff);
1034 1052
1035 if (rdev->wb.enabled) 1053 for (i = 0; i < 3; ++i) {
1036 WREG32(SCRATCH_UMSK, 0xff); 1054 uint32_t rb_cntl;
1037 else { 1055 uint64_t addr;
1038 tmp |= RB_NO_UPDATE;
1039 WREG32(SCRATCH_UMSK, 0);
1040 }
1041 1056
1042 mdelay(1); 1057 /* Set ring buffer size */
1043 WREG32(CP_RB0_CNTL, tmp); 1058 ring = &rdev->ring[ridx[i]];
1044 1059 rb_cntl = drm_order(ring->ring_size / 8);
1045 WREG32(CP_RB0_BASE, ring->gpu_addr >> 8); 1060 rb_cntl |= drm_order(RADEON_GPU_PAGE_SIZE/8) << 8;
1046
1047 ring->rptr = RREG32(CP_RB0_RPTR);
1048
1049 /* ring1 - compute only */
1050 /* Set ring buffer size */
1051 ring = &rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX];
1052 rb_bufsz = drm_order(ring->ring_size / 8);
1053 tmp = (drm_order(RADEON_GPU_PAGE_SIZE/8) << 8) | rb_bufsz;
1054#ifdef __BIG_ENDIAN 1061#ifdef __BIG_ENDIAN
1055 tmp |= BUF_SWAP_32BIT; 1062 rb_cntl |= BUF_SWAP_32BIT;
1056#endif 1063#endif
1057 WREG32(CP_RB1_CNTL, tmp); 1064 WREG32(cp_rb_cntl[i], rb_cntl);
1058
1059 /* Initialize the ring buffer's read and write pointers */
1060 WREG32(CP_RB1_CNTL, tmp | RB_RPTR_WR_ENA);
1061 ring->wptr = 0;
1062 WREG32(CP_RB1_WPTR, ring->wptr);
1063
1064 /* set the wb address wether it's enabled or not */
1065 WREG32(CP_RB1_RPTR_ADDR, (rdev->wb.gpu_addr + RADEON_WB_CP1_RPTR_OFFSET) & 0xFFFFFFFC);
1066 WREG32(CP_RB1_RPTR_ADDR_HI, upper_32_bits(rdev->wb.gpu_addr + RADEON_WB_CP1_RPTR_OFFSET) & 0xFF);
1067
1068 mdelay(1);
1069 WREG32(CP_RB1_CNTL, tmp);
1070 1065
1071 WREG32(CP_RB1_BASE, ring->gpu_addr >> 8); 1066 /* set the wb address wether it's enabled or not */
1072 1067 addr = rdev->wb.gpu_addr + RADEON_WB_CP_RPTR_OFFSET;
1073 ring->rptr = RREG32(CP_RB1_RPTR); 1068 WREG32(cp_rb_rptr_addr[i], addr & 0xFFFFFFFC);
1074 1069 WREG32(cp_rb_rptr_addr_hi[i], upper_32_bits(addr) & 0xFF);
1075 /* ring2 - compute only */ 1070 }
1076 /* Set ring buffer size */
1077 ring = &rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX];
1078 rb_bufsz = drm_order(ring->ring_size / 8);
1079 tmp = (drm_order(RADEON_GPU_PAGE_SIZE/8) << 8) | rb_bufsz;
1080#ifdef __BIG_ENDIAN
1081 tmp |= BUF_SWAP_32BIT;
1082#endif
1083 WREG32(CP_RB2_CNTL, tmp);
1084
1085 /* Initialize the ring buffer's read and write pointers */
1086 WREG32(CP_RB2_CNTL, tmp | RB_RPTR_WR_ENA);
1087 ring->wptr = 0;
1088 WREG32(CP_RB2_WPTR, ring->wptr);
1089 1071
1090 /* set the wb address wether it's enabled or not */ 1072 /* set the rb base addr, this causes an internal reset of ALL rings */
1091 WREG32(CP_RB2_RPTR_ADDR, (rdev->wb.gpu_addr + RADEON_WB_CP2_RPTR_OFFSET) & 0xFFFFFFFC); 1073 for (i = 0; i < 3; ++i) {
1092 WREG32(CP_RB2_RPTR_ADDR_HI, upper_32_bits(rdev->wb.gpu_addr + RADEON_WB_CP2_RPTR_OFFSET) & 0xFF); 1074 ring = &rdev->ring[ridx[i]];
1075 WREG32(cp_rb_base[i], ring->gpu_addr >> 8);
1076 }
1093 1077
1094 mdelay(1); 1078 for (i = 0; i < 3; ++i) {
1095 WREG32(CP_RB2_CNTL, tmp); 1079 /* Initialize the ring buffer's read and write pointers */
1080 ring = &rdev->ring[ridx[i]];
1081 WREG32_P(cp_rb_cntl[i], RB_RPTR_WR_ENA, ~RB_RPTR_WR_ENA);
1096 1082
1097 WREG32(CP_RB2_BASE, ring->gpu_addr >> 8); 1083 ring->rptr = ring->wptr = 0;
1084 WREG32(ring->rptr_reg, ring->rptr);
1085 WREG32(ring->wptr_reg, ring->wptr);
1098 1086
1099 ring->rptr = RREG32(CP_RB2_RPTR); 1087 mdelay(1);
1088 WREG32_P(cp_rb_cntl[i], 0, ~RB_RPTR_WR_ENA);
1089 }
1100 1090
1101 /* start the rings */ 1091 /* start the rings */
1102 cayman_cp_start(rdev); 1092 cayman_cp_start(rdev);
@@ -1132,6 +1122,14 @@ static int cayman_gpu_soft_reset(struct radeon_device *rdev)
1132 RREG32(GRBM_STATUS_SE1)); 1122 RREG32(GRBM_STATUS_SE1));
1133 dev_info(rdev->dev, " SRBM_STATUS=0x%08X\n", 1123 dev_info(rdev->dev, " SRBM_STATUS=0x%08X\n",
1134 RREG32(SRBM_STATUS)); 1124 RREG32(SRBM_STATUS));
1125 dev_info(rdev->dev, " R_008674_CP_STALLED_STAT1 = 0x%08X\n",
1126 RREG32(CP_STALLED_STAT1));
1127 dev_info(rdev->dev, " R_008678_CP_STALLED_STAT2 = 0x%08X\n",
1128 RREG32(CP_STALLED_STAT2));
1129 dev_info(rdev->dev, " R_00867C_CP_BUSY_STAT = 0x%08X\n",
1130 RREG32(CP_BUSY_STAT));
1131 dev_info(rdev->dev, " R_008680_CP_STAT = 0x%08X\n",
1132 RREG32(CP_STAT));
1135 dev_info(rdev->dev, " VM_CONTEXT0_PROTECTION_FAULT_ADDR 0x%08X\n", 1133 dev_info(rdev->dev, " VM_CONTEXT0_PROTECTION_FAULT_ADDR 0x%08X\n",
1136 RREG32(0x14F8)); 1134 RREG32(0x14F8));
1137 dev_info(rdev->dev, " VM_CONTEXT0_PROTECTION_FAULT_STATUS 0x%08X\n", 1135 dev_info(rdev->dev, " VM_CONTEXT0_PROTECTION_FAULT_STATUS 0x%08X\n",
@@ -1180,6 +1178,14 @@ static int cayman_gpu_soft_reset(struct radeon_device *rdev)
1180 RREG32(GRBM_STATUS_SE1)); 1178 RREG32(GRBM_STATUS_SE1));
1181 dev_info(rdev->dev, " SRBM_STATUS=0x%08X\n", 1179 dev_info(rdev->dev, " SRBM_STATUS=0x%08X\n",
1182 RREG32(SRBM_STATUS)); 1180 RREG32(SRBM_STATUS));
1181 dev_info(rdev->dev, " R_008674_CP_STALLED_STAT1 = 0x%08X\n",
1182 RREG32(CP_STALLED_STAT1));
1183 dev_info(rdev->dev, " R_008678_CP_STALLED_STAT2 = 0x%08X\n",
1184 RREG32(CP_STALLED_STAT2));
1185 dev_info(rdev->dev, " R_00867C_CP_BUSY_STAT = 0x%08X\n",
1186 RREG32(CP_BUSY_STAT));
1187 dev_info(rdev->dev, " R_008680_CP_STAT = 0x%08X\n",
1188 RREG32(CP_STAT));
1183 evergreen_mc_resume(rdev, &save); 1189 evergreen_mc_resume(rdev, &save);
1184 return 0; 1190 return 0;
1185} 1191}
@@ -1291,17 +1297,17 @@ static int cayman_startup(struct radeon_device *rdev)
1291 if (r) 1297 if (r)
1292 return r; 1298 return r;
1293 1299
1294 r = radeon_ib_pool_start(rdev); 1300 r = radeon_ib_pool_init(rdev);
1295 if (r) 1301 if (r) {
1296 return r; 1302 dev_err(rdev->dev, "IB initialization failed (%d).\n", r);
1297
1298 r = radeon_ib_ring_tests(rdev);
1299 if (r)
1300 return r; 1303 return r;
1304 }
1301 1305
1302 r = radeon_vm_manager_start(rdev); 1306 r = radeon_vm_manager_init(rdev);
1303 if (r) 1307 if (r) {
1308 dev_err(rdev->dev, "vm manager initialization failed (%d).\n", r);
1304 return r; 1309 return r;
1310 }
1305 1311
1306 r = r600_audio_init(rdev); 1312 r = r600_audio_init(rdev);
1307 if (r) 1313 if (r)
@@ -1334,10 +1340,6 @@ int cayman_resume(struct radeon_device *rdev)
1334int cayman_suspend(struct radeon_device *rdev) 1340int cayman_suspend(struct radeon_device *rdev)
1335{ 1341{
1336 r600_audio_fini(rdev); 1342 r600_audio_fini(rdev);
1337 /* FIXME: we should wait for ring to be empty */
1338 radeon_ib_pool_suspend(rdev);
1339 radeon_vm_manager_suspend(rdev);
1340 r600_blit_suspend(rdev);
1341 cayman_cp_enable(rdev, false); 1343 cayman_cp_enable(rdev, false);
1342 rdev->ring[RADEON_RING_TYPE_GFX_INDEX].ready = false; 1344 rdev->ring[RADEON_RING_TYPE_GFX_INDEX].ready = false;
1343 evergreen_irq_suspend(rdev); 1345 evergreen_irq_suspend(rdev);
@@ -1413,17 +1415,7 @@ int cayman_init(struct radeon_device *rdev)
1413 if (r) 1415 if (r)
1414 return r; 1416 return r;
1415 1417
1416 r = radeon_ib_pool_init(rdev);
1417 rdev->accel_working = true; 1418 rdev->accel_working = true;
1418 if (r) {
1419 dev_err(rdev->dev, "IB initialization failed (%d).\n", r);
1420 rdev->accel_working = false;
1421 }
1422 r = radeon_vm_manager_init(rdev);
1423 if (r) {
1424 dev_err(rdev->dev, "vm manager initialization failed (%d).\n", r);
1425 }
1426
1427 r = cayman_startup(rdev); 1419 r = cayman_startup(rdev);
1428 if (r) { 1420 if (r) {
1429 dev_err(rdev->dev, "disabling GPU acceleration\n"); 1421 dev_err(rdev->dev, "disabling GPU acceleration\n");
@@ -1432,7 +1424,7 @@ int cayman_init(struct radeon_device *rdev)
1432 if (rdev->flags & RADEON_IS_IGP) 1424 if (rdev->flags & RADEON_IS_IGP)
1433 si_rlc_fini(rdev); 1425 si_rlc_fini(rdev);
1434 radeon_wb_fini(rdev); 1426 radeon_wb_fini(rdev);
1435 r100_ib_fini(rdev); 1427 radeon_ib_pool_fini(rdev);
1436 radeon_vm_manager_fini(rdev); 1428 radeon_vm_manager_fini(rdev);
1437 radeon_irq_kms_fini(rdev); 1429 radeon_irq_kms_fini(rdev);
1438 cayman_pcie_gart_fini(rdev); 1430 cayman_pcie_gart_fini(rdev);
@@ -1463,7 +1455,7 @@ void cayman_fini(struct radeon_device *rdev)
1463 si_rlc_fini(rdev); 1455 si_rlc_fini(rdev);
1464 radeon_wb_fini(rdev); 1456 radeon_wb_fini(rdev);
1465 radeon_vm_manager_fini(rdev); 1457 radeon_vm_manager_fini(rdev);
1466 r100_ib_fini(rdev); 1458 radeon_ib_pool_fini(rdev);
1467 radeon_irq_kms_fini(rdev); 1459 radeon_irq_kms_fini(rdev);
1468 cayman_pcie_gart_fini(rdev); 1460 cayman_pcie_gart_fini(rdev);
1469 r600_vram_scratch_fini(rdev); 1461 r600_vram_scratch_fini(rdev);