aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2012-05-04 01:17:28 -0400
committerBen Skeggs <bskeggs@redhat.com>2012-05-24 02:56:23 -0400
commit1a46098e910b96337f0fe3838223db43b923bad4 (patch)
tree1d0d09e6a48a2f11d9dc0e2f2f409fb8149c9a3f /drivers/gpu
parentfdf53241c1845a4a1d8bd2df65f574b281649957 (diff)
drm/nvc0/ttm: use copy engines for async buffer moves
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bo.c60
1 files changed, 51 insertions, 9 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index fc463ef92d42..7f80ed523562 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -523,6 +523,44 @@ nvc0_bo_move_init(struct nouveau_channel *chan, u32 handle)
523} 523}
524 524
525static int 525static int
526nvc0_bo_move_copy(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
527 struct ttm_mem_reg *old_mem, struct ttm_mem_reg *new_mem)
528{
529 struct nouveau_mem *node = old_mem->mm_node;
530 u64 src_offset = node->vma[0].offset;
531 u64 dst_offset = node->vma[1].offset;
532 u32 page_count = new_mem->num_pages;
533 int ret;
534
535 page_count = new_mem->num_pages;
536 while (page_count) {
537 int line_count = (page_count > 8191) ? 8191 : page_count;
538
539 ret = RING_SPACE(chan, 11);
540 if (ret)
541 return ret;
542
543 BEGIN_NVC0(chan, NvSubCopy, 0x030c, 8);
544 OUT_RING (chan, upper_32_bits(src_offset));
545 OUT_RING (chan, lower_32_bits(src_offset));
546 OUT_RING (chan, upper_32_bits(dst_offset));
547 OUT_RING (chan, lower_32_bits(dst_offset));
548 OUT_RING (chan, PAGE_SIZE);
549 OUT_RING (chan, PAGE_SIZE);
550 OUT_RING (chan, PAGE_SIZE);
551 OUT_RING (chan, line_count);
552 BEGIN_NVC0(chan, NvSubCopy, 0x0300, 1);
553 OUT_RING (chan, 0x00000110);
554
555 page_count -= line_count;
556 src_offset += (PAGE_SIZE * line_count);
557 dst_offset += (PAGE_SIZE * line_count);
558 }
559
560 return 0;
561}
562
563static int
526nvc0_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo, 564nvc0_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
527 struct ttm_mem_reg *old_mem, struct ttm_mem_reg *new_mem) 565 struct ttm_mem_reg *old_mem, struct ttm_mem_reg *new_mem)
528{ 566{
@@ -887,28 +925,32 @@ nouveau_bo_move_init(struct nouveau_channel *chan)
887 struct drm_nouveau_private *dev_priv = chan->dev->dev_private; 925 struct drm_nouveau_private *dev_priv = chan->dev->dev_private;
888 static const struct { 926 static const struct {
889 const char *name; 927 const char *name;
928 int engine;
890 u32 oclass; 929 u32 oclass;
891 int (*exec)(struct nouveau_channel *, 930 int (*exec)(struct nouveau_channel *,
892 struct ttm_buffer_object *, 931 struct ttm_buffer_object *,
893 struct ttm_mem_reg *, struct ttm_mem_reg *); 932 struct ttm_mem_reg *, struct ttm_mem_reg *);
894 int (*init)(struct nouveau_channel *, u32 handle); 933 int (*init)(struct nouveau_channel *, u32 handle);
895 } _methods[] = { 934 } _methods[] = {
896 { "COPY", 0xa0b5, nve0_bo_move_copy, nvc0_bo_move_init }, 935 { "COPY", 0, 0xa0b5, nve0_bo_move_copy, nvc0_bo_move_init },
897 { "COPY", 0x85b5, nva3_bo_move_copy, nv50_bo_move_init }, 936 { "COPY1", 5, 0x90b8, nvc0_bo_move_copy, nvc0_bo_move_init },
898 { "CRYPT", 0x74c1, nv84_bo_move_exec, nv50_bo_move_init }, 937 { "COPY0", 4, 0x90b5, nvc0_bo_move_copy, nvc0_bo_move_init },
899 { "M2MF", 0x9039, nvc0_bo_move_m2mf, nvc0_bo_move_init }, 938 { "COPY", 0, 0x85b5, nva3_bo_move_copy, nv50_bo_move_init },
900 { "M2MF", 0x5039, nv50_bo_move_m2mf, nv50_bo_move_init }, 939 { "CRYPT", 0, 0x74c1, nv84_bo_move_exec, nv50_bo_move_init },
901 { "M2MF", 0x0039, nv04_bo_move_m2mf, nv04_bo_move_init }, 940 { "M2MF", 0, 0x9039, nvc0_bo_move_m2mf, nvc0_bo_move_init },
941 { "M2MF", 0, 0x5039, nv50_bo_move_m2mf, nv50_bo_move_init },
942 { "M2MF", 0, 0x0039, nv04_bo_move_m2mf, nv04_bo_move_init },
902 {}, 943 {},
903 { "CRYPT", 0x88b4, nv98_bo_move_exec, nv50_bo_move_init }, 944 { "CRYPT", 0, 0x88b4, nv98_bo_move_exec, nv50_bo_move_init },
904 }, *mthd = _methods; 945 }, *mthd = _methods;
905 const char *name = "CPU"; 946 const char *name = "CPU";
906 int ret; 947 int ret;
907 948
908 do { 949 do {
909 ret = nouveau_gpuobj_gr_new(chan, mthd->oclass, mthd->oclass); 950 u32 handle = (mthd->engine << 16) | mthd->oclass;
951 ret = nouveau_gpuobj_gr_new(chan, handle, mthd->oclass);
910 if (ret == 0) { 952 if (ret == 0) {
911 ret = mthd->init(chan, mthd->oclass); 953 ret = mthd->init(chan, handle);
912 if (ret == 0) { 954 if (ret == 0) {
913 dev_priv->ttm.move = mthd->exec; 955 dev_priv->ttm.move = mthd->exec;
914 name = mthd->name; 956 name = mthd->name;