We would like to report them on gpu errors.

Signed-off-by: Chia-I Wu <olva...@gmail.com>
---
 drivers/gpu/drm/panthor/panthor_device.h | 6 ++++++
 drivers/gpu/drm/panthor/panthor_drv.c    | 9 +++++++++
 2 files changed, 15 insertions(+)

diff --git a/drivers/gpu/drm/panthor/panthor_device.h 
b/drivers/gpu/drm/panthor/panthor_device.h
index 75ae6fd3a5128..8c31c1d4296b6 100644
--- a/drivers/gpu/drm/panthor/panthor_device.h
+++ b/drivers/gpu/drm/panthor/panthor_device.h
@@ -257,6 +257,12 @@ struct panthor_file {
        /** @stats: cycle and timestamp measures for job execution. */
        struct panthor_gpu_usage stats;
 
+       /** @pid: pid of the task created this file */
+       pid_t pid;
+
+       /** @comm: comm of the task created this file */
+       char *comm;
+
        /** @refcount: ref count of this file */
        struct kref refcount;
 };
diff --git a/drivers/gpu/drm/panthor/panthor_drv.c 
b/drivers/gpu/drm/panthor/panthor_drv.c
index aea9609684b77..b9d86b86591db 100644
--- a/drivers/gpu/drm/panthor/panthor_drv.c
+++ b/drivers/gpu/drm/panthor/panthor_drv.c
@@ -1400,6 +1400,7 @@ void panthor_file_release(struct kref *kref)
 
        WARN_ON(pfile->vms || pfile->groups);
 
+       kfree(pfile->comm);
        kfree(pfile);
 }
 
@@ -1408,6 +1409,7 @@ panthor_open(struct drm_device *ddev, struct drm_file 
*file)
 {
        struct panthor_device *ptdev = container_of(ddev, struct 
panthor_device, base);
        struct panthor_file *pfile;
+       struct task_struct *task;
        int ret;
 
        pfile = kzalloc(sizeof(*pfile), GFP_KERNEL);
@@ -1436,6 +1438,13 @@ panthor_open(struct drm_device *ddev, struct drm_file 
*file)
        if (ret)
                goto err_destroy_vm_pool;
 
+       task = get_pid_task(rcu_access_pointer(file->pid), PIDTYPE_PID);
+       if (task) {
+               pfile->pid = task->pid;
+               pfile->comm = kstrdup(task->comm, GFP_KERNEL);
+               put_task_struct(task);
+       }
+
        kref_init(&pfile->refcount);
 
        file->driver_priv = pfile;
-- 
2.50.0.714.g196bf9f422-goog

Reply via email to