summaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorSunny He <suhe@nvidia.com>2017-06-21 15:08:08 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-08-24 12:34:52 -0400
commitcc64606a535edd9fd96487631f8ef583226fc575 (patch)
treee639f1496ab22b35fde90643abd2ddfc28a27bf5 /drivers/gpu
parent4b5b67d6d83430d8d670660b1dfc9cf024d60d88 (diff)
gpu: nvgpu: debugfs code to dump HAL functions
Prints addresses of device-specific HAL functions to debugfs file hal/gops. The list of functions is produced by dumping the contents of the gpu_ops substruct of the gk20a struct. This interface makes the assumption that there are only function pointers in gpu_ops. Companion Python script nvgpu_debug_hal.py analyzes gk20a.h to determine operation counts and prettyify debugfs interface's output. Jira NVGPU-107 Change-Id: I0910e86638d144979e8630bbc5b330bccfd3ad94 Signed-off-by: Sunny He <suhe@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1542990 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/nvgpu/Makefile.nvgpu1
-rw-r--r--drivers/gpu/nvgpu/common/linux/debug.c2
-rw-r--r--drivers/gpu/nvgpu/common/linux/debug_hal.c95
-rw-r--r--drivers/gpu/nvgpu/common/linux/debug_hal.h22
-rw-r--r--drivers/gpu/nvgpu/common/linux/os_linux.h1
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.h5
6 files changed, 126 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/Makefile.nvgpu b/drivers/gpu/nvgpu/Makefile.nvgpu
index 2aa76497..dab9db92 100644
--- a/drivers/gpu/nvgpu/Makefile.nvgpu
+++ b/drivers/gpu/nvgpu/Makefile.nvgpu
@@ -129,6 +129,7 @@ nvgpu-$(CONFIG_DEBUG_FS) += \
129 common/linux/debug_sched.o \ 129 common/linux/debug_sched.o \
130 common/linux/debug_mm.o \ 130 common/linux/debug_mm.o \
131 common/linux/debug_allocator.o \ 131 common/linux/debug_allocator.o \
132 common/linux/debug_hal.o \
132 common/linux/debug_kmem.o \ 133 common/linux/debug_kmem.o \
133 common/linux/debug_clk.o 134 common/linux/debug_clk.o
134 135
diff --git a/drivers/gpu/nvgpu/common/linux/debug.c b/drivers/gpu/nvgpu/common/linux/debug.c
index 7dce74d6..abc8b907 100644
--- a/drivers/gpu/nvgpu/common/linux/debug.c
+++ b/drivers/gpu/nvgpu/common/linux/debug.c
@@ -21,6 +21,7 @@
21#include "debug_kmem.h" 21#include "debug_kmem.h"
22#include "debug_pmu.h" 22#include "debug_pmu.h"
23#include "debug_sched.h" 23#include "debug_sched.h"
24#include "debug_hal.h"
24#include "os_linux.h" 25#include "os_linux.h"
25 26
26#include "gk20a/gk20a.h" 27#include "gk20a/gk20a.h"
@@ -386,6 +387,7 @@ void gk20a_debug_init(struct gk20a *g, const char *debugfs_symlink)
386 gk20a_cde_debugfs_init(g); 387 gk20a_cde_debugfs_init(g);
387 gk20a_ce_debugfs_init(g); 388 gk20a_ce_debugfs_init(g);
388 nvgpu_alloc_debugfs_init(g); 389 nvgpu_alloc_debugfs_init(g);
390 nvgpu_hal_debugfs_init(g);
389 gk20a_mm_debugfs_init(g); 391 gk20a_mm_debugfs_init(g);
390 gk20a_fifo_debugfs_init(g); 392 gk20a_fifo_debugfs_init(g);
391 gk20a_sched_debugfs_init(g); 393 gk20a_sched_debugfs_init(g);
diff --git a/drivers/gpu/nvgpu/common/linux/debug_hal.c b/drivers/gpu/nvgpu/common/linux/debug_hal.c
new file mode 100644
index 00000000..031e335e
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/linux/debug_hal.c
@@ -0,0 +1,95 @@
1/*
2 * Copyright (C) 2017 NVIDIA Corporation. All rights reserved.
3 *
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 */
14
15#include "debug_hal.h"
16#include "os_linux.h"
17
18#include <linux/debugfs.h>
19#include <linux/seq_file.h>
20
21/* Format and print a single function pointer to the specified seq_file. */
22static void __hal_print_op(struct seq_file *s, void *op_ptr)
23{
24 seq_printf(s, "%pF\n", op_ptr);
25}
26
27/*
28 * Prints an array of function pointer addresses in op_ptrs to the
29 * specified seq_file
30 */
31static void __hal_print_ops(struct seq_file *s, void **op_ptrs, int num_ops)
32{
33 int i;
34
35 for (i = 0; i < num_ops; i++)
36 __hal_print_op(s, op_ptrs[i]);
37}
38
39/*
40 * Show file operation, which generates content of the file once. Prints a list
41 * of gpu operations as defined by gops and the corresponding function pointer
42 * destination addresses. Relies on no compiler reordering of struct fields and
43 * assumption that all members are function pointers.
44 */
45static int __hal_show(struct seq_file *s, void *unused)
46{
47 struct gpu_ops *gops = s->private;
48
49 __hal_print_ops(s, (void **)gops, sizeof(*gops) / sizeof(void *));
50
51 return 0;
52}
53
54static int __hal_open(struct inode *inode, struct file *file)
55{
56 return single_open(file, __hal_show, inode->i_private);
57}
58
59static const struct file_operations __hal_fops = {
60 .open = __hal_open,
61 .read = seq_read,
62 .llseek = seq_lseek,
63 .release = single_release,
64};
65
66void nvgpu_hal_debugfs_fini(struct gk20a *g)
67{
68 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
69
70 if (!(l->debugfs_hal == NULL))
71 debugfs_remove_recursive(l->debugfs_hal);
72}
73
74void nvgpu_hal_debugfs_init(struct gk20a *g)
75{
76 struct dentry *d;
77 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
78
79 if (!l->debugfs)
80 return;
81 l->debugfs_hal = debugfs_create_dir("hal", l->debugfs);
82 if (IS_ERR_OR_NULL(l->debugfs_hal)) {
83 l->debugfs_hal = NULL;
84 return;
85 }
86
87 /* Pass along reference to the gpu_ops struct as private data */
88 d = debugfs_create_file("gops", S_IRUGO, l->debugfs_hal,
89 &g->ops, &__hal_fops);
90 if (!d) {
91 nvgpu_err(g, "%s: Failed to make debugfs node\n", __func__);
92 debugfs_remove_recursive(l->debugfs_hal);
93 return;
94 }
95}
diff --git a/drivers/gpu/nvgpu/common/linux/debug_hal.h b/drivers/gpu/nvgpu/common/linux/debug_hal.h
new file mode 100644
index 00000000..eee6f234
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/linux/debug_hal.h
@@ -0,0 +1,22 @@
1/*
2 * Copyright (C) 2017 NVIDIA Corporation. All rights reserved.
3 *
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 */
14
15#ifndef __NVGPU_DEBUG_HAL_H__
16#define __NVGPU_DEBUG_HAL_H__
17
18struct gk20a;
19void nvgpu_hal_debugfs_fini(struct gk20a *g);
20void nvgpu_hal_debugfs_init(struct gk20a *g);
21
22#endif /* __NVGPU_DEBUG_HAL_H__ */
diff --git a/drivers/gpu/nvgpu/common/linux/os_linux.h b/drivers/gpu/nvgpu/common/linux/os_linux.h
index d7fdfa78..ed8364a9 100644
--- a/drivers/gpu/nvgpu/common/linux/os_linux.h
+++ b/drivers/gpu/nvgpu/common/linux/os_linux.h
@@ -102,6 +102,7 @@ struct nvgpu_os_linux {
102 struct dentry *debugfs_allocators; 102 struct dentry *debugfs_allocators;
103 struct dentry *debugfs_xve; 103 struct dentry *debugfs_xve;
104 struct dentry *debugfs_kmem; 104 struct dentry *debugfs_kmem;
105 struct dentry *debugfs_hal;
105 106
106 struct dentry *debugfs_force_preemption_cilp; 107 struct dentry *debugfs_force_preemption_cilp;
107 struct dentry *debugfs_force_preemption_gfxp; 108 struct dentry *debugfs_force_preemption_gfxp;
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h
index 15e81291..121dd962 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.h
@@ -130,6 +130,11 @@ enum gk20a_cbc_op {
130 130
131enum nvgpu_unit; 131enum nvgpu_unit;
132 132
133/*
134 * gpu_ops should only contain function pointers! Non-function pointer members
135 * should go in struct gk20a or be implemented with the boolean flag API defined
136 * in nvgpu/enabled.h
137 */
133struct gpu_ops { 138struct gpu_ops {
134 struct { 139 struct {
135 int (*determine_L2_size_bytes)(struct gk20a *gk20a); 140 int (*determine_L2_size_bytes)(struct gk20a *gk20a);