This commit sets the perf state of a user queue
before publish it.

Signed-off-by: Zhu Lingshan <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 27 +++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
index 8a1f0841e8e7..fb4d8c8c6eef 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
@@ -731,6 +731,30 @@ static int amdgpu_userq_priority_permit(struct drm_file 
*filp,
        return -EACCES;
 }
 
+static int amdgpu_userq_attach(struct amdgpu_device *adev,
+                              struct amdgpu_usermode_queue *queue,
+                              u64 index)
+{
+       struct amdgpu_mqd *mqd_funcs = &adev->mqds[queue->queue_type];
+       int r;
+
+       mutex_lock(&adev->pmc_profiler.lock);
+
+       /* set the queue PMC state based on the device PMC state */
+       if (mqd_funcs->set_mqd_perfcount) {
+               queue->userq_prop->perfcount_enable = adev->pmc_profiler.enable;
+               mqd_funcs->set_mqd_perfcount(queue->mqd.cpu_ptr,
+                                            queue->userq_prop);
+       }
+
+       /* attach the queue to the xarray */
+       r = xa_insert_irq(&adev->userq_doorbell_xa, index, queue, GFP_KERNEL);
+
+       mutex_unlock(&adev->pmc_profiler.lock);
+
+       return r;
+}
+
 static int
 amdgpu_userq_create(struct drm_file *filp, union drm_amdgpu_userq *args)
 {
@@ -831,8 +855,7 @@ amdgpu_userq_create(struct drm_file *filp, union 
drm_amdgpu_userq *args)
        /* Update VM owner at userq submit-time for page-fault attribution. */
        amdgpu_vm_set_task_info(&fpriv->vm);
 
-       r = xa_insert_irq(&adev->userq_doorbell_xa, index, queue,
-                         GFP_KERNEL);
+       r = amdgpu_userq_attach(adev, queue, index);
        if (r)
                goto clean_mqd;
 
-- 
2.55.0

Reply via email to