2 * Copyright 2018 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_BO_LIST_H__
24 #define __AMDGPU_BO_LIST_H__
26 #include <drm/amdgpu_drm.h>
37 struct amdgpu_bo_list_entry {
39 struct amdgpu_bo_va *bo_va;
41 struct page **user_pages;
42 struct hmm_range *range;
43 bool user_invalidated;
46 struct amdgpu_bo_list {
47 struct rcu_head rhead;
49 struct amdgpu_bo *gds_obj;
50 struct amdgpu_bo *gws_obj;
51 struct amdgpu_bo *oa_obj;
52 unsigned first_userptr;
55 /* Protect access during command submission.
57 struct mutex bo_list_mutex;
60 int amdgpu_bo_list_get(struct amdgpu_fpriv *fpriv, int id,
61 struct amdgpu_bo_list **result);
62 void amdgpu_bo_list_put(struct amdgpu_bo_list *list);
63 int amdgpu_bo_create_list_entry_array(struct drm_amdgpu_bo_list_in *in,
64 struct drm_amdgpu_bo_list_entry **info_param);
66 int amdgpu_bo_list_create(struct amdgpu_device *adev,
67 struct drm_file *filp,
68 struct drm_amdgpu_bo_list_entry *info,
70 struct amdgpu_bo_list **list);
72 static inline struct amdgpu_bo_list_entry *
73 amdgpu_bo_list_array_entry(struct amdgpu_bo_list *list, unsigned index)
75 struct amdgpu_bo_list_entry *array = (void *)&list[1];
80 #define amdgpu_bo_list_for_each_entry(e, list) \
81 for (e = amdgpu_bo_list_array_entry(list, 0); \
82 e != amdgpu_bo_list_array_entry(list, (list)->num_entries); \
85 #define amdgpu_bo_list_for_each_userptr_entry(e, list) \
86 for (e = amdgpu_bo_list_array_entry(list, (list)->first_userptr); \
87 e != amdgpu_bo_list_array_entry(list, (list)->num_entries); \