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=1794065485; b=O+kSph4F0jHNINL5b5/5HOZCtndEfigpooqOYYn930sncNkKIWMzwzL0gOwGUYZbyJcZ x9nWuDbz/JLehzjpLurbY6EDASbArceBu5PKTpNOmJ/jTLBRvTeqz8FK+UiULwc506i4z xXPk9g5KZGJZYMgE/B2TBMF3DP7Plz2cRzHv0ZgpQuUwsktLtwQPwBBGMhqs6/nvwEAlR ab221p6Zi4WFMDoRXDFIyStxkWyu6PZrZA+3hxFv2lrTROgtFJ55OWrZdDrHSqx87hQdZ wm4R6oSVFrji0iq8F+ZYR63yXP1Ud2iiLnwLUZdSyOWlMHEQ3JK+dUxWrEOrDKG0G9w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794065485; 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=E17N6AA/rK3jzJhGGfifoYNAYDCsdFKAsVYh3G6afg4=; b=rFqE3RJ0ovrTpQE6FZoMO56i5dgqlsUDI+XZH+OKPs7/sM4m6wZNjF42XUVYmtFyq+Xx dvXO12HJb49+Hw3p5XbS3e2PbZrIFZbSMC4I61bH88deSKeV1x5aHSLkc08pZfg5p/g6R h6TQhBX41rtU1wLevVRjdKqbLZy3EZzQBC8XBW1iDITnuLN3o2KynkJcUKnFh/doMDrE5 jGDBnBwrdGpaZ6UynDrmpClU7PWvv5RJCxkvr3s/N+8wlAdOXqxnh40F3IIX8ROrsbP1d I7rnKOmQ5w+7+ZqVS1PX0Ry9DkNuGokuRFeZ9MqeTQ0QbmViuCCmXsqVemj92+jhaOA== 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=ST1J6pM3; 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 118ED606A337; Sat, 7 Nov 2026 15:31:25 +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=ST1J6pM3 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B40101F0089F; Sat, 7 Nov 2026 15:31:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1794065484; bh=E17N6AA/rK3jzJhGGfifoYNAYDCsdFKAsVYh3G6afg4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ST1J6pM3GLsTmaJsH5z5KyJYDNoCLi1QFhlK1vMGxcYrBJCwJxrhBNARkvLhqu4Ci wLSLgfG0DBhVofE/ougxC7gl84M+MaoQhtGhx1zvENfmxxXl9OLpEErRMaUaUMV8Q7 8T3Q2zM47NBxF/Ud32tHbUjWha/UaPBmEKtyn2sY= 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 7.3 1178/1257] drm/amdkfd: stop restore retries on device unplug Date: Sat, 7 Nov 2026 08:57:54 -0500 Message-ID: <20261107135011.709871354@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261107134939.434104957@linuxfoundation.org> References: <20261107134939.434104957@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 7.3-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 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 46632a021ce85..c5c2a73ddd94b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c @@ -2854,6 +2854,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; @@ -2873,14 +2874,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 @@ -2889,11 +2892,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; } @@ -2911,8 +2917,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) { queue_delayed_work(system_freezable_wq, &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 d7f2ff5c8f024..54bdae99d4971 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c @@ -1942,7 +1942,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); @@ -2016,8 +2016,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"); queue_delayed_work(system_freezable_wq, &svms->restore_work, msecs_to_jiffies(AMDGPU_SVM_RANGE_RESTORE_DELAY_MS)); -- 2.53.0