diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c index 46a3080b0b20..8cdba0c1a14b 100644 --- a/drivers/gpu/drm/panthor/panthor_drv.c +++ b/drivers/gpu/drm/panthor/panthor_drv.c @@ -1769,6 +1769,7 @@ static void panthor_debugfs_init(struct drm_minor *minor) { panthor_mmu_debugfs_init(minor); panthor_gem_debugfs_init(minor); + panthor_sched_debugfs_init(minor); } #endif diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c index 60b2417deb81..ac6aee554820 100644 --- a/drivers/gpu/drm/panthor/panthor_sched.c +++ b/drivers/gpu/drm/panthor/panthor_sched.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 or MIT /* Copyright 2023 Collabora ltd. */ +#include #include #include #include @@ -4175,3 +4176,75 @@ int panthor_sched_init(struct panthor_device *ptdev) ptdev->scheduler = sched; return 0; } + +#ifdef CONFIG_DEBUG_FS + +static const char * +panthor_sched_prio_str(enum panthor_csg_priority prio) +{ + switch (prio) { + case PANTHOR_CSG_PRIORITY_LOW: + return "LOW"; + case PANTHOR_CSG_PRIORITY_MEDIUM: + return "MEDIUM"; + case PANTHOR_CSG_PRIORITY_HIGH: + return "HIGH"; + case PANTHOR_CSG_PRIORITY_RT: + return "REAL-TIME"; + default: + return "UNKNOWN"; + } +} + +static int show_file_groups(struct drm_file *file, struct seq_file *m) +{ + struct panthor_file *pfile = file->driver_priv; + struct panthor_group *group; + unsigned long i; + + if (IS_ERR_OR_NULL(pfile->groups)) + return -ENOENT; + + xa_lock(&pfile->groups->xa); + xa_for_each_marked(&pfile->groups->xa, i, group, GROUP_REGISTERED) { + seq_printf(m, "client_id %8llu pid %8d command %s: group %2lu priority %s queue count %u\n", + file->client_id, group->task_info.pid, group->task_info.comm, i, + panthor_sched_prio_str(group->priority), group->queue_count); + } + xa_unlock(&pfile->groups->xa); + + return 0; +} + +static int show_each_file(struct seq_file *m, void *arg) +{ + struct drm_info_node *node = (struct drm_info_node *)m->private; + struct drm_device *ddev = node->minor->dev; + int (*show)(struct drm_file *, struct seq_file *) = + node->info_ent->data; + struct drm_file *file; + int ret; + + scoped_cond_guard(mutex_intr, return -EINTR, &ddev->filelist_mutex) { + list_for_each_entry(file, &ddev->filelist, lhead) { + ret = show(file, m); + if (ret < 0) + return ret; + } + } + + return 0; +} + +static struct drm_info_list panthor_sched_debugfs_list[] = { + { "sched_groups", show_each_file, 0, show_file_groups }, +}; + +void panthor_sched_debugfs_init(struct drm_minor *minor) +{ + drm_debugfs_create_files(panthor_sched_debugfs_list, + ARRAY_SIZE(panthor_sched_debugfs_list), + minor->debugfs_root, minor); +} + +#endif /* CONFIG_DEBUG_FS */ diff --git a/drivers/gpu/drm/panthor/panthor_sched.h b/drivers/gpu/drm/panthor/panthor_sched.h index 9a8692de8ade..d87cbdba4d40 100644 --- a/drivers/gpu/drm/panthor/panthor_sched.h +++ b/drivers/gpu/drm/panthor/panthor_sched.h @@ -10,6 +10,7 @@ struct drm_file; struct drm_gem_object; struct drm_sched_job; struct drm_memory_stats; +struct drm_minor; struct drm_panthor_group_create; struct drm_panthor_queue_create; struct drm_panthor_group_get_state; @@ -55,4 +56,8 @@ void panthor_sched_report_fw_events(struct panthor_device *ptdev, u32 events); void panthor_fdinfo_gather_group_samples(struct panthor_file *pfile); +#ifdef CONFIG_DEBUG_FS +void panthor_sched_debugfs_init(struct drm_minor *minor); +#endif + #endif