summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/debug_gk20a.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/debug_gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/debug_gk20a.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/debug_gk20a.c b/drivers/gpu/nvgpu/gk20a/debug_gk20a.c
index 85b24f2e..1a9ffe77 100644
--- a/drivers/gpu/nvgpu/gk20a/debug_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/debug_gk20a.c
@@ -228,6 +228,74 @@ void gk20a_init_debug_ops(struct gpu_ops *gops)
228 gops->debug.show_dump = gk20a_debug_show_dump; 228 gops->debug.show_dump = gk20a_debug_show_dump;
229} 229}
230 230
231#ifdef CONFIG_DEBUG_FS
232static int railgate_residency_show(struct seq_file *s, void *data)
233{
234 struct device *dev = s->private;
235 struct gk20a_platform *platform = dev_get_drvdata(dev);
236 struct gk20a *g = get_gk20a(dev);
237 unsigned long time_since_last_state_transition_ms;
238 unsigned long total_rail_gate_time_ms;
239 unsigned long total_rail_ungate_time_ms;
240
241 if (platform->is_railgated(dev)) {
242 time_since_last_state_transition_ms =
243 jiffies_to_msecs(jiffies -
244 g->pstats.last_rail_gate_complete);
245 total_rail_ungate_time_ms = g->pstats.total_rail_ungate_time_ms;
246 total_rail_gate_time_ms =
247 g->pstats.total_rail_gate_time_ms +
248 time_since_last_state_transition_ms;
249 } else {
250 time_since_last_state_transition_ms =
251 jiffies_to_msecs(jiffies -
252 g->pstats.last_rail_ungate_complete);
253 total_rail_gate_time_ms = g->pstats.total_rail_gate_time_ms;
254 total_rail_ungate_time_ms =
255 g->pstats.total_rail_ungate_time_ms +
256 time_since_last_state_transition_ms;
257 }
258
259 seq_printf(s, "Time with Rails Gated: %lu ms\n"
260 "Time with Rails UnGated: %lu ms\n"
261 "Total railgating cycles: %lu\n",
262 total_rail_gate_time_ms,
263 total_rail_ungate_time_ms,
264 g->pstats.railgating_cycle_count - 1);
265 return 0;
266
267}
268
269static int railgate_residency_open(struct inode *inode, struct file *file)
270{
271 return single_open(file, railgate_residency_show, inode->i_private);
272}
273
274static const struct file_operations railgate_residency_fops = {
275 .open = railgate_residency_open,
276 .read = seq_read,
277 .llseek = seq_lseek,
278 .release = single_release,
279};
280
281int gk20a_railgating_debugfs_init(struct device *dev)
282{
283 struct dentry *d;
284 struct gk20a_platform *platform = dev_get_drvdata(dev);
285
286 if (!platform->can_railgate)
287 return 0;
288
289 d = debugfs_create_file(
290 "railgate_residency", S_IRUGO|S_IWUSR, platform->debugfs, dev,
291 &railgate_residency_fops);
292 if (!d)
293 return -ENOMEM;
294
295 return 0;
296}
297#endif
298
231void gk20a_debug_init(struct device *dev, const char *debugfs_symlink) 299void gk20a_debug_init(struct device *dev, const char *debugfs_symlink)
232{ 300{
233 struct gk20a_platform *platform = dev_get_drvdata(dev); 301 struct gk20a_platform *platform = dev_get_drvdata(dev);