forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/gpu/drm/v3d/v3d_debugfs.c
....@@ -6,7 +6,8 @@
66 #include <linux/debugfs.h>
77 #include <linux/pm_runtime.h>
88 #include <linux/seq_file.h>
9
-#include <drm/drmP.h>
9
+
10
+#include <drm/drm_debugfs.h>
1011
1112 #include "v3d_drv.h"
1213 #include "v3d_regs.h"
....@@ -26,6 +27,11 @@
2627 REGDEF(V3D_HUB_IDENT3),
2728 REGDEF(V3D_HUB_INT_STS),
2829 REGDEF(V3D_HUB_INT_MSK_STS),
30
+
31
+ REGDEF(V3D_MMU_CTL),
32
+ REGDEF(V3D_MMU_VIO_ADDR),
33
+ REGDEF(V3D_MMU_VIO_ID),
34
+ REGDEF(V3D_MMU_DEBUG_INFO),
2935 };
3036
3137 static const struct v3d_reg_def v3d_gca_reg_defs[] = {
....@@ -50,12 +56,25 @@
5056 REGDEF(V3D_PTB_BPCA),
5157 REGDEF(V3D_PTB_BPCS),
5258
53
- REGDEF(V3D_MMU_CTL),
54
- REGDEF(V3D_MMU_VIO_ADDR),
55
-
5659 REGDEF(V3D_GMP_STATUS),
5760 REGDEF(V3D_GMP_CFG),
5861 REGDEF(V3D_GMP_VIO_ADDR),
62
+
63
+ REGDEF(V3D_ERR_FDBGO),
64
+ REGDEF(V3D_ERR_FDBGB),
65
+ REGDEF(V3D_ERR_FDBGS),
66
+ REGDEF(V3D_ERR_STAT),
67
+};
68
+
69
+static const struct v3d_reg_def v3d_csd_reg_defs[] = {
70
+ REGDEF(V3D_CSD_STATUS),
71
+ REGDEF(V3D_CSD_CURRENT_CFG0),
72
+ REGDEF(V3D_CSD_CURRENT_CFG1),
73
+ REGDEF(V3D_CSD_CURRENT_CFG2),
74
+ REGDEF(V3D_CSD_CURRENT_CFG3),
75
+ REGDEF(V3D_CSD_CURRENT_CFG4),
76
+ REGDEF(V3D_CSD_CURRENT_CFG5),
77
+ REGDEF(V3D_CSD_CURRENT_CFG6),
5978 };
6079
6180 static int v3d_v3d_debugfs_regs(struct seq_file *m, void *unused)
....@@ -89,6 +108,17 @@
89108 V3D_CORE_READ(core,
90109 v3d_core_reg_defs[i].reg));
91110 }
111
+
112
+ if (v3d_has_csd(v3d)) {
113
+ for (i = 0; i < ARRAY_SIZE(v3d_csd_reg_defs); i++) {
114
+ seq_printf(m, "core %d %s (0x%04x): 0x%08x\n",
115
+ core,
116
+ v3d_csd_reg_defs[i].name,
117
+ v3d_csd_reg_defs[i].reg,
118
+ V3D_CORE_READ(core,
119
+ v3d_csd_reg_defs[i].reg));
120
+ }
121
+ }
92122 }
93123
94124 return 0;
....@@ -102,7 +132,7 @@
102132 u32 ident0, ident1, ident2, ident3, cores;
103133 int ret, core;
104134
105
- ret = pm_runtime_get_sync(v3d->dev);
135
+ ret = pm_runtime_get_sync(v3d->drm.dev);
106136 if (ret < 0)
107137 return ret;
108138
....@@ -157,8 +187,8 @@
157187 (misccfg & V3D_MISCCFG_OVRTMUOUT) != 0);
158188 }
159189
160
- pm_runtime_mark_last_busy(v3d->dev);
161
- pm_runtime_put_autosuspend(v3d->dev);
190
+ pm_runtime_mark_last_busy(v3d->drm.dev);
191
+ pm_runtime_put_autosuspend(v3d->drm.dev);
162192
163193 return 0;
164194 }
....@@ -179,16 +209,59 @@
179209 return 0;
180210 }
181211
212
+static int v3d_measure_clock(struct seq_file *m, void *unused)
213
+{
214
+ struct drm_info_node *node = (struct drm_info_node *)m->private;
215
+ struct drm_device *dev = node->minor->dev;
216
+ struct v3d_dev *v3d = to_v3d_dev(dev);
217
+ uint32_t cycles;
218
+ int core = 0;
219
+ int measure_ms = 1000;
220
+ int ret;
221
+
222
+ ret = pm_runtime_get_sync(v3d->drm.dev);
223
+ if (ret < 0)
224
+ return ret;
225
+
226
+ if (v3d->ver >= 40) {
227
+ V3D_CORE_WRITE(core, V3D_V4_PCTR_0_SRC_0_3,
228
+ V3D_SET_FIELD(V3D_PCTR_CYCLE_COUNT,
229
+ V3D_PCTR_S0));
230
+ V3D_CORE_WRITE(core, V3D_V4_PCTR_0_CLR, 1);
231
+ V3D_CORE_WRITE(core, V3D_V4_PCTR_0_EN, 1);
232
+ } else {
233
+ V3D_CORE_WRITE(core, V3D_V3_PCTR_0_PCTRS0,
234
+ V3D_PCTR_CYCLE_COUNT);
235
+ V3D_CORE_WRITE(core, V3D_V3_PCTR_0_CLR, 1);
236
+ V3D_CORE_WRITE(core, V3D_V3_PCTR_0_EN,
237
+ V3D_V3_PCTR_0_EN_ENABLE |
238
+ 1);
239
+ }
240
+ msleep(measure_ms);
241
+ cycles = V3D_CORE_READ(core, V3D_PCTR_0_PCTR0);
242
+
243
+ seq_printf(m, "cycles: %d (%d.%d Mhz)\n",
244
+ cycles,
245
+ cycles / (measure_ms * 1000),
246
+ (cycles / (measure_ms * 100)) % 10);
247
+
248
+ pm_runtime_mark_last_busy(v3d->drm.dev);
249
+ pm_runtime_put_autosuspend(v3d->drm.dev);
250
+
251
+ return 0;
252
+}
253
+
182254 static const struct drm_info_list v3d_debugfs_list[] = {
183255 {"v3d_ident", v3d_v3d_debugfs_ident, 0},
184256 {"v3d_regs", v3d_v3d_debugfs_regs, 0},
257
+ {"measure_clock", v3d_measure_clock, 0},
185258 {"bo_stats", v3d_debugfs_bo_stats, 0},
186259 };
187260
188
-int
261
+void
189262 v3d_debugfs_init(struct drm_minor *minor)
190263 {
191
- return drm_debugfs_create_files(v3d_debugfs_list,
192
- ARRAY_SIZE(v3d_debugfs_list),
193
- minor->debugfs_root, minor);
264
+ drm_debugfs_create_files(v3d_debugfs_list,
265
+ ARRAY_SIZE(v3d_debugfs_list),
266
+ minor->debugfs_root, minor);
194267 }