diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2018-11-21 16:35:10 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2018-11-22 03:52:27 -0500 |
commit | c6fdea6e1a1942bd1ab2abaa16c34f23a25226b9 (patch) | |
tree | 3d801008261f6b091eaac4e9ee1099f39838a050 | |
parent | 42843dc2d536afb5bb1b318b48f3f22b485f0dec (diff) |
drm: Merge drm_info.c into drm_debugfs.c
Ever since
commit cb6458f97b53d7f73043206c18014b3ca63ac345
Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date: Thu Aug 8 15:41:34 2013 +0200
drm: remove procfs code, take 2
Having the code shared between procfs and debugfs in the separate
drm_info.c file stopped making sense. Merge them.
Noticed because Lyude asked some questions on irc about why we even
have drm_info_node and I remember this old story.
Cc: Lyude Paul <lyude@redhat.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181121213510.31260-1-daniel.vetter@ffwll.ch
-rw-r--r-- | drivers/gpu/drm/Makefile | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_debugfs.c | 89 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_info.c | 137 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_internal.h | 5 |
4 files changed, 90 insertions, 143 deletions
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 576ba985e138..7c88f12096c5 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile | |||
@@ -10,7 +10,7 @@ drm-y := drm_auth.o drm_bufs.o drm_cache.o \ | |||
10 | drm_scatter.o drm_pci.o \ | 10 | drm_scatter.o drm_pci.o \ |
11 | drm_sysfs.o drm_hashtab.o drm_mm.o \ | 11 | drm_sysfs.o drm_hashtab.o drm_mm.o \ |
12 | drm_crtc.o drm_fourcc.o drm_modes.o drm_edid.o \ | 12 | drm_crtc.o drm_fourcc.o drm_modes.o drm_edid.o \ |
13 | drm_info.o drm_encoder_slave.o \ | 13 | drm_encoder_slave.o \ |
14 | drm_trace_points.o drm_global.o drm_prime.o \ | 14 | drm_trace_points.o drm_global.o drm_prime.o \ |
15 | drm_rect.o drm_vma_manager.o drm_flip_work.o \ | 15 | drm_rect.o drm_vma_manager.o drm_flip_work.o \ |
16 | drm_modeset_lock.o drm_atomic.o drm_bridge.o \ | 16 | drm_modeset_lock.o drm_atomic.o drm_bridge.o \ |
diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index 373bd4c2b698..f8468eae0503 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c | |||
@@ -32,6 +32,8 @@ | |||
32 | #include <drm/drm_debugfs.h> | 32 | #include <drm/drm_debugfs.h> |
33 | #include <drm/drm_edid.h> | 33 | #include <drm/drm_edid.h> |
34 | #include <drm/drm_atomic.h> | 34 | #include <drm/drm_atomic.h> |
35 | #include <drm/drm_auth.h> | ||
36 | #include <drm/drm_gem.h> | ||
35 | #include <drm/drmP.h> | 37 | #include <drm/drmP.h> |
36 | 38 | ||
37 | #include "drm_internal.h" | 39 | #include "drm_internal.h" |
@@ -43,6 +45,93 @@ | |||
43 | * Initialization, etc. | 45 | * Initialization, etc. |
44 | **************************************************/ | 46 | **************************************************/ |
45 | 47 | ||
48 | static int drm_name_info(struct seq_file *m, void *data) | ||
49 | { | ||
50 | struct drm_info_node *node = (struct drm_info_node *) m->private; | ||
51 | struct drm_minor *minor = node->minor; | ||
52 | struct drm_device *dev = minor->dev; | ||
53 | struct drm_master *master; | ||
54 | |||
55 | mutex_lock(&dev->master_mutex); | ||
56 | master = dev->master; | ||
57 | seq_printf(m, "%s", dev->driver->name); | ||
58 | if (dev->dev) | ||
59 | seq_printf(m, " dev=%s", dev_name(dev->dev)); | ||
60 | if (master && master->unique) | ||
61 | seq_printf(m, " master=%s", master->unique); | ||
62 | if (dev->unique) | ||
63 | seq_printf(m, " unique=%s", dev->unique); | ||
64 | seq_printf(m, "\n"); | ||
65 | mutex_unlock(&dev->master_mutex); | ||
66 | |||
67 | return 0; | ||
68 | } | ||
69 | |||
70 | static int drm_clients_info(struct seq_file *m, void *data) | ||
71 | { | ||
72 | struct drm_info_node *node = (struct drm_info_node *) m->private; | ||
73 | struct drm_device *dev = node->minor->dev; | ||
74 | struct drm_file *priv; | ||
75 | kuid_t uid; | ||
76 | |||
77 | seq_printf(m, | ||
78 | "%20s %5s %3s master a %5s %10s\n", | ||
79 | "command", | ||
80 | "pid", | ||
81 | "dev", | ||
82 | "uid", | ||
83 | "magic"); | ||
84 | |||
85 | /* dev->filelist is sorted youngest first, but we want to present | ||
86 | * oldest first (i.e. kernel, servers, clients), so walk backwardss. | ||
87 | */ | ||
88 | mutex_lock(&dev->filelist_mutex); | ||
89 | list_for_each_entry_reverse(priv, &dev->filelist, lhead) { | ||
90 | struct task_struct *task; | ||
91 | |||
92 | rcu_read_lock(); /* locks pid_task()->comm */ | ||
93 | task = pid_task(priv->pid, PIDTYPE_PID); | ||
94 | uid = task ? __task_cred(task)->euid : GLOBAL_ROOT_UID; | ||
95 | seq_printf(m, "%20s %5d %3d %c %c %5d %10u\n", | ||
96 | task ? task->comm : "<unknown>", | ||
97 | pid_vnr(priv->pid), | ||
98 | priv->minor->index, | ||
99 | drm_is_current_master(priv) ? 'y' : 'n', | ||
100 | priv->authenticated ? 'y' : 'n', | ||
101 | from_kuid_munged(seq_user_ns(m), uid), | ||
102 | priv->magic); | ||
103 | rcu_read_unlock(); | ||
104 | } | ||
105 | mutex_unlock(&dev->filelist_mutex); | ||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | static int drm_gem_one_name_info(int id, void *ptr, void *data) | ||
110 | { | ||
111 | struct drm_gem_object *obj = ptr; | ||
112 | struct seq_file *m = data; | ||
113 | |||
114 | seq_printf(m, "%6d %8zd %7d %8d\n", | ||
115 | obj->name, obj->size, | ||
116 | obj->handle_count, | ||
117 | kref_read(&obj->refcount)); | ||
118 | return 0; | ||
119 | } | ||
120 | |||
121 | static int drm_gem_name_info(struct seq_file *m, void *data) | ||
122 | { | ||
123 | struct drm_info_node *node = (struct drm_info_node *) m->private; | ||
124 | struct drm_device *dev = node->minor->dev; | ||
125 | |||
126 | seq_printf(m, " name size handles refcount\n"); | ||
127 | |||
128 | mutex_lock(&dev->object_name_lock); | ||
129 | idr_for_each(&dev->object_name_idr, drm_gem_one_name_info, m); | ||
130 | mutex_unlock(&dev->object_name_lock); | ||
131 | |||
132 | return 0; | ||
133 | } | ||
134 | |||
46 | static const struct drm_info_list drm_debugfs_list[] = { | 135 | static const struct drm_info_list drm_debugfs_list[] = { |
47 | {"name", drm_name_info, 0}, | 136 | {"name", drm_name_info, 0}, |
48 | {"clients", drm_clients_info, 0}, | 137 | {"clients", drm_clients_info, 0}, |
diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c deleted file mode 100644 index 6b68e9088436..000000000000 --- a/drivers/gpu/drm/drm_info.c +++ /dev/null | |||
@@ -1,137 +0,0 @@ | |||
1 | /** | ||
2 | * \file drm_info.c | ||
3 | * DRM info file implementations | ||
4 | * | ||
5 | * \author Ben Gamari <bgamari@gmail.com> | ||
6 | */ | ||
7 | |||
8 | /* | ||
9 | * Created: Sun Dec 21 13:09:50 2008 by bgamari@gmail.com | ||
10 | * | ||
11 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. | ||
12 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. | ||
13 | * Copyright 2008 Ben Gamari <bgamari@gmail.com> | ||
14 | * All Rights Reserved. | ||
15 | * | ||
16 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
17 | * copy of this software and associated documentation files (the "Software"), | ||
18 | * to deal in the Software without restriction, including without limitation | ||
19 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
20 | * and/or sell copies of the Software, and to permit persons to whom the | ||
21 | * Software is furnished to do so, subject to the following conditions: | ||
22 | * | ||
23 | * The above copyright notice and this permission notice (including the next | ||
24 | * paragraph) shall be included in all copies or substantial portions of the | ||
25 | * Software. | ||
26 | * | ||
27 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
28 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
29 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
30 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
31 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
32 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
33 | * OTHER DEALINGS IN THE SOFTWARE. | ||
34 | */ | ||
35 | |||
36 | #include <linux/seq_file.h> | ||
37 | #include <drm/drmP.h> | ||
38 | #include <drm/drm_gem.h> | ||
39 | |||
40 | #include "drm_internal.h" | ||
41 | #include "drm_legacy.h" | ||
42 | |||
43 | /** | ||
44 | * Called when "/proc/dri/.../name" is read. | ||
45 | * | ||
46 | * Prints the device name together with the bus id if available. | ||
47 | */ | ||
48 | int drm_name_info(struct seq_file *m, void *data) | ||
49 | { | ||
50 | struct drm_info_node *node = (struct drm_info_node *) m->private; | ||
51 | struct drm_minor *minor = node->minor; | ||
52 | struct drm_device *dev = minor->dev; | ||
53 | struct drm_master *master; | ||
54 | |||
55 | mutex_lock(&dev->master_mutex); | ||
56 | master = dev->master; | ||
57 | seq_printf(m, "%s", dev->driver->name); | ||
58 | if (dev->dev) | ||
59 | seq_printf(m, " dev=%s", dev_name(dev->dev)); | ||
60 | if (master && master->unique) | ||
61 | seq_printf(m, " master=%s", master->unique); | ||
62 | if (dev->unique) | ||
63 | seq_printf(m, " unique=%s", dev->unique); | ||
64 | seq_printf(m, "\n"); | ||
65 | mutex_unlock(&dev->master_mutex); | ||
66 | |||
67 | return 0; | ||
68 | } | ||
69 | |||
70 | /** | ||
71 | * Called when "/proc/dri/.../clients" is read. | ||
72 | * | ||
73 | */ | ||
74 | int drm_clients_info(struct seq_file *m, void *data) | ||
75 | { | ||
76 | struct drm_info_node *node = (struct drm_info_node *) m->private; | ||
77 | struct drm_device *dev = node->minor->dev; | ||
78 | struct drm_file *priv; | ||
79 | kuid_t uid; | ||
80 | |||
81 | seq_printf(m, | ||
82 | "%20s %5s %3s master a %5s %10s\n", | ||
83 | "command", | ||
84 | "pid", | ||
85 | "dev", | ||
86 | "uid", | ||
87 | "magic"); | ||
88 | |||
89 | /* dev->filelist is sorted youngest first, but we want to present | ||
90 | * oldest first (i.e. kernel, servers, clients), so walk backwardss. | ||
91 | */ | ||
92 | mutex_lock(&dev->filelist_mutex); | ||
93 | list_for_each_entry_reverse(priv, &dev->filelist, lhead) { | ||
94 | struct task_struct *task; | ||
95 | |||
96 | rcu_read_lock(); /* locks pid_task()->comm */ | ||
97 | task = pid_task(priv->pid, PIDTYPE_PID); | ||
98 | uid = task ? __task_cred(task)->euid : GLOBAL_ROOT_UID; | ||
99 | seq_printf(m, "%20s %5d %3d %c %c %5d %10u\n", | ||
100 | task ? task->comm : "<unknown>", | ||
101 | pid_vnr(priv->pid), | ||
102 | priv->minor->index, | ||
103 | drm_is_current_master(priv) ? 'y' : 'n', | ||
104 | priv->authenticated ? 'y' : 'n', | ||
105 | from_kuid_munged(seq_user_ns(m), uid), | ||
106 | priv->magic); | ||
107 | rcu_read_unlock(); | ||
108 | } | ||
109 | mutex_unlock(&dev->filelist_mutex); | ||
110 | return 0; | ||
111 | } | ||
112 | |||
113 | static int drm_gem_one_name_info(int id, void *ptr, void *data) | ||
114 | { | ||
115 | struct drm_gem_object *obj = ptr; | ||
116 | struct seq_file *m = data; | ||
117 | |||
118 | seq_printf(m, "%6d %8zd %7d %8d\n", | ||
119 | obj->name, obj->size, | ||
120 | obj->handle_count, | ||
121 | kref_read(&obj->refcount)); | ||
122 | return 0; | ||
123 | } | ||
124 | |||
125 | int drm_gem_name_info(struct seq_file *m, void *data) | ||
126 | { | ||
127 | struct drm_info_node *node = (struct drm_info_node *) m->private; | ||
128 | struct drm_device *dev = node->minor->dev; | ||
129 | |||
130 | seq_printf(m, " name size handles refcount\n"); | ||
131 | |||
132 | mutex_lock(&dev->object_name_lock); | ||
133 | idr_for_each(&dev->object_name_idr, drm_gem_one_name_info, m); | ||
134 | mutex_unlock(&dev->object_name_lock); | ||
135 | |||
136 | return 0; | ||
137 | } | ||
diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h index 0c4eb4a9ab31..c7a7d7ce5d1c 100644 --- a/drivers/gpu/drm/drm_internal.h +++ b/drivers/gpu/drm/drm_internal.h | |||
@@ -56,11 +56,6 @@ void drm_prime_remove_buf_handle_locked(struct drm_prime_file_private *prime_fpr | |||
56 | struct drm_minor *drm_minor_acquire(unsigned int minor_id); | 56 | struct drm_minor *drm_minor_acquire(unsigned int minor_id); |
57 | void drm_minor_release(struct drm_minor *minor); | 57 | void drm_minor_release(struct drm_minor *minor); |
58 | 58 | ||
59 | /* drm_info.c */ | ||
60 | int drm_name_info(struct seq_file *m, void *data); | ||
61 | int drm_clients_info(struct seq_file *m, void* data); | ||
62 | int drm_gem_name_info(struct seq_file *m, void *data); | ||
63 | |||
64 | /* drm_vblank.c */ | 59 | /* drm_vblank.c */ |
65 | void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe); | 60 | void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe); |
66 | void drm_vblank_cleanup(struct drm_device *dev); | 61 | void drm_vblank_cleanup(struct drm_device *dev); |