FAILED: patch "[PATCH] drm/amdkfd: stop restore retries on device unplug" failed to apply to 5.10-stable tree
Subsystems (4)
Sasha Levin
maintainerThe patch below does not apply to the 5.10-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 <[email protected]>.
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.10.y
git checkout FETCH_HEAD
git cherry-pick -x 3254ed0b15f2fe656c9cb36ccb59b92422440bf8
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From 3254ed0b15f2fe656c9cb36ccb59b92422440bf8 Mon Sep 17 00:00:00 2001
From: Olivier Kaloudoff <[email protected]>
Date: Tue, 13 Oct 2026 20:53:12 +0200
Subject: [PATCH] drm/amdkfd: stop restore retries on device unplug
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.
--- .../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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +13 -5
@@ -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 ));
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +5 -3
@@ -1963,7 +1963,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);
@@ -2037,8 +2037,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 ));
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 drm/amdkfd: stop restore retries on device unplug
From: Olivier Kaloudoff <[email protected]>
[ 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.
--- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +12 -5
@@ -1952,6 +1952,7 @@ static void amdgpu_amdkfd_restore_userptr_worker(struct work_struct *work)struct task_struct *usertask;struct mm_struct *mm;int evicted_bos; +int ret; evicted_bos =atomic_read (&process_info->evicted_bos);if (!evicted_bos)
@@ -1969,7 +1970,8 @@ 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
@@ -1979,7 +1981,8 @@ static void amdgpu_amdkfd_restore_userptr_worker(struct work_struct *work)if (atomic_read (&process_info->evicted_bos) != evicted_bos) goto unlock_out;/* Concurrent eviction, try again */ -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
@@ -1988,8 +1991,10 @@ static void amdgpu_amdkfd_restore_userptr_worker(struct work_struct *work)* reference counting inside KFD will handle this case. */ if (atomic_cmpxchg (&process_info->evicted_bos, evicted_bos,0 ) != - evicted_bos) + evicted_bos) { + ret = -EAGAIN ; goto unlock_out; + } evicted_bos =0 ;if (kgd2kfd_resume_mm (mm)) {pr_err ("%s: Failed to resume KFD\n" , __func__);
@@ -2003,8 +2008,10 @@ static void amdgpu_amdkfd_restore_userptr_worker(struct work_struct *work)mmput (mm);put_task_struct (usertask); -/* 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 )); }
Signature · 1 line
2.53.0