From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 519F8606A31A for ; Wed, 2 Dec 2026 13:39:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ub1f13gN Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CC0FB10E5B3; Wed, 2 Dec 2026 13:39:07 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id EC19510E5B3 for ; Wed, 2 Dec 2026 13:39:01 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id B6E58453DB; Wed, 2 Dec 2026 13:39:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F65B1F00924; Wed, 2 Dec 2026 13:39:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796218741; bh=gCG/TZVfOdgsC+kDznnYhMZ2bF1002B0LG+FU36Jd9k=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=Ub1f13gN8we0ZSYsRSUi7P3NyJQEy4/yAFwQ4nOqEMD1ASEdXRnFHdlFRVfZWFzJK k1aHiXQbj8Y/T5KrD5rXYsLDqSByFIMlCeiWkh9TO7bnPw3FS47tUJYecIm5Fjqa6u ndts+A7Agi7LuNYpPU6MAsGcQFDhz+LkrvBFHuQ1DLN3Qn1FMaaYBySTsfudqS4/7o uuI+Jvq7YfSmh6WBkjJ/QYuyNVJc5uLvuD2JROACv5Q6IHREV0l0Qk4pvUbcq+Mu0L mtVi0f60vIaLKYlH4NdV/IxzTUJjEGPWFTdCNDhceZQ7zJEXdbitC+8Fm0kiTcsiDK t/SCHBmAPc3fQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 2/2] drm/amdgpu: Reset cleared state of free VRAM after GPU reset To: "Arunpravin Paneer Selvam" , amd-gfx@lists.freedesktop.org In-Reply-To: <20261202132224.217180-2-Arunpravin.PaneerSelvam@amd.com> References: <20261202132224.217180-1-Arunpravin.PaneerSelvam@amd.com> <20261202132224.217180-2-Arunpravin.PaneerSelvam@amd.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 13:39:00 +0000 X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "amd-gfx" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] drm/amdgpu: stale clear flag on in-flight BOs in amdgpu_vram_mgr_del() - [Medium] drm/amdgpu: post-reset cleared VRAM marked dirty in amdgpu_vram_mgr_new() -- commit 2577c3d1b0a535240f16afc3751845e6b2fd1bb7 Author: Arunpravin Paneer Selvam drm/amdgpu: Reset cleared state of free VRAM after GPU reset This commit tracks adev->gpu_reset_counter in the VRAM manager and resets the cleared state of free buddy blocks on the first VRAM allocation after a GPU reset. > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/d= rm/amd/amdgpu/amdgpu_vram_mgr.c > index 249f07f309515..6aa6d49b8e80b 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c > @@ -456,7 +456,7 @@ static int amdgpu_vram_mgr_new(struct ttm_resource_ma= nager *man, > struct gpu_buddy *mm =3D &mgr->mm; > struct gpu_buddy_block *block; > unsigned long pages_per_block; > - int r; > + int reset_counter, r; > =20 > lpfn =3D (u64)place->lpfn << PAGE_SHIFT; > if (!lpfn || lpfn > man->size) > @@ -523,6 +523,13 @@ static int amdgpu_vram_mgr_new(struct ttm_resource_m= anager *man, > } > =20 > mutex_lock(&mgr->lock); > + > + reset_counter =3D atomic_read(&adev->gpu_reset_counter); > + if (unlikely(mgr->reset_counter !=3D reset_counter)) { > + gpu_buddy_reset_clear(mm, false); > + mgr->reset_counter =3D reset_counter; > + } > + [Severity: High] Can a BO whose wipe-on-release clear job was in flight across a GPU reset still return its uncleared blocks to the buddy allocator with GPU_BUDDY_CLEARED after gpu_buddy_reset_clear() has already run? amdgpu_bo_release_notify() sets GPU_BUDDY_CLEARED on bo->resource as soon as amdgpu_ttm_clear_buffer() submits the asynchronous SDMA clear job, while the blocks remain allocated until the fence signals and ttm_bo_delayed_delete() calls amdgpu_vram_mgr_del(): CPU0 CPU1 / bdev->wq amdgpu_bo_release_notify() amdgpu_ttm_clear_buffer() amdgpu_vram_mgr_set_cleared() amdgpu_device_halt_activities() atomic_inc(&gpu_reset_counter) amdgpu_vram_mgr_new() gpu_buddy_reset_clear(mm, false) mgr->reset_counter =3D reset_counter ... (reset cancels clear fence or loses VRAM) ttm_bo_delayed_delete() amdgpu_vram_mgr_del() gpu_buddy_free_list(..., vres->flags) <-- marks dirty blocks clear Because vres->blocks were not in mm->free_tree when amdgpu_vram_mgr_new() ran, gpu_buddy_reset_clear() did not touch them, and amdgpu_vram_mgr_del() later frees them with GPU_BUDDY_CLEARED while mgr->reset_counter is already up to date. Subsequent AMDGPU_GEM_CREATE_VRAM_CLEARED allocations can then skip zeroing those blocks and expose stale pre-reset VRAM contents across userspace processes. [Severity: Medium] What happens if one or more BOs are released and cleared by SDMA after a GPU reset finishes, before the first post-reset call to amdgpu_vram_mgr_new()? Because amdgpu_vram_mgr_del() does not check or update mgr->reset_counter, any blocks that were genuinely cleared and freed during post-reset teardown are placed into mm->free_tree while mgr->reset_counter still holds its pre-reset value. The first subsequent amdgpu_vram_mgr_new() then sees mgr->reset_counter !=3D reset_counter and calls gpu_buddy_reset_clear(mm, false), wiping the cleared state of those post-reset blocks and forcing redundant SDMA clear passes on reallocation. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202132224.2171= 80-1-Arunpravin.PaneerSelvam@amd.com?part=3D2