From e7a069f69d289c6564ea45a122750a0f5cc7ec7c Mon Sep 17 00:00:00 2001 From: Cho KyongHo Date: Sat, 17 Mar 2018 21:37:50 +0900 Subject: [PATCH] g2d: add debugfs node about states of tasks When G2D driver is not able to allocate a free task, we are curious about the states of each task. debugs/g2d/tasks shows details of all tasks including flags, state flags, priority and the time of starting job and the time of the completion of the job. Change-Id: I617f98169daaaca851bfd7c0dc52245ab96c624d Signed-off-by: Cho KyongHo --- drivers/gpu/exynos/g2d/g2d.h | 1 + drivers/gpu/exynos/g2d/g2d_debug.c | 37 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/drivers/gpu/exynos/g2d/g2d.h b/drivers/gpu/exynos/g2d/g2d.h index a764b1dbb6ee..4e5ad05c05b4 100644 --- a/drivers/gpu/exynos/g2d/g2d.h +++ b/drivers/gpu/exynos/g2d/g2d.h @@ -109,6 +109,7 @@ struct g2d_device { struct dentry *debug; struct dentry *debug_logs; struct dentry *debug_contexts; + struct dentry *debug_tasks; atomic_t prior_stats[G2D_PRIORITY_END]; diff --git a/drivers/gpu/exynos/g2d/g2d_debug.c b/drivers/gpu/exynos/g2d/g2d_debug.c index 8dd3e46e3c02..9c6184f23870 100644 --- a/drivers/gpu/exynos/g2d/g2d_debug.c +++ b/drivers/gpu/exynos/g2d/g2d_debug.c @@ -184,6 +184,34 @@ static const struct file_operations g2d_debug_contexts_fops = { .release = single_release, }; +static int g2d_debug_tasks_show(struct seq_file *s, void *unused) +{ + struct g2d_device *g2d_dev = s->private; + struct g2d_task *task; + + for (task = g2d_dev->tasks; task; task = task->next) { + seq_printf(s, "TASK[%d]: state %#lx flags %#x ", + task->job_id, task->state, task->flags); + seq_printf(s, "prio %d begin@%llu end@%llu nr_src %d\n", + task->priority, ktime_to_us(task->ktime_begin), + ktime_to_us(task->ktime_end), task->num_source); + } + + return 0; +} + +static int g2d_debug_tasks_open(struct inode *inode, struct file *file) +{ + return single_open(file, g2d_debug_tasks_show, inode->i_private); +} + +static const struct file_operations g2d_debug_tasks_fops = { + .open = g2d_debug_tasks_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + void g2d_init_debug(struct g2d_device *g2d_dev) { atomic_set(&g2d_stamp_id, -1); @@ -216,6 +244,15 @@ void g2d_init_debug(struct g2d_device *g2d_dev) "debugfs : failed to create debug contexts file\n"); return; } + + g2d_dev->debug_tasks= debugfs_create_file("tasks", + 0400, g2d_dev->debug_root, g2d_dev, + &g2d_debug_tasks_fops); + if (!g2d_dev->debug_logs) { + dev_err(g2d_dev->dev, + "debugfs : failed to create debug contexts file\n"); + return; + } } void g2d_destroy_debug(struct g2d_device *g2d_dev) -- 2.20.1