Add cwsr parameters to userqueue ioctl. User should pass the GPU virtual
address for save/restore buffer, and size allocated. They are supported
only for user compute queues.

Signed-off-by: Lijo Lazar <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 13 ++++++++-----
 include/uapi/drm/amdgpu_drm.h              | 11 +++++++++++
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c 
b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
index 71a323ad1ac6..9d77f72c4773 100644
--- a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
+++ b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
@@ -349,17 +349,20 @@ static int mes_userq_mqd_create(struct 
amdgpu_usermode_queue *queue,
                        num_xcc = amdgpu_xcp_get_num_xcc(adev->xcp_mgr,
                                                         fpriv->xcp_id);
                        cwsr_params.ctx_save_area_address =
-                               userq_props->ctx_save_area_addr;
-                       cwsr_params.cwsr_sz = userq_props->ctx_save_area_size;
-                       userq_props->ctl_stack_size =
-                               adev->cwsr_info->xcc_ctl_stack_sz * num_xcc;
-
+                               compute_mqd->ctx_save_area_va;
+                       cwsr_params.cwsr_sz = compute_mqd->ctx_save_area_size;
                        r = amdgpu_userq_input_cwsr_params_validate(
                                queue, &cwsr_params);
                        if (r) {
                                kfree(compute_mqd);
                                goto free_mqd;
                        }
+                       userq_props->ctx_save_area_addr =
+                               compute_mqd->ctx_save_area_va;
+                       userq_props->ctx_save_area_size =
+                               compute_mqd->ctx_save_area_size;
+                       userq_props->ctl_stack_size =
+                               adev->cwsr_info->xcc_ctl_stack_sz * num_xcc;
                }
 
                kfree(compute_mqd);
diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
index c178b8e0bd3f..41a155fe2c01 100644
--- a/include/uapi/drm/amdgpu_drm.h
+++ b/include/uapi/drm/amdgpu_drm.h
@@ -460,6 +460,17 @@ struct drm_amdgpu_userq_mqd_compute_gfx11 {
         * to get the size.
         */
        __u64   eop_va;
+       /**
+        * @ctx_save_area_va: Virtual address of the GPU memory for 
save/restore buffer.
+        * This must be from a separate GPU object, and use AMDGPU_INFO IOCTL
+        * to get the size. This includes control stack, wave context and 
debugger memory.
+        */
+       __u64 ctx_save_area_va;
+       /**
+        * @ctx_save_area_size:  Total size (in bytes) allocated for 
save/restore buffer.
+        * Use AMDGPU_INFO IOCTL to get the size.
+        */
+       __u32 ctx_save_area_size;
 };
 
 /* userq signal/wait ioctl */
-- 
2.49.0

Reply via email to