0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
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
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 }