Re: [PATCH 1/7] drm/amdgpu: add amdgpu_bo_vm bo type

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

 




On 5/21/21 4:54 PM, Alex Deucher wrote:
On Fri, May 21, 2021 at 8:46 AM Nirmoy Das <nirmoy.das@xxxxxxx> wrote:
Add new BO subcalss that will be used by amdgpu vm code.
s/subcalss/subclass/


Thanks, Alex!


Alex

Signed-off-by: Nirmoy Das <nirmoy.das@xxxxxxx>
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 32 ++++++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 10 +++++++
  2 files changed, 42 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 745fcf3ea450..61b1edcb490a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -692,6 +692,38 @@ int amdgpu_bo_create_user(struct amdgpu_device *adev,
         *ubo_ptr = to_amdgpu_bo_user(bo_ptr);
         return r;
  }
+
+/**
+ * amdgpu_bo_create_vm - create an &amdgpu_bo_vm buffer object
+ * @adev: amdgpu device object
+ * @bp: parameters to be used for the buffer object
+ * @vmbo_ptr: pointer to the buffer object pointer
+ *
+ * Create a BO to be for GPUVM.
+ *
+ * Returns:
+ * 0 for success or a negative error code on failure.
+ */
+
+int amdgpu_bo_create_vm(struct amdgpu_device *adev,
+                       struct amdgpu_bo_param *bp,
+                       struct amdgpu_bo_vm **vmbo_ptr)
+{
+       struct amdgpu_bo *bo_ptr;
+       int r;
+
+       /* bo_ptr_size will be determined by the caller and it depends on
+        * num of amdgpu_vm_pt entries.
+        */
+       BUG_ON(bp->bo_ptr_size < sizeof(struct amdgpu_bo_vm));
+       r = amdgpu_bo_create(adev, bp, &bo_ptr);
+       if (r)
+               return r;
+
+       *vmbo_ptr = to_amdgpu_bo_vm(bo_ptr);
+       return r;
+}
+
  /**
   * amdgpu_bo_validate - validate an &amdgpu_bo buffer object
   * @bo: pointer to the buffer object
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index 11480c5a2716..a7fbf5f7051e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -44,6 +44,7 @@
  #define AMDGPU_AMDKFD_CREATE_SVM_BO    (1ULL << 62)

  #define to_amdgpu_bo_user(abo) container_of((abo), struct amdgpu_bo_user, bo)
+#define to_amdgpu_bo_vm(abo) container_of((abo), struct amdgpu_bo_vm, bo)

  struct amdgpu_bo_param {
         unsigned long                   size;
@@ -125,6 +126,12 @@ struct amdgpu_bo_user {

  };

+struct amdgpu_bo_vm {
+       struct amdgpu_bo                bo;
+       struct amdgpu_bo                *shadow;
+       struct amdgpu_vm_pt             entries[];
+};
+
  static inline struct amdgpu_bo *ttm_to_amdgpu_bo(struct ttm_buffer_object *tbo)
  {
         return container_of(tbo, struct amdgpu_bo, tbo);
@@ -272,6 +279,9 @@ int amdgpu_bo_create_kernel_at(struct amdgpu_device *adev,
  int amdgpu_bo_create_user(struct amdgpu_device *adev,
                           struct amdgpu_bo_param *bp,
                           struct amdgpu_bo_user **ubo_ptr);
+int amdgpu_bo_create_vm(struct amdgpu_device *adev,
+                       struct amdgpu_bo_param *bp,
+                       struct amdgpu_bo_vm **ubo_ptr);
  void amdgpu_bo_free_kernel(struct amdgpu_bo **bo, u64 *gpu_addr,
                            void **cpu_addr);
  int amdgpu_bo_create_shadow(struct amdgpu_device *adev,
--
2.31.1

_______________________________________________
amd-gfx mailing list
amd-gfx@xxxxxxxxxxxxxxxxxxxxx
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=04%7C01%7Cnirmoy.das%40amd.com%7C87c7640809fa40c6156808d91c68614e%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637572056899554154%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=57XL2ddPiPTzp1mM7xKi6o3vHzeDHB37vOjJyxL%2FD4s%3D&amp;reserved=0
_______________________________________________
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