• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  *
4  * (C) COPYRIGHT 2021 ARM Limited. All rights reserved.
5  *
6  * This program is free software and is provided to you under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation, and any use by you of this program is subject to the terms
9  * of such GNU license.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you can access it online at
18  * http://www.gnu.org/licenses/gpl-2.0.html.
19  *
20  */
21 
22 /*
23  * Concrete implementation of mali_kbase_hwcnt_backend interface for CSF
24  * backend.
25  */
26 
27 #ifndef _KBASE_HWCNT_BACKEND_CSF_H_
28 #define _KBASE_HWCNT_BACKEND_CSF_H_
29 
30 #include "mali_kbase_hwcnt_backend.h"
31 #include "mali_kbase_hwcnt_backend_csf_if.h"
32 #include "mali_kbase_hwcnt_watchdog_if.h"
33 
34 /**
35  * kbase_hwcnt_backend_csf_create() - Create a CSF hardware counter backend
36  *                                    interface.
37  * @csf_if:       Non-NULL pointer to a hwcnt backend CSF interface structure
38  *                used to create backend interface.
39  * @ring_buf_cnt: The buffer count of CSF hwcnt backend, used when allocate ring
40  *                buffer, MUST be power of 2.
41  * @watchdog_if:  Non-NULL pointer to a hwcnt watchdog interface structure used
42  *                to create backend interface.
43  * @iface:        Non-NULL pointer to backend interface structure that is filled
44  *                in on creation success.
45  *
46  * Calls to iface->dump_enable_nolock() require the CSF Scheduler IRQ lock.
47  *
48  * Return: 0 on success, else error code.
49  */
50 int kbase_hwcnt_backend_csf_create(
51 	struct kbase_hwcnt_backend_csf_if *csf_if, u32 ring_buf_cnt,
52 	struct kbase_hwcnt_watchdog_interface *watchdog_if,
53 	struct kbase_hwcnt_backend_interface *iface);
54 
55 /**
56  * kbase_hwcnt_backend_csf_metadata_init() - Initialize the metadata for a CSF
57  *                                           hardware counter backend.
58  * @iface: Non-NULL pointer to backend interface structure
59  * Return: 0 on success, else error code.
60  */
61 int kbase_hwcnt_backend_csf_metadata_init(
62 	struct kbase_hwcnt_backend_interface *iface);
63 
64 /**
65  * kbase_hwcnt_backend_csf_metadata_term() - Terminate the metadata for a CSF
66  *                                           hardware counter backend.
67  * @iface: Non-NULL pointer to backend interface structure.
68  */
69 void kbase_hwcnt_backend_csf_metadata_term(
70 	struct kbase_hwcnt_backend_interface *iface);
71 
72 /**
73  * kbase_hwcnt_backend_csf_destroy() - Destroy a CSF hardware counter backend
74  *                                     interface.
75  * @iface: Pointer to interface to destroy.
76  *
77  * Can be safely called on an all-zeroed interface, or on an already destroyed
78  * interface.
79  */
80 void kbase_hwcnt_backend_csf_destroy(
81 	struct kbase_hwcnt_backend_interface *iface);
82 
83 /**
84  * kbase_hwcnt_backend_csf_protm_entered() - CSF HWC backend function to receive
85  *                                           notification that protected mode
86  *                                           has been entered.
87  * @iface: Non-NULL pointer to HWC backend interface.
88  */
89 void kbase_hwcnt_backend_csf_protm_entered(
90 	struct kbase_hwcnt_backend_interface *iface);
91 
92 /**
93  * kbase_hwcnt_backend_csf_protm_exited() - CSF HWC backend function to receive
94  *                                          notification that protected mode has
95  *                                          been exited.
96  * @iface: Non-NULL pointer to HWC backend interface.
97  */
98 void kbase_hwcnt_backend_csf_protm_exited(
99 	struct kbase_hwcnt_backend_interface *iface);
100 
101 /**
102  * kbase_hwcnt_backend_csf_on_unrecoverable_error() - CSF HWC backend function
103  *                                                    called when unrecoverable
104  *                                                    errors are detected.
105  * @iface: Non-NULL pointer to HWC backend interface.
106  *
107  * This should be called on encountering errors that can only be recovered from
108  * with reset, or that may put HWC logic in state that could result in hang. For
109  * example, on bus error, or when FW becomes unresponsive.
110  */
111 void kbase_hwcnt_backend_csf_on_unrecoverable_error(
112 	struct kbase_hwcnt_backend_interface *iface);
113 
114 /**
115  * kbase_hwcnt_backend_csf_on_before_reset() - CSF HWC backend function to be
116  *                                             called immediately before a
117  *                                             reset. Takes us out of the
118  *                                             unrecoverable error state, if we
119  *                                             were in it.
120  * @iface: Non-NULL pointer to HWC backend interface.
121  */
122 void kbase_hwcnt_backend_csf_on_before_reset(
123 	struct kbase_hwcnt_backend_interface *iface);
124 
125 /**
126  * kbase_hwcnt_backend_csf_on_prfcnt_sample() - CSF performance counter sample
127  *                                              complete interrupt handler.
128  * @iface: Non-NULL pointer to HWC backend interface.
129  */
130 void kbase_hwcnt_backend_csf_on_prfcnt_sample(
131 	struct kbase_hwcnt_backend_interface *iface);
132 
133 /**
134  * kbase_hwcnt_backend_csf_on_prfcnt_threshold() - CSF performance counter
135  *                                                 buffer reach threshold
136  *                                                 interrupt handler.
137  * @iface: Non-NULL pointer to HWC backend interface.
138  */
139 void kbase_hwcnt_backend_csf_on_prfcnt_threshold(
140 	struct kbase_hwcnt_backend_interface *iface);
141 
142 /**
143  * kbase_hwcnt_backend_csf_on_prfcnt_overflow() - CSF performance counter buffer
144  *                                                overflow interrupt handler.
145  * @iface: Non-NULL pointer to HWC backend interface.
146  */
147 void kbase_hwcnt_backend_csf_on_prfcnt_overflow(
148 	struct kbase_hwcnt_backend_interface *iface);
149 
150 /**
151  * kbase_hwcnt_backend_csf_on_prfcnt_enable() - CSF performance counter enabled
152  *                                              interrupt handler.
153  * @iface: Non-NULL pointer to HWC backend interface.
154  */
155 void kbase_hwcnt_backend_csf_on_prfcnt_enable(
156 	struct kbase_hwcnt_backend_interface *iface);
157 
158 /**
159  * kbase_hwcnt_backend_csf_on_prfcnt_disable() - CSF performance counter
160  *                                               disabled interrupt handler.
161  * @iface: Non-NULL pointer to HWC backend interface.
162  */
163 void kbase_hwcnt_backend_csf_on_prfcnt_disable(
164 	struct kbase_hwcnt_backend_interface *iface);
165 
166 #endif /* _KBASE_HWCNT_BACKEND_CSF_H_ */
167