drm/ttm: allow fence to be added as shared
Subsystems (6)
PATCH 1/3 drm/ttm: allow fence to be added as shared
From: Christian König <[email protected]>
This patch adds a new flag to the ttm_validate_buffer list to add the fence as shared to the reservation object.
--- drivers/gpu/drm/qxl/qxl_release.c | 1 + drivers/gpu/drm/radeon/radeon_cs.c | 1 + drivers/gpu/drm/radeon/radeon_vm.c | 3 +++ drivers/gpu/drm/ttm/ttm_execbuf_util.c | 18 +++++++++++++++--- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 3 +++ drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 5 +++++ include/drm/ttm/ttm_execbuf_util.h | 2 ++ 7 files changed, 30 insertions(+), 3 deletions(-)
drivers/gpu/drm/qxl/qxl_release.c +1 -0
@@ -226,6 +226,7 @@ int qxl_release_list_add(struct qxl_release *release, struct qxl_bo *bo)qxl_bo_ref (bo); entry->tv.bo = &bo->tbo; + entry->tv.shared = false;list_add_tail (&entry->tv.head, &release->bos);return 0 ; }
drivers/gpu/drm/radeon/radeon_cs.c +1 -0
@@ -183,6 +183,7 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p) } p->relocs[i].tv.bo = &p->relocs[i].robj->tbo; + p->relocs[i].tv.shared = false; p->relocs[i].handle = r->handle; radeon_cs_buckets_add(&buckets, &p->relocs[i].tv.head,
drivers/gpu/drm/radeon/radeon_vm.c +3 -0
@@ -143,6 +143,7 @@ struct radeon_cs_reloc *radeon_vm_get_bos(struct radeon_device *rdev, list[0 ].prefered_domains =RADEON_GEM_DOMAIN_VRAM ; list[0 ].allowed_domains =RADEON_GEM_DOMAIN_VRAM ; list[0 ].tv.bo = &vm->page_directory->tbo; + list[0 ].tv.shared = false; list[0 ].tiling_flags =0 ; list[0 ].handle =0 ;list_add (&list[0 ].tv.head, head);
@@ -156,6 +157,7 @@ struct radeon_cs_reloc *radeon_vm_get_bos(struct radeon_device *rdev, list[idx].prefered_domains =RADEON_GEM_DOMAIN_VRAM ; list[idx].allowed_domains =RADEON_GEM_DOMAIN_VRAM ; list[idx].tv.bo = &list[idx].robj->tbo; + list[idx].tv.shared = false; list[idx].tiling_flags =0 ; list[idx].handle =0 ;list_add (&list[idx++].tv.head, head);
@@ -395,6 +397,7 @@ static int radeon_vm_clear_bo(struct radeon_device *rdev,memset (&tv,0 ,sizeof (tv)); tv.bo = &bo->tbo; + tv.shared = false;INIT_LIST_HEAD (&head);list_add (&tv.head, &head);
drivers/gpu/drm/ttm/ttm_execbuf_util.c +15 -3
@@ -119,8 +119,14 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket, ret = -EBUSY ; } -if (!ret) -continue ; +if (!ret) { +if (!entry->shared) +continue ; + + ret =reservation_object_reserve_shared (bo->resv); +if (!ret) +continue ; + }/* uh oh, we lost out, drop every reservation and try * to only reserve this buffer, then start over if
@@ -136,6 +142,9 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket, ret =0 ; } +if (!ret && entry->shared) + ret =reservation_object_reserve_shared (bo->resv); +if (unlikely (ret !=0 )) {if (ret == -EINTR ) ret = -ERESTARTSYS ;
@@ -183,7 +192,10 @@ void ttm_eu_fence_buffer_objects(struct ww_acquire_ctx *ticket,list_for_each_entry (entry, list, head) { bo = entry->bo; -reservation_object_add_excl_fence (bo->resv, fence); +if (entry->shared) +reservation_object_add_shared_fence (bo->resv, fence); +else +reservation_object_add_excl_fence (bo->resv, fence);ttm_bo_add_to_lru (bo);__ttm_bo_unreserve (bo); }
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +3 -0
@@ -346,6 +346,7 @@ static int vmw_bo_to_validate_list(struct vmw_sw_context *sw_context, ++sw_context->cur_val_buf; val_buf = &vval_buf->base; val_buf->bo =ttm_bo_reference (bo); + val_buf->shared = false;list_add_tail (&val_buf->head, &sw_context->validate_nodes); vval_buf->validate_as_mob = validate_as_mob; }
@@ -2670,9 +2671,11 @@ void __vmw_execbuf_release_pinned_bo(struct vmw_private *dev_priv,INIT_LIST_HEAD (&validate_list); pinned_val.bo =ttm_bo_reference (dev_priv->pinned_bo); + pinned_val.shared = false;list_add_tail (&pinned_val.head, &validate_list); query_val.bo =ttm_bo_reference (dev_priv->dummy_query_bo); + query_val.shared = false;list_add_tail (&query_val.head, &validate_list); ret =ttm_eu_reserve_buffers (&ticket, &validate_list, false);
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +5 -0
@@ -133,6 +133,7 @@ static void vmw_resource_release(struct kref *kref)struct ttm_validate_buffer val_buf; val_buf.bo = bo; + val_buf.shared = false; res->func->unbind (res, false, &val_buf); } res->backup_dirty = false;
@@ -1219,6 +1220,7 @@ vmw_resource_check_buffer(struct vmw_resource *res,INIT_LIST_HEAD (&val_list); val_buf->bo =ttm_bo_reference (&res->backup->base); + val_buf->shared = false;list_add_tail (&val_buf->head, &val_list); ret =ttm_eu_reserve_buffers (NULL , &val_list, interruptible);if (unlikely (ret !=0 ))
@@ -1312,6 +1314,7 @@ int vmw_resource_do_evict(struct vmw_resource *res, bool interruptible)BUG_ON (!func->may_evict); val_buf.bo =NULL ; + val_buf.shared = false; ret =vmw_resource_check_buffer (res, interruptible, &val_buf);if (unlikely (ret !=0 ))return ret;
@@ -1357,6 +1360,7 @@ int vmw_resource_validate(struct vmw_resource *res)return 0 ; val_buf.bo =NULL ; + val_buf.shared = false;if (res->backup) val_buf.bo = &res->backup->base; do {
@@ -1474,6 +1478,7 @@ void vmw_resource_move_notify(struct ttm_buffer_object *bo,struct ttm_validate_buffer val_buf; val_buf.bo = bo; + val_buf.shared = false;list_for_each_entry_safe (res, n, &dma_buf->res_list, mob_head) {
include/drm/ttm/ttm_execbuf_util.h +2 -0
@@ -39,11 +39,13 @@* * @head: list head for thread-private list. * @bo: refcounted buffer object pointer. +* @shared: should the fence be added shared? */ struct ttm_validate_buffer {struct list_head head;struct ttm_buffer_object *bo; +bool shared; };/**
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/3 drm/radeon: add the infrastructure for concurrent buffer access
From: Christian König <[email protected]>
This allows us to specify if we want to sync to
the shared fences of a reservation object or not.
--- drivers/gpu/drm/radeon/cik.c | 25 ++++++----- drivers/gpu/drm/radeon/cik_sdma.c | 25 ++++++----- drivers/gpu/drm/radeon/evergreen_dma.c | 24 +++++----- drivers/gpu/drm/radeon/r100.c | 21 +++++---- drivers/gpu/drm/radeon/r200.c | 21 +++++---- drivers/gpu/drm/radeon/r600.c | 23 +++++----- drivers/gpu/drm/radeon/r600_dma.c | 25 ++++++----- drivers/gpu/drm/radeon/radeon.h | 43 +++++++++--------- drivers/gpu/drm/radeon/radeon_asic.h | 74 ++++++++++++++++--------------- drivers/gpu/drm/radeon/radeon_benchmark.c | 30 ++++++------- drivers/gpu/drm/radeon/radeon_cs.c | 8 +--- drivers/gpu/drm/radeon/radeon_ib.c | 2 +- drivers/gpu/drm/radeon/radeon_semaphore.c | 38 ++++++++++++++-- drivers/gpu/drm/radeon/radeon_test.c | 24 +++++++--- drivers/gpu/drm/radeon/radeon_ttm.c | 12 ++--- drivers/gpu/drm/radeon/radeon_vm.c | 16 ++----- drivers/gpu/drm/radeon/rv770_dma.c | 25 ++++++----- drivers/gpu/drm/radeon/si_dma.c | 25 ++++++----- 18 files changed, 253 insertions(+), 208 deletions(-)
drivers/gpu/drm/radeon/cik.c +13 -12
@@ -3959,18 +3959,19 @@ bool cik_semaphore_ring_emit(struct radeon_device *rdev,* @src_offset: src GPU address * @dst_offset: dst GPU address * @num_gpu_pages: number of GPU pages to xfer -* @fence: radeon fence object +* @resv: reservation object to sync to * * Copy GPU paging using the CP DMA engine (CIK+). * Used by the radeon ttm implementation to move pages if * registered as the asic copy callback. */ -int cik_copy_cpdma (struct radeon_device *rdev, -uint64_t src_offset,uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence) +struct radeon_fence *cik_copy_cpdma (struct radeon_device *rdev, +uint64_t src_offset,uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv) {struct radeon_semaphore *sem =NULL ; +struct radeon_fence *fence;int ring_index = rdev->asic->copy.blit_ring_index;struct radeon_ring *ring = &rdev->ring[ring_index];u32 size_in_bytes, cur_size_in_bytes, control;
@@ -3980,7 +3981,7 @@ int cik_copy_cpdma(struct radeon_device *rdev, r =radeon_semaphore_create (rdev, &sem);if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r); -return r; +return ERR_PTR (r); } size_in_bytes = (num_gpu_pages <<RADEON_GPU_PAGE_SHIFT );
@@ -3989,10 +3990,10 @@ int cik_copy_cpdma(struct radeon_device *rdev,if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); } -radeon_semaphore_sync_to (sem, *fence); +radeon_semaphore_sync_resv (sem, resv, false);radeon_semaphore_sync_rings (rdev, sem, ring->idx);for (i =0 ; i < num_loops; i++) {
@@ -4014,17 +4015,17 @@ int cik_copy_cpdma(struct radeon_device *rdev, dst_offset += cur_size_in_bytes; } - r =radeon_fence_emit (rdev, fence, ring->idx); + r =radeon_fence_emit (rdev, &fence, ring->idx);if (r) {radeon_ring_unlock_undo (rdev, ring);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); }radeon_ring_unlock_commit (rdev, ring, false); -radeon_semaphore_free (rdev, &sem, *fence); +radeon_semaphore_free (rdev, &sem, fence); -return r; +return fence; }/*
drivers/gpu/drm/radeon/cik_sdma.c +13 -12
@@ -537,18 +537,19 @@ void cik_sdma_fini(struct radeon_device *rdev)* @src_offset: src GPU address * @dst_offset: dst GPU address * @num_gpu_pages: number of GPU pages to xfer -* @fence: radeon fence object +* @resv: reservation object to sync to * * Copy GPU paging using the DMA engine (CIK). * Used by the radeon ttm implementation to move pages if * registered as the asic copy callback. */ -int cik_copy_dma (struct radeon_device *rdev, -uint64_t src_offset,uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence) +struct radeon_fence *cik_copy_dma (struct radeon_device *rdev, +uint64_t src_offset,uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv) {struct radeon_semaphore *sem =NULL ; +struct radeon_fence *fence;int ring_index = rdev->asic->copy.dma_ring_index;struct radeon_ring *ring = &rdev->ring[ring_index];u32 size_in_bytes, cur_size_in_bytes;
@@ -558,7 +559,7 @@ int cik_copy_dma(struct radeon_device *rdev, r =radeon_semaphore_create (rdev, &sem);if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r); -return r; +return ERR_PTR (r); } size_in_bytes = (num_gpu_pages <<RADEON_GPU_PAGE_SHIFT );
@@ -567,10 +568,10 @@ int cik_copy_dma(struct radeon_device *rdev,if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); } -radeon_semaphore_sync_to (sem, *fence); +radeon_semaphore_sync_resv (sem, resv, false);radeon_semaphore_sync_rings (rdev, sem, ring->idx);for (i =0 ; i < num_loops; i++) {
@@ -589,17 +590,17 @@ int cik_copy_dma(struct radeon_device *rdev, dst_offset += cur_size_in_bytes; } - r =radeon_fence_emit (rdev, fence, ring->idx); + r =radeon_fence_emit (rdev, &fence, ring->idx);if (r) {radeon_ring_unlock_undo (rdev, ring);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); }radeon_ring_unlock_commit (rdev, ring, false); -radeon_semaphore_free (rdev, &sem, *fence); +radeon_semaphore_free (rdev, &sem, fence); -return r; +return fence; }/**
drivers/gpu/drm/radeon/evergreen_dma.c +13 -11
@@ -104,12 +104,14 @@ void evergreen_dma_ring_ib_execute(struct radeon_device *rdev,* Used by the radeon ttm implementation to move pages if * registered as the asic copy callback. */ -int evergreen_copy_dma (struct radeon_device *rdev, -uint64_t src_offset,uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence) +struct radeon_fence *evergreen_copy_dma (struct radeon_device *rdev, +uint64_t src_offset, +uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv) {struct radeon_semaphore *sem =NULL ; +struct radeon_fence *fence;int ring_index = rdev->asic->copy.dma_ring_index;struct radeon_ring *ring = &rdev->ring[ring_index];u32 size_in_dw, cur_size_in_dw;
@@ -119,7 +121,7 @@ int evergreen_copy_dma(struct radeon_device *rdev, r =radeon_semaphore_create (rdev, &sem);if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r); -return r; +return ERR_PTR (r); } size_in_dw = (num_gpu_pages <<RADEON_GPU_PAGE_SHIFT ) /4 ;
@@ -128,10 +130,10 @@ int evergreen_copy_dma(struct radeon_device *rdev,if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); } -radeon_semaphore_sync_to (sem, *fence); +radeon_semaphore_sync_resv (sem, resv, false);radeon_semaphore_sync_rings (rdev, sem, ring->idx);for (i =0 ; i < num_loops; i++) {
@@ -148,17 +150,17 @@ int evergreen_copy_dma(struct radeon_device *rdev, dst_offset += cur_size_in_dw *4 ; } - r =radeon_fence_emit (rdev, fence, ring->idx); + r =radeon_fence_emit (rdev, &fence, ring->idx);if (r) {radeon_ring_unlock_undo (rdev, ring);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); }radeon_ring_unlock_commit (rdev, ring, false); -radeon_semaphore_free (rdev, &sem, *fence); +radeon_semaphore_free (rdev, &sem, fence); -return r; +return fence; }/**
drivers/gpu/drm/radeon/r100.c +12 -9
@@ -855,13 +855,14 @@ bool r100_semaphore_ring_emit(struct radeon_device *rdev,return false; } -int r100_copy_blit (struct radeon_device *rdev, -uint64_t src_offset, -uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence) +struct radeon_fence *r100_copy_blit (struct radeon_device *rdev, +uint64_t src_offset, +uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv) {struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX ]; +struct radeon_fence *fence;uint32_t cur_pages;uint32_t stride_bytes =RADEON_GPU_PAGE_SIZE ;uint32_t pitch;
@@ -882,7 +883,7 @@ int r100_copy_blit(struct radeon_device *rdev, r =radeon_ring_lock (rdev, ring, ndw);if (r) {DRM_ERROR ("radeon: moving bo (%d) asking for %u dw.\n" , r, ndw); -return -EINVAL ; +return ERR_PTR (-EINVAL ); }while (num_gpu_pages >0 ) { cur_pages = num_gpu_pages;
@@ -922,11 +923,13 @@ int r100_copy_blit(struct radeon_device *rdev,RADEON_WAIT_2D_IDLECLEAN |RADEON_WAIT_HOST_IDLECLEAN | RADEON_WAIT_DMA_GUI_IDLE); -if (fence) { - r =radeon_fence_emit (rdev, fence,RADEON_RING_TYPE_GFX_INDEX ); + r =radeon_fence_emit (rdev, &fence,RADEON_RING_TYPE_GFX_INDEX ); +if (r) { +radeon_ring_unlock_undo (rdev, ring); +return ERR_PTR (r); }radeon_ring_unlock_commit (rdev, ring, false); -return r; +return fence; }static int r100_cp_wait_for_idle (struct radeon_device *rdev)
drivers/gpu/drm/radeon/r200.c +12 -9
@@ -80,13 +80,14 @@ static int r200_get_vtx_size_0(uint32_t vtx_fmt_0)return vtx_size; } -int r200_copy_dma (struct radeon_device *rdev, -uint64_t src_offset, -uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence) +struct radeon_fence *r200_copy_dma (struct radeon_device *rdev, +uint64_t src_offset, +uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv) {struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX ]; +struct radeon_fence *fence;uint32_t size;uint32_t cur_size;int i, num_loops;
@@ -98,7 +99,7 @@ int r200_copy_dma(struct radeon_device *rdev, r =radeon_ring_lock (rdev, ring, num_loops *4 +64 );if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r); -return r; +return ERR_PTR (r); }/* Must wait for 2D idle & clean before DMA or hangs might happen */ radeon_ring_write (ring,PACKET0 (RADEON_WAIT_UNTIL ,0 ));
@@ -118,11 +119,13 @@ int r200_copy_dma(struct radeon_device *rdev, }radeon_ring_write (ring,PACKET0 (RADEON_WAIT_UNTIL ,0 ));radeon_ring_write (ring,RADEON_WAIT_DMA_GUI_IDLE ); -if (fence) { - r =radeon_fence_emit (rdev, fence,RADEON_RING_TYPE_GFX_INDEX ); + r =radeon_fence_emit (rdev, &fence,RADEON_RING_TYPE_GFX_INDEX ); +if (r) { +radeon_ring_unlock_undo (rdev, ring); +return ERR_PTR (r); }radeon_ring_unlock_commit (rdev, ring, false); -return r; +return fence; }
drivers/gpu/drm/radeon/r600.c +12 -11
@@ -2894,12 +2894,13 @@ bool r600_semaphore_ring_emit(struct radeon_device *rdev,* Used by the radeon ttm implementation to move pages if * registered as the asic copy callback. */ -int r600_copy_cpdma (struct radeon_device *rdev, -uint64_t src_offset,uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence) +struct radeon_fence *r600_copy_cpdma (struct radeon_device *rdev, +uint64_t src_offset,uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv) {struct radeon_semaphore *sem =NULL ; +struct radeon_fence *fence;int ring_index = rdev->asic->copy.blit_ring_index;struct radeon_ring *ring = &rdev->ring[ring_index];u32 size_in_bytes, cur_size_in_bytes, tmp;
@@ -2909,7 +2910,7 @@ int r600_copy_cpdma(struct radeon_device *rdev, r =radeon_semaphore_create (rdev, &sem);if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r); -return r; +return ERR_PTR (r); } size_in_bytes = (num_gpu_pages <<RADEON_GPU_PAGE_SHIFT );
@@ -2918,10 +2919,10 @@ int r600_copy_cpdma(struct radeon_device *rdev,if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); } -radeon_semaphore_sync_to (sem, *fence); +radeon_semaphore_sync_resv (sem, resv, false);radeon_semaphore_sync_rings (rdev, sem, ring->idx);radeon_ring_write (ring,PACKET3 (PACKET3_SET_CONFIG_REG ,1 ));
@@ -2948,17 +2949,17 @@ int r600_copy_cpdma(struct radeon_device *rdev,radeon_ring_write (ring, (WAIT_UNTIL -PACKET3_SET_CONFIG_REG_OFFSET ) >>2 );radeon_ring_write (ring, WAIT_CP_DMA_IDLE_bit); - r =radeon_fence_emit (rdev, fence, ring->idx); + r =radeon_fence_emit (rdev, &fence, ring->idx);if (r) {radeon_ring_unlock_undo (rdev, ring);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); }radeon_ring_unlock_commit (rdev, ring, false); -radeon_semaphore_free (rdev, &sem, *fence); +radeon_semaphore_free (rdev, &sem, fence); -return r; +return fence; } int r600_set_surface_reg(struct radeon_device *rdev, int reg,
drivers/gpu/drm/radeon/r600_dma.c +13 -12
@@ -436,18 +436,19 @@ void r600_dma_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib)* @src_offset: src GPU address * @dst_offset: dst GPU address * @num_gpu_pages: number of GPU pages to xfer -* @fence: radeon fence object +* @resv: reservation object to sync to * * Copy GPU paging using the DMA engine (r6xx). * Used by the radeon ttm implementation to move pages if * registered as the asic copy callback. */ -int r600_copy_dma (struct radeon_device *rdev, -uint64_t src_offset,uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence) +struct radeon_fence *r600_copy_dma (struct radeon_device *rdev, +uint64_t src_offset,uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv) {struct radeon_semaphore *sem =NULL ; +struct radeon_fence *fence;int ring_index = rdev->asic->copy.dma_ring_index;struct radeon_ring *ring = &rdev->ring[ring_index];u32 size_in_dw, cur_size_in_dw;
@@ -457,7 +458,7 @@ int r600_copy_dma(struct radeon_device *rdev, r =radeon_semaphore_create (rdev, &sem);if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r); -return r; +return ERR_PTR (r); } size_in_dw = (num_gpu_pages <<RADEON_GPU_PAGE_SHIFT ) /4 ;
@@ -466,10 +467,10 @@ int r600_copy_dma(struct radeon_device *rdev,if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); } -radeon_semaphore_sync_to (sem, *fence); +radeon_semaphore_sync_resv (sem, resv, false);radeon_semaphore_sync_rings (rdev, sem, ring->idx);for (i =0 ; i < num_loops; i++) {
@@ -486,15 +487,15 @@ int r600_copy_dma(struct radeon_device *rdev, dst_offset += cur_size_in_dw *4 ; } - r =radeon_fence_emit (rdev, fence, ring->idx); + r =radeon_fence_emit (rdev, &fence, ring->idx);if (r) {radeon_ring_unlock_undo (rdev, ring);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); }radeon_ring_unlock_commit (rdev, ring, false); -radeon_semaphore_free (rdev, &sem, *fence); +radeon_semaphore_free (rdev, &sem, fence); -return r; +return fence; }
drivers/gpu/drm/radeon/radeon.h +23 -20
64 lines not on this page · raw message
drivers/gpu/drm/radeon/radeon_asic.h +38 -36
116 lines not on this page · raw message
drivers/gpu/drm/radeon/radeon_benchmark.c +13 -17
@@ -45,33 +45,29 @@ static int radeon_benchmark_do_move(struct radeon_device *rdev, unsigned size,for (i =0 ; i < n; i++) {switch (flag) {case RADEON_BENCHMARK_COPY_DMA : - r =radeon_copy_dma (rdev, saddr, daddr, - size /RADEON_GPU_PAGE_SIZE , - &fence); + fence =radeon_copy_dma (rdev, saddr, daddr, + size /RADEON_GPU_PAGE_SIZE , +NULL );break ;case RADEON_BENCHMARK_COPY_BLIT : - r =radeon_copy_blit (rdev, saddr, daddr, - size /RADEON_GPU_PAGE_SIZE , - &fence); + fence =radeon_copy_blit (rdev, saddr, daddr, + size /RADEON_GPU_PAGE_SIZE , +NULL );break ;default :DRM_ERROR ("Unknown copy method\n" ); - r = -EINVAL ; +return -EINVAL ; } -if (r) - goto exit_do_move; +if (IS_ERR (fence)) +return PTR_ERR (fence); + r =radeon_fence_wait (fence, false); -if (r) - goto exit_do_move;radeon_fence_unref (&fence); +if (r) +return r; } end_jiffies = jiffies; - r =jiffies_to_msecs (end_jiffies - start_jiffies); - -exit_do_move: -if (fence) -radeon_fence_unref (&fence); -return r; +return jiffies_to_msecs (end_jiffies - start_jiffies); }
drivers/gpu/drm/radeon/radeon_cs.c +2 -6
@@ -255,16 +255,12 @@ static void radeon_cs_sync_rings(struct radeon_cs_parser *p)for (i =0 ; i < p->nrelocs; i++) {struct reservation_object *resv; -struct fence *fence;if (!p->relocs[i].robj)continue ; resv = p->relocs[i].robj->tbo.resv; - fence =reservation_object_get_excl (resv); - -radeon_semaphore_sync_to (p->ib.semaphore, - (struct radeon_fence *)fence); +radeon_semaphore_sync_resv (p->ib.semaphore, resv, false); } }
@@ -569,7 +565,7 @@ static int radeon_cs_ib_vm_chunk(struct radeon_device *rdev, goto out; }radeon_cs_sync_rings (parser); -radeon_semaphore_sync_to (parser->ib.semaphore, vm->fence); +radeon_semaphore_sync_fence (parser->ib.semaphore, vm->fence);if ((rdev->family >=CHIP_TAHITI ) && (parser->chunk_const_ib_idx !=-1 )) {
drivers/gpu/drm/radeon/radeon_ib.c +1 -1
@@ -145,7 +145,7 @@ int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib,if (ib->vm) {struct radeon_fence *vm_id_fence; vm_id_fence =radeon_vm_grab_id (rdev, ib->vm, ib->ring); -radeon_semaphore_sync_to (ib->semaphore, vm_id_fence); +radeon_semaphore_sync_fence (ib->semaphore, vm_id_fence); }/* sync with other rings */
drivers/gpu/drm/radeon/radeon_semaphore.c +35 -3
@@ -96,15 +96,15 @@ bool radeon_semaphore_emit_wait(struct radeon_device *rdev, int ridx, }/** -* radeon_semaphore_sync_to - use the semaphore to sync to a fence +* radeon_semaphore_sync_fence - use the semaphore to sync to a fence * * @semaphore: semaphore object to add fence to * @fence: fence to sync to * * Sync to the fence using this semaphore object */ -void radeon_semaphore_sync_to (struct radeon_semaphore *semaphore, -struct radeon_fence *fence) +void radeon_semaphore_sync_fence (struct radeon_semaphore *semaphore, +struct radeon_fence *fence) {struct radeon_fence *other;
@@ -116,6 +116,38 @@ void radeon_semaphore_sync_to(struct radeon_semaphore *semaphore, }/** +* radeon_semaphore_sync_to - use the semaphore to sync to a reservation object +* +* @sema: semaphore object to add fence from reservation object to +* @resv: reservation object with embedded fence +* @shared: true if we should onyl sync to the exclusive fence +* +* Sync to the fence using this semaphore object +*/ +void radeon_semaphore_sync_resv (struct radeon_semaphore *sema, +struct reservation_object *resv, +bool shared) +{ +struct reservation_object_list *flist; +struct fence *f; +unsigned i; + +/* always sync to the exclusive fence */ + f =reservation_object_get_excl (resv); +radeon_semaphore_sync_fence (sema, (struct radeon_fence *)f); + + flist =reservation_object_get_list (resv); +if (shared || !flist) +return ; + +for (i =0 ; i < flist->shared_count; ++i) { + f =rcu_dereference_protected (flist->shared[i], +reservation_object_held (resv)); +radeon_semaphore_sync_fence (sema, (struct radeon_fence *)f); + } +} + +/** * radeon_semaphore_sync_rings - sync ring to all registered fences * * @rdev: radeon_device pointer
drivers/gpu/drm/radeon/radeon_test.c +17 -7
@@ -116,11 +116,16 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag)radeon_bo_kunmap (gtt_obj[i]);if (ring ==R600_RING_TYPE_DMA_INDEX ) - r =radeon_copy_dma (rdev, gtt_addr, vram_addr, size /RADEON_GPU_PAGE_SIZE , &fence); + fence =radeon_copy_dma (rdev, gtt_addr, vram_addr, + size /RADEON_GPU_PAGE_SIZE , +NULL );else - r =radeon_copy_blit (rdev, gtt_addr, vram_addr, size /RADEON_GPU_PAGE_SIZE , &fence); -if (r) { + fence =radeon_copy_blit (rdev, gtt_addr, vram_addr, + size /RADEON_GPU_PAGE_SIZE , +NULL ); +if (IS_ERR (fence)) {DRM_ERROR ("Failed GTT->VRAM copy %d\n" , i); + r =PTR_ERR (fence); goto out_lclean_unpin; }
@@ -162,11 +167,16 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag)radeon_bo_kunmap (vram_obj);if (ring ==R600_RING_TYPE_DMA_INDEX ) - r =radeon_copy_dma (rdev, vram_addr, gtt_addr, size /RADEON_GPU_PAGE_SIZE , &fence); + fence =radeon_copy_dma (rdev, vram_addr, gtt_addr, + size /RADEON_GPU_PAGE_SIZE , +NULL );else - r =radeon_copy_blit (rdev, vram_addr, gtt_addr, size /RADEON_GPU_PAGE_SIZE , &fence); -if (r) { + fence =radeon_copy_blit (rdev, vram_addr, gtt_addr, + size /RADEON_GPU_PAGE_SIZE , +NULL ); +if (IS_ERR (fence)) {DRM_ERROR ("Failed VRAM->GTT copy %d\n" , i); + r =PTR_ERR (fence); goto out_lclean_unpin; }
@@ -222,7 +232,7 @@ out_lclean:radeon_bo_unreserve (gtt_obj[i]);radeon_bo_unref (>t_obj[i]); } -if (fence) +if (fence && !IS_ERR (fence))radeon_fence_unref (&fence);break ; }
drivers/gpu/drm/radeon/radeon_ttm.c +6 -6
@@ -233,6 +233,7 @@ static int radeon_move_blit(struct ttm_buffer_object *bo,struct radeon_device *rdev;uint64_t old_start, new_start;struct radeon_fence *fence; +unsigned num_pages;int r, ridx; rdev =radeon_get_rdev (bo->bdev);
@@ -269,12 +270,11 @@ static int radeon_move_blit(struct ttm_buffer_object *bo,BUILD_BUG_ON ((PAGE_SIZE %RADEON_GPU_PAGE_SIZE ) !=0 ); -/* sync other rings */ - fence = (struct radeon_fence *)reservation_object_get_excl (bo->resv); - r =radeon_copy (rdev, old_start, new_start, - new_mem->num_pages * (PAGE_SIZE /RADEON_GPU_PAGE_SIZE ),/* GPU pages */ - &fence); -/* FIXME: handle copy error */ + num_pages = new_mem->num_pages * (PAGE_SIZE /RADEON_GPU_PAGE_SIZE ); + fence =radeon_copy (rdev, old_start, new_start, num_pages, bo->resv); +if (IS_ERR (fence)) +return PTR_ERR (fence); + r =ttm_bo_move_accel_cleanup (bo, &fence->base, evict, no_wait_gpu, new_mem);radeon_fence_unref (&fence);
drivers/gpu/drm/radeon/radeon_vm.c +4 -12
@@ -696,15 +696,10 @@ int radeon_vm_update_page_directory(struct radeon_device *rdev, incr, R600_PTE_VALID);if (ib.length_dw !=0 ) { -struct fence *fence; -radeon_asic_vm_pad_ib (rdev, &ib); - fence =reservation_object_get_excl (pd->tbo.resv); -radeon_semaphore_sync_to (ib.semaphore, - (struct radeon_fence *)fence); - -radeon_semaphore_sync_to (ib.semaphore, vm->last_id_use); +radeon_semaphore_sync_resv (ib.semaphore, pd->tbo.resv, false); +radeon_semaphore_sync_fence (ib.semaphore, vm->last_id_use);WARN_ON (ib.length_dw > ndw); r =radeon_ib_schedule (rdev, &ib,NULL , false);if (r) {
@@ -829,11 +824,8 @@ static void radeon_vm_update_ptes(struct radeon_device *rdev,struct radeon_bo *pt = vm->page_tables[pt_idx].bo;unsigned nptes;uint64_t pte; -struct fence *fence; - fence =reservation_object_get_excl (pt->tbo.resv); -radeon_semaphore_sync_to (ib->semaphore, - (struct radeon_fence *)fence); +radeon_semaphore_sync_resv (ib->semaphore, pt->tbo.resv, false);if ((addr & ~mask) == (end & ~mask)) nptes = end - addr;
@@ -975,7 +967,7 @@ int radeon_vm_bo_update(struct radeon_device *rdev,radeon_asic_vm_pad_ib (rdev, &ib);WARN_ON (ib.length_dw > ndw); -radeon_semaphore_sync_to (ib.semaphore, vm->fence); +radeon_semaphore_sync_fence (ib.semaphore, vm->fence); r =radeon_ib_schedule (rdev, &ib,NULL , false);if (r) {radeon_ib_free (rdev, &ib);
drivers/gpu/drm/radeon/rv770_dma.c +13 -12
@@ -33,18 +33,19 @@* @src_offset: src GPU address * @dst_offset: dst GPU address * @num_gpu_pages: number of GPU pages to xfer -* @fence: radeon fence object +* @resv: reservation object to sync to * * Copy GPU paging using the DMA engine (r7xx). * Used by the radeon ttm implementation to move pages if * registered as the asic copy callback. */ -int rv770_copy_dma (struct radeon_device *rdev, -uint64_t src_offset,uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence) +struct radeon_fence *rv770_copy_dma (struct radeon_device *rdev, +uint64_t src_offset,uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv) {struct radeon_semaphore *sem =NULL ; +struct radeon_fence *fence;int ring_index = rdev->asic->copy.dma_ring_index;struct radeon_ring *ring = &rdev->ring[ring_index];u32 size_in_dw, cur_size_in_dw;
@@ -54,7 +55,7 @@ int rv770_copy_dma(struct radeon_device *rdev, r =radeon_semaphore_create (rdev, &sem);if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r); -return r; +return ERR_PTR (r); } size_in_dw = (num_gpu_pages <<RADEON_GPU_PAGE_SHIFT ) /4 ;
@@ -63,10 +64,10 @@ int rv770_copy_dma(struct radeon_device *rdev,if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); } -radeon_semaphore_sync_to (sem, *fence); +radeon_semaphore_sync_resv (sem, resv, false);radeon_semaphore_sync_rings (rdev, sem, ring->idx);for (i =0 ; i < num_loops; i++) {
@@ -83,15 +84,15 @@ int rv770_copy_dma(struct radeon_device *rdev, dst_offset += cur_size_in_dw *4 ; } - r =radeon_fence_emit (rdev, fence, ring->idx); + r =radeon_fence_emit (rdev, &fence, ring->idx);if (r) {radeon_ring_unlock_undo (rdev, ring);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); }radeon_ring_unlock_commit (rdev, ring, false); -radeon_semaphore_free (rdev, &sem, *fence); +radeon_semaphore_free (rdev, &sem, fence); -return r; +return fence; }
drivers/gpu/drm/radeon/si_dma.c +13 -12
@@ -218,18 +218,19 @@ void si_dma_vm_flush(struct radeon_device *rdev, int ridx, struct radeon_vm *vm)* @src_offset: src GPU address * @dst_offset: dst GPU address * @num_gpu_pages: number of GPU pages to xfer -* @fence: radeon fence object +* @resv: reservation object to sync to * * Copy GPU paging using the DMA engine (SI). * Used by the radeon ttm implementation to move pages if * registered as the asic copy callback. */ -int si_copy_dma (struct radeon_device *rdev, -uint64_t src_offset,uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence) +struct radeon_fence *si_copy_dma (struct radeon_device *rdev, +uint64_t src_offset,uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv) {struct radeon_semaphore *sem =NULL ; +struct radeon_fence *fence;int ring_index = rdev->asic->copy.dma_ring_index;struct radeon_ring *ring = &rdev->ring[ring_index];u32 size_in_bytes, cur_size_in_bytes;
@@ -239,7 +240,7 @@ int si_copy_dma(struct radeon_device *rdev, r =radeon_semaphore_create (rdev, &sem);if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r); -return r; +return ERR_PTR (r); } size_in_bytes = (num_gpu_pages <<RADEON_GPU_PAGE_SHIFT );
@@ -248,10 +249,10 @@ int si_copy_dma(struct radeon_device *rdev,if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); } -radeon_semaphore_sync_to (sem, *fence); +radeon_semaphore_sync_resv (sem, resv, false);radeon_semaphore_sync_rings (rdev, sem, ring->idx);for (i =0 ; i < num_loops; i++) {
@@ -268,16 +269,16 @@ int si_copy_dma(struct radeon_device *rdev, dst_offset += cur_size_in_bytes; } - r =radeon_fence_emit (rdev, fence, ring->idx); + r =radeon_fence_emit (rdev, &fence, ring->idx);if (r) {radeon_ring_unlock_undo (rdev, ring);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); }radeon_ring_unlock_commit (rdev, ring, false); -radeon_semaphore_free (rdev, &sem, *fence); +radeon_semaphore_free (rdev, &sem, fence); -return r; +return fence; }
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/3] drm/radeon: add the infrastructure for concurrent buffer access
Quoted 6 lines · Christian König
From: Christian König <[email protected]>
This allows us to specify if we want to sync to
the shared fences of a reservation object or not.Signed-off-by Christian König <[email protected]>
Just one minor copy/paste typo in the comments below. With that fixed:
Quoted 788 lines
--- drivers/gpu/drm/radeon/cik.c | 25 ++++++----- drivers/gpu/drm/radeon/cik_sdma.c | 25 ++++++----- drivers/gpu/drm/radeon/evergreen_dma.c | 24 +++++----- drivers/gpu/drm/radeon/r100.c | 21 +++++---- drivers/gpu/drm/radeon/r200.c | 21 +++++---- drivers/gpu/drm/radeon/r600.c | 23 +++++----- drivers/gpu/drm/radeon/r600_dma.c | 25 ++++++----- drivers/gpu/drm/radeon/radeon.h | 43 +++++++++--------- drivers/gpu/drm/radeon/radeon_asic.h | 74 ++++++++++++++++--------------- drivers/gpu/drm/radeon/radeon_benchmark.c | 30 ++++++------- drivers/gpu/drm/radeon/radeon_cs.c | 8 +--- drivers/gpu/drm/radeon/radeon_ib.c | 2 +- drivers/gpu/drm/radeon/radeon_semaphore.c | 38 ++++++++++++++-- drivers/gpu/drm/radeon/radeon_test.c | 24 +++++++--- drivers/gpu/drm/radeon/radeon_ttm.c | 12 ++--- drivers/gpu/drm/radeon/radeon_vm.c | 16 ++----- drivers/gpu/drm/radeon/rv770_dma.c | 25 ++++++----- drivers/gpu/drm/radeon/si_dma.c | 25 ++++++----- 18 files changed, 253 insertions(+), 208 deletions(-)drivers/gpu/drm/radeon/cik.c +13
-12@@ -3959,18 +3959,19 @@ bool cik_semaphore_ring_emit(struct radeon_device *rdev,* @src_offset: src GPU address * @dst_offset: dst GPU address * @num_gpu_pages: number of GPU pages to xfer -* @fence: radeon fence object +* @resv: reservation object to sync to * * Copy GPU paging using the CP DMA engine (CIK+). * Used by the radeon ttm implementation to move pages if * registered as the asic copy callback. */ -int cik_copy_cpdma (struct radeon_device *rdev, -uint64_t src_offset,uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence) +struct radeon_fence *cik_copy_cpdma (struct radeon_device *rdev, +uint64_t src_offset,uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv) {struct radeon_semaphore *sem =NULL ; +struct radeon_fence *fence;int ring_index = rdev->asic->copy.blit_ring_index;struct radeon_ring *ring = &rdev->ring[ring_index];u32 size_in_bytes, cur_size_in_bytes, control;@@ -3980,7 +3981,7 @@ int cik_copy_cpdma(struct radeon_device *rdev, r =radeon_semaphore_create (rdev, &sem);if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r); -return r; +return ERR_PTR (r); } size_in_bytes = (num_gpu_pages <<RADEON_GPU_PAGE_SHIFT );@@ -3989,10 +3990,10 @@ int cik_copy_cpdma(struct radeon_device *rdev,if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); } -radeon_semaphore_sync_to (sem, *fence); +radeon_semaphore_sync_resv (sem, resv, false);radeon_semaphore_sync_rings (rdev, sem, ring->idx);for (i =0 ; i < num_loops; i++) {@@ -4014,17 +4015,17 @@ int cik_copy_cpdma(struct radeon_device *rdev, dst_offset += cur_size_in_bytes; } - r =radeon_fence_emit (rdev, fence, ring->idx); + r =radeon_fence_emit (rdev, &fence, ring->idx);if (r) {radeon_ring_unlock_undo (rdev, ring);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); }radeon_ring_unlock_commit (rdev, ring, false); -radeon_semaphore_free (rdev, &sem, *fence); +radeon_semaphore_free (rdev, &sem, fence); -return r; +return fence; }/* drivers/gpu/drm/radeon/cik_sdma.c +13
-12@@ -537,18 +537,19 @@ void cik_sdma_fini(struct radeon_device *rdev)* @src_offset: src GPU address * @dst_offset: dst GPU address * @num_gpu_pages: number of GPU pages to xfer -* @fence: radeon fence object +* @resv: reservation object to sync to * * Copy GPU paging using the DMA engine (CIK). * Used by the radeon ttm implementation to move pages if * registered as the asic copy callback. */ -int cik_copy_dma (struct radeon_device *rdev, -uint64_t src_offset,uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence) +struct radeon_fence *cik_copy_dma (struct radeon_device *rdev, +uint64_t src_offset,uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv) {struct radeon_semaphore *sem =NULL ; +struct radeon_fence *fence;int ring_index = rdev->asic->copy.dma_ring_index;struct radeon_ring *ring = &rdev->ring[ring_index];u32 size_in_bytes, cur_size_in_bytes;@@ -558,7 +559,7 @@ int cik_copy_dma(struct radeon_device *rdev, r =radeon_semaphore_create (rdev, &sem);if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r); -return r; +return ERR_PTR (r); } size_in_bytes = (num_gpu_pages <<RADEON_GPU_PAGE_SHIFT );@@ -567,10 +568,10 @@ int cik_copy_dma(struct radeon_device *rdev,if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); } -radeon_semaphore_sync_to (sem, *fence); +radeon_semaphore_sync_resv (sem, resv, false);radeon_semaphore_sync_rings (rdev, sem, ring->idx);for (i =0 ; i < num_loops; i++) {@@ -589,17 +590,17 @@ int cik_copy_dma(struct radeon_device *rdev, dst_offset += cur_size_in_bytes; } - r =radeon_fence_emit (rdev, fence, ring->idx); + r =radeon_fence_emit (rdev, &fence, ring->idx);if (r) {radeon_ring_unlock_undo (rdev, ring);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); }radeon_ring_unlock_commit (rdev, ring, false); -radeon_semaphore_free (rdev, &sem, *fence); +radeon_semaphore_free (rdev, &sem, fence); -return r; +return fence; }/** drivers/gpu/drm/radeon/evergreen_dma.c +13
-11@@ -104,12 +104,14 @@ void evergreen_dma_ring_ib_execute(struct radeon_device *rdev,* Used by the radeon ttm implementation to move pages if * registered as the asic copy callback. */ -int evergreen_copy_dma (struct radeon_device *rdev, -uint64_t src_offset,uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence) +struct radeon_fence *evergreen_copy_dma (struct radeon_device *rdev, +uint64_t src_offset, +uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv) {struct radeon_semaphore *sem =NULL ; +struct radeon_fence *fence;int ring_index = rdev->asic->copy.dma_ring_index;struct radeon_ring *ring = &rdev->ring[ring_index];u32 size_in_dw, cur_size_in_dw;@@ -119,7 +121,7 @@ int evergreen_copy_dma(struct radeon_device *rdev, r =radeon_semaphore_create (rdev, &sem);if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r); -return r; +return ERR_PTR (r); } size_in_dw = (num_gpu_pages <<RADEON_GPU_PAGE_SHIFT ) /4 ;@@ -128,10 +130,10 @@ int evergreen_copy_dma(struct radeon_device *rdev,if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); } -radeon_semaphore_sync_to (sem, *fence); +radeon_semaphore_sync_resv (sem, resv, false);radeon_semaphore_sync_rings (rdev, sem, ring->idx);for (i =0 ; i < num_loops; i++) {@@ -148,17 +150,17 @@ int evergreen_copy_dma(struct radeon_device *rdev, dst_offset += cur_size_in_dw *4 ; } - r =radeon_fence_emit (rdev, fence, ring->idx); + r =radeon_fence_emit (rdev, &fence, ring->idx);if (r) {radeon_ring_unlock_undo (rdev, ring);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); }radeon_ring_unlock_commit (rdev, ring, false); -radeon_semaphore_free (rdev, &sem, *fence); +radeon_semaphore_free (rdev, &sem, fence); -return r; +return fence; }/** drivers/gpu/drm/radeon/r100.c +12
-9@@ -855,13 +855,14 @@ bool r100_semaphore_ring_emit(struct radeon_device *rdev,return false; } -int r100_copy_blit (struct radeon_device *rdev, -uint64_t src_offset, -uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence) +struct radeon_fence *r100_copy_blit (struct radeon_device *rdev, +uint64_t src_offset, +uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv) {struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX ]; +struct radeon_fence *fence;uint32_t cur_pages;uint32_t stride_bytes =RADEON_GPU_PAGE_SIZE ;uint32_t pitch;@@ -882,7 +883,7 @@ int r100_copy_blit(struct radeon_device *rdev, r =radeon_ring_lock (rdev, ring, ndw);if (r) {DRM_ERROR ("radeon: moving bo (%d) asking for %u dw.\n" , r, ndw); -return -EINVAL ; +return ERR_PTR (-EINVAL ); }while (num_gpu_pages >0 ) { cur_pages = num_gpu_pages;@@ -922,11 +923,13 @@ int r100_copy_blit(struct radeon_device *rdev,RADEON_WAIT_2D_IDLECLEAN |RADEON_WAIT_HOST_IDLECLEAN | RADEON_WAIT_DMA_GUI_IDLE); -if (fence) { - r =radeon_fence_emit (rdev, fence,RADEON_RING_TYPE_GFX_INDEX ); + r =radeon_fence_emit (rdev, &fence,RADEON_RING_TYPE_GFX_INDEX ); +if (r) { +radeon_ring_unlock_undo (rdev, ring); +return ERR_PTR (r); }radeon_ring_unlock_commit (rdev, ring, false); -return r; +return fence; }static int r100_cp_wait_for_idle (struct radeon_device *rdev)drivers/gpu/drm/radeon/r200.c +12
-9@@ -80,13 +80,14 @@ static int r200_get_vtx_size_0(uint32_t vtx_fmt_0)return vtx_size; } -int r200_copy_dma (struct radeon_device *rdev, -uint64_t src_offset, -uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence) +struct radeon_fence *r200_copy_dma (struct radeon_device *rdev, +uint64_t src_offset, +uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv) {struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX ]; +struct radeon_fence *fence;uint32_t size;uint32_t cur_size;int i, num_loops;@@ -98,7 +99,7 @@ int r200_copy_dma(struct radeon_device *rdev, r =radeon_ring_lock (rdev, ring, num_loops *4 +64 );if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r); -return r; +return ERR_PTR (r); }/* Must wait for 2D idle & clean before DMA or hangs might happen */ radeon_ring_write (ring,PACKET0 (RADEON_WAIT_UNTIL ,0 ));@@ -118,11 +119,13 @@ int r200_copy_dma(struct radeon_device *rdev, }radeon_ring_write (ring,PACKET0 (RADEON_WAIT_UNTIL ,0 ));radeon_ring_write (ring,RADEON_WAIT_DMA_GUI_IDLE ); -if (fence) { - r =radeon_fence_emit (rdev, fence,RADEON_RING_TYPE_GFX_INDEX ); + r =radeon_fence_emit (rdev, &fence,RADEON_RING_TYPE_GFX_INDEX ); +if (r) { +radeon_ring_unlock_undo (rdev, ring); +return ERR_PTR (r); }radeon_ring_unlock_commit (rdev, ring, false); -return r; +return fence; }drivers/gpu/drm/radeon/r600.c +12
-11@@ -2894,12 +2894,13 @@ bool r600_semaphore_ring_emit(struct radeon_device *rdev,* Used by the radeon ttm implementation to move pages if * registered as the asic copy callback. */ -int r600_copy_cpdma (struct radeon_device *rdev, -uint64_t src_offset,uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence) +struct radeon_fence *r600_copy_cpdma (struct radeon_device *rdev, +uint64_t src_offset,uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv) {struct radeon_semaphore *sem =NULL ; +struct radeon_fence *fence;int ring_index = rdev->asic->copy.blit_ring_index;struct radeon_ring *ring = &rdev->ring[ring_index];u32 size_in_bytes, cur_size_in_bytes, tmp;@@ -2909,7 +2910,7 @@ int r600_copy_cpdma(struct radeon_device *rdev, r =radeon_semaphore_create (rdev, &sem);if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r); -return r; +return ERR_PTR (r); } size_in_bytes = (num_gpu_pages <<RADEON_GPU_PAGE_SHIFT );@@ -2918,10 +2919,10 @@ int r600_copy_cpdma(struct radeon_device *rdev,if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); } -radeon_semaphore_sync_to (sem, *fence); +radeon_semaphore_sync_resv (sem, resv, false);radeon_semaphore_sync_rings (rdev, sem, ring->idx);radeon_ring_write (ring,PACKET3 (PACKET3_SET_CONFIG_REG ,1 ));@@ -2948,17 +2949,17 @@ int r600_copy_cpdma(struct radeon_device *rdev,radeon_ring_write (ring, (WAIT_UNTIL -PACKET3_SET_CONFIG_REG_OFFSET ) >>2 );radeon_ring_write (ring, WAIT_CP_DMA_IDLE_bit); - r =radeon_fence_emit (rdev, fence, ring->idx); + r =radeon_fence_emit (rdev, &fence, ring->idx);if (r) {radeon_ring_unlock_undo (rdev, ring);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); }radeon_ring_unlock_commit (rdev, ring, false); -radeon_semaphore_free (rdev, &sem, *fence); +radeon_semaphore_free (rdev, &sem, fence); -return r; +return fence; } int r600_set_surface_reg(struct radeon_device *rdev, int reg,drivers/gpu/drm/radeon/r600_dma.c +13
-12@@ -436,18 +436,19 @@ void r600_dma_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib)* @src_offset: src GPU address * @dst_offset: dst GPU address * @num_gpu_pages: number of GPU pages to xfer -* @fence: radeon fence object +* @resv: reservation object to sync to * * Copy GPU paging using the DMA engine (r6xx). * Used by the radeon ttm implementation to move pages if * registered as the asic copy callback. */ -int r600_copy_dma (struct radeon_device *rdev, -uint64_t src_offset,uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence) +struct radeon_fence *r600_copy_dma (struct radeon_device *rdev, +uint64_t src_offset,uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv) {struct radeon_semaphore *sem =NULL ; +struct radeon_fence *fence;int ring_index = rdev->asic->copy.dma_ring_index;struct radeon_ring *ring = &rdev->ring[ring_index];u32 size_in_dw, cur_size_in_dw;@@ -457,7 +458,7 @@ int r600_copy_dma(struct radeon_device *rdev, r =radeon_semaphore_create (rdev, &sem);if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r); -return r; +return ERR_PTR (r); } size_in_dw = (num_gpu_pages <<RADEON_GPU_PAGE_SHIFT ) /4 ;@@ -466,10 +467,10 @@ int r600_copy_dma(struct radeon_device *rdev,if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); } -radeon_semaphore_sync_to (sem, *fence); +radeon_semaphore_sync_resv (sem, resv, false);radeon_semaphore_sync_rings (rdev, sem, ring->idx);for (i =0 ; i < num_loops; i++) {@@ -486,15 +487,15 @@ int r600_copy_dma(struct radeon_device *rdev, dst_offset += cur_size_in_dw *4 ; } - r =radeon_fence_emit (rdev, fence, ring->idx); + r =radeon_fence_emit (rdev, &fence, ring->idx);if (r) {radeon_ring_unlock_undo (rdev, ring);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); }radeon_ring_unlock_commit (rdev, ring, false); -radeon_semaphore_free (rdev, &sem, *fence); +radeon_semaphore_free (rdev, &sem, fence); -return r; +return fence; }drivers/gpu/drm/radeon/radeon.h +23
-20@@ -585,8 +585,11 @@ bool radeon_semaphore_emit_signal(struct radeon_device *rdev, int ring, struct radeon_semaphore *semaphore);bool radeon_semaphore_emit_wait (struct radeon_device *rdev,int ring,struct radeon_semaphore *semaphore); -void radeon_semaphore_sync_to (struct radeon_semaphore *semaphore, -struct radeon_fence *fence); +void radeon_semaphore_sync_fence (struct radeon_semaphore *semaphore, +struct radeon_fence *fence); +void radeon_semaphore_sync_resv (struct radeon_semaphore *semaphore, +struct reservation_object *resv, +bool shared);int radeon_semaphore_sync_rings (struct radeon_device *rdev,struct radeon_semaphore *semaphore,int waiting_ring);@@ -1855,24 +1858,24 @@ struct radeon_asic { } display;/* copy functions for bo handling */ struct { -int (*blit)(struct radeon_device *rdev, -uint64_t src_offset, -uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence); +struct radeon_fence *(*blit)(struct radeon_device *rdev, +uint64_t src_offset, +uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv);u32 blit_ring_index; -int (*dma)(struct radeon_device *rdev, -uint64_t src_offset, -uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence); +struct radeon_fence *(*dma)(struct radeon_device *rdev, +uint64_t src_offset, +uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv);u32 dma_ring_index;/* method used for bo copy */ -int (*copy)(struct radeon_device *rdev, -uint64_t src_offset, -uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence); +struct radeon_fence *(*copy)(struct radeon_device *rdev, +uint64_t src_offset, +uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv);/* ring used for bo copies */ u32 copy_ring_index; } copy;@@ -2826,9 +2829,9 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t v);#define radeon_hdmi_setmode (rdev, e, m) (rdev)->asic->display.hdmi_setmode((e), (m))#define radeon_fence_ring_emit (rdev, r, fence) (rdev)->asic->ring[(r)]->emit_fence((rdev), (fence))#define radeon_semaphore_ring_emit (rdev, r, cp, semaphore, emit_wait) (rdev)->asic->ring[(r)]->emit_semaphore((rdev), (cp), (semaphore), (emit_wait)) -#define radeon_copy_blit (rdev, s, d, np, f) (rdev)->asic->copy.blit((rdev), (s), (d), (np), (f)) -#define radeon_copy_dma (rdev, s, d, np, f) (rdev)->asic->copy.dma((rdev), (s), (d), (np), (f)) -#define radeon_copy (rdev, s, d, np, f) (rdev)->asic->copy.copy((rdev), (s), (d), (np), (f)) +#define radeon_copy_blit (rdev, s, d, np, resv) (rdev)->asic->copy.blit((rdev), (s), (d), (np), (resv)) +#define radeon_copy_dma (rdev, s, d, np, resv) (rdev)->asic->copy.dma((rdev), (s), (d), (np), (resv)) +#define radeon_copy (rdev, s, d, np, resv) (rdev)->asic->copy.copy((rdev), (s), (d), (np), (resv))#define radeon_copy_blit_ring_index (rdev) (rdev)->asic->copy.blit_ring_index#define radeon_copy_dma_ring_index (rdev) (rdev)->asic->copy.dma_ring_index#define radeon_copy_ring_index (rdev) (rdev)->asic->copy.copy_ring_indexdrivers/gpu/drm/radeon/radeon_asic.h +38
-36@@ -81,11 +81,11 @@ bool r100_semaphore_ring_emit(struct radeon_device *rdev,int r100_cs_parse (struct radeon_cs_parser *p);void r100_pll_wreg (struct radeon_device *rdev,uint32_t reg,uint32_t v);uint32_t r100_pll_rreg (struct radeon_device *rdev,uint32_t reg); -int r100_copy_blit (struct radeon_device *rdev, -uint64_t src_offset, -uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence); +struct radeon_fence *r100_copy_blit (struct radeon_device *rdev, +uint64_t src_offset, +uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv);int r100_set_surface_reg (struct radeon_device *rdev,int reg,uint32_t tiling_flags,uint32_t pitch,uint32_t offset,uint32_t obj_size);@@ -153,11 +153,11 @@ void r100_ring_hdp_flush(struct radeon_device *rdev,/* * r200,rv250,rs300,rv280 */ -extern int r200_copy_dma (struct radeon_device *rdev, -uint64_t src_offset, -uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence); +struct radeon_fence *r200_copy_dma (struct radeon_device *rdev, +uint64_t src_offset, +uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv);void r200_set_safe_registers (struct radeon_device *rdev);/* @@ -341,12 +341,14 @@ int r600_dma_ib_test(struct radeon_device *rdev, struct radeon_ring *ring);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_dma_ring_test (struct radeon_device *rdev,struct radeon_ring *cp); -int r600_copy_cpdma (struct radeon_device *rdev, -uint64_t src_offset,uint64_t dst_offset, -unsigned num_gpu_pages,struct radeon_fence **fence); -int r600_copy_dma (struct radeon_device *rdev, -uint64_t src_offset,uint64_t dst_offset, -unsigned num_gpu_pages,struct radeon_fence **fence); +struct radeon_fence *r600_copy_cpdma (struct radeon_device *rdev, +uint64_t src_offset,uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv); +struct radeon_fence *r600_copy_dma (struct radeon_device *rdev, +uint64_t src_offset,uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv);void r600_hpd_init (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);@@ -462,10 +464,10 @@ bool rv770_page_flip_pending(struct radeon_device *rdev, int crtc);void r700_vram_gtt_location (struct radeon_device *rdev,struct radeon_mc *mc);void r700_cp_stop (struct radeon_device *rdev);void r700_cp_fini (struct radeon_device *rdev); -int rv770_copy_dma (struct radeon_device *rdev, -uint64_t src_offset,uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence); +struct radeon_fence *rv770_copy_dma (struct radeon_device *rdev, +uint64_t src_offset,uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv);u32 rv770_get_xclk (struct radeon_device *rdev);int rv770_set_uvd_clocks (struct radeon_device *rdev,u32 vclk,u32 dclk);int rv770_get_temp (struct radeon_device *rdev);@@ -536,10 +538,10 @@ void evergreen_dma_fence_ring_emit(struct radeon_device *rdev, struct radeon_fence *fence);void evergreen_dma_ring_ib_execute (struct radeon_device *rdev,struct radeon_ib *ib); -int evergreen_copy_dma (struct radeon_device *rdev, -uint64_t src_offset,uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence); +struct radeon_fence *evergreen_copy_dma (struct radeon_device *rdev, +uint64_t src_offset,uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv);void evergreen_hdmi_enable (struct drm_encoder *encoder,bool enable);void evergreen_hdmi_setmode (struct drm_encoder *encoder,struct drm_display_mode *mode);int evergreen_get_temp (struct radeon_device *rdev);@@ -701,10 +703,10 @@ int si_vm_init(struct radeon_device *rdev);void si_vm_fini (struct radeon_device *rdev);void si_vm_flush (struct radeon_device *rdev,int ridx,struct radeon_vm *vm);int si_ib_parse (struct radeon_device *rdev,struct radeon_ib *ib); -int si_copy_dma (struct radeon_device *rdev, -uint64_t src_offset,uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence); +struct radeon_fence *si_copy_dma (struct radeon_device *rdev, +uint64_t src_offset,uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv); void si_dma_vm_copy_pages(struct radeon_device *rdev, struct radeon_ib *ib,@@ -760,14 +762,14 @@ bool cik_sdma_semaphore_ring_emit(struct radeon_device *rdev,struct radeon_semaphore *semaphore, bool emit_wait);void cik_sdma_ring_ib_execute (struct radeon_device *rdev,struct radeon_ib *ib); -int cik_copy_dma (struct radeon_device *rdev, -uint64_t src_offset,uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence); -int cik_copy_cpdma (struct radeon_device *rdev, -uint64_t src_offset,uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence); +struct radeon_fence *cik_copy_dma (struct radeon_device *rdev, +uint64_t src_offset,uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv); +struct radeon_fence *cik_copy_cpdma (struct radeon_device *rdev, +uint64_t src_offset,uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv);int cik_sdma_ring_test (struct radeon_device *rdev,struct radeon_ring *ring);int cik_sdma_ib_test (struct radeon_device *rdev,struct radeon_ring *ring);bool cik_sdma_is_lockup (struct radeon_device *rdev,struct radeon_ring *ring);drivers/gpu/drm/radeon/radeon_benchmark.c +13
-17@@ -45,33 +45,29 @@ static int radeon_benchmark_do_move(struct radeon_device *rdev, unsigned size,for (i =0 ; i < n; i++) {switch (flag) {case RADEON_BENCHMARK_COPY_DMA : - r =radeon_copy_dma (rdev, saddr, daddr, - size /RADEON_GPU_PAGE_SIZE , - &fence); + fence =radeon_copy_dma (rdev, saddr, daddr, + size /RADEON_GPU_PAGE_SIZE , +NULL );break ;case RADEON_BENCHMARK_COPY_BLIT : - r =radeon_copy_blit (rdev, saddr, daddr, - size /RADEON_GPU_PAGE_SIZE , - &fence); + fence =radeon_copy_blit (rdev, saddr, daddr, + size /RADEON_GPU_PAGE_SIZE , +NULL );break ;default :DRM_ERROR ("Unknown copy method\n" ); - r = -EINVAL ; +return -EINVAL ; } -if (r) - goto exit_do_move; +if (IS_ERR (fence)) +return PTR_ERR (fence); + r =radeon_fence_wait (fence, false); -if (r) - goto exit_do_move;radeon_fence_unref (&fence); +if (r) +return r; } end_jiffies = jiffies; - r =jiffies_to_msecs (end_jiffies - start_jiffies); - -exit_do_move: -if (fence) -radeon_fence_unref (&fence); -return r; +return jiffies_to_msecs (end_jiffies - start_jiffies); }drivers/gpu/drm/radeon/radeon_cs.c +2
-6@@ -255,16 +255,12 @@ static void radeon_cs_sync_rings(struct radeon_cs_parser *p)for (i =0 ; i < p->nrelocs; i++) {struct reservation_object *resv; -struct fence *fence;if (!p->relocs[i].robj)continue ; resv = p->relocs[i].robj->tbo.resv; - fence =reservation_object_get_excl (resv); - -radeon_semaphore_sync_to (p->ib.semaphore, - (struct radeon_fence *)fence); +radeon_semaphore_sync_resv (p->ib.semaphore, resv, false); } }@@ -569,7 +565,7 @@ static int radeon_cs_ib_vm_chunk(struct radeon_device *rdev, goto out; }radeon_cs_sync_rings (parser); -radeon_semaphore_sync_to (parser->ib.semaphore, vm->fence); +radeon_semaphore_sync_fence (parser->ib.semaphore, vm->fence);if ((rdev->family >=CHIP_TAHITI ) && (parser->chunk_const_ib_idx !=-1 )) {drivers/gpu/drm/radeon/radeon_ib.c +1
-1@@ -145,7 +145,7 @@ int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib,if (ib->vm) {struct radeon_fence *vm_id_fence; vm_id_fence =radeon_vm_grab_id (rdev, ib->vm, ib->ring); -radeon_semaphore_sync_to (ib->semaphore, vm_id_fence); +radeon_semaphore_sync_fence (ib->semaphore, vm_id_fence); }/* sync with other rings */ drivers/gpu/drm/radeon/radeon_semaphore.c +3
-3@@ -96,15 +96,15 @@ bool radeon_semaphore_emit_wait(struct radeon_device *rdev, int ridx, }/** -* radeon_semaphore_sync_to - use the semaphore to sync to a fence +* radeon_semaphore_sync_fence - use the semaphore to sync to a fence * * @semaphore: semaphore object to add fence to * @fence: fence to sync to * * Sync to the fence using this semaphore object */ -void radeon_semaphore_sync_to (struct radeon_semaphore *semaphore, -struct radeon_fence *fence) +void radeon_semaphore_sync_fence (struct radeon_semaphore *semaphore, +struct radeon_fence *fence) {struct radeon_fence *other;
drivers/gpu/drm/radeon/radeon_semaphore.c void radeon_semaphore_sync_to(struct radeon_semaphore *semaphore, · line 120
Quoted 5 lines
drivers/gpu/drm/radeon/radeon_semaphore.c +2
-0@@ -116,6 +116,38 @@ void radeon_semaphore_sync_to(struct radeon_semaphore *semaphore, }/** +* radeon_semaphore_sync_to - use the semaphore to sync to a reservation object +*
Copy-paste typo: radeon_semaphore_sync_to vs. radeon_semaphore_sync_resv
Quoted 306 lines
drivers/gpu/drm/radeon/radeon_semaphore.c +30
-0+* @sema: semaphore object to add fence from reservation object to +* @resv: reservation object with embedded fence +* @shared: true if we should onyl sync to the exclusive fence +* +* Sync to the fence using this semaphore object +*/ +void radeon_semaphore_sync_resv (struct radeon_semaphore *sema, +struct reservation_object *resv, +bool shared) +{ +struct reservation_object_list *flist; +struct fence *f; +unsigned i; + +/* always sync to the exclusive fence */ + f =reservation_object_get_excl (resv); +radeon_semaphore_sync_fence (sema, (struct radeon_fence *)f); + + flist =reservation_object_get_list (resv); +if (shared || !flist) +return ; + +for (i =0 ; i < flist->shared_count; ++i) { + f =rcu_dereference_protected (flist->shared[i], +reservation_object_held (resv)); +radeon_semaphore_sync_fence (sema, (struct radeon_fence *)f); + } +} + +/** * radeon_semaphore_sync_rings - sync ring to all registered fences * * @rdev: radeon_device pointer drivers/gpu/drm/radeon/radeon_test.c +17
-7@@ -116,11 +116,16 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag)radeon_bo_kunmap (gtt_obj[i]);if (ring ==R600_RING_TYPE_DMA_INDEX ) - r =radeon_copy_dma (rdev, gtt_addr, vram_addr, size /RADEON_GPU_PAGE_SIZE , &fence); + fence =radeon_copy_dma (rdev, gtt_addr, vram_addr, + size /RADEON_GPU_PAGE_SIZE , +NULL );else - r =radeon_copy_blit (rdev, gtt_addr, vram_addr, size /RADEON_GPU_PAGE_SIZE , &fence); -if (r) { + fence =radeon_copy_blit (rdev, gtt_addr, vram_addr, + size /RADEON_GPU_PAGE_SIZE , +NULL ); +if (IS_ERR (fence)) {DRM_ERROR ("Failed GTT->VRAM copy %d\n" , i); + r =PTR_ERR (fence); goto out_lclean_unpin; }@@ -162,11 +167,16 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag)radeon_bo_kunmap (vram_obj);if (ring ==R600_RING_TYPE_DMA_INDEX ) - r =radeon_copy_dma (rdev, vram_addr, gtt_addr, size /RADEON_GPU_PAGE_SIZE , &fence); + fence =radeon_copy_dma (rdev, vram_addr, gtt_addr, + size /RADEON_GPU_PAGE_SIZE , +NULL );else - r =radeon_copy_blit (rdev, vram_addr, gtt_addr, size /RADEON_GPU_PAGE_SIZE , &fence); -if (r) { + fence =radeon_copy_blit (rdev, vram_addr, gtt_addr, + size /RADEON_GPU_PAGE_SIZE , +NULL ); +if (IS_ERR (fence)) {DRM_ERROR ("Failed VRAM->GTT copy %d\n" , i); + r =PTR_ERR (fence); goto out_lclean_unpin; }@@ -222,7 +232,7 @@ out_lclean:radeon_bo_unreserve (gtt_obj[i]);radeon_bo_unref (>t_obj[i]); } -if (fence) +if (fence && !IS_ERR (fence))radeon_fence_unref (&fence);break ; }drivers/gpu/drm/radeon/radeon_ttm.c +6
-6@@ -233,6 +233,7 @@ static int radeon_move_blit(struct ttm_buffer_object *bo,struct radeon_device *rdev;uint64_t old_start, new_start;struct radeon_fence *fence; +unsigned num_pages;int r, ridx; rdev =radeon_get_rdev (bo->bdev);@@ -269,12 +270,11 @@ static int radeon_move_blit(struct ttm_buffer_object *bo,BUILD_BUG_ON ((PAGE_SIZE %RADEON_GPU_PAGE_SIZE ) !=0 ); -/* sync other rings */ - fence = (struct radeon_fence *)reservation_object_get_excl (bo->resv); - r =radeon_copy (rdev, old_start, new_start, - new_mem->num_pages * (PAGE_SIZE /RADEON_GPU_PAGE_SIZE ),/* GPU pages */ - &fence); -/* FIXME: handle copy error */ + num_pages = new_mem->num_pages * (PAGE_SIZE /RADEON_GPU_PAGE_SIZE ); + fence =radeon_copy (rdev, old_start, new_start, num_pages, bo->resv); +if (IS_ERR (fence)) +return PTR_ERR (fence); + r =ttm_bo_move_accel_cleanup (bo, &fence->base, evict, no_wait_gpu, new_mem);radeon_fence_unref (&fence);drivers/gpu/drm/radeon/radeon_vm.c +4
-12@@ -696,15 +696,10 @@ int radeon_vm_update_page_directory(struct radeon_device *rdev, incr, R600_PTE_VALID);if (ib.length_dw !=0 ) { -struct fence *fence; -radeon_asic_vm_pad_ib (rdev, &ib); - fence =reservation_object_get_excl (pd->tbo.resv); -radeon_semaphore_sync_to (ib.semaphore, - (struct radeon_fence *)fence); - -radeon_semaphore_sync_to (ib.semaphore, vm->last_id_use); +radeon_semaphore_sync_resv (ib.semaphore, pd->tbo.resv, false); +radeon_semaphore_sync_fence (ib.semaphore, vm->last_id_use);WARN_ON (ib.length_dw > ndw); r =radeon_ib_schedule (rdev, &ib,NULL , false);if (r) {@@ -829,11 +824,8 @@ static void radeon_vm_update_ptes(struct radeon_device *rdev,struct radeon_bo *pt = vm->page_tables[pt_idx].bo;unsigned nptes;uint64_t pte; -struct fence *fence; - fence =reservation_object_get_excl (pt->tbo.resv); -radeon_semaphore_sync_to (ib->semaphore, - (struct radeon_fence *)fence); +radeon_semaphore_sync_resv (ib->semaphore, pt->tbo.resv, false);if ((addr & ~mask) == (end & ~mask)) nptes = end - addr;@@ -975,7 +967,7 @@ int radeon_vm_bo_update(struct radeon_device *rdev,radeon_asic_vm_pad_ib (rdev, &ib);WARN_ON (ib.length_dw > ndw); -radeon_semaphore_sync_to (ib.semaphore, vm->fence); +radeon_semaphore_sync_fence (ib.semaphore, vm->fence); r =radeon_ib_schedule (rdev, &ib,NULL , false);if (r) {radeon_ib_free (rdev, &ib);drivers/gpu/drm/radeon/rv770_dma.c +13
-12@@ -33,18 +33,19 @@* @src_offset: src GPU address * @dst_offset: dst GPU address * @num_gpu_pages: number of GPU pages to xfer -* @fence: radeon fence object +* @resv: reservation object to sync to * * Copy GPU paging using the DMA engine (r7xx). * Used by the radeon ttm implementation to move pages if * registered as the asic copy callback. */ -int rv770_copy_dma (struct radeon_device *rdev, -uint64_t src_offset,uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence) +struct radeon_fence *rv770_copy_dma (struct radeon_device *rdev, +uint64_t src_offset,uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv) {struct radeon_semaphore *sem =NULL ; +struct radeon_fence *fence;int ring_index = rdev->asic->copy.dma_ring_index;struct radeon_ring *ring = &rdev->ring[ring_index];u32 size_in_dw, cur_size_in_dw;@@ -54,7 +55,7 @@ int rv770_copy_dma(struct radeon_device *rdev, r =radeon_semaphore_create (rdev, &sem);if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r); -return r; +return ERR_PTR (r); } size_in_dw = (num_gpu_pages <<RADEON_GPU_PAGE_SHIFT ) /4 ;@@ -63,10 +64,10 @@ int rv770_copy_dma(struct radeon_device *rdev,if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); } -radeon_semaphore_sync_to (sem, *fence); +radeon_semaphore_sync_resv (sem, resv, false);radeon_semaphore_sync_rings (rdev, sem, ring->idx);for (i =0 ; i < num_loops; i++) {@@ -83,15 +84,15 @@ int rv770_copy_dma(struct radeon_device *rdev, dst_offset += cur_size_in_dw *4 ; } - r =radeon_fence_emit (rdev, fence, ring->idx); + r =radeon_fence_emit (rdev, &fence, ring->idx);if (r) {radeon_ring_unlock_undo (rdev, ring);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); }radeon_ring_unlock_commit (rdev, ring, false); -radeon_semaphore_free (rdev, &sem, *fence); +radeon_semaphore_free (rdev, &sem, fence); -return r; +return fence; }drivers/gpu/drm/radeon/si_dma.c +13
-13@@ -218,18 +218,19 @@ void si_dma_vm_flush(struct radeon_device *rdev, int ridx, struct radeon_vm *vm)* @src_offset: src GPU address * @dst_offset: dst GPU address * @num_gpu_pages: number of GPU pages to xfer -* @fence: radeon fence object +* @resv: reservation object to sync to * * Copy GPU paging using the DMA engine (SI). * Used by the radeon ttm implementation to move pages if * registered as the asic copy callback. */ -int si_copy_dma (struct radeon_device *rdev, -uint64_t src_offset,uint64_t dst_offset, -unsigned num_gpu_pages, -struct radeon_fence **fence) +struct radeon_fence *si_copy_dma (struct radeon_device *rdev, +uint64_t src_offset,uint64_t dst_offset, +unsigned num_gpu_pages, +struct reservation_object *resv) {struct radeon_semaphore *sem =NULL ; +struct radeon_fence *fence;int ring_index = rdev->asic->copy.dma_ring_index;struct radeon_ring *ring = &rdev->ring[ring_index];u32 size_in_bytes, cur_size_in_bytes;@@ -239,7 +240,7 @@ int si_copy_dma(struct radeon_device *rdev, r =radeon_semaphore_create (rdev, &sem);if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r); -return r; +return ERR_PTR (r); } size_in_bytes = (num_gpu_pages <<RADEON_GPU_PAGE_SHIFT );@@ -248,10 +249,10 @@ int si_copy_dma(struct radeon_device *rdev,if (r) {DRM_ERROR ("radeon: moving bo (%d).\n" , r);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); } -radeon_semaphore_sync_to (sem, *fence); +radeon_semaphore_sync_resv (sem, resv, false);radeon_semaphore_sync_rings (rdev, sem, ring->idx);for (i =0 ; i < num_loops; i++) {@@ -268,16 +269,16 @@ int si_copy_dma(struct radeon_device *rdev, dst_offset += cur_size_in_bytes; } - r =radeon_fence_emit (rdev, fence, ring->idx); + r =radeon_fence_emit (rdev, &fence, ring->idx);if (r) {radeon_ring_unlock_undo (rdev, ring);radeon_semaphore_free (rdev, &sem,NULL ); -return r; +return ERR_PTR (r); }radeon_ring_unlock_commit (rdev, ring, false); -radeon_semaphore_free (rdev, &sem, *fence); +radeon_semaphore_free (rdev, &sem, fence); -return r; +return fence; } --1.9.1
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/3 drm/radeon: allow concurrent buffer reads
In reply to Christian KönigFrom: Christian König <[email protected]>
--- drivers/gpu/drm/radeon/radeon_cs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_cs.c +3 -2
@@ -183,7 +183,7 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p) } p->relocs[i].tv.bo = &p->relocs[i].robj->tbo; - p->relocs[i].tv.shared = false; + p->relocs[i].tv.shared = !r->write_domain; p->relocs[i].handle = r->handle; radeon_cs_buckets_add(&buckets, &p->relocs[i].tv.head,
@@ -260,7 +260,8 @@ static void radeon_cs_sync_rings(struct radeon_cs_parser *p)continue ; resv = p->relocs[i].robj->tbo.resv; -radeon_semaphore_sync_resv (p->ib.semaphore, resv, false); +radeon_semaphore_sync_resv (p->ib.semaphore, resv, + p->relocs[i].tv.shared); } }
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 3/3] drm/radeon: allow concurrent buffer reads
Quoted 3 lines · Christian König
From: Christian König <[email protected]>
Signed-off-by Christian König <[email protected]>
Quoted 30 lines
--- drivers/gpu/drm/radeon/radeon_cs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/gpu/drm/radeon/radeon_cs.c +3
-3@@ -183,7 +183,7 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p) } p->relocs[i].tv.bo = &p->relocs[i].robj->tbo; - p->relocs[i].tv.shared = false; + p->relocs[i].tv.shared = !r->write_domain; p->relocs[i].handle = r->handle; radeon_cs_buckets_add(&buckets, &p->relocs[i].tv.head,@@ -260,7 +260,8 @@ static void radeon_cs_sync_rings(struct radeon_cs_parser *p)continue ; resv = p->relocs[i].robj->tbo.resv; -radeon_semaphore_sync_resv (p->ib.semaphore, resv, false); +radeon_semaphore_sync_resv (p->ib.semaphore, resv, + p->relocs[i].tv.shared); } } --1.9.1
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 6 lines · Christian König
From: Christian König <[email protected]>
This patch adds a new flag to the
ttm_validate_bufferlist to add the fence as shared to the reservation object.Signed-off-by Christian König <[email protected]>
Quoted 194 lines
--- drivers/gpu/drm/qxl/qxl_release.c | 1 + drivers/gpu/drm/radeon/radeon_cs.c | 1 + drivers/gpu/drm/radeon/radeon_vm.c | 3 +++ drivers/gpu/drm/ttm/ttm_execbuf_util.c | 18 +++++++++++++++--- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 3 +++ drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 5 +++++ include/drm/ttm/ttm_execbuf_util.h | 2 ++ 7 files changed, 30 insertions(+), 3 deletions(-)drivers/gpu/drm/qxl/qxl_release.c +1
-0@@ -226,6 +226,7 @@ int qxl_release_list_add(struct qxl_release *release, struct qxl_bo *bo)qxl_bo_ref (bo); entry->tv.bo = &bo->tbo; + entry->tv.shared = false;list_add_tail (&entry->tv.head, &release->bos);return 0 ; }drivers/gpu/drm/radeon/radeon_cs.c +1
-0@@ -183,6 +183,7 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p) } p->relocs[i].tv.bo = &p->relocs[i].robj->tbo; + p->relocs[i].tv.shared = false; p->relocs[i].handle = r->handle; radeon_cs_buckets_add(&buckets, &p->relocs[i].tv.head,drivers/gpu/drm/radeon/radeon_vm.c +3
-0@@ -143,6 +143,7 @@ struct radeon_cs_reloc *radeon_vm_get_bos(struct radeon_device *rdev, list[0 ].prefered_domains =RADEON_GEM_DOMAIN_VRAM ; list[0 ].allowed_domains =RADEON_GEM_DOMAIN_VRAM ; list[0 ].tv.bo = &vm->page_directory->tbo; + list[0 ].tv.shared = false; list[0 ].tiling_flags =0 ; list[0 ].handle =0 ;list_add (&list[0 ].tv.head, head);@@ -156,6 +157,7 @@ struct radeon_cs_reloc *radeon_vm_get_bos(struct radeon_device *rdev, list[idx].prefered_domains =RADEON_GEM_DOMAIN_VRAM ; list[idx].allowed_domains =RADEON_GEM_DOMAIN_VRAM ; list[idx].tv.bo = &list[idx].robj->tbo; + list[idx].tv.shared = false; list[idx].tiling_flags =0 ; list[idx].handle =0 ;list_add (&list[idx++].tv.head, head);@@ -395,6 +397,7 @@ static int radeon_vm_clear_bo(struct radeon_device *rdev,memset (&tv,0 ,sizeof (tv)); tv.bo = &bo->tbo; + tv.shared = false;INIT_LIST_HEAD (&head);list_add (&tv.head, &head);drivers/gpu/drm/ttm/ttm_execbuf_util.c +15
-3@@ -119,8 +119,14 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket, ret = -EBUSY ; } -if (!ret) -continue ; +if (!ret) { +if (!entry->shared) +continue ; + + ret =reservation_object_reserve_shared (bo->resv); +if (!ret) +continue ; + }/* uh oh, we lost out, drop every reservation and try * to only reserve this buffer, then start over if @@ -136,6 +142,9 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket, ret =0 ; } +if (!ret && entry->shared) + ret =reservation_object_reserve_shared (bo->resv); +if (unlikely (ret !=0 )) {if (ret == -EINTR ) ret = -ERESTARTSYS ;@@ -183,7 +192,10 @@ void ttm_eu_fence_buffer_objects(struct ww_acquire_ctx *ticket,list_for_each_entry (entry, list, head) { bo = entry->bo; -reservation_object_add_excl_fence (bo->resv, fence); +if (entry->shared) +reservation_object_add_shared_fence (bo->resv, fence); +else +reservation_object_add_excl_fence (bo->resv, fence);ttm_bo_add_to_lru (bo);__ttm_bo_unreserve (bo); }drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +3
-0@@ -346,6 +346,7 @@ static int vmw_bo_to_validate_list(struct vmw_sw_context *sw_context, ++sw_context->cur_val_buf; val_buf = &vval_buf->base; val_buf->bo =ttm_bo_reference (bo); + val_buf->shared = false;list_add_tail (&val_buf->head, &sw_context->validate_nodes); vval_buf->validate_as_mob = validate_as_mob; }@@ -2670,9 +2671,11 @@ void __vmw_execbuf_release_pinned_bo(struct vmw_private *dev_priv,INIT_LIST_HEAD (&validate_list); pinned_val.bo =ttm_bo_reference (dev_priv->pinned_bo); + pinned_val.shared = false;list_add_tail (&pinned_val.head, &validate_list); query_val.bo =ttm_bo_reference (dev_priv->dummy_query_bo); + query_val.shared = false;list_add_tail (&query_val.head, &validate_list); ret =ttm_eu_reserve_buffers (&ticket, &validate_list, false);drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +5
-0@@ -133,6 +133,7 @@ static void vmw_resource_release(struct kref *kref)struct ttm_validate_buffer val_buf; val_buf.bo = bo; + val_buf.shared = false; res->func->unbind (res, false, &val_buf); } res->backup_dirty = false;@@ -1219,6 +1220,7 @@ vmw_resource_check_buffer(struct vmw_resource *res,INIT_LIST_HEAD (&val_list); val_buf->bo =ttm_bo_reference (&res->backup->base); + val_buf->shared = false;list_add_tail (&val_buf->head, &val_list); ret =ttm_eu_reserve_buffers (NULL , &val_list, interruptible);if (unlikely (ret !=0 ))@@ -1312,6 +1314,7 @@ int vmw_resource_do_evict(struct vmw_resource *res, bool interruptible)BUG_ON (!func->may_evict); val_buf.bo =NULL ; + val_buf.shared = false; ret =vmw_resource_check_buffer (res, interruptible, &val_buf);if (unlikely (ret !=0 ))return ret;@@ -1357,6 +1360,7 @@ int vmw_resource_validate(struct vmw_resource *res)return 0 ; val_buf.bo =NULL ; + val_buf.shared = false;if (res->backup) val_buf.bo = &res->backup->base; do {@@ -1474,6 +1478,7 @@ void vmw_resource_move_notify(struct ttm_buffer_object *bo,struct ttm_validate_buffer val_buf; val_buf.bo = bo; + val_buf.shared = false;list_for_each_entry_safe (res, n, &dma_buf->res_list, mob_head) {include/drm/ttm/ttm_execbuf_util.h +2
-1@@ -39,11 +39,13 @@* * @head: list head for thread-private list. * @bo: refcounted buffer object pointer. +* @shared: should the fence be added shared? */ struct ttm_validate_buffer {struct list_head head;struct ttm_buffer_object *bo; +bool shared; };/** -- 1.9.1
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave any opinion on this patch set? Are you ok with me including it in my next drm-next pull request? It'd be nice to get some additional review on the ttm changes, but it shouldn't really affect any other drivers unless they enable shared fences for concurrent buffer reads. We'd like to get this in since it avoid unnecessary serialization of the command stream when a buffer is read by multiple engines.
Alex
Quoted 200 lines · Alex Deucher
Quoted 6 lines · Christian König
From: Christian König <[email protected]>
This patch adds a new flag to the
ttm_validate_bufferlist to add the fence as shared to the reservation object.Signed-off-by Christian König <[email protected]>Reviewed-by Alex Deucher <[email protected]>Quoted 190 lines
--- drivers/gpu/drm/qxl/qxl_release.c | 1 + drivers/gpu/drm/radeon/radeon_cs.c | 1 + drivers/gpu/drm/radeon/radeon_vm.c | 3 +++ drivers/gpu/drm/ttm/ttm_execbuf_util.c | 18 +++++++++++++++--- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 3 +++ drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 5 +++++ include/drm/ttm/ttm_execbuf_util.h | 2 ++ 7 files changed, 30 insertions(+), 3 deletions(-)drivers/gpu/drm/qxl/qxl_release.c +1
-0@@ -226,6 +226,7 @@ int qxl_release_list_add(struct qxl_release *release, struct qxl_bo *bo)qxl_bo_ref (bo); entry->tv.bo = &bo->tbo; + entry->tv.shared = false;list_add_tail (&entry->tv.head, &release->bos);return 0 ; }drivers/gpu/drm/radeon/radeon_cs.c +1
-0@@ -183,6 +183,7 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p) } p->relocs[i].tv.bo = &p->relocs[i].robj->tbo; + p->relocs[i].tv.shared = false; p->relocs[i].handle = r->handle; radeon_cs_buckets_add(&buckets, &p->relocs[i].tv.head,drivers/gpu/drm/radeon/radeon_vm.c +3
-0@@ -143,6 +143,7 @@ struct radeon_cs_reloc *radeon_vm_get_bos(struct radeon_device *rdev, list[0 ].prefered_domains =RADEON_GEM_DOMAIN_VRAM ; list[0 ].allowed_domains =RADEON_GEM_DOMAIN_VRAM ; list[0 ].tv.bo = &vm->page_directory->tbo; + list[0 ].tv.shared = false; list[0 ].tiling_flags =0 ; list[0 ].handle =0 ;list_add (&list[0 ].tv.head, head);@@ -156,6 +157,7 @@ struct radeon_cs_reloc *radeon_vm_get_bos(struct radeon_device *rdev, list[idx].prefered_domains =RADEON_GEM_DOMAIN_VRAM ; list[idx].allowed_domains =RADEON_GEM_DOMAIN_VRAM ; list[idx].tv.bo = &list[idx].robj->tbo; + list[idx].tv.shared = false; list[idx].tiling_flags =0 ; list[idx].handle =0 ;list_add (&list[idx++].tv.head, head);@@ -395,6 +397,7 @@ static int radeon_vm_clear_bo(struct radeon_device *rdev,memset (&tv,0 ,sizeof (tv)); tv.bo = &bo->tbo; + tv.shared = false;INIT_LIST_HEAD (&head);list_add (&tv.head, &head);drivers/gpu/drm/ttm/ttm_execbuf_util.c +15
-3@@ -119,8 +119,14 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket, ret = -EBUSY ; } -if (!ret) -continue ; +if (!ret) { +if (!entry->shared) +continue ; + + ret =reservation_object_reserve_shared (bo->resv); +if (!ret) +continue ; + }/* uh oh, we lost out, drop every reservation and try * to only reserve this buffer, then start over if @@ -136,6 +142,9 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket, ret =0 ; } +if (!ret && entry->shared) + ret =reservation_object_reserve_shared (bo->resv); +if (unlikely (ret !=0 )) {if (ret == -EINTR ) ret = -ERESTARTSYS ;@@ -183,7 +192,10 @@ void ttm_eu_fence_buffer_objects(struct ww_acquire_ctx *ticket,list_for_each_entry (entry, list, head) { bo = entry->bo; -reservation_object_add_excl_fence (bo->resv, fence); +if (entry->shared) +reservation_object_add_shared_fence (bo->resv, fence); +else +reservation_object_add_excl_fence (bo->resv, fence);ttm_bo_add_to_lru (bo);__ttm_bo_unreserve (bo); }drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +3
-0@@ -346,6 +346,7 @@ static int vmw_bo_to_validate_list(struct vmw_sw_context *sw_context, ++sw_context->cur_val_buf; val_buf = &vval_buf->base; val_buf->bo =ttm_bo_reference (bo); + val_buf->shared = false;list_add_tail (&val_buf->head, &sw_context->validate_nodes); vval_buf->validate_as_mob = validate_as_mob; }@@ -2670,9 +2671,11 @@ void __vmw_execbuf_release_pinned_bo(struct vmw_private *dev_priv,INIT_LIST_HEAD (&validate_list); pinned_val.bo =ttm_bo_reference (dev_priv->pinned_bo); + pinned_val.shared = false;list_add_tail (&pinned_val.head, &validate_list); query_val.bo =ttm_bo_reference (dev_priv->dummy_query_bo); + query_val.shared = false;list_add_tail (&query_val.head, &validate_list); ret =ttm_eu_reserve_buffers (&ticket, &validate_list, false);drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +5
-0@@ -133,6 +133,7 @@ static void vmw_resource_release(struct kref *kref)struct ttm_validate_buffer val_buf; val_buf.bo = bo; + val_buf.shared = false; res->func->unbind (res, false, &val_buf); } res->backup_dirty = false;@@ -1219,6 +1220,7 @@ vmw_resource_check_buffer(struct vmw_resource *res,INIT_LIST_HEAD (&val_list); val_buf->bo =ttm_bo_reference (&res->backup->base); + val_buf->shared = false;list_add_tail (&val_buf->head, &val_list); ret =ttm_eu_reserve_buffers (NULL , &val_list, interruptible);if (unlikely (ret !=0 ))@@ -1312,6 +1314,7 @@ int vmw_resource_do_evict(struct vmw_resource *res, bool interruptible)BUG_ON (!func->may_evict); val_buf.bo =NULL ; + val_buf.shared = false; ret =vmw_resource_check_buffer (res, interruptible, &val_buf);if (unlikely (ret !=0 ))return ret;@@ -1357,6 +1360,7 @@ int vmw_resource_validate(struct vmw_resource *res)return 0 ; val_buf.bo =NULL ; + val_buf.shared = false;if (res->backup) val_buf.bo = &res->backup->base; do {@@ -1474,6 +1478,7 @@ void vmw_resource_move_notify(struct ttm_buffer_object *bo,struct ttm_validate_buffer val_buf; val_buf.bo = bo; + val_buf.shared = false;list_for_each_entry_safe (res, n, &dma_buf->res_list, mob_head) {include/drm/ttm/ttm_execbuf_util.h +2
-0@@ -39,11 +39,13 @@* * @head: list head for thread-private list. * @bo: refcounted buffer object pointer. +* @shared: should the fence be added shared? */ struct ttm_validate_buffer {struct list_head head;struct ttm_buffer_object *bo; +bool shared; };
Quoted 8 lines
Quoted 8 lines
include/drm/ttm/ttm_execbuf_util.h +0
-1/** -- 1.9.1
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel