0001
0002
0003
0004
0005 #ifndef _I915_GEM_TTM_H_
0006 #define _I915_GEM_TTM_H_
0007
0008 #include <drm/ttm/ttm_placement.h>
0009
0010 #include "gem/i915_gem_object_types.h"
0011
0012
0013
0014
0015
0016
0017
0018
0019 static inline struct ttm_buffer_object *
0020 i915_gem_to_ttm(struct drm_i915_gem_object *obj)
0021 {
0022 return &obj->__do_not_access;
0023 }
0024
0025
0026
0027
0028 void i915_ttm_bo_destroy(struct ttm_buffer_object *bo);
0029
0030
0031
0032
0033
0034
0035
0036
0037 static inline struct drm_i915_gem_object *
0038 i915_ttm_to_gem(struct ttm_buffer_object *bo)
0039 {
0040 if (bo->destroy != i915_ttm_bo_destroy)
0041 return NULL;
0042
0043 return container_of(bo, struct drm_i915_gem_object, __do_not_access);
0044 }
0045
0046 int __i915_gem_ttm_object_init(struct intel_memory_region *mem,
0047 struct drm_i915_gem_object *obj,
0048 resource_size_t offset,
0049 resource_size_t size,
0050 resource_size_t page_size,
0051 unsigned int flags);
0052
0053
0054
0055 #define I915_PL_LMEM0 TTM_PL_PRIV
0056 #define I915_PL_SYSTEM TTM_PL_SYSTEM
0057 #define I915_PL_STOLEN TTM_PL_VRAM
0058 #define I915_PL_GGTT TTM_PL_TT
0059
0060 struct ttm_placement *i915_ttm_sys_placement(void);
0061
0062 void i915_ttm_free_cached_io_rsgt(struct drm_i915_gem_object *obj);
0063
0064 struct i915_refct_sgt *
0065 i915_ttm_resource_get_st(struct drm_i915_gem_object *obj,
0066 struct ttm_resource *res);
0067
0068 void i915_ttm_adjust_lru(struct drm_i915_gem_object *obj);
0069
0070 int i915_ttm_purge(struct drm_i915_gem_object *obj);
0071
0072
0073
0074
0075
0076
0077
0078
0079 static inline bool i915_ttm_gtt_binds_lmem(struct ttm_resource *mem)
0080 {
0081 return mem->mem_type != I915_PL_SYSTEM;
0082 }
0083
0084
0085
0086
0087
0088
0089
0090 static inline bool i915_ttm_cpu_maps_iomem(struct ttm_resource *mem)
0091 {
0092
0093 return mem->mem_type != I915_PL_SYSTEM;
0094 }
0095
0096 bool i915_ttm_resource_mappable(struct ttm_resource *res);
0097
0098 #endif