Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
0002 
0003 #ifndef _TTM_RANGE_MANAGER_H_
0004 #define _TTM_RANGE_MANAGER_H_
0005 
0006 #include <drm/ttm/ttm_resource.h>
0007 #include <drm/ttm/ttm_device.h>
0008 #include <drm/drm_mm.h>
0009 
0010 /**
0011  * struct ttm_range_mgr_node
0012  *
0013  * @base: base clase we extend
0014  * @mm_nodes: MM nodes, usually 1
0015  *
0016  * Extending the ttm_resource object to manage an address space allocation with
0017  * one or more drm_mm_nodes.
0018  */
0019 struct ttm_range_mgr_node {
0020     struct ttm_resource base;
0021     struct drm_mm_node mm_nodes[];
0022 };
0023 
0024 /**
0025  * to_ttm_range_mgr_node
0026  *
0027  * @res: the resource to upcast
0028  *
0029  * Upcast the ttm_resource object into a ttm_range_mgr_node object.
0030  */
0031 static inline struct ttm_range_mgr_node *
0032 to_ttm_range_mgr_node(struct ttm_resource *res)
0033 {
0034     return container_of(res, struct ttm_range_mgr_node, base);
0035 }
0036 
0037 int ttm_range_man_init_nocheck(struct ttm_device *bdev,
0038                unsigned type, bool use_tt,
0039                unsigned long p_size);
0040 int ttm_range_man_fini_nocheck(struct ttm_device *bdev,
0041                unsigned type);
0042 static __always_inline int ttm_range_man_init(struct ttm_device *bdev,
0043                unsigned int type, bool use_tt,
0044                unsigned long p_size)
0045 {
0046     BUILD_BUG_ON(__builtin_constant_p(type) && type >= TTM_NUM_MEM_TYPES);
0047     return ttm_range_man_init_nocheck(bdev, type, use_tt, p_size);
0048 }
0049 
0050 static __always_inline int ttm_range_man_fini(struct ttm_device *bdev,
0051                unsigned int type)
0052 {
0053     BUILD_BUG_ON(__builtin_constant_p(type) && type >= TTM_NUM_MEM_TYPES);
0054     return ttm_range_man_fini_nocheck(bdev, type);
0055 }
0056 #endif