drm/i915: Drop address size from ppgtt_type
[linux-2.6-microblaze.git] / drivers / gpu / drm / i915 / intel_device_info.h
1 /*
2  * Copyright © 2014-2017 Intel Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  *
23  */
24
25 #ifndef _INTEL_DEVICE_INFO_H_
26 #define _INTEL_DEVICE_INFO_H_
27
28 #include <uapi/drm/i915_drm.h>
29
30 #include "intel_display.h"
31
32 struct drm_printer;
33 struct drm_i915_private;
34
35 /* Keep in gen based order, and chronological order within a gen */
36 enum intel_platform {
37         INTEL_PLATFORM_UNINITIALIZED = 0,
38         /* gen2 */
39         INTEL_I830,
40         INTEL_I845G,
41         INTEL_I85X,
42         INTEL_I865G,
43         /* gen3 */
44         INTEL_I915G,
45         INTEL_I915GM,
46         INTEL_I945G,
47         INTEL_I945GM,
48         INTEL_G33,
49         INTEL_PINEVIEW,
50         /* gen4 */
51         INTEL_I965G,
52         INTEL_I965GM,
53         INTEL_G45,
54         INTEL_GM45,
55         /* gen5 */
56         INTEL_IRONLAKE,
57         /* gen6 */
58         INTEL_SANDYBRIDGE,
59         /* gen7 */
60         INTEL_IVYBRIDGE,
61         INTEL_VALLEYVIEW,
62         INTEL_HASWELL,
63         /* gen8 */
64         INTEL_BROADWELL,
65         INTEL_CHERRYVIEW,
66         /* gen9 */
67         INTEL_SKYLAKE,
68         INTEL_BROXTON,
69         INTEL_KABYLAKE,
70         INTEL_GEMINILAKE,
71         INTEL_COFFEELAKE,
72         /* gen10 */
73         INTEL_CANNONLAKE,
74         /* gen11 */
75         INTEL_ICELAKE,
76         INTEL_MAX_PLATFORMS
77 };
78
79 enum intel_ppgtt_type {
80         INTEL_PPGTT_NONE = I915_GEM_PPGTT_NONE,
81         INTEL_PPGTT_ALIASING = I915_GEM_PPGTT_ALIASING,
82         INTEL_PPGTT_FULL = I915_GEM_PPGTT_FULL,
83 };
84
85 #define DEV_INFO_FOR_EACH_FLAG(func) \
86         func(is_mobile); \
87         func(is_lp); \
88         func(is_alpha_support); \
89         /* Keep has_* in alphabetical order */ \
90         func(has_64bit_reloc); \
91         func(gpu_reset_clobbers_display); \
92         func(has_reset_engine); \
93         func(has_fpga_dbg); \
94         func(has_guc); \
95         func(has_guc_ct); \
96         func(has_l3_dpf); \
97         func(has_llc); \
98         func(has_logical_ring_contexts); \
99         func(has_logical_ring_elsq); \
100         func(has_logical_ring_preemption); \
101         func(has_pooled_eu); \
102         func(has_rc6); \
103         func(has_rc6p); \
104         func(has_runtime_pm); \
105         func(has_snoop); \
106         func(has_coherent_ggtt); \
107         func(unfenced_needs_alignment); \
108         func(hws_needs_physical);
109
110 #define DEV_INFO_DISPLAY_FOR_EACH_FLAG(func) \
111         /* Keep in alphabetical order */ \
112         func(cursor_needs_physical); \
113         func(has_csr); \
114         func(has_ddi); \
115         func(has_dp_mst); \
116         func(has_fbc); \
117         func(has_gmch); \
118         func(has_hotplug); \
119         func(has_ipc); \
120         func(has_overlay); \
121         func(has_psr); \
122         func(overlay_needs_physical); \
123         func(supports_tv);
124
125 #define GEN_MAX_SLICES          (6) /* CNL upper bound */
126 #define GEN_MAX_SUBSLICES       (8) /* ICL upper bound */
127
128 struct sseu_dev_info {
129         u8 slice_mask;
130         u8 subslice_mask[GEN_MAX_SLICES];
131         u16 eu_total;
132         u8 eu_per_subslice;
133         u8 min_eu_in_pool;
134         /* For each slice, which subslice(s) has(have) 7 EUs (bitfield)? */
135         u8 subslice_7eu[3];
136         u8 has_slice_pg:1;
137         u8 has_subslice_pg:1;
138         u8 has_eu_pg:1;
139
140         /* Topology fields */
141         u8 max_slices;
142         u8 max_subslices;
143         u8 max_eus_per_subslice;
144
145         /* We don't have more than 8 eus per subslice at the moment and as we
146          * store eus enabled using bits, no need to multiply by eus per
147          * subslice.
148          */
149         u8 eu_mask[GEN_MAX_SLICES * GEN_MAX_SUBSLICES];
150 };
151
152 typedef u8 intel_engine_mask_t;
153
154 struct intel_device_info {
155         u16 gen_mask;
156
157         u8 gen;
158         u8 gt; /* GT number, 0 if undefined */
159         intel_engine_mask_t engine_mask; /* Engines supported by the HW */
160
161         enum intel_platform platform;
162         u32 platform_mask;
163
164         enum intel_ppgtt_type ppgtt_type;
165         unsigned int ppgtt_size; /* log2, e.g. 31/32/48 bits */
166
167         unsigned int page_sizes; /* page sizes supported by the HW */
168
169         u32 display_mmio_offset;
170
171         u8 num_pipes;
172
173 #define DEFINE_FLAG(name) u8 name:1
174         DEV_INFO_FOR_EACH_FLAG(DEFINE_FLAG);
175 #undef DEFINE_FLAG
176
177         struct {
178 #define DEFINE_FLAG(name) u8 name:1
179                 DEV_INFO_DISPLAY_FOR_EACH_FLAG(DEFINE_FLAG);
180 #undef DEFINE_FLAG
181         } display;
182
183         u16 ddb_size; /* in blocks */
184
185         /* Register offsets for the various display pipes and transcoders */
186         int pipe_offsets[I915_MAX_TRANSCODERS];
187         int trans_offsets[I915_MAX_TRANSCODERS];
188         int cursor_offsets[I915_MAX_PIPES];
189
190         struct color_luts {
191                 u16 degamma_lut_size;
192                 u16 gamma_lut_size;
193                 u32 degamma_lut_tests;
194                 u32 gamma_lut_tests;
195         } color;
196 };
197
198 struct intel_runtime_info {
199         u16 device_id;
200
201         u8 num_sprites[I915_MAX_PIPES];
202         u8 num_scalers[I915_MAX_PIPES];
203
204         u8 num_engines;
205
206         /* Slice/subslice/EU info */
207         struct sseu_dev_info sseu;
208
209         u32 cs_timestamp_frequency_khz;
210
211         /* Enabled (not fused off) media engine bitmasks. */
212         u8 vdbox_enable;
213         u8 vebox_enable;
214
215         /* Media engine access to SFC per instance */
216         u8 vdbox_sfc_access;
217 };
218
219 struct intel_driver_caps {
220         unsigned int scheduler;
221         bool has_logical_contexts:1;
222 };
223
224 static inline unsigned int sseu_subslice_total(const struct sseu_dev_info *sseu)
225 {
226         unsigned int i, total = 0;
227
228         for (i = 0; i < ARRAY_SIZE(sseu->subslice_mask); i++)
229                 total += hweight8(sseu->subslice_mask[i]);
230
231         return total;
232 }
233
234 static inline int sseu_eu_idx(const struct sseu_dev_info *sseu,
235                               int slice, int subslice)
236 {
237         int subslice_stride = DIV_ROUND_UP(sseu->max_eus_per_subslice,
238                                            BITS_PER_BYTE);
239         int slice_stride = sseu->max_subslices * subslice_stride;
240
241         return slice * slice_stride + subslice * subslice_stride;
242 }
243
244 static inline u16 sseu_get_eus(const struct sseu_dev_info *sseu,
245                                int slice, int subslice)
246 {
247         int i, offset = sseu_eu_idx(sseu, slice, subslice);
248         u16 eu_mask = 0;
249
250         for (i = 0;
251              i < DIV_ROUND_UP(sseu->max_eus_per_subslice, BITS_PER_BYTE); i++) {
252                 eu_mask |= ((u16) sseu->eu_mask[offset + i]) <<
253                         (i * BITS_PER_BYTE);
254         }
255
256         return eu_mask;
257 }
258
259 static inline void sseu_set_eus(struct sseu_dev_info *sseu,
260                                 int slice, int subslice, u16 eu_mask)
261 {
262         int i, offset = sseu_eu_idx(sseu, slice, subslice);
263
264         for (i = 0;
265              i < DIV_ROUND_UP(sseu->max_eus_per_subslice, BITS_PER_BYTE); i++) {
266                 sseu->eu_mask[offset + i] =
267                         (eu_mask >> (BITS_PER_BYTE * i)) & 0xff;
268         }
269 }
270
271 const char *intel_platform_name(enum intel_platform platform);
272
273 void intel_device_info_runtime_init(struct drm_i915_private *dev_priv);
274 void intel_device_info_dump_flags(const struct intel_device_info *info,
275                                   struct drm_printer *p);
276 void intel_device_info_dump_runtime(const struct intel_runtime_info *info,
277                                     struct drm_printer *p);
278 void intel_device_info_dump_topology(const struct sseu_dev_info *sseu,
279                                      struct drm_printer *p);
280
281 void intel_device_info_init_mmio(struct drm_i915_private *dev_priv);
282
283 void intel_driver_caps_print(const struct intel_driver_caps *caps,
284                              struct drm_printer *p);
285
286 #endif