diff options
Diffstat (limited to 'drivers/gpu/drm/vmwgfx/vmwgfx_resource.c')
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 35 |
1 files changed, 1 insertions, 34 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c index 1c7f09e26819..a37abb581cbb 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | |||
@@ -1540,29 +1540,10 @@ out_bad_surface: | |||
1540 | /** | 1540 | /** |
1541 | * Buffer management. | 1541 | * Buffer management. |
1542 | */ | 1542 | */ |
1543 | |||
1544 | static size_t vmw_dmabuf_acc_size(struct ttm_bo_global *glob, | ||
1545 | unsigned long num_pages) | ||
1546 | { | ||
1547 | static size_t bo_user_size = ~0; | ||
1548 | |||
1549 | size_t page_array_size = | ||
1550 | (num_pages * sizeof(void *) + PAGE_SIZE - 1) & PAGE_MASK; | ||
1551 | |||
1552 | if (unlikely(bo_user_size == ~0)) { | ||
1553 | bo_user_size = glob->ttm_bo_extra_size + | ||
1554 | ttm_round_pot(sizeof(struct vmw_dma_buffer)); | ||
1555 | } | ||
1556 | |||
1557 | return bo_user_size + page_array_size; | ||
1558 | } | ||
1559 | |||
1560 | void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo) | 1543 | void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo) |
1561 | { | 1544 | { |
1562 | struct vmw_dma_buffer *vmw_bo = vmw_dma_buffer(bo); | 1545 | struct vmw_dma_buffer *vmw_bo = vmw_dma_buffer(bo); |
1563 | struct ttm_bo_global *glob = bo->glob; | ||
1564 | 1546 | ||
1565 | ttm_mem_global_free(glob->mem_glob, bo->acc_size); | ||
1566 | kfree(vmw_bo); | 1547 | kfree(vmw_bo); |
1567 | } | 1548 | } |
1568 | 1549 | ||
@@ -1573,24 +1554,12 @@ int vmw_dmabuf_init(struct vmw_private *dev_priv, | |||
1573 | void (*bo_free) (struct ttm_buffer_object *bo)) | 1554 | void (*bo_free) (struct ttm_buffer_object *bo)) |
1574 | { | 1555 | { |
1575 | struct ttm_bo_device *bdev = &dev_priv->bdev; | 1556 | struct ttm_bo_device *bdev = &dev_priv->bdev; |
1576 | struct ttm_mem_global *mem_glob = bdev->glob->mem_glob; | ||
1577 | size_t acc_size; | 1557 | size_t acc_size; |
1578 | int ret; | 1558 | int ret; |
1579 | 1559 | ||
1580 | BUG_ON(!bo_free); | 1560 | BUG_ON(!bo_free); |
1581 | 1561 | ||
1582 | acc_size = | 1562 | acc_size = ttm_bo_acc_size(bdev, size, sizeof(struct vmw_dma_buffer)); |
1583 | vmw_dmabuf_acc_size(bdev->glob, | ||
1584 | (size + PAGE_SIZE - 1) >> PAGE_SHIFT); | ||
1585 | |||
1586 | ret = ttm_mem_global_alloc(mem_glob, acc_size, false, false); | ||
1587 | if (unlikely(ret != 0)) { | ||
1588 | /* we must free the bo here as | ||
1589 | * ttm_buffer_object_init does so as well */ | ||
1590 | bo_free(&vmw_bo->base); | ||
1591 | return ret; | ||
1592 | } | ||
1593 | |||
1594 | memset(vmw_bo, 0, sizeof(*vmw_bo)); | 1563 | memset(vmw_bo, 0, sizeof(*vmw_bo)); |
1595 | 1564 | ||
1596 | INIT_LIST_HEAD(&vmw_bo->validate_list); | 1565 | INIT_LIST_HEAD(&vmw_bo->validate_list); |
@@ -1605,9 +1574,7 @@ int vmw_dmabuf_init(struct vmw_private *dev_priv, | |||
1605 | static void vmw_user_dmabuf_destroy(struct ttm_buffer_object *bo) | 1574 | static void vmw_user_dmabuf_destroy(struct ttm_buffer_object *bo) |
1606 | { | 1575 | { |
1607 | struct vmw_user_dma_buffer *vmw_user_bo = vmw_user_dma_buffer(bo); | 1576 | struct vmw_user_dma_buffer *vmw_user_bo = vmw_user_dma_buffer(bo); |
1608 | struct ttm_bo_global *glob = bo->glob; | ||
1609 | 1577 | ||
1610 | ttm_mem_global_free(glob->mem_glob, bo->acc_size); | ||
1611 | kfree(vmw_user_bo); | 1578 | kfree(vmw_user_bo); |
1612 | } | 1579 | } |
1613 | 1580 | ||