1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
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>
8 #include "ttm_module.h"
10 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)
15 *res = kzalloc(sizeof(**res), GFP_KERNEL);
19 ttm_resource_init(bo, place, *res);
23 static void ttm_sys_man_free(struct ttm_resource_manager *man,
24 struct ttm_resource *res)
26 ttm_resource_fini(man, res);
30 static const struct ttm_resource_manager_func ttm_sys_manager_func = {
31 .alloc = ttm_sys_man_alloc,
32 .free = ttm_sys_man_free,
35 void ttm_sys_man_init(struct ttm_device *bdev)
37 struct ttm_resource_manager *man = &bdev->sysman;
40 * Initialize the system memory buffer type.
41 * Other types need to be driver / IOCTL initialized.
44 man->func = &ttm_sys_manager_func;
46 ttm_resource_manager_init(man, bdev, 0);
47 ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, man);
48 ttm_resource_manager_set_used(man, true);