xref: /OK3568_Linux_fs/kernel/drivers/gpu/arm/bifrost/hwcnt/backend/mali_kbase_hwcnt_backend_csf.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  *
4  * (C) COPYRIGHT 2021-2022 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 "hwcnt/backend/mali_kbase_hwcnt_backend.h"
31 #include "hwcnt/backend/mali_kbase_hwcnt_backend_csf_if.h"
32 #include "hwcnt/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(struct kbase_hwcnt_backend_csf_if *csf_if, u32 ring_buf_cnt,
51 				   struct kbase_hwcnt_watchdog_interface *watchdog_if,
52 				   struct kbase_hwcnt_backend_interface *iface);
53 
54 /**
55  * kbase_hwcnt_backend_csf_metadata_init() - Initialize the metadata for a CSF
56  *                                           hardware counter backend.
57  * @iface: Non-NULL pointer to backend interface structure
58  * Return: 0 on success, else error code.
59  */
60 int kbase_hwcnt_backend_csf_metadata_init(struct kbase_hwcnt_backend_interface *iface);
61 
62 /**
63  * kbase_hwcnt_backend_csf_metadata_term() - Terminate the metadata for a CSF
64  *                                           hardware counter backend.
65  * @iface: Non-NULL pointer to backend interface structure.
66  */
67 void kbase_hwcnt_backend_csf_metadata_term(struct kbase_hwcnt_backend_interface *iface);
68 
69 /**
70  * kbase_hwcnt_backend_csf_destroy() - Destroy a CSF hardware counter backend
71  *                                     interface.
72  * @iface: Pointer to interface to destroy.
73  *
74  * Can be safely called on an all-zeroed interface, or on an already destroyed
75  * interface.
76  */
77 void kbase_hwcnt_backend_csf_destroy(struct kbase_hwcnt_backend_interface *iface);
78 
79 /**
80  * kbase_hwcnt_backend_csf_protm_entered() - CSF HWC backend function to receive
81  *                                           notification that protected mode
82  *                                           has been entered.
83  * @iface: Non-NULL pointer to HWC backend interface.
84  */
85 void kbase_hwcnt_backend_csf_protm_entered(struct kbase_hwcnt_backend_interface *iface);
86 
87 /**
88  * kbase_hwcnt_backend_csf_protm_exited() - CSF HWC backend function to receive
89  *                                          notification that protected mode has
90  *                                          been exited.
91  * @iface: Non-NULL pointer to HWC backend interface.
92  */
93 void kbase_hwcnt_backend_csf_protm_exited(struct kbase_hwcnt_backend_interface *iface);
94 
95 /**
96  * kbase_hwcnt_backend_csf_on_unrecoverable_error() - CSF HWC backend function
97  *                                                    called when unrecoverable
98  *                                                    errors are detected.
99  * @iface: Non-NULL pointer to HWC backend interface.
100  *
101  * This should be called on encountering errors that can only be recovered from
102  * with reset, or that may put HWC logic in state that could result in hang. For
103  * example, on bus error, or when FW becomes unresponsive.
104  */
105 void kbase_hwcnt_backend_csf_on_unrecoverable_error(struct kbase_hwcnt_backend_interface *iface);
106 
107 /**
108  * kbase_hwcnt_backend_csf_on_before_reset() - CSF HWC backend function to be
109  *                                             called immediately before a
110  *                                             reset. Takes us out of the
111  *                                             unrecoverable error state, if we
112  *                                             were in it.
113  * @iface: Non-NULL pointer to HWC backend interface.
114  */
115 void kbase_hwcnt_backend_csf_on_before_reset(struct kbase_hwcnt_backend_interface *iface);
116 
117 /**
118  * kbase_hwcnt_backend_csf_on_prfcnt_sample() - CSF performance counter sample
119  *                                              complete interrupt handler.
120  * @iface: Non-NULL pointer to HWC backend interface.
121  */
122 void kbase_hwcnt_backend_csf_on_prfcnt_sample(struct kbase_hwcnt_backend_interface *iface);
123 
124 /**
125  * kbase_hwcnt_backend_csf_on_prfcnt_threshold() - CSF performance counter
126  *                                                 buffer reach threshold
127  *                                                 interrupt handler.
128  * @iface: Non-NULL pointer to HWC backend interface.
129  */
130 void kbase_hwcnt_backend_csf_on_prfcnt_threshold(struct kbase_hwcnt_backend_interface *iface);
131 
132 /**
133  * kbase_hwcnt_backend_csf_on_prfcnt_overflow() - CSF performance counter buffer
134  *                                                overflow interrupt handler.
135  * @iface: Non-NULL pointer to HWC backend interface.
136  */
137 void kbase_hwcnt_backend_csf_on_prfcnt_overflow(struct kbase_hwcnt_backend_interface *iface);
138 
139 /**
140  * kbase_hwcnt_backend_csf_on_prfcnt_enable() - CSF performance counter enabled
141  *                                              interrupt handler.
142  * @iface: Non-NULL pointer to HWC backend interface.
143  */
144 void kbase_hwcnt_backend_csf_on_prfcnt_enable(struct kbase_hwcnt_backend_interface *iface);
145 
146 /**
147  * kbase_hwcnt_backend_csf_on_prfcnt_disable() - CSF performance counter
148  *                                               disabled interrupt handler.
149  * @iface: Non-NULL pointer to HWC backend interface.
150  */
151 void kbase_hwcnt_backend_csf_on_prfcnt_disable(struct kbase_hwcnt_backend_interface *iface);
152 
153 #endif /* _KBASE_HWCNT_BACKEND_CSF_H_ */
154