xref: /linux/drivers/gpu/drm/imagination/pvr_debugfs.c (revision 0ea5c948cb64bab5bc7a5516774eb8536f05aa0d)
1*cb56cd61SSarah Walker // SPDX-License-Identifier: GPL-2.0-only OR MIT
2*cb56cd61SSarah Walker /* Copyright (c) 2023 Imagination Technologies Ltd. */
3*cb56cd61SSarah Walker 
4*cb56cd61SSarah Walker #include "pvr_debugfs.h"
5*cb56cd61SSarah Walker 
6*cb56cd61SSarah Walker #include "pvr_device.h"
7*cb56cd61SSarah Walker #include "pvr_fw_trace.h"
8*cb56cd61SSarah Walker #include "pvr_params.h"
9*cb56cd61SSarah Walker 
10*cb56cd61SSarah Walker #include <linux/dcache.h>
11*cb56cd61SSarah Walker #include <linux/debugfs.h>
12*cb56cd61SSarah Walker #include <linux/err.h>
13*cb56cd61SSarah Walker #include <linux/kernel.h>
14*cb56cd61SSarah Walker #include <linux/types.h>
15*cb56cd61SSarah Walker 
16*cb56cd61SSarah Walker #include <drm/drm_device.h>
17*cb56cd61SSarah Walker #include <drm/drm_file.h>
18*cb56cd61SSarah Walker #include <drm/drm_print.h>
19*cb56cd61SSarah Walker 
20*cb56cd61SSarah Walker static const struct pvr_debugfs_entry pvr_debugfs_entries[] = {
21*cb56cd61SSarah Walker 	{"pvr_params", pvr_params_debugfs_init},
22*cb56cd61SSarah Walker 	{"pvr_fw", pvr_fw_trace_debugfs_init},
23*cb56cd61SSarah Walker };
24*cb56cd61SSarah Walker 
25*cb56cd61SSarah Walker void
pvr_debugfs_init(struct drm_minor * minor)26*cb56cd61SSarah Walker pvr_debugfs_init(struct drm_minor *minor)
27*cb56cd61SSarah Walker {
28*cb56cd61SSarah Walker 	struct drm_device *drm_dev = minor->dev;
29*cb56cd61SSarah Walker 	struct pvr_device *pvr_dev = to_pvr_device(drm_dev);
30*cb56cd61SSarah Walker 	struct dentry *root = minor->debugfs_root;
31*cb56cd61SSarah Walker 	size_t i;
32*cb56cd61SSarah Walker 
33*cb56cd61SSarah Walker 	for (i = 0; i < ARRAY_SIZE(pvr_debugfs_entries); ++i) {
34*cb56cd61SSarah Walker 		const struct pvr_debugfs_entry *entry = &pvr_debugfs_entries[i];
35*cb56cd61SSarah Walker 		struct dentry *dir;
36*cb56cd61SSarah Walker 
37*cb56cd61SSarah Walker 		dir = debugfs_create_dir(entry->name, root);
38*cb56cd61SSarah Walker 		if (IS_ERR(dir)) {
39*cb56cd61SSarah Walker 			drm_warn(drm_dev,
40*cb56cd61SSarah Walker 				 "failed to create debugfs dir '%s' (err=%d)",
41*cb56cd61SSarah Walker 				 entry->name, (int)PTR_ERR(dir));
42*cb56cd61SSarah Walker 			continue;
43*cb56cd61SSarah Walker 		}
44*cb56cd61SSarah Walker 
45*cb56cd61SSarah Walker 		entry->init(pvr_dev, dir);
46*cb56cd61SSarah Walker 	}
47*cb56cd61SSarah Walker }
48*cb56cd61SSarah Walker 
49*cb56cd61SSarah Walker /*
50*cb56cd61SSarah Walker  * Since all entries are created under &drm_minor->debugfs_root, there's no
51*cb56cd61SSarah Walker  * need for a pvr_debugfs_fini() as DRM will clean up everything under its root
52*cb56cd61SSarah Walker  * automatically.
53*cb56cd61SSarah Walker  */
54