aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/vmwgfx/vmwgfx_resource.c')
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_resource.c75
1 files changed, 0 insertions, 75 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
index c8c40e9979db..36e129f0023f 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
@@ -765,28 +765,11 @@ static size_t vmw_dmabuf_acc_size(struct ttm_bo_global *glob,
765 return bo_user_size + page_array_size; 765 return bo_user_size + page_array_size;
766} 766}
767 767
768void vmw_dmabuf_gmr_unbind(struct ttm_buffer_object *bo)
769{
770 struct vmw_dma_buffer *vmw_bo = vmw_dma_buffer(bo);
771 struct ttm_bo_global *glob = bo->glob;
772 struct vmw_private *dev_priv =
773 container_of(bo->bdev, struct vmw_private, bdev);
774
775 if (vmw_bo->gmr_bound) {
776 vmw_gmr_unbind(dev_priv, vmw_bo->gmr_id);
777 spin_lock(&glob->lru_lock);
778 ida_remove(&dev_priv->gmr_ida, vmw_bo->gmr_id);
779 spin_unlock(&glob->lru_lock);
780 vmw_bo->gmr_bound = false;
781 }
782}
783
784void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo) 768void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo)
785{ 769{
786 struct vmw_dma_buffer *vmw_bo = vmw_dma_buffer(bo); 770 struct vmw_dma_buffer *vmw_bo = vmw_dma_buffer(bo);
787 struct ttm_bo_global *glob = bo->glob; 771 struct ttm_bo_global *glob = bo->glob;
788 772
789 vmw_dmabuf_gmr_unbind(bo);
790 ttm_mem_global_free(glob->mem_glob, bo->acc_size); 773 ttm_mem_global_free(glob->mem_glob, bo->acc_size);
791 kfree(vmw_bo); 774 kfree(vmw_bo);
792} 775}
@@ -818,10 +801,7 @@ int vmw_dmabuf_init(struct vmw_private *dev_priv,
818 801
819 memset(vmw_bo, 0, sizeof(*vmw_bo)); 802 memset(vmw_bo, 0, sizeof(*vmw_bo));
820 803
821 INIT_LIST_HEAD(&vmw_bo->gmr_lru);
822 INIT_LIST_HEAD(&vmw_bo->validate_list); 804 INIT_LIST_HEAD(&vmw_bo->validate_list);
823 vmw_bo->gmr_id = 0;
824 vmw_bo->gmr_bound = false;
825 805
826 ret = ttm_bo_init(bdev, &vmw_bo->base, size, 806 ret = ttm_bo_init(bdev, &vmw_bo->base, size,
827 ttm_bo_type_device, placement, 807 ttm_bo_type_device, placement,
@@ -835,7 +815,6 @@ static void vmw_user_dmabuf_destroy(struct ttm_buffer_object *bo)
835 struct vmw_user_dma_buffer *vmw_user_bo = vmw_user_dma_buffer(bo); 815 struct vmw_user_dma_buffer *vmw_user_bo = vmw_user_dma_buffer(bo);
836 struct ttm_bo_global *glob = bo->glob; 816 struct ttm_bo_global *glob = bo->glob;
837 817
838 vmw_dmabuf_gmr_unbind(bo);
839 ttm_mem_global_free(glob->mem_glob, bo->acc_size); 818 ttm_mem_global_free(glob->mem_glob, bo->acc_size);
840 kfree(vmw_user_bo); 819 kfree(vmw_user_bo);
841} 820}
@@ -938,25 +917,6 @@ void vmw_dmabuf_validate_clear(struct ttm_buffer_object *bo)
938 vmw_bo->on_validate_list = false; 917 vmw_bo->on_validate_list = false;
939} 918}
940 919
941uint32_t vmw_dmabuf_gmr(struct ttm_buffer_object *bo)
942{
943 struct vmw_dma_buffer *vmw_bo;
944
945 if (bo->mem.mem_type == TTM_PL_VRAM)
946 return SVGA_GMR_FRAMEBUFFER;
947
948 vmw_bo = vmw_dma_buffer(bo);
949
950 return (vmw_bo->gmr_bound) ? vmw_bo->gmr_id : SVGA_GMR_NULL;
951}
952
953void vmw_dmabuf_set_gmr(struct ttm_buffer_object *bo, uint32_t id)
954{
955 struct vmw_dma_buffer *vmw_bo = vmw_dma_buffer(bo);
956 vmw_bo->gmr_bound = true;
957 vmw_bo->gmr_id = id;
958}
959
960int vmw_user_dmabuf_lookup(struct ttm_object_file *tfile, 920int vmw_user_dmabuf_lookup(struct ttm_object_file *tfile,
961 uint32_t handle, struct vmw_dma_buffer **out) 921 uint32_t handle, struct vmw_dma_buffer **out)
962{ 922{
@@ -985,41 +945,6 @@ int vmw_user_dmabuf_lookup(struct ttm_object_file *tfile,
985 return 0; 945 return 0;
986} 946}
987 947
988/**
989 * TODO: Implement a gmr id eviction mechanism. Currently we just fail
990 * when we're out of ids, causing GMR space to be allocated
991 * out of VRAM.
992 */
993
994int vmw_gmr_id_alloc(struct vmw_private *dev_priv, uint32_t *p_id)
995{
996 struct ttm_bo_global *glob = dev_priv->bdev.glob;
997 int id;
998 int ret;
999
1000 do {
1001 if (unlikely(ida_pre_get(&dev_priv->gmr_ida, GFP_KERNEL) == 0))
1002 return -ENOMEM;
1003
1004 spin_lock(&glob->lru_lock);
1005 ret = ida_get_new(&dev_priv->gmr_ida, &id);
1006 spin_unlock(&glob->lru_lock);
1007 } while (ret == -EAGAIN);
1008
1009 if (unlikely(ret != 0))
1010 return ret;
1011
1012 if (unlikely(id >= dev_priv->max_gmr_ids)) {
1013 spin_lock(&glob->lru_lock);
1014 ida_remove(&dev_priv->gmr_ida, id);
1015 spin_unlock(&glob->lru_lock);
1016 return -EBUSY;
1017 }
1018
1019 *p_id = (uint32_t) id;
1020 return 0;
1021}
1022
1023/* 948/*
1024 * Stream management 949 * Stream management
1025 */ 950 */