mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
drm/amdgpu: explicitely sync to VM updates v2
Allows us to reduce the overhead while syncing to fences a bit. v2: also drop adev parameter from the functions Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
committed by
Alex Deucher
parent
6ceeb144b1
commit
e095fc17bb
@@ -129,7 +129,8 @@ static void amdgpu_sync_keep_later(struct dma_fence **keep,
|
||||
* Tries to add the fence to an existing hash entry. Returns true when an entry
|
||||
* was found, false otherwise.
|
||||
*/
|
||||
static bool amdgpu_sync_add_later(struct amdgpu_sync *sync, struct dma_fence *f, bool explicit)
|
||||
static bool amdgpu_sync_add_later(struct amdgpu_sync *sync, struct dma_fence *f,
|
||||
bool explicit)
|
||||
{
|
||||
struct amdgpu_sync_entry *e;
|
||||
|
||||
@@ -151,19 +152,18 @@ static bool amdgpu_sync_add_later(struct amdgpu_sync *sync, struct dma_fence *f,
|
||||
* amdgpu_sync_fence - remember to sync to this fence
|
||||
*
|
||||
* @sync: sync object to add fence to
|
||||
* @fence: fence to sync to
|
||||
* @f: fence to sync to
|
||||
* @explicit: if this is an explicit dependency
|
||||
*
|
||||
* Add the fence to the sync object.
|
||||
*/
|
||||
int amdgpu_sync_fence(struct amdgpu_device *adev, struct amdgpu_sync *sync,
|
||||
struct dma_fence *f, bool explicit)
|
||||
int amdgpu_sync_fence(struct amdgpu_sync *sync, struct dma_fence *f,
|
||||
bool explicit)
|
||||
{
|
||||
struct amdgpu_sync_entry *e;
|
||||
|
||||
if (!f)
|
||||
return 0;
|
||||
if (amdgpu_sync_same_dev(adev, f) &&
|
||||
amdgpu_sync_get_owner(f) == AMDGPU_FENCE_OWNER_VM)
|
||||
amdgpu_sync_keep_later(&sync->last_vm_update, f);
|
||||
|
||||
if (amdgpu_sync_add_later(sync, f, explicit))
|
||||
return 0;
|
||||
@@ -179,6 +179,24 @@ int amdgpu_sync_fence(struct amdgpu_device *adev, struct amdgpu_sync *sync,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* amdgpu_sync_vm_fence - remember to sync to this VM fence
|
||||
*
|
||||
* @adev: amdgpu device
|
||||
* @sync: sync object to add fence to
|
||||
* @fence: the VM fence to add
|
||||
*
|
||||
* Add the fence to the sync object and remember it as VM update.
|
||||
*/
|
||||
int amdgpu_sync_vm_fence(struct amdgpu_sync *sync, struct dma_fence *fence)
|
||||
{
|
||||
if (!fence)
|
||||
return 0;
|
||||
|
||||
amdgpu_sync_keep_later(&sync->last_vm_update, fence);
|
||||
return amdgpu_sync_fence(sync, fence, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* amdgpu_sync_resv - sync to a reservation object
|
||||
*
|
||||
@@ -204,7 +222,7 @@ int amdgpu_sync_resv(struct amdgpu_device *adev,
|
||||
|
||||
/* always sync to the exclusive fence */
|
||||
f = dma_resv_get_excl(resv);
|
||||
r = amdgpu_sync_fence(adev, sync, f, false);
|
||||
r = amdgpu_sync_fence(sync, f, false);
|
||||
|
||||
flist = dma_resv_get_list(resv);
|
||||
if (!flist || r)
|
||||
@@ -239,7 +257,7 @@ int amdgpu_sync_resv(struct amdgpu_device *adev,
|
||||
continue;
|
||||
}
|
||||
|
||||
r = amdgpu_sync_fence(adev, sync, f, false);
|
||||
r = amdgpu_sync_fence(sync, f, false);
|
||||
if (r)
|
||||
break;
|
||||
}
|
||||
@@ -340,7 +358,7 @@ int amdgpu_sync_clone(struct amdgpu_sync *source, struct amdgpu_sync *clone)
|
||||
hash_for_each_safe(source->fences, i, tmp, e, node) {
|
||||
f = e->fence;
|
||||
if (!dma_fence_is_signaled(f)) {
|
||||
r = amdgpu_sync_fence(NULL, clone, f, e->explicit);
|
||||
r = amdgpu_sync_fence(clone, f, e->explicit);
|
||||
if (r)
|
||||
return r;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user