Lines Matching +full:memory +full:- +full:region

1 // SPDX-License-Identifier: MIT
19 * The code in this file deals with setting up memory managers for TTM
22 * i915 GEM regions to TTM memory types and resource managers.
26 * intel_region_ttm_device_init - Initialize a TTM device
33 struct drm_device *drm = &dev_priv->drm; in intel_region_ttm_device_init()
35 return ttm_device_init(&dev_priv->bdev, i915_ttm_driver(), in intel_region_ttm_device_init()
36 drm->dev, drm->anon_inode->i_mapping, in intel_region_ttm_device_init()
37 drm->vma_offset_manager, false, false); in intel_region_ttm_device_init()
41 * intel_region_ttm_device_fini - Finalize a TTM device
46 ttm_device_fini(&dev_priv->bdev); in intel_region_ttm_device_fini()
50 * Map the i915 memory regions to TTM memory types. We use the
51 * driver-private types for now, reserving TTM_PL_VRAM for stolen
52 * memory and TTM_PL_TT for GGTT use if decided to implement this.
58 GEM_BUG_ON(mem->type != INTEL_MEMORY_LOCAL && in intel_region_to_ttm_type()
59 mem->type != INTEL_MEMORY_MOCK && in intel_region_to_ttm_type()
60 mem->type != INTEL_MEMORY_SYSTEM); in intel_region_to_ttm_type()
62 if (mem->type == INTEL_MEMORY_SYSTEM) in intel_region_to_ttm_type()
65 type = mem->instance + TTM_PL_PRIV; in intel_region_to_ttm_type()
72 * intel_region_ttm_init - Initialize a memory region for TTM.
73 * @mem: The region to initialize.
76 * region, and if it's a LMEM region type, attaches it to the TTM
84 struct ttm_device *bdev = &mem->i915->bdev; in intel_region_ttm_init()
89 resource_size(&mem->region), in intel_region_ttm_init()
90 mem->min_page_size, PAGE_SIZE); in intel_region_ttm_init()
94 mem->region_private = ttm_manager_type(bdev, mem_type); in intel_region_ttm_init()
100 * intel_region_ttm_fini - Finalize a TTM region.
101 * @mem: The memory region
104 * memory region, and if it was registered with the TTM device,
111 ret = i915_ttm_buddy_man_fini(&mem->i915->bdev, in intel_region_ttm_fini()
114 mem->region_private = NULL; in intel_region_ttm_fini()
118 * intel_region_ttm_resource_to_st - Convert an opaque TTM resource manager resource
120 * @mem: The memory region.
123 * The gem backends typically use sg-tables for operations on the underlying
125 * nodes they are handed from TTM to sg-tables.
132 if (mem->is_range_manager) { in intel_region_ttm_resource_to_st()
136 return i915_sg_from_mm_node(&range_node->mm_nodes[0], in intel_region_ttm_resource_to_st()
137 mem->region.start); in intel_region_ttm_resource_to_st()
139 return i915_sg_from_buddy_resource(res, mem->region.start); in intel_region_ttm_resource_to_st()
145 * intel_region_ttm_resource_alloc - Allocate memory resources from a region
146 * @mem: The memory region,
151 * memory from standalone TTM range managers, without the TTM eviction
164 struct ttm_resource_manager *man = mem->region_private; in intel_region_ttm_resource_alloc()
173 ret = man->func->alloc(man, &mock_bo, &place, &res); in intel_region_ttm_resource_alloc()
174 if (ret == -ENOSPC) in intel_region_ttm_resource_alloc()
175 ret = -ENXIO; in intel_region_ttm_resource_alloc()
182 * intel_region_ttm_resource_free - Free a resource allocated from a resource manager
183 * @mem: The region the resource was allocated from.
189 struct ttm_resource_manager *man = mem->region_private; in intel_region_ttm_resource_free()
191 man->func->free(man, res); in intel_region_ttm_resource_free()