mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
drm/amdgpu: Get rid of dep_sync as a seperate object.
Instead mark fence as explicit in it's amdgpu_sync_entry. v2: Fix use after free bug and add new parameter description. Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
committed by
Alex Deucher
parent
97489129c2
commit
cebb52b7bc
@@ -35,6 +35,7 @@
|
||||
struct amdgpu_sync_entry {
|
||||
struct hlist_node node;
|
||||
struct dma_fence *fence;
|
||||
bool explicit;
|
||||
};
|
||||
|
||||
static struct kmem_cache *amdgpu_sync_slab;
|
||||
@@ -141,7 +142,7 @@ static bool amdgpu_sync_add_later(struct amdgpu_sync *sync, struct dma_fence *f)
|
||||
*
|
||||
*/
|
||||
int amdgpu_sync_fence(struct amdgpu_device *adev, struct amdgpu_sync *sync,
|
||||
struct dma_fence *f)
|
||||
struct dma_fence *f, bool explicit)
|
||||
{
|
||||
struct amdgpu_sync_entry *e;
|
||||
|
||||
@@ -159,6 +160,8 @@ int amdgpu_sync_fence(struct amdgpu_device *adev, struct amdgpu_sync *sync,
|
||||
if (!e)
|
||||
return -ENOMEM;
|
||||
|
||||
e->explicit = explicit;
|
||||
|
||||
hash_add(sync->fences, &e->node, f->context);
|
||||
e->fence = dma_fence_get(f);
|
||||
return 0;
|
||||
@@ -189,7 +192,7 @@ int amdgpu_sync_resv(struct amdgpu_device *adev,
|
||||
|
||||
/* always sync to the exclusive fence */
|
||||
f = reservation_object_get_excl(resv);
|
||||
r = amdgpu_sync_fence(adev, sync, f);
|
||||
r = amdgpu_sync_fence(adev, sync, f, false);
|
||||
|
||||
if (explicit_sync)
|
||||
return r;
|
||||
@@ -220,7 +223,7 @@ int amdgpu_sync_resv(struct amdgpu_device *adev,
|
||||
continue;
|
||||
}
|
||||
|
||||
r = amdgpu_sync_fence(adev, sync, f);
|
||||
r = amdgpu_sync_fence(adev, sync, f, false);
|
||||
if (r)
|
||||
break;
|
||||
}
|
||||
@@ -275,19 +278,21 @@ struct dma_fence *amdgpu_sync_peek_fence(struct amdgpu_sync *sync,
|
||||
* amdgpu_sync_get_fence - get the next fence from the sync object
|
||||
*
|
||||
* @sync: sync object to use
|
||||
* @explicit: true if the next fence is explicit
|
||||
*
|
||||
* Get and removes the next fence from the sync object not signaled yet.
|
||||
*/
|
||||
struct dma_fence *amdgpu_sync_get_fence(struct amdgpu_sync *sync)
|
||||
struct dma_fence *amdgpu_sync_get_fence(struct amdgpu_sync *sync, bool *explicit)
|
||||
{
|
||||
struct amdgpu_sync_entry *e;
|
||||
struct hlist_node *tmp;
|
||||
struct dma_fence *f;
|
||||
int i;
|
||||
|
||||
hash_for_each_safe(sync->fences, i, tmp, e, node) {
|
||||
|
||||
f = e->fence;
|
||||
if (explicit)
|
||||
*explicit = e->explicit;
|
||||
|
||||
hash_del(&e->node);
|
||||
kmem_cache_free(amdgpu_sync_slab, e);
|
||||
|
||||
Reference in New Issue
Block a user