diff options
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_bo.c | 59 |
1 files changed, 37 insertions, 22 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index cfdecd31f802..d7a9e80a7c79 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c | |||
@@ -805,6 +805,25 @@ out: | |||
805 | return ret; | 805 | return ret; |
806 | } | 806 | } |
807 | 807 | ||
808 | static void | ||
809 | nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem) | ||
810 | { | ||
811 | struct drm_nouveau_private *dev_priv = nouveau_bdev(bo->bdev); | ||
812 | struct nouveau_bo *nvbo = nouveau_bo(bo); | ||
813 | |||
814 | if (dev_priv->card_type < NV_50 || nvbo->no_vm) | ||
815 | return; | ||
816 | |||
817 | switch (new_mem->mem_type) { | ||
818 | case TTM_PL_VRAM: | ||
819 | nouveau_vm_map(&nvbo->vma, new_mem->mm_node); | ||
820 | break; | ||
821 | case TTM_PL_TT: | ||
822 | default: | ||
823 | break; | ||
824 | } | ||
825 | } | ||
826 | |||
808 | static int | 827 | static int |
809 | nouveau_bo_vm_bind(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem, | 828 | nouveau_bo_vm_bind(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem, |
810 | struct nouveau_tile_reg **new_tile) | 829 | struct nouveau_tile_reg **new_tile) |
@@ -812,19 +831,13 @@ nouveau_bo_vm_bind(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem, | |||
812 | struct drm_nouveau_private *dev_priv = nouveau_bdev(bo->bdev); | 831 | struct drm_nouveau_private *dev_priv = nouveau_bdev(bo->bdev); |
813 | struct drm_device *dev = dev_priv->dev; | 832 | struct drm_device *dev = dev_priv->dev; |
814 | struct nouveau_bo *nvbo = nouveau_bo(bo); | 833 | struct nouveau_bo *nvbo = nouveau_bo(bo); |
815 | uint64_t offset; | 834 | u64 offset = new_mem->start << PAGE_SHIFT; |
816 | 835 | ||
817 | if (new_mem->mem_type != TTM_PL_VRAM) { | 836 | *new_tile = NULL; |
818 | /* Nothing to do. */ | 837 | if (new_mem->mem_type != TTM_PL_VRAM) |
819 | *new_tile = NULL; | ||
820 | return 0; | 838 | return 0; |
821 | } | ||
822 | 839 | ||
823 | offset = new_mem->start << PAGE_SHIFT; | 840 | if (dev_priv->card_type >= NV_10) { |
824 | |||
825 | if (dev_priv->chan_vm) { | ||
826 | nouveau_vm_map(&nvbo->vma, new_mem->mm_node); | ||
827 | } else if (dev_priv->card_type >= NV_10) { | ||
828 | *new_tile = nv10_mem_set_tiling(dev, offset, new_mem->size, | 841 | *new_tile = nv10_mem_set_tiling(dev, offset, new_mem->size, |
829 | nvbo->tile_mode, | 842 | nvbo->tile_mode, |
830 | nvbo->tile_flags); | 843 | nvbo->tile_flags); |
@@ -841,11 +854,8 @@ nouveau_bo_vm_cleanup(struct ttm_buffer_object *bo, | |||
841 | struct drm_nouveau_private *dev_priv = nouveau_bdev(bo->bdev); | 854 | struct drm_nouveau_private *dev_priv = nouveau_bdev(bo->bdev); |
842 | struct drm_device *dev = dev_priv->dev; | 855 | struct drm_device *dev = dev_priv->dev; |
843 | 856 | ||
844 | if (dev_priv->card_type >= NV_10 && | 857 | nv10_mem_put_tile_region(dev, *old_tile, bo->sync_obj); |
845 | dev_priv->card_type < NV_50) { | 858 | *old_tile = new_tile; |
846 | nv10_mem_put_tile_region(dev, *old_tile, bo->sync_obj); | ||
847 | *old_tile = new_tile; | ||
848 | } | ||
849 | } | 859 | } |
850 | 860 | ||
851 | static int | 861 | static int |
@@ -859,9 +869,11 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr, | |||
859 | struct nouveau_tile_reg *new_tile = NULL; | 869 | struct nouveau_tile_reg *new_tile = NULL; |
860 | int ret = 0; | 870 | int ret = 0; |
861 | 871 | ||
862 | ret = nouveau_bo_vm_bind(bo, new_mem, &new_tile); | 872 | if (dev_priv->card_type < NV_50) { |
863 | if (ret) | 873 | ret = nouveau_bo_vm_bind(bo, new_mem, &new_tile); |
864 | return ret; | 874 | if (ret) |
875 | return ret; | ||
876 | } | ||
865 | 877 | ||
866 | /* Fake bo copy. */ | 878 | /* Fake bo copy. */ |
867 | if (old_mem->mem_type == TTM_PL_SYSTEM && !bo->ttm) { | 879 | if (old_mem->mem_type == TTM_PL_SYSTEM && !bo->ttm) { |
@@ -892,10 +904,12 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr, | |||
892 | ret = ttm_bo_move_memcpy(bo, evict, no_wait_reserve, no_wait_gpu, new_mem); | 904 | ret = ttm_bo_move_memcpy(bo, evict, no_wait_reserve, no_wait_gpu, new_mem); |
893 | 905 | ||
894 | out: | 906 | out: |
895 | if (ret) | 907 | if (dev_priv->card_type < NV_50) { |
896 | nouveau_bo_vm_cleanup(bo, NULL, &new_tile); | 908 | if (ret) |
897 | else | 909 | nouveau_bo_vm_cleanup(bo, NULL, &new_tile); |
898 | nouveau_bo_vm_cleanup(bo, new_tile, &nvbo->tile); | 910 | else |
911 | nouveau_bo_vm_cleanup(bo, new_tile, &nvbo->tile); | ||
912 | } | ||
899 | 913 | ||
900 | return ret; | 914 | return ret; |
901 | } | 915 | } |
@@ -1039,6 +1053,7 @@ struct ttm_bo_driver nouveau_bo_driver = { | |||
1039 | .invalidate_caches = nouveau_bo_invalidate_caches, | 1053 | .invalidate_caches = nouveau_bo_invalidate_caches, |
1040 | .init_mem_type = nouveau_bo_init_mem_type, | 1054 | .init_mem_type = nouveau_bo_init_mem_type, |
1041 | .evict_flags = nouveau_bo_evict_flags, | 1055 | .evict_flags = nouveau_bo_evict_flags, |
1056 | .move_notify = nouveau_bo_move_ntfy, | ||
1042 | .move = nouveau_bo_move, | 1057 | .move = nouveau_bo_move, |
1043 | .verify_access = nouveau_bo_verify_access, | 1058 | .verify_access = nouveau_bo_verify_access, |
1044 | .sync_obj_signaled = __nouveau_fence_signalled, | 1059 | .sync_obj_signaled = __nouveau_fence_signalled, |