1bf215546Sopenharmony_ci /*
2bf215546Sopenharmony_ci  * Copyright © 2013 Intel Corporation
3bf215546Sopenharmony_ci  *
4bf215546Sopenharmony_ci  * Permission is hereby granted, free of charge, to any person obtaining a
5bf215546Sopenharmony_ci  * copy of this software and associated documentation files (the "Software"),
6bf215546Sopenharmony_ci  * to deal in the Software without restriction, including without limitation
7bf215546Sopenharmony_ci  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8bf215546Sopenharmony_ci  * and/or sell copies of the Software, and to permit persons to whom the
9bf215546Sopenharmony_ci  * Software is furnished to do so, subject to the following conditions:
10bf215546Sopenharmony_ci  *
11bf215546Sopenharmony_ci  * The above copyright notice and this permission notice (including the next
12bf215546Sopenharmony_ci  * paragraph) shall be included in all copies or substantial portions of the
13bf215546Sopenharmony_ci  * Software.
14bf215546Sopenharmony_ci  *
15bf215546Sopenharmony_ci  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16bf215546Sopenharmony_ci  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17bf215546Sopenharmony_ci  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18bf215546Sopenharmony_ci  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19bf215546Sopenharmony_ci  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20bf215546Sopenharmony_ci  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21bf215546Sopenharmony_ci  * IN THE SOFTWARE.
22bf215546Sopenharmony_ci  *
23bf215546Sopenharmony_ci  */
24bf215546Sopenharmony_ci
25bf215546Sopenharmony_ci#ifndef INTEL_DEVICE_INFO_H
26bf215546Sopenharmony_ci#define INTEL_DEVICE_INFO_H
27bf215546Sopenharmony_ci
28bf215546Sopenharmony_ci#include <stdbool.h>
29bf215546Sopenharmony_ci#include <stdint.h>
30bf215546Sopenharmony_ci
31bf215546Sopenharmony_ci#include "util/macros.h"
32bf215546Sopenharmony_ci#include "compiler/shader_enums.h"
33bf215546Sopenharmony_ci
34bf215546Sopenharmony_ci#ifdef __cplusplus
35bf215546Sopenharmony_ciextern "C" {
36bf215546Sopenharmony_ci#endif
37bf215546Sopenharmony_ci
38bf215546Sopenharmony_cistruct drm_i915_query_topology_info;
39bf215546Sopenharmony_ci
40bf215546Sopenharmony_ci#define INTEL_DEVICE_MAX_NAME_SIZE        64
41bf215546Sopenharmony_ci#define INTEL_DEVICE_MAX_SLICES           8
42bf215546Sopenharmony_ci#define INTEL_DEVICE_MAX_SUBSLICES        (8)  /* Maximum on gfx11 */
43bf215546Sopenharmony_ci#define INTEL_DEVICE_MAX_EUS_PER_SUBSLICE (16) /* Maximum on gfx12 */
44bf215546Sopenharmony_ci#define INTEL_DEVICE_MAX_PIXEL_PIPES      (16) /* Maximum on DG2 */
45bf215546Sopenharmony_ci
46bf215546Sopenharmony_ci#define INTEL_PLATFORM_GROUP_START(group, new_enum) \
47bf215546Sopenharmony_ci   new_enum, INTEL_PLATFORM_ ## group ## _START = new_enum
48bf215546Sopenharmony_ci#define INTEL_PLATFORM_GROUP_END(group, new_enum) \
49bf215546Sopenharmony_ci   new_enum, INTEL_PLATFORM_ ## group ## _END = new_enum
50bf215546Sopenharmony_ci
51bf215546Sopenharmony_cienum intel_platform {
52bf215546Sopenharmony_ci   INTEL_PLATFORM_GFX3 = 1,
53bf215546Sopenharmony_ci   INTEL_PLATFORM_I965,
54bf215546Sopenharmony_ci   INTEL_PLATFORM_ILK,
55bf215546Sopenharmony_ci   INTEL_PLATFORM_G4X,
56bf215546Sopenharmony_ci   INTEL_PLATFORM_SNB,
57bf215546Sopenharmony_ci   INTEL_PLATFORM_IVB,
58bf215546Sopenharmony_ci   INTEL_PLATFORM_BYT,
59bf215546Sopenharmony_ci   INTEL_PLATFORM_HSW,
60bf215546Sopenharmony_ci   INTEL_PLATFORM_BDW,
61bf215546Sopenharmony_ci   INTEL_PLATFORM_CHV,
62bf215546Sopenharmony_ci   INTEL_PLATFORM_SKL,
63bf215546Sopenharmony_ci   INTEL_PLATFORM_BXT,
64bf215546Sopenharmony_ci   INTEL_PLATFORM_KBL,
65bf215546Sopenharmony_ci   INTEL_PLATFORM_GLK,
66bf215546Sopenharmony_ci   INTEL_PLATFORM_CFL,
67bf215546Sopenharmony_ci   INTEL_PLATFORM_ICL,
68bf215546Sopenharmony_ci   INTEL_PLATFORM_EHL,
69bf215546Sopenharmony_ci   INTEL_PLATFORM_TGL,
70bf215546Sopenharmony_ci   INTEL_PLATFORM_RKL,
71bf215546Sopenharmony_ci   INTEL_PLATFORM_DG1,
72bf215546Sopenharmony_ci   INTEL_PLATFORM_ADL,
73bf215546Sopenharmony_ci   INTEL_PLATFORM_RPL,
74bf215546Sopenharmony_ci   INTEL_PLATFORM_GROUP_START(DG2, INTEL_PLATFORM_DG2_G10),
75bf215546Sopenharmony_ci   INTEL_PLATFORM_DG2_G11,
76bf215546Sopenharmony_ci   INTEL_PLATFORM_GROUP_END(DG2, INTEL_PLATFORM_DG2_G12),
77bf215546Sopenharmony_ci};
78bf215546Sopenharmony_ci
79bf215546Sopenharmony_ci#undef INTEL_PLATFORM_GROUP_START
80bf215546Sopenharmony_ci#undef INTEL_PLATFORM_GROUP_END
81bf215546Sopenharmony_ci
82bf215546Sopenharmony_ci#define intel_platform_in_range(platform, platform_range) \
83bf215546Sopenharmony_ci   (((platform) >= INTEL_PLATFORM_ ## platform_range ## _START) && \
84bf215546Sopenharmony_ci    ((platform) <= INTEL_PLATFORM_ ## platform_range ## _END))
85bf215546Sopenharmony_ci
86bf215546Sopenharmony_ci#define intel_device_info_is_dg2(devinfo) \
87bf215546Sopenharmony_ci   intel_platform_in_range((devinfo)->platform, DG2)
88bf215546Sopenharmony_ci
89bf215546Sopenharmony_ci/**
90bf215546Sopenharmony_ci * Intel hardware information and quirks
91bf215546Sopenharmony_ci */
92bf215546Sopenharmony_cistruct intel_device_info
93bf215546Sopenharmony_ci{
94bf215546Sopenharmony_ci   /* Driver internal numbers used to differentiate platforms. */
95bf215546Sopenharmony_ci   int ver;
96bf215546Sopenharmony_ci   int verx10;
97bf215546Sopenharmony_ci   int display_ver;
98bf215546Sopenharmony_ci
99bf215546Sopenharmony_ci   /**
100bf215546Sopenharmony_ci    * This revision is from ioctl (I915_PARAM_REVISION) unlike
101bf215546Sopenharmony_ci    * pci_revision_id from drm device. Its value is not always
102bf215546Sopenharmony_ci    * same as the pci_revision_id.
103bf215546Sopenharmony_ci    */
104bf215546Sopenharmony_ci   int revision;
105bf215546Sopenharmony_ci   int gt;
106bf215546Sopenharmony_ci
107bf215546Sopenharmony_ci   /* PCI info */
108bf215546Sopenharmony_ci   uint16_t pci_domain;
109bf215546Sopenharmony_ci   uint8_t pci_bus;
110bf215546Sopenharmony_ci   uint8_t pci_dev;
111bf215546Sopenharmony_ci   uint8_t pci_func;
112bf215546Sopenharmony_ci   uint16_t pci_device_id;
113bf215546Sopenharmony_ci   uint8_t pci_revision_id;
114bf215546Sopenharmony_ci
115bf215546Sopenharmony_ci   enum intel_platform platform;
116bf215546Sopenharmony_ci
117bf215546Sopenharmony_ci   bool has_hiz_and_separate_stencil;
118bf215546Sopenharmony_ci   bool must_use_separate_stencil;
119bf215546Sopenharmony_ci   bool has_sample_with_hiz;
120bf215546Sopenharmony_ci   bool has_bit6_swizzle;
121bf215546Sopenharmony_ci   bool has_llc;
122bf215546Sopenharmony_ci
123bf215546Sopenharmony_ci   bool has_pln;
124bf215546Sopenharmony_ci   bool has_64bit_float;
125bf215546Sopenharmony_ci   bool has_64bit_int;
126bf215546Sopenharmony_ci   bool has_integer_dword_mul;
127bf215546Sopenharmony_ci   bool has_compr4;
128bf215546Sopenharmony_ci   bool has_surface_tile_offset;
129bf215546Sopenharmony_ci   bool supports_simd16_3src;
130bf215546Sopenharmony_ci   bool disable_ccs_repack;
131bf215546Sopenharmony_ci
132bf215546Sopenharmony_ci   /**
133bf215546Sopenharmony_ci    * True if CCS uses a flat virtual address translation to a memory
134bf215546Sopenharmony_ci    * carve-out, rather than aux map translations, or additional surfaces.
135bf215546Sopenharmony_ci    */
136bf215546Sopenharmony_ci   bool has_flat_ccs;
137bf215546Sopenharmony_ci   bool has_aux_map;
138bf215546Sopenharmony_ci   bool has_tiling_uapi;
139bf215546Sopenharmony_ci   bool has_ray_tracing;
140bf215546Sopenharmony_ci   bool has_ray_query;
141bf215546Sopenharmony_ci   bool has_local_mem;
142bf215546Sopenharmony_ci   bool has_lsc;
143bf215546Sopenharmony_ci   bool has_mesh_shading;
144bf215546Sopenharmony_ci
145bf215546Sopenharmony_ci   /**
146bf215546Sopenharmony_ci    * \name Intel hardware quirks
147bf215546Sopenharmony_ci    *  @{
148bf215546Sopenharmony_ci    */
149bf215546Sopenharmony_ci   bool has_negative_rhw_bug;
150bf215546Sopenharmony_ci
151bf215546Sopenharmony_ci   /**
152bf215546Sopenharmony_ci    * Whether this platform supports fragment shading rate controlled by a
153bf215546Sopenharmony_ci    * primitive in geometry shaders and by a control buffer.
154bf215546Sopenharmony_ci    */
155bf215546Sopenharmony_ci   bool has_coarse_pixel_primitive_and_cb;
156bf215546Sopenharmony_ci
157bf215546Sopenharmony_ci   /**
158bf215546Sopenharmony_ci    * Some versions of Gen hardware don't do centroid interpolation correctly
159bf215546Sopenharmony_ci    * on unlit pixels, causing incorrect values for derivatives near triangle
160bf215546Sopenharmony_ci    * edges.  Enabling this flag causes the fragment shader to use
161bf215546Sopenharmony_ci    * non-centroid interpolation for unlit pixels, at the expense of two extra
162bf215546Sopenharmony_ci    * fragment shader instructions.
163bf215546Sopenharmony_ci    */
164bf215546Sopenharmony_ci   bool needs_unlit_centroid_workaround;
165bf215546Sopenharmony_ci   /** @} */
166bf215546Sopenharmony_ci
167bf215546Sopenharmony_ci   /**
168bf215546Sopenharmony_ci    * \name GPU hardware limits
169bf215546Sopenharmony_ci    *
170bf215546Sopenharmony_ci    * In general, you can find shader thread maximums by looking at the "Maximum
171bf215546Sopenharmony_ci    * Number of Threads" field in the Intel PRM description of the 3DSTATE_VS,
172bf215546Sopenharmony_ci    * 3DSTATE_GS, 3DSTATE_HS, 3DSTATE_DS, and 3DSTATE_PS commands. URB entry
173bf215546Sopenharmony_ci    * limits come from the "Number of URB Entries" field in the
174bf215546Sopenharmony_ci    * 3DSTATE_URB_VS command and friends.
175bf215546Sopenharmony_ci    *
176bf215546Sopenharmony_ci    * These fields are used to calculate the scratch space to allocate.  The
177bf215546Sopenharmony_ci    * amount of scratch space can be larger without being harmful on modern
178bf215546Sopenharmony_ci    * GPUs, however, prior to Haswell, programming the maximum number of threads
179bf215546Sopenharmony_ci    * to greater than the hardware maximum would cause GPU performance to tank.
180bf215546Sopenharmony_ci    *
181bf215546Sopenharmony_ci    *  @{
182bf215546Sopenharmony_ci    */
183bf215546Sopenharmony_ci   /**
184bf215546Sopenharmony_ci    * Total number of slices present on the device whether or not they've been
185bf215546Sopenharmony_ci    * fused off.
186bf215546Sopenharmony_ci    *
187bf215546Sopenharmony_ci    * XXX: CS thread counts are limited by the inability to do cross subslice
188bf215546Sopenharmony_ci    * communication. It is the effectively the number of logical threads which
189bf215546Sopenharmony_ci    * can be executed in a subslice. Fuse configurations may cause this number
190bf215546Sopenharmony_ci    * to change, so we program @max_cs_threads as the lower maximum.
191bf215546Sopenharmony_ci    */
192bf215546Sopenharmony_ci   unsigned num_slices;
193bf215546Sopenharmony_ci
194bf215546Sopenharmony_ci   /**
195bf215546Sopenharmony_ci    * Maximum number of slices present on this device (can be more than
196bf215546Sopenharmony_ci    * num_slices if some slices are fused).
197bf215546Sopenharmony_ci    */
198bf215546Sopenharmony_ci   unsigned max_slices;
199bf215546Sopenharmony_ci
200bf215546Sopenharmony_ci   /**
201bf215546Sopenharmony_ci    * Number of subslices for each slice (used to be uniform until CNL).
202bf215546Sopenharmony_ci    */
203bf215546Sopenharmony_ci   unsigned num_subslices[INTEL_DEVICE_MAX_SLICES];
204bf215546Sopenharmony_ci
205bf215546Sopenharmony_ci   /**
206bf215546Sopenharmony_ci    * Maximum number of subslices per slice present on this device (can be
207bf215546Sopenharmony_ci    * more than the maximum value in the num_subslices[] array if some
208bf215546Sopenharmony_ci    * subslices are fused).
209bf215546Sopenharmony_ci    */
210bf215546Sopenharmony_ci   unsigned max_subslices_per_slice;
211bf215546Sopenharmony_ci
212bf215546Sopenharmony_ci   /**
213bf215546Sopenharmony_ci    * Maximum number of subslices per slice present on this device (can be
214bf215546Sopenharmony_ci    * more than the maximum value in the num_subslices[] array if some
215bf215546Sopenharmony_ci    * subslices are fused).
216bf215546Sopenharmony_ci    */
217bf215546Sopenharmony_ci   unsigned max_subslices_per_slice;
218bf215546Sopenharmony_ci
219bf215546Sopenharmony_ci   /**
220bf215546Sopenharmony_ci    * Number of subslices on each pixel pipe (ICL).
221bf215546Sopenharmony_ci    */
222bf215546Sopenharmony_ci   unsigned ppipe_subslices[INTEL_DEVICE_MAX_PIXEL_PIPES];
223bf215546Sopenharmony_ci
224bf215546Sopenharmony_ci   /**
225bf215546Sopenharmony_ci    * Maximum number of EUs per subslice (some EUs can be fused off).
226bf215546Sopenharmony_ci    */
227bf215546Sopenharmony_ci   unsigned max_eus_per_subslice;
228bf215546Sopenharmony_ci
229bf215546Sopenharmony_ci   /**
230bf215546Sopenharmony_ci    * Maximum number of EUs per subslice (can be more than num_eu_per_subslice
231bf215546Sopenharmony_ci    * if some EUs are fused off).
232bf215546Sopenharmony_ci    */
233bf215546Sopenharmony_ci   unsigned max_eu_per_subslice;
234bf215546Sopenharmony_ci
235bf215546Sopenharmony_ci   /**
236bf215546Sopenharmony_ci    * Number of threads per eu, varies between 4 and 8 between generations.
237bf215546Sopenharmony_ci    */
238bf215546Sopenharmony_ci   unsigned num_thread_per_eu;
239bf215546Sopenharmony_ci
240bf215546Sopenharmony_ci   /**
241bf215546Sopenharmony_ci    * A bit mask of the slices available.
242bf215546Sopenharmony_ci    */
243bf215546Sopenharmony_ci   uint8_t slice_masks;
244bf215546Sopenharmony_ci
245bf215546Sopenharmony_ci   /**
246bf215546Sopenharmony_ci    * An array of bit mask of the subslices available, use subslice_slice_stride
247bf215546Sopenharmony_ci    * to access this array.
248bf215546Sopenharmony_ci    */
249bf215546Sopenharmony_ci   uint8_t subslice_masks[INTEL_DEVICE_MAX_SLICES *
250bf215546Sopenharmony_ci                          DIV_ROUND_UP(INTEL_DEVICE_MAX_SUBSLICES, 8)];
251bf215546Sopenharmony_ci
252bf215546Sopenharmony_ci   /**
253bf215546Sopenharmony_ci    * The number of enabled subslices (considering fusing). For exactly which
254bf215546Sopenharmony_ci    * subslices are enabled, see subslice_masks[].
255bf215546Sopenharmony_ci    */
256bf215546Sopenharmony_ci   unsigned subslice_total;
257bf215546Sopenharmony_ci
258bf215546Sopenharmony_ci   /**
259bf215546Sopenharmony_ci    * An array of bit mask of EUs available, use eu_slice_stride &
260bf215546Sopenharmony_ci    * eu_subslice_stride to access this array.
261bf215546Sopenharmony_ci    */
262bf215546Sopenharmony_ci   uint8_t eu_masks[INTEL_DEVICE_MAX_SLICES *
263bf215546Sopenharmony_ci                    INTEL_DEVICE_MAX_SUBSLICES *
264bf215546Sopenharmony_ci                    DIV_ROUND_UP(INTEL_DEVICE_MAX_EUS_PER_SUBSLICE, 8)];
265bf215546Sopenharmony_ci
266bf215546Sopenharmony_ci   /**
267bf215546Sopenharmony_ci    * Stride to access subslice_masks[].
268bf215546Sopenharmony_ci    */
269bf215546Sopenharmony_ci   uint16_t subslice_slice_stride;
270bf215546Sopenharmony_ci
271bf215546Sopenharmony_ci   /**
272bf215546Sopenharmony_ci    * Strides to access eu_masks[].
273bf215546Sopenharmony_ci    */
274bf215546Sopenharmony_ci   uint16_t eu_slice_stride;
275bf215546Sopenharmony_ci   uint16_t eu_subslice_stride;
276bf215546Sopenharmony_ci
277bf215546Sopenharmony_ci   unsigned l3_banks;
278bf215546Sopenharmony_ci   unsigned max_vs_threads;   /**< Maximum Vertex Shader threads */
279bf215546Sopenharmony_ci   unsigned max_tcs_threads;  /**< Maximum Hull Shader threads */
280bf215546Sopenharmony_ci   unsigned max_tes_threads;  /**< Maximum Domain Shader threads */
281bf215546Sopenharmony_ci   unsigned max_gs_threads;   /**< Maximum Geometry Shader threads. */
282bf215546Sopenharmony_ci   /**
283bf215546Sopenharmony_ci    * Theoretical maximum number of Pixel Shader threads.
284bf215546Sopenharmony_ci    *
285bf215546Sopenharmony_ci    * PSD means Pixel Shader Dispatcher. On modern Intel GPUs, hardware will
286bf215546Sopenharmony_ci    * automatically scale pixel shader thread count, based on a single value
287bf215546Sopenharmony_ci    * programmed into 3DSTATE_PS.
288bf215546Sopenharmony_ci    *
289bf215546Sopenharmony_ci    * To calculate the maximum number of threads for Gfx8 beyond (which have
290bf215546Sopenharmony_ci    * multiple Pixel Shader Dispatchers):
291bf215546Sopenharmony_ci    *
292bf215546Sopenharmony_ci    * - Look up 3DSTATE_PS and find "Maximum Number of Threads Per PSD"
293bf215546Sopenharmony_ci    * - Usually there's only one PSD per subslice, so use the number of
294bf215546Sopenharmony_ci    *   subslices for number of PSDs.
295bf215546Sopenharmony_ci    * - For max_wm_threads, the total should be PSD threads * #PSDs.
296bf215546Sopenharmony_ci    */
297bf215546Sopenharmony_ci   unsigned max_wm_threads;
298bf215546Sopenharmony_ci
299bf215546Sopenharmony_ci   unsigned max_threads_per_psd;
300bf215546Sopenharmony_ci
301bf215546Sopenharmony_ci   /**
302bf215546Sopenharmony_ci    * Maximum Compute Shader threads.
303bf215546Sopenharmony_ci    *
304bf215546Sopenharmony_ci    * Thread count * number of EUs per subslice
305bf215546Sopenharmony_ci    */
306bf215546Sopenharmony_ci   unsigned max_cs_threads;
307bf215546Sopenharmony_ci
308bf215546Sopenharmony_ci   /**
309bf215546Sopenharmony_ci    * Maximum number of threads per workgroup supported by the GPGPU_WALKER or
310bf215546Sopenharmony_ci    * COMPUTE_WALKER command.
311bf215546Sopenharmony_ci    *
312bf215546Sopenharmony_ci    * This may be smaller than max_cs_threads as it takes into account added
313bf215546Sopenharmony_ci    * restrictions on the GPGPU/COMPUTE_WALKER commands.  While max_cs_threads
314bf215546Sopenharmony_ci    * expresses the total parallelism of the GPU, this expresses the maximum
315bf215546Sopenharmony_ci    * number of threads we can dispatch in a single workgroup.
316bf215546Sopenharmony_ci    */
317bf215546Sopenharmony_ci   unsigned max_cs_workgroup_threads;
318bf215546Sopenharmony_ci
319bf215546Sopenharmony_ci   /**
320bf215546Sopenharmony_ci    * The maximum number of potential scratch ids. Due to hardware
321bf215546Sopenharmony_ci    * implementation details, the range of scratch ids may be larger than the
322bf215546Sopenharmony_ci    * number of subslices.
323bf215546Sopenharmony_ci    */
324bf215546Sopenharmony_ci   unsigned max_scratch_ids[MESA_SHADER_STAGES];
325bf215546Sopenharmony_ci
326bf215546Sopenharmony_ci   struct {
327bf215546Sopenharmony_ci      /**
328bf215546Sopenharmony_ci       * Fixed size of the URB.
329bf215546Sopenharmony_ci       *
330bf215546Sopenharmony_ci       * On Gfx6 and DG1, this is measured in KB.  Gfx4-5 instead measure
331bf215546Sopenharmony_ci       * this in 512b blocks, as that's more convenient there.
332bf215546Sopenharmony_ci       *
333bf215546Sopenharmony_ci       * On most Gfx7+ platforms, the URB is a section of the L3 cache,
334bf215546Sopenharmony_ci       * and can be resized based on the L3 programming.  For those platforms,
335bf215546Sopenharmony_ci       * simply leave this field blank (zero) - it isn't used.
336bf215546Sopenharmony_ci       */
337bf215546Sopenharmony_ci      unsigned size;
338bf215546Sopenharmony_ci
339bf215546Sopenharmony_ci      /**
340bf215546Sopenharmony_ci       * The minimum number of URB entries.  See the 3DSTATE_URB_<XS> docs.
341bf215546Sopenharmony_ci       */
342bf215546Sopenharmony_ci      unsigned min_entries[4];
343bf215546Sopenharmony_ci
344bf215546Sopenharmony_ci      /**
345bf215546Sopenharmony_ci       * The maximum number of URB entries.  See the 3DSTATE_URB_<XS> docs.
346bf215546Sopenharmony_ci       */
347bf215546Sopenharmony_ci      unsigned max_entries[4];
348bf215546Sopenharmony_ci   } urb;
349bf215546Sopenharmony_ci
350bf215546Sopenharmony_ci   /* Maximum size in Kb that can be allocated to constants in the URB, this
351bf215546Sopenharmony_ci    * is usually divided among the stages for implementing push constants.
352bf215546Sopenharmony_ci    * See 3DSTATE_PUSH_CONSTANT_ALLOC_*.
353bf215546Sopenharmony_ci    */
354bf215546Sopenharmony_ci   unsigned max_constant_urb_size_kb;
355bf215546Sopenharmony_ci
356bf215546Sopenharmony_ci   /**
357bf215546Sopenharmony_ci    * Size of the command streamer prefetch. This is important to know for
358bf215546Sopenharmony_ci    * self modifying batches.
359bf215546Sopenharmony_ci    */
360bf215546Sopenharmony_ci   unsigned cs_prefetch_size;
361bf215546Sopenharmony_ci
362bf215546Sopenharmony_ci   /**
363bf215546Sopenharmony_ci    * For the longest time the timestamp frequency for Gen's timestamp counter
364bf215546Sopenharmony_ci    * could be assumed to be 12.5MHz, where the least significant bit neatly
365bf215546Sopenharmony_ci    * corresponded to 80 nanoseconds.
366bf215546Sopenharmony_ci    *
367bf215546Sopenharmony_ci    * Since Gfx9 the numbers aren't so round, with a a frequency of 12MHz for
368bf215546Sopenharmony_ci    * SKL (or scale factor of 83.33333333) and a frequency of 19200000Hz for
369bf215546Sopenharmony_ci    * BXT.
370bf215546Sopenharmony_ci    *
371bf215546Sopenharmony_ci    * For simplicity to fit with the current code scaling by a single constant
372bf215546Sopenharmony_ci    * to map from raw timestamps to nanoseconds we now do the conversion in
373bf215546Sopenharmony_ci    * floating point instead of integer arithmetic.
374bf215546Sopenharmony_ci    *
375bf215546Sopenharmony_ci    * In general it's probably worth noting that the documented constants we
376bf215546Sopenharmony_ci    * have for the per-platform timestamp frequencies aren't perfect and
377bf215546Sopenharmony_ci    * shouldn't be trusted for scaling and comparing timestamps with a large
378bf215546Sopenharmony_ci    * delta.
379bf215546Sopenharmony_ci    *
380bf215546Sopenharmony_ci    * E.g. with crude testing on my system using the 'correct' scale factor I'm
381bf215546Sopenharmony_ci    * seeing a drift of ~2 milliseconds per second.
382bf215546Sopenharmony_ci    */
383bf215546Sopenharmony_ci   uint64_t timestamp_frequency;
384bf215546Sopenharmony_ci
385bf215546Sopenharmony_ci   uint64_t aperture_bytes;
386bf215546Sopenharmony_ci   uint64_t gtt_size;
387bf215546Sopenharmony_ci
388bf215546Sopenharmony_ci   /**
389bf215546Sopenharmony_ci    * ID to put into the .aub files.
390bf215546Sopenharmony_ci    */
391bf215546Sopenharmony_ci   int simulator_id;
392bf215546Sopenharmony_ci
393bf215546Sopenharmony_ci   /**
394bf215546Sopenharmony_ci    * holds the name of the device
395bf215546Sopenharmony_ci    */
396bf215546Sopenharmony_ci   char name[INTEL_DEVICE_MAX_NAME_SIZE];
397bf215546Sopenharmony_ci
398bf215546Sopenharmony_ci   /**
399bf215546Sopenharmony_ci    * no_hw is true when the pci_device_id has been overridden
400bf215546Sopenharmony_ci    */
401bf215546Sopenharmony_ci   bool no_hw;
402bf215546Sopenharmony_ci
403bf215546Sopenharmony_ci   /**
404bf215546Sopenharmony_ci    * apply_hwconfig is true when the platform should apply hwconfig values
405bf215546Sopenharmony_ci    */
406bf215546Sopenharmony_ci   bool apply_hwconfig;
407bf215546Sopenharmony_ci
408bf215546Sopenharmony_ci   struct {
409bf215546Sopenharmony_ci      bool use_class_instance;
410bf215546Sopenharmony_ci      struct {
411bf215546Sopenharmony_ci         uint16_t mem_class;
412bf215546Sopenharmony_ci         uint16_t mem_instance;
413bf215546Sopenharmony_ci         struct {
414bf215546Sopenharmony_ci            uint64_t size;
415bf215546Sopenharmony_ci            uint64_t free;
416bf215546Sopenharmony_ci         } mappable, unmappable;
417bf215546Sopenharmony_ci      } sram, vram;
418bf215546Sopenharmony_ci   } mem;
419bf215546Sopenharmony_ci   /** @} */
420bf215546Sopenharmony_ci};
421bf215546Sopenharmony_ci
422bf215546Sopenharmony_ci#ifdef GFX_VER
423bf215546Sopenharmony_ci
424bf215546Sopenharmony_ci#define intel_device_info_is_9lp(devinfo) \
425bf215546Sopenharmony_ci   (GFX_VER == 9 && ((devinfo)->platform == INTEL_PLATFORM_BXT || \
426bf215546Sopenharmony_ci                     (devinfo)->platform == INTEL_PLATFORM_GLK))
427bf215546Sopenharmony_ci
428bf215546Sopenharmony_ci#else
429bf215546Sopenharmony_ci
430bf215546Sopenharmony_ci#define intel_device_info_is_9lp(devinfo) \
431bf215546Sopenharmony_ci   ((devinfo)->platform == INTEL_PLATFORM_BXT || \
432bf215546Sopenharmony_ci    (devinfo)->platform == INTEL_PLATFORM_GLK)
433bf215546Sopenharmony_ci
434bf215546Sopenharmony_ci#endif
435bf215546Sopenharmony_ci
436bf215546Sopenharmony_cistatic inline bool
437bf215546Sopenharmony_ciintel_device_info_slice_available(const struct intel_device_info *devinfo,
438bf215546Sopenharmony_ci                                  int slice)
439bf215546Sopenharmony_ci{
440bf215546Sopenharmony_ci   assert(slice < INTEL_DEVICE_MAX_SLICES);
441bf215546Sopenharmony_ci   return (devinfo->slice_masks & (1U << slice)) != 0;
442bf215546Sopenharmony_ci}
443bf215546Sopenharmony_ci
444bf215546Sopenharmony_cistatic inline bool
445bf215546Sopenharmony_ciintel_device_info_subslice_available(const struct intel_device_info *devinfo,
446bf215546Sopenharmony_ci                                     int slice, int subslice)
447bf215546Sopenharmony_ci{
448bf215546Sopenharmony_ci   return (devinfo->subslice_masks[slice * devinfo->subslice_slice_stride +
449bf215546Sopenharmony_ci                                   subslice / 8] & (1U << (subslice % 8))) != 0;
450bf215546Sopenharmony_ci}
451bf215546Sopenharmony_ci
452bf215546Sopenharmony_cistatic inline bool
453bf215546Sopenharmony_ciintel_device_info_eu_available(const struct intel_device_info *devinfo,
454bf215546Sopenharmony_ci                               int slice, int subslice, int eu)
455bf215546Sopenharmony_ci{
456bf215546Sopenharmony_ci   unsigned subslice_offset = slice * devinfo->eu_slice_stride +
457bf215546Sopenharmony_ci      subslice * devinfo->eu_subslice_stride;
458bf215546Sopenharmony_ci
459bf215546Sopenharmony_ci   return (devinfo->eu_masks[subslice_offset + eu / 8] & (1U << eu % 8)) != 0;
460bf215546Sopenharmony_ci}
461bf215546Sopenharmony_ci
462bf215546Sopenharmony_cistatic inline uint32_t
463bf215546Sopenharmony_ciintel_device_info_subslice_total(const struct intel_device_info *devinfo)
464bf215546Sopenharmony_ci{
465bf215546Sopenharmony_ci   uint32_t total = 0;
466bf215546Sopenharmony_ci
467bf215546Sopenharmony_ci   for (size_t i = 0; i < ARRAY_SIZE(devinfo->subslice_masks); i++) {
468bf215546Sopenharmony_ci      total += __builtin_popcount(devinfo->subslice_masks[i]);
469bf215546Sopenharmony_ci   }
470bf215546Sopenharmony_ci
471bf215546Sopenharmony_ci   return total;
472bf215546Sopenharmony_ci}
473bf215546Sopenharmony_ci
474bf215546Sopenharmony_cistatic inline uint32_t
475bf215546Sopenharmony_ciintel_device_info_eu_total(const struct intel_device_info *devinfo)
476bf215546Sopenharmony_ci{
477bf215546Sopenharmony_ci   uint32_t total = 0;
478bf215546Sopenharmony_ci
479bf215546Sopenharmony_ci   for (size_t i = 0; i < ARRAY_SIZE(devinfo->eu_masks); i++)
480bf215546Sopenharmony_ci      total += __builtin_popcount(devinfo->eu_masks[i]);
481bf215546Sopenharmony_ci
482bf215546Sopenharmony_ci   return total;
483bf215546Sopenharmony_ci}
484bf215546Sopenharmony_ci
485bf215546Sopenharmony_cistatic inline unsigned
486bf215546Sopenharmony_ciintel_device_info_num_dual_subslices(UNUSED
487bf215546Sopenharmony_ci                                     const struct intel_device_info *devinfo)
488bf215546Sopenharmony_ci{
489bf215546Sopenharmony_ci   unreachable("TODO");
490bf215546Sopenharmony_ci}
491bf215546Sopenharmony_ci
492bf215546Sopenharmony_ciint intel_device_name_to_pci_device_id(const char *name);
493bf215546Sopenharmony_ci
494bf215546Sopenharmony_cistatic inline uint64_t
495bf215546Sopenharmony_ciintel_device_info_timebase_scale(const struct intel_device_info *devinfo,
496bf215546Sopenharmony_ci                                 uint64_t gpu_timestamp)
497bf215546Sopenharmony_ci{
498bf215546Sopenharmony_ci   /* Try to avoid going over the 64bits when doing the scaling */
499bf215546Sopenharmony_ci   uint64_t upper_ts = gpu_timestamp >> 32;
500bf215546Sopenharmony_ci   uint64_t lower_ts = gpu_timestamp & 0xffffffff;
501bf215546Sopenharmony_ci   uint64_t upper_scaled_ts = upper_ts * 1000000000ull / devinfo->timestamp_frequency;
502bf215546Sopenharmony_ci   uint64_t lower_scaled_ts = lower_ts * 1000000000ull / devinfo->timestamp_frequency;
503bf215546Sopenharmony_ci   return (upper_scaled_ts << 32) + lower_scaled_ts;
504bf215546Sopenharmony_ci}
505bf215546Sopenharmony_ci
506bf215546Sopenharmony_cistatic inline bool
507bf215546Sopenharmony_ciintel_vram_all_mappable(const struct intel_device_info *devinfo)
508bf215546Sopenharmony_ci{
509bf215546Sopenharmony_ci   return devinfo->mem.vram.unmappable.size == 0;
510bf215546Sopenharmony_ci}
511bf215546Sopenharmony_ci
512bf215546Sopenharmony_cibool intel_get_device_info_from_fd(int fh, struct intel_device_info *devinfo);
513bf215546Sopenharmony_cibool intel_get_device_info_from_pci_id(int pci_id,
514bf215546Sopenharmony_ci                                       struct intel_device_info *devinfo);
515bf215546Sopenharmony_ci
516bf215546Sopenharmony_ci/* Only updates intel_device_info::regions::...::free fields. The
517bf215546Sopenharmony_ci * class/instance/size should remain the same over time.
518bf215546Sopenharmony_ci */
519bf215546Sopenharmony_cibool intel_device_info_update_memory_info(struct intel_device_info *devinfo,
520bf215546Sopenharmony_ci                                          int fd);
521bf215546Sopenharmony_ci
522bf215546Sopenharmony_ci#ifdef __cplusplus
523bf215546Sopenharmony_ci}
524bf215546Sopenharmony_ci#endif
525bf215546Sopenharmony_ci
526bf215546Sopenharmony_ci#endif /* INTEL_DEVICE_INFO_H */
527