1*41ec0267Sriastradh /* $NetBSD: virtgpu_debugfs.c,v 1.3 2021/12/18 23:45:45 riastradh Exp $ */
2efa246c0Sriastradh
3efa246c0Sriastradh /*
4efa246c0Sriastradh * Copyright (C) 2015 Red Hat, Inc.
5efa246c0Sriastradh * All Rights Reserved.
6efa246c0Sriastradh *
7efa246c0Sriastradh * Permission is hereby granted, free of charge, to any person obtaining
8efa246c0Sriastradh * a copy of this software and associated documentation files (the
9efa246c0Sriastradh * "Software"), to deal in the Software without restriction, including
10efa246c0Sriastradh * without limitation the rights to use, copy, modify, merge, publish,
11efa246c0Sriastradh * distribute, sublicense, and/or sell copies of the Software, and to
12efa246c0Sriastradh * permit persons to whom the Software is furnished to do so, subject to
13efa246c0Sriastradh * the following conditions:
14efa246c0Sriastradh *
15efa246c0Sriastradh * The above copyright notice and this permission notice (including the
16efa246c0Sriastradh * next paragraph) shall be included in all copies or substantial
17efa246c0Sriastradh * portions of the Software.
18efa246c0Sriastradh *
19efa246c0Sriastradh * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20efa246c0Sriastradh * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21efa246c0Sriastradh * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22efa246c0Sriastradh * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
23efa246c0Sriastradh * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24efa246c0Sriastradh * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25efa246c0Sriastradh * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26efa246c0Sriastradh */
27efa246c0Sriastradh
28efa246c0Sriastradh #include <sys/cdefs.h>
29*41ec0267Sriastradh __KERNEL_RCSID(0, "$NetBSD: virtgpu_debugfs.c,v 1.3 2021/12/18 23:45:45 riastradh Exp $");
30efa246c0Sriastradh
31*41ec0267Sriastradh #include <drm/drm_debugfs.h>
32*41ec0267Sriastradh #include <drm/drm_file.h>
33efa246c0Sriastradh
34efa246c0Sriastradh #include "virtgpu_drv.h"
35efa246c0Sriastradh
virtio_add_bool(struct seq_file * m,const char * name,bool value)36*41ec0267Sriastradh static void virtio_add_bool(struct seq_file *m, const char *name,
37*41ec0267Sriastradh bool value)
38*41ec0267Sriastradh {
39*41ec0267Sriastradh seq_printf(m, "%-16s : %s\n", name, value ? "yes" : "no");
40*41ec0267Sriastradh }
41*41ec0267Sriastradh
virtio_add_int(struct seq_file * m,const char * name,int value)42*41ec0267Sriastradh static void virtio_add_int(struct seq_file *m, const char *name,
43*41ec0267Sriastradh int value)
44*41ec0267Sriastradh {
45*41ec0267Sriastradh seq_printf(m, "%-16s : %d\n", name, value);
46*41ec0267Sriastradh }
47*41ec0267Sriastradh
virtio_gpu_features(struct seq_file * m,void * data)48*41ec0267Sriastradh static int virtio_gpu_features(struct seq_file *m, void *data)
49*41ec0267Sriastradh {
50*41ec0267Sriastradh struct drm_info_node *node = (struct drm_info_node *) m->private;
51*41ec0267Sriastradh struct virtio_gpu_device *vgdev = node->minor->dev->dev_private;
52*41ec0267Sriastradh
53*41ec0267Sriastradh virtio_add_bool(m, "virgl", vgdev->has_virgl_3d);
54*41ec0267Sriastradh virtio_add_bool(m, "edid", vgdev->has_edid);
55*41ec0267Sriastradh virtio_add_int(m, "cap sets", vgdev->num_capsets);
56*41ec0267Sriastradh virtio_add_int(m, "scanouts", vgdev->num_scanouts);
57*41ec0267Sriastradh return 0;
58*41ec0267Sriastradh }
59*41ec0267Sriastradh
60efa246c0Sriastradh static int
virtio_gpu_debugfs_irq_info(struct seq_file * m,void * data)61efa246c0Sriastradh virtio_gpu_debugfs_irq_info(struct seq_file *m, void *data)
62efa246c0Sriastradh {
63efa246c0Sriastradh struct drm_info_node *node = (struct drm_info_node *) m->private;
64efa246c0Sriastradh struct virtio_gpu_device *vgdev = node->minor->dev->dev_private;
65efa246c0Sriastradh
66efa246c0Sriastradh seq_printf(m, "fence %llu %lld\n",
67efa246c0Sriastradh (u64)atomic64_read(&vgdev->fence_drv.last_seq),
68efa246c0Sriastradh vgdev->fence_drv.sync_seq);
69efa246c0Sriastradh return 0;
70efa246c0Sriastradh }
71efa246c0Sriastradh
72efa246c0Sriastradh static struct drm_info_list virtio_gpu_debugfs_list[] = {
73*41ec0267Sriastradh { "virtio-gpu-features", virtio_gpu_features },
74*41ec0267Sriastradh { "virtio-gpu-irq-fence", virtio_gpu_debugfs_irq_info, 0, NULL },
75efa246c0Sriastradh };
76efa246c0Sriastradh
77efa246c0Sriastradh #define VIRTIO_GPU_DEBUGFS_ENTRIES ARRAY_SIZE(virtio_gpu_debugfs_list)
78efa246c0Sriastradh
79efa246c0Sriastradh int
virtio_gpu_debugfs_init(struct drm_minor * minor)80efa246c0Sriastradh virtio_gpu_debugfs_init(struct drm_minor *minor)
81efa246c0Sriastradh {
82efa246c0Sriastradh drm_debugfs_create_files(virtio_gpu_debugfs_list,
83efa246c0Sriastradh VIRTIO_GPU_DEBUGFS_ENTRIES,
84efa246c0Sriastradh minor->debugfs_root, minor);
85efa246c0Sriastradh return 0;
86efa246c0Sriastradh }
87