aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2020-08-04 12:55:34 +1000
committerDave Airlie <airlied@redhat.com>2020-08-06 12:16:22 +1000
commit56dc01f18d3d002de34f642ce92f730e5d50efa5 (patch)
tree842aca091554336bf6c73033c040e945a58b379e /drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
parentvideo: fbdev: pvr2fb: initialize variables (diff)
downloadlinux-dev-56dc01f18d3d002de34f642ce92f730e5d50efa5.tar.xz
linux-dev-56dc01f18d3d002de34f642ce92f730e5d50efa5.zip
drm/vmwgfx: consolidate ttm object creation and populate
These two functions has the same code in them, create a common helper function instead. Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200804025632.3868079-2-airlied@gmail.com
Diffstat (limited to 'drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c')
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
index 0e2897895327..ef41d0c5e3d3 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
@@ -819,3 +819,35 @@ struct ttm_bo_driver vmw_bo_driver = {
.swap_notify = vmw_swap_notify,
.io_mem_reserve = &vmw_ttm_io_mem_reserve,
};
+
+int vmw_bo_create_and_populate(struct vmw_private *dev_priv,
+ unsigned long bo_size,
+ struct ttm_buffer_object **bo_p)
+{
+ struct ttm_operation_ctx ctx = {
+ .interruptible = false,
+ .no_wait_gpu = false
+ };
+ struct ttm_buffer_object *bo;
+ int ret;
+
+ ret = ttm_bo_create(&dev_priv->bdev, bo_size,
+ ttm_bo_type_device,
+ &vmw_sys_ne_placement,
+ 0, false, &bo);
+
+ if (unlikely(ret != 0))
+ return ret;
+
+ ret = ttm_bo_reserve(bo, false, true, NULL);
+ BUG_ON(ret != 0);
+ ret = vmw_bo_driver.ttm_tt_populate(bo->ttm, &ctx);
+ if (likely(ret == 0))
+ ret = vmw_bo_map_dma(bo);
+
+ ttm_bo_unreserve(bo);
+
+ if (likely(ret == 0))
+ *bo_p = bo;
+ return ret;
+}