162306a36Sopenharmony_ci/* SPDX-License-Identifier: MIT */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright © 2020 Intel Corporation
462306a36Sopenharmony_ci */
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci#ifndef __I915_GEM_GTT_H__
762306a36Sopenharmony_ci#define __I915_GEM_GTT_H__
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#include <linux/io-mapping.h>
1062306a36Sopenharmony_ci#include <linux/types.h>
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#include <drm/drm_mm.h>
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci#include "gt/intel_gtt.h"
1562306a36Sopenharmony_ci#include "i915_scatterlist.h"
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_cistruct drm_i915_gem_object;
1862306a36Sopenharmony_cistruct i915_address_space;
1962306a36Sopenharmony_cistruct i915_gem_ww_ctx;
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci#define I915_COLOR_UNEVICTABLE (-1) /* a non-vma sharing the address space */
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ciint __must_check i915_gem_gtt_prepare_pages(struct drm_i915_gem_object *obj,
2462306a36Sopenharmony_ci					    struct sg_table *pages);
2562306a36Sopenharmony_civoid i915_gem_gtt_finish_pages(struct drm_i915_gem_object *obj,
2662306a36Sopenharmony_ci			       struct sg_table *pages);
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ciint i915_gem_gtt_reserve(struct i915_address_space *vm,
2962306a36Sopenharmony_ci			 struct i915_gem_ww_ctx *ww,
3062306a36Sopenharmony_ci			 struct drm_mm_node *node,
3162306a36Sopenharmony_ci			 u64 size, u64 offset, unsigned long color,
3262306a36Sopenharmony_ci			 unsigned int flags);
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ciint i915_gem_gtt_insert(struct i915_address_space *vm,
3562306a36Sopenharmony_ci			struct i915_gem_ww_ctx *ww,
3662306a36Sopenharmony_ci			struct drm_mm_node *node,
3762306a36Sopenharmony_ci			u64 size, u64 alignment, unsigned long color,
3862306a36Sopenharmony_ci			u64 start, u64 end, unsigned int flags);
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci/* Flags used by pin/bind&friends. */
4162306a36Sopenharmony_ci#define PIN_NOEVICT		BIT_ULL(0)
4262306a36Sopenharmony_ci#define PIN_NOSEARCH		BIT_ULL(1)
4362306a36Sopenharmony_ci#define PIN_NONBLOCK		BIT_ULL(2)
4462306a36Sopenharmony_ci#define PIN_MAPPABLE		BIT_ULL(3)
4562306a36Sopenharmony_ci#define PIN_ZONE_4G		BIT_ULL(4)
4662306a36Sopenharmony_ci#define PIN_HIGH		BIT_ULL(5)
4762306a36Sopenharmony_ci#define PIN_OFFSET_BIAS		BIT_ULL(6)
4862306a36Sopenharmony_ci#define PIN_OFFSET_FIXED	BIT_ULL(7)
4962306a36Sopenharmony_ci#define PIN_OFFSET_GUARD	BIT_ULL(8)
5062306a36Sopenharmony_ci#define PIN_VALIDATE		BIT_ULL(9) /* validate placement only, no need to call unpin() */
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci#define PIN_GLOBAL		BIT_ULL(10) /* I915_VMA_GLOBAL_BIND */
5362306a36Sopenharmony_ci#define PIN_USER		BIT_ULL(11) /* I915_VMA_LOCAL_BIND */
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci#define PIN_OFFSET_MASK		I915_GTT_PAGE_MASK
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci#endif
58