drm/amdgpu: group userptr in the BO list v2
We need them together with the next patch. v2: Don't take bo reference twice Signed-off-by: Christian König <christian.koenig@amd.com> Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com> Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
a8bd1bec7c
commit
211dff5518
|
@ -1048,7 +1048,7 @@ struct amdgpu_bo_list {
|
||||||
struct amdgpu_bo *gds_obj;
|
struct amdgpu_bo *gds_obj;
|
||||||
struct amdgpu_bo *gws_obj;
|
struct amdgpu_bo *gws_obj;
|
||||||
struct amdgpu_bo *oa_obj;
|
struct amdgpu_bo *oa_obj;
|
||||||
bool has_userptr;
|
unsigned first_userptr;
|
||||||
unsigned num_entries;
|
unsigned num_entries;
|
||||||
struct amdgpu_bo_list_entry *array;
|
struct amdgpu_bo_list_entry *array;
|
||||||
};
|
};
|
||||||
|
|
|
@ -91,7 +91,7 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev,
|
||||||
struct amdgpu_bo *gws_obj = adev->gds.gws_gfx_bo;
|
struct amdgpu_bo *gws_obj = adev->gds.gws_gfx_bo;
|
||||||
struct amdgpu_bo *oa_obj = adev->gds.oa_gfx_bo;
|
struct amdgpu_bo *oa_obj = adev->gds.oa_gfx_bo;
|
||||||
|
|
||||||
bool has_userptr = false;
|
unsigned last_entry = 0, first_userptr = num_entries;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -101,8 +101,9 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev,
|
||||||
memset(array, 0, num_entries * sizeof(struct amdgpu_bo_list_entry));
|
memset(array, 0, num_entries * sizeof(struct amdgpu_bo_list_entry));
|
||||||
|
|
||||||
for (i = 0; i < num_entries; ++i) {
|
for (i = 0; i < num_entries; ++i) {
|
||||||
struct amdgpu_bo_list_entry *entry = &array[i];
|
struct amdgpu_bo_list_entry *entry;
|
||||||
struct drm_gem_object *gobj;
|
struct drm_gem_object *gobj;
|
||||||
|
struct amdgpu_bo *bo;
|
||||||
struct mm_struct *usermm;
|
struct mm_struct *usermm;
|
||||||
|
|
||||||
gobj = drm_gem_object_lookup(adev->ddev, filp, info[i].bo_handle);
|
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,
|
||||||
goto error_free;
|
goto error_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
entry->robj = amdgpu_bo_ref(gem_to_amdgpu_bo(gobj));
|
bo = amdgpu_bo_ref(gem_to_amdgpu_bo(gobj));
|
||||||
drm_gem_object_unreference_unlocked(gobj);
|
drm_gem_object_unreference_unlocked(gobj);
|
||||||
entry->priority = min(info[i].bo_priority,
|
|
||||||
AMDGPU_BO_LIST_MAX_PRIORITY);
|
usermm = amdgpu_ttm_tt_get_usermm(bo->tbo.ttm);
|
||||||
usermm = amdgpu_ttm_tt_get_usermm(entry->robj->tbo.ttm);
|
|
||||||
if (usermm) {
|
if (usermm) {
|
||||||
if (usermm != current->mm) {
|
if (usermm != current->mm) {
|
||||||
amdgpu_bo_unref(&entry->robj);
|
amdgpu_bo_unref(&bo);
|
||||||
r = -EPERM;
|
r = -EPERM;
|
||||||
goto error_free;
|
goto error_free;
|
||||||
}
|
}
|
||||||
has_userptr = true;
|
entry = &array[--first_userptr];
|
||||||
|
} else {
|
||||||
|
entry = &array[last_entry++];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
entry->robj = bo;
|
||||||
|
entry->priority = min(info[i].bo_priority,
|
||||||
|
AMDGPU_BO_LIST_MAX_PRIORITY);
|
||||||
entry->tv.bo = &entry->robj->tbo;
|
entry->tv.bo = &entry->robj->tbo;
|
||||||
entry->tv.shared = true;
|
entry->tv.shared = true;
|
||||||
|
|
||||||
|
@ -145,7 +151,7 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev,
|
||||||
list->gds_obj = gds_obj;
|
list->gds_obj = gds_obj;
|
||||||
list->gws_obj = gws_obj;
|
list->gws_obj = gws_obj;
|
||||||
list->oa_obj = oa_obj;
|
list->oa_obj = oa_obj;
|
||||||
list->has_userptr = has_userptr;
|
list->first_userptr = first_userptr;
|
||||||
list->array = array;
|
list->array = array;
|
||||||
list->num_entries = num_entries;
|
list->num_entries = num_entries;
|
||||||
|
|
||||||
|
|
|
@ -350,7 +350,8 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
|
||||||
|
|
||||||
p->bo_list = amdgpu_bo_list_get(fpriv, cs->in.bo_list_handle);
|
p->bo_list = amdgpu_bo_list_get(fpriv, cs->in.bo_list_handle);
|
||||||
if (p->bo_list) {
|
if (p->bo_list) {
|
||||||
need_mmap_lock = p->bo_list->has_userptr;
|
need_mmap_lock = p->bo_list->first_userptr !=
|
||||||
|
p->bo_list->num_entries;
|
||||||
amdgpu_bo_list_get_list(p->bo_list, &p->validated);
|
amdgpu_bo_list_get_list(p->bo_list, &p->validated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue