⬢ DragonFlyBSD Kernel Audit
DF-4356 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/drm/amd/amdgpu/amdgpu_kms.c
+++ b/sys/dev/drm/amd/amdgpu/amdgpu_kms.c
@@ -1070,8 +1070,12 @@
 	pasid = fpriv->vm.pasid;
 	pd = amdgpu_bo_ref(fpriv->vm.root.base.bo);
 
-	amdgpu_vm_fini(adev, &fpriv->vm);
+	/* Finish contexts (and their scheduler entities / in-flight jobs)
+	 * BEFORE tearing down the VM, matching upstream Linux: amdgpu_vm_fini
+	 * frees the GPU page tables and drops the PASID, which executing
+	 * context jobs still reference. */
 	amdgpu_ctx_mgr_fini(&fpriv->ctx_mgr);
+	amdgpu_vm_fini(adev, &fpriv->vm);
 
 	if (pasid)
 		amdgpu_pasid_free_delayed(pd->tbo.resv, pasid);