Add the pid and the process name of the process
with the userq manager which could be used in
debugging and understanding error messages better.

Signed-off-by: Sunil Khatri <sunil.kha...@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c       | 8 ++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 4262c320ad1d..f73bcca35287 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -1357,6 +1357,7 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct 
drm_file *file_priv)
 {
        struct amdgpu_device *adev = drm_to_adev(dev);
        struct amdgpu_fpriv *fpriv;
+       struct task_struct *task;
        int r, pasid;
 
        /* Ensure IB tests are run on ring */
@@ -1426,6 +1427,13 @@ int amdgpu_driver_open_kms(struct drm_device *dev, 
struct drm_file *file_priv)
 
        amdgpu_ctx_mgr_init(&fpriv->ctx_mgr, adev);
 
+       task = get_pid_task(rcu_access_pointer(file_priv->pid), PIDTYPE_PID);
+       if (task) {
+               fpriv->userq_mgr.pid = task->pid;
+               fpriv->userq_mgr.process_name = kstrdup(task->comm, GFP_KERNEL);
+               put_task_struct(task);
+       }
+
        r = amdgpu_userq_mgr_init(&fpriv->userq_mgr, adev);
        if (r)
                DRM_WARN("Can't setup usermode queues, use legacy workload 
submission only\n");
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h
index ec1a4ca6f632..a495b24165f9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h
@@ -77,6 +77,8 @@ struct amdgpu_userq_mgr {
        struct amdgpu_device            *adev;
        struct delayed_work             resume_work;
        struct list_head                list;
+       pid_t                           pid;
+       char                            *process_name;
 };
 
 struct amdgpu_db_info {
-- 
2.34.1

Reply via email to