1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 /* 3 * 4 * (C) COPYRIGHT 2019-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 * Defines the Mali arbiter interface 24 */ 25 26 #ifndef _MALI_KBASE_ARBITER_INTERFACE_H_ 27 #define _MALI_KBASE_ARBITER_INTERFACE_H_ 28 29 /** 30 * Mali arbiter interface version 31 * 32 * This specifies the current version of the configuration interface. Whenever 33 * the arbiter interface changes, so that integration effort is required, the 34 * version number will be increased. Each configuration must make an effort 35 * to check that it implements the correct version. 36 * 37 * Version history: 38 * 1 - Added the Mali arbiter configuration interface. 39 * 2 - Strip out reference code from header 40 * 3 - Removed DVFS utilization interface (DVFS moved to arbiter side) 41 * 4 - Added max_config support 42 * 5 - Added GPU clock frequency reporting support from arbiter 43 */ 44 #define MALI_KBASE_ARBITER_INTERFACE_VERSION 5 45 46 /** 47 * NO_FREQ is used in case platform doesn't support reporting frequency 48 */ 49 #define NO_FREQ 0 50 51 struct arbiter_if_dev; 52 53 /** 54 * struct arbiter_if_arb_vm_ops - Interface to communicate messages to VM 55 * 56 * This struct contains callbacks used to deliver messages 57 * from the arbiter to the corresponding VM. 58 * 59 * Note that calls into these callbacks may have synchronous calls back into 60 * the arbiter arbiter_if_vm_arb_ops callbacks below. 61 * For example vm_arb_gpu_stopped() may be called as a side effect of 62 * arb_vm_gpu_stop() being called here. 63 * 64 * @arb_vm_gpu_stop: Callback to ask VM to stop using GPU. 65 * dev: The arbif kernel module device. 66 * 67 * Informs KBase to stop using the GPU as soon as possible. 68 * Note: Once the driver is no longer using the GPU, a call 69 * to vm_arb_gpu_stopped is expected by the arbiter. 70 * @arb_vm_gpu_granted: Callback to indicate that GPU has been granted to VM. 71 * dev: The arbif kernel module device. 72 * 73 * Informs KBase that the GPU can now be used by the VM. 74 * @arb_vm_gpu_lost: Callback to indicate that VM has lost the GPU. 75 * dev: The arbif kernel module device. 76 * 77 * This is called if KBase takes too long to respond to the 78 * arbiter stop request. 79 * Once this is called, KBase will assume that access to the 80 * GPU has been lost and will fail all running jobs and 81 * reset its internal state. 82 * If successful, will respond with a vm_arb_gpu_stopped 83 * message. 84 * @arb_vm_max_config: Callback to send the max config info to the VM. 85 * dev: The arbif kernel module device. 86 * max_l2_slices: The maximum number of L2 slices. 87 * max_core_mask: The largest core mask. 88 * 89 * Informs KBase the maximum resources that can be 90 * allocated to the partition in use. 91 * @arb_vm_update_freq: Callback to notify that GPU clock frequency has been 92 * updated. 93 * dev: The arbif kernel module device. 94 * freq: GPU clock frequency value reported from arbiter 95 * 96 * Informs KBase that the GPU clock frequency has been updated. 97 */ 98 struct arbiter_if_arb_vm_ops { 99 void (*arb_vm_gpu_stop)(struct device *dev); 100 void (*arb_vm_gpu_granted)(struct device *dev); 101 void (*arb_vm_gpu_lost)(struct device *dev); 102 void (*arb_vm_max_config)(struct device *dev, uint32_t max_l2_slices, 103 uint32_t max_core_mask); 104 void (*arb_vm_update_freq)(struct device *dev, uint32_t freq); 105 }; 106 107 /** 108 * struct arbiter_if_vm_arb_ops - Interface to communicate messages to arbiter 109 * 110 * This struct contains callbacks used to request operations 111 * from the VM to the arbiter 112 * 113 * Note that we must not make any synchronous calls back in to the VM 114 * (via arbiter_if_arb_vm_ops above) in the context of these callbacks. 115 * 116 * @vm_arb_register_dev: Callback to register VM device driver callbacks. 117 * arbif_dev: The arbiter interface to register 118 * with for device callbacks 119 * dev: The device structure to supply in the callbacks. 120 * ops: The callbacks that the device driver supports 121 * (none are optional). 122 * 123 * Returns 124 * 0 - successful. 125 * -EINVAL - invalid argument. 126 * -EPROBE_DEFER - module dependencies are not yet 127 * available. 128 * @vm_arb_unregister_dev: Callback to unregister VM device driver callbacks. 129 * arbif_dev: The arbiter interface to unregistering 130 * from. 131 * @vm_arb_get_max_config: Callback to Request the max config from the Arbiter. 132 * arbif_dev: The arbiter interface to issue the 133 * request to. 134 * @vm_arb_gpu_request: Callback to ask the arbiter interface for GPU access. 135 * arbif_dev: The arbiter interface to issue the request 136 * to. 137 * @vm_arb_gpu_active: Callback to inform arbiter that driver has gone active. 138 * arbif_dev: The arbiter interface device to notify. 139 * @vm_arb_gpu_idle: Callback to inform the arbiter that driver has gone idle. 140 * arbif_dev: The arbiter interface device to notify. 141 * @vm_arb_gpu_stopped: Callback to inform arbiter that driver has stopped 142 * using the GPU 143 * arbif_dev: The arbiter interface device to notify. 144 * gpu_required: The GPU is still needed to do more work. 145 */ 146 struct arbiter_if_vm_arb_ops { 147 int (*vm_arb_register_dev)(struct arbiter_if_dev *arbif_dev, 148 struct device *dev, struct arbiter_if_arb_vm_ops *ops); 149 void (*vm_arb_unregister_dev)(struct arbiter_if_dev *arbif_dev); 150 void (*vm_arb_get_max_config)(struct arbiter_if_dev *arbif_dev); 151 void (*vm_arb_gpu_request)(struct arbiter_if_dev *arbif_dev); 152 void (*vm_arb_gpu_active)(struct arbiter_if_dev *arbif_dev); 153 void (*vm_arb_gpu_idle)(struct arbiter_if_dev *arbif_dev); 154 void (*vm_arb_gpu_stopped)(struct arbiter_if_dev *arbif_dev, 155 u8 gpu_required); 156 }; 157 158 /** 159 * struct arbiter_if_dev - Arbiter Interface 160 * @vm_ops: Callback functions for connecting KBase with 161 * arbiter interface device. 162 * @priv_data: Internal arbif data not used by KBASE. 163 * 164 * Arbiter Interface Kernel Module State used for linking KBase 165 * with an arbiter interface platform device 166 */ 167 struct arbiter_if_dev { 168 struct arbiter_if_vm_arb_ops vm_ops; 169 void *priv_data; 170 }; 171 172 #endif /* _MALI_KBASE_ARBITER_INTERFACE_H_ */ 173