mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/
synced 2026-04-18 06:33:43 -04:00
dma-buf: Rename struct fence to dma_fence
I plan to usurp the short name of struct fence for a core kernel struct, and so I need to rename the specialised fence/timeline for DMA operations to make room. A consensus was reached in https://lists.freedesktop.org/archives/dri-devel/2016-July/113083.html that making clear this fence applies to DMA operations was a good thing. Since then the patch has grown a bit as usage increases, so hopefully it remains a good thing! (v2...: rebase, rerun spatch) v3: Compile on msm, spotted a manual fixup that I broke. v4: Try again for msm, sorry Daniel coccinelle script: @@ @@ - struct fence + struct dma_fence @@ @@ - struct fence_ops + struct dma_fence_ops @@ @@ - struct fence_cb + struct dma_fence_cb @@ @@ - struct fence_array + struct dma_fence_array @@ @@ - enum fence_flag_bits + enum dma_fence_flag_bits @@ @@ ( - fence_init + dma_fence_init | - fence_release + dma_fence_release | - fence_free + dma_fence_free | - fence_get + dma_fence_get | - fence_get_rcu + dma_fence_get_rcu | - fence_put + dma_fence_put | - fence_signal + dma_fence_signal | - fence_signal_locked + dma_fence_signal_locked | - fence_default_wait + dma_fence_default_wait | - fence_add_callback + dma_fence_add_callback | - fence_remove_callback + dma_fence_remove_callback | - fence_enable_sw_signaling + dma_fence_enable_sw_signaling | - fence_is_signaled_locked + dma_fence_is_signaled_locked | - fence_is_signaled + dma_fence_is_signaled | - fence_is_later + dma_fence_is_later | - fence_later + dma_fence_later | - fence_wait_timeout + dma_fence_wait_timeout | - fence_wait_any_timeout + dma_fence_wait_any_timeout | - fence_wait + dma_fence_wait | - fence_context_alloc + dma_fence_context_alloc | - fence_array_create + dma_fence_array_create | - to_fence_array + to_dma_fence_array | - fence_is_array + dma_fence_is_array | - trace_fence_emit + trace_dma_fence_emit | - FENCE_TRACE + DMA_FENCE_TRACE | - FENCE_WARN + DMA_FENCE_WARN | - FENCE_ERR + DMA_FENCE_ERR ) ( ... ) Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk> Acked-by: Sumit Semwal <sumit.semwal@linaro.org> Acked-by: Christian König <christian.koenig@amd.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/20161025120045.28839-1-chris@chris-wilson.co.uk
This commit is contained in:
committed by
Daniel Vetter
parent
0fc4f78f44
commit
f54d186700
@@ -25,7 +25,7 @@
|
||||
* Alex Deucher
|
||||
* Jerome Glisse
|
||||
*/
|
||||
#include <linux/fence-array.h>
|
||||
#include <linux/dma-fence-array.h>
|
||||
#include <drm/drmP.h>
|
||||
#include <drm/amdgpu_drm.h>
|
||||
#include "amdgpu.h"
|
||||
@@ -194,14 +194,14 @@ static bool amdgpu_vm_is_gpu_reset(struct amdgpu_device *adev,
|
||||
* Allocate an id for the vm, adding fences to the sync obj as necessary.
|
||||
*/
|
||||
int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring,
|
||||
struct amdgpu_sync *sync, struct fence *fence,
|
||||
struct amdgpu_sync *sync, struct dma_fence *fence,
|
||||
struct amdgpu_job *job)
|
||||
{
|
||||
struct amdgpu_device *adev = ring->adev;
|
||||
uint64_t fence_context = adev->fence_context + ring->idx;
|
||||
struct fence *updates = sync->last_vm_update;
|
||||
struct dma_fence *updates = sync->last_vm_update;
|
||||
struct amdgpu_vm_id *id, *idle;
|
||||
struct fence **fences;
|
||||
struct dma_fence **fences;
|
||||
unsigned i;
|
||||
int r = 0;
|
||||
|
||||
@@ -225,17 +225,17 @@ int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring,
|
||||
if (&idle->list == &adev->vm_manager.ids_lru) {
|
||||
u64 fence_context = adev->vm_manager.fence_context + ring->idx;
|
||||
unsigned seqno = ++adev->vm_manager.seqno[ring->idx];
|
||||
struct fence_array *array;
|
||||
struct dma_fence_array *array;
|
||||
unsigned j;
|
||||
|
||||
for (j = 0; j < i; ++j)
|
||||
fence_get(fences[j]);
|
||||
dma_fence_get(fences[j]);
|
||||
|
||||
array = fence_array_create(i, fences, fence_context,
|
||||
array = dma_fence_array_create(i, fences, fence_context,
|
||||
seqno, true);
|
||||
if (!array) {
|
||||
for (j = 0; j < i; ++j)
|
||||
fence_put(fences[j]);
|
||||
dma_fence_put(fences[j]);
|
||||
kfree(fences);
|
||||
r = -ENOMEM;
|
||||
goto error;
|
||||
@@ -243,7 +243,7 @@ int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring,
|
||||
|
||||
|
||||
r = amdgpu_sync_fence(ring->adev, sync, &array->base);
|
||||
fence_put(&array->base);
|
||||
dma_fence_put(&array->base);
|
||||
if (r)
|
||||
goto error;
|
||||
|
||||
@@ -257,7 +257,7 @@ int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring,
|
||||
/* Check if we can use a VMID already assigned to this VM */
|
||||
i = ring->idx;
|
||||
do {
|
||||
struct fence *flushed;
|
||||
struct dma_fence *flushed;
|
||||
|
||||
id = vm->ids[i++];
|
||||
if (i == AMDGPU_MAX_RINGS)
|
||||
@@ -279,12 +279,12 @@ int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring,
|
||||
continue;
|
||||
|
||||
if (id->last_flush->context != fence_context &&
|
||||
!fence_is_signaled(id->last_flush))
|
||||
!dma_fence_is_signaled(id->last_flush))
|
||||
continue;
|
||||
|
||||
flushed = id->flushed_updates;
|
||||
if (updates &&
|
||||
(!flushed || fence_is_later(updates, flushed)))
|
||||
(!flushed || dma_fence_is_later(updates, flushed)))
|
||||
continue;
|
||||
|
||||
/* Good we can use this VMID. Remember this submission as
|
||||
@@ -315,14 +315,14 @@ int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring,
|
||||
if (r)
|
||||
goto error;
|
||||
|
||||
fence_put(id->first);
|
||||
id->first = fence_get(fence);
|
||||
dma_fence_put(id->first);
|
||||
id->first = dma_fence_get(fence);
|
||||
|
||||
fence_put(id->last_flush);
|
||||
dma_fence_put(id->last_flush);
|
||||
id->last_flush = NULL;
|
||||
|
||||
fence_put(id->flushed_updates);
|
||||
id->flushed_updates = fence_get(updates);
|
||||
dma_fence_put(id->flushed_updates);
|
||||
id->flushed_updates = dma_fence_get(updates);
|
||||
|
||||
id->pd_gpu_addr = job->vm_pd_addr;
|
||||
id->current_gpu_reset_count = atomic_read(&adev->gpu_reset_counter);
|
||||
@@ -393,7 +393,7 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job)
|
||||
|
||||
if (ring->funcs->emit_vm_flush && (job->vm_needs_flush ||
|
||||
amdgpu_vm_is_gpu_reset(adev, id))) {
|
||||
struct fence *fence;
|
||||
struct dma_fence *fence;
|
||||
|
||||
trace_amdgpu_vm_flush(job->vm_pd_addr, ring->idx, job->vm_id);
|
||||
amdgpu_ring_emit_vm_flush(ring, job->vm_id, job->vm_pd_addr);
|
||||
@@ -403,7 +403,7 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job)
|
||||
return r;
|
||||
|
||||
mutex_lock(&adev->vm_manager.lock);
|
||||
fence_put(id->last_flush);
|
||||
dma_fence_put(id->last_flush);
|
||||
id->last_flush = fence;
|
||||
mutex_unlock(&adev->vm_manager.lock);
|
||||
}
|
||||
@@ -537,7 +537,7 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,
|
||||
struct amdgpu_bo *bo)
|
||||
{
|
||||
struct amdgpu_ring *ring;
|
||||
struct fence *fence = NULL;
|
||||
struct dma_fence *fence = NULL;
|
||||
struct amdgpu_job *job;
|
||||
struct amdgpu_pte_update_params params;
|
||||
unsigned entries;
|
||||
@@ -578,7 +578,7 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,
|
||||
goto error_free;
|
||||
|
||||
amdgpu_bo_fence(bo, fence, true);
|
||||
fence_put(fence);
|
||||
dma_fence_put(fence);
|
||||
return 0;
|
||||
|
||||
error_free:
|
||||
@@ -625,7 +625,7 @@ static int amdgpu_vm_update_pd_or_shadow(struct amdgpu_device *adev,
|
||||
unsigned count = 0, pt_idx, ndw;
|
||||
struct amdgpu_job *job;
|
||||
struct amdgpu_pte_update_params params;
|
||||
struct fence *fence = NULL;
|
||||
struct dma_fence *fence = NULL;
|
||||
|
||||
int r;
|
||||
|
||||
@@ -714,9 +714,9 @@ static int amdgpu_vm_update_pd_or_shadow(struct amdgpu_device *adev,
|
||||
goto error_free;
|
||||
|
||||
amdgpu_bo_fence(pd, fence, true);
|
||||
fence_put(vm->page_directory_fence);
|
||||
vm->page_directory_fence = fence_get(fence);
|
||||
fence_put(fence);
|
||||
dma_fence_put(vm->page_directory_fence);
|
||||
vm->page_directory_fence = dma_fence_get(fence);
|
||||
dma_fence_put(fence);
|
||||
|
||||
} else {
|
||||
amdgpu_job_free(job);
|
||||
@@ -929,20 +929,20 @@ static void amdgpu_vm_frag_ptes(struct amdgpu_pte_update_params *params,
|
||||
* Returns 0 for success, -EINVAL for failure.
|
||||
*/
|
||||
static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
|
||||
struct fence *exclusive,
|
||||
struct dma_fence *exclusive,
|
||||
uint64_t src,
|
||||
dma_addr_t *pages_addr,
|
||||
struct amdgpu_vm *vm,
|
||||
uint64_t start, uint64_t last,
|
||||
uint32_t flags, uint64_t addr,
|
||||
struct fence **fence)
|
||||
struct dma_fence **fence)
|
||||
{
|
||||
struct amdgpu_ring *ring;
|
||||
void *owner = AMDGPU_FENCE_OWNER_VM;
|
||||
unsigned nptes, ncmds, ndw;
|
||||
struct amdgpu_job *job;
|
||||
struct amdgpu_pte_update_params params;
|
||||
struct fence *f = NULL;
|
||||
struct dma_fence *f = NULL;
|
||||
int r;
|
||||
|
||||
memset(¶ms, 0, sizeof(params));
|
||||
@@ -1045,10 +1045,10 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
|
||||
|
||||
amdgpu_bo_fence(vm->page_directory, f, true);
|
||||
if (fence) {
|
||||
fence_put(*fence);
|
||||
*fence = fence_get(f);
|
||||
dma_fence_put(*fence);
|
||||
*fence = dma_fence_get(f);
|
||||
}
|
||||
fence_put(f);
|
||||
dma_fence_put(f);
|
||||
return 0;
|
||||
|
||||
error_free:
|
||||
@@ -1074,13 +1074,13 @@ error_free:
|
||||
* Returns 0 for success, -EINVAL for failure.
|
||||
*/
|
||||
static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,
|
||||
struct fence *exclusive,
|
||||
struct dma_fence *exclusive,
|
||||
uint32_t gtt_flags,
|
||||
dma_addr_t *pages_addr,
|
||||
struct amdgpu_vm *vm,
|
||||
struct amdgpu_bo_va_mapping *mapping,
|
||||
uint32_t flags, uint64_t addr,
|
||||
struct fence **fence)
|
||||
struct dma_fence **fence)
|
||||
{
|
||||
const uint64_t max_size = 64ULL * 1024ULL * 1024ULL / AMDGPU_GPU_PAGE_SIZE;
|
||||
|
||||
@@ -1147,7 +1147,7 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev,
|
||||
dma_addr_t *pages_addr = NULL;
|
||||
uint32_t gtt_flags, flags;
|
||||
struct ttm_mem_reg *mem;
|
||||
struct fence *exclusive;
|
||||
struct dma_fence *exclusive;
|
||||
uint64_t addr;
|
||||
int r;
|
||||
|
||||
@@ -1547,7 +1547,7 @@ void amdgpu_vm_bo_rmv(struct amdgpu_device *adev,
|
||||
kfree(mapping);
|
||||
}
|
||||
|
||||
fence_put(bo_va->last_pt_update);
|
||||
dma_fence_put(bo_va->last_pt_update);
|
||||
kfree(bo_va);
|
||||
}
|
||||
|
||||
@@ -1709,7 +1709,7 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)
|
||||
|
||||
amdgpu_bo_unref(&vm->page_directory->shadow);
|
||||
amdgpu_bo_unref(&vm->page_directory);
|
||||
fence_put(vm->page_directory_fence);
|
||||
dma_fence_put(vm->page_directory_fence);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1733,7 +1733,8 @@ void amdgpu_vm_manager_init(struct amdgpu_device *adev)
|
||||
&adev->vm_manager.ids_lru);
|
||||
}
|
||||
|
||||
adev->vm_manager.fence_context = fence_context_alloc(AMDGPU_MAX_RINGS);
|
||||
adev->vm_manager.fence_context =
|
||||
dma_fence_context_alloc(AMDGPU_MAX_RINGS);
|
||||
for (i = 0; i < AMDGPU_MAX_RINGS; ++i)
|
||||
adev->vm_manager.seqno[i] = 0;
|
||||
|
||||
@@ -1755,8 +1756,8 @@ void amdgpu_vm_manager_fini(struct amdgpu_device *adev)
|
||||
for (i = 0; i < AMDGPU_NUM_VM; ++i) {
|
||||
struct amdgpu_vm_id *id = &adev->vm_manager.ids[i];
|
||||
|
||||
fence_put(adev->vm_manager.ids[i].first);
|
||||
dma_fence_put(adev->vm_manager.ids[i].first);
|
||||
amdgpu_sync_free(&adev->vm_manager.ids[i].active);
|
||||
fence_put(id->flushed_updates);
|
||||
dma_fence_put(id->flushed_updates);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user