Skip to content

Commit b3fefbb

Browse files
davidhildenbrandDanilo Krummrich
authored andcommitted
nouveau/svm: fix missing folio unlock + put after make_device_exclusive_range()
In case we have to retry the loop, we are missing to unlock+put the folio. In that case, we will keep failing make_device_exclusive_range() because we cannot grab the folio lock, and even return from the function with the folio locked and referenced, effectively never succeeding the make_device_exclusive_range(). While at it, convert the other unlock+put to use a folio as well. This was found by code inspection. Fixes: 8f18716 ("nouveau/svm: implement atomic SVM access") Signed-off-by: David Hildenbrand <david@redhat.com> Reviewed-by: Alistair Popple <apopple@nvidia.com> Tested-by: Alistair Popple <apopple@nvidia.com> Signed-off-by: Danilo Krummrich <dakr@kernel.org> Link: https://patchwork.freedesktop.org/patch/msgid/20250124181524.3584236-2-david@redhat.com
1 parent a8972d5 commit b3fefbb

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/gpu/drm/nouveau/nouveau_svm.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ static int nouveau_atomic_range_fault(struct nouveau_svmm *svmm,
590590
unsigned long timeout =
591591
jiffies + msecs_to_jiffies(HMM_RANGE_DEFAULT_TIMEOUT);
592592
struct mm_struct *mm = svmm->notifier.mm;
593+
struct folio *folio;
593594
struct page *page;
594595
unsigned long start = args->p.addr;
595596
unsigned long notifier_seq;
@@ -616,12 +617,16 @@ static int nouveau_atomic_range_fault(struct nouveau_svmm *svmm,
616617
ret = -EINVAL;
617618
goto out;
618619
}
620+
folio = page_folio(page);
619621

620622
mutex_lock(&svmm->mutex);
621623
if (!mmu_interval_read_retry(&notifier->notifier,
622624
notifier_seq))
623625
break;
624626
mutex_unlock(&svmm->mutex);
627+
628+
folio_unlock(folio);
629+
folio_put(folio);
625630
}
626631

627632
/* Map the page on the GPU. */
@@ -637,8 +642,8 @@ static int nouveau_atomic_range_fault(struct nouveau_svmm *svmm,
637642
ret = nvif_object_ioctl(&svmm->vmm->vmm.object, args, size, NULL);
638643
mutex_unlock(&svmm->mutex);
639644

640-
unlock_page(page);
641-
put_page(page);
645+
folio_unlock(folio);
646+
folio_put(folio);
642647

643648
out:
644649
mmu_interval_notifier_remove(&notifier->notifier);

0 commit comments

Comments
 (0)