Re: [PATCH 1/1] drm/amdgpu: implement and use amdgpu_bo_create_with_shadow()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 21.04.21 um 15:20 schrieb Nirmoy Das:
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().

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.


Signed-off-by: Nirmoy Das <nirmoy.das@xxxxxxx>
---
  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(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 1345f7eba011..608f07377d20 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -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;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index 973c88bdf37b..6a9187ca0496 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -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,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index f95bcda8463f..2770d3b8dbde 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -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;

_______________________________________________
amd-gfx mailing list
amd-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/amd-gfx



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux