1 /*
2 * Copyright (c) 2018, 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 shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22 //!
23 //! \file     media_sysinfo_g11.cpp
24 //!
25 
26 #include "igfxfmid.h"
27 #include "linux_system_info.h"
28 #include "skuwa_factory.h"
29 #include "linux_skuwa_debug.h"
30 #include "linux_media_skuwa.h"
31 #include "linux_shadow_skuwa.h"
32 
33 //extern template class DeviceInfoFactory<GfxDeviceInfo>;
34 typedef DeviceInfoFactory<GfxDeviceInfo> base_fact;
35 
36 #define GEN11_THREADS_PER_EU        7
37 #define GEN11_VDBOX4_SUBSLICE_COUNT 4
38 #define GEN11_VEBOX2_SUBSLICE_COUNT 4
39 
InitIclShadowSku(struct GfxDeviceInfo * devInfo,SHADOW_MEDIA_FEATURE_TABLE * skuTable,struct LinuxDriverInfo * drvInfo)40 static bool InitIclShadowSku(struct GfxDeviceInfo *devInfo,
41                              SHADOW_MEDIA_FEATURE_TABLE *skuTable,
42                              struct LinuxDriverInfo *drvInfo)
43 {
44     if ((devInfo == nullptr) || (skuTable == nullptr) || (drvInfo == nullptr))
45     {
46         DEVINFO_ERROR("null ptr is passed\n");
47         return false;
48     }
49 
50     skuTable->FtrVERing = 0;
51     if (drvInfo->hasVebox)
52     {
53        skuTable->FtrVERing = 1;
54     }
55 
56     skuTable->FtrVcs2 = 0;
57 
58     skuTable->FtrULT = 0;
59 
60     skuTable->FtrPPGTT = 1;
61     skuTable->FtrIA32eGfxPTEs = 1;
62 
63     skuTable->FtrDisplayYTiling = 1;
64     skuTable->FtrEDram = devInfo->hasERAM;
65 
66     skuTable->FtrTileY = 1;
67 
68     return true;
69 }
70 
InitIclShadowWa(struct GfxDeviceInfo * devInfo,SHADOW_MEDIA_WA_TABLE * waTable,struct LinuxDriverInfo * drvInfo)71 static bool InitIclShadowWa(struct GfxDeviceInfo *devInfo,
72                              SHADOW_MEDIA_WA_TABLE *waTable,
73                              struct LinuxDriverInfo *drvInfo)
74 {
75     if ((devInfo == nullptr) || (waTable == nullptr) || (drvInfo == nullptr))
76     {
77         DEVINFO_ERROR("null ptr is passed\n");
78         return false;
79     }
80 
81     /* by default PPGTT is enabled */
82     waTable->WaForceGlobalGTT = 0;
83     if (drvInfo->hasPpgtt == 0)
84     {
85         waTable->WaForceGlobalGTT = 1;
86     }
87 
88     waTable->WaDisregardPlatformChecks          = 1;
89     waTable->Wa4kAlignUVOffsetNV12LinearSurface = 1;
90 
91     //source and recon surfaces need to be aligned to the LCU size
92     waTable->WaAlignYUVResourceToLCU = 1;
93 
94     return true;
95 }
96 
InitIcllpMediaSysInfo(struct GfxDeviceInfo * devInfo,MEDIA_GT_SYSTEM_INFO * sysInfo)97 static bool InitIcllpMediaSysInfo(struct GfxDeviceInfo *devInfo, MEDIA_GT_SYSTEM_INFO *sysInfo)
98 {
99     if ((devInfo == nullptr) || (sysInfo == nullptr))
100     {
101         DEVINFO_ERROR("null ptr is passed\n");
102         return false;
103     }
104 
105     if (!sysInfo->SliceCount)
106     {
107         sysInfo->SliceCount    = devInfo->SliceCount;
108     }
109 
110     if (!sysInfo->SubSliceCount)
111     {
112         sysInfo->SubSliceCount = devInfo->SubSliceCount;
113     }
114 
115     if (!sysInfo->EUCount)
116     {
117         sysInfo->EUCount       = devInfo->EUCount;
118     }
119 
120     sysInfo->L3CacheSizeInKb = devInfo->L3CacheSizeInKb;
121     sysInfo->L3BankCount     = devInfo->L3BankCount;
122     sysInfo->VDBoxInfo.Instances.Bits.VDBox0Enabled = 1;
123     sysInfo->VDBoxInfo.Instances.Bits.VDBox1Enabled = 0;
124     sysInfo->VEBoxInfo.Instances.Bits.VEBox0Enabled = 1;
125     sysInfo->MaxEuPerSubSlice = devInfo->MaxEuPerSubSlice;
126     sysInfo->MaxSlicesSupported = sysInfo->SliceCount;
127     sysInfo->MaxSubSlicesSupported = sysInfo->SubSliceCount;
128 
129     sysInfo->VEBoxInfo.NumberOfVEBoxEnabled = 1;
130     sysInfo->VDBoxInfo.NumberOfVDBoxEnabled = 0;//Query the VDBox number from KMD
131 
132     sysInfo->ThreadCount = sysInfo->EUCount * GEN11_THREADS_PER_EU;
133 
134     sysInfo->VEBoxInfo.IsValid = true;
135     sysInfo->VDBoxInfo.IsValid = true;
136 
137     /* the GMM doesn't care the real size of ERAM/LLC. Instead it is used to
138      * indicate whether the LLC/ERAM exists
139      */
140     if (devInfo->hasERAM)
141     {
142         // 64M
143         sysInfo->EdramSizeInKb = 64 * 1024;
144     }
145     if (devInfo->hasLLC)
146     {
147         // 2M
148         sysInfo->LLCCacheSizeInKb = 2 * 1024;
149     }
150 
151     return true;
152 }
153 
InitEhlShadowSku(struct GfxDeviceInfo * devInfo,SHADOW_MEDIA_FEATURE_TABLE * skuTable,struct LinuxDriverInfo * drvInfo)154 static bool InitEhlShadowSku(struct GfxDeviceInfo *devInfo,
155                              SHADOW_MEDIA_FEATURE_TABLE *skuTable,
156                              struct LinuxDriverInfo *drvInfo)
157 {
158     if ((devInfo == nullptr) || (skuTable == nullptr) || (drvInfo == nullptr))
159     {
160         DEVINFO_ERROR("null ptr is passed\n");
161         return false;
162     }
163 
164     skuTable->FtrVERing = 0;
165     if (drvInfo->hasVebox)
166     {
167        skuTable->FtrVERing = 1;
168     }
169 
170     skuTable->FtrVcs2 = 0;
171 
172     skuTable->FtrULT = 0;
173 
174     skuTable->FtrPPGTT = 1;
175     skuTable->FtrIA32eGfxPTEs = 1;
176 
177     skuTable->FtrDisplayYTiling = 1;
178     skuTable->FtrEDram          = 0;
179     skuTable->FtrLLCBypass      = 1;
180 
181     return true;
182 }
InitEhlShadowWa(struct GfxDeviceInfo * devInfo,SHADOW_MEDIA_WA_TABLE * waTable,struct LinuxDriverInfo * drvInfo)183 static bool InitEhlShadowWa(struct GfxDeviceInfo *devInfo,
184                              SHADOW_MEDIA_WA_TABLE *waTable,
185                              struct LinuxDriverInfo *drvInfo)
186 {
187     if ((devInfo == nullptr) || (waTable == nullptr) || (drvInfo == nullptr))
188     {
189         DEVINFO_ERROR("null ptr is passed\n");
190         return false;
191     }
192 
193     /* by default PPGTT is enabled */
194     waTable->WaForceGlobalGTT = 0;
195     if (drvInfo->hasPpgtt == 0)
196     {
197         waTable->WaForceGlobalGTT = 1;
198     }
199 
200     waTable->WaDisregardPlatformChecks          = 1;
201     waTable->Wa4kAlignUVOffsetNV12LinearSurface = 1;
202 
203     return true;
204 }
205 
InitEhlMediaSysInfo(struct GfxDeviceInfo * devInfo,MEDIA_GT_SYSTEM_INFO * sysInfo)206 static bool InitEhlMediaSysInfo(struct GfxDeviceInfo *devInfo, MEDIA_GT_SYSTEM_INFO *sysInfo)
207 {
208     if ((devInfo == nullptr) || (sysInfo == nullptr))
209     {
210         DEVINFO_ERROR("null ptr is passed\n");
211         return false;
212     }
213 
214     if (!sysInfo->SliceCount)
215     {
216         sysInfo->SliceCount    = devInfo->SliceCount;
217     }
218 
219     if (!sysInfo->SubSliceCount)
220     {
221         sysInfo->SubSliceCount = devInfo->SubSliceCount;
222     }
223 
224     if (!sysInfo->EUCount)
225     {
226         sysInfo->EUCount       = devInfo->EUCount;
227     }
228 
229     sysInfo->L3CacheSizeInKb = devInfo->L3CacheSizeInKb;
230     sysInfo->L3BankCount     = devInfo->L3BankCount;
231     /* EHL has only one VDBox */
232     sysInfo->VDBoxInfo.Instances.Bits.VDBox0Enabled = 1;
233     sysInfo->VDBoxInfo.Instances.Bits.VDBox1Enabled = 0;
234     sysInfo->VEBoxInfo.Instances.Bits.VEBox0Enabled = 1;
235     sysInfo->MaxEuPerSubSlice = devInfo->MaxEuPerSubSlice;
236     sysInfo->MaxSlicesSupported = sysInfo->SliceCount;
237     sysInfo->MaxSubSlicesSupported = sysInfo->SubSliceCount;
238 
239     sysInfo->VEBoxInfo.NumberOfVEBoxEnabled = 1;
240     sysInfo->VDBoxInfo.NumberOfVDBoxEnabled = 1;
241 
242     sysInfo->ThreadCount = sysInfo->EUCount * GEN11_THREADS_PER_EU;
243 
244     sysInfo->VEBoxInfo.IsValid = true;
245     sysInfo->VDBoxInfo.IsValid = true;
246 
247     /* the GMM doesn't care the real size of ERAM/LLC. Instead it is used to
248      * indicate whether the LLC/ERAM exists
249      */
250     if (devInfo->hasERAM)
251     {
252         // 64M
253         sysInfo->EdramSizeInKb = 64 * 1024;
254     }
255     if (devInfo->hasLLC)
256     {
257         // 2M
258         sysInfo->LLCCacheSizeInKb = 2 * 1024;
259     }
260 
261     return true;
262 }
263 
264 static struct GfxDeviceInfo icllpGt1Info = {
265     .platformType  = PLATFORM_MOBILE,
266     .productFamily = IGFX_ICELAKE_LP,
267     .displayFamily = IGFX_GEN11_CORE,
268     .renderFamily  = IGFX_GEN11_CORE,
269     .eGTType       = GTTYPE_GT1,
270     .L3CacheSizeInKb = 2304,
271     .L3BankCount   = 6,
272     .EUCount       = 48,
273     .SliceCount    = 1,
274     .SubSliceCount = 6,
275     .MaxEuPerSubSlice = 8,
276     .isLCIA        = 0,
277     .hasLLC        = 1,
278     .hasERAM       = 0,
279     .InitMediaSysInfo = InitIcllpMediaSysInfo,
280     .InitShadowSku    = InitIclShadowSku,
281     .InitShadowWa     = InitIclShadowWa,
282 };
283 
284 static struct GfxDeviceInfo icllpGt05Info = {
285     .platformType  = PLATFORM_MOBILE,
286     .productFamily = IGFX_ICELAKE_LP,
287     .displayFamily = IGFX_GEN11_CORE,
288     .renderFamily  = IGFX_GEN11_CORE,
289     .eGTType       = GTTYPE_GT1,
290     .L3CacheSizeInKb = 2304,
291     .L3BankCount   = 6,
292     .EUCount       = 8,
293     .SliceCount    = 1,
294     .SubSliceCount = 1,
295     .MaxEuPerSubSlice = 8,
296     .isLCIA        = 0,
297     .hasLLC        = 1,
298     .hasERAM       = 0,
299     .InitMediaSysInfo = InitIcllpMediaSysInfo,
300     .InitShadowSku    = InitIclShadowSku,
301     .InitShadowWa     = InitIclShadowWa,
302 };
303 static struct GfxDeviceInfo icllpGt2Info = {
304     .platformType  = PLATFORM_MOBILE,
305     .productFamily = IGFX_ICELAKE_LP,
306     .displayFamily = IGFX_GEN11_CORE,
307     .renderFamily  = IGFX_GEN11_CORE,
308     .eGTType       = GTTYPE_GT2,
309     .L3CacheSizeInKb = 3072,
310     .L3BankCount   = 8,
311     .EUCount       = 64,
312     .SliceCount    = 1,
313     .SubSliceCount = 8,
314     .MaxEuPerSubSlice = 8,
315     .isLCIA        = 0,
316     .hasLLC        = 1,
317     .hasERAM       = 0,
318     .InitMediaSysInfo = InitIcllpMediaSysInfo,
319     .InitShadowSku    = InitIclShadowSku,
320     .InitShadowWa     = InitIclShadowWa,
321 };
322 static struct GfxDeviceInfo ehlDevInfo = {
323     .platformType  = PLATFORM_MOBILE,
324     .productFamily = IGFX_ELKHARTLAKE,
325     .displayFamily = IGFX_GEN11_CORE,
326     .renderFamily  = IGFX_GEN11_CORE,
327     .eGTType       = GTTYPE_GT1,
328     .L3CacheSizeInKb = 1280,
329     .L3BankCount   = 4,
330     .EUCount       = 32,
331     .SliceCount    = 1,
332     .SubSliceCount = 4,
333     .MaxEuPerSubSlice = 8,
334     .isLCIA        = 0,
335     .hasLLC        = 1,
336     .hasERAM       = 0,
337     .InitMediaSysInfo = InitEhlMediaSysInfo,
338     .InitShadowSku    = InitEhlShadowSku,
339     .InitShadowWa     = InitEhlShadowWa,
340 };
341 
342 static bool icllpDeviceff05 = DeviceInfoFactory<GfxDeviceInfo>::
343     RegisterDevice(0xff05, &icllpGt1Info);
344 
345 static bool icllpDevice8a50 = DeviceInfoFactory<GfxDeviceInfo>::
346     RegisterDevice(0x8a50, &icllpGt2Info);
347 
348 static bool icllpDevice8a51 = DeviceInfoFactory<GfxDeviceInfo>::
349     RegisterDevice(0x8a51, &icllpGt2Info);
350 
351 static bool icllpDevice8a52 = DeviceInfoFactory<GfxDeviceInfo>::
352     RegisterDevice(0x8a52, &icllpGt2Info);
353 
354 static bool icllpDevice8a53 = DeviceInfoFactory<GfxDeviceInfo>::
355     RegisterDevice(0x8a53, &icllpGt2Info);
356 
357 static bool icllpDevice8a54 = DeviceInfoFactory<GfxDeviceInfo>::
358     RegisterDevice(0x8a54, &icllpGt1Info);
359 
360 static bool icllpDevice8a56 = DeviceInfoFactory<GfxDeviceInfo>::
361     RegisterDevice(0x8a56, &icllpGt1Info);
362 
363 static bool icllpDevice8a57 = DeviceInfoFactory<GfxDeviceInfo>::
364     RegisterDevice(0x8a57, &icllpGt1Info);
365 
366 static bool icllpDevice8a58 = DeviceInfoFactory<GfxDeviceInfo>::
367     RegisterDevice(0x8a58, &icllpGt1Info);
368 
369 static bool icllpDevice8a59 = DeviceInfoFactory<GfxDeviceInfo>::
370     RegisterDevice(0x8a59, &icllpGt1Info);
371 
372 static bool icllpDevice8a5d = DeviceInfoFactory<GfxDeviceInfo>::
373     RegisterDevice(0x8a5d, &icllpGt1Info);
374 
375 static bool icllpDevice8a5c = DeviceInfoFactory<GfxDeviceInfo>::
376     RegisterDevice(0x8a5c, &icllpGt1Info);
377 
378 static bool icllpDevice8a5b = DeviceInfoFactory<GfxDeviceInfo>::
379     RegisterDevice(0x8a5b, &icllpGt1Info);
380 
381 static bool icllpDevice8a5a = DeviceInfoFactory<GfxDeviceInfo>::
382     RegisterDevice(0x8a5a, &icllpGt1Info);
383 
384 static bool icllpDevice8a71 = DeviceInfoFactory<GfxDeviceInfo>::
385     RegisterDevice(0x8a71, &icllpGt05Info);
386 
387 static bool ehlDevice4500 = DeviceInfoFactory<GfxDeviceInfo>::
388     RegisterDevice(0x4500, &ehlDevInfo);
389 
390 static bool ehlDevice4571 = DeviceInfoFactory<GfxDeviceInfo>::
391     RegisterDevice(0x4571, &ehlDevInfo);
392 
393 static bool ehlDevice4551 = DeviceInfoFactory<GfxDeviceInfo>::
394     RegisterDevice(0x4551, &ehlDevInfo);
395 
396 static bool ehlDevice4541 = DeviceInfoFactory<GfxDeviceInfo>::
397     RegisterDevice(0x4541, &ehlDevInfo);
398 
399 static bool ehlDevice4E51 = DeviceInfoFactory<GfxDeviceInfo>::
400     RegisterDevice(0x4E51, &ehlDevInfo);
401 
402 static bool ehlDevice4E61 = DeviceInfoFactory<GfxDeviceInfo>::
403     RegisterDevice(0x4E61, &ehlDevInfo);
404 
405 static bool ehlDevice4E71 = DeviceInfoFactory<GfxDeviceInfo>::
406     RegisterDevice(0x4E71, &ehlDevInfo);
407