Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: MIT */
0002 /*
0003  * Copyright © 2020 Intel Corporation
0004  */
0005 
0006 #ifndef __GEN6_PPGTT_H__
0007 #define __GEN6_PPGTT_H__
0008 
0009 #include "intel_gtt.h"
0010 
0011 struct i915_gem_ww_ctx;
0012 
0013 struct gen6_ppgtt {
0014     struct i915_ppgtt base;
0015 
0016     struct mutex flush;
0017     struct i915_vma *vma;
0018     gen6_pte_t __iomem *pd_addr;
0019     u32 pp_dir;
0020 
0021     atomic_t pin_count;
0022 
0023     bool scan_for_unused_pt;
0024 };
0025 
0026 static inline u32 gen6_pte_index(u32 addr)
0027 {
0028     return i915_pte_index(addr, GEN6_PDE_SHIFT);
0029 }
0030 
0031 static inline u32 gen6_pte_count(u32 addr, u32 length)
0032 {
0033     return i915_pte_count(addr, length, GEN6_PDE_SHIFT);
0034 }
0035 
0036 static inline u32 gen6_pde_index(u32 addr)
0037 {
0038     return i915_pde_index(addr, GEN6_PDE_SHIFT);
0039 }
0040 
0041 #define __to_gen6_ppgtt(base) container_of(base, struct gen6_ppgtt, base)
0042 
0043 static inline struct gen6_ppgtt *to_gen6_ppgtt(struct i915_ppgtt *base)
0044 {
0045     BUILD_BUG_ON(offsetof(struct gen6_ppgtt, base));
0046     return __to_gen6_ppgtt(base);
0047 }
0048 
0049 /*
0050  * gen6_for_each_pde() iterates over every pde from start until start+length.
0051  * If start and start+length are not perfectly divisible, the macro will round
0052  * down and up as needed. Start=0 and length=2G effectively iterates over
0053  * every PDE in the system. The macro modifies ALL its parameters except 'pd',
0054  * so each of the other parameters should preferably be a simple variable, or
0055  * at most an lvalue with no side-effects!
0056  */
0057 #define gen6_for_each_pde(pt, pd, start, length, iter)          \
0058     for (iter = gen6_pde_index(start);              \
0059          length > 0 && iter < I915_PDES &&              \
0060              (pt = i915_pt_entry(pd, iter), true);      \
0061          ({ u32 temp = ALIGN(start + 1, 1 << GEN6_PDE_SHIFT);   \
0062             temp = min(temp - start, length);           \
0063             start += temp; length -= temp; }), ++iter)
0064 
0065 #define gen6_for_all_pdes(pt, pd, iter)                 \
0066     for (iter = 0;                          \
0067          iter < I915_PDES &&                    \
0068              (pt = i915_pt_entry(pd, iter), true);      \
0069          ++iter)
0070 
0071 int gen6_ppgtt_pin(struct i915_ppgtt *base, struct i915_gem_ww_ctx *ww);
0072 void gen6_ppgtt_unpin(struct i915_ppgtt *base);
0073 void gen6_ppgtt_enable(struct intel_gt *gt);
0074 void gen7_ppgtt_enable(struct intel_gt *gt);
0075 struct i915_ppgtt *gen6_ppgtt_create(struct intel_gt *gt);
0076 
0077 #endif