提交 e36a2e06 编写于 作者: A Alistair Popple 提交者: Zheng Zengkai

nouveau/svm: Fix to migrate all requested pages

stable inclusion
from stable-v5.10.135
commit b38a8802c52d5ed9a0256b6ff95229e9f454e93e
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5ZWFM

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=b38a8802c52d5ed9a0256b6ff95229e9f454e93e

--------------------------------

commit 66cee909 upstream.

Users may request that pages from an OpenCL SVM allocation be migrated
to the GPU with clEnqueueSVMMigrateMem(). In Nouveau this will call into
nouveau_dmem_migrate_vma() to do the migration. If the total range to be
migrated exceeds SG_MAX_SINGLE_ALLOC the pages will be migrated in
chunks of size SG_MAX_SINGLE_ALLOC. However a typo in updating the
starting address means that only the first chunk will get migrated.

Fix the calculation so that the entire range will get migrated if
possible.
Signed-off-by: NAlistair Popple <apopple@nvidia.com>
Fixes: e3d8b089 ("drm/nouveau/svm: map pages after migration")
Reviewed-by: NRalph Campbell <rcampbell@nvidia.com>
Reviewed-by: NLyude Paul <lyude@redhat.com>
Signed-off-by: NLyude Paul <lyude@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220720062745.960701-1-apopple@nvidia.com
Cc: <stable@vger.kernel.org> # v5.8+
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
上级 7514a47a
...@@ -680,7 +680,11 @@ nouveau_dmem_migrate_vma(struct nouveau_drm *drm, ...@@ -680,7 +680,11 @@ nouveau_dmem_migrate_vma(struct nouveau_drm *drm,
goto out_free_dma; goto out_free_dma;
for (i = 0; i < npages; i += max) { for (i = 0; i < npages; i += max) {
args.end = start + (max << PAGE_SHIFT); if (args.start + (max << PAGE_SHIFT) > end)
args.end = end;
else
args.end = args.start + (max << PAGE_SHIFT);
ret = migrate_vma_setup(&args); ret = migrate_vma_setup(&args);
if (ret) if (ret)
goto out_free_pfns; goto out_free_pfns;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册