Skip to content

Commit c47fcec

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

File tree

1 file changed

+34
-20
lines changed

1 file changed

+34
-20
lines changed

drivers/gpu/drm/nouveau/nouveau_dmem.c

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -462,15 +462,7 @@ nvc0b5_migrate_clear(struct nouveau_drm *drm, u32 length,
462462
enum nouveau_aper dst_aper, u64 dst_addr)
463463
{
464464
struct nvif_push *push = drm->dmem->migrate.chan->chan.push;
465-
u32 launch_dma = (1 << 10) /* REMAP_ENABLE_TRUE */ |
466-
(1 << 8) /* DST_MEMORY_LAYOUT_PITCH. */ |
467-
(1 << 7) /* SRC_MEMORY_LAYOUT_PITCH. */ |
468-
(1 << 2) /* FLUSH_ENABLE_TRUE. */ |
469-
(2 << 0) /* DATA_TRANSFER_TYPE_NON_PIPELINED. */;
470-
u32 remap = (4 << 0) /* DST_X_CONST_A */ |
471-
(5 << 4) /* DST_Y_CONST_B */ |
472-
(3 << 16) /* COMPONENT_SIZE_FOUR */ |
473-
(1 << 24) /* NUM_DST_COMPONENTS_TWO */;
465+
u32 launch_dma = 0;
474466
int ret;
475467

476468
ret = PUSH_WAIT(push, 12);
@@ -479,23 +471,45 @@ nvc0b5_migrate_clear(struct nouveau_drm *drm, u32 length,
479471

480472
switch (dst_aper) {
481473
case NOUVEAU_APER_VRAM:
482-
PUSH_NVIM(push, NVA0B5, 0x0264, 0);
474+
PUSH_IMMD(push, NVA0B5, SET_DST_PHYS_MODE,
475+
NVDEF(NVA0B5, SET_DST_PHYS_MODE, TARGET, LOCAL_FB));
483476
break;
484477
case NOUVEAU_APER_HOST:
485-
PUSH_NVIM(push, NVA0B5, 0x0264, 1);
478+
PUSH_IMMD(push, NVA0B5, SET_DST_PHYS_MODE,
479+
NVDEF(NVA0B5, SET_DST_PHYS_MODE, TARGET, COHERENT_SYSMEM));
486480
break;
487481
default:
488482
return -EINVAL;
489483
}
490-
launch_dma |= 0x00002000; /* DST_TYPE_PHYSICAL. */
491-
492-
PUSH_NVSQ(push, NVA0B5, 0x0700, 0,
493-
0x0704, 0,
494-
0x0708, remap);
495-
PUSH_NVSQ(push, NVA0B5, 0x0408, upper_32_bits(dst_addr),
496-
0x040c, lower_32_bits(dst_addr));
497-
PUSH_NVSQ(push, NVA0B5, 0x0418, length >> 3);
498-
PUSH_NVSQ(push, NVA0B5, 0x0300, launch_dma);
484+
485+
launch_dma |= NVDEF(NVA0B5, LAUNCH_DMA, DST_TYPE, PHYSICAL);
486+
487+
PUSH_MTHD(push, NVA0B5, SET_REMAP_CONST_A, 0,
488+
SET_REMAP_CONST_B, 0,
489+
490+
SET_REMAP_COMPONENTS,
491+
NVDEF(NVA0B5, SET_REMAP_COMPONENTS, DST_X, CONST_A) |
492+
NVDEF(NVA0B5, SET_REMAP_COMPONENTS, DST_Y, CONST_B) |
493+
NVDEF(NVA0B5, SET_REMAP_COMPONENTS, COMPONENT_SIZE, FOUR) |
494+
NVDEF(NVA0B5, SET_REMAP_COMPONENTS, NUM_DST_COMPONENTS, TWO));
495+
496+
PUSH_MTHD(push, NVA0B5, OFFSET_OUT_UPPER,
497+
NVVAL(NVA0B5, OFFSET_OUT_UPPER, UPPER, upper_32_bits(dst_addr)),
498+
499+
OFFSET_OUT_LOWER, lower_32_bits(dst_addr));
500+
501+
PUSH_MTHD(push, NVA0B5, LINE_LENGTH_IN, length >> 3);
502+
503+
PUSH_MTHD(push, NVA0B5, LAUNCH_DMA, launch_dma |
504+
NVDEF(NVA0B5, LAUNCH_DMA, DATA_TRANSFER_TYPE, NON_PIPELINED) |
505+
NVDEF(NVA0B5, LAUNCH_DMA, FLUSH_ENABLE, TRUE) |
506+
NVDEF(NVA0B5, LAUNCH_DMA, SEMAPHORE_TYPE, NONE) |
507+
NVDEF(NVA0B5, LAUNCH_DMA, INTERRUPT_TYPE, NONE) |
508+
NVDEF(NVA0B5, LAUNCH_DMA, SRC_MEMORY_LAYOUT, PITCH) |
509+
NVDEF(NVA0B5, LAUNCH_DMA, DST_MEMORY_LAYOUT, PITCH) |
510+
NVDEF(NVA0B5, LAUNCH_DMA, MULTI_LINE_ENABLE, FALSE) |
511+
NVDEF(NVA0B5, LAUNCH_DMA, REMAP_ENABLE, TRUE) |
512+
NVDEF(NVA0B5, LAUNCH_DMA, BYPASS_L2, USE_PTE_SETTING));
499513
return 0;
500514
}
501515

0 commit comments

Comments
 (0)