aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ttm/ttm_bo.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2012-04-02 06:46:06 -0400
committerDave Airlie <airlied@redhat.com>2012-05-23 05:46:27 -0400
commit129b78bfca591e736e56a294f0e357d73d938f7e (patch)
treeb5754d4b12346b67077ac3b2239c04bda37bf6a0 /drivers/gpu/drm/ttm/ttm_bo.c
parent96503f592fd729f296f5870a57be0417eeffc92a (diff)
ttm: add prime sharing support to TTM (v2)
This adds the ability for ttm common code to take an SG table and use it as the backing for a slave TTM object. The drivers can then populate their GTT tables using the SG object. v2: make sure to setup VM for sg bos as well. Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Jerome Glisse <jglisse@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/ttm/ttm_bo.c')
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 1f5c67c579cf..36792bd4da77 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -343,6 +343,16 @@ static int ttm_bo_add_ttm(struct ttm_buffer_object *bo, bool zero_alloc)
343 if (unlikely(bo->ttm == NULL)) 343 if (unlikely(bo->ttm == NULL))
344 ret = -ENOMEM; 344 ret = -ENOMEM;
345 break; 345 break;
346 case ttm_bo_type_sg:
347 bo->ttm = bdev->driver->ttm_tt_create(bdev, bo->num_pages << PAGE_SHIFT,
348 page_flags | TTM_PAGE_FLAG_SG,
349 glob->dummy_read_page);
350 if (unlikely(bo->ttm == NULL)) {
351 ret = -ENOMEM;
352 break;
353 }
354 bo->ttm->sg = bo->sg;
355 break;
346 default: 356 default:
347 pr_err("Illegal buffer object type\n"); 357 pr_err("Illegal buffer object type\n");
348 ret = -EINVAL; 358 ret = -EINVAL;
@@ -1169,6 +1179,7 @@ int ttm_bo_init(struct ttm_bo_device *bdev,
1169 bool interruptible, 1179 bool interruptible,
1170 struct file *persistent_swap_storage, 1180 struct file *persistent_swap_storage,
1171 size_t acc_size, 1181 size_t acc_size,
1182 struct sg_table *sg,
1172 void (*destroy) (struct ttm_buffer_object *)) 1183 void (*destroy) (struct ttm_buffer_object *))
1173{ 1184{
1174 int ret = 0; 1185 int ret = 0;
@@ -1223,6 +1234,7 @@ int ttm_bo_init(struct ttm_bo_device *bdev,
1223 bo->seq_valid = false; 1234 bo->seq_valid = false;
1224 bo->persistent_swap_storage = persistent_swap_storage; 1235 bo->persistent_swap_storage = persistent_swap_storage;
1225 bo->acc_size = acc_size; 1236 bo->acc_size = acc_size;
1237 bo->sg = sg;
1226 atomic_inc(&bo->glob->bo_count); 1238 atomic_inc(&bo->glob->bo_count);
1227 1239
1228 ret = ttm_bo_check_placement(bo, placement); 1240 ret = ttm_bo_check_placement(bo, placement);
@@ -1233,7 +1245,8 @@ int ttm_bo_init(struct ttm_bo_device *bdev,
1233 * For ttm_bo_type_device buffers, allocate 1245 * For ttm_bo_type_device buffers, allocate
1234 * address space from the device. 1246 * address space from the device.
1235 */ 1247 */
1236 if (bo->type == ttm_bo_type_device) { 1248 if (bo->type == ttm_bo_type_device ||
1249 bo->type == ttm_bo_type_sg) {
1237 ret = ttm_bo_setup_vm(bo); 1250 ret = ttm_bo_setup_vm(bo);
1238 if (ret) 1251 if (ret)
1239 goto out_err; 1252 goto out_err;
@@ -1312,7 +1325,7 @@ int ttm_bo_create(struct ttm_bo_device *bdev,
1312 1325
1313 ret = ttm_bo_init(bdev, bo, size, type, placement, page_alignment, 1326 ret = ttm_bo_init(bdev, bo, size, type, placement, page_alignment,
1314 buffer_start, interruptible, 1327 buffer_start, interruptible,
1315 persistent_swap_storage, acc_size, NULL); 1328 persistent_swap_storage, acc_size, NULL, NULL);
1316 if (likely(ret == 0)) 1329 if (likely(ret == 0))
1317 *p_bo = bo; 1330 *p_bo = bo;
1318 1331