Message ID | 1549660894-4080-1-git-send-email-Felix.Kuehling@amd.com |
---|---|
State | New |
Series | "Series without cover letter" |
Headers | show |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index fd9c4be..ec9e450 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -1285,6 +1285,30 @@ void amdgpu_bo_fence(struct amdgpu_bo *bo, struct dma_fence *fence, } /** + * amdgpu_sync_wait_resv - Wait for BO reservation fences + * + * @bo: buffer object + * @owner: fence owner + * @intr: Whether the wait is interruptible + * + * Returns: + * 0 on success, errno otherwise. + */ +int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr) +{ + struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); + struct amdgpu_sync sync; + int r; + + amdgpu_sync_create(&sync); + amdgpu_sync_resv(adev, &sync, bo->tbo.resv, owner, false); + r = amdgpu_sync_wait(&sync, intr); + amdgpu_sync_free(&sync); + + return r; +} + +/** * amdgpu_bo_gpu_offset - return GPU offset of bo * @bo: amdgpu object for which we query the offset * diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h index 9291c2f..220a6a7 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h @@ -266,6 +266,7 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo, int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo); void amdgpu_bo_fence(struct amdgpu_bo *bo, struct dma_fence *fence, bool shared); +int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr); u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo); int amdgpu_bo_validate(struct amdgpu_bo *bo); int amdgpu_bo_restore_shadow(struct amdgpu_bo *shadow, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 5d7c191..488d913 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -1330,31 +1330,6 @@ static void amdgpu_vm_cpu_set_ptes(struct amdgpu_pte_update_params *params, } } - -/** - * amdgpu_vm_wait_pd - Wait for PT BOs to be free. - * - * @adev: amdgpu_device pointer - * @vm: related vm - * @owner: fence owner - * - * Returns: - * 0 on success, errno otherwise. - */ -static int amdgpu_vm_wait_pd(struct amdgpu_device *adev, struct amdgpu_vm *vm, - void *owner) -{ - struct amdgpu_sync sync; - int r; - - amdgpu_sync_create(&sync); - amdgpu_sync_resv(adev, &sync, vm->root.base.bo->tbo.resv, owner, false); - r = amdgpu_sync_wait(&sync, true); - amdgpu_sync_free(&sync); - - return r; -} - /** * amdgpu_vm_update_func - helper to call update function * @@ -1449,7 +1424,8 @@ int amdgpu_vm_update_directories(struct amdgpu_device *adev, params.adev = adev; if (vm->use_cpu_for_update) { - r = amdgpu_vm_wait_pd(adev, vm, AMDGPU_FENCE_OWNER_VM); + r = amdgpu_bo_sync_wait(vm->root.base.bo, + AMDGPU_FENCE_OWNER_VM, true); if (unlikely(r)) return r; @@ -1782,7 +1758,7 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, /* Wait for PT BOs to be idle. PTs share the same resv. object * as the root PD BO */ - r = amdgpu_vm_wait_pd(adev, vm, owner); + r = amdgpu_bo_sync_wait(vm->root.base.bo, owner, true); if (unlikely(r)) return r;
Am 08.02.19 um 22:21 schrieb Kuehling, Felix: > Creates a temporary sync object to wait for the BO reservation. This > generalizes amdgpu_vm_wait_pd. > > Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 24 ++++++++++++++++++++++++ > drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 + > drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 30 +++--------------------------- > 3 files changed, 28 insertions(+), 27 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c > index fd9c4be..ec9e450 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c > @@ -1285,6 +1285,30 @@ void amdgpu_bo_fence(struct amdgpu_bo *bo, struct dma_fence *fence, > } > > /** > + * amdgpu_sync_wait_resv - Wait for BO reservation fences > + * > + * @bo: buffer object > + * @owner: fence owner > + * @intr: Whether the wait is interruptible > + * > + * Returns: > + * 0 on success, errno otherwise. > + */ > +int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr) > +{ > + struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); > + struct amdgpu_sync sync; > + int r; > + > + amdgpu_sync_create(&sync); > + amdgpu_sync_resv(adev, &sync, bo->tbo.resv, owner, false); > + r = amdgpu_sync_wait(&sync, intr); > + amdgpu_sync_free(&sync); > + > + return r; > +} > + > +/** > * amdgpu_bo_gpu_offset - return GPU offset of bo > * @bo: amdgpu object for which we query the offset > * > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h > index 9291c2f..220a6a7 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h > @@ -266,6 +266,7 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo, > int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo); > void amdgpu_bo_fence(struct amdgpu_bo *bo, struct dma_fence *fence, > bool shared); > +int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr); > u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo); > int amdgpu_bo_validate(struct amdgpu_bo *bo); > int amdgpu_bo_restore_shadow(struct amdgpu_bo *shadow, > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c > index 5d7c191..488d913 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c > @@ -1330,31 +1330,6 @@ static void amdgpu_vm_cpu_set_ptes(struct amdgpu_pte_update_params *params, > } > } > > - > -/** > - * amdgpu_vm_wait_pd - Wait for PT BOs to be free. > - * > - * @adev: amdgpu_device pointer > - * @vm: related vm > - * @owner: fence owner > - * > - * Returns: > - * 0 on success, errno otherwise. > - */ > -static int amdgpu_vm_wait_pd(struct amdgpu_device *adev, struct amdgpu_vm *vm, > - void *owner) > -{ > - struct amdgpu_sync sync; > - int r; > - > - amdgpu_sync_create(&sync); > - amdgpu_sync_resv(adev, &sync, vm->root.base.bo->tbo.resv, owner, false); > - r = amdgpu_sync_wait(&sync, true); > - amdgpu_sync_free(&sync); > - > - return r; > -} > - > /** > * amdgpu_vm_update_func - helper to call update function > * > @@ -1449,7 +1424,8 @@ int amdgpu_vm_update_directories(struct amdgpu_device *adev, > params.adev = adev; > > if (vm->use_cpu_for_update) { > - r = amdgpu_vm_wait_pd(adev, vm, AMDGPU_FENCE_OWNER_VM); > + r = amdgpu_bo_sync_wait(vm->root.base.bo, > + AMDGPU_FENCE_OWNER_VM, true); > if (unlikely(r)) > return r; > > @@ -1782,7 +1758,7 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, > /* Wait for PT BOs to be idle. PTs share the same resv. object > * as the root PD BO > */ > - r = amdgpu_vm_wait_pd(adev, vm, owner); > + r = amdgpu_bo_sync_wait(vm->root.base.bo, owner, true); > if (unlikely(r)) > return r; >
Creates a temporary sync object to wait for the BO reservation. This generalizes amdgpu_vm_wait_pd. Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com> --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 24 ++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 30 +++--------------------------- 3 files changed, 28 insertions(+), 27 deletions(-)