Skip to content

Commit 66c3bdd

Browse files
author
Ben Skeggs
committed
drm/nouveau/svm: use NVIDIA's headers for migrate_copy()
Signed-off-by: Ben Skeggs <[email protected]> Reviewed-by: Lyude Paul <[email protected]>
1 parent 6c75137 commit 66c3bdd

File tree

1 file changed

+39
-20
lines changed

1 file changed

+39
-20
lines changed

drivers/gpu/drm/nouveau/nouveau_dmem.c

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
#include <nvif/if900b.h>
3636
#include <nvif/if000c.h>
3737

38+
#include <nvhw/class/cla0b5.h>
39+
3840
#include <linux/sched/mm.h>
3941
#include <linux/hmm.h>
4042

@@ -387,11 +389,7 @@ nvc0b5_migrate_copy(struct nouveau_drm *drm, u64 npages,
387389
enum nouveau_aper src_aper, u64 src_addr)
388390
{
389391
struct nvif_push *push = drm->dmem->migrate.chan->chan.push;
390-
u32 launch_dma = (1 << 9) /* MULTI_LINE_ENABLE. */ |
391-
(1 << 8) /* DST_MEMORY_LAYOUT_PITCH. */ |
392-
(1 << 7) /* SRC_MEMORY_LAYOUT_PITCH. */ |
393-
(1 << 2) /* FLUSH_ENABLE_TRUE. */ |
394-
(2 << 0) /* DATA_TRANSFER_TYPE_NON_PIPELINED. */;
392+
u32 launch_dma = 0;
395393
int ret;
396394

397395
ret = PUSH_WAIT(push, 13);
@@ -401,40 +399,61 @@ nvc0b5_migrate_copy(struct nouveau_drm *drm, u64 npages,
401399
if (src_aper != NOUVEAU_APER_VIRT) {
402400
switch (src_aper) {
403401
case NOUVEAU_APER_VRAM:
404-
PUSH_NVIM(push, NVA0B5, 0x0260, 0);
402+
PUSH_IMMD(push, NVA0B5, SET_SRC_PHYS_MODE,
403+
NVDEF(NVA0B5, SET_SRC_PHYS_MODE, TARGET, LOCAL_FB));
405404
break;
406405
case NOUVEAU_APER_HOST:
407-
PUSH_NVIM(push, NVA0B5, 0x0260, 1);
406+
PUSH_IMMD(push, NVA0B5, SET_SRC_PHYS_MODE,
407+
NVDEF(NVA0B5, SET_SRC_PHYS_MODE, TARGET, COHERENT_SYSMEM));
408408
break;
409409
default:
410410
return -EINVAL;
411411
}
412-
launch_dma |= 0x00001000; /* SRC_TYPE_PHYSICAL. */
412+
413+
launch_dma |= NVDEF(NVA0B5, LAUNCH_DMA, SRC_TYPE, PHYSICAL);
413414
}
414415

415416
if (dst_aper != NOUVEAU_APER_VIRT) {
416417
switch (dst_aper) {
417418
case NOUVEAU_APER_VRAM:
418-
PUSH_NVIM(push, NVA0B5, 0x0264, 0);
419+
PUSH_IMMD(push, NVA0B5, SET_DST_PHYS_MODE,
420+
NVDEF(NVA0B5, SET_DST_PHYS_MODE, TARGET, LOCAL_FB));
419421
break;
420422
case NOUVEAU_APER_HOST:
421-
PUSH_NVIM(push, NVA0B5, 0x0264, 1);
423+
PUSH_IMMD(push, NVA0B5, SET_DST_PHYS_MODE,
424+
NVDEF(NVA0B5, SET_DST_PHYS_MODE, TARGET, COHERENT_SYSMEM));
422425
break;
423426
default:
424427
return -EINVAL;
425428
}
426-
launch_dma |= 0x00002000; /* DST_TYPE_PHYSICAL. */
429+
430+
launch_dma |= NVDEF(NVA0B5, LAUNCH_DMA, DST_TYPE, PHYSICAL);
427431
}
428432

429-
PUSH_NVSQ(push, NVA0B5, 0x0400, upper_32_bits(src_addr),
430-
0x0404, lower_32_bits(src_addr),
431-
0x0408, upper_32_bits(dst_addr),
432-
0x040c, lower_32_bits(dst_addr),
433-
0x0410, PAGE_SIZE,
434-
0x0414, PAGE_SIZE,
435-
0x0418, PAGE_SIZE,
436-
0x041c, npages);
437-
PUSH_NVSQ(push, NVA0B5, 0x0300, launch_dma);
433+
PUSH_MTHD(push, NVA0B5, OFFSET_IN_UPPER,
434+
NVVAL(NVA0B5, OFFSET_IN_UPPER, UPPER, upper_32_bits(src_addr)),
435+
436+
OFFSET_IN_LOWER, lower_32_bits(src_addr),
437+
438+
OFFSET_OUT_UPPER,
439+
NVVAL(NVA0B5, OFFSET_OUT_UPPER, UPPER, upper_32_bits(dst_addr)),
440+
441+
OFFSET_OUT_LOWER, lower_32_bits(dst_addr),
442+
PITCH_IN, PAGE_SIZE,
443+
PITCH_OUT, PAGE_SIZE,
444+
LINE_LENGTH_IN, PAGE_SIZE,
445+
LINE_COUNT, npages);
446+
447+
PUSH_MTHD(push, NVA0B5, LAUNCH_DMA, launch_dma |
448+
NVDEF(NVA0B5, LAUNCH_DMA, DATA_TRANSFER_TYPE, NON_PIPELINED) |
449+
NVDEF(NVA0B5, LAUNCH_DMA, FLUSH_ENABLE, TRUE) |
450+
NVDEF(NVA0B5, LAUNCH_DMA, SEMAPHORE_TYPE, NONE) |
451+
NVDEF(NVA0B5, LAUNCH_DMA, INTERRUPT_TYPE, NONE) |
452+
NVDEF(NVA0B5, LAUNCH_DMA, SRC_MEMORY_LAYOUT, PITCH) |
453+
NVDEF(NVA0B5, LAUNCH_DMA, DST_MEMORY_LAYOUT, PITCH) |
454+
NVDEF(NVA0B5, LAUNCH_DMA, MULTI_LINE_ENABLE, TRUE) |
455+
NVDEF(NVA0B5, LAUNCH_DMA, REMAP_ENABLE, FALSE) |
456+
NVDEF(NVA0B5, LAUNCH_DMA, BYPASS_L2, USE_PTE_SETTING));
438457
return 0;
439458
}
440459

0 commit comments

Comments
 (0)