Subversion Repositories Kolibri OS

Rev

Rev 4112 | Rev 5078 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4112 Rev 4569
Line 424... Line 424...
424
	}
424
	}
425
	if (bo->sync_obj)
425
	if (bo->sync_obj)
426
		sync_obj = driver->sync_obj_ref(bo->sync_obj);
426
		sync_obj = driver->sync_obj_ref(bo->sync_obj);
427
	spin_unlock(&bdev->fence_lock);
427
	spin_unlock(&bdev->fence_lock);
Line 428... Line 428...
428
 
428
 
-
 
429
	if (!ret) {
-
 
430
 
-
 
431
		/*
-
 
432
		 * Make NO_EVICT bos immediately available to
-
 
433
		 * shrinkers, now that they are queued for
-
 
434
		 * destruction.
-
 
435
		 */
-
 
436
		if (bo->mem.placement & TTM_PL_FLAG_NO_EVICT) {
-
 
437
			bo->mem.placement &= ~TTM_PL_FLAG_NO_EVICT;
-
 
438
			ttm_bo_add_to_lru(bo);
-
 
439
		}
429
	if (!ret)
440
 
-
 
441
		ww_mutex_unlock(&bo->resv->lock);
Line 430... Line 442...
430
		ww_mutex_unlock(&bo->resv->lock);
442
	}
431
 
443
 
432
	kref_get(&bo->list_kref);
444
	kref_get(&bo->list_kref);
Line 942... Line 954...
942
	ret = (has_erestartsys) ? -ERESTARTSYS : -ENOMEM;
954
	ret = (has_erestartsys) ? -ERESTARTSYS : -ENOMEM;
943
	return ret;
955
	return ret;
944
}
956
}
945
EXPORT_SYMBOL(ttm_bo_mem_space);
957
EXPORT_SYMBOL(ttm_bo_mem_space);
Line 946... Line 958...
946
 
958
 
947
int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
959
static int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
948
			struct ttm_placement *placement,
960
			struct ttm_placement *placement,
949
			bool interruptible,
961
			bool interruptible,
950
			bool no_wait_gpu)
962
			bool no_wait_gpu)
951
{
963
{
Line 984... Line 996...
984
		ttm_bo_mem_put(bo, &mem);
996
		ttm_bo_mem_put(bo, &mem);
985
	return ret;
997
	return ret;
986
}
998
}
987
#endif
999
#endif
Line 988... Line 1000...
988
 
1000
 
989
static int ttm_bo_mem_compat(struct ttm_placement *placement,
1001
static bool ttm_bo_mem_compat(struct ttm_placement *placement,
-
 
1002
			      struct ttm_mem_reg *mem,
990
			     struct ttm_mem_reg *mem)
1003
			      uint32_t *new_flags)
991
{
1004
{
Line 992... Line 1005...
992
	int i;
1005
	int i;
993
 
1006
 
994
	if (mem->mm_node && placement->lpfn != 0 &&
1007
	if (mem->mm_node && placement->lpfn != 0 &&
995
	    (mem->start < placement->fpfn ||
1008
	    (mem->start < placement->fpfn ||
Line 996... Line 1009...
996
	     mem->start + mem->num_pages > placement->lpfn))
1009
	     mem->start + mem->num_pages > placement->lpfn))
997
		return -1;
1010
		return false;
998
 
1011
 
999
	for (i = 0; i < placement->num_placement; i++) {
1012
	for (i = 0; i < placement->num_placement; i++) {
1000
		if ((placement->placement[i] & mem->placement &
-
 
1001
			TTM_PL_MASK_CACHING) &&
1013
		*new_flags = placement->placement[i];
1002
			(placement->placement[i] & mem->placement &
1014
		if ((*new_flags & mem->placement & TTM_PL_MASK_CACHING) &&
-
 
1015
		    (*new_flags & mem->placement & TTM_PL_MASK_MEM))
-
 
1016
			return true;
-
 
1017
	}
-
 
1018
 
-
 
1019
	for (i = 0; i < placement->num_busy_placement; i++) {
-
 
1020
		*new_flags = placement->busy_placement[i];
-
 
1021
		if ((*new_flags & mem->placement & TTM_PL_MASK_CACHING) &&
-
 
1022
		    (*new_flags & mem->placement & TTM_PL_MASK_MEM))
1003
			TTM_PL_MASK_MEM))
1023
			return true;
1004
			return i;
1024
	}
Line 1005... Line 1025...
1005
	}
1025
 
1006
	return -1;
1026
	return false;
1007
}
1027
}
1008
 
1028
 
1009
int ttm_bo_validate(struct ttm_buffer_object *bo,
1029
int ttm_bo_validate(struct ttm_buffer_object *bo,
1010
			struct ttm_placement *placement,
1030
			struct ttm_placement *placement,
-
 
1031
			bool interruptible,
Line 1011... Line 1032...
1011
			bool interruptible,
1032
			bool no_wait_gpu)
1012
			bool no_wait_gpu)
