From: Rob Clark <robdcl...@chromium.org> Deduplicate this from fault_worker and recover_worker.
Signed-off-by: Rob Clark <robdcl...@chromium.org> --- drivers/gpu/drm/msm/msm_gpu.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c index 8fe4aee96aa9..4ec62b601adc 100644 --- a/drivers/gpu/drm/msm/msm_gpu.c +++ b/drivers/gpu/drm/msm/msm_gpu.c @@ -362,6 +362,20 @@ find_submit(struct msm_ringbuffer *ring, uint32_t fence) static void retire_submits(struct msm_gpu *gpu); +static void get_comm_cmdline(struct msm_gem_submit *submit, char **comm, char **cmd) +{ + struct task_struct *task; + + task = get_pid_task(submit->pid, PIDTYPE_PID); + if (!task) + return; + + *comm = kstrdup(task->comm, GFP_KERNEL); + *cmd = kstrdup_quotable_cmdline(task, GFP_KERNEL); + + put_task_struct(task); +} + static void recover_worker(struct kthread_work *work) { struct msm_gpu *gpu = container_of(work, struct msm_gpu, recover_work); @@ -378,18 +392,11 @@ static void recover_worker(struct kthread_work *work) submit = find_submit(cur_ring, cur_ring->memptrs->fence + 1); if (submit) { - struct task_struct *task; - /* Increment the fault counts */ submit->queue->faults++; submit->aspace->faults++; - task = get_pid_task(submit->pid, PIDTYPE_PID); - if (task) { - comm = kstrdup(task->comm, GFP_KERNEL); - cmd = kstrdup_quotable_cmdline(task, GFP_KERNEL); - put_task_struct(task); - } + get_comm_cmdline(submit, &comm, &cmd); if (comm && cmd) { DRM_DEV_ERROR(dev->dev, "%s: offending task: %s (%s)\n", @@ -478,14 +485,7 @@ static void fault_worker(struct kthread_work *work) goto resume_smmu; if (submit) { - struct task_struct *task; - - task = get_pid_task(submit->pid, PIDTYPE_PID); - if (task) { - comm = kstrdup(task->comm, GFP_KERNEL); - cmd = kstrdup_quotable_cmdline(task, GFP_KERNEL); - put_task_struct(task); - } + get_comm_cmdline(submit, &comm, &cmd); /* * When we get GPU iova faults, we can get 1000s of them, -- 2.35.1