[PATCH 2/4] fixup! drm/nouveau: use hmm_range_fault_unlocked_timeout() for SVM faults
From: Stanislav Kinsburskii
Date: Tue Jul 14 2026 - 16:15:10 EST
nouveau_range_fault() now uses hmm_range_fault_unlocked_timeout() for
the HMM fault path. The timeout passed to that helper is meant to bound
HMM's internal mmu-notifier retry loop, not the whole nouveau retry loop
around mmu_interval_read_retry().
Pass the full relative HMM_RANGE_DEFAULT_TIMEOUT value to
hmm_range_fault_unlocked_timeout() on each attempt, and retry from the
nouveau-side mmu_interval_read_retry() check with a fresh HMM retry
budget. This lets HMM continue when it has made progress, while still
preserving a timeout for repeated notifier invalidation retries inside
one HMM fault attempt.
This also removes the open-coded absolute deadline and remaining-time
calculation from nouveau_range_fault().
Signed-off-by: Stanislav Kinsburskii <skinsburskii@xxxxxxxxx>
---
drivers/gpu/drm/nouveau/nouveau_svm.c | 30 ++++++++++--------------------
1 file changed, 10 insertions(+), 20 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c
index 4cfb6eb7c771..b1415c2e49fc 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -655,8 +655,7 @@ static int nouveau_range_fault(struct nouveau_svmm *svmm,
unsigned long hmm_flags,
struct svm_notifier *notifier)
{
- unsigned long timeout =
- jiffies + msecs_to_jiffies(HMM_RANGE_DEFAULT_TIMEOUT);
+ unsigned long timeout = msecs_to_jiffies(HMM_RANGE_DEFAULT_TIMEOUT);
/* Have HMM fault pages within the fault window to the GPU. */
unsigned long hmm_pfns[1];
struct hmm_range range = {
@@ -677,25 +676,16 @@ static int nouveau_range_fault(struct nouveau_svmm *svmm,
range.start = notifier->notifier.interval_tree.start;
range.end = notifier->notifier.interval_tree.last + 1;
- while (true) {
- if (time_after(jiffies, timeout)) {
- ret = -EBUSY;
- goto out;
- }
-
- ret = hmm_range_fault_unlocked_timeout(&range,
- max(timeout - jiffies,
- 1L));
- if (ret)
- goto out;
+again:
+ ret = hmm_range_fault_unlocked_timeout(&range, timeout);
+ if (ret)
+ goto out;
- mutex_lock(&svmm->mutex);
- if (mmu_interval_read_retry(range.notifier,
- range.notifier_seq)) {
- mutex_unlock(&svmm->mutex);
- continue;
- }
- break;
+ mutex_lock(&svmm->mutex);
+ if (mmu_interval_read_retry(range.notifier,
+ range.notifier_seq)) {
+ mutex_unlock(&svmm->mutex);
+ goto again;
}
nouveau_hmm_convert_pfn(drm, &range, args);