Lines Matching +full:use +full:- +full:guard +full:- +full:pages
1 // SPDX-License-Identifier: MIT
7 #include <linux/slab.h> /* fault-inject.h is not standalone! */
9 #include <linux/fault-inject.h>
28 struct sg_table *pages) in i915_gem_gtt_prepare_pages() argument
31 if (dma_map_sg_attrs(obj->base.dev->dev, in i915_gem_gtt_prepare_pages()
32 pages->sgl, pages->nents, in i915_gem_gtt_prepare_pages()
43 * try again - if there are no more pages to remove from in i915_gem_gtt_prepare_pages()
46 GEM_BUG_ON(obj->mm.pages == pages); in i915_gem_gtt_prepare_pages()
47 } while (i915_gem_shrink(NULL, to_i915(obj->base.dev), in i915_gem_gtt_prepare_pages()
48 obj->base.size >> PAGE_SHIFT, NULL, in i915_gem_gtt_prepare_pages()
52 return -ENOSPC; in i915_gem_gtt_prepare_pages()
56 struct sg_table *pages) in i915_gem_gtt_finish_pages() argument
58 struct drm_i915_private *i915 = to_i915(obj->base.dev); in i915_gem_gtt_finish_pages()
59 struct i915_ggtt *ggtt = to_gt(i915)->ggtt; in i915_gem_gtt_finish_pages()
62 if (unlikely(ggtt->do_idle_maps)) in i915_gem_gtt_finish_pages()
66 dma_unmap_sg(i915->drm.dev, pages->sgl, pages->nents, in i915_gem_gtt_finish_pages()
71 * i915_gem_gtt_reserve - reserve a node in an address_space (GTT)
87 * neighbouring nodes if the colors do not match (to ensure guard pages between
93 * Returns: 0 on success, -ENOSPC if no suitable hole is found, -EINTR if
107 GEM_BUG_ON(range_overflows(offset, size, vm->total)); in i915_gem_gtt_reserve()
108 GEM_BUG_ON(vm == &to_gt(vm->i915)->ggtt->alias->vm); in i915_gem_gtt_reserve()
111 node->size = size; in i915_gem_gtt_reserve()
112 node->start = offset; in i915_gem_gtt_reserve()
113 node->color = color; in i915_gem_gtt_reserve()
115 err = drm_mm_reserve_node(&vm->mm, node); in i915_gem_gtt_reserve()
116 if (err != -ENOSPC) in i915_gem_gtt_reserve()
120 return -ENOSPC; in i915_gem_gtt_reserve()
124 err = drm_mm_reserve_node(&vm->mm, node); in i915_gem_gtt_reserve()
134 GEM_BUG_ON(round_up(start, align) > round_down(end - len, align)); in random_offset()
136 range = round_down(end - len, align) - round_up(start, align); in random_offset()
155 * i915_gem_gtt_insert - insert a node into an address_space (GTT)
162 * if specified, this must be a power-of-two and at least
174 * nodes on either side of the hole must match @color, or else a guard page
180 * rebound before any future use). Any node that is currently pinned cannot
186 * Returns: 0 on success, -ENOSPC if no suitable hole is found, -EINTR if
199 lockdep_assert_held(&vm->mutex); in i915_gem_gtt_insert()
208 GEM_BUG_ON(vm == &to_gt(vm->i915)->ggtt->alias->vm); in i915_gem_gtt_insert()
212 return -ENOSPC; in i915_gem_gtt_insert()
214 if (unlikely(round_up(start, alignment) > round_down(end - size, alignment))) in i915_gem_gtt_insert()
215 return -ENOSPC; in i915_gem_gtt_insert()
226 * with zero alignment, so where possible use the optimal in i915_gem_gtt_insert()
233 err = drm_mm_insert_node_in_range(&vm->mm, node, in i915_gem_gtt_insert()
236 if (err != -ENOSPC) in i915_gem_gtt_insert()
240 err = drm_mm_insert_node_in_range(&vm->mm, node, in i915_gem_gtt_insert()
244 if (err != -ENOSPC) in i915_gem_gtt_insert()
249 return -ENOSPC; in i915_gem_gtt_insert()
255 * mmap and GPU (i.e. ggtt/aliasing_ppgtt but not full-ppgtt): in i915_gem_gtt_insert()
257 * |<-- 256 MiB aperture -->||<-- 1792 MiB unmappable -->| in i915_gem_gtt_insert()
260 * Now imagine that the eviction LRU is ordered top-down (just because in i915_gem_gtt_insert()
267 * On a full-ppgtt system, if we have run out of available space, there in i915_gem_gtt_insert()
277 if (err != -ENOSPC) in i915_gem_gtt_insert()
281 return -ENOSPC; in i915_gem_gtt_insert()
289 return drm_mm_insert_node_in_range(&vm->mm, node, in i915_gem_gtt_insert()