drm/amdgpu: implement and use amdgpu_bo_create_with_shadow()
Subsystems (2)
PATCH 1/1 drm/amdgpu: implement and use amdgpu_bo_create_with_shadow()
Shadow bo is only needed for some amdgpu_vm allcations. amdgpu_bo_create_with_shadow() should make it clear that a bo is for amdgpu_vm and will also remove unnecessary checks from amdgpu_bo_create().
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 26 ++++++++++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 5 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 5 ++++- 3 files changed, 31 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +22 -4
@@ -661,10 +661,7 @@ static int amdgpu_bo_create_shadow(struct amdgpu_device *adev,* @bp: parameters to be used for the buffer object * @bo_ptr: pointer to the buffer object pointer * -* Creates an &amdgpu_bo buffer object; and if requested, also creates a -* shadow object. -* Shadow object is used to backup the original buffer object, and is always -* in GTT. +* Creates an &amdgpu_bo buffer object. * * Returns: * 0 for success or a negative error code on failure.
@@ -673,6 +670,27 @@ int amdgpu_bo_create(struct amdgpu_device *adev,struct amdgpu_bo_param *bp, struct amdgpu_bo **bo_ptr) { + + return amdgpu_bo_do_create(adev, bp, bo_ptr); +} + +/** +* amdgpu_bo_create_with_shadow - create an &amdgpu_bo buffer object +* @adev: amdgpu device object +* @bp: parameters to be used for the buffer object +* @bo_ptr: pointer to the buffer object pointer +* +* Creates an &amdgpu_bo buffer object with a shadow object. +* Shadow object is used to backup the original buffer object, and is always +* in GTT. +* +* Returns: +* 0 for success or a negative error code on failure. +*/ +int amdgpu_bo_create_with_shadow (struct amdgpu_device *adev, +struct amdgpu_bo_param *bp, +struct amdgpu_bo **bo_ptr) +{u64 flags = bp->flags;int r;
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +5 -0
@@ -255,6 +255,11 @@ void amdgpu_bo_placement_from_domain(struct amdgpu_bo *abo, u32 domain);int amdgpu_bo_create (struct amdgpu_device *adev,struct amdgpu_bo_param *bp,struct amdgpu_bo **bo_ptr); + +int amdgpu_bo_create_with_shadow (struct amdgpu_device *adev, +struct amdgpu_bo_param *bp, +struct amdgpu_bo **bo_ptr); + int amdgpu_bo_create_reserved(struct amdgpu_device *adev, unsigned long size, int align, u32 domain, struct amdgpu_bo **bo_ptr,
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4 -1
@@ -920,8 +920,11 @@ static int amdgpu_vm_alloc_pts(struct amdgpu_device *adev,return 0 ;amdgpu_vm_bo_param (adev, vm, cursor->level, immediate, &bp); +if (bp.flags &AMDGPU_GEM_CREATE_SHADOW ) + r =amdgpu_bo_create_with_shadow (adev, &bp, &pt); +else + r =amdgpu_bo_create (adev, &bp, &pt); - r =amdgpu_bo_create (adev, &bp, &pt);if (r)return r;
Signature · 6 lines
2.31.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
maintainerAm 21.04.21 um 15:20 schrieb Nirmoy Das:
Quoted 4 lines
Shadow bo is only needed for some
amdgpu_vmallcations.amdgpu_bo_create_with_shadow()should make it clear that a bo is foramdgpu_vmand will also remove unnecessary checks fromamdgpu_bo_create().
I was the one suggesting to make the shadow thing general handling.
But since that never took of I think we could just move it back into the VM handling and maybe even drop the flag.
Christian.
Quoted 75 lines
Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 26 ++++++++++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 5 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 5 ++++- 3 files changed, 31 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +22
-4@@ -661,10 +661,7 @@ static int amdgpu_bo_create_shadow(struct amdgpu_device *adev,* @bp: parameters to be used for the buffer object * @bo_ptr: pointer to the buffer object pointer * -* Creates an &amdgpu_bo buffer object; and if requested, also creates a -* shadow object. -* Shadow object is used to backup the original buffer object, and is always -* in GTT. +* Creates an &amdgpu_bo buffer object. * * Returns: * 0 for success or a negative error code on failure. @@ -673,6 +670,27 @@ int amdgpu_bo_create(struct amdgpu_device *adev,struct amdgpu_bo_param *bp, struct amdgpu_bo **bo_ptr) { + + return amdgpu_bo_do_create(adev, bp, bo_ptr); +} + +/** +* amdgpu_bo_create_with_shadow - create an &amdgpu_bo buffer object +* @adev: amdgpu device object +* @bp: parameters to be used for the buffer object +* @bo_ptr: pointer to the buffer object pointer +* +* Creates an &amdgpu_bo buffer object with a shadow object. +* Shadow object is used to backup the original buffer object, and is always +* in GTT. +* +* Returns: +* 0 for success or a negative error code on failure. +*/ +int amdgpu_bo_create_with_shadow (struct amdgpu_device *adev, +struct amdgpu_bo_param *bp, +struct amdgpu_bo **bo_ptr) +{u64 flags = bp->flags;int r;drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +5
-0@@ -255,6 +255,11 @@ void amdgpu_bo_placement_from_domain(struct amdgpu_bo *abo, u32 domain);int amdgpu_bo_create (struct amdgpu_device *adev,struct amdgpu_bo_param *bp,struct amdgpu_bo **bo_ptr); + +int amdgpu_bo_create_with_shadow (struct amdgpu_device *adev, +struct amdgpu_bo_param *bp, +struct amdgpu_bo **bo_ptr); + int amdgpu_bo_create_reserved(struct amdgpu_device *adev, unsigned long size, int align, u32 domain, struct amdgpu_bo **bo_ptr,drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0@@ -920,8 +920,11 @@ static int amdgpu_vm_alloc_pts(struct amdgpu_device *adev,return 0 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_alloc_pts(struct amdgpu_device *adev, · line 930
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4
-1amdgpu_vm_bo_param (adev, vm, cursor->level, immediate, &bp); +if (bp.flags &AMDGPU_GEM_CREATE_SHADOW ) + r =amdgpu_bo_create_with_shadow (adev, &bp, &pt); +else + r =amdgpu_bo_create (adev, &bp, &pt); - r =amdgpu_bo_create (adev, &bp, &pt);if (r)return r;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx