Skip to contentSkip to conversation

FAILED: patch "[PATCH] drm/amdgpu: fix clearing mappings for BOs that are always" failed to apply to 5.10-stable tree

PATCH [email protected] 1 participant 1 message Jul 21, 2023

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x ea2c3c08554601b051d91403a241266e1cf490a5
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2023072146-landscape-vendetta-a711@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^..

Possible dependencies:

ea2c3c085546 ("drm/amdgpu: fix clearing mappings for BOs that are always valid in VM")

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From ea2c3c08554601b051d91403a241266e1cf490a5 Mon Sep 17 00:00:00 2001
From: Samuel Pitoiset <[email protected]>
Date: Fri, 16 Jun 2023 15:14:07 +0200
Subject: [PATCH] drm/amdgpu: fix clearing mappings for BOs that are always
valid in VM
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Per VM BOs must be marked as moved or otherwise their ranges are not updated on use which might be necessary when the replace operation splits mappings.

This fixes random GPU hangs when replacing sparse mappings from the userspace, while OP_MAP/OP_UNMAP works fine because always valid BOs are correctly handled there.

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +12 -0
index 143d11afe0e5..eff73c428b12 100644
@@ -1771,18 +1771,30 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,
 
 	/* Insert partial mapping before the range */
 	if (!list_empty(&before->list)) {
+		struct amdgpu_bo *bo = before->bo_va->base.bo;
+
 		amdgpu_vm_it_insert(before, &vm->va);
 		if (before->flags & AMDGPU_PTE_PRT)
 			amdgpu_vm_prt_get(adev);
+
+		if (bo && bo->tbo.base.resv == vm->root.bo->tbo.base.resv &&
+		    !before->bo_va->base.moved)
+			amdgpu_vm_bo_moved(&before->bo_va->base);
 	} else {
 		kfree(before);
 	}
 
 	/* Insert partial mapping after the range */
 	if (!list_empty(&after->list)) {
+		struct amdgpu_bo *bo = after->bo_va->base.bo;
+
 		amdgpu_vm_it_insert(after, &vm->va);
 		if (after->flags & AMDGPU_PTE_PRT)
 			amdgpu_vm_prt_get(adev);
+
+		if (bo && bo->tbo.base.resv == vm->root.bo->tbo.base.resv &&
+		    !after->bo_va->base.moved)
+			amdgpu_vm_bo_moved(&after->bo_va->base);
 	} else {
 		kfree(after);
 	}