Line data Source code
1 : /* SPDX-License-Identifier: GPL-2.0 OR MIT */ 2 : 3 : #include <drm/ttm/ttm_resource.h> 4 : #include <drm/ttm/ttm_device.h> 5 : #include <drm/ttm/ttm_placement.h> 6 : #include <linux/slab.h> 7 : 8 : #include "ttm_module.h" 9 : 10 0 : static int ttm_sys_man_alloc(struct ttm_resource_manager *man, 11 : struct ttm_buffer_object *bo, 12 : const struct ttm_place *place, 13 : struct ttm_resource **res) 14 : { 15 0 : *res = kzalloc(sizeof(**res), GFP_KERNEL); 16 0 : if (!*res) 17 : return -ENOMEM; 18 : 19 0 : ttm_resource_init(bo, place, *res); 20 0 : return 0; 21 : } 22 : 23 0 : static void ttm_sys_man_free(struct ttm_resource_manager *man, 24 : struct ttm_resource *res) 25 : { 26 0 : ttm_resource_fini(man, res); 27 0 : kfree(res); 28 0 : } 29 : 30 : static const struct ttm_resource_manager_func ttm_sys_manager_func = { 31 : .alloc = ttm_sys_man_alloc, 32 : .free = ttm_sys_man_free, 33 : }; 34 : 35 0 : void ttm_sys_man_init(struct ttm_device *bdev) 36 : { 37 0 : struct ttm_resource_manager *man = &bdev->sysman; 38 : 39 : /* 40 : * Initialize the system memory buffer type. 41 : * Other types need to be driver / IOCTL initialized. 42 : */ 43 0 : man->use_tt = true; 44 0 : man->func = &ttm_sys_manager_func; 45 : 46 0 : ttm_resource_manager_init(man, bdev, 0); 47 0 : ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, man); 48 0 : ttm_resource_manager_set_used(man, true); 49 0 : }