0001
0002
0003 #include <drm/ttm/ttm_resource.h>
0004 #include <drm/ttm/ttm_device.h>
0005 #include <drm/ttm/ttm_placement.h>
0006 #include <linux/slab.h>
0007
0008 #include "ttm_module.h"
0009
0010 static int ttm_sys_man_alloc(struct ttm_resource_manager *man,
0011 struct ttm_buffer_object *bo,
0012 const struct ttm_place *place,
0013 struct ttm_resource **res)
0014 {
0015 *res = kzalloc(sizeof(**res), GFP_KERNEL);
0016 if (!*res)
0017 return -ENOMEM;
0018
0019 ttm_resource_init(bo, place, *res);
0020 return 0;
0021 }
0022
0023 static void ttm_sys_man_free(struct ttm_resource_manager *man,
0024 struct ttm_resource *res)
0025 {
0026 ttm_resource_fini(man, res);
0027 kfree(res);
0028 }
0029
0030 static const struct ttm_resource_manager_func ttm_sys_manager_func = {
0031 .alloc = ttm_sys_man_alloc,
0032 .free = ttm_sys_man_free,
0033 };
0034
0035 void ttm_sys_man_init(struct ttm_device *bdev)
0036 {
0037 struct ttm_resource_manager *man = &bdev->sysman;
0038
0039
0040
0041
0042
0043 man->use_tt = true;
0044 man->func = &ttm_sys_manager_func;
0045
0046 ttm_resource_manager_init(man, bdev, 0);
0047 ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, man);
0048 ttm_resource_manager_set_used(man, true);
0049 }