Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (C) 2009 Red Hat <bskeggs@redhat.com>
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining
0005  * a copy of this software and associated documentation files (the
0006  * "Software"), to deal in the Software without restriction, including
0007  * without limitation the rights to use, copy, modify, merge, publish,
0008  * distribute, sublicense, and/or sell copies of the Software, and to
0009  * permit persons to whom the Software is furnished to do so, subject to
0010  * the following conditions:
0011  *
0012  * The above copyright notice and this permission notice (including the
0013  * next paragraph) shall be included in all copies or substantial
0014  * portions of the Software.
0015  *
0016  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0017  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0018  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
0019  * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
0020  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
0021  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
0022  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0023  *
0024  */
0025 
0026 /*
0027  * Authors:
0028  *  Alon Levy <alevy@redhat.com>
0029  */
0030 
0031 #include <drm/drm_debugfs.h>
0032 #include <drm/drm_file.h>
0033 
0034 #include "qxl_drv.h"
0035 #include "qxl_object.h"
0036 
0037 #if defined(CONFIG_DEBUG_FS)
0038 static int
0039 qxl_debugfs_irq_received(struct seq_file *m, void *data)
0040 {
0041     struct drm_info_node *node = (struct drm_info_node *) m->private;
0042     struct qxl_device *qdev = to_qxl(node->minor->dev);
0043 
0044     seq_printf(m, "%d\n", atomic_read(&qdev->irq_received));
0045     seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_display));
0046     seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_cursor));
0047     seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_io_cmd));
0048     seq_printf(m, "%d\n", qdev->irq_received_error);
0049     return 0;
0050 }
0051 
0052 static int
0053 qxl_debugfs_buffers_info(struct seq_file *m, void *data)
0054 {
0055     struct drm_info_node *node = (struct drm_info_node *) m->private;
0056     struct qxl_device *qdev = to_qxl(node->minor->dev);
0057     struct qxl_bo *bo;
0058 
0059     list_for_each_entry(bo, &qdev->gem.objects, list) {
0060         struct dma_resv_iter cursor;
0061         struct dma_fence *fence;
0062         int rel = 0;
0063 
0064         dma_resv_iter_begin(&cursor, bo->tbo.base.resv,
0065                     DMA_RESV_USAGE_BOOKKEEP);
0066         dma_resv_for_each_fence_unlocked(&cursor, fence) {
0067             if (dma_resv_iter_is_restarted(&cursor))
0068                 rel = 0;
0069             ++rel;
0070         }
0071 
0072         seq_printf(m, "size %ld, pc %d, num releases %d\n",
0073                (unsigned long)bo->tbo.base.size,
0074                bo->tbo.pin_count, rel);
0075     }
0076     return 0;
0077 }
0078 
0079 static struct drm_info_list qxl_debugfs_list[] = {
0080     { "irq_received", qxl_debugfs_irq_received, 0, NULL },
0081     { "qxl_buffers", qxl_debugfs_buffers_info, 0, NULL },
0082 };
0083 #define QXL_DEBUGFS_ENTRIES ARRAY_SIZE(qxl_debugfs_list)
0084 #endif
0085 
0086 void
0087 qxl_debugfs_init(struct drm_minor *minor)
0088 {
0089 #if defined(CONFIG_DEBUG_FS)
0090     struct qxl_device *dev = to_qxl(minor->dev);
0091 
0092     drm_debugfs_create_files(qxl_debugfs_list, QXL_DEBUGFS_ENTRIES,
0093                  minor->debugfs_root, minor);
0094 
0095     qxl_ttm_debugfs_init(dev);
0096 #endif
0097 }
0098 
0099 void qxl_debugfs_add_files(struct qxl_device *qdev,
0100                struct drm_info_list *files,
0101                unsigned int nfiles)
0102 {
0103     unsigned int i;
0104 
0105     for (i = 0; i < qdev->debugfs_count; i++) {
0106         if (qdev->debugfs[i].files == files) {
0107             /* Already registered */
0108             return;
0109         }
0110     }
0111 
0112     i = qdev->debugfs_count + 1;
0113     if (i > QXL_DEBUGFS_MAX_COMPONENTS) {
0114         DRM_ERROR("Reached maximum number of debugfs components.\n");
0115         DRM_ERROR("Report so we increase QXL_DEBUGFS_MAX_COMPONENTS.\n");
0116         return;
0117     }
0118     qdev->debugfs[qdev->debugfs_count].files = files;
0119     qdev->debugfs[qdev->debugfs_count].num_files = nfiles;
0120     qdev->debugfs_count = i;
0121 #if defined(CONFIG_DEBUG_FS)
0122     drm_debugfs_create_files(files, nfiles,
0123                  qdev->ddev.primary->debugfs_root,
0124                  qdev->ddev.primary);
0125 #endif
0126 }