Skip to content

Commit fd5e985

Browse files
author
Ben Skeggs
committed
drm/nouveau/dmem: use physical vram addresses during migration copies
Removes the need for temporary VMM mappings. Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
1 parent 6c762d1 commit fd5e985

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

drivers/gpu/drm/nouveau/nouveau_dmem.c

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ struct nouveau_dmem_chunk {
6363
unsigned long pfn_first;
6464
unsigned long callocated;
6565
unsigned long bitmap[BITS_TO_LONGS(DMEM_CHUNK_NPAGES)];
66-
struct nvif_vma vma;
6766
spinlock_t lock;
6867
};
6968

@@ -272,10 +271,10 @@ nouveau_dmem_fault_alloc_and_copy(struct vm_area_struct *vma,
272271

273272
chunk = (void *)hmm_devmem_page_get_drvdata(spage);
274273
src_addr = page_to_pfn(spage) - chunk->pfn_first;
275-
src_addr = (src_addr << PAGE_SHIFT) + chunk->vma.addr;
274+
src_addr = (src_addr << PAGE_SHIFT) + chunk->bo->bo.offset;
276275

277276
ret = copy(drm, 1, NOUVEAU_APER_VIRT, dst_addr,
278-
NOUVEAU_APER_VIRT, src_addr);
277+
NOUVEAU_APER_VRAM, src_addr);
279278
if (ret) {
280279
dst_pfns[i] = MIGRATE_PFN_ERROR;
281280
__free_page(dpage);
@@ -371,7 +370,6 @@ nouveau_dmem_devmem_ops = {
371370
static int
372371
nouveau_dmem_chunk_alloc(struct nouveau_drm *drm)
373372
{
374-
struct nvif_vmm *vmm = &drm->client.vmm.vmm;
375373
struct nouveau_dmem_chunk *chunk;
376374
int ret;
377375

@@ -390,11 +388,6 @@ nouveau_dmem_chunk_alloc(struct nouveau_drm *drm)
390388
list_del(&chunk->list);
391389
mutex_unlock(&drm->dmem->mutex);
392390

393-
ret = nvif_vmm_get(vmm, LAZY, false, 12, 0,
394-
DMEM_CHUNK_SIZE, &chunk->vma);
395-
if (ret)
396-
goto out;
397-
398391
ret = nouveau_bo_new(&drm->client, DMEM_CHUNK_SIZE, 0,
399392
TTM_PL_FLAG_VRAM, 0, 0, NULL, NULL,
400393
&chunk->bo);
@@ -407,13 +400,6 @@ nouveau_dmem_chunk_alloc(struct nouveau_drm *drm)
407400
goto out;
408401
}
409402

410-
ret = nouveau_mem_map(nouveau_mem(&chunk->bo->bo.mem), vmm, &chunk->vma);
411-
if (ret) {
412-
nouveau_bo_unpin(chunk->bo);
413-
nouveau_bo_ref(NULL, &chunk->bo);
414-
goto out;
415-
}
416-
417403
bitmap_zero(chunk->bitmap, DMEM_CHUNK_NPAGES);
418404
spin_lock_init(&chunk->lock);
419405

@@ -570,7 +556,6 @@ nouveau_dmem_suspend(struct nouveau_drm *drm)
570556
void
571557
nouveau_dmem_fini(struct nouveau_drm *drm)
572558
{
573-
struct nvif_vmm *vmm = &drm->client.vmm.vmm;
574559
struct nouveau_dmem_chunk *chunk, *tmp;
575560

576561
if (drm->dmem == NULL)
@@ -586,7 +571,6 @@ nouveau_dmem_fini(struct nouveau_drm *drm)
586571
nouveau_bo_unpin(chunk->bo);
587572
nouveau_bo_ref(NULL, &chunk->bo);
588573
}
589-
nvif_vmm_put(vmm, &chunk->vma);
590574
list_del(&chunk->list);
591575
kfree(chunk);
592576
}
@@ -792,7 +776,7 @@ nouveau_dmem_migrate_alloc_and_copy(struct vm_area_struct *vma,
792776

793777
chunk = (void *)hmm_devmem_page_get_drvdata(dpage);
794778
dst_addr = page_to_pfn(dpage) - chunk->pfn_first;
795-
dst_addr = (dst_addr << PAGE_SHIFT) + chunk->vma.addr;
779+
dst_addr = (dst_addr << PAGE_SHIFT) + chunk->bo->bo.offset;
796780

797781
spage = migrate_pfn_to_page(src_pfns[i]);
798782
if (!spage || !(src_pfns[i] & MIGRATE_PFN_MIGRATE)) {
@@ -804,7 +788,7 @@ nouveau_dmem_migrate_alloc_and_copy(struct vm_area_struct *vma,
804788
src_addr = migrate->hmem.vma.addr + (c << PAGE_SHIFT);
805789
c++;
806790

807-
ret = copy(drm, 1, NOUVEAU_APER_VIRT, dst_addr,
791+
ret = copy(drm, 1, NOUVEAU_APER_VRAM, dst_addr,
808792
NOUVEAU_APER_VIRT, src_addr);
809793
if (ret) {
810794
nouveau_dmem_page_free_locked(drm, dpage);

0 commit comments

Comments
 (0)