xref: /linux/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.h (revision cbac924200b838cfb8d8b1415113d788089dc50b)
1 /*
2  * Copyright 2022 Advanced Micro Devices, Inc.
3  *
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:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
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.
21  *
22  */
23 #ifndef __AMDGPU_CS_H__
24 #define __AMDGPU_CS_H__
25 
26 #include "amdgpu_job.h"
27 #include "amdgpu_bo_list.h"
28 #include "amdgpu_ring.h"
29 
30 struct amdgpu_bo_va_mapping;
31 
32 struct amdgpu_cs_chunk {
33 	uint32_t		chunk_id;
34 	uint32_t		length_dw;
35 	void			*kdata;
36 };
37 
38 struct amdgpu_cs_post_dep {
39 	struct drm_syncobj *syncobj;
40 	struct dma_fence_chain *chain;
41 	u64 point;
42 };
43 
44 struct amdgpu_cs_parser {
45 	struct amdgpu_device	*adev;
46 	struct drm_file		*filp;
47 	struct amdgpu_ctx	*ctx;
48 
49 	/* chunks */
50 	unsigned		nchunks;
51 	struct amdgpu_cs_chunk	*chunks;
52 
53 	/* scheduler job object */
54 	struct amdgpu_job	*job;
55 	struct drm_sched_entity	*entity;
56 
57 	/* buffer objects */
58 	struct ww_acquire_ctx		ticket;
59 	struct amdgpu_bo_list		*bo_list;
60 	struct amdgpu_mn		*mn;
61 	struct amdgpu_bo_list_entry	vm_pd;
62 	struct list_head		validated;
63 	struct dma_fence		*fence;
64 	uint64_t			bytes_moved_threshold;
65 	uint64_t			bytes_moved_vis_threshold;
66 	uint64_t			bytes_moved;
67 	uint64_t			bytes_moved_vis;
68 
69 	/* user fence */
70 	struct amdgpu_bo_list_entry	uf_entry;
71 
72 	unsigned			num_post_deps;
73 	struct amdgpu_cs_post_dep	*post_deps;
74 };
75 
76 int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,
77 			   uint64_t addr, struct amdgpu_bo **bo,
78 			   struct amdgpu_bo_va_mapping **mapping);
79 
80 #endif
81