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: validate the queue va for resuming the queue

It requires validating the userq VA whether is mapped before
trying to resume the queue.

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
89926812 873f44c3

+44
+44
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
··· 97 97 return r; 98 98 } 99 99 100 + static bool amdgpu_userq_buffer_va_mapped(struct amdgpu_vm *vm, u64 addr) 101 + { 102 + struct amdgpu_bo_va_mapping *mapping; 103 + bool r; 104 + 105 + if (amdgpu_bo_reserve(vm->root.bo, false)) 106 + return false; 107 + 108 + mapping = amdgpu_vm_bo_lookup_mapping(vm, addr); 109 + if (!IS_ERR_OR_NULL(mapping) && atomic_read(&mapping->bo_va->userq_va_mapped)) 110 + r = true; 111 + else 112 + r = false; 113 + amdgpu_bo_unreserve(vm->root.bo); 114 + 115 + return r; 116 + } 117 + 118 + static bool amdgpu_userq_buffer_vas_mapped(struct amdgpu_usermode_queue *queue) 119 + { 120 + struct amdgpu_userq_va_cursor *va_cursor, *tmp; 121 + int r = 0; 122 + 123 + list_for_each_entry_safe(va_cursor, tmp, &queue->userq_va_list, list) { 124 + r += amdgpu_userq_buffer_va_mapped(queue->vm, va_cursor->gpu_addr); 125 + dev_dbg(queue->userq_mgr->adev->dev, 126 + "validate the userq mapping:%p va:%llx r:%d\n", 127 + queue, va_cursor->gpu_addr, r); 128 + } 129 + 130 + if (r != 0) 131 + return true; 132 + 133 + return false; 134 + } 135 + 100 136 static void amdgpu_userq_buffer_va_list_del(struct amdgpu_bo_va_mapping *mapping, 101 137 struct amdgpu_userq_va_cursor *va_cursor) 102 138 { ··· 797 761 798 762 /* Resume all the queues for this process */ 799 763 idr_for_each_entry(&uq_mgr->userq_idr, queue, queue_id) { 764 + 765 + if (!amdgpu_userq_buffer_vas_mapped(queue)) { 766 + drm_file_err(uq_mgr->file, 767 + "trying restore queue without va mapping\n"); 768 + queue->state = AMDGPU_USERQ_STATE_INVALID_VA; 769 + continue; 770 + } 771 + 800 772 r = amdgpu_userq_restore_helper(uq_mgr, queue); 801 773 if (r) 802 774 ret = r;