misc: tegra-profiler: support raw hardware events
[linux-3.10.git] / drivers / misc / tegra-profiler / debug.h
1 /*
2  * drivers/misc/tegra-profiler/debug.h
3  *
4  * Copyright (c) 2013-2017, NVIDIA CORPORATION.  All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  *
15  */
16
17 #ifndef __QUADD_DEBUG_H
18 #define __QUADD_DEBUG_H
19
20 #include <linux/tegra_profiler.h>
21
22 /* #define QM_DEBUG_SAMPLES_ENABLE 1 */
23
24 #ifdef QM_DEBUG_SAMPLES_ENABLE
25 void qm_debug_handler_sample(struct pt_regs *regs);
26 void qm_debug_timer_forward(struct pt_regs *regs, u64 period);
27 void qm_debug_timer_start(struct pt_regs *regs, u64 period);
28 void qm_debug_timer_cancel(void);
29 void qm_debug_task_sched_in(pid_t prev_pid, pid_t current_pid,
30                             int prev_nr_active);
31 void qm_debug_read_counter(struct quadd_event *event, u32 prev_val, u32 val);
32 void qm_debug_start_source(int source_type);
33 void qm_debug_stop_source(int source_type);
34 #else
35 static inline void qm_debug_handler_sample(struct pt_regs *regs)
36 {
37 }
38 static inline void qm_debug_timer_forward(struct pt_regs *regs, u64 period)
39 {
40 }
41 static inline void qm_debug_timer_start(struct pt_regs *regs, u64 period)
42 {
43 }
44 static inline void qm_debug_timer_cancel(void)
45 {
46 }
47 static inline void
48 qm_debug_task_sched_in(pid_t prev_pid, pid_t current_pid, int prev_nr_active)
49 {
50 }
51 static inline void
52 qm_debug_read_counter(struct quadd_event *event, u32 prev_val, u32 val)
53 {
54 }
55 static inline void qm_debug_start_source(int source_type)
56 {
57 }
58 static inline void qm_debug_stop_source(int source_type)
59 {
60 }
61 #endif
62
63 void quadd_test_delay(void);
64
65 #define QM_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
66 static inline const char *
67 quadd_get_hw_event_str(int event)
68 {
69         static const char * const str[] = {
70                 [QUADD_EVENT_HW_CPU_CYCLES]             = "cpu-cycles",
71
72                 [QUADD_EVENT_HW_INSTRUCTIONS]           = "instructions",
73                 [QUADD_EVENT_HW_BRANCH_INSTRUCTIONS]    = "branch_instruction",
74                 [QUADD_EVENT_HW_BRANCH_MISSES]          = "branch_misses",
75                 [QUADD_EVENT_HW_BUS_CYCLES]             = "bus-cycles",
76
77                 [QUADD_EVENT_HW_L1_DCACHE_READ_MISSES]  = "l1_d_read",
78                 [QUADD_EVENT_HW_L1_DCACHE_WRITE_MISSES] = "l1_d_write",
79                 [QUADD_EVENT_HW_L1_ICACHE_MISSES]       = "l1_i",
80
81                 [QUADD_EVENT_HW_L2_DCACHE_READ_MISSES]  = "l2_d_read",
82                 [QUADD_EVENT_HW_L2_DCACHE_WRITE_MISSES] = "l2_d_write",
83                 [QUADD_EVENT_HW_L2_ICACHE_MISSES]       = "l2_i",
84         };
85         return (event < QM_ARRAY_SIZE(str)) ? str[event] : "invalid event";
86 }
87
88 #endif  /* __QUADD_DEBUG_H */