[PATCH 66/73] drm/amdgpu/mes: map ctx metadata for mes self test

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

 



From: Jack Xiao <Jack.Xiao@xxxxxxx>

Map ctx metadata for mes self test.

Signed-off-by: Jack Xiao <Jack.Xiao@xxxxxxx>
Acked-by: Christian König <christian.koenig@xxxxxxx>
Reviewed-by: Hawking Zhang <Hawking.Zhang@xxxxxxx>
Signed-off-by: Alex Deucher <alexander.deucher@xxxxxxx>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 37 +++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
index 6c01581e3a7b..b440b36dd98a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
@@ -882,3 +882,40 @@ 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);
 }
+
+static int amdgpu_mes_test_map_ctx_meta_data(struct amdgpu_device *adev,
+				     struct amdgpu_vm *vm,
+				     struct amdgpu_mes_ctx_data *ctx_data)
+{
+	struct amdgpu_bo_va *meta_data_va = NULL;
+	uint64_t meta_data_addr = AMDGPU_VA_RESERVED_SIZE;
+	int r;
+
+	r = amdgpu_map_static_csa(adev, vm, ctx_data->meta_data_obj,
+				  &meta_data_va, meta_data_addr,
+				  sizeof(struct amdgpu_mes_ctx_meta_data));
+	if (r)
+		return r;
+
+	r = amdgpu_vm_bo_update(adev, meta_data_va, false);
+	if (r)
+		goto error;
+
+	r = amdgpu_vm_update_pdes(adev, vm, false);
+	if (r)
+		goto error;
+
+	dma_fence_wait(vm->last_update, false);
+	dma_fence_wait(meta_data_va->last_pt_update, false);
+
+	ctx_data->meta_data_gpu_addr = meta_data_addr;
+	ctx_data->meta_data_va = meta_data_va;
+
+	return 0;
+
+error:
+	BUG_ON(amdgpu_bo_reserve(ctx_data->meta_data_obj, true));
+	amdgpu_vm_bo_rmv(adev, meta_data_va);
+	amdgpu_bo_unreserve(ctx_data->meta_data_obj);
+	return r;
+}
-- 
2.35.1




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

  Powered by Linux