drm/amdgpu/mes: add helper functions to alloc/free ctx metadata
authorJack Xiao <Jack.Xiao@amd.com>
Fri, 27 Mar 2020 10:11:15 +0000 (18:11 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 4 May 2022 14:43:52 +0000 (10:43 -0400)
Add the helper functions to allocate/free context metadata.

Signed-off-by: Jack Xiao <Jack.Xiao@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h

index fa43a7e..6c01581 100644 (file)
@@ -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);
+}
index b687198..828d52c 100644 (file)
@@ -262,4 +262,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__ */