drivers/gpu/drm/panfrost/panfrost_drv.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/panfrost/panfrost_drv.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/panfrost/panfrost_drv.c
Extension
.c
Size
32961 bytes
Lines
1201
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

static const struct file_operations panfrost_drm_driver_fops = {
	.owner = THIS_MODULE,
	DRM_GEM_FOPS,
	.show_fdinfo = drm_show_fdinfo,
};

#ifdef CONFIG_DEBUG_FS
static int panthor_gems_show(struct seq_file *m, void *data)
{
	struct drm_info_node *node = m->private;
	struct panfrost_device *pfdev = to_panfrost_device(node->minor->dev);

	panfrost_gem_debugfs_print_bos(pfdev, m);

	return 0;
}

static void show_panfrost_jm_ctx(struct panfrost_jm_ctx *jm_ctx, u32 handle,
				 struct seq_file *m)
{
	struct drm_device *ddev = ((struct drm_info_node *)m->private)->minor->dev;
	const char *prio = "UNKNOWN";

	static const char * const prios[] = {
		[DRM_SCHED_PRIORITY_HIGH] = "HIGH",
		[DRM_SCHED_PRIORITY_NORMAL] = "NORMAL",
		[DRM_SCHED_PRIORITY_LOW] = "LOW",
	};

	if (jm_ctx->slot_entity[0].priority !=
	    jm_ctx->slot_entity[1].priority)
		drm_warn(ddev, "Slot priorities should be the same in a single context");

	if (jm_ctx->slot_entity[0].priority < ARRAY_SIZE(prios))
		prio = prios[jm_ctx->slot_entity[0].priority];

	seq_printf(m, " JM context %u: priority %s\n", handle, prio);
}

static int show_file_jm_ctxs(struct panfrost_file_priv *pfile,
			     struct seq_file *m)
{
	struct panfrost_jm_ctx *jm_ctx;
	unsigned long i;

	xa_lock(&pfile->jm_ctxs);
	xa_for_each(&pfile->jm_ctxs, i, jm_ctx) {
		jm_ctx = panfrost_jm_ctx_get(jm_ctx);
		xa_unlock(&pfile->jm_ctxs);
		show_panfrost_jm_ctx(jm_ctx, i, m);
		panfrost_jm_ctx_put(jm_ctx);
		xa_lock(&pfile->jm_ctxs);
	}
	xa_unlock(&pfile->jm_ctxs);

	return 0;
}

static struct drm_info_list panthor_debugfs_list[] = {
	{"gems",
	 panthor_gems_show, 0, NULL},
};

static int panthor_gems_debugfs_init(struct drm_minor *minor)
{
	drm_debugfs_create_files(panthor_debugfs_list,
				 ARRAY_SIZE(panthor_debugfs_list),
				 minor->debugfs_root, minor);

	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 panfrost_file_priv *, struct seq_file *) =
		node->info_ent->data;
	struct drm_file *file;
	int ret;

	ret = mutex_lock_interruptible(&ddev->filelist_mutex);
	if (ret)
		return ret;

	list_for_each_entry(file, &ddev->filelist, lhead) {
		struct task_struct *task;
		struct panfrost_file_priv *pfile = file->driver_priv;
		struct pid *pid;

Annotation

Implementation Notes