Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: MIT */
0002 /*
0003  * Copyright © 2021 Intel Corporation
0004  */
0005 
0006 #ifndef __I915_TTM_BUDDY_MANAGER_H__
0007 #define __I915_TTM_BUDDY_MANAGER_H__
0008 
0009 #include <linux/list.h>
0010 #include <linux/types.h>
0011 
0012 #include <drm/ttm/ttm_resource.h>
0013 
0014 struct ttm_device;
0015 struct ttm_resource_manager;
0016 struct drm_buddy;
0017 
0018 /**
0019  * struct i915_ttm_buddy_resource
0020  *
0021  * @base: struct ttm_resource base class we extend
0022  * @blocks: the list of struct i915_buddy_block for this resource/allocation
0023  * @flags: DRM_BUDDY_*_ALLOCATION flags
0024  * @used_visible_size: How much of this resource, if any, uses the CPU visible
0025  * portion, in pages.
0026  * @mm: the struct i915_buddy_mm for this resource
0027  *
0028  * Extends the struct ttm_resource to manage an address space allocation with
0029  * one or more struct i915_buddy_block.
0030  */
0031 struct i915_ttm_buddy_resource {
0032     struct ttm_resource base;
0033     struct list_head blocks;
0034     unsigned long flags;
0035     unsigned long used_visible_size;
0036     struct drm_buddy *mm;
0037 };
0038 
0039 /**
0040  * to_ttm_buddy_resource
0041  *
0042  * @res: the resource to upcast
0043  *
0044  * Upcast the struct ttm_resource object into a struct i915_ttm_buddy_resource.
0045  */
0046 static inline struct i915_ttm_buddy_resource *
0047 to_ttm_buddy_resource(struct ttm_resource *res)
0048 {
0049     return container_of(res, struct i915_ttm_buddy_resource, base);
0050 }
0051 
0052 int i915_ttm_buddy_man_init(struct ttm_device *bdev,
0053                 unsigned type, bool use_tt,
0054                 u64 size, u64 visible_size,
0055                 u64 default_page_size, u64 chunk_size);
0056 int i915_ttm_buddy_man_fini(struct ttm_device *bdev,
0057                 unsigned int type);
0058 
0059 int i915_ttm_buddy_man_reserve(struct ttm_resource_manager *man,
0060                    u64 start, u64 size);
0061 
0062 u64 i915_ttm_buddy_man_visible_size(struct ttm_resource_manager *man);
0063 
0064 void i915_ttm_buddy_man_avail(struct ttm_resource_manager *man,
0065                   u64 *avail, u64 *avail_visible);
0066 
0067 #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
0068 void i915_ttm_buddy_man_force_visible_size(struct ttm_resource_manager *man,
0069                        u64 size);
0070 #endif
0071 
0072 #endif