hc
2023-07-06 0d92c6001e626cf3cfa86b826ccc10a16115901e
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
 *
 * (C) COPYRIGHT 2019-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.
 *
 */
 
/**
 * @file
 * Defines the Mali arbiter interface
 */
 
#ifndef _MALI_KBASE_ARBITER_INTERFACE_H_
#define _MALI_KBASE_ARBITER_INTERFACE_H_
 
/**
 *  Mali arbiter interface version
 *
 * This specifies the current version of the configuration interface. Whenever
 * the arbiter interface changes, so that integration effort is required, the
 * version number will be increased. Each configuration must make an effort
 * to check that it implements the correct version.
 *
 * Version history:
 * 1 - Added the Mali arbiter configuration interface.
 * 2 - Strip out reference code from header
 * 3 - Removed DVFS utilization interface (DVFS moved to arbiter side)
 * 4 - Added max_config support
 * 5 - Added GPU clock frequency reporting support from arbiter
 */
#define MALI_KBASE_ARBITER_INTERFACE_VERSION 5
 
/**
 * NO_FREQ is used in case platform doesn't support reporting frequency
 */
#define NO_FREQ 0
 
struct arbiter_if_dev;
 
/**
 * struct arbiter_if_arb_vm_ops - Interface to communicate messages to VM
 *
 * This struct contains callbacks used to deliver messages
 * from the arbiter to the corresponding VM.
 *
 * Note that calls into these callbacks may have synchronous calls back into
 * the arbiter arbiter_if_vm_arb_ops callbacks below.
 * For example vm_arb_gpu_stopped() may be called as a side effect of
 * arb_vm_gpu_stop() being called here.
 */
struct arbiter_if_arb_vm_ops {
   /**
    * arb_vm_gpu_stop() - Ask VM to stop using GPU
    * @dev: The arbif kernel module device.
    *
    * Informs KBase to stop using the GPU as soon as possible.
    * @Note: Once the driver is no longer using the GPU, a call to
    *        vm_arb_gpu_stopped is expected by the arbiter.
    */
   void (*arb_vm_gpu_stop)(struct device *dev);
 
   /**
    * arb_vm_gpu_granted() - GPU has been granted to VM
    * @dev: The arbif kernel module device.
    *
    * Informs KBase that the GPU can now be used by the VM.
    */
   void (*arb_vm_gpu_granted)(struct device *dev);
 
   /**
    * arb_vm_gpu_lost() - VM has lost the GPU
    * @dev: The arbif kernel module device.
    *
    * This is called if KBase takes too long to respond to the arbiter
    * stop request.
    * Once this is called, KBase will assume that access to the GPU
    * has been lost and will fail all running jobs and reset its
    * internal state.
    * If successful, will respond with a vm_arb_gpu_stopped message.
    */
   void (*arb_vm_gpu_lost)(struct device *dev);
 
   /**
    * arb_vm_max_config() - Send max config info to the VM
    * @dev: The arbif kernel module device.
    * @max_l2_slices: The maximum number of L2 slices.
    * @max_core_mask: The largest core mask.
    *
    * Informs KBase the maximum resources that can be allocated to the
    * partition in use.
    */
   void (*arb_vm_max_config)(struct device *dev, uint32_t max_l2_slices,
                 uint32_t max_core_mask);
 
   /**
    * arb_vm_update_freq() - GPU clock frequency has been updated
    * @dev: The arbif kernel module device.
    * @freq: GPU clock frequency value reported from arbiter
    *
    * Informs KBase that the GPU clock frequency has been updated.
    */
   void (*arb_vm_update_freq)(struct device *dev, uint32_t freq);
};
 
/**
 * struct arbiter_if_vm_arb_ops - Interface to communicate messages to arbiter
 *
 * This struct contains callbacks used to request operations
 * from the VM to the arbiter
 *
 * Note that we must not make any synchronous calls back in to the VM
 * (via arbiter_if_arb_vm_ops above) in the context of these callbacks.
 */
struct arbiter_if_vm_arb_ops {
   /**
    * vm_arb_register_dev() - Register VM device driver callbacks.
    * @arbif_dev: The arbiter interface we are registering device callbacks
    * @dev: The device structure to supply in the callbacks.
    * @ops: The callbacks that the device driver supports
    *       (none are optional).
    *
    * Return:
    * * 0            - successful.
    * * -EINVAL        - invalid argument.
    * * -EPROBE_DEFER    - module dependencies are not yet available.
    */
   int (*vm_arb_register_dev)(struct arbiter_if_dev *arbif_dev,
       struct device *dev, struct arbiter_if_arb_vm_ops *ops);
 
   /**
    * vm_arb_unregister_dev() - Unregister VM device driver callbacks.
    * @arbif_dev: The arbiter interface we are unregistering from.
    */
   void (*vm_arb_unregister_dev)(struct arbiter_if_dev *arbif_dev);
 
   /**
    * vm_arb_gpu_get_max_config() - Request the max config from the
    * Arbiter.
    * @arbif_dev: The arbiter interface we want to issue the request.
    */
   void (*vm_arb_get_max_config)(struct arbiter_if_dev *arbif_dev);
 
   /**
    * vm_arb_gpu_request() - Ask the arbiter interface for GPU access.
    * @arbif_dev: The arbiter interface we want to issue the request.
    */
   void (*vm_arb_gpu_request)(struct arbiter_if_dev *arbif_dev);
 
   /**
    * vm_arb_gpu_active() - Inform arbiter that the driver has gone active
    * @arbif_dev: The arbiter interface device.
    */
   void (*vm_arb_gpu_active)(struct arbiter_if_dev *arbif_dev);
 
   /**
    * vm_arb_gpu_idle() - Inform the arbiter that the driver has gone idle
    * @arbif_dev: The arbiter interface device.
    */
   void (*vm_arb_gpu_idle)(struct arbiter_if_dev *arbif_dev);
 
   /**
    * vm_arb_gpu_stopped() - Inform the arbiter that the driver has stopped
    *                        using the GPU
    * @arbif_dev: The arbiter interface device.
    * @gpu_required: The GPU is still needed to do more work.
    */
   void (*vm_arb_gpu_stopped)(struct arbiter_if_dev *arbif_dev,
       u8 gpu_required);
};
 
/**
 * struct arbiter_if_dev - Arbiter Interface
 * @vm_ops: Callback functions for connecting KBase with
 *          arbiter interface device.
 * @priv_data: Internal arbif data not used by KBASE.
 *
 * Arbiter Interface Kernel Module State used for linking KBase
 * with an arbiter interface platform device
 */
struct arbiter_if_dev {
   struct arbiter_if_vm_arb_ops vm_ops;
   void *priv_data;
};
 
#endif /* _MALI_KBASE_ARBITER_INTERFACE_H_ */