1 /*
2 * Copyright (c) 2017-2021, 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 mos_graphicsresource_specific.cpp
24 //! \brief Container class for the linux/Android specfic graphic resource
25 //!
26
27 #include "mos_defs.h"
28 #include "mos_util_debug.h"
29
30 #include "mos_graphicsresource_specific.h"
31 #include "mos_context_specific.h"
32 #include "memory_policy_manager.h"
33
GraphicsResourceSpecific()34 GraphicsResourceSpecific::GraphicsResourceSpecific()
35 {
36 MOS_OS_FUNCTION_ENTER;
37 }
38
~GraphicsResourceSpecific()39 GraphicsResourceSpecific::~GraphicsResourceSpecific()
40 {
41 MOS_OS_FUNCTION_ENTER;
42 }
43
ResourceIsNull()44 bool GraphicsResourceSpecific::ResourceIsNull()
45 {
46 return ((m_bo == nullptr)
47 #if (_DEBUG || _RELEASE_INTERNAL)
48 && ((m_pData == nullptr) )
49 #endif // (_DEBUG || _RELEASE_INTERNAL)
50 );
51
52 }
53
Allocate(OsContext * osContextPtr,CreateParams & params)54 MOS_STATUS GraphicsResourceSpecific::Allocate(OsContext* osContextPtr, CreateParams& params)
55 {
56 MOS_OS_FUNCTION_ENTER;
57
58 if (osContextPtr == nullptr)
59 {
60 MOS_OS_ASSERTMESSAGE("Unable to get the active OS context.");
61 return MOS_STATUS_INVALID_HANDLE;
62 }
63
64 if (osContextPtr->GetOsContextValid() == false)
65 {
66 MOS_OS_ASSERTMESSAGE("The OS context got is not valid.");
67 return MOS_STATUS_INVALID_HANDLE;
68 }
69
70 OsContextSpecific *pOsContextSpecific = static_cast<OsContextSpecific *>(osContextPtr);
71
72 MOS_STATUS status = MOS_STATUS_SUCCESS;
73 uint32_t tileFormatLinux = TILING_NONE;
74 uint32_t alignedHeight = params.m_height;
75 uint32_t bufHeight = params.m_height;
76 GMM_RESOURCE_TYPE resourceType = RESOURCE_2D;
77 int mem_type = MOS_MEMPOOL_VIDEOMEMORY;
78
79 GMM_RESCREATE_PARAMS gmmParams;
80 MOS_ZeroMemory(&gmmParams, sizeof(gmmParams));
81
82 switch (params.m_type)
83 {
84 case MOS_GFXRES_BUFFER:
85 case MOS_GFXRES_SCRATCH:
86 gmmParams.Type = RESOURCE_BUFFER;
87 gmmParams.Flags.Gpu.State = true;
88 alignedHeight = 1;
89 break;
90
91 case MOS_GFXRES_2D:
92 gmmParams.Type = RESOURCE_2D;
93 gmmParams.Flags.Gpu.Video = true;
94 break;
95
96 case MOS_GFXRES_VOLUME:
97 gmmParams.Type = RESOURCE_3D;
98 gmmParams.Flags.Gpu.Video = true;
99 gmmParams.Depth = params.m_depth;
100 break;
101
102 default:
103 MOS_OS_ASSERTMESSAGE("Unknown surface type");
104 return MOS_STATUS_UNKNOWN;
105 }
106
107 // Create GmmResourceInfo
108 gmmParams.Format = MosInterface::MosFmtToGmmFmt(params.m_format);
109 if (gmmParams.Format == GMM_FORMAT_INVALID)
110 {
111 MOS_OS_ASSERTMESSAGE("Unsupported format");
112 return MOS_STATUS_UNIMPLEMENTED;
113 }
114 gmmParams.BaseWidth = params.m_width;
115 gmmParams.BaseHeight = alignedHeight;
116 gmmParams.ArraySize = 1;
117
118 MOS_TILE_TYPE tileformat = params.m_tileType;
119 MOS_OS_NORMALMESSAGE("tilemode: tileformat = %d for %s, tileModeByForce = %d", tileformat, params.m_name.c_str(), params.m_tileModeByForce);
120 switch (tileformat)
121 {
122 case MOS_TILE_Y:
123 tileFormatLinux = TILING_Y;
124 if (params.m_isCompressible &&
125 MEDIA_IS_SKU(pOsContextSpecific->GetSkuTable(), FtrE2ECompression) &&
126 MEDIA_IS_SKU(pOsContextSpecific->GetSkuTable(), FtrCompressibleSurfaceDefault))
127 {
128 gmmParams.Flags.Gpu.MMC = true;
129 gmmParams.Flags.Info.MediaCompressed = 1;
130 gmmParams.Flags.Gpu.CCS = 1;
131 gmmParams.Flags.Gpu.RenderTarget = 1;
132 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1;
133
134 if(MEDIA_IS_SKU(pOsContextSpecific->GetSkuTable(), FtrFlatPhysCCS))
135 {
136 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
137 }
138 }
139 SetTileModebyForce(gmmParams, params.m_tileModeByForce);
140 break;
141 case MOS_TILE_X:
142 gmmParams.Flags.Info.TiledX = true;
143 tileFormatLinux = TILING_X;
144 break;
145 default:
146 gmmParams.Flags.Info.Linear = true;
147 tileFormatLinux = TILING_NONE;
148 }
149
150 if (nullptr != params.m_pSystemMemory)
151 {
152 // If user provides a system memory pointer, the gfx resource is backed
153 // by the system memory pages. The resource is required to be linear.
154 gmmParams.Flags.Info.Linear = true;
155 gmmParams.Flags.Info.Cacheable = true;
156 gmmParams.NoGfxMemory = true;
157 GMM_RESOURCE_INFO *tmpGmmResInfoPtr = pOsContextSpecific
158 ->GetGmmClientContext()->CreateResInfoObject(&gmmParams);
159 if (tmpGmmResInfoPtr == nullptr)
160 {
161 MOS_OS_ASSERTMESSAGE("Create GmmResInfo failed");
162 return MOS_STATUS_UNKNOWN;
163 }
164
165 gmmParams.ExistingSysMemSize = GFX_ULONG_CAST(tmpGmmResInfoPtr->GetSizeSurface());
166 gmmParams.pExistingSysMem = (GMM_VOIDPTR64)params.m_pSystemMemory;
167 gmmParams.NoGfxMemory = false;
168 gmmParams.Flags.Info.ExistingSysMem = true;
169
170 pOsContextSpecific->GetGmmClientContext()
171 ->DestroyResInfoObject(tmpGmmResInfoPtr);
172 }
173 else
174 {
175 gmmParams.Flags.Info.LocalOnly = MEDIA_IS_SKU(pOsContextSpecific->GetSkuTable(), FtrLocalMemory);
176 }
177
178 GMM_RESOURCE_INFO* gmmResourceInfoPtr = pOsContextSpecific->GetGmmClientContext()->CreateResInfoObject(&gmmParams);
179
180 if (gmmResourceInfoPtr == nullptr)
181 {
182 MOS_OS_ASSERTMESSAGE("Get gmmResourceInfoPtr failed.");
183 return MOS_STATUS_INVALID_PARAMETER;
184 }
185
186 switch (gmmResourceInfoPtr->GetTileType())
187 {
188 case GMM_TILED_X:
189 tileformat = MOS_TILE_X;
190 tileFormatLinux = TILING_X;
191 break;
192 case GMM_TILED_Y:
193 tileformat = MOS_TILE_Y;
194 tileFormatLinux = TILING_Y;
195 break;
196 case GMM_NOT_TILED:
197 tileformat = MOS_TILE_LINEAR;
198 tileFormatLinux = TILING_NONE;
199 break;
200 default:
201 tileformat = MOS_TILE_Y;
202 tileFormatLinux = TILING_Y;
203 break;
204 }
205
206 if (params.m_tileType== MOS_TILE_Y)
207 {
208 gmmResourceInfoPtr->SetMmcMode((GMM_RESOURCE_MMC_INFO)params.m_compressionMode, 0);
209 }
210
211 uint32_t bufPitch = GFX_ULONG_CAST(gmmResourceInfoPtr->GetRenderPitch());
212 uint32_t bufSize = GFX_ULONG_CAST(gmmResourceInfoPtr->GetSizeSurface());
213 bufHeight = gmmResourceInfoPtr->GetBaseHeight();
214 MOS_LINUX_BO* boPtr = nullptr;
215
216 char bufName[m_maxBufNameLength];
217 MOS_SecureStrcpy(bufName, m_maxBufNameLength, params.m_name.c_str());
218
219 if(!params.m_pSystemMemory)
220 {
221 MemoryPolicyParameter memPolicyPar;
222 MOS_ZeroMemory(&memPolicyPar, sizeof(MemoryPolicyParameter));
223
224 memPolicyPar.skuTable = pOsContextSpecific->GetSkuTable();
225 memPolicyPar.waTable = pOsContextSpecific->GetWaTable();
226 memPolicyPar.resInfo = gmmResourceInfoPtr;
227 memPolicyPar.resName = params.m_name.c_str();
228 memPolicyPar.preferredMemType = params.m_memType;
229
230 mem_type = MemoryPolicyManager::UpdateMemoryPolicy(&memPolicyPar);
231 }
232
233 MOS_TraceEventExt(EVENT_RESOURCE_ALLOCATE, EVENT_TYPE_START, nullptr, 0, nullptr, 0);
234 if (nullptr != params.m_pSystemMemory)
235 {
236 struct mos_drm_bo_alloc_userptr alloc_uptr;
237 alloc_uptr.name = bufName;
238 alloc_uptr.addr = params.m_pSystemMemory;
239 alloc_uptr.tiling_mode = tileFormatLinux;
240 alloc_uptr.stride = bufPitch;
241 alloc_uptr.size = bufSize;
242
243 boPtr = mos_bo_alloc_userptr(pOsContextSpecific->m_bufmgr, &alloc_uptr);
244 }
245 // Only Linear and Y TILE supported
246 else if (tileFormatLinux == TILING_NONE)
247 {
248 struct mos_drm_bo_alloc alloc;
249 alloc.name = bufName;
250 alloc.size = bufSize;
251 alloc.alignment = 4096;
252 alloc.ext.mem_type = mem_type;
253 boPtr = mos_bo_alloc(pOsContextSpecific->m_bufmgr, &alloc);
254 }
255 else
256 {
257 struct mos_drm_bo_alloc_tiled alloc_tiled;
258 alloc_tiled.name = bufName;
259 alloc_tiled.x = bufPitch;
260 alloc_tiled.y = bufSize/bufPitch;
261 alloc_tiled.cpp = 1;
262 alloc_tiled.ext.tiling_mode = tileFormatLinux;
263 alloc_tiled.ext.mem_type = mem_type;
264
265 boPtr = mos_bo_alloc_tiled(pOsContextSpecific->m_bufmgr,
266 &alloc_tiled);
267
268 bufPitch = (uint32_t)alloc_tiled.pitch;
269 }
270
271 m_mapped = false;
272 if (boPtr)
273 {
274 m_format = params.m_format;
275 m_width = params.m_width;
276 m_height = bufHeight;
277 m_pitch = bufPitch;
278 m_count = 0;
279 m_bo = boPtr;
280 m_name = params.m_name;
281 m_pData = (uint8_t*) boPtr->virt;
282
283 m_gmmResInfo = gmmResourceInfoPtr;
284 m_mapped = false;
285 m_mmapOperation = MOS_MMAP_OPERATION_NONE;
286
287 m_arraySize = 1;
288 m_depth = MOS_MAX(1, gmmResourceInfoPtr->GetBaseDepth());
289 m_size = (uint32_t)gmmResourceInfoPtr->GetSizeSurface();
290 m_tileType = tileformat;
291 m_tileModeGMM = (MOS_TILE_MODE_GMM)gmmResourceInfoPtr->GetTileModeSurfaceState();
292 m_isGMMTileEnabled = true;
293
294 m_compressible = gmmParams.Flags.Gpu.MMC ?
295 (gmmResourceInfoPtr->GetMmcHint(0) == GMM_MMC_HINT_ON) : false;
296 m_isCompressed = gmmResourceInfoPtr->IsMediaMemoryCompressed(0);
297 m_compressionMode = (MOS_RESOURCE_MMC_MODE)gmmResourceInfoPtr->GetMmcMode(0);
298
299 m_memObjCtrlState = MosInterface::GetCachePolicyMemoryObject(
300 pOsContextSpecific->GetGmmClientContext(),
301 params.m_mocsMosResUsageType);
302 m_mocsMosResUsageType = params.m_mocsMosResUsageType;
303
304 MOS_OS_VERBOSEMESSAGE("Alloc %7d bytes (%d x %d resource), tile encoding %d.",bufSize, params.m_width, bufHeight, m_tileModeGMM);
305
306 struct {
307 uint32_t m_handle;
308 uint32_t m_resFormat;
309 uint32_t m_baseWidth;
310 uint32_t m_baseHeight;
311 uint32_t m_pitch;
312 uint32_t m_size;
313 uint32_t m_resTileType;
314 GMM_RESOURCE_FLAG m_resFlag;
315 uint32_t m_reserve;
316 } eventData;
317
318 eventData.m_handle = boPtr->handle;
319 eventData.m_baseWidth = m_width;
320 eventData.m_baseHeight = m_height;
321 eventData.m_pitch = m_pitch;
322 eventData.m_size = m_size;
323 eventData.m_resFormat = m_format;
324 eventData.m_resTileType = m_tileType;
325 eventData.m_resFlag = gmmResourceInfoPtr->GetResFlags();
326 eventData.m_reserve = 0;
327 MOS_TraceEventExt(EVENT_RESOURCE_ALLOCATE,
328 EVENT_TYPE_INFO,
329 &eventData,
330 sizeof(eventData),
331 params.m_name.c_str(),
332 params.m_name.size() + 1);
333 }
334 else
335 {
336 MOS_OS_ASSERTMESSAGE("Fail to Alloc %7d bytes (%d x %d resource).",bufSize, params.m_width, params.m_height);
337 status = MOS_STATUS_NO_SPACE;
338 }
339 MOS_TraceEventExt(EVENT_RESOURCE_ALLOCATE, EVENT_TYPE_END, &status, sizeof(status), nullptr, 0);
340
341 m_memAllocCounterGfx++;
342 return status;
343 }
344
Free(OsContext * osContextPtr,uint32_t freeFlag)345 void GraphicsResourceSpecific::Free(OsContext* osContextPtr, uint32_t freeFlag)
346 {
347 MOS_OS_FUNCTION_ENTER;
348
349 MOS_UNUSED(osContextPtr);
350 MOS_UNUSED(freeFlag);
351
352 OsContextSpecific *pOsContextSpecific = static_cast<OsContextSpecific *>(osContextPtr);
353
354 MOS_LINUX_BO* boPtr = m_bo;
355
356 if (boPtr)
357 {
358 AuxTableMgr *auxTableMgr = pOsContextSpecific->GetAuxTableMgr();
359 if (auxTableMgr)
360 {
361 auxTableMgr->UnmapResource(m_gmmResInfo, boPtr);
362 }
363 mos_bo_unreference(boPtr);
364 m_bo = nullptr;
365 if (nullptr != m_gmmResInfo)
366 {
367 pOsContextSpecific->GetGmmClientContext()->DestroyResInfoObject(m_gmmResInfo);
368 m_gmmResInfo = nullptr;
369 m_memAllocCounterGfx--;
370 }
371 }
372 return;
373 }
374
IsEqual(GraphicsResource * toCompare)375 bool GraphicsResourceSpecific::IsEqual(GraphicsResource* toCompare)
376 {
377 if (toCompare == nullptr)
378 {
379 return false;
380 }
381
382 GraphicsResourceSpecific *resSpecificPtr = static_cast<GraphicsResourceSpecific *>(toCompare);
383
384 return (m_bo == resSpecificPtr->m_bo);
385 }
386
IsValid()387 bool GraphicsResourceSpecific::IsValid()
388 {
389 return (m_bo != nullptr);
390 }
391
ConvertToMosResource(MOS_RESOURCE * pMosResource)392 MOS_STATUS GraphicsResourceSpecific::ConvertToMosResource(MOS_RESOURCE* pMosResource)
393 {
394 if (pMosResource == nullptr)
395 {
396 return MOS_STATUS_INVALID_PARAMETER;
397 }
398
399 pMosResource->Format = m_format;
400 pMosResource->iWidth = m_width;
401 pMosResource->iHeight = m_height;
402 pMosResource->iPitch = m_pitch;
403 pMosResource->iDepth = m_depth;
404 pMosResource->TileType = m_tileType;
405 pMosResource->TileModeGMM = m_tileModeGMM;
406 pMosResource->bGMMTileEnabled = m_isGMMTileEnabled;
407 pMosResource->iCount = 0;
408 pMosResource->pData = m_pData;
409 pMosResource->bufname = m_name.c_str();
410 pMosResource->bo = m_bo;
411 pMosResource->bMapped = m_mapped;
412 pMosResource->MmapOperation = m_mmapOperation;
413 pMosResource->pGmmResInfo = m_gmmResInfo;
414
415 pMosResource->user_provided_va = m_userProvidedVA;
416
417 pMosResource->memObjCtrlState = m_memObjCtrlState;
418 pMosResource->mocsMosResUsageType = m_mocsMosResUsageType;
419
420 pMosResource->pGfxResource = this;
421
422 return MOS_STATUS_SUCCESS;
423 }
424
Lock(OsContext * osContextPtr,LockParams & params)425 void* GraphicsResourceSpecific::Lock(OsContext* osContextPtr, LockParams& params)
426 {
427 MOS_OS_FUNCTION_ENTER;
428
429 if (osContextPtr == nullptr)
430 {
431 MOS_OS_ASSERTMESSAGE("Unable to get the active OS context.");
432 return nullptr;
433 }
434
435 if (osContextPtr ->GetOsContextValid() == false)
436 {
437 MOS_OS_ASSERTMESSAGE("The OS context got is not valid.");
438 return nullptr;
439 }
440
441 OsContextSpecific *pOsContextSpecific = static_cast<OsContextSpecific *>(osContextPtr);
442
443 void* dataPtr = nullptr;
444 MOS_LINUX_BO* boPtr = m_bo;
445
446 if (boPtr)
447 {
448 // Do decompression for a compressed surface before lock
449 const auto pGmmResInfo = m_gmmResInfo;
450 MOS_OS_ASSERT(pGmmResInfo);
451 GMM_RESOURCE_FLAG GmmFlags = pGmmResInfo->GetResFlags();
452
453 if (!params.m_noDecompress &&
454 (((GmmFlags.Gpu.MMC || GmmFlags.Gpu.CCS) && GmmFlags.Info.MediaCompressed) ||
455 pGmmResInfo->IsMediaMemoryCompressed(0)))
456 {
457 if ((pOsContextSpecific->m_mediaMemDecompState == nullptr) ||
458 (pOsContextSpecific->m_memoryDecompress == nullptr))
459 {
460 MOS_OS_ASSERTMESSAGE("m_mediaMemDecompState/m_memoryDecompress is not valid.");
461 return nullptr;
462 }
463
464 MOS_RESOURCE mosResource = {};
465 ConvertToMosResource(&mosResource);
466 pOsContextSpecific->m_memoryDecompress(pOsContextSpecific->m_mosContext, &mosResource);
467 }
468
469 if(false == m_mapped)
470 {
471 if (pOsContextSpecific->IsAtomSoc())
472 {
473 mos_bo_map_gtt(boPtr);
474 }
475 else
476 {
477 if (m_tileType != MOS_TILE_LINEAR && !params.m_tileAsTiled)
478 {
479 if (pOsContextSpecific->UseSwSwizzling())
480 {
481 mos_bo_map(boPtr, ( OSKM_LOCKFLAG_WRITEONLY & params.m_writeRequest ));
482 m_mmapOperation = MOS_MMAP_OPERATION_MMAP;
483 if (m_systemShadow == nullptr)
484 {
485 m_systemShadow = (uint8_t *)MOS_AllocMemory(boPtr->size);
486 MOS_OS_CHECK_CONDITION((m_systemShadow == nullptr), "Failed to allocate shadow surface", nullptr);
487 }
488 if (m_systemShadow)
489 {
490 int32_t flags = pOsContextSpecific->GetTileYFlag() ? 0 : 1;
491 uint64_t surfSize = m_gmmResInfo->GetSizeMainSurface();
492 MOS_OS_CHECK_CONDITION((m_tileType != MOS_TILE_Y), "Unsupported tile type", nullptr);
493 MOS_OS_CHECK_CONDITION((boPtr->size <= 0 || m_pitch <= 0), "Invalid BO size or pitch", nullptr);
494 Mos_SwizzleData((uint8_t*)boPtr->virt, m_systemShadow,
495 MOS_TILE_Y, MOS_TILE_LINEAR,
496 (int32_t)(surfSize / m_pitch), m_pitch, flags);
497 }
498 }
499 else
500 {
501 mos_bo_map_gtt(boPtr);
502 m_mmapOperation = MOS_MMAP_OPERATION_MMAP_GTT;
503 }
504 }
505 else if (params.m_uncached)
506 {
507 mos_bo_map_wc(boPtr);
508 m_mmapOperation = MOS_MMAP_OPERATION_MMAP_WC;
509 }
510 else
511 {
512 mos_bo_map(boPtr, ( OSKM_LOCKFLAG_WRITEONLY & params.m_writeRequest ));
513 m_mmapOperation = MOS_MMAP_OPERATION_MMAP;
514 }
515 }
516 m_mapped = true;
517 m_pData = m_systemShadow ? m_systemShadow : (uint8_t *)boPtr->virt;
518 }
519
520 dataPtr = m_pData;
521 }
522
523 MOS_OS_ASSERT(dataPtr);
524 return dataPtr;
525 }
526
Unlock(OsContext * osContextPtr)527 MOS_STATUS GraphicsResourceSpecific::Unlock(OsContext* osContextPtr)
528 {
529 MOS_OS_FUNCTION_ENTER;
530
531 if (osContextPtr == nullptr)
532 {
533 MOS_OS_ASSERTMESSAGE("Unable to get the active OS context.");
534 return MOS_STATUS_INVALID_HANDLE;
535 }
536
537 if (osContextPtr ->GetOsContextValid() == false)
538 {
539 MOS_OS_ASSERTMESSAGE("The OS context got is not valid.");
540 return MOS_STATUS_INVALID_HANDLE;
541 }
542
543 OsContextSpecific *pOsContextSpecific = static_cast<OsContextSpecific *>(osContextPtr);
544
545 MOS_LINUX_BO* boPtr = m_bo;
546 if (boPtr)
547 {
548 if (m_mapped)
549 {
550 if (pOsContextSpecific->IsAtomSoc())
551 {
552 mos_bo_unmap_gtt(boPtr);
553 }
554 else
555 {
556 if (m_systemShadow)
557 {
558 int32_t flags = pOsContextSpecific->GetTileYFlag() ? 0 : 1;
559 uint64_t surfSize = m_gmmResInfo->GetSizeMainSurface();
560 Mos_SwizzleData(m_systemShadow, (uint8_t*)boPtr->virt,
561 MOS_TILE_LINEAR, MOS_TILE_Y,
562 (int32_t)(surfSize / m_pitch), m_pitch, flags);
563 MOS_FreeMemory(m_systemShadow);
564 m_systemShadow = nullptr;
565 }
566
567 switch(m_mmapOperation)
568 {
569 case MOS_MMAP_OPERATION_MMAP_GTT:
570 mos_bo_unmap_gtt(boPtr);
571 break;
572 case MOS_MMAP_OPERATION_MMAP_WC:
573 mos_bo_unmap_wc(boPtr);
574 break;
575 case MOS_MMAP_OPERATION_MMAP:
576 mos_bo_unmap(boPtr);
577 break;
578 default:
579 MOS_OS_ASSERTMESSAGE("Invalid mmap operation type");
580 break;
581 }
582 }
583
584 m_mapped = false;
585 m_mmapOperation = MOS_MMAP_OPERATION_NONE;
586
587 boPtr->virt = nullptr;
588 m_bo = boPtr;
589 }
590
591 m_pData = nullptr;
592 }
593
594 return MOS_STATUS_SUCCESS;
595 }
596
SetTileModebyForce(GMM_RESCREATE_PARAMS & gmmParams,MOS_TILE_MODE_GMM tileMode)597 MOS_STATUS GraphicsResourceSpecific::SetTileModebyForce(GMM_RESCREATE_PARAMS &gmmParams, MOS_TILE_MODE_GMM tileMode)
598 {
599 if (tileMode == MOS_TILE_64_GMM)
600 {
601 gmmParams.Flags.Info.Tile64 = true;
602 }
603 else if (tileMode == MOS_TILE_4_GMM)
604 {
605 gmmParams.Flags.Info.Tile4 = true;
606 }
607 return MOS_STATUS_SUCCESS;
608 }
609