1 /* SPDX-License-Identifier: MIT */ 2 /* 3 * Copyright © 2021 Intel Corporation 4 */ 5 6 #ifndef __I915_TTM_BUDDY_MANAGER_H__ 7 #define __I915_TTM_BUDDY_MANAGER_H__ 8 9 #include <linux/list.h> 10 #include <linux/types.h> 11 12 #include <drm/ttm/ttm_resource.h> 13 14 struct ttm_device; 15 struct ttm_resource_manager; 16 struct drm_buddy; 17 18 /** 19 * struct i915_ttm_buddy_resource 20 * 21 * @base: struct ttm_resource base class we extend 22 * @blocks: the list of struct i915_buddy_block for this resource/allocation 23 * @flags: DRM_BUDDY_*_ALLOCATION flags 24 * @mm: the struct i915_buddy_mm for this resource 25 * 26 * Extends the struct ttm_resource to manage an address space allocation with 27 * one or more struct i915_buddy_block. 28 */ 29 struct i915_ttm_buddy_resource { 30 struct ttm_resource base; 31 struct list_head blocks; 32 unsigned long flags; 33 struct drm_buddy *mm; 34 }; 35 36 /** 37 * to_ttm_buddy_resource 38 * 39 * @res: the resource to upcast 40 * 41 * Upcast the struct ttm_resource object into a struct i915_ttm_buddy_resource. 42 */ 43 static inline struct i915_ttm_buddy_resource * 44 to_ttm_buddy_resource(struct ttm_resource *res) 45 { 46 return container_of(res, struct i915_ttm_buddy_resource, base); 47 } 48 49 int i915_ttm_buddy_man_init(struct ttm_device *bdev, 50 unsigned type, bool use_tt, 51 u64 size, u64 default_page_size, u64 chunk_size); 52 int i915_ttm_buddy_man_fini(struct ttm_device *bdev, 53 unsigned int type); 54 55 int i915_ttm_buddy_man_reserve(struct ttm_resource_manager *man, 56 u64 start, u64 size); 57 58 #endif 59