aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu.h2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c24
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c3
3 files changed, 18 insertions, 11 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 497ca587cc35..11a9f5899995 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1048,7 +1048,7 @@ struct amdgpu_bo_list {
1048 struct amdgpu_bo *gds_obj; 1048 struct amdgpu_bo *gds_obj;
1049 struct amdgpu_bo *gws_obj; 1049 struct amdgpu_bo *gws_obj;
1050 struct amdgpu_bo *oa_obj; 1050 struct amdgpu_bo *oa_obj;
1051 bool has_userptr; 1051 unsigned first_userptr;
1052 unsigned num_entries; 1052 unsigned num_entries;
1053 struct amdgpu_bo_list_entry *array; 1053 struct amdgpu_bo_list_entry *array;
1054}; 1054};
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
index 4792f9d0b7d4..9763e52886fe 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
@@ -91,7 +91,7 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev,
91 struct amdgpu_bo *gws_obj = adev->gds.gws_gfx_bo; 91 struct amdgpu_bo *gws_obj = adev->gds.gws_gfx_bo;
92 struct amdgpu_bo *oa_obj = adev->gds.oa_gfx_bo; 92 struct amdgpu_bo *oa_obj = adev->gds.oa_gfx_bo;
93 93
94 bool has_userptr = false; 94 unsigned last_entry = 0, first_userptr = num_entries;
95 unsigned i; 95 unsigned i;
96 int r; 96 int r;
97 97
@@ -101,8 +101,9 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev,
101 memset(array, 0, num_entries * sizeof(struct amdgpu_bo_list_entry)); 101 memset(array, 0, num_entries * sizeof(struct amdgpu_bo_list_entry));
102 102
103 for (i = 0; i < num_entries; ++i) { 103 for (i = 0; i < num_entries; ++i) {
104 struct amdgpu_bo_list_entry *entry = &array[i]; 104 struct amdgpu_bo_list_entry *entry;
105 struct drm_gem_object *gobj; 105 struct drm_gem_object *gobj;
106 struct amdgpu_bo *bo;
106 struct mm_struct *usermm; 107 struct mm_struct *usermm;
107 108
108 gobj = drm_gem_object_lookup(adev->ddev, filp, info[i].bo_handle); 109 gobj = drm_gem_object_lookup(adev->ddev, filp, info[i].bo_handle);
@@ -111,19 +112,24 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev,
111 goto error_free; 112 goto error_free;
112 } 113 }
113 114
114 entry->robj = amdgpu_bo_ref(gem_to_amdgpu_bo(gobj)); 115 bo = amdgpu_bo_ref(gem_to_amdgpu_bo(gobj));
115 drm_gem_object_unreference_unlocked(gobj); 116 drm_gem_object_unreference_unlocked(gobj);
116 entry->priority = min(info[i].bo_priority, 117
117 AMDGPU_BO_LIST_MAX_PRIORITY); 118 usermm = amdgpu_ttm_tt_get_usermm(bo->tbo.ttm);
118 usermm = amdgpu_ttm_tt_get_usermm(entry->robj->tbo.ttm);
119 if (usermm) { 119 if (usermm) {
120 if (usermm != current->mm) { 120 if (usermm != current->mm) {
121 amdgpu_bo_unref(&entry->robj); 121 amdgpu_bo_unref(&bo);
122 r = -EPERM; 122 r = -EPERM;
123 goto error_free; 123 goto error_free;
124 } 124 }
125 has_userptr = true; 125 entry = &array[--first_userptr];
126 } else {
127 entry = &array[last_entry++];
126 } 128 }
129
130 entry->robj = bo;
131 entry->priority = min(info[i].bo_priority,
132 AMDGPU_BO_LIST_MAX_PRIORITY);
127 entry->tv.bo = &entry->robj->tbo; 133 entry->tv.bo = &entry->robj->tbo;
128 entry->tv.shared = true; 134 entry->tv.shared = true;
129 135
@@ -145,7 +151,7 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev,
145 list->gds_obj = gds_obj; 151 list->gds_obj = gds_obj;
146 list->gws_obj = gws_obj; 152 list->gws_obj = gws_obj;
147 list->oa_obj = oa_obj; 153 list->oa_obj = oa_obj;
148 list->has_userptr = has_userptr; 154 list->first_userptr = first_userptr;
149 list->array = array; 155 list->array = array;
150 list->num_entries = num_entries; 156 list->num_entries = num_entries;
151 157
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 52c3eb96b199..7833dfb1ff6e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -350,7 +350,8 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
350 350
351 p->bo_list = amdgpu_bo_list_get(fpriv, cs->in.bo_list_handle); 351 p->bo_list = amdgpu_bo_list_get(fpriv, cs->in.bo_list_handle);
352 if (p->bo_list) { 352 if (p->bo_list) {
353 need_mmap_lock = p->bo_list->has_userptr; 353 need_mmap_lock = p->bo_list->first_userptr !=
354 p->bo_list->num_entries;
354 amdgpu_bo_list_get_list(p->bo_list, &p->validated); 355 amdgpu_bo_list_get_list(p->bo_list, &p->validated);
355 } 356 }
356 357