summaryrefslogtreecommitdiff
path: root/mali_kbase/mali_kbase_hwcnt_backend_csf.h
blob: e0cafbe70660d51b79aa1c9b3be44b609b7e18ba (plain)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
 *
 * (C) COPYRIGHT 2021 ARM Limited. All rights reserved.
 *
 * This program is free software and is provided to you under the terms of the
 * GNU General Public License version 2 as published by the Free Software
 * Foundation, and any use by you of this program is subject to the terms
 * of such GNU license.
 *
 * This program is distributed in the hope that 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, you can access it online at
 * http://www.gnu.org/licenses/gpl-2.0.html.
 *
 */

/*
 * Concrete implementation of mali_kbase_hwcnt_backend interface for CSF
 * backend.
 */

#ifndef _KBASE_HWCNT_BACKEND_CSF_H_
#define _KBASE_HWCNT_BACKEND_CSF_H_

#include "mali_kbase_hwcnt_backend.h"
#include "mali_kbase_hwcnt_backend_csf_if.h"
#include "mali_kbase_hwcnt_watchdog_if.h"

/**
 * kbase_hwcnt_backend_csf_create() - Create a CSF hardware counter backend
 *                                    interface.
 * @csf_if:       Non-NULL pointer to a hwcnt backend CSF interface structure
 *                used to create backend interface.
 * @ring_buf_cnt: The buffer count of CSF hwcnt backend, used when allocate ring
 *                buffer, MUST be power of 2.
 * @watchdog_if:  Non-NULL pointer to a hwcnt watchdog interface structure used
 *                to create backend interface.
 * @iface:        Non-NULL pointer to backend interface structure that is filled
 *                in on creation success.
 *
 * Calls to iface->dump_enable_nolock() require the CSF Scheduler IRQ lock.
 *
 * Return: 0 on success, else error code.
 */
int kbase_hwcnt_backend_csf_create(
	struct kbase_hwcnt_backend_csf_if *csf_if, u32 ring_buf_cnt,
	struct kbase_hwcnt_watchdog_interface *watchdog_if,
	struct kbase_hwcnt_backend_interface *iface);

/**
 * kbase_hwcnt_backend_csf_metadata_init() - Initialize the metadata for a CSF
 *                                           hardware counter backend.
 * @iface: Non-NULL pointer to backend interface structure
 * Return: 0 on success, else error code.
 */
int kbase_hwcnt_backend_csf_metadata_init(
	struct kbase_hwcnt_backend_interface *iface);

/**
 * kbase_hwcnt_backend_csf_metadata_term() - Terminate the metadata for a CSF
 *                                           hardware counter backend.
 * @iface: Non-NULL pointer to backend interface structure.
 */
void kbase_hwcnt_backend_csf_metadata_term(
	struct kbase_hwcnt_backend_interface *iface);

/**
 * kbase_hwcnt_backend_csf_destroy() - Destroy a CSF hardware counter backend
 *                                     interface.
 * @iface: Pointer to interface to destroy.
 *
 * Can be safely called on an all-zeroed interface, or on an already destroyed
 * interface.
 */
void kbase_hwcnt_backend_csf_destroy(
	struct kbase_hwcnt_backend_interface *iface);

/**
 * kbase_hwcnt_backend_csf_protm_entered() - CSF HWC backend function to receive
 *                                           notification that protected mode
 *                                           has been entered.
 * @iface: Non-NULL pointer to HWC backend interface.
 */
void kbase_hwcnt_backend_csf_protm_entered(
	struct kbase_hwcnt_backend_interface *iface);

/**
 * kbase_hwcnt_backend_csf_protm_exited() - CSF HWC backend function to receive
 *                                          notification that protected mode has
 *                                          been exited.
 * @iface: Non-NULL pointer to HWC backend interface.
 */
void kbase_hwcnt_backend_csf_protm_exited(
	struct kbase_hwcnt_backend_interface *iface);

/**
 * kbase_hwcnt_backend_csf_on_unrecoverable_error() - CSF HWC backend function
 *                                                    called when unrecoverable
 *                                                    errors are detected.
 * @iface: Non-NULL pointer to HWC backend interface.
 *
 * This should be called on encountering errors that can only be recovered from
 * with reset, or that may put HWC logic in state that could result in hang. For
 * example, on bus error, or when FW becomes unresponsive.
 */
void kbase_hwcnt_backend_csf_on_unrecoverable_error(
	struct kbase_hwcnt_backend_interface *iface);

/**
 * kbase_hwcnt_backend_csf_on_before_reset() - CSF HWC backend function to be
 *                                             called immediately before a
 *                                             reset. Takes us out of the
 *                                             unrecoverable error state, if we
 *                                             were in it.
 * @iface: Non-NULL pointer to HWC backend interface.
 */
void kbase_hwcnt_backend_csf_on_before_reset(
	struct kbase_hwcnt_backend_interface *iface);

/**
 * kbase_hwcnt_backend_csf_on_prfcnt_sample() - CSF performance counter sample
 *                                              complete interrupt handler.
 * @iface: Non-NULL pointer to HWC backend interface.
 */
void kbase_hwcnt_backend_csf_on_prfcnt_sample(
	struct kbase_hwcnt_backend_interface *iface);

/**
 * kbase_hwcnt_backend_csf_on_prfcnt_threshold() - CSF performance counter
 *                                                 buffer reach threshold
 *                                                 interrupt handler.
 * @iface: Non-NULL pointer to HWC backend interface.
 */
void kbase_hwcnt_backend_csf_on_prfcnt_threshold(
	struct kbase_hwcnt_backend_interface *iface);

/**
 * kbase_hwcnt_backend_csf_on_prfcnt_overflow() - CSF performance counter buffer
 *                                                overflow interrupt handler.
 * @iface: Non-NULL pointer to HWC backend interface.
 */
void kbase_hwcnt_backend_csf_on_prfcnt_overflow(
	struct kbase_hwcnt_backend_interface *iface);

/**
 * kbase_hwcnt_backend_csf_on_prfcnt_enable() - CSF performance counter enabled
 *                                              interrupt handler.
 * @iface: Non-NULL pointer to HWC backend interface.
 */
void kbase_hwcnt_backend_csf_on_prfcnt_enable(
	struct kbase_hwcnt_backend_interface *iface);

/**
 * kbase_hwcnt_backend_csf_on_prfcnt_disable() - CSF performance counter
 *                                               disabled interrupt handler.
 * @iface: Non-NULL pointer to HWC backend interface.
 */
void kbase_hwcnt_backend_csf_on_prfcnt_disable(
	struct kbase_hwcnt_backend_interface *iface);

#endif /* _KBASE_HWCNT_BACKEND_CSF_H_ */