| .. | .. |
|---|
| 1 | 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ |
|---|
| 2 | 2 | /* |
|---|
| 3 | 3 | * |
|---|
| 4 | | - * (C) COPYRIGHT 2018-2021 ARM Limited. All rights reserved. |
|---|
| 4 | + * (C) COPYRIGHT 2018-2023 ARM Limited. All rights reserved. |
|---|
| 5 | 5 | * |
|---|
| 6 | 6 | * This program is free software and is provided to you under the terms of the |
|---|
| 7 | 7 | * GNU General Public License version 2 as published by the Free Software |
|---|
| .. | .. |
|---|
| 21 | 21 | |
|---|
| 22 | 22 | #ifndef _KBASE_CSF_KCPU_H_ |
|---|
| 23 | 23 | #define _KBASE_CSF_KCPU_H_ |
|---|
| 24 | + |
|---|
| 25 | +#include <mali_kbase_fence.h> |
|---|
| 26 | +#include <mali_kbase_sync.h> |
|---|
| 24 | 27 | |
|---|
| 25 | 28 | #if (KERNEL_VERSION(4, 10, 0) > LINUX_VERSION_CODE) |
|---|
| 26 | 29 | #include <linux/fence.h> |
|---|
| .. | .. |
|---|
| 44 | 47 | }; |
|---|
| 45 | 48 | |
|---|
| 46 | 49 | /** |
|---|
| 47 | | - * struct kbase_kcpu_command_fence_info - Structure which holds information |
|---|
| 48 | | - * about the fence object enqueued in the kcpu command queue |
|---|
| 50 | + * struct kbase_kcpu_command_fence_info - Structure which holds information about the |
|---|
| 51 | + * fence object enqueued in the kcpu command queue |
|---|
| 49 | 52 | * |
|---|
| 50 | | - * @fence_cb: Fence callback |
|---|
| 51 | | - * @fence: Fence |
|---|
| 52 | | - * @kcpu_queue: kcpu command queue |
|---|
| 53 | + * @fence_cb: Fence callback |
|---|
| 54 | + * @fence: Fence |
|---|
| 55 | + * @kcpu_queue: kcpu command queue |
|---|
| 53 | 56 | */ |
|---|
| 54 | 57 | struct kbase_kcpu_command_fence_info { |
|---|
| 55 | 58 | #if (KERNEL_VERSION(4, 10, 0) > LINUX_VERSION_CODE) |
|---|
| .. | .. |
|---|
| 117 | 120 | * @signaled: Bit array used to report the status of the CQS wait objects. |
|---|
| 118 | 121 | * 1 is signaled, 0 otherwise. |
|---|
| 119 | 122 | * @nr_objs: Number of CQS objects in the array. |
|---|
| 123 | + * @inherit_err_flags: Bit-pattern for CQSs in the array who's error field is to |
|---|
| 124 | + * be used as the source to import into the queue's error-state |
|---|
| 120 | 125 | */ |
|---|
| 121 | 126 | struct kbase_kcpu_command_cqs_wait_operation_info { |
|---|
| 122 | 127 | struct base_cqs_wait_operation_info *objs; |
|---|
| .. | .. |
|---|
| 181 | 186 | struct kbase_mem_phy_alloc *cpu_alloc; |
|---|
| 182 | 187 | }; |
|---|
| 183 | 188 | |
|---|
| 189 | +#if IS_ENABLED(CONFIG_MALI_VECTOR_DUMP) || MALI_UNIT_TEST |
|---|
| 184 | 190 | /** |
|---|
| 185 | | - * struct base_kcpu_command_group_suspend - structure which contains |
|---|
| 191 | + * struct kbase_kcpu_command_group_suspend_info - structure which contains |
|---|
| 186 | 192 | * suspend buffer data captured for a suspended queue group. |
|---|
| 187 | 193 | * |
|---|
| 188 | 194 | * @sus_buf: Pointer to the structure which contains details of the |
|---|
| .. | .. |
|---|
| 193 | 199 | struct kbase_suspend_copy_buffer *sus_buf; |
|---|
| 194 | 200 | u8 group_handle; |
|---|
| 195 | 201 | }; |
|---|
| 202 | +#endif |
|---|
| 196 | 203 | |
|---|
| 197 | | -#if MALI_UNIT_TEST |
|---|
| 198 | | -struct kbase_kcpu_command_sample_time_info { |
|---|
| 199 | | - u64 page_addr; |
|---|
| 200 | | - u64 page_offset; |
|---|
| 201 | | - struct page **page; |
|---|
| 202 | | -}; |
|---|
| 203 | | -#endif /* MALI_UNIT_TEST */ |
|---|
| 204 | 204 | |
|---|
| 205 | 205 | /** |
|---|
| 206 | | - * struct kbase_cpu_command - Command which is to be part of the kernel |
|---|
| 206 | + * struct kbase_kcpu_command - Command which is to be part of the kernel |
|---|
| 207 | 207 | * command queue |
|---|
| 208 | 208 | * |
|---|
| 209 | 209 | * @type: Type of the command. |
|---|
| .. | .. |
|---|
| 211 | 211 | * indicates that it has been enqueued earlier. |
|---|
| 212 | 212 | * @info: Structure which holds information about the command |
|---|
| 213 | 213 | * dependent on the command type. |
|---|
| 214 | | - * @info.fence: Fence |
|---|
| 215 | | - * @info.cqs_wait: CQS wait |
|---|
| 216 | | - * @info.cqs_set: CQS set |
|---|
| 217 | | - * @info.import: import |
|---|
| 218 | | - * @info.jit_alloc: jit allocation |
|---|
| 219 | | - * @info.jit_free: jit deallocation |
|---|
| 220 | | - * @info.suspend_buf_copy: suspend buffer copy |
|---|
| 221 | | - * @info.sample_time: sample time |
|---|
| 214 | + * @info.fence: Fence |
|---|
| 215 | + * @info.cqs_wait: CQS wait |
|---|
| 216 | + * @info.cqs_set: CQS set |
|---|
| 217 | + * @info.cqs_wait_operation: CQS wait operation |
|---|
| 218 | + * @info.cqs_set_operation: CQS set operation |
|---|
| 219 | + * @info.import: import |
|---|
| 220 | + * @info.jit_alloc: JIT allocation |
|---|
| 221 | + * @info.jit_free: JIT deallocation |
|---|
| 222 | + * @info.suspend_buf_copy: suspend buffer copy |
|---|
| 223 | + * @info.sample_time: sample time |
|---|
| 222 | 224 | */ |
|---|
| 223 | 225 | struct kbase_kcpu_command { |
|---|
| 224 | 226 | enum base_kcpu_command_type type; |
|---|
| .. | .. |
|---|
| 232 | 234 | struct kbase_kcpu_command_import_info import; |
|---|
| 233 | 235 | struct kbase_kcpu_command_jit_alloc_info jit_alloc; |
|---|
| 234 | 236 | struct kbase_kcpu_command_jit_free_info jit_free; |
|---|
| 237 | +#if IS_ENABLED(CONFIG_MALI_VECTOR_DUMP) || MALI_UNIT_TEST |
|---|
| 235 | 238 | struct kbase_kcpu_command_group_suspend_info suspend_buf_copy; |
|---|
| 236 | | -#if MALI_UNIT_TEST |
|---|
| 237 | | - struct kbase_kcpu_command_sample_time_info sample_time; |
|---|
| 238 | | -#endif /* MALI_UNIT_TEST */ |
|---|
| 239 | +#endif |
|---|
| 239 | 240 | } info; |
|---|
| 240 | 241 | }; |
|---|
| 241 | 242 | |
|---|
| 242 | 243 | /** |
|---|
| 243 | 244 | * struct kbase_kcpu_command_queue - a command queue executed by the kernel |
|---|
| 244 | 245 | * |
|---|
| 246 | + * @lock: Lock to protect accesses to this queue. |
|---|
| 245 | 247 | * @kctx: The context to which this command queue belongs. |
|---|
| 246 | 248 | * @commands: Array of commands which have been successfully |
|---|
| 247 | 249 | * enqueued to this command queue. |
|---|
| 250 | + * @wq: Dedicated workqueue for processing commands. |
|---|
| 248 | 251 | * @work: struct work_struct which contains a pointer to |
|---|
| 249 | 252 | * the function which handles processing of kcpu |
|---|
| 250 | 253 | * commands enqueued into a kcpu command queue; |
|---|
| .. | .. |
|---|
| 277 | 280 | * or without errors since last cleaned. |
|---|
| 278 | 281 | * @jit_blocked: Used to keep track of command queues blocked |
|---|
| 279 | 282 | * by a pending JIT allocation command. |
|---|
| 283 | + * @fence_timeout: Timer used to detect the fence wait timeout. |
|---|
| 284 | + * @metadata: Metadata structure containing basic information about |
|---|
| 285 | + * this queue for any fence objects associated with this queue. |
|---|
| 280 | 286 | */ |
|---|
| 281 | 287 | struct kbase_kcpu_command_queue { |
|---|
| 288 | + struct mutex lock; |
|---|
| 282 | 289 | struct kbase_context *kctx; |
|---|
| 283 | 290 | struct kbase_kcpu_command commands[KBASEP_KCPU_QUEUE_SIZE]; |
|---|
| 291 | + struct workqueue_struct *wq; |
|---|
| 284 | 292 | struct work_struct work; |
|---|
| 285 | 293 | u8 start_offset; |
|---|
| 286 | 294 | u8 id; |
|---|
| .. | .. |
|---|
| 293 | 301 | bool command_started; |
|---|
| 294 | 302 | struct list_head jit_blocked; |
|---|
| 295 | 303 | bool has_error; |
|---|
| 304 | +#ifdef CONFIG_MALI_BIFROST_FENCE_DEBUG |
|---|
| 305 | + struct timer_list fence_timeout; |
|---|
| 306 | +#endif /* CONFIG_MALI_BIFROST_FENCE_DEBUG */ |
|---|
| 307 | +#if IS_ENABLED(CONFIG_SYNC_FILE) |
|---|
| 308 | + struct kbase_kcpu_dma_fence_meta *metadata; |
|---|
| 309 | +#endif /* CONFIG_SYNC_FILE */ |
|---|
| 296 | 310 | }; |
|---|
| 297 | 311 | |
|---|
| 298 | 312 | /** |
|---|
| .. | .. |
|---|
| 302 | 316 | * queue will be created. |
|---|
| 303 | 317 | * @newq: Pointer to the structure which contains information about |
|---|
| 304 | 318 | * the new KCPU command queue to be created. |
|---|
| 319 | + * |
|---|
| 320 | + * Return: 0 if successful or a negative error code on failure. |
|---|
| 305 | 321 | */ |
|---|
| 306 | 322 | int kbase_csf_kcpu_queue_new(struct kbase_context *kctx, |
|---|
| 307 | 323 | struct kbase_ioctl_kcpu_queue_new *newq); |
|---|
| .. | .. |
|---|
| 309 | 325 | /** |
|---|
| 310 | 326 | * kbase_csf_kcpu_queue_delete - Delete KCPU command queue. |
|---|
| 311 | 327 | * |
|---|
| 312 | | - * Return: 0 if successful, -EINVAL if the queue ID is invalid. |
|---|
| 313 | | - * |
|---|
| 314 | 328 | * @kctx: Pointer to the kbase context from which the KCPU command |
|---|
| 315 | 329 | * queue is to be deleted. |
|---|
| 316 | 330 | * @del: Pointer to the structure which specifies the KCPU command |
|---|
| 317 | 331 | * queue to be deleted. |
|---|
| 332 | + * |
|---|
| 333 | + * Return: 0 if successful or a negative error code on failure. |
|---|
| 318 | 334 | */ |
|---|
| 319 | 335 | int kbase_csf_kcpu_queue_delete(struct kbase_context *kctx, |
|---|
| 320 | 336 | struct kbase_ioctl_kcpu_queue_delete *del); |
|---|
| .. | .. |
|---|
| 328 | 344 | * @enq: Pointer to the structure which specifies the KCPU command |
|---|
| 329 | 345 | * as well as the KCPU command queue into which the command |
|---|
| 330 | 346 | * is to be enqueued. |
|---|
| 347 | + * |
|---|
| 348 | + * Return: 0 if successful or a negative error code on failure. |
|---|
| 331 | 349 | */ |
|---|
| 332 | 350 | int kbase_csf_kcpu_queue_enqueue(struct kbase_context *kctx, |
|---|
| 333 | 351 | struct kbase_ioctl_kcpu_queue_enqueue *enq); |
|---|
| .. | .. |
|---|
| 345 | 363 | /** |
|---|
| 346 | 364 | * kbase_csf_kcpu_queue_context_term - Terminate the kernel CPU queues context |
|---|
| 347 | 365 | * for a GPU address space |
|---|
| 366 | + * @kctx: Pointer to the kbase context being terminated. |
|---|
| 348 | 367 | * |
|---|
| 349 | 368 | * This function deletes any kernel CPU queues that weren't deleted before |
|---|
| 350 | 369 | * context termination. |
|---|
| 351 | 370 | * |
|---|
| 352 | | - * @kctx: Pointer to the kbase context being terminated. |
|---|
| 353 | 371 | */ |
|---|
| 354 | 372 | void kbase_csf_kcpu_queue_context_term(struct kbase_context *kctx); |
|---|
| 355 | 373 | |
|---|
| 374 | +#if IS_ENABLED(CONFIG_SYNC_FILE) |
|---|
| 375 | +/* Test wrappers for dma fence operations. */ |
|---|
| 376 | +int kbase_kcpu_fence_signal_process(struct kbase_kcpu_command_queue *kcpu_queue, |
|---|
| 377 | + struct kbase_kcpu_command_fence_info *fence_info); |
|---|
| 378 | + |
|---|
| 379 | +int kbase_kcpu_fence_signal_init(struct kbase_kcpu_command_queue *kcpu_queue, |
|---|
| 380 | + struct kbase_kcpu_command *current_command, |
|---|
| 381 | + struct base_fence *fence, struct sync_file **sync_file, int *fd); |
|---|
| 382 | +#endif /* CONFIG_SYNC_FILE */ |
|---|
| 383 | + |
|---|
| 356 | 384 | #endif /* _KBASE_CSF_KCPU_H_ */ |
|---|