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=1795038716; b=Q9HKCsodWfJKxap78sPNypGtqsMlEwFAfOMitxgJ4FH0Xl+HiA6wT2UhARIP3AQ4GN8I bKtQBUzz/QgUyqw0tifBgT2quaA2Wix1D5RfgVUpYVrZwIdtxsiKI0ASjXtbMNFRznOS1 aHZlPXcngHZyXen3M6nTWp7Hsf0gWwi4ErHUuXRKVo4IGpUiqflZiUDKq6PueD80KLQRQ K24h11/SBKBEb8LVTOxRLB8ofwanAieqVE5yLGhntpzVI2nxruq/A7yWMvVTc9VQ8klGD SjwCR+OblOyV7UVjvL7IQfBgyoWXtD9ig6OmpQJ+kNXxfuoPFQMa+2uGJjC6G96idOQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795038716; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=vJFbb0l7zAGGwO/6lSBUxpE9Y9vE++t59f0CUruUXtw=; b=y4X/jPJpkgCfvzaVMjnyObJlEuDGdV8/IxjxiL1qIxHoGu8tlS4hLX+5E/IGIWSHABna qYJMzA5zUEh232nadJ+0vahnKLRhcZoNBDuqdz+PrcRTFlZYY8JRL7bfXV7xhjhFSmOCG fWZTPoU4lLeGJJnuVXerf0x/3gPwL5lMrnx6FAT7TactYkjTAfQ/qzrG6S0SHWT674Qe0 DxhZw+HkZaXU6Wjr0Dxn3suNyb8VEAzmcZeWWUlMEFccTV18oOhoX+SaK+m+6WKZaxgTP FWVx9ANdUAGtmuueyLOmFcOL012MHZrLXKet5EuUsRFC+ryxZ/ZNp0FbtjoHA1aETVw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=HBg1bEr7; 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 72DC0606A325; Wed, 18 Nov 2026 21:51:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=HBg1bEr7 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CCAB1F000C4; Wed, 18 Nov 2026 21:51:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795038716; bh=vJFbb0l7zAGGwO/6lSBUxpE9Y9vE++t59f0CUruUXtw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HBg1bEr7/vvoskBXhtKpi7v/cM4nP4+P6brUFQvQ0LWz9UHe49uWPISXFJOwJhd+R ImLyOnavFFr0tJjXU46rWu/HUCgYFdnEfmUbvKmtcOMTHMcTnzDz6XTZpV/5pGZ3nu bN/8ijtIQK4K6l/BZWRkbYjzWyfcb4Jp6j21W2mI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Xiaogang Chen , Olivier Kaloudoff , Felix Kuehling , Alex Deucher , Sasha Levin Subject: [PATCH 6.6 1843/3318] drm/amdkfd: stop restore retries on device unplug Date: Wed, 18 Nov 2026 15:41:05 +0100 Message-ID: <20261118150417.146790791@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150313.527275416@linuxfoundation.org> References: <20261118150313.527275416@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Olivier Kaloudoff [ Upstream commit 3254ed0b15f2fe656c9cb36ccb59b92422440bf8 ] amdgpu_amdkfd_restore_userptr_worker() and svm_range_restore_work() reschedule themselves when validation fails with evicted objects pending. After a surprise removal the restore paths fail with -ENODEV permanently, so rescheduling just spins the worker uselessly until cancel_delayed_work_sync() in fini finally stops it - which can take a while, since process teardown itself is delayed by the dead device. Treat -ENODEV as terminal in both workers. 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 266fab83139600e58db7e900e930c722e619b78c) Cc: stable@vger.kernel.org [ sashal: adjusted context for schedule_delayed_work() ] Signed-off-by: Sasha Levin --- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 18 +++++++++++++----- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 8 +++++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c index 8237772ca9426..05426ac8d9e14 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c @@ -2700,6 +2700,7 @@ static void amdgpu_amdkfd_restore_userptr_worker(struct work_struct *work) struct task_struct *usertask; struct mm_struct *mm; uint32_t evicted_bos; + int ret; mutex_lock(&process_info->notifier_lock); evicted_bos = process_info->evicted_bos; @@ -2719,14 +2720,16 @@ static void amdgpu_amdkfd_restore_userptr_worker(struct work_struct *work) mutex_lock(&process_info->lock); - if (update_invalid_user_pages(process_info, mm)) + ret = update_invalid_user_pages(process_info, mm); + if (ret) goto unlock_out; /* userptr_inval_list can be empty if all evicted userptr BOs * have been freed. In that case there is nothing to validate * and we can just restart the queues. */ if (!list_empty(&process_info->userptr_inval_list)) { - if (validate_invalid_user_pages(process_info)) + ret = validate_invalid_user_pages(process_info); + if (ret) goto unlock_out; } /* Final check for concurrent evicton and atomic update. If @@ -2735,11 +2738,14 @@ static void amdgpu_amdkfd_restore_userptr_worker(struct work_struct *work) * reference counting inside KFD will handle this case. */ mutex_lock(&process_info->notifier_lock); - if (process_info->evicted_bos != evicted_bos) + if (process_info->evicted_bos != evicted_bos) { + ret = -EAGAIN; goto unlock_notifier_out; + } if (confirm_valid_user_pages_locked(process_info)) { WARN(1, "User pages unexpectedly invalid"); + ret = -EINVAL; goto unlock_notifier_out; } @@ -2757,8 +2763,10 @@ static void amdgpu_amdkfd_restore_userptr_worker(struct work_struct *work) unlock_out: mutex_unlock(&process_info->lock); - /* If validation failed, reschedule another attempt */ - if (evicted_bos) { + /* If validation failed, reschedule another attempt, unless the + * device is gone for good + */ + if (evicted_bos && ret != -ENODEV) { schedule_delayed_work(&process_info->restore_userptr_work, msecs_to_jiffies(AMDGPU_USERPTR_RESTORE_DELAY_MS)); diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c index 006ba258e683f..9e073c74d0d15 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c @@ -1821,7 +1821,7 @@ static void svm_range_restore_work(struct work_struct *work) struct mm_struct *mm; int evicted_ranges; int invalid; - int r; + int r = 0; svms = container_of(dwork, struct svm_range_list, restore_work); evicted_ranges = atomic_read(&svms->evicted_ranges); @@ -1895,8 +1895,10 @@ static void svm_range_restore_work(struct work_struct *work) mmap_write_unlock(mm); mutex_unlock(&process_info->lock); - /* If validation failed, reschedule another attempt */ - if (evicted_ranges) { + /* If validation failed, reschedule another attempt, unless the + * device is gone for good + */ + if (evicted_ranges && r != -ENODEV) { pr_debug("reschedule to restore svm range\n"); schedule_delayed_work(&svms->restore_work, msecs_to_jiffies(AMDGPU_SVM_RANGE_RESTORE_DELAY_MS)); -- 2.53.0