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=1795047314; b=Y6w/XL9ruSCAiFGindVds1Gwb6VrmOfzewjsq12TZmK1e+m+9Itm0OGsaVeQ3iGPuQVf OqUVhxscxXrTv1NCTuWaqFwZFxFs1k5R0syTjQ0eI8CEapcCV+JTPVPv3/ct0pumW3Z4m WjjHEIxnelzJZ0o9vtYK0zYDD/Zaf8fm73jlyJyLh+yMkMTlO/f8OKEIhVjeEY/eVtc9A YQrx3epsRqeOuKcOFBrxQxF13zsw42/ZByO6lRF3B0LUdBlpjMMWpprzmadFkN5WrQrYu wzxZfG3nOKV555LPuh1SdXDrXATJnrwnHsy8rkLGz5LEnGl/Ak74SjDifu4WWfD1lLg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795047314; 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=Jzk3j7gtmNv0F4wX388y8Dy5FxADMmS508W55IsrIbU=; b=mPByczwQFsSkVdw6ZZ7ns5PwSzht1oqLULe/+W4rboOFL85UzDVnsPM4Vtj4L8gLD48j uVhXX92rPz5/wuJdqywJEI5BkIzH3BBCkq1xJsfViSHfKE2nYpV4PP8317Euco4gWZVTh rRzfA7/s5hWuTeRvL+bORz0Pbx0YOPSTzneOE3Hs3xCehRFOCFSgxdPMoslkADIIlQK+d MI55C+T0xFnz5K0ZMjFuTw8PZhNWsr5NCNZ7HDb94uSpE4ynADSxDADRNd9ogIkyerBgq JbuoFznR/vXpuyAG9lxe+cmV9ePxIFfEmM/Wfo7fRmnGgU9fG1s7hXg+ud+cNQ0rk5A== 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=1BXCgcEf; 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 4B78B606A32A; Thu, 19 Nov 2026 00:15:14 +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=1BXCgcEf Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6835B1F000C5; Thu, 19 Nov 2026 00:15:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795047313; bh=Jzk3j7gtmNv0F4wX388y8Dy5FxADMmS508W55IsrIbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1BXCgcEfMHVu50mcfYOqEu9tcIAqbtoVf+91K3qAS8pjY+hx+dO/gW1zj8Hu5F4lf Y2h5iP/L1EB4XICf8mW98JH9jMJlCAogLP8Uwg53QStwN6tdmcdcRBueVqHg5oacQV z4P8AvK0/x//qvBXordbpfDK2muJc9MP25feY+xc= 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.1 1592/2857] drm/amdkfd: stop restore retries on device unplug Date: Wed, 18 Nov 2026 15:43:46 +0100 Message-ID: <20261118150258.691866344@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150201.293410965@linuxfoundation.org> References: <20261118150201.293410965@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.1-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: Adapted retry handling to existing atomic eviction counters instead of notifier locking. ] Signed-off-by: Sasha Levin --- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 17 ++++++++++++----- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 8 +++++--- 2 files changed, 17 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 dd18be88e1b84..eb4d652afbb60 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c @@ -2620,6 +2620,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) @@ -2637,7 +2638,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 @@ -2647,7 +2649,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 @@ -2656,8 +2659,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__); @@ -2669,8 +2674,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 e60ab76d3e6f6..13ae155bd5325 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c @@ -1692,7 +1692,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); @@ -1766,8 +1766,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