aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/nouveau_debugfs.c
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2009-12-11 04:24:15 -0500
committerDave Airlie <airlied@redhat.com>2009-12-11 06:29:34 -0500
commit6ee738610f41b59733f63718f0bdbcba7d3a3f12 (patch)
treeeccb9f07671998c50a1bc606a54cd6f82ba43e0a /drivers/gpu/drm/nouveau/nouveau_debugfs.c
parentd1ede145cea25c5b6d2ebb19b167af14e374bb45 (diff)
drm/nouveau: Add DRM driver for NVIDIA GPUs
This adds a drm/kms staging non-API stable driver for GPUs from NVIDIA. This driver is a KMS-based driver and requires a compatible nouveau userspace libdrm and nouveau X.org driver. This driver requires firmware files not available in this kernel tree, interested parties can find them via the nouveau project git archive. This driver is reverse engineered, and is in no way supported by nVidia. Support for nearly the complete range of nvidia hw from nv04->g80 (nv50) is available, and the kms driver should support driving nearly all output types (displayport is under development still) along with supporting suspend/resume. This work is all from the upstream nouveau project found at nouveau.freedesktop.org. The original authors list from nouveau git tree is: Anssi Hannula <anssi.hannula@iki.fi> Ben Skeggs <bskeggs@redhat.com> Francisco Jerez <currojerez@riseup.net> Maarten Maathuis <madman2003@gmail.com> Marcin Koƛcielnicki <koriakin@0x04.net> Matthew Garrett <mjg@redhat.com> Matt Parnell <mparnell@gmail.com> Patrice Mandin <patmandin@gmail.com> Pekka Paalanen <pq@iki.fi> Xavier Chantry <shiningxc@gmail.com> along with project founder Stephane Marchesin <marchesin@icps.u-strasbg.fr> Signed-off-by: Ben Skeggs <bskeggs@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_debugfs.c')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_debugfs.c155
1 files changed, 155 insertions, 0 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
new file mode 100644
index 000000000000..d79db3698f16
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
@@ -0,0 +1,155 @@
1/*
2 * Copyright (C) 2009 Red Hat <bskeggs@redhat.com>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial
14 * portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
20 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *
24 */
25
26/*
27 * Authors:
28 * Ben Skeggs <bskeggs@redhat.com>
29 */
30
31#include <linux/debugfs.h>
32
33#include "drmP.h"
34#include "nouveau_drv.h"
35
36static int
37nouveau_debugfs_channel_info(struct seq_file *m, void *data)
38{
39 struct drm_info_node *node = (struct drm_info_node *) m->private;
40 struct nouveau_channel *chan = node->info_ent->data;
41
42 seq_printf(m, "channel id : %d\n", chan->id);
43
44 seq_printf(m, "cpu fifo state:\n");
45 seq_printf(m, " base: 0x%08x\n", chan->pushbuf_base);
46 seq_printf(m, " max: 0x%08x\n", chan->dma.max << 2);
47 seq_printf(m, " cur: 0x%08x\n", chan->dma.cur << 2);
48 seq_printf(m, " put: 0x%08x\n", chan->dma.put << 2);
49 seq_printf(m, " free: 0x%08x\n", chan->dma.free << 2);
50
51 seq_printf(m, "gpu fifo state:\n");
52 seq_printf(m, " get: 0x%08x\n",
53 nvchan_rd32(chan, chan->user_get));
54 seq_printf(m, " put: 0x%08x\n",
55 nvchan_rd32(chan, chan->user_put));
56
57 seq_printf(m, "last fence : %d\n", chan->fence.sequence);
58 seq_printf(m, "last signalled: %d\n", chan->fence.sequence_ack);
59 return 0;
60}
61
62int
63nouveau_debugfs_channel_init(struct nouveau_channel *chan)
64{
65 struct drm_nouveau_private *dev_priv = chan->dev->dev_private;
66 struct drm_minor *minor = chan->dev->primary;
67 int ret;
68
69 if (!dev_priv->debugfs.channel_root) {
70 dev_priv->debugfs.channel_root =
71 debugfs_create_dir("channel", minor->debugfs_root);
72 if (!dev_priv->debugfs.channel_root)
73 return -ENOENT;
74 }
75
76 snprintf(chan->debugfs.name, 32, "%d", chan->id);
77 chan->debugfs.info.name = chan->debugfs.name;
78 chan->debugfs.info.show = nouveau_debugfs_channel_info;
79 chan->debugfs.info.driver_features = 0;
80 chan->debugfs.info.data = chan;
81
82 ret = drm_debugfs_create_files(&chan->debugfs.info, 1,
83 dev_priv->debugfs.channel_root,
84 chan->dev->primary);
85 if (ret == 0)
86 chan->debugfs.active = true;
87 return ret;
88}
89
90void
91nouveau_debugfs_channel_fini(struct nouveau_channel *chan)
92{
93 struct drm_nouveau_private *dev_priv = chan->dev->dev_private;
94
95 if (!chan->debugfs.active)
96 return;
97
98 drm_debugfs_remove_files(&chan->debugfs.info, 1, chan->dev->primary);
99 chan->debugfs.active = false;
100
101 if (chan == dev_priv->channel) {
102 debugfs_remove(dev_priv->debugfs.channel_root);
103 dev_priv->debugfs.channel_root = NULL;
104 }
105}
106
107static int
108nouveau_debugfs_chipset_info(struct seq_file *m, void *data)
109{
110 struct drm_info_node *node = (struct drm_info_node *) m->private;
111 struct drm_minor *minor = node->minor;
112 struct drm_device *dev = minor->dev;
113 struct drm_nouveau_private *dev_priv = dev->dev_private;
114 uint32_t ppci_0;
115
116 ppci_0 = nv_rd32(dev, dev_priv->chipset >= 0x40 ? 0x88000 : 0x1800);
117
118 seq_printf(m, "PMC_BOOT_0: 0x%08x\n", nv_rd32(dev, NV03_PMC_BOOT_0));
119 seq_printf(m, "PCI ID : 0x%04x:0x%04x\n",
120 ppci_0 & 0xffff, ppci_0 >> 16);
121 return 0;
122}
123
124static int
125nouveau_debugfs_memory_info(struct seq_file *m, void *data)
126{
127 struct drm_info_node *node = (struct drm_info_node *) m->private;
128 struct drm_minor *minor = node->minor;
129 struct drm_device *dev = minor->dev;
130
131 seq_printf(m, "VRAM total: %dKiB\n",
132 (int)(nouveau_mem_fb_amount(dev) >> 10));
133 return 0;
134}
135
136static struct drm_info_list nouveau_debugfs_list[] = {
137 { "chipset", nouveau_debugfs_chipset_info, 0, NULL },
138 { "memory", nouveau_debugfs_memory_info, 0, NULL },
139};
140#define NOUVEAU_DEBUGFS_ENTRIES ARRAY_SIZE(nouveau_debugfs_list)
141
142int
143nouveau_debugfs_init(struct drm_minor *minor)
144{
145 drm_debugfs_create_files(nouveau_debugfs_list, NOUVEAU_DEBUGFS_ENTRIES,
146 minor->debugfs_root, minor);
147 return 0;
148}
149
150void
151nouveau_debugfs_takedown(struct drm_minor *minor)
152{
153 drm_debugfs_remove_files(nouveau_debugfs_list, NOUVEAU_DEBUGFS_ENTRIES,
154 minor);
155}