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: extract amdgpu_vm_lock_by_pasid from amdgpu_vm_handle_fault

This is tricky to implement right and we're going to need
it from the devcoredump.

Signed-off-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Pierre-Eric Pelloux-Prayer and committed by
Alex Deucher
1b135c6d d1f188b1

+54 -29
+51 -29
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
··· 2950 2950 } 2951 2951 2952 2952 /** 2953 + * amdgpu_vm_lock_by_pasid - return an amdgpu_vm and its root bo from a pasid, if possible. 2954 + * @adev: amdgpu device pointer 2955 + * @root: root BO of the VM 2956 + * @pasid: PASID of the VM 2957 + * The caller needs to unreserve and unref the root bo on success. 2958 + */ 2959 + struct amdgpu_vm *amdgpu_vm_lock_by_pasid(struct amdgpu_device *adev, 2960 + struct amdgpu_bo **root, u32 pasid) 2961 + { 2962 + unsigned long irqflags; 2963 + struct amdgpu_vm *vm; 2964 + int r; 2965 + 2966 + xa_lock_irqsave(&adev->vm_manager.pasids, irqflags); 2967 + vm = xa_load(&adev->vm_manager.pasids, pasid); 2968 + *root = vm ? amdgpu_bo_ref(vm->root.bo) : NULL; 2969 + xa_unlock_irqrestore(&adev->vm_manager.pasids, irqflags); 2970 + 2971 + if (!*root) 2972 + return NULL; 2973 + 2974 + r = amdgpu_bo_reserve(*root, true); 2975 + if (r) 2976 + goto error_unref; 2977 + 2978 + /* Double check that the VM still exists */ 2979 + xa_lock_irqsave(&adev->vm_manager.pasids, irqflags); 2980 + vm = xa_load(&adev->vm_manager.pasids, pasid); 2981 + if (vm && vm->root.bo != *root) 2982 + vm = NULL; 2983 + xa_unlock_irqrestore(&adev->vm_manager.pasids, irqflags); 2984 + if (!vm) 2985 + goto error_unlock; 2986 + 2987 + return vm; 2988 + error_unlock: 2989 + amdgpu_bo_unreserve(*root); 2990 + 2991 + error_unref: 2992 + amdgpu_bo_unref(root); 2993 + return NULL; 2994 + } 2995 + 2996 + /** 2953 2997 * amdgpu_vm_handle_fault - graceful handling of VM faults. 2954 2998 * @adev: amdgpu device pointer 2955 2999 * @pasid: PASID of the VM ··· 3008 2964 * shouldn't be reported any more. 3009 2965 */ 3010 2966 bool amdgpu_vm_handle_fault(struct amdgpu_device *adev, u32 pasid, 3011 - u32 vmid, u32 node_id, uint64_t addr, uint64_t ts, 3012 - bool write_fault) 2967 + u32 vmid, u32 node_id, uint64_t addr, 2968 + uint64_t ts, bool write_fault) 3013 2969 { 3014 2970 bool is_compute_context = false; 3015 2971 struct amdgpu_bo *root; 3016 - unsigned long irqflags; 3017 2972 uint64_t value, flags; 3018 2973 struct amdgpu_vm *vm; 3019 2974 int r; 3020 2975 3021 - xa_lock_irqsave(&adev->vm_manager.pasids, irqflags); 3022 - vm = xa_load(&adev->vm_manager.pasids, pasid); 3023 - if (vm) { 3024 - root = amdgpu_bo_ref(vm->root.bo); 3025 - is_compute_context = vm->is_compute_context; 3026 - } else { 3027 - root = NULL; 3028 - } 3029 - xa_unlock_irqrestore(&adev->vm_manager.pasids, irqflags); 3030 - 3031 - if (!root) 2976 + vm = amdgpu_vm_lock_by_pasid(adev, &root, pasid); 2977 + if (!vm) 3032 2978 return false; 2979 + 2980 + is_compute_context = vm->is_compute_context; 3033 2981 3034 2982 if (is_compute_context && !svm_range_restore_pages(adev, pasid, vmid, 3035 2983 node_id, addr >> PAGE_SHIFT, ts, write_fault)) { 2984 + amdgpu_bo_unreserve(root); 3036 2985 amdgpu_bo_unref(&root); 3037 2986 return true; 3038 2987 } 3039 2988 3040 2989 addr /= AMDGPU_GPU_PAGE_SIZE; 3041 - 3042 - r = amdgpu_bo_reserve(root, true); 3043 - if (r) 3044 - goto error_unref; 3045 - 3046 - /* Double check that the VM still exists */ 3047 - xa_lock_irqsave(&adev->vm_manager.pasids, irqflags); 3048 - vm = xa_load(&adev->vm_manager.pasids, pasid); 3049 - if (vm && vm->root.bo != root) 3050 - vm = NULL; 3051 - xa_unlock_irqrestore(&adev->vm_manager.pasids, irqflags); 3052 - if (!vm) 3053 - goto error_unlock; 3054 - 3055 2990 flags = AMDGPU_PTE_VALID | AMDGPU_PTE_SNOOPED | 3056 2991 AMDGPU_PTE_SYSTEM; 3057 2992 ··· 3069 3046 if (r < 0) 3070 3047 dev_err(adev->dev, "Can't handle page fault (%d)\n", r); 3071 3048 3072 - error_unref: 3073 3049 amdgpu_bo_unref(&root); 3074 3050 3075 3051 return false;
+3
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
··· 592 592 u32 vmid, u32 node_id, uint64_t addr, uint64_t ts, 593 593 bool write_fault); 594 594 595 + struct amdgpu_vm *amdgpu_vm_lock_by_pasid(struct amdgpu_device *adev, 596 + struct amdgpu_bo **root, u32 pasid); 597 + 595 598 void amdgpu_vm_set_task_info(struct amdgpu_vm *vm); 596 599 597 600 void amdgpu_vm_move_to_lru_tail(struct amdgpu_device *adev,