1033
{
1013
{
1034
	int ret;
1014
	int ret;
1035
	uint32_t new_flags;
1015
 
1036
 
1016
//	BUG_ON(!ttm_bo_is_reserved(bo));
1037
//	BUG_ON(!ttm_bo_is_reserved(bo));
1017
	/* Check that range is valid */
1038
	/* Check that range is valid */
1018
	if (placement->lpfn || placement->fpfn)
1039
	if (placement->lpfn || placement->fpfn)
1019
		if (placement->fpfn > placement->lpfn ||
1040
		if (placement->fpfn > placement->lpfn ||
1020
			(placement->lpfn - placement->fpfn) < bo->num_pages)
1041
			(placement->lpfn - placement->fpfn) < bo->num_pages)
1021
			return -EINVAL;
-
 
1022
	/*
1042
			return -EINVAL;
1023
	 * Check whether we need to move buffer.
1043
	/*
1024
	 */
1044
	 * Check whether we need to move buffer.
1025
	ret = ttm_bo_mem_compat(placement, &bo->mem);
1045
	 */
1026
	if (ret < 0) {
1046
	if (!ttm_bo_mem_compat(placement, &bo->mem, &new_flags)) {
1027
//       ret = ttm_bo_move_buffer(bo, placement, interruptible,
1047
//       ret = ttm_bo_move_buffer(bo, placement, interruptible,
1028
//                    no_wait_gpu);
1048
//                    no_wait_gpu);
1029
		if (ret)
1049
		if (ret)
1030
			return ret;
1050
			return ret;
1031
	} else {
1051
	} else {
1032
		/*
1052
		/*
1033
		 * Use the access and other non-mapping-related flag bits from
1053
		 * Use the access and other non-mapping-related flag bits from
1034
		 * the compatible memory placement flags to the active flags
1054
		 * the compatible memory placement flags to the active flags
1035
		 */
1055
		 */
1036
		ttm_flag_masked(&bo->mem.placement, placement->placement[ret],
1056
		ttm_flag_masked(&bo->mem.placement, new_flags,
Line 1101... Line 1121...
1101
	atomic_set(&bo->cpu_writers, 0);
1121
	atomic_set(&bo->cpu_writers, 0);
1102
	INIT_LIST_HEAD(&bo->lru);
1122
	INIT_LIST_HEAD(&bo->lru);
1103
	INIT_LIST_HEAD(&bo->ddestroy);
1123
	INIT_LIST_HEAD(&bo->ddestroy);
1104
	INIT_LIST_HEAD(&bo->swap);
1124
	INIT_LIST_HEAD(&bo->swap);
1105
	INIT_LIST_HEAD(&bo->io_reserve_lru);
1125
	INIT_LIST_HEAD(&bo->io_reserve_lru);
-
 
1126
	mutex_init(&bo->wu_mutex);
1106
	bo->bdev = bdev;
1127
	bo->bdev = bdev;
1107
	bo->glob = bdev->glob;
1128
	bo->glob = bdev->glob;
1108
	bo->type = type;
1129
	bo->type = type;
1109
	bo->num_pages = num_pages;
1130
	bo->num_pages = num_pages;
1110
	bo->mem.size = num_pages << PAGE_SHIFT;
1131
	bo->mem.size = num_pages << PAGE_SHIFT;
Line 1366... Line 1387...
1366
			return false;
1387
			return false;
1367
	}
1388
	}
1368
	return true;
1389
	return true;
1369
}
1390
}
Line -... Line 1391...
-
 
1391
 
-
 
1392
int ttm_bo_wait(struct ttm_buffer_object *bo,
-
 
1393
		bool lazy, bool interruptible, bool no_wait)
-
 
1394
{
-
 
1395
	struct ttm_bo_driver *driver = bo->bdev->driver;
-
 
1396
	struct ttm_bo_device *bdev = bo->bdev;
-
 
1397
	void *sync_obj;
-
 
1398
	int ret = 0;
-
 
1399
 
-
 
1400
	if (likely(bo->sync_obj == NULL))
-
 
1401
		return 0;
-
 
1402
 
-
 
1403
	return 0;
-
 
1404
}
-
 
1405
EXPORT_SYMBOL(ttm_bo_wait);
-
 
1406
 
-
 
1407
int ttm_bo_synccpu_write_grab(struct ttm_buffer_object *bo, bool no_wait)
-
 
1408
{
-
 
1409
	struct ttm_bo_device *bdev = bo->bdev;
-
 
1410
	int ret = 0;
-
 
1411
 
-
 
1412
	/*
-
 
1413
	 * Using ttm_bo_reserve makes sure the lru lists are updated.
-
 
1414
	 */
-
 
1415
 
-
 
1416
	return ret;
-
 
1417
}
-
 
1418
EXPORT_SYMBOL(ttm_bo_synccpu_write_grab);
-
 
1419
 
-
 
1420
void ttm_bo_synccpu_write_release(struct ttm_buffer_object *bo)
-
 
1421
{
-
 
1422
	atomic_dec(&bo->cpu_writers);
-
 
1423
}