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