1 /* SPDX-License-Identifier: MIT */
3 * Copyright © 2021 Intel Corporation
6 #ifndef __I915_TTM_BUDDY_MANAGER_H__
7 #define __I915_TTM_BUDDY_MANAGER_H__
9 #include <linux/list.h>
10 #include <linux/types.h>
12 #include <drm/ttm/ttm_resource.h>
15 struct ttm_resource_manager;
19 * struct i915_ttm_buddy_resource
21 * @base: struct ttm_resource base class we extend
22 * @blocks: the list of struct i915_buddy_block for this resource/allocation
23 * @mm: the struct i915_buddy_mm for this resource
25 * Extends the struct ttm_resource to manage an address space allocation with
26 * one or more struct i915_buddy_block.
28 struct i915_ttm_buddy_resource {
29 struct ttm_resource base;
30 struct list_head blocks;
31 struct i915_buddy_mm *mm;
35 * to_ttm_buddy_resource
37 * @res: the resource to upcast
39 * Upcast the struct ttm_resource object into a struct i915_ttm_buddy_resource.
41 static inline struct i915_ttm_buddy_resource *
42 to_ttm_buddy_resource(struct ttm_resource *res)
44 return container_of(res, struct i915_ttm_buddy_resource, base);
47 int i915_ttm_buddy_man_init(struct ttm_device *bdev,
48 unsigned type, bool use_tt,
49 u64 size, u64 default_page_size, u64 chunk_size);
50 int i915_ttm_buddy_man_fini(struct ttm_device *bdev,
53 int i915_ttm_buddy_man_reserve(struct ttm_resource_manager *man,