aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian König <deathsimple@vodafone.de>2012-05-08 08:24:01 -0400
committerChristian König <deathsimple@vodafone.de>2012-06-21 03:38:35 -0400
commit876dc9f32907e57e0298bcd0f1607cb7a2582f63 (patch)
treee7bd45fff5d2ddff8c8805ee83116e02b75d2a6a
parent9c19415c233499c26081798b880910ec0e1d7bad (diff)
drm/radeon: remove radeon_fence_create
It is completely unnecessary to create fences before they are emitted, so remove it and a bunch of checks if fences are emitted or not. Signed-off-by: Christian König <deathsimple@vodafone.de> Reviewed-by: Jerome Glisse <jglisse@redhat.com>
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c2
-rw-r--r--drivers/gpu/drm/radeon/ni.c2
-rw-r--r--drivers/gpu/drm/radeon/r100.c4
-rw-r--r--drivers/gpu/drm/radeon/r200.c4
-rw-r--r--drivers/gpu/drm/radeon/r600.c4
-rw-r--r--drivers/gpu/drm/radeon/r600_blit_kms.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon.h11
-rw-r--r--drivers/gpu/drm/radeon/radeon_asic.h8
-rw-r--r--drivers/gpu/drm/radeon/radeon_benchmark.c10
-rw-r--r--drivers/gpu/drm/radeon/radeon_fence.c42
-rw-r--r--drivers/gpu/drm/radeon/radeon_ring.c19
-rw-r--r--drivers/gpu/drm/radeon/radeon_sa.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_test.c66
-rw-r--r--drivers/gpu/drm/radeon/radeon_ttm.c30
-rw-r--r--drivers/gpu/drm/radeon/si.c6
15 files changed, 86 insertions, 130 deletions
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index 7fb3d2e0434c..8e40ba4a9b79 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -1371,7 +1371,7 @@ void evergreen_mc_program(struct radeon_device *rdev)
1371 */ 1371 */
1372void evergreen_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib) 1372void evergreen_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib)
1373{ 1373{
1374 struct radeon_ring *ring = &rdev->ring[ib->fence->ring]; 1374 struct radeon_ring *ring = &rdev->ring[ib->ring];
1375 1375
1376 /* set to DX10/11 mode */ 1376 /* set to DX10/11 mode */
1377 radeon_ring_write(ring, PACKET3(PACKET3_MODE_CONTROL, 0)); 1377 radeon_ring_write(ring, PACKET3(PACKET3_MODE_CONTROL, 0));
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index b7bf18e40215..2366be3df074 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -850,7 +850,7 @@ 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));
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index fb44e7e49083..415b7d8fbba2 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -883,7 +883,7 @@ int r100_copy_blit(struct radeon_device *rdev,
883 uint64_t src_offset, 883 uint64_t src_offset,
884 uint64_t dst_offset, 884 uint64_t dst_offset,
885 unsigned num_gpu_pages, 885 unsigned num_gpu_pages,
886 struct radeon_fence *fence) 886 struct radeon_fence **fence)
887{ 887{
888 struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; 888 struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
889 uint32_t cur_pages; 889 uint32_t cur_pages;
@@ -947,7 +947,7 @@ int r100_copy_blit(struct radeon_device *rdev,
947 RADEON_WAIT_HOST_IDLECLEAN | 947 RADEON_WAIT_HOST_IDLECLEAN |
948 RADEON_WAIT_DMA_GUI_IDLE); 948 RADEON_WAIT_DMA_GUI_IDLE);
949 if (fence) { 949 if (fence) {
950 r = radeon_fence_emit(rdev, fence); 950 r = radeon_fence_emit(rdev, fence, RADEON_RING_TYPE_GFX_INDEX);
951 } 951 }
952 radeon_ring_unlock_commit(rdev, ring); 952 radeon_ring_unlock_commit(rdev, ring);
953 return r; 953 return r;
diff --git a/drivers/gpu/drm/radeon/r200.c b/drivers/gpu/drm/radeon/r200.c
index a26144d01207..f0889259eb08 100644
--- a/drivers/gpu/drm/radeon/r200.c
+++ b/drivers/gpu/drm/radeon/r200.c
@@ -85,7 +85,7 @@ int r200_copy_dma(struct radeon_device *rdev,
85 uint64_t src_offset, 85 uint64_t src_offset,
86 uint64_t dst_offset, 86 uint64_t dst_offset,
87 unsigned num_gpu_pages, 87 unsigned num_gpu_pages,
88 struct radeon_fence *fence) 88 struct radeon_fence **fence)
89{ 89{
90 struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; 90 struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
91 uint32_t size; 91 uint32_t size;
@@ -120,7 +120,7 @@ int r200_copy_dma(struct radeon_device *rdev,
120 radeon_ring_write(ring, PACKET0(RADEON_WAIT_UNTIL, 0)); 120 radeon_ring_write(ring, PACKET0(RADEON_WAIT_UNTIL, 0));
121 radeon_ring_write(ring, RADEON_WAIT_DMA_GUI_IDLE); 121 radeon_ring_write(ring, RADEON_WAIT_DMA_GUI_IDLE);
122 if (fence) { 122 if (fence) {
123 r = radeon_fence_emit(rdev, fence); 123 r = radeon_fence_emit(rdev, fence, RADEON_RING_TYPE_GFX_INDEX);
124 } 124 }
125 radeon_ring_unlock_commit(rdev, ring); 125 radeon_ring_unlock_commit(rdev, ring);
126 return r; 126 return r;
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index bff627293812..a80e61e138db 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -2309,7 +2309,7 @@ int r600_copy_blit(struct radeon_device *rdev,
2309 uint64_t src_offset, 2309 uint64_t src_offset,
2310 uint64_t dst_offset, 2310 uint64_t dst_offset,
2311 unsigned num_gpu_pages, 2311 unsigned num_gpu_pages,
2312 struct radeon_fence *fence) 2312 struct radeon_fence **fence)
2313{ 2313{
2314 struct radeon_sa_bo *vb = NULL; 2314 struct radeon_sa_bo *vb = NULL;
2315 int r; 2315 int r;
@@ -2607,7 +2607,7 @@ void r600_fini(struct radeon_device *rdev)
2607 */ 2607 */
2608void r600_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib) 2608void r600_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib)
2609{ 2609{
2610 struct radeon_ring *ring = &rdev->ring[ib->fence->ring]; 2610 struct radeon_ring *ring = &rdev->ring[ib->ring];
2611 2611
2612 /* FIXME: implement */ 2612 /* FIXME: implement */
2613 radeon_ring_write(ring, PACKET3(PACKET3_INDIRECT_BUFFER, 2)); 2613 radeon_ring_write(ring, PACKET3(PACKET3_INDIRECT_BUFFER, 2));
diff --git a/drivers/gpu/drm/radeon/r600_blit_kms.c b/drivers/gpu/drm/radeon/r600_blit_kms.c
index 03b6e0d3d503..02f4eebf805f 100644
--- a/drivers/gpu/drm/radeon/r600_blit_kms.c
+++ b/drivers/gpu/drm/radeon/r600_blit_kms.c
@@ -703,20 +703,20 @@ int r600_blit_prepare_copy(struct radeon_device *rdev, unsigned num_gpu_pages,
703 return 0; 703 return 0;
704} 704}
705 705
706void r600_blit_done_copy(struct radeon_device *rdev, struct radeon_fence *fence, 706void r600_blit_done_copy(struct radeon_device *rdev, struct radeon_fence **fence,
707 struct radeon_sa_bo *vb) 707 struct radeon_sa_bo *vb)
708{ 708{
709 struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; 709 struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
710 int r; 710 int r;
711 711
712 r = radeon_fence_emit(rdev, fence); 712 r = radeon_fence_emit(rdev, fence, RADEON_RING_TYPE_GFX_INDEX);
713 if (r) { 713 if (r) {
714 radeon_ring_unlock_undo(rdev, ring); 714 radeon_ring_unlock_undo(rdev, ring);
715 return; 715 return;
716 } 716 }
717 717
718 radeon_ring_unlock_commit(rdev, ring); 718 radeon_ring_unlock_commit(rdev, ring);
719 radeon_sa_bo_free(rdev, &vb, fence); 719 radeon_sa_bo_free(rdev, &vb, *fence);
720} 720}
721 721
722void r600_kms_blit_copy(struct radeon_device *rdev, 722void r600_kms_blit_copy(struct radeon_device *rdev,
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index fefcca55c1eb..e2feddd91df5 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -113,7 +113,6 @@ extern int radeon_lockup_timeout;
113 113
114/* fence seq are set to this number when signaled */ 114/* fence seq are set to this number when signaled */
115#define RADEON_FENCE_SIGNALED_SEQ 0LL 115#define RADEON_FENCE_SIGNALED_SEQ 0LL
116#define RADEON_FENCE_NOTEMITED_SEQ (~0LL)
117 116
118/* internal ring indices */ 117/* internal ring indices */
119/* r1xx+ has gfx CP ring */ 118/* r1xx+ has gfx CP ring */
@@ -277,8 +276,7 @@ struct radeon_fence {
277int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring); 276int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring);
278int radeon_fence_driver_init(struct radeon_device *rdev); 277int radeon_fence_driver_init(struct radeon_device *rdev);
279void radeon_fence_driver_fini(struct radeon_device *rdev); 278void radeon_fence_driver_fini(struct radeon_device *rdev);
280int radeon_fence_create(struct radeon_device *rdev, struct radeon_fence **fence, int ring); 279int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence **fence, int ring);
281int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence *fence);
282void radeon_fence_process(struct radeon_device *rdev, int ring); 280void radeon_fence_process(struct radeon_device *rdev, int ring);
283bool radeon_fence_signaled(struct radeon_fence *fence); 281bool radeon_fence_signaled(struct radeon_fence *fence);
284int radeon_fence_wait(struct radeon_fence *fence, bool interruptible); 282int radeon_fence_wait(struct radeon_fence *fence, bool interruptible);
@@ -630,6 +628,7 @@ struct radeon_ib {
630 uint32_t length_dw; 628 uint32_t length_dw;
631 uint64_t gpu_addr; 629 uint64_t gpu_addr;
632 uint32_t *ptr; 630 uint32_t *ptr;
631 int ring;
633 struct radeon_fence *fence; 632 struct radeon_fence *fence;
634 unsigned vm_id; 633 unsigned vm_id;
635 bool is_const_ib; 634 bool is_const_ib;
@@ -1192,20 +1191,20 @@ struct radeon_asic {
1192 uint64_t src_offset, 1191 uint64_t src_offset,
1193 uint64_t dst_offset, 1192 uint64_t dst_offset,
1194 unsigned num_gpu_pages, 1193 unsigned num_gpu_pages,
1195 struct radeon_fence *fence); 1194 struct radeon_fence **fence);
1196 u32 blit_ring_index; 1195 u32 blit_ring_index;
1197 int (*dma)(struct radeon_device *rdev, 1196 int (*dma)(struct radeon_device *rdev,
1198 uint64_t src_offset, 1197 uint64_t src_offset,
1199 uint64_t dst_offset, 1198 uint64_t dst_offset,
1200 unsigned num_gpu_pages, 1199 unsigned num_gpu_pages,
1201 struct radeon_fence *fence); 1200 struct radeon_fence **fence);
1202 u32 dma_ring_index; 1201 u32 dma_ring_index;
1203 /* method used for bo copy */ 1202 /* method used for bo copy */
1204 int (*copy)(struct radeon_device *rdev, 1203 int (*copy)(struct radeon_device *rdev,
1205 uint64_t src_offset, 1204 uint64_t src_offset,
1206 uint64_t dst_offset, 1205 uint64_t dst_offset,
1207 unsigned num_gpu_pages, 1206 unsigned num_gpu_pages,
1208 struct radeon_fence *fence); 1207 struct radeon_fence **fence);
1209 /* ring used for bo copies */ 1208 /* ring used for bo copies */
1210 u32 copy_ring_index; 1209 u32 copy_ring_index;
1211 } copy; 1210 } copy;
diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h
index e76a941ef14e..8cdf075aacfd 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.h
+++ b/drivers/gpu/drm/radeon/radeon_asic.h
@@ -79,7 +79,7 @@ int r100_copy_blit(struct radeon_device *rdev,
79 uint64_t src_offset, 79 uint64_t src_offset,
80 uint64_t dst_offset, 80 uint64_t dst_offset,
81 unsigned num_gpu_pages, 81 unsigned num_gpu_pages,
82 struct radeon_fence *fence); 82 struct radeon_fence **fence);
83int r100_set_surface_reg(struct radeon_device *rdev, int reg, 83int r100_set_surface_reg(struct radeon_device *rdev, int reg,
84 uint32_t tiling_flags, uint32_t pitch, 84 uint32_t tiling_flags, uint32_t pitch,
85 uint32_t offset, uint32_t obj_size); 85 uint32_t offset, uint32_t obj_size);
@@ -144,7 +144,7 @@ extern int r200_copy_dma(struct radeon_device *rdev,
144 uint64_t src_offset, 144 uint64_t src_offset,
145 uint64_t dst_offset, 145 uint64_t dst_offset,
146 unsigned num_gpu_pages, 146 unsigned num_gpu_pages,
147 struct radeon_fence *fence); 147 struct radeon_fence **fence);
148void r200_set_safe_registers(struct radeon_device *rdev); 148void r200_set_safe_registers(struct radeon_device *rdev);
149 149
150/* 150/*
@@ -318,7 +318,7 @@ void r600_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib);
318int r600_ring_test(struct radeon_device *rdev, struct radeon_ring *cp); 318int r600_ring_test(struct radeon_device *rdev, struct radeon_ring *cp);
319int r600_copy_blit(struct radeon_device *rdev, 319int r600_copy_blit(struct radeon_device *rdev,
320 uint64_t src_offset, uint64_t dst_offset, 320 uint64_t src_offset, uint64_t dst_offset,
321 unsigned num_gpu_pages, struct radeon_fence *fence); 321 unsigned num_gpu_pages, struct radeon_fence **fence);
322void r600_hpd_init(struct radeon_device *rdev); 322void r600_hpd_init(struct radeon_device *rdev);
323void r600_hpd_fini(struct radeon_device *rdev); 323void r600_hpd_fini(struct radeon_device *rdev);
324bool r600_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd); 324bool r600_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd);
@@ -364,7 +364,7 @@ void r600_hdmi_update_audio_settings(struct drm_encoder *encoder);
364/* r600 blit */ 364/* r600 blit */
365int r600_blit_prepare_copy(struct radeon_device *rdev, unsigned num_gpu_pages, 365int r600_blit_prepare_copy(struct radeon_device *rdev, unsigned num_gpu_pages,
366 struct radeon_sa_bo **vb); 366 struct radeon_sa_bo **vb);
367void r600_blit_done_copy(struct radeon_device *rdev, struct radeon_fence *fence, 367void r600_blit_done_copy(struct radeon_device *rdev, struct radeon_fence **fence,
368 struct radeon_sa_bo *vb); 368 struct radeon_sa_bo *vb);
369void r600_kms_blit_copy(struct radeon_device *rdev, 369void r600_kms_blit_copy(struct radeon_device *rdev,
370 u64 src_gpu_addr, u64 dst_gpu_addr, 370 u64 src_gpu_addr, u64 dst_gpu_addr,
diff --git a/drivers/gpu/drm/radeon/radeon_benchmark.c b/drivers/gpu/drm/radeon/radeon_benchmark.c
index 364f5b1a04b9..bedda9caadd9 100644
--- a/drivers/gpu/drm/radeon/radeon_benchmark.c
+++ b/drivers/gpu/drm/radeon/radeon_benchmark.c
@@ -45,20 +45,14 @@ static int radeon_benchmark_do_move(struct radeon_device *rdev, unsigned size,
45 for (i = 0; i < n; i++) { 45 for (i = 0; i < n; i++) {
46 switch (flag) { 46 switch (flag) {
47 case RADEON_BENCHMARK_COPY_DMA: 47 case RADEON_BENCHMARK_COPY_DMA:
48 r = radeon_fence_create(rdev, &fence, radeon_copy_dma_ring_index(rdev));
49 if (r)
50 return r;
51 r = radeon_copy_dma(rdev, saddr, daddr, 48 r = radeon_copy_dma(rdev, saddr, daddr,
52 size / RADEON_GPU_PAGE_SIZE, 49 size / RADEON_GPU_PAGE_SIZE,
53 fence); 50 &fence);
54 break; 51 break;
55 case RADEON_BENCHMARK_COPY_BLIT: 52 case RADEON_BENCHMARK_COPY_BLIT:
56 r = radeon_fence_create(rdev, &fence, radeon_copy_blit_ring_index(rdev));
57 if (r)
58 return r;
59 r = radeon_copy_blit(rdev, saddr, daddr, 53 r = radeon_copy_blit(rdev, saddr, daddr,
60 size / RADEON_GPU_PAGE_SIZE, 54 size / RADEON_GPU_PAGE_SIZE,
61 fence); 55 &fence);
62 break; 56 break;
63 default: 57 default:
64 DRM_ERROR("Unknown copy method\n"); 58 DRM_ERROR("Unknown copy method\n");
diff --git a/drivers/gpu/drm/radeon/radeon_fence.c b/drivers/gpu/drm/radeon/radeon_fence.c
index 11f5f402d22c..401d346a05c0 100644
--- a/drivers/gpu/drm/radeon/radeon_fence.c
+++ b/drivers/gpu/drm/radeon/radeon_fence.c
@@ -61,15 +61,21 @@ static u32 radeon_fence_read(struct radeon_device *rdev, int ring)
61 return seq; 61 return seq;
62} 62}
63 63
64int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence *fence) 64int radeon_fence_emit(struct radeon_device *rdev,
65 struct radeon_fence **fence,
66 int ring)
65{ 67{
66 /* we are protected by the ring emission mutex */ 68 /* we are protected by the ring emission mutex */
67 if (fence->seq && fence->seq < RADEON_FENCE_NOTEMITED_SEQ) { 69 *fence = kmalloc(sizeof(struct radeon_fence), GFP_KERNEL);
68 return 0; 70 if ((*fence) == NULL) {
71 return -ENOMEM;
69 } 72 }
70 fence->seq = ++rdev->fence_drv[fence->ring].seq; 73 kref_init(&((*fence)->kref));
71 radeon_fence_ring_emit(rdev, fence->ring, fence); 74 (*fence)->rdev = rdev;
72 trace_radeon_fence_emit(rdev->ddev, fence->seq); 75 (*fence)->seq = ++rdev->fence_drv[ring].seq;
76 (*fence)->ring = ring;
77 radeon_fence_ring_emit(rdev, ring, *fence);
78 trace_radeon_fence_emit(rdev->ddev, (*fence)->seq);
73 return 0; 79 return 0;
74} 80}
75 81
@@ -138,25 +144,9 @@ static void radeon_fence_destroy(struct kref *kref)
138 struct radeon_fence *fence; 144 struct radeon_fence *fence;
139 145
140 fence = container_of(kref, struct radeon_fence, kref); 146 fence = container_of(kref, struct radeon_fence, kref);
141 fence->seq = RADEON_FENCE_NOTEMITED_SEQ;
142 kfree(fence); 147 kfree(fence);
143} 148}
144 149
145int radeon_fence_create(struct radeon_device *rdev,
146 struct radeon_fence **fence,
147 int ring)
148{
149 *fence = kmalloc(sizeof(struct radeon_fence), GFP_KERNEL);
150 if ((*fence) == NULL) {
151 return -ENOMEM;
152 }
153 kref_init(&((*fence)->kref));
154 (*fence)->rdev = rdev;
155 (*fence)->seq = RADEON_FENCE_NOTEMITED_SEQ;
156 (*fence)->ring = ring;
157 return 0;
158}
159
160static bool radeon_fence_seq_signaled(struct radeon_device *rdev, 150static bool radeon_fence_seq_signaled(struct radeon_device *rdev,
161 u64 seq, unsigned ring) 151 u64 seq, unsigned ring)
162{ 152{
@@ -176,10 +166,6 @@ bool radeon_fence_signaled(struct radeon_fence *fence)
176 if (!fence) { 166 if (!fence) {
177 return true; 167 return true;
178 } 168 }
179 if (fence->seq == RADEON_FENCE_NOTEMITED_SEQ) {
180 WARN(1, "Querying an unemitted fence : %p !\n", fence);
181 return true;
182 }
183 if (fence->seq == RADEON_FENCE_SIGNALED_SEQ) { 169 if (fence->seq == RADEON_FENCE_SIGNALED_SEQ) {
184 return true; 170 return true;
185 } 171 }
@@ -444,9 +430,7 @@ int radeon_fence_wait_any(struct radeon_device *rdev,
444 return 0; 430 return 0;
445 } 431 }
446 432
447 if (fences[i]->seq < RADEON_FENCE_NOTEMITED_SEQ) { 433 seq[i] = fences[i]->seq;
448 seq[i] = fences[i]->seq;
449 }
450 } 434 }
451 435
452 r = radeon_fence_wait_any_seq(rdev, seq, intr); 436 r = radeon_fence_wait_any_seq(rdev, seq, intr);
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
index 983658c91358..dd506c216d8f 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -49,13 +49,9 @@ int radeon_ib_get(struct radeon_device *rdev, int ring,
49 dev_err(rdev->dev, "failed to get a new IB (%d)\n", r); 49 dev_err(rdev->dev, "failed to get a new IB (%d)\n", r);
50 return r; 50 return r;
51 } 51 }
52 r = radeon_fence_create(rdev, &ib->fence, ring);
53 if (r) {
54 dev_err(rdev->dev, "failed to create fence for new IB (%d)\n", r);
55 radeon_sa_bo_free(rdev, &ib->sa_bo, NULL);
56 return r;
57 }
58 52
53 ib->ring = ring;
54 ib->fence = NULL;
59 ib->ptr = radeon_sa_bo_cpu_addr(ib->sa_bo); 55 ib->ptr = radeon_sa_bo_cpu_addr(ib->sa_bo);
60 ib->gpu_addr = radeon_sa_bo_gpu_addr(ib->sa_bo); 56 ib->gpu_addr = radeon_sa_bo_gpu_addr(ib->sa_bo);
61 ib->vm_id = 0; 57 ib->vm_id = 0;
@@ -74,7 +70,7 @@ void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib *ib)
74 70
75int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib) 71int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib)
76{ 72{
77 struct radeon_ring *ring = &rdev->ring[ib->fence->ring]; 73 struct radeon_ring *ring = &rdev->ring[ib->ring];
78 int r = 0; 74 int r = 0;
79 75
80 if (!ib->length_dw || !ring->ready) { 76 if (!ib->length_dw || !ring->ready) {
@@ -89,8 +85,13 @@ int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib)
89 dev_err(rdev->dev, "scheduling IB failed (%d).\n", r); 85 dev_err(rdev->dev, "scheduling IB failed (%d).\n", r);
90 return r; 86 return r;
91 } 87 }
92 radeon_ring_ib_execute(rdev, ib->fence->ring, ib); 88 radeon_ring_ib_execute(rdev, ib->ring, ib);
93 radeon_fence_emit(rdev, ib->fence); 89 r = radeon_fence_emit(rdev, &ib->fence, ib->ring);
90 if (r) {
91 dev_err(rdev->dev, "failed to emit fence for new IB (%d)\n", r);
92 radeon_ring_unlock_undo(rdev, ring);
93 return r;
94 }
94 radeon_ring_unlock_commit(rdev, ring); 95 radeon_ring_unlock_commit(rdev, ring);
95 return 0; 96 return 0;
96} 97}
diff --git a/drivers/gpu/drm/radeon/radeon_sa.c b/drivers/gpu/drm/radeon/radeon_sa.c
index 32059b745728..81dbb5b946ef 100644
--- a/drivers/gpu/drm/radeon/radeon_sa.c
+++ b/drivers/gpu/drm/radeon/radeon_sa.c
@@ -349,7 +349,7 @@ void radeon_sa_bo_free(struct radeon_device *rdev, struct radeon_sa_bo **sa_bo,
349 349
350 sa_manager = (*sa_bo)->manager; 350 sa_manager = (*sa_bo)->manager;
351 spin_lock(&sa_manager->lock); 351 spin_lock(&sa_manager->lock);
352 if (fence && fence->seq && fence->seq < RADEON_FENCE_NOTEMITED_SEQ) { 352 if (fence && !radeon_fence_signaled(fence)) {
353 (*sa_bo)->fence = radeon_fence_ref(fence); 353 (*sa_bo)->fence = radeon_fence_ref(fence);
354 list_add_tail(&(*sa_bo)->flist, 354 list_add_tail(&(*sa_bo)->flist,
355 &sa_manager->flist[fence->ring]); 355 &sa_manager->flist[fence->ring]);
diff --git a/drivers/gpu/drm/radeon/radeon_test.c b/drivers/gpu/drm/radeon/radeon_test.c
index efff929ea49d..47e1535f2706 100644
--- a/drivers/gpu/drm/radeon/radeon_test.c
+++ b/drivers/gpu/drm/radeon/radeon_test.c
@@ -106,13 +106,7 @@ void radeon_test_moves(struct radeon_device *rdev)
106 106
107 radeon_bo_kunmap(gtt_obj[i]); 107 radeon_bo_kunmap(gtt_obj[i]);
108 108
109 r = radeon_fence_create(rdev, &fence, RADEON_RING_TYPE_GFX_INDEX); 109 r = radeon_copy(rdev, gtt_addr, vram_addr, size / RADEON_GPU_PAGE_SIZE, &fence);
110 if (r) {
111 DRM_ERROR("Failed to create GTT->VRAM fence %d\n", i);
112 goto out_cleanup;
113 }
114
115 r = radeon_copy(rdev, gtt_addr, vram_addr, size / RADEON_GPU_PAGE_SIZE, fence);
116 if (r) { 110 if (r) {
117 DRM_ERROR("Failed GTT->VRAM copy %d\n", i); 111 DRM_ERROR("Failed GTT->VRAM copy %d\n", i);
118 goto out_cleanup; 112 goto out_cleanup;
@@ -155,13 +149,7 @@ void radeon_test_moves(struct radeon_device *rdev)
155 149
156 radeon_bo_kunmap(vram_obj); 150 radeon_bo_kunmap(vram_obj);
157 151
158 r = radeon_fence_create(rdev, &fence, RADEON_RING_TYPE_GFX_INDEX); 152 r = radeon_copy(rdev, vram_addr, gtt_addr, size / RADEON_GPU_PAGE_SIZE, &fence);
159 if (r) {
160 DRM_ERROR("Failed to create VRAM->GTT fence %d\n", i);
161 goto out_cleanup;
162 }
163
164 r = radeon_copy(rdev, vram_addr, gtt_addr, size / RADEON_GPU_PAGE_SIZE, fence);
165 if (r) { 153 if (r) {
166 DRM_ERROR("Failed VRAM->GTT copy %d\n", i); 154 DRM_ERROR("Failed VRAM->GTT copy %d\n", i);
167 goto out_cleanup; 155 goto out_cleanup;
@@ -245,17 +233,6 @@ void radeon_test_ring_sync(struct radeon_device *rdev,
245 int ridxB = radeon_ring_index(rdev, ringB); 233 int ridxB = radeon_ring_index(rdev, ringB);
246 int r; 234 int r;
247 235
248 r = radeon_fence_create(rdev, &fence1, ridxA);
249 if (r) {
250 DRM_ERROR("Failed to create sync fence 1\n");
251 goto out_cleanup;
252 }
253 r = radeon_fence_create(rdev, &fence2, ridxA);
254 if (r) {
255 DRM_ERROR("Failed to create sync fence 2\n");
256 goto out_cleanup;
257 }
258
259 r = radeon_semaphore_create(rdev, &semaphore); 236 r = radeon_semaphore_create(rdev, &semaphore);
260 if (r) { 237 if (r) {
261 DRM_ERROR("Failed to create semaphore\n"); 238 DRM_ERROR("Failed to create semaphore\n");
@@ -268,9 +245,19 @@ void radeon_test_ring_sync(struct radeon_device *rdev,
268 goto out_cleanup; 245 goto out_cleanup;
269 } 246 }
270 radeon_semaphore_emit_wait(rdev, ridxA, semaphore); 247 radeon_semaphore_emit_wait(rdev, ridxA, semaphore);
271 radeon_fence_emit(rdev, fence1); 248 r = radeon_fence_emit(rdev, &fence1, ridxA);
249 if (r) {
250 DRM_ERROR("Failed to emit fence 1\n");
251 radeon_ring_unlock_undo(rdev, ringA);
252 goto out_cleanup;
253 }
272 radeon_semaphore_emit_wait(rdev, ridxA, semaphore); 254 radeon_semaphore_emit_wait(rdev, ridxA, semaphore);
273 radeon_fence_emit(rdev, fence2); 255 r = radeon_fence_emit(rdev, &fence2, ridxA);
256 if (r) {
257 DRM_ERROR("Failed to emit fence 2\n");
258 radeon_ring_unlock_undo(rdev, ringA);
259 goto out_cleanup;
260 }
274 radeon_ring_unlock_commit(rdev, ringA); 261 radeon_ring_unlock_commit(rdev, ringA);
275 262
276 mdelay(1000); 263 mdelay(1000);
@@ -342,17 +329,6 @@ void radeon_test_ring_sync2(struct radeon_device *rdev,
342 bool sigA, sigB; 329 bool sigA, sigB;
343 int i, r; 330 int i, r;
344 331
345 r = radeon_fence_create(rdev, &fenceA, ridxA);
346 if (r) {
347 DRM_ERROR("Failed to create sync fence 1\n");
348 goto out_cleanup;
349 }
350 r = radeon_fence_create(rdev, &fenceB, ridxB);
351 if (r) {
352 DRM_ERROR("Failed to create sync fence 2\n");
353 goto out_cleanup;
354 }
355
356 r = radeon_semaphore_create(rdev, &semaphore); 332 r = radeon_semaphore_create(rdev, &semaphore);
357 if (r) { 333 if (r) {
358 DRM_ERROR("Failed to create semaphore\n"); 334 DRM_ERROR("Failed to create semaphore\n");
@@ -365,7 +341,12 @@ void radeon_test_ring_sync2(struct radeon_device *rdev,
365 goto out_cleanup; 341 goto out_cleanup;
366 } 342 }
367 radeon_semaphore_emit_wait(rdev, ridxA, semaphore); 343 radeon_semaphore_emit_wait(rdev, ridxA, semaphore);
368 radeon_fence_emit(rdev, fenceA); 344 r = radeon_fence_emit(rdev, &fenceA, ridxA);
345 if (r) {
346 DRM_ERROR("Failed to emit sync fence 1\n");
347 radeon_ring_unlock_undo(rdev, ringA);
348 goto out_cleanup;
349 }
369 radeon_ring_unlock_commit(rdev, ringA); 350 radeon_ring_unlock_commit(rdev, ringA);
370 351
371 r = radeon_ring_lock(rdev, ringB, 64); 352 r = radeon_ring_lock(rdev, ringB, 64);
@@ -374,7 +355,12 @@ void radeon_test_ring_sync2(struct radeon_device *rdev,
374 goto out_cleanup; 355 goto out_cleanup;
375 } 356 }
376 radeon_semaphore_emit_wait(rdev, ridxB, semaphore); 357 radeon_semaphore_emit_wait(rdev, ridxB, semaphore);
377 radeon_fence_emit(rdev, fenceB); 358 r = radeon_fence_emit(rdev, &fenceB, ridxB);
359 if (r) {
360 DRM_ERROR("Failed to create sync fence 2\n");
361 radeon_ring_unlock_undo(rdev, ringB);
362 goto out_cleanup;
363 }
378 radeon_ring_unlock_commit(rdev, ringB); 364 radeon_ring_unlock_commit(rdev, ringB);
379 365
380 mdelay(1000); 366 mdelay(1000);
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index c94a2257761f..2d36bdda9327 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -222,15 +222,12 @@ static int radeon_move_blit(struct ttm_buffer_object *bo,
222{ 222{
223 struct radeon_device *rdev; 223 struct radeon_device *rdev;
224 uint64_t old_start, new_start; 224 uint64_t old_start, new_start;
225 struct radeon_fence *fence, *old_fence; 225 struct radeon_fence *fence;
226 struct radeon_semaphore *sem = NULL; 226 struct radeon_semaphore *sem = NULL;
227 int r; 227 int r, ridx;
228 228
229 rdev = radeon_get_rdev(bo->bdev); 229 rdev = radeon_get_rdev(bo->bdev);
230 r = radeon_fence_create(rdev, &fence, radeon_copy_ring_index(rdev)); 230 ridx = radeon_copy_ring_index(rdev);
231 if (unlikely(r)) {
232 return r;
233 }
234 old_start = old_mem->start << PAGE_SHIFT; 231 old_start = old_mem->start << PAGE_SHIFT;
235 new_start = new_mem->start << PAGE_SHIFT; 232 new_start = new_mem->start << PAGE_SHIFT;
236 233
@@ -243,7 +240,6 @@ static int radeon_move_blit(struct ttm_buffer_object *bo,
243 break; 240 break;
244 default: 241 default:
245 DRM_ERROR("Unknown placement %d\n", old_mem->mem_type); 242 DRM_ERROR("Unknown placement %d\n", old_mem->mem_type);
246 radeon_fence_unref(&fence);
247 return -EINVAL; 243 return -EINVAL;
248 } 244 }
249 switch (new_mem->mem_type) { 245 switch (new_mem->mem_type) {
@@ -255,42 +251,38 @@ static int radeon_move_blit(struct ttm_buffer_object *bo,
255 break; 251 break;
256 default: 252 default:
257 DRM_ERROR("Unknown placement %d\n", old_mem->mem_type); 253 DRM_ERROR("Unknown placement %d\n", old_mem->mem_type);
258 radeon_fence_unref(&fence);
259 return -EINVAL; 254 return -EINVAL;
260 } 255 }
261 if (!rdev->ring[radeon_copy_ring_index(rdev)].ready) { 256 if (!rdev->ring[ridx].ready) {
262 DRM_ERROR("Trying to move memory with ring turned off.\n"); 257 DRM_ERROR("Trying to move memory with ring turned off.\n");
263 radeon_fence_unref(&fence);
264 return -EINVAL; 258 return -EINVAL;
265 } 259 }
266 260
267 BUILD_BUG_ON((PAGE_SIZE % RADEON_GPU_PAGE_SIZE) != 0); 261 BUILD_BUG_ON((PAGE_SIZE % RADEON_GPU_PAGE_SIZE) != 0);
268 262
269 /* sync other rings */ 263 /* sync other rings */
270 old_fence = bo->sync_obj; 264 fence = bo->sync_obj;
271 if (old_fence && old_fence->ring != fence->ring 265 if (fence && fence->ring != ridx
272 && !radeon_fence_signaled(old_fence)) { 266 && !radeon_fence_signaled(fence)) {
273 bool sync_to_ring[RADEON_NUM_RINGS] = { }; 267 bool sync_to_ring[RADEON_NUM_RINGS] = { };
274 sync_to_ring[old_fence->ring] = true; 268 sync_to_ring[fence->ring] = true;
275 269
276 r = radeon_semaphore_create(rdev, &sem); 270 r = radeon_semaphore_create(rdev, &sem);
277 if (r) { 271 if (r) {
278 radeon_fence_unref(&fence);
279 return r; 272 return r;
280 } 273 }
281 274
282 r = radeon_semaphore_sync_rings(rdev, sem, 275 r = radeon_semaphore_sync_rings(rdev, sem, sync_to_ring, ridx);
283 sync_to_ring, fence->ring);
284 if (r) { 276 if (r) {
285 radeon_semaphore_free(rdev, sem, NULL); 277 radeon_semaphore_free(rdev, sem, NULL);
286 radeon_fence_unref(&fence);
287 return r; 278 return r;
288 } 279 }
289 } 280 }
290 281
282 fence = NULL;
291 r = radeon_copy(rdev, old_start, new_start, 283 r = radeon_copy(rdev, old_start, new_start,
292 new_mem->num_pages * (PAGE_SIZE / RADEON_GPU_PAGE_SIZE), /* GPU pages */ 284 new_mem->num_pages * (PAGE_SIZE / RADEON_GPU_PAGE_SIZE), /* GPU pages */
293 fence); 285 &fence);
294 /* FIXME: handle copy error */ 286 /* FIXME: handle copy error */
295 r = ttm_bo_move_accel_cleanup(bo, (void *)fence, NULL, 287 r = ttm_bo_move_accel_cleanup(bo, (void *)fence, NULL,
296 evict, no_wait_reserve, no_wait_gpu, new_mem); 288 evict, no_wait_reserve, no_wait_gpu, new_mem);
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
index c7b61f16ecfd..8868a1fa20e5 100644
--- a/drivers/gpu/drm/radeon/si.c
+++ b/drivers/gpu/drm/radeon/si.c
@@ -1762,7 +1762,7 @@ void si_fence_ring_emit(struct radeon_device *rdev,
1762 */ 1762 */
1763void si_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib) 1763void si_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib)
1764{ 1764{
1765 struct radeon_ring *ring = &rdev->ring[ib->fence->ring]; 1765 struct radeon_ring *ring = &rdev->ring[ib->ring];
1766 u32 header; 1766 u32 header;
1767 1767
1768 if (ib->is_const_ib) 1768 if (ib->is_const_ib)
@@ -2702,7 +2702,7 @@ int si_ib_parse(struct radeon_device *rdev, struct radeon_ib *ib)
2702 if (ib->is_const_ib) 2702 if (ib->is_const_ib)
2703 ret = si_vm_packet3_ce_check(rdev, ib->ptr, &pkt); 2703 ret = si_vm_packet3_ce_check(rdev, ib->ptr, &pkt);
2704 else { 2704 else {
2705 switch (ib->fence->ring) { 2705 switch (ib->ring) {
2706 case RADEON_RING_TYPE_GFX_INDEX: 2706 case RADEON_RING_TYPE_GFX_INDEX:
2707 ret = si_vm_packet3_gfx_check(rdev, ib->ptr, &pkt); 2707 ret = si_vm_packet3_gfx_check(rdev, ib->ptr, &pkt);
2708 break; 2708 break;
@@ -2711,7 +2711,7 @@ int si_ib_parse(struct radeon_device *rdev, struct radeon_ib *ib)
2711 ret = si_vm_packet3_compute_check(rdev, ib->ptr, &pkt); 2711 ret = si_vm_packet3_compute_check(rdev, ib->ptr, &pkt);
2712 break; 2712 break;
2713 default: 2713 default:
2714 dev_err(rdev->dev, "Non-PM4 ring %d !\n", ib->fence->ring); 2714 dev_err(rdev->dev, "Non-PM4 ring %d !\n", ib->ring);
2715 ret = -EINVAL; 2715 ret = -EINVAL;
2716 break; 2716 break;
2717 } 2717 }