提交 876dc9f3 编写于 作者: C Christian König

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: NChristian König <deathsimple@vodafone.de>
Reviewed-by: NJerome Glisse <jglisse@redhat.com>
上级 9c19415c
...@@ -1371,7 +1371,7 @@ void evergreen_mc_program(struct radeon_device *rdev) ...@@ -1371,7 +1371,7 @@ void evergreen_mc_program(struct radeon_device *rdev)
*/ */
void evergreen_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib) void evergreen_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib)
{ {
struct radeon_ring *ring = &rdev->ring[ib->fence->ring]; struct radeon_ring *ring = &rdev->ring[ib->ring];
/* set to DX10/11 mode */ /* set to DX10/11 mode */
radeon_ring_write(ring, PACKET3(PACKET3_MODE_CONTROL, 0)); radeon_ring_write(ring, PACKET3(PACKET3_MODE_CONTROL, 0));
......
...@@ -850,7 +850,7 @@ void cayman_fence_ring_emit(struct radeon_device *rdev, ...@@ -850,7 +850,7 @@ void cayman_fence_ring_emit(struct radeon_device *rdev,
void cayman_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib) void cayman_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib)
{ {
struct radeon_ring *ring = &rdev->ring[ib->fence->ring]; struct radeon_ring *ring = &rdev->ring[ib->ring];
/* set to DX10/11 mode */ /* set to DX10/11 mode */
radeon_ring_write(ring, PACKET3(PACKET3_MODE_CONTROL, 0)); radeon_ring_write(ring, PACKET3(PACKET3_MODE_CONTROL, 0));
......
...@@ -883,7 +883,7 @@ int r100_copy_blit(struct radeon_device *rdev, ...@@ -883,7 +883,7 @@ int r100_copy_blit(struct radeon_device *rdev,
uint64_t src_offset, uint64_t src_offset,
uint64_t dst_offset, uint64_t dst_offset,
unsigned num_gpu_pages, unsigned num_gpu_pages,
struct radeon_fence *fence) struct radeon_fence **fence)
{ {
struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
uint32_t cur_pages; uint32_t cur_pages;
...@@ -947,7 +947,7 @@ int r100_copy_blit(struct radeon_device *rdev, ...@@ -947,7 +947,7 @@ int r100_copy_blit(struct radeon_device *rdev,
RADEON_WAIT_HOST_IDLECLEAN | RADEON_WAIT_HOST_IDLECLEAN |
RADEON_WAIT_DMA_GUI_IDLE); RADEON_WAIT_DMA_GUI_IDLE);
if (fence) { if (fence) {
r = radeon_fence_emit(rdev, fence); r = radeon_fence_emit(rdev, fence, RADEON_RING_TYPE_GFX_INDEX);
} }
radeon_ring_unlock_commit(rdev, ring); radeon_ring_unlock_commit(rdev, ring);
return r; return r;
......
...@@ -85,7 +85,7 @@ int r200_copy_dma(struct radeon_device *rdev, ...@@ -85,7 +85,7 @@ int r200_copy_dma(struct radeon_device *rdev,
uint64_t src_offset, uint64_t src_offset,
uint64_t dst_offset, uint64_t dst_offset,
unsigned num_gpu_pages, unsigned num_gpu_pages,
struct radeon_fence *fence) struct radeon_fence **fence)
{ {
struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
uint32_t size; uint32_t size;
...@@ -120,7 +120,7 @@ int r200_copy_dma(struct radeon_device *rdev, ...@@ -120,7 +120,7 @@ int r200_copy_dma(struct radeon_device *rdev,
radeon_ring_write(ring, PACKET0(RADEON_WAIT_UNTIL, 0)); radeon_ring_write(ring, PACKET0(RADEON_WAIT_UNTIL, 0));
radeon_ring_write(ring, RADEON_WAIT_DMA_GUI_IDLE); radeon_ring_write(ring, RADEON_WAIT_DMA_GUI_IDLE);
if (fence) { if (fence) {
r = radeon_fence_emit(rdev, fence); r = radeon_fence_emit(rdev, fence, RADEON_RING_TYPE_GFX_INDEX);
} }
radeon_ring_unlock_commit(rdev, ring); radeon_ring_unlock_commit(rdev, ring);
return r; return r;
......
...@@ -2309,7 +2309,7 @@ int r600_copy_blit(struct radeon_device *rdev, ...@@ -2309,7 +2309,7 @@ int r600_copy_blit(struct radeon_device *rdev,
uint64_t src_offset, uint64_t src_offset,
uint64_t dst_offset, uint64_t dst_offset,
unsigned num_gpu_pages, unsigned num_gpu_pages,
struct radeon_fence *fence) struct radeon_fence **fence)
{ {
struct radeon_sa_bo *vb = NULL; struct radeon_sa_bo *vb = NULL;
int r; int r;
...@@ -2607,7 +2607,7 @@ void r600_fini(struct radeon_device *rdev) ...@@ -2607,7 +2607,7 @@ void r600_fini(struct radeon_device *rdev)
*/ */
void r600_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib) void r600_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib)
{ {
struct radeon_ring *ring = &rdev->ring[ib->fence->ring]; struct radeon_ring *ring = &rdev->ring[ib->ring];
/* FIXME: implement */ /* FIXME: implement */
radeon_ring_write(ring, PACKET3(PACKET3_INDIRECT_BUFFER, 2)); radeon_ring_write(ring, PACKET3(PACKET3_INDIRECT_BUFFER, 2));
......
...@@ -703,20 +703,20 @@ int r600_blit_prepare_copy(struct radeon_device *rdev, unsigned num_gpu_pages, ...@@ -703,20 +703,20 @@ int r600_blit_prepare_copy(struct radeon_device *rdev, unsigned num_gpu_pages,
return 0; return 0;
} }
void r600_blit_done_copy(struct radeon_device *rdev, struct radeon_fence *fence, void r600_blit_done_copy(struct radeon_device *rdev, struct radeon_fence **fence,
struct radeon_sa_bo *vb) struct radeon_sa_bo *vb)
{ {
struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
int r; int r;
r = radeon_fence_emit(rdev, fence); r = radeon_fence_emit(rdev, fence, RADEON_RING_TYPE_GFX_INDEX);
if (r) { if (r) {
radeon_ring_unlock_undo(rdev, ring); radeon_ring_unlock_undo(rdev, ring);
return; return;
} }
radeon_ring_unlock_commit(rdev, ring); radeon_ring_unlock_commit(rdev, ring);
radeon_sa_bo_free(rdev, &vb, fence); radeon_sa_bo_free(rdev, &vb, *fence);
} }
void r600_kms_blit_copy(struct radeon_device *rdev, void r600_kms_blit_copy(struct radeon_device *rdev,
......
...@@ -113,7 +113,6 @@ extern int radeon_lockup_timeout; ...@@ -113,7 +113,6 @@ extern int radeon_lockup_timeout;
/* fence seq are set to this number when signaled */ /* fence seq are set to this number when signaled */
#define RADEON_FENCE_SIGNALED_SEQ 0LL #define RADEON_FENCE_SIGNALED_SEQ 0LL
#define RADEON_FENCE_NOTEMITED_SEQ (~0LL)
/* internal ring indices */ /* internal ring indices */
/* r1xx+ has gfx CP ring */ /* r1xx+ has gfx CP ring */
...@@ -277,8 +276,7 @@ struct radeon_fence { ...@@ -277,8 +276,7 @@ struct radeon_fence {
int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring); int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring);
int radeon_fence_driver_init(struct radeon_device *rdev); int radeon_fence_driver_init(struct radeon_device *rdev);
void radeon_fence_driver_fini(struct radeon_device *rdev); void radeon_fence_driver_fini(struct radeon_device *rdev);
int radeon_fence_create(struct radeon_device *rdev, struct radeon_fence **fence, int ring); int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence **fence, int ring);
int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence *fence);
void radeon_fence_process(struct radeon_device *rdev, int ring); void radeon_fence_process(struct radeon_device *rdev, int ring);
bool radeon_fence_signaled(struct radeon_fence *fence); bool radeon_fence_signaled(struct radeon_fence *fence);
int radeon_fence_wait(struct radeon_fence *fence, bool interruptible); int radeon_fence_wait(struct radeon_fence *fence, bool interruptible);
...@@ -630,6 +628,7 @@ struct radeon_ib { ...@@ -630,6 +628,7 @@ struct radeon_ib {
uint32_t length_dw; uint32_t length_dw;
uint64_t gpu_addr; uint64_t gpu_addr;
uint32_t *ptr; uint32_t *ptr;
int ring;
struct radeon_fence *fence; struct radeon_fence *fence;
unsigned vm_id; unsigned vm_id;
bool is_const_ib; bool is_const_ib;
...@@ -1192,20 +1191,20 @@ struct radeon_asic { ...@@ -1192,20 +1191,20 @@ struct radeon_asic {
uint64_t src_offset, uint64_t src_offset,
uint64_t dst_offset, uint64_t dst_offset,
unsigned num_gpu_pages, unsigned num_gpu_pages,
struct radeon_fence *fence); struct radeon_fence **fence);
u32 blit_ring_index; u32 blit_ring_index;
int (*dma)(struct radeon_device *rdev, int (*dma)(struct radeon_device *rdev,
uint64_t src_offset, uint64_t src_offset,
uint64_t dst_offset, uint64_t dst_offset,
unsigned num_gpu_pages, unsigned num_gpu_pages,
struct radeon_fence *fence); struct radeon_fence **fence);
u32 dma_ring_index; u32 dma_ring_index;
/* method used for bo copy */ /* method used for bo copy */
int (*copy)(struct radeon_device *rdev, int (*copy)(struct radeon_device *rdev,
uint64_t src_offset, uint64_t src_offset,
uint64_t dst_offset, uint64_t dst_offset,
unsigned num_gpu_pages, unsigned num_gpu_pages,
struct radeon_fence *fence); struct radeon_fence **fence);
/* ring used for bo copies */ /* ring used for bo copies */
u32 copy_ring_index; u32 copy_ring_index;
} copy; } copy;
......
...@@ -79,7 +79,7 @@ int r100_copy_blit(struct radeon_device *rdev, ...@@ -79,7 +79,7 @@ int r100_copy_blit(struct radeon_device *rdev,
uint64_t src_offset, uint64_t src_offset,
uint64_t dst_offset, uint64_t dst_offset,
unsigned num_gpu_pages, unsigned num_gpu_pages,
struct radeon_fence *fence); struct radeon_fence **fence);
int r100_set_surface_reg(struct radeon_device *rdev, int reg, int r100_set_surface_reg(struct radeon_device *rdev, int reg,
uint32_t tiling_flags, uint32_t pitch, uint32_t tiling_flags, uint32_t pitch,
uint32_t offset, uint32_t obj_size); uint32_t offset, uint32_t obj_size);
...@@ -144,7 +144,7 @@ extern int r200_copy_dma(struct radeon_device *rdev, ...@@ -144,7 +144,7 @@ extern int r200_copy_dma(struct radeon_device *rdev,
uint64_t src_offset, uint64_t src_offset,
uint64_t dst_offset, uint64_t dst_offset,
unsigned num_gpu_pages, unsigned num_gpu_pages,
struct radeon_fence *fence); struct radeon_fence **fence);
void r200_set_safe_registers(struct radeon_device *rdev); void r200_set_safe_registers(struct radeon_device *rdev);
/* /*
...@@ -318,7 +318,7 @@ void r600_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib); ...@@ -318,7 +318,7 @@ void r600_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib);
int r600_ring_test(struct radeon_device *rdev, struct radeon_ring *cp); int r600_ring_test(struct radeon_device *rdev, struct radeon_ring *cp);
int r600_copy_blit(struct radeon_device *rdev, int r600_copy_blit(struct radeon_device *rdev,
uint64_t src_offset, uint64_t dst_offset, uint64_t src_offset, uint64_t dst_offset,
unsigned num_gpu_pages, struct radeon_fence *fence); unsigned num_gpu_pages, struct radeon_fence **fence);
void r600_hpd_init(struct radeon_device *rdev); void r600_hpd_init(struct radeon_device *rdev);
void r600_hpd_fini(struct radeon_device *rdev); void r600_hpd_fini(struct radeon_device *rdev);
bool r600_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd); bool 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,7 +364,7 @@ void r600_hdmi_update_audio_settings(struct drm_encoder *encoder);
/* r600 blit */ /* r600 blit */
int r600_blit_prepare_copy(struct radeon_device *rdev, unsigned num_gpu_pages, int r600_blit_prepare_copy(struct radeon_device *rdev, unsigned num_gpu_pages,
struct radeon_sa_bo **vb); struct radeon_sa_bo **vb);
void r600_blit_done_copy(struct radeon_device *rdev, struct radeon_fence *fence, void r600_blit_done_copy(struct radeon_device *rdev, struct radeon_fence **fence,
struct radeon_sa_bo *vb); struct radeon_sa_bo *vb);
void r600_kms_blit_copy(struct radeon_device *rdev, void r600_kms_blit_copy(struct radeon_device *rdev,
u64 src_gpu_addr, u64 dst_gpu_addr, u64 src_gpu_addr, u64 dst_gpu_addr,
......
...@@ -45,20 +45,14 @@ static int radeon_benchmark_do_move(struct radeon_device *rdev, unsigned size, ...@@ -45,20 +45,14 @@ static int radeon_benchmark_do_move(struct radeon_device *rdev, unsigned size,
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
switch (flag) { switch (flag) {
case RADEON_BENCHMARK_COPY_DMA: case RADEON_BENCHMARK_COPY_DMA:
r = radeon_fence_create(rdev, &fence, radeon_copy_dma_ring_index(rdev));
if (r)
return r;
r = radeon_copy_dma(rdev, saddr, daddr, r = radeon_copy_dma(rdev, saddr, daddr,
size / RADEON_GPU_PAGE_SIZE, size / RADEON_GPU_PAGE_SIZE,
fence); &fence);
break; break;
case RADEON_BENCHMARK_COPY_BLIT: case RADEON_BENCHMARK_COPY_BLIT:
r = radeon_fence_create(rdev, &fence, radeon_copy_blit_ring_index(rdev));
if (r)
return r;
r = radeon_copy_blit(rdev, saddr, daddr, r = radeon_copy_blit(rdev, saddr, daddr,
size / RADEON_GPU_PAGE_SIZE, size / RADEON_GPU_PAGE_SIZE,
fence); &fence);
break; break;
default: default:
DRM_ERROR("Unknown copy method\n"); DRM_ERROR("Unknown copy method\n");
......
...@@ -61,15 +61,21 @@ static u32 radeon_fence_read(struct radeon_device *rdev, int ring) ...@@ -61,15 +61,21 @@ static u32 radeon_fence_read(struct radeon_device *rdev, int ring)
return seq; return seq;
} }
int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence *fence) int radeon_fence_emit(struct radeon_device *rdev,
struct radeon_fence **fence,
int ring)
{ {
/* we are protected by the ring emission mutex */ /* we are protected by the ring emission mutex */
if (fence->seq && fence->seq < RADEON_FENCE_NOTEMITED_SEQ) { *fence = kmalloc(sizeof(struct radeon_fence), GFP_KERNEL);
return 0; if ((*fence) == NULL) {
return -ENOMEM;
} }
fence->seq = ++rdev->fence_drv[fence->ring].seq; kref_init(&((*fence)->kref));
radeon_fence_ring_emit(rdev, fence->ring, fence); (*fence)->rdev = rdev;
trace_radeon_fence_emit(rdev->ddev, fence->seq); (*fence)->seq = ++rdev->fence_drv[ring].seq;
(*fence)->ring = ring;
radeon_fence_ring_emit(rdev, ring, *fence);
trace_radeon_fence_emit(rdev->ddev, (*fence)->seq);
return 0; return 0;
} }
...@@ -138,25 +144,9 @@ static void radeon_fence_destroy(struct kref *kref) ...@@ -138,25 +144,9 @@ static void radeon_fence_destroy(struct kref *kref)
struct radeon_fence *fence; struct radeon_fence *fence;
fence = container_of(kref, struct radeon_fence, kref); fence = container_of(kref, struct radeon_fence, kref);
fence->seq = RADEON_FENCE_NOTEMITED_SEQ;
kfree(fence); kfree(fence);
} }
int radeon_fence_create(struct radeon_device *rdev,
struct radeon_fence **fence,
int ring)
{
*fence = kmalloc(sizeof(struct radeon_fence), GFP_KERNEL);
if ((*fence) == NULL) {
return -ENOMEM;
}
kref_init(&((*fence)->kref));
(*fence)->rdev = rdev;
(*fence)->seq = RADEON_FENCE_NOTEMITED_SEQ;
(*fence)->ring = ring;
return 0;
}
static bool radeon_fence_seq_signaled(struct radeon_device *rdev, static bool radeon_fence_seq_signaled(struct radeon_device *rdev,
u64 seq, unsigned ring) u64 seq, unsigned ring)
{ {
...@@ -176,10 +166,6 @@ bool radeon_fence_signaled(struct radeon_fence *fence) ...@@ -176,10 +166,6 @@ bool radeon_fence_signaled(struct radeon_fence *fence)
if (!fence) { if (!fence) {
return true; return true;
} }
if (fence->seq == RADEON_FENCE_NOTEMITED_SEQ) {
WARN(1, "Querying an unemitted fence : %p !\n", fence);
return true;
}
if (fence->seq == RADEON_FENCE_SIGNALED_SEQ) { if (fence->seq == RADEON_FENCE_SIGNALED_SEQ) {
return true; return true;
} }
...@@ -444,9 +430,7 @@ int radeon_fence_wait_any(struct radeon_device *rdev, ...@@ -444,9 +430,7 @@ int radeon_fence_wait_any(struct radeon_device *rdev,
return 0; return 0;
} }
if (fences[i]->seq < RADEON_FENCE_NOTEMITED_SEQ) { seq[i] = fences[i]->seq;
seq[i] = fences[i]->seq;
}
} }
r = radeon_fence_wait_any_seq(rdev, seq, intr); r = radeon_fence_wait_any_seq(rdev, seq, intr);
......
...@@ -49,13 +49,9 @@ int radeon_ib_get(struct radeon_device *rdev, int ring, ...@@ -49,13 +49,9 @@ int radeon_ib_get(struct radeon_device *rdev, int ring,
dev_err(rdev->dev, "failed to get a new IB (%d)\n", r); dev_err(rdev->dev, "failed to get a new IB (%d)\n", r);
return r; return r;
} }
r = radeon_fence_create(rdev, &ib->fence, ring);
if (r) {
dev_err(rdev->dev, "failed to create fence for new IB (%d)\n", r);
radeon_sa_bo_free(rdev, &ib->sa_bo, NULL);
return r;
}
ib->ring = ring;
ib->fence = NULL;
ib->ptr = radeon_sa_bo_cpu_addr(ib->sa_bo); ib->ptr = radeon_sa_bo_cpu_addr(ib->sa_bo);
ib->gpu_addr = radeon_sa_bo_gpu_addr(ib->sa_bo); ib->gpu_addr = radeon_sa_bo_gpu_addr(ib->sa_bo);
ib->vm_id = 0; ib->vm_id = 0;
...@@ -74,7 +70,7 @@ void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib *ib) ...@@ -74,7 +70,7 @@ void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib *ib)
int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib) int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib)
{ {
struct radeon_ring *ring = &rdev->ring[ib->fence->ring]; struct radeon_ring *ring = &rdev->ring[ib->ring];
int r = 0; int r = 0;
if (!ib->length_dw || !ring->ready) { if (!ib->length_dw || !ring->ready) {
...@@ -89,8 +85,13 @@ int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib) ...@@ -89,8 +85,13 @@ int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib)
dev_err(rdev->dev, "scheduling IB failed (%d).\n", r); dev_err(rdev->dev, "scheduling IB failed (%d).\n", r);
return r; return r;
} }
radeon_ring_ib_execute(rdev, ib->fence->ring, ib); radeon_ring_ib_execute(rdev, ib->ring, ib);
radeon_fence_emit(rdev, ib->fence); r = radeon_fence_emit(rdev, &ib->fence, ib->ring);
if (r) {
dev_err(rdev->dev, "failed to emit fence for new IB (%d)\n", r);
radeon_ring_unlock_undo(rdev, ring);
return r;
}
radeon_ring_unlock_commit(rdev, ring); radeon_ring_unlock_commit(rdev, ring);
return 0; return 0;
} }
......
...@@ -349,7 +349,7 @@ void radeon_sa_bo_free(struct radeon_device *rdev, struct radeon_sa_bo **sa_bo, ...@@ -349,7 +349,7 @@ void radeon_sa_bo_free(struct radeon_device *rdev, struct radeon_sa_bo **sa_bo,
sa_manager = (*sa_bo)->manager; sa_manager = (*sa_bo)->manager;
spin_lock(&sa_manager->lock); spin_lock(&sa_manager->lock);
if (fence && fence->seq && fence->seq < RADEON_FENCE_NOTEMITED_SEQ) { if (fence && !radeon_fence_signaled(fence)) {
(*sa_bo)->fence = radeon_fence_ref(fence); (*sa_bo)->fence = radeon_fence_ref(fence);
list_add_tail(&(*sa_bo)->flist, list_add_tail(&(*sa_bo)->flist,
&sa_manager->flist[fence->ring]); &sa_manager->flist[fence->ring]);
......
...@@ -106,13 +106,7 @@ void radeon_test_moves(struct radeon_device *rdev) ...@@ -106,13 +106,7 @@ void radeon_test_moves(struct radeon_device *rdev)
radeon_bo_kunmap(gtt_obj[i]); radeon_bo_kunmap(gtt_obj[i]);
r = radeon_fence_create(rdev, &fence, RADEON_RING_TYPE_GFX_INDEX); r = radeon_copy(rdev, gtt_addr, vram_addr, size / RADEON_GPU_PAGE_SIZE, &fence);
if (r) {
DRM_ERROR("Failed to create GTT->VRAM fence %d\n", i);
goto out_cleanup;
}
r = radeon_copy(rdev, gtt_addr, vram_addr, size / RADEON_GPU_PAGE_SIZE, fence);
if (r) { if (r) {
DRM_ERROR("Failed GTT->VRAM copy %d\n", i); DRM_ERROR("Failed GTT->VRAM copy %d\n", i);
goto out_cleanup; goto out_cleanup;
...@@ -155,13 +149,7 @@ void radeon_test_moves(struct radeon_device *rdev) ...@@ -155,13 +149,7 @@ void radeon_test_moves(struct radeon_device *rdev)
radeon_bo_kunmap(vram_obj); radeon_bo_kunmap(vram_obj);
r = radeon_fence_create(rdev, &fence, RADEON_RING_TYPE_GFX_INDEX); r = radeon_copy(rdev, vram_addr, gtt_addr, size / RADEON_GPU_PAGE_SIZE, &fence);
if (r) {
DRM_ERROR("Failed to create VRAM->GTT fence %d\n", i);
goto out_cleanup;
}
r = radeon_copy(rdev, vram_addr, gtt_addr, size / RADEON_GPU_PAGE_SIZE, fence);
if (r) { if (r) {
DRM_ERROR("Failed VRAM->GTT copy %d\n", i); DRM_ERROR("Failed VRAM->GTT copy %d\n", i);
goto out_cleanup; goto out_cleanup;
...@@ -245,17 +233,6 @@ void radeon_test_ring_sync(struct radeon_device *rdev, ...@@ -245,17 +233,6 @@ void radeon_test_ring_sync(struct radeon_device *rdev,
int ridxB = radeon_ring_index(rdev, ringB); int ridxB = radeon_ring_index(rdev, ringB);
int r; int r;
r = radeon_fence_create(rdev, &fence1, ridxA);
if (r) {
DRM_ERROR("Failed to create sync fence 1\n");
goto out_cleanup;
}
r = radeon_fence_create(rdev, &fence2, ridxA);
if (r) {
DRM_ERROR("Failed to create sync fence 2\n");
goto out_cleanup;
}
r = radeon_semaphore_create(rdev, &semaphore); r = radeon_semaphore_create(rdev, &semaphore);
if (r) { if (r) {
DRM_ERROR("Failed to create semaphore\n"); DRM_ERROR("Failed to create semaphore\n");
...@@ -268,9 +245,19 @@ void radeon_test_ring_sync(struct radeon_device *rdev, ...@@ -268,9 +245,19 @@ void radeon_test_ring_sync(struct radeon_device *rdev,
goto out_cleanup; goto out_cleanup;
} }
radeon_semaphore_emit_wait(rdev, ridxA, semaphore); radeon_semaphore_emit_wait(rdev, ridxA, semaphore);
radeon_fence_emit(rdev, fence1); r = radeon_fence_emit(rdev, &fence1, ridxA);
if (r) {
DRM_ERROR("Failed to emit fence 1\n");
radeon_ring_unlock_undo(rdev, ringA);
goto out_cleanup;
}
radeon_semaphore_emit_wait(rdev, ridxA, semaphore); radeon_semaphore_emit_wait(rdev, ridxA, semaphore);
radeon_fence_emit(rdev, fence2); r = radeon_fence_emit(rdev, &fence2, ridxA);
if (r) {
DRM_ERROR("Failed to emit fence 2\n");
radeon_ring_unlock_undo(rdev, ringA);
goto out_cleanup;
}
radeon_ring_unlock_commit(rdev, ringA); radeon_ring_unlock_commit(rdev, ringA);
mdelay(1000); mdelay(1000);
...@@ -342,17 +329,6 @@ void radeon_test_ring_sync2(struct radeon_device *rdev, ...@@ -342,17 +329,6 @@ void radeon_test_ring_sync2(struct radeon_device *rdev,
bool sigA, sigB; bool sigA, sigB;
int i, r; int i, r;
r = radeon_fence_create(rdev, &fenceA, ridxA);
if (r) {
DRM_ERROR("Failed to create sync fence 1\n");
goto out_cleanup;
}
r = radeon_fence_create(rdev, &fenceB, ridxB);
if (r) {
DRM_ERROR("Failed to create sync fence 2\n");
goto out_cleanup;
}
r = radeon_semaphore_create(rdev, &semaphore); r = radeon_semaphore_create(rdev, &semaphore);
if (r) { if (r) {
DRM_ERROR("Failed to create semaphore\n"); DRM_ERROR("Failed to create semaphore\n");
...@@ -365,7 +341,12 @@ void radeon_test_ring_sync2(struct radeon_device *rdev, ...@@ -365,7 +341,12 @@ void radeon_test_ring_sync2(struct radeon_device *rdev,
goto out_cleanup; goto out_cleanup;
} }
radeon_semaphore_emit_wait(rdev, ridxA, semaphore); radeon_semaphore_emit_wait(rdev, ridxA, semaphore);
radeon_fence_emit(rdev, fenceA); r = radeon_fence_emit(rdev, &fenceA, ridxA);
if (r) {
DRM_ERROR("Failed to emit sync fence 1\n");
radeon_ring_unlock_undo(rdev, ringA);
goto out_cleanup;
}
radeon_ring_unlock_commit(rdev, ringA); radeon_ring_unlock_commit(rdev, ringA);
r = radeon_ring_lock(rdev, ringB, 64); r = radeon_ring_lock(rdev, ringB, 64);
...@@ -374,7 +355,12 @@ void radeon_test_ring_sync2(struct radeon_device *rdev, ...@@ -374,7 +355,12 @@ void radeon_test_ring_sync2(struct radeon_device *rdev,
goto out_cleanup; goto out_cleanup;
} }
radeon_semaphore_emit_wait(rdev, ridxB, semaphore); radeon_semaphore_emit_wait(rdev, ridxB, semaphore);
radeon_fence_emit(rdev, fenceB); r = radeon_fence_emit(rdev, &fenceB, ridxB);
if (r) {
DRM_ERROR("Failed to create sync fence 2\n");
radeon_ring_unlock_undo(rdev, ringB);
goto out_cleanup;
}
radeon_ring_unlock_commit(rdev, ringB); radeon_ring_unlock_commit(rdev, ringB);
mdelay(1000); mdelay(1000);
......
...@@ -222,15 +222,12 @@ static int radeon_move_blit(struct ttm_buffer_object *bo, ...@@ -222,15 +222,12 @@ static int radeon_move_blit(struct ttm_buffer_object *bo,
{ {
struct radeon_device *rdev; struct radeon_device *rdev;
uint64_t old_start, new_start; uint64_t old_start, new_start;
struct radeon_fence *fence, *old_fence; struct radeon_fence *fence;
struct radeon_semaphore *sem = NULL; struct radeon_semaphore *sem = NULL;
int r; int r, ridx;
rdev = radeon_get_rdev(bo->bdev); rdev = radeon_get_rdev(bo->bdev);
r = radeon_fence_create(rdev, &fence, radeon_copy_ring_index(rdev)); ridx = radeon_copy_ring_index(rdev);
if (unlikely(r)) {
return r;
}
old_start = old_mem->start << PAGE_SHIFT; old_start = old_mem->start << PAGE_SHIFT;
new_start = new_mem->start << PAGE_SHIFT; new_start = new_mem->start << PAGE_SHIFT;
...@@ -243,7 +240,6 @@ static int radeon_move_blit(struct ttm_buffer_object *bo, ...@@ -243,7 +240,6 @@ static int radeon_move_blit(struct ttm_buffer_object *bo,
break; break;
default: default:
DRM_ERROR("Unknown placement %d\n", old_mem->mem_type); DRM_ERROR("Unknown placement %d\n", old_mem->mem_type);
radeon_fence_unref(&fence);
return -EINVAL; return -EINVAL;
} }
switch (new_mem->mem_type) { switch (new_mem->mem_type) {
...@@ -255,42 +251,38 @@ static int radeon_move_blit(struct ttm_buffer_object *bo, ...@@ -255,42 +251,38 @@ static int radeon_move_blit(struct ttm_buffer_object *bo,
break; break;
default: default:
DRM_ERROR("Unknown placement %d\n", old_mem->mem_type); DRM_ERROR("Unknown placement %d\n", old_mem->mem_type);
radeon_fence_unref(&fence);
return -EINVAL; return -EINVAL;
} }
if (!rdev->ring[radeon_copy_ring_index(rdev)].ready) { if (!rdev->ring[ridx].ready) {
DRM_ERROR("Trying to move memory with ring turned off.\n"); DRM_ERROR("Trying to move memory with ring turned off.\n");
radeon_fence_unref(&fence);
return -EINVAL; return -EINVAL;
} }
BUILD_BUG_ON((PAGE_SIZE % RADEON_GPU_PAGE_SIZE) != 0); BUILD_BUG_ON((PAGE_SIZE % RADEON_GPU_PAGE_SIZE) != 0);
/* sync other rings */ /* sync other rings */
old_fence = bo->sync_obj; fence = bo->sync_obj;
if (old_fence && old_fence->ring != fence->ring if (fence && fence->ring != ridx
&& !radeon_fence_signaled(old_fence)) { && !radeon_fence_signaled(fence)) {
bool sync_to_ring[RADEON_NUM_RINGS] = { }; bool sync_to_ring[RADEON_NUM_RINGS] = { };
sync_to_ring[old_fence->ring] = true; sync_to_ring[fence->ring] = true;
r = radeon_semaphore_create(rdev, &sem); r = radeon_semaphore_create(rdev, &sem);
if (r) { if (r) {
radeon_fence_unref(&fence);
return r; return r;
} }
r = radeon_semaphore_sync_rings(rdev, sem, r = radeon_semaphore_sync_rings(rdev, sem, sync_to_ring, ridx);
sync_to_ring, fence->ring);
if (r) { if (r) {
radeon_semaphore_free(rdev, sem, NULL); radeon_semaphore_free(rdev, sem, NULL);
radeon_fence_unref(&fence);
return r; return r;
} }
} }
fence = NULL;
r = radeon_copy(rdev, old_start, new_start, r = radeon_copy(rdev, old_start, new_start,
new_mem->num_pages * (PAGE_SIZE / RADEON_GPU_PAGE_SIZE), /* GPU pages */ new_mem->num_pages * (PAGE_SIZE / RADEON_GPU_PAGE_SIZE), /* GPU pages */
fence); &fence);
/* FIXME: handle copy error */ /* FIXME: handle copy error */
r = ttm_bo_move_accel_cleanup(bo, (void *)fence, NULL, r = ttm_bo_move_accel_cleanup(bo, (void *)fence, NULL,
evict, no_wait_reserve, no_wait_gpu, new_mem); evict, no_wait_reserve, no_wait_gpu, new_mem);
......
...@@ -1762,7 +1762,7 @@ void si_fence_ring_emit(struct radeon_device *rdev, ...@@ -1762,7 +1762,7 @@ void si_fence_ring_emit(struct radeon_device *rdev,
*/ */
void si_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib) void si_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib)
{ {
struct radeon_ring *ring = &rdev->ring[ib->fence->ring]; struct radeon_ring *ring = &rdev->ring[ib->ring];
u32 header; u32 header;
if (ib->is_const_ib) if (ib->is_const_ib)
...@@ -2702,7 +2702,7 @@ int si_ib_parse(struct radeon_device *rdev, struct radeon_ib *ib) ...@@ -2702,7 +2702,7 @@ int si_ib_parse(struct radeon_device *rdev, struct radeon_ib *ib)
if (ib->is_const_ib) if (ib->is_const_ib)
ret = si_vm_packet3_ce_check(rdev, ib->ptr, &pkt); ret = si_vm_packet3_ce_check(rdev, ib->ptr, &pkt);
else { else {
switch (ib->fence->ring) { switch (ib->ring) {
case RADEON_RING_TYPE_GFX_INDEX: case RADEON_RING_TYPE_GFX_INDEX:
ret = si_vm_packet3_gfx_check(rdev, ib->ptr, &pkt); ret = si_vm_packet3_gfx_check(rdev, ib->ptr, &pkt);
break; break;
...@@ -2711,7 +2711,7 @@ int si_ib_parse(struct radeon_device *rdev, struct radeon_ib *ib) ...@@ -2711,7 +2711,7 @@ int si_ib_parse(struct radeon_device *rdev, struct radeon_ib *ib)
ret = si_vm_packet3_compute_check(rdev, ib->ptr, &pkt); ret = si_vm_packet3_compute_check(rdev, ib->ptr, &pkt);
break; break;
default: default:
dev_err(rdev->dev, "Non-PM4 ring %d !\n", ib->fence->ring); dev_err(rdev->dev, "Non-PM4 ring %d !\n", ib->ring);
ret = -EINVAL; ret = -EINVAL;
break; break;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册