2 * Copyright 2022 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
23 #ifndef __AMDGPU_CS_H__
24 #define __AMDGPU_CS_H__
26 #include <linux/ww_mutex.h>
28 #include "amdgpu_job.h"
29 #include "amdgpu_bo_list.h"
30 #include "amdgpu_ring.h"
32 #define AMDGPU_CS_GANG_SIZE 4
34 struct amdgpu_bo_va_mapping;
36 struct amdgpu_cs_chunk {
42 struct amdgpu_cs_post_dep {
43 struct drm_syncobj *syncobj;
44 struct dma_fence_chain *chain;
48 struct amdgpu_cs_parser {
49 struct amdgpu_device *adev;
50 struct drm_file *filp;
51 struct amdgpu_ctx *ctx;
55 struct amdgpu_cs_chunk *chunks;
57 /* scheduler job objects */
58 unsigned int gang_size;
59 unsigned int gang_leader_idx;
60 struct drm_sched_entity *entities[AMDGPU_CS_GANG_SIZE];
61 struct amdgpu_job *jobs[AMDGPU_CS_GANG_SIZE];
62 struct amdgpu_job *gang_leader;
65 struct ww_acquire_ctx ticket;
66 struct amdgpu_bo_list *bo_list;
68 struct amdgpu_bo_list_entry vm_pd;
69 struct list_head validated;
70 struct dma_fence *fence;
71 uint64_t bytes_moved_threshold;
72 uint64_t bytes_moved_vis_threshold;
74 uint64_t bytes_moved_vis;
77 struct amdgpu_bo_list_entry uf_entry;
79 unsigned num_post_deps;
80 struct amdgpu_cs_post_dep *post_deps;
82 struct amdgpu_sync sync;
85 int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,
86 uint64_t addr, struct amdgpu_bo **bo,
87 struct amdgpu_bo_va_mapping **mapping);