Skip to content

Commit 0092965

Browse files
Ralph Campbellgregkh
authored andcommitted
drm/nouveau/nouveau: fix the start/end range for migration
[ Upstream commit cfa736f ] The user level OpenCL code shouldn't have to align start and end addresses to a page boundary. That is better handled in the nouveau driver. The npages field is also redundant since it can be computed from the start and end addresses. Signed-off-by: Ralph Campbell <rcampbell@nvidia.com> Signed-off-by: Ben Skeggs <bskeggs@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 5f23480 commit 0092965

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

‎drivers/gpu/drm/nouveau/nouveau_svm.c‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
105105
struct nouveau_cli *cli = nouveau_cli(file_priv);
106106
struct drm_nouveau_svm_bind *args = data;
107107
unsigned target, cmd, priority;
108-
unsigned long addr, end, size;
108+
unsigned long addr, end;
109109
struct mm_struct *mm;
110110

111111
args->va_start &= PAGE_MASK;
112-
args->va_end &= PAGE_MASK;
112+
args->va_end = ALIGN(args->va_end, PAGE_SIZE);
113113

114114
/* Sanity check arguments */
115115
if (args->reserved0 || args->reserved1)
@@ -118,8 +118,6 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
118118
return -EINVAL;
119119
if (args->va_start >= args->va_end)
120120
return -EINVAL;
121-
if (!args->npages)
122-
return -EINVAL;
123121

124122
cmd = args->header >> NOUVEAU_SVM_BIND_COMMAND_SHIFT;
125123
cmd &= NOUVEAU_SVM_BIND_COMMAND_MASK;
@@ -151,12 +149,6 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
151149
if (args->stride)
152150
return -EINVAL;
153151

154-
size = ((unsigned long)args->npages) << PAGE_SHIFT;
155-
if ((args->va_start + size) <= args->va_start)
156-
return -EINVAL;
157-
if ((args->va_start + size) > args->va_end)
158-
return -EINVAL;
159-
160152
/*
161153
* Ok we are ask to do something sane, for now we only support migrate
162154
* commands but we will add things like memory policy (what to do on
@@ -171,7 +163,7 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
171163
return -EINVAL;
172164
}
173165

174-
for (addr = args->va_start, end = args->va_start + size; addr < end;) {
166+
for (addr = args->va_start, end = args->va_end; addr < end;) {
175167
struct vm_area_struct *vma;
176168
unsigned long next;
177169

0 commit comments

Comments
 (0)