Linux Audio

Check our new training course

Loading...
v3.1
  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
 36#include <ttm/ttm_page_alloc.h>
 37
 38static int
 39nouveau_debugfs_channel_info(struct seq_file *m, void *data)
 40{
 41	struct drm_info_node *node = (struct drm_info_node *) m->private;
 42	struct nouveau_channel *chan = node->info_ent->data;
 43
 44	seq_printf(m, "channel id    : %d\n", chan->id);
 45
 46	seq_printf(m, "cpu fifo state:\n");
 47	seq_printf(m, "          base: 0x%08x\n", chan->pushbuf_base);
 48	seq_printf(m, "           max: 0x%08x\n", chan->dma.max << 2);
 49	seq_printf(m, "           cur: 0x%08x\n", chan->dma.cur << 2);
 50	seq_printf(m, "           put: 0x%08x\n", chan->dma.put << 2);
 51	seq_printf(m, "          free: 0x%08x\n", chan->dma.free << 2);
 52	if (chan->dma.ib_max) {
 53		seq_printf(m, "        ib max: 0x%08x\n", chan->dma.ib_max);
 54		seq_printf(m, "        ib put: 0x%08x\n", chan->dma.ib_put);
 55		seq_printf(m, "       ib free: 0x%08x\n", chan->dma.ib_free);
 56	}
 57
 58	seq_printf(m, "gpu fifo state:\n");
 59	seq_printf(m, "           get: 0x%08x\n",
 60					nvchan_rd32(chan, chan->user_get));
 61	seq_printf(m, "           put: 0x%08x\n",
 62					nvchan_rd32(chan, chan->user_put));
 63	if (chan->dma.ib_max) {
 64		seq_printf(m, "        ib get: 0x%08x\n",
 65			   nvchan_rd32(chan, 0x88));
 66		seq_printf(m, "        ib put: 0x%08x\n",
 67			   nvchan_rd32(chan, 0x8c));
 68	}
 69
 70	seq_printf(m, "last fence    : %d\n", chan->fence.sequence);
 71	seq_printf(m, "last signalled: %d\n", chan->fence.sequence_ack);
 72	return 0;
 73}
 74
 75int
 76nouveau_debugfs_channel_init(struct nouveau_channel *chan)
 77{
 78	struct drm_nouveau_private *dev_priv = chan->dev->dev_private;
 79	struct drm_minor *minor = chan->dev->primary;
 80	int ret;
 81
 82	if (!dev_priv->debugfs.channel_root) {
 83		dev_priv->debugfs.channel_root =
 84			debugfs_create_dir("channel", minor->debugfs_root);
 85		if (!dev_priv->debugfs.channel_root)
 86			return -ENOENT;
 87	}
 88
 89	snprintf(chan->debugfs.name, 32, "%d", chan->id);
 90	chan->debugfs.info.name = chan->debugfs.name;
 91	chan->debugfs.info.show = nouveau_debugfs_channel_info;
 92	chan->debugfs.info.driver_features = 0;
 93	chan->debugfs.info.data = chan;
 94
 95	ret = drm_debugfs_create_files(&chan->debugfs.info, 1,
 96				       dev_priv->debugfs.channel_root,
 97				       chan->dev->primary);
 98	if (ret == 0)
 99		chan->debugfs.active = true;
100	return ret;
101}
102
103void
104nouveau_debugfs_channel_fini(struct nouveau_channel *chan)
105{
106	struct drm_nouveau_private *dev_priv = chan->dev->dev_private;
107
108	if (!chan->debugfs.active)
109		return;
110
111	drm_debugfs_remove_files(&chan->debugfs.info, 1, chan->dev->primary);
112	chan->debugfs.active = false;
113
114	if (chan == dev_priv->channel) {
115		debugfs_remove(dev_priv->debugfs.channel_root);
116		dev_priv->debugfs.channel_root = NULL;
117	}
118}
119
120static int
121nouveau_debugfs_chipset_info(struct seq_file *m, void *data)
122{
123	struct drm_info_node *node = (struct drm_info_node *) m->private;
124	struct drm_minor *minor = node->minor;
125	struct drm_device *dev = minor->dev;
126	struct drm_nouveau_private *dev_priv = dev->dev_private;
127	uint32_t ppci_0;
128
129	ppci_0 = nv_rd32(dev, dev_priv->chipset >= 0x40 ? 0x88000 : 0x1800);
130
131	seq_printf(m, "PMC_BOOT_0: 0x%08x\n", nv_rd32(dev, NV03_PMC_BOOT_0));
132	seq_printf(m, "PCI ID    : 0x%04x:0x%04x\n",
133		   ppci_0 & 0xffff, ppci_0 >> 16);
134	return 0;
135}
136
137static int
138nouveau_debugfs_memory_info(struct seq_file *m, void *data)
139{
140	struct drm_info_node *node = (struct drm_info_node *) m->private;
141	struct drm_minor *minor = node->minor;
142	struct drm_nouveau_private *dev_priv = minor->dev->dev_private;
143
144	seq_printf(m, "VRAM total: %dKiB\n", (int)(dev_priv->vram_size >> 10));
145	return 0;
146}
147
148static int
149nouveau_debugfs_vbios_image(struct seq_file *m, void *data)
150{
151	struct drm_info_node *node = (struct drm_info_node *) m->private;
152	struct drm_nouveau_private *dev_priv = node->minor->dev->dev_private;
153	int i;
154
155	for (i = 0; i < dev_priv->vbios.length; i++)
156		seq_printf(m, "%c", dev_priv->vbios.data[i]);
157	return 0;
158}
159
160static int
161nouveau_debugfs_evict_vram(struct seq_file *m, void *data)
162{
163	struct drm_info_node *node = (struct drm_info_node *) m->private;
164	struct drm_nouveau_private *dev_priv = node->minor->dev->dev_private;
165	int ret;
166
167	ret = ttm_bo_evict_mm(&dev_priv->ttm.bdev, TTM_PL_VRAM);
168	if (ret)
169		seq_printf(m, "failed: %d", ret);
170	else
171		seq_printf(m, "succeeded\n");
172	return 0;
173}
174
175static struct drm_info_list nouveau_debugfs_list[] = {
176	{ "evict_vram", nouveau_debugfs_evict_vram, 0, NULL },
177	{ "chipset", nouveau_debugfs_chipset_info, 0, NULL },
178	{ "memory", nouveau_debugfs_memory_info, 0, NULL },
179	{ "vbios.rom", nouveau_debugfs_vbios_image, 0, NULL },
180	{ "ttm_page_pool", ttm_page_alloc_debugfs, 0, NULL },
 
181};
182#define NOUVEAU_DEBUGFS_ENTRIES ARRAY_SIZE(nouveau_debugfs_list)
183
184int
185nouveau_debugfs_init(struct drm_minor *minor)
186{
187	drm_debugfs_create_files(nouveau_debugfs_list, NOUVEAU_DEBUGFS_ENTRIES,
188				 minor->debugfs_root, minor);
189	return 0;
190}
191
192void
193nouveau_debugfs_takedown(struct drm_minor *minor)
194{
195	drm_debugfs_remove_files(nouveau_debugfs_list, NOUVEAU_DEBUGFS_ENTRIES,
196				 minor);
197}
v3.5.6
  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
 36#include <ttm/ttm_page_alloc.h>
 37
 38static int
 39nouveau_debugfs_channel_info(struct seq_file *m, void *data)
 40{
 41	struct drm_info_node *node = (struct drm_info_node *) m->private;
 42	struct nouveau_channel *chan = node->info_ent->data;
 43
 44	seq_printf(m, "channel id    : %d\n", chan->id);
 45
 46	seq_printf(m, "cpu fifo state:\n");
 47	seq_printf(m, "          base: 0x%10llx\n", chan->pushbuf_base);
 48	seq_printf(m, "           max: 0x%08x\n", chan->dma.max << 2);
 49	seq_printf(m, "           cur: 0x%08x\n", chan->dma.cur << 2);
 50	seq_printf(m, "           put: 0x%08x\n", chan->dma.put << 2);
 51	seq_printf(m, "          free: 0x%08x\n", chan->dma.free << 2);
 52	if (chan->dma.ib_max) {
 53		seq_printf(m, "        ib max: 0x%08x\n", chan->dma.ib_max);
 54		seq_printf(m, "        ib put: 0x%08x\n", chan->dma.ib_put);
 55		seq_printf(m, "       ib free: 0x%08x\n", chan->dma.ib_free);
 56	}
 57
 58	seq_printf(m, "gpu fifo state:\n");
 59	seq_printf(m, "           get: 0x%08x\n",
 60					nvchan_rd32(chan, chan->user_get));
 61	seq_printf(m, "           put: 0x%08x\n",
 62					nvchan_rd32(chan, chan->user_put));
 63	if (chan->dma.ib_max) {
 64		seq_printf(m, "        ib get: 0x%08x\n",
 65			   nvchan_rd32(chan, 0x88));
 66		seq_printf(m, "        ib put: 0x%08x\n",
 67			   nvchan_rd32(chan, 0x8c));
 68	}
 69
 
 
 70	return 0;
 71}
 72
 73int
 74nouveau_debugfs_channel_init(struct nouveau_channel *chan)
 75{
 76	struct drm_nouveau_private *dev_priv = chan->dev->dev_private;
 77	struct drm_minor *minor = chan->dev->primary;
 78	int ret;
 79
 80	if (!dev_priv->debugfs.channel_root) {
 81		dev_priv->debugfs.channel_root =
 82			debugfs_create_dir("channel", minor->debugfs_root);
 83		if (!dev_priv->debugfs.channel_root)
 84			return -ENOENT;
 85	}
 86
 87	snprintf(chan->debugfs.name, 32, "%d", chan->id);
 88	chan->debugfs.info.name = chan->debugfs.name;
 89	chan->debugfs.info.show = nouveau_debugfs_channel_info;
 90	chan->debugfs.info.driver_features = 0;
 91	chan->debugfs.info.data = chan;
 92
 93	ret = drm_debugfs_create_files(&chan->debugfs.info, 1,
 94				       dev_priv->debugfs.channel_root,
 95				       chan->dev->primary);
 96	if (ret == 0)
 97		chan->debugfs.active = true;
 98	return ret;
 99}
