Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (C) 2015 Red Hat, Inc.
0003  * All Rights Reserved.
0004  *
0005  * Permission is hereby granted, free of charge, to any person obtaining
0006  * a copy of this software and associated documentation files (the
0007  * "Software"), to deal in the Software without restriction, including
0008  * without limitation the rights to use, copy, modify, merge, publish,
0009  * distribute, sublicense, and/or sell copies of the Software, and to
0010  * permit persons to whom the Software is furnished to do so, subject to
0011  * the following conditions:
0012  *
0013  * The above copyright notice and this permission notice (including the
0014  * next paragraph) shall be included in all copies or substantial
0015  * portions of the Software.
0016  *
0017  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0018  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0019  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
0020  * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
0021  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
0022  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
0023  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0024  */
0025 
0026 #include <linux/string_helpers.h>
0027 
0028 #include <drm/drm_debugfs.h>
0029 #include <drm/drm_file.h>
0030 
0031 #include "virtgpu_drv.h"
0032 
0033 static void virtio_gpu_add_bool(struct seq_file *m, const char *name,
0034                 bool value)
0035 {
0036     seq_printf(m, "%-16s : %s\n", name, str_yes_no(value));
0037 }
0038 
0039 static void virtio_gpu_add_int(struct seq_file *m, const char *name, int value)
0040 {
0041     seq_printf(m, "%-16s : %d\n", name, value);
0042 }
0043 
0044 static int virtio_gpu_features(struct seq_file *m, void *data)
0045 {
0046     struct drm_info_node *node = (struct drm_info_node *)m->private;
0047     struct virtio_gpu_device *vgdev = node->minor->dev->dev_private;
0048 
0049     virtio_gpu_add_bool(m, "virgl", vgdev->has_virgl_3d);
0050     virtio_gpu_add_bool(m, "edid", vgdev->has_edid);
0051     virtio_gpu_add_bool(m, "indirect", vgdev->has_indirect);
0052 
0053     virtio_gpu_add_bool(m, "resource uuid",
0054                 vgdev->has_resource_assign_uuid);
0055 
0056     virtio_gpu_add_bool(m, "blob resources", vgdev->has_resource_blob);
0057     virtio_gpu_add_bool(m, "context init", vgdev->has_context_init);
0058     virtio_gpu_add_int(m, "cap sets", vgdev->num_capsets);
0059     virtio_gpu_add_int(m, "scanouts", vgdev->num_scanouts);
0060     if (vgdev->host_visible_region.len) {
0061         seq_printf(m, "%-16s : 0x%lx +0x%lx\n", "host visible region",
0062                (unsigned long)vgdev->host_visible_region.addr,
0063                (unsigned long)vgdev->host_visible_region.len);
0064     }
0065     return 0;
0066 }
0067 
0068 static int
0069 virtio_gpu_debugfs_irq_info(struct seq_file *m, void *data)
0070 {
0071     struct drm_info_node *node = (struct drm_info_node *) m->private;
0072     struct virtio_gpu_device *vgdev = node->minor->dev->dev_private;
0073 
0074     seq_printf(m, "fence %llu %lld\n",
0075            (u64)atomic64_read(&vgdev->fence_drv.last_fence_id),
0076            vgdev->fence_drv.current_fence_id);
0077     return 0;
0078 }
0079 
0080 static int
0081 virtio_gpu_debugfs_host_visible_mm(struct seq_file *m, void *data)
0082 {
0083     struct drm_info_node *node = (struct drm_info_node *)m->private;
0084     struct virtio_gpu_device *vgdev = node->minor->dev->dev_private;
0085     struct drm_printer p;
0086 
0087     if (!vgdev->has_host_visible) {
0088         seq_puts(m, "Host allocations not visible to guest\n");
0089         return 0;
0090     }
0091 
0092     p = drm_seq_file_printer(m);
0093     drm_mm_print(&vgdev->host_visible_mm, &p);
0094     return 0;
0095 }
0096 
0097 static struct drm_info_list virtio_gpu_debugfs_list[] = {
0098     { "virtio-gpu-features", virtio_gpu_features },
0099     { "virtio-gpu-irq-fence", virtio_gpu_debugfs_irq_info, 0, NULL },
0100     { "virtio-gpu-host-visible-mm", virtio_gpu_debugfs_host_visible_mm },
0101 };
0102 
0103 #define VIRTIO_GPU_DEBUGFS_ENTRIES ARRAY_SIZE(virtio_gpu_debugfs_list)
0104 
0105 void
0106 virtio_gpu_debugfs_init(struct drm_minor *minor)
0107 {
0108     drm_debugfs_create_files(virtio_gpu_debugfs_list,
0109                  VIRTIO_GPU_DEBUGFS_ENTRIES,
0110                  minor->debugfs_root, minor);
0111 }