Commit f81c69a2 authored by Alistair Popple's avatar Alistair Popple Committed by Linus Torvalds

nouveau/svm: refactor nouveau_range_fault

Call mmu_interval_notifier_insert() as part of nouveau_range_fault().
This doesn't introduce any functional change but makes it easier for a
subsequent patch to alter the behaviour of nouveau_range_fault() to
support GPU atomic operations.

Link: https://lkml.kernel.org/r/20210616105937.23201-10-apopple@nvidia.comSigned-off-by: default avatarAlistair Popple <apopple@nvidia.com>
Reviewed-by: default avatarBen Skeggs <bskeggs@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hugh Dickins <hughd@google.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: Peter Xu <peterx@redhat.com>
Cc: Ralph Campbell <rcampbell@nvidia.com>
Cc: Shakeel Butt <shakeelb@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b659baea
...@@ -567,18 +567,27 @@ static int nouveau_range_fault(struct nouveau_svmm *svmm, ...@@ -567,18 +567,27 @@ static int nouveau_range_fault(struct nouveau_svmm *svmm,
unsigned long hmm_pfns[1]; unsigned long hmm_pfns[1];
struct hmm_range range = { struct hmm_range range = {
.notifier = &notifier->notifier, .notifier = &notifier->notifier,
.start = notifier->notifier.interval_tree.start,
.end = notifier->notifier.interval_tree.last + 1,
.default_flags = hmm_flags, .default_flags = hmm_flags,
.hmm_pfns = hmm_pfns, .hmm_pfns = hmm_pfns,
.dev_private_owner = drm->dev, .dev_private_owner = drm->dev,
}; };
struct mm_struct *mm = notifier->notifier.mm; struct mm_struct *mm = svmm->notifier.mm;
int ret; int ret;
ret = mmu_interval_notifier_insert(&notifier->notifier, mm,
args->p.addr, args->p.size,
&nouveau_svm_mni_ops);
if (ret)
return ret;
range.start = notifier->notifier.interval_tree.start;
range.end = notifier->notifier.interval_tree.last + 1;
while (true) { while (true) {
if (time_after(jiffies, timeout)) if (time_after(jiffies, timeout)) {
return -EBUSY; ret = -EBUSY;
goto out;
}
range.notifier_seq = mmu_interval_read_begin(range.notifier); range.notifier_seq = mmu_interval_read_begin(range.notifier);
mmap_read_lock(mm); mmap_read_lock(mm);
...@@ -587,7 +596,7 @@ static int nouveau_range_fault(struct nouveau_svmm *svmm, ...@@ -587,7 +596,7 @@ static int nouveau_range_fault(struct nouveau_svmm *svmm,
if (ret) { if (ret) {
if (ret == -EBUSY) if (ret == -EBUSY)
continue; continue;
return ret; goto out;
} }
mutex_lock(&svmm->mutex); mutex_lock(&svmm->mutex);
...@@ -606,6 +615,9 @@ static int nouveau_range_fault(struct nouveau_svmm *svmm, ...@@ -606,6 +615,9 @@ static int nouveau_range_fault(struct nouveau_svmm *svmm,
svmm->vmm->vmm.object.client->super = false; svmm->vmm->vmm.object.client->super = false;
mutex_unlock(&svmm->mutex); mutex_unlock(&svmm->mutex);
out:
mmu_interval_notifier_remove(&notifier->notifier);
return ret; return ret;
} }
...@@ -727,14 +739,8 @@ nouveau_svm_fault(struct nvif_notify *notify) ...@@ -727,14 +739,8 @@ nouveau_svm_fault(struct nvif_notify *notify)
} }
notifier.svmm = svmm; notifier.svmm = svmm;
ret = mmu_interval_notifier_insert(&notifier.notifier, mm,
args.i.p.addr, args.i.p.size,
&nouveau_svm_mni_ops);
if (!ret) {
ret = nouveau_range_fault(svmm, svm->drm, &args.i, ret = nouveau_range_fault(svmm, svm->drm, &args.i,
sizeof(args), hmm_flags, &notifier); sizeof(args), hmm_flags, &notifier);
mmu_interval_notifier_remove(&notifier.notifier);
}
mmput(mm); mmput(mm);
limit = args.i.p.addr + args.i.p.size; limit = args.i.p.addr + args.i.p.size;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment