hc
2024-05-16 8d2a02b24d66aa359e83eebc1ed3c0f85367a1cb
kernel/drivers/gpu/arm/bifrost/csf/mali_kbase_csf_kcpu.h
....@@ -1,7 +1,7 @@
11 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
22 /*
33 *
4
- * (C) COPYRIGHT 2018-2021 ARM Limited. All rights reserved.
4
+ * (C) COPYRIGHT 2018-2023 ARM Limited. All rights reserved.
55 *
66 * This program is free software and is provided to you under the terms of the
77 * GNU General Public License version 2 as published by the Free Software
....@@ -21,6 +21,9 @@
2121
2222 #ifndef _KBASE_CSF_KCPU_H_
2323 #define _KBASE_CSF_KCPU_H_
24
+
25
+#include <mali_kbase_fence.h>
26
+#include <mali_kbase_sync.h>
2427
2528 #if (KERNEL_VERSION(4, 10, 0) > LINUX_VERSION_CODE)
2629 #include <linux/fence.h>
....@@ -44,12 +47,12 @@
4447 };
4548
4649 /**
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
4952 *
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
5356 */
5457 struct kbase_kcpu_command_fence_info {
5558 #if (KERNEL_VERSION(4, 10, 0) > LINUX_VERSION_CODE)
....@@ -117,6 +120,8 @@
117120 * @signaled: Bit array used to report the status of the CQS wait objects.
118121 * 1 is signaled, 0 otherwise.
119122 * @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
120125 */
121126 struct kbase_kcpu_command_cqs_wait_operation_info {
122127 struct base_cqs_wait_operation_info *objs;
....@@ -181,8 +186,9 @@
181186 struct kbase_mem_phy_alloc *cpu_alloc;
182187 };
183188
189
+#if IS_ENABLED(CONFIG_MALI_VECTOR_DUMP) || MALI_UNIT_TEST
184190 /**
185
- * struct base_kcpu_command_group_suspend - structure which contains
191
+ * struct kbase_kcpu_command_group_suspend_info - structure which contains
186192 * suspend buffer data captured for a suspended queue group.
187193 *
188194 * @sus_buf: Pointer to the structure which contains details of the
....@@ -193,17 +199,11 @@
193199 struct kbase_suspend_copy_buffer *sus_buf;
194200 u8 group_handle;
195201 };
202
+#endif
196203
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 */
204204
205205 /**
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
207207 * command queue
208208 *
209209 * @type: Type of the command.
....@@ -211,14 +211,16 @@
211211 * indicates that it has been enqueued earlier.
212212 * @info: Structure which holds information about the command
213213 * 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
222224 */
223225 struct kbase_kcpu_command {
224226 enum base_kcpu_command_type type;
....@@ -232,19 +234,20 @@
232234 struct kbase_kcpu_command_import_info import;
233235 struct kbase_kcpu_command_jit_alloc_info jit_alloc;
234236 struct kbase_kcpu_command_jit_free_info jit_free;
237
+#if IS_ENABLED(CONFIG_MALI_VECTOR_DUMP) || MALI_UNIT_TEST
235238 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
239240 } info;
240241 };
241242
242243 /**
243244 * struct kbase_kcpu_command_queue - a command queue executed by the kernel
244245 *
246
+ * @lock: Lock to protect accesses to this queue.
245247 * @kctx: The context to which this command queue belongs.
246248 * @commands: Array of commands which have been successfully
247249 * enqueued to this command queue.
250
+ * @wq: Dedicated workqueue for processing commands.
248251 * @work: struct work_struct which contains a pointer to
249252 * the function which handles processing of kcpu
250253 * commands enqueued into a kcpu command queue;
....@@ -277,10 +280,15 @@
277280 * or without errors since last cleaned.
278281 * @jit_blocked: Used to keep track of command queues blocked
279282 * 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.
280286 */
281287 struct kbase_kcpu_command_queue {
288
+ struct mutex lock;
282289 struct kbase_context *kctx;
283290 struct kbase_kcpu_command commands[KBASEP_KCPU_QUEUE_SIZE];
291
+ struct workqueue_struct *wq;
284292 struct work_struct work;
285293 u8 start_offset;
286294 u8 id;
....@@ -293,6 +301,12 @@
293301 bool command_started;
294302 struct list_head jit_blocked;
295303 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 */
296310 };
297311
298312 /**
....@@ -302,6 +316,8 @@
302316 * queue will be created.
303317 * @newq: Pointer to the structure which contains information about
304318 * the new KCPU command queue to be created.
319
+ *
320
+ * Return: 0 if successful or a negative error code on failure.
305321 */
306322 int kbase_csf_kcpu_queue_new(struct kbase_context *kctx,
307323 struct kbase_ioctl_kcpu_queue_new *newq);
....@@ -309,12 +325,12 @@
309325 /**
310326 * kbase_csf_kcpu_queue_delete - Delete KCPU command queue.
311327 *
312
- * Return: 0 if successful, -EINVAL if the queue ID is invalid.
313
- *
314328 * @kctx: Pointer to the kbase context from which the KCPU command
315329 * queue is to be deleted.
316330 * @del: Pointer to the structure which specifies the KCPU command
317331 * queue to be deleted.
332
+ *
333
+ * Return: 0 if successful or a negative error code on failure.
318334 */
319335 int kbase_csf_kcpu_queue_delete(struct kbase_context *kctx,
320336 struct kbase_ioctl_kcpu_queue_delete *del);
....@@ -328,6 +344,8 @@
328344 * @enq: Pointer to the structure which specifies the KCPU command
329345 * as well as the KCPU command queue into which the command
330346 * is to be enqueued.
347
+ *
348
+ * Return: 0 if successful or a negative error code on failure.
331349 */
332350 int kbase_csf_kcpu_queue_enqueue(struct kbase_context *kctx,
333351 struct kbase_ioctl_kcpu_queue_enqueue *enq);
....@@ -345,12 +363,22 @@
345363 /**
346364 * kbase_csf_kcpu_queue_context_term - Terminate the kernel CPU queues context
347365 * for a GPU address space
366
+ * @kctx: Pointer to the kbase context being terminated.
348367 *
349368 * This function deletes any kernel CPU queues that weren't deleted before
350369 * context termination.
351370 *
352
- * @kctx: Pointer to the kbase context being terminated.
353371 */
354372 void kbase_csf_kcpu_queue_context_term(struct kbase_context *kctx);
355373
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
+
356384 #endif /* _KBASE_CSF_KCPU_H_ */