Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/amdgpu: track the userq bo va for its obj management

Track the userq obj for its life time, and reference and
dereference the buffer flag at its creating and destroying
period.

Suggested-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Prike Liang <Prike.Liang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Prike Liang and committed by
Alex Deucher
2a28f966 5cfa33fa

+36
+36
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
··· 97 97 return r; 98 98 } 99 99 100 + static void amdgpu_userq_buffer_va_list_del(struct amdgpu_bo_va_mapping *mapping, 101 + struct amdgpu_userq_va_cursor *va_cursor) 102 + { 103 + atomic_set(&mapping->bo_va->userq_va_mapped, 0); 104 + list_del(&va_cursor->list); 105 + kfree(va_cursor); 106 + } 107 + 108 + static int amdgpu_userq_buffer_vas_list_cleanup(struct amdgpu_device *adev, 109 + struct amdgpu_usermode_queue *queue) 110 + { 111 + struct amdgpu_userq_va_cursor *va_cursor, *tmp; 112 + struct amdgpu_bo_va_mapping *mapping; 113 + int r; 114 + 115 + r = amdgpu_bo_reserve(queue->vm->root.bo, false); 116 + if (r) 117 + return r; 118 + 119 + list_for_each_entry_safe(va_cursor, tmp, &queue->userq_va_list, list) { 120 + mapping = amdgpu_vm_bo_lookup_mapping(queue->vm, va_cursor->gpu_addr); 121 + if (!mapping) { 122 + r = -EINVAL; 123 + goto err; 124 + } 125 + amdgpu_userq_buffer_va_list_del(mapping, va_cursor); 126 + dev_dbg(adev->dev, "delete the userq:%p va:%llx\n", 127 + queue, va_cursor->gpu_addr); 128 + } 129 + err: 130 + amdgpu_bo_unreserve(queue->vm->root.bo); 131 + return r; 132 + } 133 + 100 134 static int 101 135 amdgpu_userq_preempt_helper(struct amdgpu_userq_mgr *uq_mgr, 102 136 struct amdgpu_usermode_queue *queue) ··· 236 202 struct amdgpu_device *adev = uq_mgr->adev; 237 203 const struct amdgpu_userq_funcs *uq_funcs = adev->userq_funcs[queue->queue_type]; 238 204 205 + /* Drop the userq reference. */ 206 + amdgpu_userq_buffer_vas_list_cleanup(adev, queue); 239 207 uq_funcs->mqd_destroy(uq_mgr, queue); 240 208 amdgpu_userq_fence_driver_free(queue); 241 209 idr_remove(&uq_mgr->userq_idr, queue_id);