Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794049976; b=ekkJrSg9VXH4QPjyWe2alp1vjKvTOylPxQh3kjiAcZKOCY/a/z+oI8zqOpla3aPNhxLG 2HHFMtVMGiBcR8am6gS1w5IyyIiXz/zRVQuo+us7Im6vhaxh/RWKPVDJRKW1Oe7QRIHTt 5zj0Gg3NH7PW1vMZBbB8wRPBa4/C/jqmCczaMoL4RJzYMLAoGn7EEaFDHiepexkAVEO16 TFsMfyakUQpY/PcQyhG5QoxAHmLmwkOfm/2WHY5P+VcOFuRlxmnAUFd93inRSbyU982DU W5HOqC+h+JbXROzhjm4c0WaWCgP9vm2ClS8xdx4iSBLyby1OOg5FIDGAq18qVdr8tuQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794049976; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=Ast9OzzURhqiaabuqvIAzKXQp4b1vCb4H8CqkZeM/W8=; b=gB23dalJGX2TJKid3zM130wQ1Xj8/U7gQtFtCLDRFurXgWTVMtMbepHSylprjD2NT/yO elN0FyjsYsSf01pODlebJkYnhOLkJ/oa65tcnxSo3Ne3yCLRQpEKL9YsmeT7wpWkVbOw+ mi/BlXT6Y9mGIbmktXQkASWfEcPTWU8UNPLiBc9BIS2uqe4rTHo7WIG5CvmA7+twmbGEC L5ogdOg3+Ct0khOvnltqct0NV7ffYjil9IOwXZ7O3BPa3NGerHM55Qs6eFaSBxQ8boHi7 ZaLMSXgeEquPbUzL3wRC48qQ8uLXIcL1EIlJWi5gZNBRbBnppZfwy8T9GnWcccxHuGA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=EZlMWuYE; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B66E606A326 for ; Sat, 7 Nov 2026 11:12: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=EZlMWuYE Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62E7E1F0089F; Sat, 7 Nov 2026 11:12:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794049976; bh=Ast9OzzURhqiaabuqvIAzKXQp4b1vCb4H8CqkZeM/W8=; h=From:To:Cc:Subject:Date; b=EZlMWuYEthzaST7kLnZf+7fAZqK6BDF1S3Ls+LdAJJMYZulAx8W5/j1jo0HWqJhjB WJ502mAz9sJ5O5x+VJ5wznKp4Bm+b5UxS4+kbsBb7o5N5udUgNE3AcKpTHJKzzNwvA PUos5hFGf7XZNbkvPgsUYp9gDA6dIfdylJ8tp1eFhaPSJ87v39kHb/O1a0kYBfd3PS q5sttTMyKpbxiZyTHIGsiVG/3F1/YSP2OsUZdD1D7NKLuDXaCuZG/ERZrKafbEZW2u Irwlt4aqfbOkYHZhpY0kxfus8Hf/SLU+EkBpFGg4vSjbvoA2I2LHM7LaYQ71GEGOKy J0GH0cLQ2Z49Q== From: Sasha Levin To: olivier.kaloudoff@gmail.com, xiaogang.chen@amd.com, felix.kuehling@amd.com, alexander.deucher@amd.com Cc: stable@vger.kernel.org Subject: FAILED: patch "[PATCH] drm/amdkfd: tear down KFD processes before early fini_sw on disconnect" failed to apply to 5.15-stable tree Date: Sat, 7 Nov 2026 06:12:54 -0500 Message-ID: <20261107061254-failed-5.15-1233dd17f99c@kernel.org> X-Mailer: git-send-email 2.53.0 X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.15-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.15.y git checkout FETCH_HEAD git cherry-pick -x 1233dd17f99c75787a31035656ecfeff80522421 # git commit -s git send-email --to '' --in-reply-to '20261107061254-failed-5.15-1233dd17f99c@kernel.org' --subject-prefix 'PATCH 5.15.y' 'HEAD^..' Thanks, Sasha ------------------ original commit in Linus's tree ------------------ From 1233dd17f99c75787a31035656ecfeff80522421 Mon Sep 17 00:00:00 2001 From: Olivier Kaloudoff Date: Tue, 13 Oct 2026 20:53:11 +0200 Subject: [PATCH] drm/amdkfd: tear down KFD processes before early fini_sw on disconnect On surprise removal, amdgpu_device_fini_hw() calls amdgpu_amdkfd_device_fini_sw() when pci_dev_is_disconnected() is true. fini_sw frees kfd.dev, but KFD processes may still be alive and hold references to it: kfd_process_destroy() dereferences kfd.dev via kfd_processes_remove(), and svm_range_list_fini() / kfd_process_free_outstanding_kfd_bos() touch per-device SVM state. The kfd_processes_count wait only happens later in kgd2kfd_teardown_processes(), called from the top-half remove path well after fini_sw. In the observed failure the killed KFD process (SIGBUS on unplug) stuck in D state on its exit path, so kfd_processes_count never drained and the PCIe removal thread wedged permanently in cond_resched(), producing soft-lockup and hung-task splats. Tear KFD processes down before freeing kfd.dev on the disconnect path, and guard kgd2kfd_teardown_processes() against kfd.dev already being gone when it runs a second time. Cc: Xiaogang Chen Signed-off-by: Olivier Kaloudoff Signed-off-by: Felix Kuehling Reviewed-by: Felix Kuehling Signed-off-by: Alex Deucher (cherry picked from commit 836f44ba87ed7b1d83e2b7bfc788f8c6437b03a7) Cc: stable@vger.kernel.org --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 5 ++++- drivers/gpu/drm/amd/amdkfd/kfd_device.c | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index f147c0c459da5..c65bc575a57a8 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -4331,8 +4331,11 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev) * before ip_fini_early to prevent kfd locking refcount issues by calling * amdgpu_amdkfd_suspend() */ - if (pci_dev_is_disconnected(adev->pdev)) + if (pci_dev_is_disconnected(adev->pdev)) { + /* Drain KFD processes while kfd.dev is still valid */ + amdgpu_amdkfd_teardown_processes(adev); amdgpu_amdkfd_device_fini_sw(adev); + } amdgpu_coredump_fini(adev); amdgpu_device_ip_fini_early(adev); diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c b/drivers/gpu/drm/amd/amdkfd/kfd_device.c index bb4c6695f3cf9..0f96c9e3fa4d9 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c @@ -1814,7 +1814,14 @@ void kgd2kfd_teardown_processes(struct amdgpu_device *adev) mutex_unlock(&kfd_processes_mutex); - /* wait all kfd processes use adev terminate */ + /* kfd.dev may already be freed on surprise removal */ + if (!adev->kfd.dev) + return; + + /* + * Wait for all KFD processes using adev to terminate. Must be + * unbounded: device state is freed once they are gone. + */ while (!!atomic_read(&adev->kfd.dev->kfd_processes_count)) cond_resched(); } -- 2.53.0