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 61DCE606A31C for ; Mon, 30 Nov 2026 12:34:56 +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=GEnC+Hf3 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EDABD10EF92; Mon, 30 Nov 2026 12:34:50 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3F0CA10EF92 for ; Mon, 30 Nov 2026 12:34:45 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 662AD62025; Mon, 30 Nov 2026 12:34:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BF541F0089B; Mon, 30 Nov 2026 12:34:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796042083; bh=K9MiH+RinwgMKPZemT9JmZHK1gBNZAVFKoVqNGtbYJU=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=GEnC+Hf3jbRlkviHBAIXTttHWoFQUQF42CVqlfqP43zs8Hg/icyCsilIoYInodMrD 9v39mMDbakY/nnJX7/hO3ku/Ll4jCMHuU3z5plnkIcK1bTeHmx8RRi5Y0HL7pDmsiI HV/iRYo3X7yJe9Ywk5uk9159ZUTkPcjohfw12sdj0v62qP9SDD8wN94QV8w3hrpB+O ALB0GUFczwhBieBTYxh7hcDQVMdDoLIpgWSCS1yHqhr2AGgs1MpmJ0j2yT/ouVQRfd 5vVC0y9mPTt2IfRKo1N9lDtaeHJ74ohe/I/CbRhKbGoahDleTWmqjIXj1LLFO2pM9X vuJSYCyrnCCeA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 2/3] drm/amdgpu: Reset cleared state of free VRAM after GPU reset To: "Arunpravin Paneer Selvam" , amd-gfx@lists.freedesktop.org In-Reply-To: <20261130121049.26541-2-Arunpravin.PaneerSelvam@amd.com> References: <20261130121049.26541-1-Arunpravin.PaneerSelvam@amd.com> <20261130121049.26541-2-Arunpravin.PaneerSelvam@amd.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 12:34:43 +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 1 potential issue to consider: - [Medium] drm/amdgpu: race on gpu_reset_counter in amdgpu_vram_mgr_check_reset() -- commit e2f6a53587f6a83dcd78a77fe71d3295729bf04a Author: Arunpravin Paneer Selvam drm/amdgpu: Reset cleared state of free VRAM after GPU reset This commit tracks adev->gpu_reset_counter in struct amdgpu_vram_mgr and resets the cleared state of free VRAM buddy blocks during allocation and free when the counter has changed. > 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..d947e048952d2 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c > @@ -431,6 +431,17 @@ int amdgpu_vram_mgr_query_address_block_info(struct = amdgpu_vram_mgr *mgr, > return ret; > } > =20 > +static void amdgpu_vram_mgr_check_reset(struct amdgpu_device *adev, > + struct amdgpu_vram_mgr *mgr) > +{ > + int reset_counter =3D atomic_read(&adev->gpu_reset_counter); > + > + if (unlikely(mgr->gpu_reset_counter !=3D reset_counter)) { > + gpu_buddy_reset_clear(&mgr->mm, false); > + mgr->gpu_reset_counter =3D reset_counter; > + } > +} [Severity: Medium] Can amdgpu_vram_mgr_check_reset() update mgr->gpu_reset_counter out of order with an in-progress GPU reset and leave unwiped or lost VRAM blocks marked as GPU_BUDDY_HEADER_CLEAR? Neither amdgpu_vram_mgr_new() nor amdgpu_vram_mgr_del() serializes against adev->reset_domain->sem, and adev->gpu_reset_counter is updated at two points that race with BO release and eviction: 1. During full GPU recovery, amdgpu_device_halt_activities() increments adev->gpu_reset_counter before amdgpu_do_asic_reset() resets the hardware and before amdgpu_device_reinit_after_reset() calls amdgpu_inc_vram_lost(): CPU0 CPU1 amdgpu_device_gpu_recover() amdgpu_device_halt_activities() atomic_inc(&gpu_reset_counter) /* counter is now N + 1 */ amdgpu_bo_release_notify() amdgpu_ttm_clear_buffer() amdgpu_job_alloc() /* captures old vram_lost */ amdgpu_vram_mgr_set_cleared() /* records N + 1 */ amdgpu_do_asic_reset() amdgpu_device_reinit_after_reset() amdgpu_inc_vram_lost() amdgpu_device_sched_resume() amdgpu_job_run() /* skips clear job: generation !=3D vm_generation */ ttm_bo_delayed_delete() amdgpu_vram_mgr_del() amdgpu_vram_mgr_check_reset() mgr->gpu_reset_counter =3D N + 1 gpu_buddy_free_list(..., CLEARED) <-- unwiped block marked clear For pipelined eviction via amdgpu_move_blit() -> ttm_bo_move_pipeline_evict(), amdgpu_vram_mgr_del() runs immediately in the window between amdgpu_device_halt_activities() and amdgpu_do_asic_reset(), consuming N + 1 and marking the freed blocks cleared before the hardware reset wipes VRAM or cancels the clear job. 2. During per-queue or IP soft reset in amdgpu_job_timedout(), amdgpu_ring_reset() and amdgpu_device_ip_soft_reset() invoke amdgpu_ring_reset_helper_end() -> amdgpu_ring_set_fence_errors_and_reemit() and drm_sched_wqueue_start() before atomic_inc(&ring->adev->gpu_reset_counter): drivers/gpu/drm/amd/amdgpu/amdgpu_job.c:amdgpu_job_timedout() { ... r =3D amdgpu_ring_reset(ring, job->vmid, job->hw_fence); if (!r) { /* Start the scheduler again */ drm_sched_wqueue_start(&ring->sched); atomic_inc(&ring->adev->gpu_reset_counter); ... } When a clear job's fence is force-completed or re-emitted as NOPs inside amdgpu_ring_set_fence_errors_and_reemit(), ttm_bo_delayed_delete() -> amdgpu_vram_mgr_del() can run on another CPU before gpu_reset_counter is incremented, freeing the unwiped blocks as cleared while adev->gpu_reset_counter still holds the pre-reset value. Subsequent AMDGPU_GEM_CREATE_VRAM_CLEARED allocations will then skip clearing in amdgpu_ttm_clear_buffer() and expose stale VRAM contents. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130121049.2654= 1-1-Arunpravin.PaneerSelvam@amd.com?part=3D2