summaryrefslogtreecommitdiffstats
path: root/drivers/misc/tegra-profiler/debug.h
blob: aa35a737a6126105b5fd53c2799bf1b279453702 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
 * drivers/misc/tegra-profiler/debug.h
 *
 * Copyright (c) 2013-2017, NVIDIA CORPORATION.  All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 */

#ifndef __QUADD_DEBUG_H
#define __QUADD_DEBUG_H

#include <linux/tegra_profiler.h>

/* #define QM_DEBUG_SAMPLES_ENABLE 1 */

#ifdef QM_DEBUG_SAMPLES_ENABLE
void qm_debug_handler_sample(struct pt_regs *regs);
void qm_debug_timer_forward(struct pt_regs *regs, u64 period);
void qm_debug_timer_start(struct pt_regs *regs, u64 period);
void qm_debug_timer_cancel(void);
void qm_debug_task_sched_in(pid_t prev_pid, pid_t current_pid,
			    int prev_nr_active);
void qm_debug_read_counter(struct quadd_event *event, u32 prev_val, u32 val);
void qm_debug_start_source(int source_type);
void qm_debug_stop_source(int source_type);
#else
static inline void qm_debug_handler_sample(struct pt_regs *regs)
{
}
static inline void qm_debug_timer_forward(struct pt_regs *regs, u64 period)
{
}
static inline void qm_debug_timer_start(struct pt_regs *regs, u64 period)
{
}
static inline void qm_debug_timer_cancel(void)
{
}
static inline void
qm_debug_task_sched_in(pid_t prev_pid, pid_t current_pid, int prev_nr_active)
{
}
static inline void
qm_debug_read_counter(struct quadd_event *event, u32 prev_val, u32 val)
{
}
static inline void qm_debug_start_source(int source_type)
{
}
static inline void qm_debug_stop_source(int source_type)
{
}
#endif

void quadd_test_delay(void);

#define QM_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
static inline const char *
quadd_get_hw_event_str(int event)
{
	static const char * const str[] = {
		[QUADD_EVENT_HW_CPU_CYCLES]		= "cpu-cycles",

		[QUADD_EVENT_HW_INSTRUCTIONS]		= "instructions",
		[QUADD_EVENT_HW_BRANCH_INSTRUCTIONS]	= "branch_instruction",
		[QUADD_EVENT_HW_BRANCH_MISSES]		= "branch_misses",
		[QUADD_EVENT_HW_BUS_CYCLES]		= "bus-cycles",

		[QUADD_EVENT_HW_L1_DCACHE_READ_MISSES]	= "l1_d_read",
		[QUADD_EVENT_HW_L1_DCACHE_WRITE_MISSES]	= "l1_d_write",
		[QUADD_EVENT_HW_L1_ICACHE_MISSES]	= "l1_i",

		[QUADD_EVENT_HW_L2_DCACHE_READ_MISSES]	= "l2_d_read",
		[QUADD_EVENT_HW_L2_DCACHE_WRITE_MISSES]	= "l2_d_write",
		[QUADD_EVENT_HW_L2_ICACHE_MISSES]	= "l2_i",
	};

	if (event >= QM_ARRAY_SIZE(str))
		return "invalid event";

	speculation_barrier();
	return str[event];
}

#endif	/* __QUADD_DEBUG_H */