Path: blob/master/drivers/gpu/drm/nouveau/nouveau_debugfs.c
15112 views
/*1* Copyright (C) 2009 Red Hat <[email protected]>2*3* Permission is hereby granted, free of charge, to any person obtaining4* a copy of this software and associated documentation files (the5* "Software"), to deal in the Software without restriction, including6* without limitation the rights to use, copy, modify, merge, publish,7* distribute, sublicense, and/or sell copies of the Software, and to8* permit persons to whom the Software is furnished to do so, subject to9* the following conditions:10*11* The above copyright notice and this permission notice (including the12* next paragraph) shall be included in all copies or substantial13* portions of the Software.14*15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,16* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF17* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.18* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE19* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION20* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION21* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.22*23*/2425/*26* Authors:27* Ben Skeggs <[email protected]>28*/2930#include <linux/debugfs.h>3132#include "drmP.h"33#include "nouveau_drv.h"3435#include <ttm/ttm_page_alloc.h>3637static int38nouveau_debugfs_channel_info(struct seq_file *m, void *data)39{40struct drm_info_node *node = (struct drm_info_node *) m->private;41struct nouveau_channel *chan = node->info_ent->data;4243seq_printf(m, "channel id : %d\n", chan->id);4445seq_printf(m, "cpu fifo state:\n");46seq_printf(m, " base: 0x%08x\n", chan->pushbuf_base);47seq_printf(m, " max: 0x%08x\n", chan->dma.max << 2);48seq_printf(m, " cur: 0x%08x\n", chan->dma.cur << 2);49seq_printf(m, " put: 0x%08x\n", chan->dma.put << 2);50seq_printf(m, " free: 0x%08x\n", chan->dma.free << 2);51if (chan->dma.ib_max) {52seq_printf(m, " ib max: 0x%08x\n", chan->dma.ib_max);53seq_printf(m, " ib put: 0x%08x\n", chan->dma.ib_put);54seq_printf(m, " ib free: 0x%08x\n", chan->dma.ib_free);55}5657seq_printf(m, "gpu fifo state:\n");58seq_printf(m, " get: 0x%08x\n",59nvchan_rd32(chan, chan->user_get));60seq_printf(m, " put: 0x%08x\n",61nvchan_rd32(chan, chan->user_put));62if (chan->dma.ib_max) {63seq_printf(m, " ib get: 0x%08x\n",64nvchan_rd32(chan, 0x88));65seq_printf(m, " ib put: 0x%08x\n",66nvchan_rd32(chan, 0x8c));67}6869seq_printf(m, "last fence : %d\n", chan->fence.sequence);70seq_printf(m, "last signalled: %d\n", chan->fence.sequence_ack);71return 0;72}7374int75nouveau_debugfs_channel_init(struct nouveau_channel *chan)76{77struct drm_nouveau_private *dev_priv = chan->dev->dev_private;78struct drm_minor *minor = chan->dev->primary;79int ret;8081if (!dev_priv->debugfs.channel_root) {82dev_priv->debugfs.channel_root =83debugfs_create_dir("channel", minor->debugfs_root);84if (!dev_priv->debugfs.channel_root)85return -ENOENT;86}8788snprintf(chan->debugfs.name, 32, "%d", chan->id);89chan->debugfs.info.name = chan->debugfs.name;90chan->debugfs.info.show = nouveau_debugfs_channel_info;91chan->debugfs.info.driver_features = 0;92chan->debugfs.info.data = chan;9394ret = drm_debugfs_create_files(&chan->debugfs.info, 1,95dev_priv->debugfs.channel_root,96chan->dev->primary);97if (ret == 0)98chan->debugfs.active = true;99return ret;100}101102void103nouveau_debugfs_channel_fini(struct nouveau_channel *chan)104{105struct drm_nouveau_private *dev_priv = chan->dev->dev_private;106107if (!chan->debugfs.active)108return;109110drm_debugfs_remove_files(&chan->debugfs.info, 1, chan->dev->primary);111chan->debugfs.active = false;112113if (chan == dev_priv->channel) {114debugfs_remove(dev_priv->debugfs.channel_root);115dev_priv->debugfs.channel_root = NULL;116}117}118119static int120nouveau_debugfs_chipset_info(struct seq_file *m, void *data)121{122struct drm_info_node *node = (struct drm_info_node *) m->private;123struct drm_minor *minor = node->minor;124struct drm_device *dev = minor->dev;125struct drm_nouveau_private *dev_priv = dev->dev_private;126uint32_t ppci_0;127128ppci_0 = nv_rd32(dev, dev_priv->chipset >= 0x40 ? 0x88000 : 0x1800);129130seq_printf(m, "PMC_BOOT_0: 0x%08x\n", nv_rd32(dev, NV03_PMC_BOOT_0));131seq_printf(m, "PCI ID : 0x%04x:0x%04x\n",132ppci_0 & 0xffff, ppci_0 >> 16);133return 0;134}135136static int137nouveau_debugfs_memory_info(struct seq_file *m, void *data)138{139struct drm_info_node *node = (struct drm_info_node *) m->private;140struct drm_minor *minor = node->minor;141struct drm_nouveau_private *dev_priv = minor->dev->dev_private;142143seq_printf(m, "VRAM total: %dKiB\n", (int)(dev_priv->vram_size >> 10));144return 0;145}146147static int148nouveau_debugfs_vbios_image(struct seq_file *m, void *data)149{150struct drm_info_node *node = (struct drm_info_node *) m->private;151struct drm_nouveau_private *dev_priv = node->minor->dev->dev_private;152int i;153154for (i = 0; i < dev_priv->vbios.length; i++)155seq_printf(m, "%c", dev_priv->vbios.data[i]);156return 0;157}158159static int160nouveau_debugfs_evict_vram(struct seq_file *m, void *data)161{162struct drm_info_node *node = (struct drm_info_node *) m->private;163struct drm_nouveau_private *dev_priv = node->minor->dev->dev_private;164int ret;165166ret = ttm_bo_evict_mm(&dev_priv->ttm.bdev, TTM_PL_VRAM);167if (ret)168seq_printf(m, "failed: %d", ret);169else170seq_printf(m, "succeeded\n");171return 0;172}173174static struct drm_info_list nouveau_debugfs_list[] = {175{ "evict_vram", nouveau_debugfs_evict_vram, 0, NULL },176{ "chipset", nouveau_debugfs_chipset_info, 0, NULL },177{ "memory", nouveau_debugfs_memory_info, 0, NULL },178{ "vbios.rom", nouveau_debugfs_vbios_image, 0, NULL },179{ "ttm_page_pool", ttm_page_alloc_debugfs, 0, NULL },180};181#define NOUVEAU_DEBUGFS_ENTRIES ARRAY_SIZE(nouveau_debugfs_list)182183int184nouveau_debugfs_init(struct drm_minor *minor)185{186drm_debugfs_create_files(nouveau_debugfs_list, NOUVEAU_DEBUGFS_ENTRIES,187minor->debugfs_root, minor);188return 0;189}190191void192nouveau_debugfs_takedown(struct drm_minor *minor)193{194drm_debugfs_remove_files(nouveau_debugfs_list, NOUVEAU_DEBUGFS_ENTRIES,195minor);196}197198199