100
101void
102nouveau_debugfs_channel_fini(struct nouveau_channel *chan)
103{
104	struct drm_nouveau_private *dev_priv = chan->dev->dev_private;
105
106	if (!chan->debugfs.active)
107		return;
108
109	drm_debugfs_remove_files(&chan->debugfs.info, 1, chan->dev->primary);
110	chan->debugfs.active = false;
111
112	if (chan == dev_priv->channel) {
113		debugfs_remove(dev_priv->debugfs.channel_root);
114		dev_priv->debugfs.channel_root = NULL;
115	}
116}
117
118static int
119nouveau_debugfs_chipset_info(struct seq_file *m, void *data)
120{
121	struct drm_info_node *node = (struct drm_info_node *) m->private;
122	struct drm_minor *minor = node->minor;
123	struct drm_device *dev = minor->dev;
124	struct drm_nouveau_private *dev_priv = dev->dev_private;
125	uint32_t ppci_0;
126
127	ppci_0 = nv_rd32(dev, dev_priv->chipset >= 0x40 ? 0x88000 : 0x1800);
128
129	seq_printf(m, "PMC_BOOT_0: 0x%08x\n", nv_rd32(dev, NV03_PMC_BOOT_0));
130	seq_printf(m, "PCI ID    : 0x%04x:0x%04x\n",
131		   ppci_0 & 0xffff, ppci_0 >> 16);
132	return 0;
133}
134
135static int
136nouveau_debugfs_memory_info(struct seq_file *m, void *data)
137{
138	struct drm_info_node *node = (struct drm_info_node *) m->private;
139	struct drm_minor *minor = node->minor;
140	struct drm_nouveau_private *dev_priv = minor->dev->dev_private;
141
142	seq_printf(m, "VRAM total: %dKiB\n", (int)(dev_priv->vram_size >> 10));
143	return 0;
144}
145
146static int
147nouveau_debugfs_vbios_image(struct seq_file *m, void *data)
148{
149	struct drm_info_node *node = (struct drm_info_node *) m->private;
150	struct drm_nouveau_private *dev_priv = node->minor->dev->dev_private;
151	int i;
152
153	for (i = 0; i < dev_priv->vbios.length; i++)
154		seq_printf(m, "%c", dev_priv->vbios.data[i]);
155	return 0;
156}
157
158static int
159nouveau_debugfs_evict_vram(struct seq_file *m, void *data)
160{
161	struct drm_info_node *node = (struct drm_info_node *) m->private;
162	struct drm_nouveau_private *dev_priv = node->minor->dev->dev_private;
163	int ret;
164
165	ret = ttm_bo_evict_mm(&dev_priv->ttm.bdev, TTM_PL_VRAM);
166	if (ret)
167		seq_printf(m, "failed: %d", ret);
168	else
169		seq_printf(m, "succeeded\n");
170	return 0;
171}
172
173static struct drm_info_list nouveau_debugfs_list[] = {
174	{ "evict_vram", nouveau_debugfs_evict_vram, 0, NULL },
175	{ "chipset", nouveau_debugfs_chipset_info, 0, NULL },
176	{ "memory", nouveau_debugfs_memory_info, 0, NULL },
177	{ "vbios.rom", nouveau_debugfs_vbios_image, 0, NULL },
178	{ "ttm_page_pool", ttm_page_alloc_debugfs, 0, NULL },
179	{ "ttm_dma_page_pool", ttm_dma_page_alloc_debugfs, 0, NULL },
180};
181#define NOUVEAU_DEBUGFS_ENTRIES ARRAY_SIZE(nouveau_debugfs_list)
182
183int
184nouveau_debugfs_init(struct drm_minor *minor)
185{
186	drm_debugfs_create_files(nouveau_debugfs_list, NOUVEAU_DEBUGFS_ENTRIES,
187				 minor->debugfs_root, minor);
188	return 0;
189}
190
191void
192nouveau_debugfs_takedown(struct drm_minor *minor)
193{
194	drm_debugfs_remove_files(nouveau_debugfs_list, NOUVEAU_DEBUGFS_ENTRIES,
195				 minor);
196}