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