From: Jack Xiao <[email protected]>

Add the helper functions to allocate/free context metadata.

Signed-off-by: Jack Xiao <[email protected]>
Acked-by: Christian König <[email protected]>
Reviewed-by: Hawking Zhang <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 25 +++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h |  4 ++++
 2 files changed, 29 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
index fa43a7e3c9ab..6c01581e3a7b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
@@ -857,3 +857,28 @@ void amdgpu_mes_remove_ring(struct amdgpu_device *adev,
        amdgpu_ring_fini(ring);
        kfree(ring);
 }
+
+int amdgpu_mes_ctx_alloc_meta_data(struct amdgpu_device *adev,
+                                  struct amdgpu_mes_ctx_data *ctx_data)
+{
+       int r;
+
+       r = amdgpu_bo_create_kernel(adev,
+                           sizeof(struct amdgpu_mes_ctx_meta_data),
+                           PAGE_SIZE, AMDGPU_GEM_DOMAIN_GTT,
+                           &ctx_data->meta_data_obj, NULL,
+                           &ctx_data->meta_data_ptr);
+       if (!ctx_data->meta_data_obj)
+               return -ENOMEM;
+
+       memset(ctx_data->meta_data_ptr, 0,
+              sizeof(struct amdgpu_mes_ctx_meta_data));
+
+       return 0;
+}
+
+void amdgpu_mes_ctx_free_meta_data(struct amdgpu_mes_ctx_data *ctx_data)
+{
+       if (ctx_data->meta_data_obj)
+               amdgpu_bo_free_kernel(&ctx_data->meta_data_obj, NULL, NULL);
+}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h
index 37232b396b06..50d490e69cb7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h
@@ -261,4 +261,8 @@ int amdgpu_mes_add_ring(struct amdgpu_device *adev, int 
gang_id,
 void amdgpu_mes_remove_ring(struct amdgpu_device *adev,
                            struct amdgpu_ring *ring);
 
+int amdgpu_mes_ctx_alloc_meta_data(struct amdgpu_device *adev,
+                                  struct amdgpu_mes_ctx_data *ctx_data);
+void amdgpu_mes_ctx_free_meta_data(struct amdgpu_mes_ctx_data *ctx_data);
+
 #endif /* __AMDGPU_MES_H__ */
-- 
2.35.1

Reply via email to