From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB4BFEB64DC for ; Fri, 21 Jul 2023 12:03:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229779AbjGUMD2 (ORCPT ); Fri, 21 Jul 2023 08:03:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229666AbjGUMD1 (ORCPT ); Fri, 21 Jul 2023 08:03:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79DAE30E1 for ; Fri, 21 Jul 2023 05:02:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 24F7561A0C for ; Fri, 21 Jul 2023 12:02:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E29DC433C7; Fri, 21 Jul 2023 12:02:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1689940928; bh=WqQzSkTTe8Gq1me05l04IGhspvLSQOvF9vSYa5fh1S0=; h=Subject:To:Cc:From:Date:From; b=K4MHEq2KD1QwSXSfbi3sUUxtltiRdU9kFL6Q4zbf9rg0wj15jMj7WoPgo2n0QJ3YO knbX4usdoLq6UEUb03OAOfuGTgpMdQCTabsgfjgN1oRSLDiZy+SnFnQcuPOgclKRbO OqvgE1tcjS25nwDuIFnyN2+AbhVu4sY+Me8i0H5Y= Subject: FAILED: patch "[PATCH] drm/amdgpu: fix clearing mappings for BOs that are always" failed to apply to 5.4-stable tree To: samuel.pitoiset@gmail.com, alexander.deucher@amd.com, christian.koenig@amd.com Cc: From: Date: Fri, 21 Jul 2023 14:02:05 +0200 Message-ID: <2023072105-enlarged-mule-8e16@gregkh> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 5.4-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 . 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.4.y git checkout FETCH_HEAD git cherry-pick -x ea2c3c08554601b051d91403a241266e1cf490a5 # git commit -s git send-email --to '' --in-reply-to '2023072105-enlarged-mule-8e16@gregkh' --subject-prefix 'PATCH 5.4.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 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. Cc: stable@vger.kernel.org Signed-off-by: Samuel Pitoiset Reviewed-by: Christian König Signed-off-by: Alex Deucher diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 143d11afe0e5..eff73c428b12 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -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); }