aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorAlex Deucher <alexander.deucher@amd.com>2013-07-11 14:48:05 -0400
committerAlex Deucher <alexander.deucher@amd.com>2013-07-14 10:11:26 -0400
commit072b5acc7edec1530acc0497b48616bf8dd93313 (patch)
tree900a7f7a647a6bee38a13eeea8aebadd9917dc84 /drivers/gpu
parentaeea40cbf9388fc829e66fa049f64d97fd72e118 (diff)
drm/radeon: implement bo copy callback using CP DMA (v2)
Lighter weight than using the 3D engine. v2: fix ring count Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/radeon/r600.c81
-rw-r--r--drivers/gpu/drm/radeon/r600d.h1
-rw-r--r--drivers/gpu/drm/radeon/radeon_asic.h3
3 files changed, 85 insertions, 0 deletions
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 2d3655f7f41e..f7d494f264a5 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -3145,6 +3145,87 @@ int r600_copy_blit(struct radeon_device *rdev,
3145} 3145}
3146 3146
3147/** 3147/**
3148 * r600_copy_cpdma - copy pages using the CP DMA engine
3149 *
3150 * @rdev: radeon_device pointer
3151 * @src_offset: src GPU address
3152 * @dst_offset: dst GPU address
3153 * @num_gpu_pages: number of GPU pages to xfer
3154 * @fence: radeon fence object
3155 *
3156 * Copy GPU paging using the CP DMA engine (r6xx+).
3157 * Used by the radeon ttm implementation to move pages if
3158 * registered as the asic copy callback.
3159 */
3160int r600_copy_cpdma(struct radeon_device *rdev,
3161 uint64_t src_offset, uint64_t dst_offset,
3162 unsigned num_gpu_pages,
3163 struct radeon_fence **fence)
3164{
3165 struct radeon_semaphore *sem = NULL;
3166 int ring_index = rdev->asic->copy.blit_ring_index;
3167 struct radeon_ring *ring = &rdev->ring[ring_index];
3168 u32 size_in_bytes, cur_size_in_bytes, tmp;
3169 int i, num_loops;
3170 int r = 0;
3171
3172 r = radeon_semaphore_create(rdev, &sem);
3173 if (r) {
3174 DRM_ERROR("radeon: moving bo (%d).\n", r);
3175 return r;
3176 }
3177
3178 size_in_bytes = (num_gpu_pages << RADEON_GPU_PAGE_SHIFT);
3179 num_loops = DIV_ROUND_UP(size_in_bytes, 0x1fffff);
3180 r = radeon_ring_lock(rdev, ring, num_loops * 6 + 21);
3181 if (r) {
3182 DRM_ERROR("radeon: moving bo (%d).\n", r);
3183 radeon_semaphore_free(rdev, &sem, NULL);
3184 return r;
3185 }
3186
3187 if (radeon_fence_need_sync(*fence, ring->idx)) {
3188 radeon_semaphore_sync_rings(rdev, sem, (*fence)->ring,
3189 ring->idx);
3190 radeon_fence_note_sync(*fence, ring->idx);
3191 } else {
3192 radeon_semaphore_free(rdev, &sem, NULL);
3193 }
3194
3195 for (i = 0; i < num_loops; i++) {
3196 cur_size_in_bytes = size_in_bytes;
3197 if (cur_size_in_bytes > 0x1fffff)
3198 cur_size_in_bytes = 0x1fffff;
3199 size_in_bytes -= cur_size_in_bytes;
3200 tmp = upper_32_bits(src_offset) & 0xff;
3201 if (size_in_bytes == 0)
3202 tmp |= PACKET3_CP_DMA_CP_SYNC;
3203 radeon_ring_write(ring, PACKET3(PACKET3_CP_DMA, 4));
3204 radeon_ring_write(ring, src_offset & 0xffffffff);
3205 radeon_ring_write(ring, tmp);
3206 radeon_ring_write(ring, dst_offset & 0xffffffff);
3207 radeon_ring_write(ring, upper_32_bits(dst_offset) & 0xff);
3208 radeon_ring_write(ring, cur_size_in_bytes);
3209 src_offset += cur_size_in_bytes;
3210 dst_offset += cur_size_in_bytes;
3211 }
3212 radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1));
3213 radeon_ring_write(ring, (WAIT_UNTIL - PACKET3_SET_CONFIG_REG_OFFSET) >> 2);
3214 radeon_ring_write(ring, WAIT_CP_DMA_IDLE_bit);
3215
3216 r = radeon_fence_emit(rdev, fence, ring->idx);
3217 if (r) {
3218 radeon_ring_unlock_undo(rdev, ring);
3219 return r;
3220 }
3221
3222 radeon_ring_unlock_commit(rdev, ring);
3223 radeon_semaphore_free(rdev, &sem, *fence);
3224
3225 return r;
3226}
3227
3228/**
3148 * r600_copy_dma - copy pages using the DMA engine 3229 * r600_copy_dma - copy pages using the DMA engine
3149 * 3230 *
3150 * @rdev: radeon_device pointer 3231 * @rdev: radeon_device pointer
diff --git a/drivers/gpu/drm/radeon/r600d.h b/drivers/gpu/drm/radeon/r600d.h
index f1b3084d8f51..8e3fe815edab 100644
--- a/drivers/gpu/drm/radeon/r600d.h
+++ b/drivers/gpu/drm/radeon/r600d.h
@@ -602,6 +602,7 @@
602#define L2_BUSY (1 << 0) 602#define L2_BUSY (1 << 0)
603 603
604#define WAIT_UNTIL 0x8040 604#define WAIT_UNTIL 0x8040
605#define WAIT_CP_DMA_IDLE_bit (1 << 8)
605#define WAIT_2D_IDLE_bit (1 << 14) 606#define WAIT_2D_IDLE_bit (1 << 14)
606#define WAIT_3D_IDLE_bit (1 << 15) 607#define WAIT_3D_IDLE_bit (1 << 15)
607#define WAIT_2D_IDLECLEAN_bit (1 << 16) 608#define WAIT_2D_IDLECLEAN_bit (1 << 16)
diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h
index 45d0693cddd5..b04b5789f4a8 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.h
+++ b/drivers/gpu/drm/radeon/radeon_asic.h
@@ -340,6 +340,9 @@ int r600_uvd_ring_test(struct radeon_device *rdev, struct radeon_ring *ring);
340int r600_copy_blit(struct radeon_device *rdev, 340int r600_copy_blit(struct radeon_device *rdev,
341 uint64_t src_offset, uint64_t dst_offset, 341 uint64_t src_offset, uint64_t dst_offset,
342 unsigned num_gpu_pages, struct radeon_fence **fence); 342 unsigned num_gpu_pages, struct radeon_fence **fence);
343int r600_copy_cpdma(struct radeon_device *rdev,
344 uint64_t src_offset, uint64_t dst_offset,
345 unsigned num_gpu_pages, struct radeon_fence **fence);
343int r600_copy_dma(struct radeon_device *rdev, 346int r600_copy_dma(struct radeon_device *rdev,
344 uint64_t src_offset, uint64_t dst_offset, 347 uint64_t src_offset, uint64_t dst_offset,
345 unsigned num_gpu_pages, struct radeon_fence **fence); 348 unsigned num_gpu_pages, struct radeon_fence **fence);