aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2010-12-09 00:17:10 -0500
committerBen Skeggs <bskeggs@redhat.com>2010-12-21 02:18:44 -0500
commit183720b8af5301e2eab7f3163f03133c5a6ad6da (patch)
treee807854af432d71a630412cb8d68f18d6fb10b56 /drivers/gpu/drm/nouveau
parent6d86951a45013ac5b060c5e6307b11b7c685c76f (diff)
drm/nvc0: accelerate ttm buffer moves
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bo.c57
1 files changed, 56 insertions, 1 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 74d0ef41118d..a7fae26f4654 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -515,6 +515,58 @@ nouveau_bo_mem_ctxdma(struct ttm_buffer_object *bo,
515} 515}
516 516
517static int 517static int
518nvc0_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
519 struct ttm_mem_reg *old_mem, struct ttm_mem_reg *new_mem)
520{
521 struct drm_nouveau_private *dev_priv = nouveau_bdev(bo->bdev);
522 struct nouveau_bo *nvbo = nouveau_bo(bo);
523 u64 src_offset = old_mem->start << PAGE_SHIFT;
524 u64 dst_offset = new_mem->start << PAGE_SHIFT;
525 u32 page_count = new_mem->num_pages;
526 int ret;
527
528 if (!nvbo->no_vm) {
529 if (old_mem->mem_type == TTM_PL_VRAM)
530 src_offset = nvbo->vma.offset;
531 else
532 src_offset += dev_priv->gart_info.aper_base;
533
534 if (new_mem->mem_type == TTM_PL_VRAM)
535 dst_offset = nvbo->vma.offset;
536 else
537 dst_offset += dev_priv->gart_info.aper_base;
538 }
539
540 page_count = new_mem->num_pages;
541 while (page_count) {
542 int line_count = (page_count > 2047) ? 2047 : page_count;
543
544 ret = RING_SPACE(chan, 12);
545 if (ret)
546 return ret;
547
548 BEGIN_NVC0(chan, 2, NvSubM2MF, 0x0238, 2);
549 OUT_RING (chan, upper_32_bits(dst_offset));
550 OUT_RING (chan, lower_32_bits(dst_offset));
551 BEGIN_NVC0(chan, 2, NvSubM2MF, 0x030c, 6);
552 OUT_RING (chan, upper_32_bits(src_offset));
553 OUT_RING (chan, lower_32_bits(src_offset));
554 OUT_RING (chan, PAGE_SIZE); /* src_pitch */
555 OUT_RING (chan, PAGE_SIZE); /* dst_pitch */
556 OUT_RING (chan, PAGE_SIZE); /* line_length */
557 OUT_RING (chan, line_count);
558 BEGIN_NVC0(chan, 2, NvSubM2MF, 0x0300, 1);
559 OUT_RING (chan, 0x00100110);
560
561 page_count -= line_count;
562 src_offset += (PAGE_SIZE * line_count);
563 dst_offset += (PAGE_SIZE * line_count);
564 }
565
566 return 0;
567}
568
569static int
518nv50_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo, 570nv50_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
519 struct ttm_mem_reg *old_mem, struct ttm_mem_reg *new_mem) 571 struct ttm_mem_reg *old_mem, struct ttm_mem_reg *new_mem)
520{ 572{
@@ -690,7 +742,10 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
690 if (dev_priv->card_type < NV_50) 742 if (dev_priv->card_type < NV_50)
691 ret = nv04_bo_move_m2mf(chan, bo, &bo->mem, new_mem); 743 ret = nv04_bo_move_m2mf(chan, bo, &bo->mem, new_mem);
692 else 744 else
745 if (dev_priv->card_type < NV_C0)
693 ret = nv50_bo_move_m2mf(chan, bo, &bo->mem, new_mem); 746 ret = nv50_bo_move_m2mf(chan, bo, &bo->mem, new_mem);
747 else
748 ret = nvc0_bo_move_m2mf(chan, bo, &bo->mem, new_mem);
694 if (ret == 0) { 749 if (ret == 0) {
695 ret = nouveau_bo_move_accel_cleanup(chan, nvbo, evict, 750 ret = nouveau_bo_move_accel_cleanup(chan, nvbo, evict,
696 no_wait_reserve, 751 no_wait_reserve,
@@ -836,7 +891,7 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr,
836 } 891 }
837 892
838 /* Software copy if the card isn't up and running yet. */ 893 /* Software copy if the card isn't up and running yet. */
839 if (!dev_priv->channel || dev_priv->card_type == NV_C0) { 894 if (!dev_priv->channel) {
840 ret = ttm_bo_move_memcpy(bo, evict, no_wait_reserve, no_wait_gpu, new_mem); 895 ret = ttm_bo_move_memcpy(bo, evict, no_wait_reserve, no_wait_gpu, new_mem);
841 goto out; 896 goto out;
842 } 897 }