3 * DRM info file implementations
11 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
12 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
14 * All Rights Reserved.
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:
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
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.
36 #include <linux/seq_file.h>
38 #include <drm/drm_gem.h>
40 #include "drm_internal.h"
41 #include "drm_legacy.h"
44 * Called when "/proc/dri/.../name" is read.
46 * Prints the device name together with the bus id if available.
48 int drm_name_info(struct seq_file *m, void *data)
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;
55 mutex_lock(&dev->master_mutex);
60 seq_printf(m, "%s", dev->driver->name);
62 seq_printf(m, " dev=%s", dev_name(dev->dev));
63 if (master && master->unique)
64 seq_printf(m, " master=%s", master->unique);
66 seq_printf(m, " unique=%s", dev->unique);
69 mutex_unlock(&dev->master_mutex);
75 * Called when "/proc/dri/.../clients" is read.
78 int drm_clients_info(struct seq_file *m, void *data)
80 struct drm_info_node *node = (struct drm_info_node *) m->private;
81 struct drm_device *dev = node->minor->dev;
82 struct drm_file *priv;
85 "%20s %5s %3s master a %5s %10s\n",
92 /* dev->filelist is sorted youngest first, but we want to present
93 * oldest first (i.e. kernel, servers, clients), so walk backwardss.
95 mutex_lock(&dev->filelist_mutex);
96 list_for_each_entry_reverse(priv, &dev->filelist, lhead) {
97 struct task_struct *task;
99 rcu_read_lock(); /* locks pid_task()->comm */
100 task = pid_task(priv->pid, PIDTYPE_PID);
101 seq_printf(m, "%20s %5d %3d %c %c %5d %10u\n",
102 task ? task->comm : "<unknown>",
105 drm_is_current_master(priv) ? 'y' : 'n',
106 priv->authenticated ? 'y' : 'n',
107 from_kuid_munged(seq_user_ns(m), priv->uid),
111 mutex_unlock(&dev->filelist_mutex);
115 static int drm_gem_one_name_info(int id, void *ptr, void *data)
117 struct drm_gem_object *obj = ptr;
118 struct seq_file *m = data;
120 seq_printf(m, "%6d %8zd %7d %8d\n",
121 obj->name, obj->size,
123 atomic_read(&obj->refcount.refcount));
127 int drm_gem_name_info(struct seq_file *m, void *data)
129 struct drm_info_node *node = (struct drm_info_node *) m->private;
130 struct drm_device *dev = node->minor->dev;
132 seq_printf(m, " name size handles refcount\n");
134 mutex_lock(&dev->object_name_lock);
135 idr_for_each(&dev->object_name_idr, drm_gem_one_name_info, m);
136 mutex_unlock(&dev->object_name_lock);