| 1 |
/* |
| 2 |
* Copyright (c) 2009-2023, 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_os_specific.c |
| 24 |
//! \brief Common interface used in MOS LINUX OS |
| 25 |
//! \details Common interface used in MOS LINUX OS |
| 26 |
//! |
| 27 |
#include <unistd.h> |
| 28 |
#include <dlfcn.h> |
| 29 |
#include <stdlib.h> |
| 30 |
|
| 31 |
#include "mos_os.h" |
| 32 |
#include "mos_os_cp_interface_specific.h" |
| 33 |
#include "mos_util_debug.h" |
| 34 |
#include "mos_resource_defs.h" |
| 35 |
#include "hwinfo_linux.h" |
| 36 |
#include "mos_graphicsresource.h" |
| 37 |
#include "mos_context_specific.h" |
| 38 |
#include "mos_gpucontext_specific.h" |
| 39 |
#include "mos_gpucontextmgr.h" |
| 40 |
|
| 41 |
#include "mos_graphicsresource_next.h" |
| 42 |
#include "mos_context_specific_next.h" |
| 43 |
#include "mos_gpucontext_specific_next.h" |
| 44 |
#include "mos_gpucontextmgr_next.h" |
| 45 |
#include "mos_interface.h" |
| 46 |
|
| 47 |
#if MOS_MEDIASOLO_SUPPORTED |
| 48 |
#include "mos_os_solo.h" |
| 49 |
#endif // MOS_MEDIASOLO_SUPPORTED |
| 50 |
#include "mos_solo_generic.h" |
| 51 |
|
| 52 |
#ifndef ANDROID |
| 53 |
#include <sys/ipc.h> |
| 54 |
#include <sys/shm.h> |
| 55 |
#include <sys/sem.h> |
| 56 |
#include <sys/types.h> |
| 57 |
#endif |
| 58 |
|
| 59 |
#include "mos_os_virtualengine.h" |
| 60 |
#include "mos_util_user_interface.h" |
| 61 |
|
| 62 |
#include "mos_os_virtualengine_singlepipe_next.h" |
| 63 |
#include "mos_os_virtualengine_scalability_next.h" |
| 64 |
|
| 65 |
#include "memory_policy_manager.h" |
| 66 |
#include "mos_oca_interface_specific.h" |
| 67 |
#include "mos_os_next.h" |
| 68 |
#include "levelzero_npu_interface.h" |
| 69 |
|
| 70 |
extern int32_t CreateCmDevice(MOS_CONTEXT *mosContext, |
| 71 |
CMRT_UMD::CmDevice* &device, |
| 72 |
uint32_t devCreateOption, |
| 73 |
uint8_t priority); |
| 74 |
|
| 75 |
extern int32_t DestroyCmDevice(CMRT_UMD::CmDevice* &device); |
| 76 |
|
| 77 |
extern MOS_STATUS InitCmOsDDIInterface(PCM_HAL_STATE cmState); |
| 78 |
|
| 79 |
//! |
| 80 |
//! \brief DRM VMAP patch |
| 81 |
//! |
| 82 |
#define Y_TILE_WIDTH 128 |
| 83 |
#define Y_TILE_HEIGHT 32 |
| 84 |
#define X_TILE_WIDTH 512 |
| 85 |
#define X_TILE_HEIGHT 8 |
| 86 |
|
| 87 |
#define MI_BATCHBUFFER_END 0x05000000 |
| 88 |
|
| 89 |
//! |
| 90 |
//! \brief Two VDBOX shared memory key |
| 91 |
//! |
| 92 |
#define DUAL_VDBOX_KEY ('D'<<24|'V'<<8|'X'<<0) |
| 93 |
|
| 94 |
//============= PRIVATE FUNCTIONS <BEGIN>========================================= |
| 95 |
|
| 96 |
bool SetupMediaSoloSwitch() |
| 97 |
{ |
| 98 |
bool mediaSoloEnabled = false; |
| 99 |
MosUtilities::MosReadMediaSoloEnabledUserFeature(mediaSoloEnabled); |
| 100 |
return mediaSoloEnabled; |
| 101 |
} |
| 102 |
|
| 103 |
bool SetupApoDdiSwitch(int32_t fd, MediaUserSettingSharedPtr userSettingPtr) |
| 104 |
{ |
| 105 |
if (fd < 0) |
| 106 |
{ |
| 107 |
return false; |
| 108 |
} |
| 109 |
|
| 110 |
//Read user feature to determine if apg mos is enabled. |
| 111 |
uint32_t userfeatureValue = 0; |
| 112 |
MOS_STATUS estatus = MosUtilities::MosReadApoDdiEnabledUserFeature(userfeatureValue, nullptr, userSettingPtr); |
| 113 |
|
| 114 |
return (userfeatureValue != 0); |
| 115 |
} |
| 116 |
|
| 117 |
bool SetupApoMosSwitch(int32_t fd, MediaUserSettingSharedPtr userSettingPtr) |
| 118 |
{ |
| 119 |
if (fd < 0) |
| 120 |
{ |
| 121 |
return false; |
| 122 |
} |
| 123 |
|
| 124 |
//Read user feature to determine if apg mos is enabled. |
| 125 |
uint32_t userfeatureValue = 0; |
| 126 |
MOS_STATUS estatus = MosUtilities::MosReadApoMosEnabledUserFeature(userfeatureValue, nullptr, userSettingPtr); |
| 127 |
|
| 128 |
if(estatus == MOS_STATUS_SUCCESS) |
| 129 |
{ |
| 130 |
return (userfeatureValue != 0); |
| 131 |
} |
| 132 |
PRODUCT_FAMILY eProductFamily = IGFX_UNKNOWN; |
| 133 |
HWInfo_GetGfxProductFamily(fd, eProductFamily); |
| 134 |
|
| 135 |
if (eProductFamily >= IGFX_TIGERLAKE_LP) |
| 136 |
{ |
| 137 |
return true; |
| 138 |
} |
| 139 |
|
| 140 |
return false; |
| 141 |
} |
| 142 |
|
| 143 |
|
| 144 |
//! |
| 145 |
//! \brief Clear Gpu Context |
| 146 |
//! \details OS GPU context clear |
| 147 |
//! \param PMOS_RESOURCE pContext |
| 148 |
//! [in] Pointer to OS context |
| 149 |
//! \return void |
| 150 |
//! Return NONE |
| 151 |
//! |
| 152 |
void Mos_Specific_ClearGpuContext(MOS_CONTEXT *pContext) |
| 153 |
{ |
| 154 |
int32_t iLoop = 0; |
| 155 |
|
| 156 |
MOS_OS_FUNCTION_ENTER; |
| 157 |
|
| 158 |
if (nullptr == pContext) |
| 159 |
{ |
| 160 |
MOS_OS_ASSERTMESSAGE("Input mos context is null"); |
| 161 |
return; |
| 162 |
} |
| 163 |
|
| 164 |
for (iLoop = 0; iLoop < MOS_GPU_CONTEXT_MAX; iLoop++) |
| 165 |
{ |
| 166 |
if (pContext->OsGpuContext[iLoop].pCB != nullptr) |
| 167 |
{ |
| 168 |
MOS_FreeMemory(pContext->OsGpuContext[iLoop].pCB); |
| 169 |
pContext->OsGpuContext[iLoop].pCB = nullptr; |
| 170 |
} |
| 171 |
|
| 172 |
if (pContext->OsGpuContext[iLoop].pAllocationList != nullptr) |
| 173 |
{ |
| 174 |
MOS_FreeMemory(pContext->OsGpuContext[iLoop].pAllocationList); |
| 175 |
pContext->OsGpuContext[iLoop].pAllocationList = nullptr; |
| 176 |
} |
| 177 |
|
| 178 |
if (pContext->OsGpuContext[iLoop].pPatchLocationList) |
| 179 |
{ |
| 180 |
MOS_FreeMemory(pContext->OsGpuContext[iLoop].pPatchLocationList); |
| 181 |
pContext->OsGpuContext[iLoop].pPatchLocationList = nullptr; |
| 182 |
} |
| 183 |
|
| 184 |
if (pContext->OsGpuContext[iLoop].pResources != nullptr) |
| 185 |
{ |
| 186 |
MOS_FreeMemory(pContext->OsGpuContext[iLoop].pResources); |
| 187 |
pContext->OsGpuContext[iLoop].pResources = nullptr; |
| 188 |
} |
| 189 |
|
| 190 |
if (pContext->OsGpuContext[iLoop].pbWriteMode != nullptr) |
| 191 |
{ |
| 192 |
MOS_FreeMemory(pContext->OsGpuContext[iLoop].pbWriteMode); |
| 193 |
pContext->OsGpuContext[iLoop].pbWriteMode = nullptr; |
| 194 |
} |
| 195 |
|
| 196 |
pContext->OsGpuContext[iLoop].uiMaxNumAllocations = 0; |
| 197 |
pContext->OsGpuContext[iLoop].uiMaxPatchLocationsize = 0; |
| 198 |
} |
| 199 |
} |
| 200 |
|
| 201 |
//! |
| 202 |
//! \brief Unified OS get command buffer |
| 203 |
//! \details Return the pointer to the next available space in Cmd Buffer |
| 204 |
//! \param PMOS_CONTEXT pOsContext |
| 205 |
//! [in] Pointer to OS Context |
| 206 |
//! \param PMOS_COMMAND_BUFFER pCmdBuffer |
| 207 |
//! [out] Pointer to Command Buffer |
| 208 |
//! \param int32_t iSize |
| 209 |
//! [out] Size of command in bytes |
| 210 |
//! \return int32_t |
| 211 |
//! Return true is there is space |
| 212 |
//! |
| 213 |
int32_t Linux_GetCommandBuffer( |
| 214 |
PMOS_CONTEXT pOsContext, |
| 215 |
PMOS_COMMAND_BUFFER pCmdBuffer, |
| 216 |
int32_t iSize) |
| 217 |
{ |
| 218 |
int32_t bResult = false; |
| 219 |
MOS_LINUX_BO *cmd_bo = nullptr; |
| 220 |
struct mos_drm_bo_alloc alloc; |
| 221 |
|
| 222 |
if ( pOsContext == nullptr || |
| 223 |
pCmdBuffer == nullptr) |
| 224 |
{ |
| 225 |
bResult = false; |
| 226 |
MOS_OS_ASSERTMESSAGE("Linux_GetCommandBuffer:pOsContext == nullptr || pCmdBuffer == NULL"); |
| 227 |
goto finish; |
| 228 |
} |
| 229 |
|
| 230 |
// Allocate the command buffer from GEM |
| 231 |
alloc.name = "MOS CmdBuf"; |
| 232 |
alloc.size = iSize; |
| 233 |
alloc.alignment = 4096; |
| 234 |
alloc.ext.mem_type = MOS_MEMPOOL_SYSTEMMEMORY; |
| 235 |
cmd_bo = mos_bo_alloc(pOsContext->bufmgr, &alloc); // Align to page boundary |
| 236 |
if (cmd_bo == nullptr) |
| 237 |
{ |
| 238 |
MOS_OS_ASSERTMESSAGE("Allocation of command buffer failed."); |
| 239 |
bResult = false; |
| 240 |
goto finish; |
| 241 |
} |
| 242 |
//MOS_OS_NORMALMESSAGE("alloc CMB, bo is 0x%x.", cmd_bo); |
| 243 |
|
| 244 |
// Map command buffer to user virtual address |
| 245 |
if (mos_bo_map(cmd_bo,1) != 0) // Write enable set |
| 246 |
{ |
| 247 |
MOS_OS_ASSERTMESSAGE("Mapping of command buffer failed."); |
| 248 |
bResult = false; |
| 249 |
goto finish; |
| 250 |
} |
| 251 |
|
| 252 |
Mos_ResetResource(&pCmdBuffer->OsResource); |
| 253 |
|
| 254 |
// Fill in resource information |
| 255 |
pCmdBuffer->OsResource.Format = Format_Buffer; |
| 256 |
pCmdBuffer->OsResource.iWidth = cmd_bo->size; |
| 257 |
pCmdBuffer->OsResource.iHeight = 1; |
| 258 |
pCmdBuffer->OsResource.iPitch = cmd_bo->size; |
| 259 |
pCmdBuffer->OsResource.iSize = pCmdBuffer->OsResource.iPitch * pCmdBuffer->OsResource.iHeight; |
| 260 |
pCmdBuffer->OsResource.iCount = 1; |
| 261 |
pCmdBuffer->OsResource.pData = (uint8_t*)cmd_bo->virt; |
| 262 |
pCmdBuffer->OsResource.TileType = MOS_TILE_LINEAR; |
| 263 |
pCmdBuffer->OsResource.bo = cmd_bo; |
| 264 |
pCmdBuffer->OsResource.bMapped = true; |
| 265 |
|
| 266 |
// for MOS wrapper to avoid memory leak |
| 267 |
pCmdBuffer->OsResource.bConvertedFromDDIResource = true; |
| 268 |
|
| 269 |
pCmdBuffer->pCmdBase = (uint32_t*)cmd_bo->virt; |
| 270 |
pCmdBuffer->pCmdPtr = (uint32_t*)cmd_bo->virt; |
| 271 |
pCmdBuffer->iOffset = 0; |
| 272 |
pCmdBuffer->iRemaining = cmd_bo->size; |
| 273 |
pCmdBuffer->iCmdIndex = -1; |
| 274 |
pCmdBuffer->iVdboxNodeIndex = MOS_VDBOX_NODE_INVALID; |
| 275 |
pCmdBuffer->iVeboxNodeIndex = MOS_VEBOX_NODE_INVALID; |
| 276 |
pCmdBuffer->is1stLvlBB = true; |
| 277 |
MOS_ZeroMemory(pCmdBuffer->pCmdBase, cmd_bo->size); |
| 278 |
pCmdBuffer->iSubmissionType = SUBMISSION_TYPE_SINGLE_PIPE; |
| 279 |
MOS_ZeroMemory(&pCmdBuffer->Attributes, sizeof(pCmdBuffer->Attributes)); |
| 280 |
bResult = true; |
| 281 |
|
| 282 |
finish: |
| 283 |
if ((false == bResult)&&(nullptr != cmd_bo)){ |
| 284 |
//need to unreference command buffer allocated. |
| 285 |
mos_bo_unreference(cmd_bo); |
| 286 |
} |
| 287 |
return bResult; |
| 288 |
} |
| 289 |
|
| 290 |
//! |
| 291 |
//! \brief Get unused command buffer space |
| 292 |
//! \details Return unused command buffer space |
| 293 |
//! \param PMOS_CONTEXT pOsContext |
| 294 |
//! [in] Pointer to OS Context |
| 295 |
//! \param MOS_GPU_CONTEXT GpuContext |
| 296 |
//! [in] GPU context |
| 297 |
//! \param PMOS_COMMAND_BUFFER pCmdBuffer |
| 298 |
//! [out] Pointer to Command buffer |
| 299 |
//! \return void |
| 300 |
//! |
| 301 |
void Linux_ReturnCommandBuffer( |
| 302 |
PMOS_CONTEXT pOsContext, |
| 303 |
MOS_GPU_CONTEXT GpuContext, |
| 304 |
PMOS_COMMAND_BUFFER pCmdBuffer) |
| 305 |
{ |
| 306 |
MOS_OS_GPU_CONTEXT *pOsGpuContext; |
| 307 |
|
| 308 |
if (pOsContext == nullptr || pCmdBuffer == nullptr || |
| 309 |
Mos_ResourceIsNull(&(pCmdBuffer->OsResource))) |
| 310 |
{ |
| 311 |
MOS_OS_ASSERTMESSAGE("Invalid input parameter pOsContext or pCmdBuffer."); |
| 312 |
goto finish; |
| 313 |
} |
| 314 |
|
| 315 |
if (GpuContext == MOS_GPU_CONTEXT_INVALID_HANDLE) |
| 316 |
{ |
| 317 |
MOS_OS_ASSERTMESSAGE("Invalid input parameter GpuContext."); |
| 318 |
goto finish; |
| 319 |
} |
| 320 |
|
| 321 |
pOsGpuContext = &pOsContext->OsGpuContext[GpuContext]; |
| 322 |
if (pOsContext == nullptr) |
| 323 |
{ |
| 324 |
MOS_OS_ASSERTMESSAGE("Os gpucontext is null."); |
| 325 |
goto finish; |
| 326 |
} |
| 327 |
|
| 328 |
pOsGpuContext->pCB->iOffset = pCmdBuffer->iOffset ; |
| 329 |
pOsGpuContext->pCB->iRemaining = pCmdBuffer->iRemaining; |
| 330 |
pOsGpuContext->pCB->pCmdPtr = pCmdBuffer->pCmdPtr; |
| 331 |
pOsGpuContext->pCB->iVdboxNodeIndex = pCmdBuffer->iVdboxNodeIndex; |
| 332 |
pOsGpuContext->pCB->iVeboxNodeIndex = pCmdBuffer->iVeboxNodeIndex; |
| 333 |
pOsGpuContext->pCB->is1stLvlBB = pCmdBuffer->is1stLvlBB; |
| 334 |
|
| 335 |
finish: |
| 336 |
return; |
| 337 |
} |
| 338 |
|
| 339 |
//! |
| 340 |
//! \brief Flush Command Buffer |
| 341 |
//! \details Flush Command Buffer space |
| 342 |
//! \param PMOS_CONTEXT pOsContext |
| 343 |
//! [in] Pointer to OS Context |
| 344 |
//! \param MOS_GPU_CONTEXT GpuContext |
| 345 |
//! [in] GPU context |
| 346 |
//! \return int32_t |
| 347 |
//! true if succeeded, false if failed or invalid parameters |
| 348 |
//! |
| 349 |
int32_t Linux_FlushCommandBuffer( |
| 350 |
PMOS_CONTEXT pOsContext, |
| 351 |
MOS_GPU_CONTEXT GpuContext) |
| 352 |
{ |
| 353 |
PCOMMAND_BUFFER pCurrCB; |
| 354 |
int32_t bResult = false; |
| 355 |
PMOS_OS_GPU_CONTEXT pOsGpuContext; |
| 356 |
|
| 357 |
if (pOsContext == nullptr) |
| 358 |
{ |
| 359 |
MOS_OS_ASSERTMESSAGE("Invalid input parameter pOsContext.") |
| 360 |
goto finish; |
| 361 |
} |
| 362 |
|
| 363 |
if (GpuContext == MOS_GPU_CONTEXT_INVALID_HANDLE) |
| 364 |
{ |
| 365 |
MOS_OS_ASSERTMESSAGE("Invalid input parameter GpuContext."); |
| 366 |
goto finish; |
| 367 |
} |
| 368 |
|
| 369 |
pOsGpuContext = &pOsContext->OsGpuContext[GpuContext]; |
| 370 |
if (pOsGpuContext == nullptr) |
| 371 |
{ |
| 372 |
MOS_OS_ASSERTMESSAGE("Invalid OsGpuContext"); |
| 373 |
goto finish; |
| 374 |
} |
| 375 |
|
| 376 |
// Refresh command buffer usage |
| 377 |
pOsContext->pfnRefresh(pOsContext); |
| 378 |
|
| 379 |
pOsGpuContext->uiCurrentNumPatchLocations = 0; |
| 380 |
|
| 381 |
// CB already active |
| 382 |
pCurrCB = pOsGpuContext->pCurrentCB; |
| 383 |
if (pCurrCB == nullptr) |
| 384 |
{ |
| 385 |
MOS_OS_ASSERTMESSAGE("Invalid current CB in OsGpuContext."); |
| 386 |
goto finish; |
| 387 |
} |
| 388 |
|
| 389 |
if (pCurrCB->bActive) |
| 390 |
{ |
| 391 |
goto finish; |
| 392 |
} |
| 393 |
|
| 394 |
pCurrCB->bActive = true; |
| 395 |
bResult = true; |
| 396 |
|
| 397 |
finish: |
| 398 |
return bResult; |
| 399 |
} |
| 400 |
|
| 401 |
//! |
| 402 |
//! \brief Init command buffer pool |
| 403 |
//! \details Initilize the command buffer pool |
| 404 |
//! \param PMOS_CONTEXT pOsContext |
| 405 |
//! [in] Pointer to OS Context |
| 406 |
//! \return void |
| 407 |
//! |
| 408 |
void Linux_InitCmdBufferPool( |
| 409 |
PMOS_CONTEXT pOsContext) |
| 410 |
{ |
| 411 |
MOS_OS_FUNCTION_ENTER; |
| 412 |
|
| 413 |
MOS_ZeroMemory(&pOsContext->CmdBufferPool, sizeof(CMD_BUFFER_BO_POOL)); |
| 414 |
pOsContext->CmdBufferPool.iFetch = 0; |
| 415 |
} |
| 416 |
|
| 417 |
//! |
| 418 |
//! \brief Wait and release command buffer |
| 419 |
//! \details Command buffer Wait and release |
| 420 |
//! \param PMOS_CONTEXT pOsContext |
| 421 |
//! [in] Pointer to OS context structure |
| 422 |
//! \param int32_t index |
| 423 |
//! [in] Command buffer's index in Command buffer pool |
| 424 |
//! \return MOS_STATUS |
| 425 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 426 |
//! |
| 427 |
MOS_STATUS Linux_WaitAndReleaseCmdBuffer( |
| 428 |
PMOS_CONTEXT pOsContext, |
| 429 |
int32_t index) |
| 430 |
{ |
| 431 |
MOS_LINUX_BO *cmd_bo; |
| 432 |
MOS_STATUS eStatus; |
| 433 |
|
| 434 |
MOS_OS_FUNCTION_ENTER; |
| 435 |
|
| 436 |
eStatus = MOS_STATUS_SUCCESS; |
| 437 |
|
| 438 |
MOS_OS_CHK_NULL(pOsContext); |
| 439 |
|
| 440 |
if (index < 0 || index >= MAX_CMD_BUF_NUM) |
| 441 |
{ |
| 442 |
eStatus = MOS_STATUS_INVALID_PARAMETER; |
| 443 |
goto finish; |
| 444 |
} |
| 445 |
|
| 446 |
// According to the logic of CmdBufferPool now, the command buffer is used in a circular way. |
| 447 |
// The input index always points to the next(oldest) buffer after the latest(newest) buffer. |
| 448 |
// If the next buffer is not empty (!= nullptr), all the buffers in the pool will also be not empty. |
| 449 |
// So it's not necessary to check all buffers to see whether there's empty buffer. |
| 450 |
cmd_bo = pOsContext->CmdBufferPool.pCmd_bo[index]; |
| 451 |
if (cmd_bo != nullptr) |
| 452 |
{ |
| 453 |
mos_bo_wait_rendering(cmd_bo); |
| 454 |
mos_bo_unreference(cmd_bo); |
| 455 |
pOsContext->CmdBufferPool.pCmd_bo[index] = nullptr; |
| 456 |
} |
| 457 |
|
| 458 |
finish: |
| 459 |
return eStatus; |
| 460 |
} |
| 461 |
|
| 462 |
//! |
| 463 |
//! \brief Release command buffer pool |
| 464 |
//! \details Release command buffer pool until all of commands are finished. |
| 465 |
//! \param PMOS_CONTEXT pOsContext |
| 466 |
//! [in] Pointer to OS context structure |
| 467 |
//! \return MOS_STATUS |
| 468 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 469 |
//! |
| 470 |
MOS_STATUS Linux_ReleaseCmdBufferPool(PMOS_CONTEXT pOsContext) |
| 471 |
{ |
| 472 |
int32_t i; |
| 473 |
MOS_STATUS eStatus; |
| 474 |
|
| 475 |
MOS_OS_FUNCTION_ENTER; |
| 476 |
|
| 477 |
eStatus = MOS_STATUS_SUCCESS; |
| 478 |
|
| 479 |
MOS_OS_CHK_NULL(pOsContext); |
| 480 |
|
| 481 |
for (i = 0; i < MAX_CMD_BUF_NUM; i++) |
| 482 |
{ |
| 483 |
MOS_OS_CHK_STATUS(Linux_WaitAndReleaseCmdBuffer(pOsContext, i)); |
| 484 |
} |
| 485 |
|
| 486 |
finish: |
| 487 |
return eStatus; |
| 488 |
} |
| 489 |
|
| 490 |
//! |
| 491 |
//! \brief Wait for the fetch command |
| 492 |
//! \details Wait for the fetch command bo until it is available |
| 493 |
//! \param PMOS_CONTEXT pOsContext |
| 494 |
//! [in] Pointer to OS context structure |
| 495 |
//! \return MOS_STATUS |
| 496 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 497 |
//! |
| 498 |
MOS_STATUS Linux_WaitForAvailableCmdBo( |
| 499 |
PMOS_CONTEXT pOsContext) |
| 500 |
{ |
| 501 |
int32_t index; |
| 502 |
MOS_STATUS eStatus; |
| 503 |
|
| 504 |
MOS_OS_FUNCTION_ENTER; |
| 505 |
|
| 506 |
eStatus = MOS_STATUS_SUCCESS; |
| 507 |
|
| 508 |
MOS_OS_CHK_NULL(pOsContext); |
| 509 |
|
| 510 |
index = pOsContext->CmdBufferPool.iFetch; |
| 511 |
MOS_OS_CHK_STATUS(Linux_WaitAndReleaseCmdBuffer(pOsContext, index)); |
| 512 |
|
| 513 |
finish: |
| 514 |
return eStatus; |
| 515 |
} |
| 516 |
|
| 517 |
//! |
| 518 |
//! \brief Insert command buffer |
| 519 |
//! \details Insert command buffer into pool |
| 520 |
//! \param PMOS_CONTEXT pOsContext |
| 521 |
//! [in] Pointer to OS context structure |
| 522 |
//! \param PMOS_COMMAND_BUFFER pCmdBuffer |
| 523 |
//! [in] Pointer to command buffer struct |
| 524 |
//! \return MOS_STATUS |
| 525 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 526 |
//! |
| 527 |
MOS_STATUS Linux_InsertCmdBufferToPool( |
| 528 |
PMOS_CONTEXT pOsContext, |
| 529 |
PMOS_COMMAND_BUFFER pCmdBuffer) |
| 530 |
{ |
| 531 |
int32_t index = 0; |
| 532 |
MOS_STATUS eStatus; |
| 533 |
|
| 534 |
MOS_OS_FUNCTION_ENTER; |
| 535 |
|
| 536 |
eStatus = MOS_STATUS_SUCCESS; |
| 537 |
|
| 538 |
MOS_OS_CHK_NULL(pOsContext); |
| 539 |
MOS_OS_CHK_NULL(pCmdBuffer); |
| 540 |
MOS_OS_CHK_STATUS(Linux_WaitForAvailableCmdBo(pOsContext)); |
| 541 |
|
| 542 |
index = pOsContext->CmdBufferPool.iFetch; |
| 543 |
|
| 544 |
pOsContext->CmdBufferPool.pCmd_bo[index] = pCmdBuffer->OsResource.bo; |
| 545 |
pCmdBuffer->iCmdIndex = index; |
| 546 |
|
| 547 |
pOsContext->CmdBufferPool.iFetch++; |
| 548 |
if (pOsContext->CmdBufferPool.iFetch >= MAX_CMD_BUF_NUM) |
| 549 |
{ |
| 550 |
pOsContext->CmdBufferPool.iFetch = 0; |
| 551 |
} |
| 552 |
|
| 553 |
finish: |
| 554 |
return eStatus; |
| 555 |
} |
| 556 |
|
| 557 |
//! |
| 558 |
//! \brief Linux Refresh |
| 559 |
//! \details Linux Refresh |
| 560 |
//! \param MOS_CONTEXT * pOsContext |
| 561 |
//! [in] Pointer to OS context structure |
| 562 |
//! \return int32_t |
| 563 |
//! true always |
| 564 |
//! |
| 565 |
int32_t Linux_Refresh(MOS_CONTEXT *pOsContext) |
| 566 |
{ |
| 567 |
MOS_UNUSED(pOsContext); |
| 568 |
return true; |
| 569 |
} |
| 570 |
|
| 571 |
#ifndef ANDROID |
| 572 |
|
| 573 |
#define MOS_LINUX_IPC_INVALID_ID -1 |
| 574 |
#define MOS_LINUX_SHM_INVALID (void *)-1 |
| 575 |
#define MOS_LINUX_SEM_MAX_TRIES 10 |
| 576 |
|
| 577 |
static MOS_STATUS DetachDestroyShm(int32_t shmid, void *pShm) |
| 578 |
{ |
| 579 |
struct shmid_ds buf; |
| 580 |
MOS_ZeroMemory(&buf, sizeof(buf)); |
| 581 |
|
| 582 |
if (shmid < 0) |
| 583 |
{ |
| 584 |
return MOS_STATUS_UNKNOWN; |
| 585 |
} |
| 586 |
|
| 587 |
if ((pShm != MOS_LINUX_SHM_INVALID) && (pShm != nullptr) && shmdt(pShm) < 0) |
| 588 |
{ |
| 589 |
return MOS_STATUS_UNKNOWN; |
| 590 |
} |
| 591 |
|
| 592 |
if (shmctl(shmid, IPC_STAT, &buf) < 0) |
| 593 |
{ |
| 594 |
return MOS_STATUS_UNKNOWN; |
| 595 |
} |
| 596 |
|
| 597 |
if (buf.shm_nattch == 0) |
| 598 |
{ |
| 599 |
if (shmctl(shmid, IPC_RMID, nullptr) < 0) |
| 600 |
{ |
| 601 |
return MOS_STATUS_UNKNOWN; |
| 602 |
} |
| 603 |
} |
| 604 |
return MOS_STATUS_SUCCESS; |
| 605 |
} |
| 606 |
|
| 607 |
static MOS_STATUS ConnectCreateShm(long key, uint32_t size, int32_t *pShmid, void **ppShm) |
| 608 |
{ |
| 609 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 610 |
MOS_OS_CHK_NULL_RETURN(pShmid); |
| 611 |
MOS_OS_CHK_NULL_RETURN(ppShm); |
| 612 |
|
| 613 |
struct shmid_ds buf; |
| 614 |
int32_t shmid = -1; |
| 615 |
key_t key_value = (key_t)key; |
| 616 |
void * shmptr = nullptr; |
| 617 |
MOS_ZeroMemory(&buf, sizeof(buf)); |
| 618 |
|
| 619 |
shmid = shmget(key_value, size, IPC_CREAT | 0666); |
| 620 |
if (shmid < 0) |
| 621 |
{ |
| 622 |
return MOS_STATUS_UNKNOWN; |
| 623 |
} |
| 624 |
|
| 625 |
shmptr = shmat(shmid, 0, 0); |
| 626 |
if (shmptr == MOS_LINUX_SHM_INVALID) |
| 627 |
{ |
| 628 |
DetachDestroyShm(shmid, shmptr); |
| 629 |
return MOS_STATUS_UNKNOWN; |
| 630 |
} |
| 631 |
|
| 632 |
if (shmctl(shmid, IPC_STAT, &buf) < 0) |
| 633 |
{ |
| 634 |
// can't get any status info |
| 635 |
DetachDestroyShm(shmid, shmptr); |
| 636 |
return MOS_STATUS_UNKNOWN; |
| 637 |
} |
| 638 |
|
| 639 |
*ppShm = shmptr; |
| 640 |
*pShmid = shmid; |
| 641 |
|
| 642 |
return MOS_STATUS_SUCCESS; |
| 643 |
} |
| 644 |
|
| 645 |
static MOS_STATUS ConnectCreateSemaphore(long key, int32_t *pSemid) |
| 646 |
{ |
| 647 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 648 |
MOS_OS_CHK_NULL_RETURN(pSemid); |
| 649 |
int32_t semid = -1; |
| 650 |
struct sembuf sop; |
| 651 |
struct semid_ds buf; |
| 652 |
uint32_t i = 0; |
| 653 |
key_t key_value = (key_t)key; |
| 654 |
int32_t val = 0; |
| 655 |
MOS_ZeroMemory(&sop, sizeof(sop)); |
| 656 |
MOS_ZeroMemory(&buf, sizeof(buf)); |
| 657 |
|
| 658 |
semid = semget(key, 1, IPC_CREAT | IPC_EXCL | 0666); |
| 659 |
|
| 660 |
if (semid != MOS_LINUX_IPC_INVALID_ID) |
| 661 |
{ |
| 662 |
// initialize it to 0 |
| 663 |
if (semctl(semid, 0, SETVAL, val) == -1) |
| 664 |
{ |
| 665 |
return MOS_STATUS_UNKNOWN; |
| 666 |
} |
| 667 |
|
| 668 |
// Perform a "no-op" semaphore operation - changes sem_otime |
| 669 |
// so other processes can see we've initialized the set. |
| 670 |
sop.sem_num = 0; |
| 671 |
sop.sem_op = 0; //Wait for value to equal 0 |
| 672 |
sop.sem_flg = 0; |
| 673 |
if (semop(semid, &sop, 1) == -1) |
| 674 |
{ |
| 675 |
return MOS_STATUS_UNKNOWN; |
| 676 |
} |
| 677 |
|
| 678 |
} |
| 679 |
else |
| 680 |
{ |
| 681 |
// errno EEXIST |
| 682 |
semid = semget(key, 1, 0666); |
| 683 |
if (semid == MOS_LINUX_IPC_INVALID_ID) |
| 684 |
{ |
| 685 |
return MOS_STATUS_UNKNOWN; |
| 686 |
} |
| 687 |
} |
| 688 |
|
| 689 |
*pSemid = semid; |
| 690 |
|
| 691 |
return MOS_STATUS_SUCCESS; |
| 692 |
} |
| 693 |
|
| 694 |
static MOS_STATUS DestroySemaphore(int32_t semid) |
| 695 |
{ |
| 696 |
int32_t nwait = -1; |
| 697 |
|
| 698 |
if (semid < 0) |
| 699 |
{ |
| 700 |
return MOS_STATUS_UNKNOWN; |
| 701 |
} |
| 702 |
|
| 703 |
nwait = semctl(semid, 0, GETZCNT, 0); |
| 704 |
|
| 705 |
if (nwait > 0) |
| 706 |
{ |
| 707 |
return MOS_STATUS_SUCCESS; |
| 708 |
} |
| 709 |
|
| 710 |
if (semctl(semid, 0, IPC_RMID, nullptr) < 0) |
| 711 |
{ |
| 712 |
return MOS_STATUS_UNKNOWN; |
| 713 |
} |
| 714 |
|
| 715 |
return MOS_STATUS_SUCCESS; |
| 716 |
} |
| 717 |
|
| 718 |
static int16_t ShmAttachedNumber(int32_t shmid) |
| 719 |
{ |
| 720 |
struct shmid_ds buf; |
| 721 |
MOS_ZeroMemory(&buf, sizeof(buf)); |
| 722 |
|
| 723 |
if (shmctl(shmid, IPC_STAT, &buf) < 0) |
| 724 |
{ |
| 725 |
return -1; |
| 726 |
} |
| 727 |
|
| 728 |
return buf.shm_nattch; |
| 729 |
} |
| 730 |
|
| 731 |
static MOS_STATUS LockSemaphore(int32_t semid) |
| 732 |
{ |
| 733 |
struct sembuf op[2] = {}; |
| 734 |
op[0].sem_num = 0; // wait for [0] to be 0 |
| 735 |
op[0].sem_op = 0; |
| 736 |
op[0].sem_flg = 0; |
| 737 |
op[1].sem_num = 0; |
| 738 |
op[1].sem_op = 1; // increment |
| 739 |
op[1].sem_flg = SEM_UNDO; |
| 740 |
|
| 741 |
if (semid < 0) |
| 742 |
{ |
| 743 |
return MOS_STATUS_UNKNOWN; |
| 744 |
} |
| 745 |
|
| 746 |
if (semop(semid, op, 2) < 0) |
| 747 |
{ |
| 748 |
return MOS_STATUS_UNKNOWN; |
| 749 |
} |
| 750 |
|
| 751 |
return MOS_STATUS_SUCCESS; |
| 752 |
} |
| 753 |
|
| 754 |
static MOS_STATUS UnLockSemaphore(int32_t semid) |
| 755 |
{ |
| 756 |
struct sembuf op; |
| 757 |
op.sem_num = 0; |
| 758 |
op.sem_op = -1; // decrement back to 0 |
| 759 |
op.sem_flg = SEM_UNDO; |
| 760 |
|
| 761 |
if (semid < 0) |
| 762 |
{ |
| 763 |
return MOS_STATUS_UNKNOWN; |
| 764 |
} |
| 765 |
|
| 766 |
if (semop(semid, &op, 1) < 0) |
| 767 |
{ |
| 768 |
return MOS_STATUS_UNKNOWN; |
| 769 |
} |
| 770 |
|
| 771 |
return MOS_STATUS_SUCCESS; |
| 772 |
} |
| 773 |
|
| 774 |
void DestroyIPC(PMOS_CONTEXT pOsContext) |
| 775 |
{ |
| 776 |
if (MOS_LINUX_IPC_INVALID_ID != pOsContext->semid) |
| 777 |
{ |
| 778 |
int16_t iAttachedNum = 0; |
| 779 |
|
| 780 |
if (MOS_LINUX_IPC_INVALID_ID != pOsContext->shmid) |
| 781 |
{ |
| 782 |
LockSemaphore(pOsContext->semid); |
| 783 |
iAttachedNum = ShmAttachedNumber(pOsContext->shmid); |
| 784 |
|
| 785 |
DetachDestroyShm(pOsContext->shmid, pOsContext->pShm); |
| 786 |
pOsContext->shmid = MOS_LINUX_IPC_INVALID_ID; |
| 787 |
pOsContext->pShm = MOS_LINUX_SHM_INVALID; |
| 788 |
|
| 789 |
if (iAttachedNum) --iAttachedNum; |
| 790 |
UnLockSemaphore(pOsContext->semid); |
| 791 |
} |
| 792 |
} |
| 793 |
} |
| 794 |
|
| 795 |
MOS_STATUS CreateIPC(PMOS_CONTEXT pOsContext) |
| 796 |
{ |
| 797 |
MOS_STATUS eStatus; |
| 798 |
|
| 799 |
MOS_OS_CHK_NULL(pOsContext); |
| 800 |
pOsContext->semid = MOS_LINUX_IPC_INVALID_ID; |
| 801 |
pOsContext->shmid = MOS_LINUX_IPC_INVALID_ID; |
| 802 |
pOsContext->pShm = MOS_LINUX_SHM_INVALID; |
| 803 |
|
| 804 |
struct semid_ds buf; |
| 805 |
MOS_ZeroMemory(&buf, sizeof(buf)); |
| 806 |
|
| 807 |
//wait and retry untill to get a valid semaphore |
| 808 |
for (int i = 0; i < MOS_LINUX_SEM_MAX_TRIES; i ++) |
| 809 |
{ |
| 810 |
ConnectCreateSemaphore(DUAL_VDBOX_KEY, &pOsContext->semid); |
| 811 |
|
| 812 |
//check whether the semid is initialized or not |
| 813 |
if (semctl(pOsContext->semid, 0, IPC_STAT, &buf) == -1) |
| 814 |
{ |
| 815 |
return MOS_STATUS_UNKNOWN; |
| 816 |
} |
| 817 |
if (buf.sem_otime != 0) |
| 818 |
{ |
| 819 |
break; |
| 820 |
} |
| 821 |
|
| 822 |
MosUtilities::MosSleep(1); //wait and retry |
| 823 |
} |
| 824 |
|
| 825 |
LockSemaphore(pOsContext->semid); |
| 826 |
eStatus = ConnectCreateShm(DUAL_VDBOX_KEY, sizeof(VDBOX_WORKLOAD), &pOsContext->shmid, &pOsContext->pShm); |
| 827 |
UnLockSemaphore(pOsContext->semid); |
| 828 |
MOS_CHK_STATUS_SAFE(eStatus); |
| 829 |
|
| 830 |
finish: |
| 831 |
return eStatus; |
| 832 |
} |
| 833 |
#endif |
| 834 |
|
| 835 |
GpuContextSpecific* Linux_GetGpuContext(PMOS_INTERFACE pOsInterface, uint32_t gpuContextHandle) |
| 836 |
{ |
| 837 |
MOS_OS_FUNCTION_ENTER; |
| 838 |
|
| 839 |
if (pOsInterface == nullptr || pOsInterface->osContextPtr == nullptr) |
| 840 |
{ |
| 841 |
MOS_OS_ASSERTMESSAGE("invalid input parameters!"); |
| 842 |
return nullptr; |
| 843 |
} |
| 844 |
|
| 845 |
auto osCxtSpecific = static_cast<OsContextSpecific*>(pOsInterface->osContextPtr); |
| 846 |
|
| 847 |
auto gpuContextMgr = osCxtSpecific->GetGpuContextMgr(); |
| 848 |
if (gpuContextMgr == nullptr) |
| 849 |
{ |
| 850 |
MOS_OS_ASSERTMESSAGE("m_gpuContextMgr cannot be nullptr"); |
| 851 |
return nullptr; |
| 852 |
} |
| 853 |
|
| 854 |
auto gpuContext = gpuContextMgr->GetGpuContext(gpuContextHandle); |
| 855 |
if (gpuContext == nullptr) |
| 856 |
{ |
| 857 |
MOS_OS_ASSERTMESSAGE("cannot find the gpuContext corresponding to the active gpuContextHandle"); |
| 858 |
return nullptr; |
| 859 |
} |
| 860 |
|
| 861 |
auto gpuContextSpecific = static_cast<GpuContextSpecific *>(gpuContext); |
| 862 |
|
| 863 |
return gpuContextSpecific; |
| 864 |
} |
| 865 |
|
| 866 |
//! |
| 867 |
//! \brief Initialize the GPU Status Buffer |
| 868 |
//! \details Initialize the GPU Status Buffer |
| 869 |
//! \param MOS_CONTEXT * pOsContext |
| 870 |
//! [in, out] Pointer to OS context structure |
| 871 |
//! \return MOS_STATUS |
| 872 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 873 |
//! |
| 874 |
MOS_STATUS Linux_InitGPUStatus( |
| 875 |
PMOS_CONTEXT pOsContext) |
| 876 |
{ |
| 877 |
MOS_LINUX_BO *bo = nullptr; |
| 878 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 879 |
struct mos_drm_bo_alloc alloc; |
| 880 |
|
| 881 |
if (pOsContext == nullptr) |
| 882 |
{ |
| 883 |
MOS_OS_ASSERTMESSAGE("Linux_InitGPUStatus:pOsContext == NULL"); |
| 884 |
eStatus = MOS_STATUS_NULL_POINTER; |
| 885 |
goto finish; |
| 886 |
} |
| 887 |
|
| 888 |
pOsContext->pGPUStatusBuffer = |
| 889 |
(MOS_RESOURCE*)MOS_AllocAndZeroMemory(sizeof(MOS_RESOURCE) * MOS_GPU_CONTEXT_MAX); |
| 890 |
if (nullptr == pOsContext->pGPUStatusBuffer) |
| 891 |
{ |
| 892 |
MOS_OS_ASSERTMESSAGE("pContext->pGPUStatusBuffer malloc failed."); |
| 893 |
eStatus = MOS_STATUS_NO_SPACE; |
| 894 |
goto finish; |
| 895 |
} |
| 896 |
|
| 897 |
// Allocate the command buffer from GEM |
| 898 |
alloc.name = "GPU Status Buffer"; |
| 899 |
alloc.size = sizeof(MOS_GPU_STATUS_DATA) * MOS_GPU_CONTEXT_MAX; |
| 900 |
alloc.alignment = 4096; |
| 901 |
alloc.ext.mem_type = MOS_MEMPOOL_SYSTEMMEMORY; |
| 902 |
bo = mos_bo_alloc(pOsContext->bufmgr, &alloc); // Align to page boundary |
| 903 |
if (bo == nullptr) |
| 904 |
{ |
| 905 |
MOS_OS_ASSERTMESSAGE("Allocation of GPU Status Buffer failed."); |
| 906 |
eStatus = MOS_STATUS_NO_SPACE; |
| 907 |
goto finish; |
| 908 |
} |
| 909 |
|
| 910 |
// Map command buffer to user virtual address |
| 911 |
if (mos_bo_map(bo, 1) != 0) // Write enable set |
| 912 |
{ |
| 913 |
MOS_OS_ASSERTMESSAGE("Mapping of GPU Status Buffer failed."); |
| 914 |
eStatus = MOS_STATUS_INVALID_HANDLE; |
| 915 |
goto finish; |
| 916 |
} |
| 917 |
|
| 918 |
Mos_ResetResource(pOsContext->pGPUStatusBuffer); |
| 919 |
|
| 920 |
// Fill in resource information |
| 921 |
pOsContext->pGPUStatusBuffer->Format = Format_Buffer; |
| 922 |
pOsContext->pGPUStatusBuffer->iWidth = bo->size; |
| 923 |
pOsContext->pGPUStatusBuffer->iHeight = 1; |
| 924 |
pOsContext->pGPUStatusBuffer->iPitch = bo->size; |
| 925 |
pOsContext->pGPUStatusBuffer->iCount = 1; |
| 926 |
pOsContext->pGPUStatusBuffer->pData = (uint8_t*)bo->virt; |
| 927 |
pOsContext->pGPUStatusBuffer->TileType = MOS_TILE_LINEAR; |
| 928 |
pOsContext->pGPUStatusBuffer->bo = bo; |
| 929 |
pOsContext->pGPUStatusBuffer->bMapped = true; |
| 930 |
|
| 931 |
MOS_ZeroMemory(pOsContext->pGPUStatusBuffer->pData, bo->size); |
| 932 |
|
| 933 |
finish: |
| 934 |
return eStatus; |
| 935 |
} |
| 936 |
|
| 937 |
//! |
| 938 |
//! \brief Release the GPU Status Buffer |
| 939 |
//! \details Release the GPU Status Buffer |
| 940 |
//! \param MOS_CONTEXT * pOsContext |
| 941 |
//! [in, out] Pointer to OS context structure |
| 942 |
//! \return void |
| 943 |
//! |
| 944 |
void Linux_ReleaseGPUStatus( |
| 945 |
PMOS_CONTEXT pOsContext) |
| 946 |
{ |
| 947 |
MOS_LINUX_BO *bo = nullptr; |
| 948 |
|
| 949 |
if ( pOsContext == nullptr || pOsContext->pGPUStatusBuffer == nullptr) |
| 950 |
{ |
| 951 |
return; |
| 952 |
} |
| 953 |
|
| 954 |
bo = pOsContext->pGPUStatusBuffer->bo; |
| 955 |
if (bo != nullptr) |
| 956 |
{ |
| 957 |
mos_bo_unmap(bo); |
| 958 |
mos_bo_wait_rendering(bo); |
| 959 |
mos_bo_unreference(bo); |
| 960 |
} |
| 961 |
pOsContext->pGPUStatusBuffer->bo = nullptr; |
| 962 |
|
| 963 |
MOS_FreeMemAndSetNull(pOsContext->pGPUStatusBuffer); |
| 964 |
} |
| 965 |
|
| 966 |
//! |
| 967 |
//! \brief Get GPU status tag for the given GPU context |
| 968 |
//! \details Get GPU status tag for the given GPU context |
| 969 |
//! \param MOS_CONTEXT * pOsContext |
| 970 |
//! [in] Pointer to OS context structure |
| 971 |
//! \param MOS_GPU_CONTEXT GpuContext |
| 972 |
//! [in, out] GPU Context |
| 973 |
//! \return uint32_t |
| 974 |
//! GPU status tag |
| 975 |
//! |
| 976 |
uint32_t Linux_GetGpuCtxBufferTag( |
| 977 |
PMOS_CONTEXT pOsContext, |
| 978 |
MOS_GPU_CONTEXT GpuContext) |
| 979 |
{ |
| 980 |
if ( pOsContext == nullptr) |
| 981 |
{ |
| 982 |
MOS_OS_ASSERTMESSAGE("Invalid pOsContext."); |
| 983 |
return 0; |
| 984 |
} |
| 985 |
|
| 986 |
if (GpuContext == MOS_GPU_CONTEXT_INVALID_HANDLE) |
| 987 |
{ |
| 988 |
MOS_OS_ASSERTMESSAGE("Invalid input parameter GpuContext."); |
| 989 |
return 0; |
| 990 |
} |
| 991 |
|
| 992 |
return pOsContext->OsGpuContext[GpuContext].uiGPUStatusTag; |
| 993 |
} |
| 994 |
|
| 995 |
//! |
| 996 |
//! \brief Increment GPU status tag for the given GPU context |
| 997 |
//! \details Increment GPU status tag for the given GPU context |
| 998 |
//! \param MOS_CONTEXT * pOsContext |
| 999 |
//! [in] Pointer to OS context structure |
| 1000 |
//! \param MOS_GPU_CONTEXT GpuContext |
| 1001 |
//! [in] GPU Context |
| 1002 |
//! \return void |
| 1003 |
//! |
| 1004 |
void Linux_IncGpuCtxBufferTag( |
| 1005 |
PMOS_CONTEXT pOsContext, |
| 1006 |
MOS_GPU_CONTEXT GpuContext) |
| 1007 |
{ |
| 1008 |
uint32_t uiGPUStatusTag; |
| 1009 |
|
| 1010 |
if ( pOsContext == nullptr) |
| 1011 |
{ |
| 1012 |
MOS_OS_ASSERTMESSAGE("Invalid pOsContext."); |
| 1013 |
return; |
| 1014 |
} |
| 1015 |
|
| 1016 |
if (GpuContext == MOS_GPU_CONTEXT_INVALID_HANDLE) |
| 1017 |
{ |
| 1018 |
MOS_OS_ASSERTMESSAGE("Invalid input parameter GpuContext."); |
| 1019 |
return; |
| 1020 |
} |
| 1021 |
|
| 1022 |
uiGPUStatusTag = pOsContext->OsGpuContext[GpuContext].uiGPUStatusTag; |
| 1023 |
|
| 1024 |
pOsContext->OsGpuContext[GpuContext].uiGPUStatusTag = uiGPUStatusTag % UINT_MAX + 1; |
| 1025 |
if(pOsContext->OsGpuContext[GpuContext].uiGPUStatusTag == 0) |
| 1026 |
{ |
| 1027 |
pOsContext->OsGpuContext[GpuContext].uiGPUStatusTag = 1; |
| 1028 |
} |
| 1029 |
} |
| 1030 |
|
| 1031 |
GMM_CLIENT_CONTEXT* Linux_GetGmmClientContext(PMOS_CONTEXT pOsContext) |
| 1032 |
{ |
| 1033 |
if (pOsContext == nullptr) |
| 1034 |
{ |
| 1035 |
return nullptr; |
| 1036 |
} |
| 1037 |
return pOsContext->pGmmClientContext; |
| 1038 |
} |
| 1039 |
|
| 1040 |
//! |
| 1041 |
//! \brief Get GPU tag for the given GPU context from the status buffer |
| 1042 |
//! \details Get GPU tag for the given GPU context from the status buffer |
| 1043 |
//! \param MOS_CONTEXT * pOsContext |
| 1044 |
//! [in] Pointer to OS context structure |
| 1045 |
//! \param MOS_GPU_CONTEXT GpuContext |
| 1046 |
//! [in] GPU Context |
| 1047 |
//! \return uint32_t |
| 1048 |
//! GPU tag |
| 1049 |
//! |
| 1050 |
uint32_t Linux_GetGPUTag( |
| 1051 |
PMOS_INTERFACE pOsInterface, |
| 1052 |
MOS_GPU_CONTEXT mosGpuCtx) |
| 1053 |
{ |
| 1054 |
MOS_OS_FUNCTION_ENTER; |
| 1055 |
|
| 1056 |
if (pOsInterface == nullptr) |
| 1057 |
{ |
| 1058 |
MOS_OS_ASSERTMESSAGE("invalid input parameters!"); |
| 1059 |
return 0; |
| 1060 |
} |
| 1061 |
|
| 1062 |
if (mosGpuCtx == MOS_GPU_CONTEXT_INVALID_HANDLE) |
| 1063 |
{ |
| 1064 |
MOS_OS_ASSERTMESSAGE("Invalid input parameter GpuContext."); |
| 1065 |
return 0; |
| 1066 |
} |
| 1067 |
|
| 1068 |
if (pOsInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 1069 |
{ |
| 1070 |
if (pOsInterface->osContextPtr == nullptr) |
| 1071 |
{ |
| 1072 |
MOS_OS_ASSERTMESSAGE("invalid input parameters!"); |
| 1073 |
return 0; |
| 1074 |
} |
| 1075 |
|
| 1076 |
auto osCxtSpecific = static_cast<OsContextSpecific*>(pOsInterface->osContextPtr); |
| 1077 |
|
| 1078 |
auto handle = osCxtSpecific->GetGpuContextHandle(mosGpuCtx); |
| 1079 |
|
| 1080 |
if (pOsInterface->apoMosEnabled) |
| 1081 |
{ |
| 1082 |
PMOS_RESOURCE gpuStatusResource = nullptr; |
| 1083 |
MOS_OS_CHK_STATUS_RETURN(MosInterface::GetGpuStatusBufferResource(pOsInterface->osStreamState, gpuStatusResource, handle)); |
| 1084 |
MOS_OS_CHK_NULL_RETURN(gpuStatusResource); |
| 1085 |
auto gpuStatusData = (MOS_GPU_STATUS_DATA *)gpuStatusResource->pData; |
| 1086 |
if (gpuStatusData == nullptr) |
| 1087 |
{ |
| 1088 |
MOS_OS_ASSERTMESSAGE("cannot find "); |
| 1089 |
return 0; |
| 1090 |
} |
| 1091 |
return gpuStatusData->GPUTag; |
| 1092 |
} |
| 1093 |
|
| 1094 |
auto gpuContext = Linux_GetGpuContext(pOsInterface, handle); |
| 1095 |
|
| 1096 |
if (gpuContext == nullptr) |
| 1097 |
{ |
| 1098 |
MOS_OS_ASSERTMESSAGE("cannot get corresponding gpu context!"); |
| 1099 |
return 0; |
| 1100 |
} |
| 1101 |
|
| 1102 |
auto resource = gpuContext->GetStatusBufferResource(); |
| 1103 |
|
| 1104 |
if (resource == nullptr) |
| 1105 |
{ |
| 1106 |
MOS_OS_ASSERTMESSAGE("cannot find the gpuContext corresponding to the active resource."); |
| 1107 |
return 0; |
| 1108 |
} |
| 1109 |
|
| 1110 |
MOS_RESOURCE gpuStatusResource; |
| 1111 |
MOS_OS_CHK_STATUS_RETURN(resource->ConvertToMosResource(&gpuStatusResource)); |
| 1112 |
auto gpuStatusData = (MOS_GPU_STATUS_DATA *)gpuStatusResource.pData; |
| 1113 |
if (gpuStatusData == nullptr) |
| 1114 |
{ |
| 1115 |
MOS_OS_ASSERTMESSAGE("cannot find "); |
| 1116 |
return 0; |
| 1117 |
} |
| 1118 |
return gpuStatusData->GPUTag; |
| 1119 |
} |
| 1120 |
|
| 1121 |
MOS_GPU_STATUS_DATA *pGPUStatusData = nullptr; |
| 1122 |
|
| 1123 |
if ( pOsInterface->pOsContext == nullptr || |
| 1124 |
pOsInterface->pOsContext->pGPUStatusBuffer == nullptr || |
| 1125 |
pOsInterface->pOsContext->pGPUStatusBuffer->pData == nullptr) |
| 1126 |
{ |
| 1127 |
return 0; |
| 1128 |
} |
| 1129 |
|
| 1130 |
pGPUStatusData = (MOS_GPU_STATUS_DATA *)(pOsInterface->pOsContext->pGPUStatusBuffer->pData + (sizeof(MOS_GPU_STATUS_DATA) * mosGpuCtx)); |
| 1131 |
if (pGPUStatusData == nullptr) |
| 1132 |
{ |
| 1133 |
MOS_OS_ASSERTMESSAGE("cannot find the gpuContext corresponding to the active resource"); |
| 1134 |
return 0; |
| 1135 |
} |
| 1136 |
return pGPUStatusData->GPUTag; |
| 1137 |
} |
| 1138 |
|
| 1139 |
//! |
| 1140 |
//! \brief Destroy Linux context |
| 1141 |
//! \details Destroy Linux context |
| 1142 |
//! \param PMOS_CONTEXT pOsContext |
| 1143 |
//! [in] Pointer to OS context structure |
| 1144 |
//! \return void |
| 1145 |
//! |
| 1146 |
void Linux_Destroy( |
| 1147 |
PMOS_CONTEXT pOsContext, |
| 1148 |
int32_t MODSEnabled, |
| 1149 |
int32_t modularizedGpuCtxEnabled) |
| 1150 |
{ |
| 1151 |
PCOMMAND_BUFFER pCurrCB = nullptr; |
| 1152 |
PCOMMAND_BUFFER pNextCB = nullptr; |
| 1153 |
int32_t iSize = 0; |
| 1154 |
int i = 0; |
| 1155 |
if (pOsContext == nullptr) |
| 1156 |
{ |
| 1157 |
MOS_OS_ASSERTMESSAGE("OsContext is null."); |
| 1158 |
return; |
| 1159 |
} |
| 1160 |
|
| 1161 |
#ifndef ANDROID |
| 1162 |
if (pOsContext->bKMDHasVCS2) |
| 1163 |
{ |
| 1164 |
DestroyIPC(pOsContext); |
| 1165 |
} |
| 1166 |
#endif |
| 1167 |
|
| 1168 |
if (!modularizedGpuCtxEnabled) |
| 1169 |
{ |
| 1170 |
Linux_ReleaseCmdBufferPool(pOsContext); |
| 1171 |
|
| 1172 |
for (i = 0; i < MOS_GPU_CONTEXT_MAX; i++) |
| 1173 |
{ |
| 1174 |
MOS_FreeMemAndSetNull(pOsContext->OsGpuContext[i].pCB); |
| 1175 |
|
| 1176 |
pCurrCB = pOsContext->OsGpuContext[i].pStartCB; |
| 1177 |
for (; (pCurrCB); pCurrCB = pNextCB) |
| 1178 |
{ |
| 1179 |
pNextCB = pCurrCB->pNext; |
| 1180 |
MOS_FreeMemAndSetNull(pCurrCB); |
| 1181 |
} |
| 1182 |
} |
| 1183 |
|
| 1184 |
Linux_ReleaseGPUStatus(pOsContext); |
| 1185 |
} |
| 1186 |
|
| 1187 |
if (pOsContext->contextOffsetList.size()) |
| 1188 |
{ |
| 1189 |
pOsContext->contextOffsetList.clear(); |
| 1190 |
pOsContext->contextOffsetList.shrink_to_fit(); |
| 1191 |
} |
| 1192 |
|
| 1193 |
if (!MODSEnabled && (pOsContext->intel_context)) |
| 1194 |
{ |
| 1195 |
if (pOsContext->intel_context->vm_id != INVALID_VM) |
| 1196 |
{ |
| 1197 |
mos_vm_destroy(pOsContext->intel_context->bufmgr,pOsContext->intel_context->vm_id); |
| 1198 |
pOsContext->intel_context->vm_id = INVALID_VM; |
| 1199 |
} |
| 1200 |
mos_context_destroy(pOsContext->intel_context); |
| 1201 |
} |
| 1202 |
|
| 1203 |
MOS_Delete(pOsContext); |
| 1204 |
} |
| 1205 |
|
| 1206 |
//! |
| 1207 |
//! \brief Get DMA Buffer ID |
| 1208 |
//! \details Get the DMA perf Buffer ID |
| 1209 |
//! \param PMOS_CONTEXT pOsContext |
| 1210 |
//! [in] Pointer to OS context structure |
| 1211 |
//! \return uint32_t |
| 1212 |
//! Return the buffer ID |
| 1213 |
//! |
| 1214 |
uint32_t Linux_GetDmaBufID (PMOS_CONTEXT pOsContext ) |
| 1215 |
{ |
| 1216 |
if (pOsContext == nullptr) |
| 1217 |
{ |
| 1218 |
MOS_OS_ASSERTMESSAGE("OsContext is null."); |
| 1219 |
return 0; |
| 1220 |
} |
| 1221 |
|
| 1222 |
uint32_t dmaBufID = 0; |
| 1223 |
if (pOsContext->pPerfData != nullptr) |
| 1224 |
{ |
| 1225 |
dmaBufID = pOsContext->pPerfData->dmaBufID; |
| 1226 |
} |
| 1227 |
return dmaBufID; |
| 1228 |
} |
| 1229 |
|
| 1230 |
//! |
| 1231 |
//! \brief Get Buffer Type |
| 1232 |
//! \details Returns the type of buffer, 1D, 2D or volume |
| 1233 |
//! \param PMOS_RESOURCE pOsResource |
| 1234 |
//! [in] Pointer to OS Resource |
| 1235 |
//! \return GFX resource Type |
| 1236 |
//! |
| 1237 |
MOS_GFXRES_TYPE GetResType(PMOS_RESOURCE pOsResource) |
| 1238 |
{ |
| 1239 |
GMM_RESOURCE_INFO *pGmmResourceInfo = nullptr; |
| 1240 |
MOS_GFXRES_TYPE ResType = MOS_GFXRES_INVALID; |
| 1241 |
GMM_RESOURCE_TYPE GMMResType = RESOURCE_INVALID; |
| 1242 |
|
| 1243 |
if (pOsResource == nullptr) |
| 1244 |
{ |
| 1245 |
MOS_OS_ASSERTMESSAGE("OsContext is null."); |
| 1246 |
return MOS_GFXRES_INVALID; |
| 1247 |
} |
| 1248 |
|
| 1249 |
pGmmResourceInfo = (GMM_RESOURCE_INFO *)pOsResource->pGmmResInfo; |
| 1250 |
GMMResType = pGmmResourceInfo->GetResourceType(); |
| 1251 |
|
| 1252 |
switch (GMMResType) |
| 1253 |
{ |
| 1254 |
case RESOURCE_BUFFER: |
| 1255 |
ResType = MOS_GFXRES_BUFFER; |
| 1256 |
break; |
| 1257 |
case RESOURCE_3D: |
| 1258 |
ResType = MOS_GFXRES_VOLUME; |
| 1259 |
break; |
| 1260 |
case RESOURCE_2D: |
| 1261 |
ResType = MOS_GFXRES_2D; |
| 1262 |
break; |
| 1263 |
default: |
| 1264 |
break; |
| 1265 |
} |
| 1266 |
return ResType; |
| 1267 |
} |
| 1268 |
//! |
| 1269 |
//! \brief Set the DMA Buffer ID |
| 1270 |
//! \details Sets the buffer ID in perf data |
| 1271 |
//! \param PMOS_CONTEXT pOsContext |
| 1272 |
//! [in] Pointer to OS context structure |
| 1273 |
//! \param uint32_t dwDmaBufID |
| 1274 |
//! [in] Buffer ID to be set |
| 1275 |
//! \return void |
| 1276 |
//! |
| 1277 |
void Linux_SetDmaBufID ( PMOS_CONTEXT pOsContext, uint32_t dwDmaBufID ) |
| 1278 |
{ |
| 1279 |
if (pOsContext == nullptr) |
| 1280 |
{ |
| 1281 |
MOS_OS_ASSERTMESSAGE("OsContext is null."); |
| 1282 |
return; |
| 1283 |
} |
| 1284 |
|
| 1285 |
if (pOsContext->pPerfData != nullptr) |
| 1286 |
{ |
| 1287 |
pOsContext->pPerfData->dmaBufID = dwDmaBufID; |
| 1288 |
} |
| 1289 |
} |
| 1290 |
|
| 1291 |
//! |
| 1292 |
//! \brief Set the DMA Kernel ID |
| 1293 |
//! \details Sets the Kernel ID in perf data |
| 1294 |
//! \param PMOS_CONTEXT pOsContext |
| 1295 |
//! [in] Pointer to OS context structure |
| 1296 |
//! \param uint32_t KernelID |
| 1297 |
//! [in] Buffer ID to be set |
| 1298 |
//! \return void |
| 1299 |
//! |
| 1300 |
void Linux_SetPerfHybridKernelID ( PMOS_CONTEXT pOsContext, uint32_t KernelID) |
| 1301 |
{ |
| 1302 |
if (pOsContext == nullptr) |
| 1303 |
{ |
| 1304 |
MOS_OS_ASSERTMESSAGE("OsContext is null."); |
| 1305 |
return; |
| 1306 |
} |
| 1307 |
|
| 1308 |
if (pOsContext->pPerfData != nullptr) |
| 1309 |
{ |
| 1310 |
pOsContext->pPerfData->dmaBufID = (pOsContext->pPerfData->dmaBufID & 0xF0FF) | ((KernelID <<8) & 0x0F00); |
| 1311 |
} |
| 1312 |
} |
| 1313 |
|
| 1314 |
//! |
| 1315 |
//! \brief Init Linux context |
| 1316 |
//! \details Initialize the linux context |
| 1317 |
//! \param MOS_OS_CONTEXT * pContext |
| 1318 |
//! [in] Pointer to OS context structure |
| 1319 |
//! \param PMOS_CONTEXT pOsDriverContext |
| 1320 |
//! [in] Pointer to OS Driver context |
| 1321 |
//! \return MOS_STATUS |
| 1322 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1323 |
//! |
| 1324 |
MOS_STATUS Linux_InitContext( |
| 1325 |
MOS_OS_CONTEXT *pContext, |
| 1326 |
PMOS_CONTEXT pOsDriverContext, |
| 1327 |
int32_t MODSEnabled, |
| 1328 |
int32_t modularizedGpuCtxEnabled) |
| 1329 |
{ |
| 1330 |
int32_t iDeviceId = -1; |
| 1331 |
MOS_STATUS eStatus; |
| 1332 |
int32_t i = -1; |
| 1333 |
|
| 1334 |
MOS_OS_FUNCTION_ENTER; |
| 1335 |
|
| 1336 |
eStatus = MOS_STATUS_SUCCESS; |
| 1337 |
|
| 1338 |
if (nullptr == pContext || |
| 1339 |
nullptr == pOsDriverContext || |
| 1340 |
nullptr == pOsDriverContext->bufmgr || |
| 1341 |
(nullptr == pOsDriverContext->m_gpuContextMgr && modularizedGpuCtxEnabled && !pOsDriverContext->m_apoMosEnabled) || |
| 1342 |
(nullptr == pOsDriverContext->m_cmdBufMgr && modularizedGpuCtxEnabled && !pOsDriverContext->m_apoMosEnabled) || |
| 1343 |
0 >= pOsDriverContext->fd) |
| 1344 |
{ |
| 1345 |
MOS_OS_ASSERT(false); |
| 1346 |
return MOS_STATUS_INVALID_HANDLE; |
| 1347 |
} |
| 1348 |
pContext->bufmgr = pOsDriverContext->bufmgr; |
| 1349 |
pContext->m_gpuContextMgr = pOsDriverContext->m_gpuContextMgr; |
| 1350 |
pContext->m_cmdBufMgr = pOsDriverContext->m_cmdBufMgr; |
| 1351 |
pContext->fd = pOsDriverContext->fd; |
| 1352 |
pContext->pPerfData = pOsDriverContext->pPerfData; |
| 1353 |
pContext->m_auxTableMgr = pOsDriverContext->m_auxTableMgr; |
| 1354 |
pContext->m_userSettingPtr = pOsDriverContext->m_userSettingPtr; |
| 1355 |
|
| 1356 |
mos_bufmgr_enable_reuse(pOsDriverContext->bufmgr); |
| 1357 |
|
| 1358 |
// DDI layer can pass over the DeviceID. |
| 1359 |
iDeviceId = pOsDriverContext->iDeviceId; |
| 1360 |
if (0 == iDeviceId) |
| 1361 |
{ |
| 1362 |
//Such as CP, it calls InitMosInterface() dretly without creating MediaContext. |
| 1363 |
iDeviceId = mos_bufmgr_get_devid(pOsDriverContext->bufmgr); |
| 1364 |
pOsDriverContext->iDeviceId = iDeviceId; |
| 1365 |
|
| 1366 |
MOS_OS_CHK_STATUS_MESSAGE( |
| 1367 |
HWInfo_GetGfxInfo(pOsDriverContext->fd, pOsDriverContext->bufmgr, &pContext->m_platform, &pContext->m_skuTable, &pContext->m_waTable, &pContext->m_gtSystemInfo, pOsDriverContext->m_userSettingPtr), |
| 1368 |
"Fatal error - unsuccesfull Sku/Wa/GtSystemInfo initialization"); |
| 1369 |
|
| 1370 |
pOsDriverContext->m_skuTable = pContext->m_skuTable; |
| 1371 |
pOsDriverContext->m_waTable = pContext->m_waTable; |
| 1372 |
pOsDriverContext->m_gtSystemInfo = pContext->m_gtSystemInfo; |
| 1373 |
pOsDriverContext->m_platform = pContext->m_platform; |
| 1374 |
MOS_OS_NORMALMESSAGE("DeviceID was created DeviceID = %d, platform product %d", iDeviceId, pContext->m_platform.eProductFamily); |
| 1375 |
} |
| 1376 |
else |
| 1377 |
{ |
| 1378 |
// pOsDriverContext's parameters were passed by CmCreateDevice. |
| 1379 |
// Get SkuTable/WaTable/systemInfo/platform from OSDriver directly. |
| 1380 |
pContext->m_skuTable = pOsDriverContext->m_skuTable; |
| 1381 |
pContext->m_waTable = pOsDriverContext->m_waTable; |
| 1382 |
pContext->m_gtSystemInfo = pOsDriverContext->m_gtSystemInfo; |
| 1383 |
pContext->m_platform = pOsDriverContext->m_platform; |
| 1384 |
} |
| 1385 |
|
| 1386 |
pContext->bUse64BitRelocs = true; |
| 1387 |
pContext->bUseSwSwizzling = pContext->bSimIsActive || MEDIA_IS_SKU(&pContext->m_skuTable, FtrUseSwSwizzling); |
| 1388 |
pContext->bTileYFlag = MEDIA_IS_SKU(&pContext->m_skuTable, FtrTileY); |
| 1389 |
// when MODS enabled, intel_context will be created by pOsContextSpecific, should not recreate it here, or will cause memory leak. |
| 1390 |
if (!MODSEnabled) |
| 1391 |
{ |
| 1392 |
pContext->intel_context = mos_context_create_ext(pOsDriverContext->bufmgr, 0, pOsDriverContext->m_protectedGEMContext); |
| 1393 |
if (!Mos_Solo_IsEnabled(nullptr) && pContext->intel_context) |
| 1394 |
{ |
| 1395 |
pContext->intel_context->vm_id = mos_vm_create(pOsDriverContext->bufmgr); |
| 1396 |
if (pContext->intel_context->vm_id == INVALID_VM) |
| 1397 |
{ |
| 1398 |
MOS_OS_ASSERTMESSAGE("Failed to create vm.\n"); |
| 1399 |
return MOS_STATUS_UNKNOWN; |
| 1400 |
} |
| 1401 |
} |
| 1402 |
else //try legacy context create ioctl if DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT is not supported |
| 1403 |
{ |
| 1404 |
pContext->intel_context = mos_context_create(pOsDriverContext->bufmgr); |
| 1405 |
if (pContext->intel_context) |
| 1406 |
{ |
| 1407 |
pContext->intel_context->vm_id = INVALID_VM; |
| 1408 |
} |
| 1409 |
} |
| 1410 |
|
| 1411 |
if (pContext->intel_context == nullptr) |
| 1412 |
{ |
| 1413 |
MOS_OS_ASSERTMESSAGE("Failed to create drm intel context"); |
| 1414 |
return MOS_STATUS_UNKNOWN; |
| 1415 |
} |
| 1416 |
} |
| 1417 |
|
| 1418 |
pContext->intel_context->pOsContext = pContext; |
| 1419 |
|
| 1420 |
pContext->bIsAtomSOC = IS_ATOMSOC(iDeviceId); |
| 1421 |
|
| 1422 |
if(!modularizedGpuCtxEnabled) |
| 1423 |
{ |
| 1424 |
Linux_InitCmdBufferPool(pContext); |
| 1425 |
|
| 1426 |
// Initialize GPU Status Buffer |
| 1427 |
eStatus = Linux_InitGPUStatus(pContext); |
| 1428 |
if (MOS_STATUS_SUCCESS != eStatus) |
| 1429 |
{ |
| 1430 |
goto finish; |
| 1431 |
} |
| 1432 |
|
| 1433 |
for (i = 0; i < MOS_GPU_CONTEXT_MAX; i++) |
| 1434 |
{ |
| 1435 |
pContext->OsGpuContext[i].pStartCB = nullptr; |
| 1436 |
pContext->OsGpuContext[i].pCurrentCB = nullptr; |
| 1437 |
pContext->OsGpuContext[i].bCBFlushed = true; |
| 1438 |
pContext->OsGpuContext[i].uiCommandBufferSize = COMMAND_BUFFER_SIZE; |
| 1439 |
pContext->OsGpuContext[i].pCB = |
| 1440 |
(PMOS_COMMAND_BUFFER)MOS_AllocAndZeroMemory(sizeof(MOS_COMMAND_BUFFER)); |
| 1441 |
|
| 1442 |
if (nullptr == pContext->OsGpuContext[i].pCB) |
| 1443 |
{ |
| 1444 |
MOS_OS_ASSERTMESSAGE("No More Avaliable Memory"); |
| 1445 |
eStatus = MOS_STATUS_NO_SPACE; |
| 1446 |
goto finish; |
| 1447 |
} |
| 1448 |
|
| 1449 |
// each thread has its own GPU context, so do not need any lock as guarder here |
| 1450 |
pContext->OsGpuContext[i].pAllocationList = |
| 1451 |
(ALLOCATION_LIST*)MOS_AllocAndZeroMemory(sizeof(ALLOCATION_LIST) * ALLOCATIONLIST_SIZE); |
| 1452 |
if (nullptr == pContext->OsGpuContext[i].pAllocationList) |
| 1453 |
{ |
| 1454 |
MOS_OS_ASSERTMESSAGE("pContext->OsGpuContext[%d].pAllocationList malloc failed.", i); |
| 1455 |
eStatus = MOS_STATUS_NO_SPACE; |
| 1456 |
goto finish; |
| 1457 |
} |
| 1458 |
pContext->OsGpuContext[i].uiMaxNumAllocations = ALLOCATIONLIST_SIZE; |
| 1459 |
|
| 1460 |
pContext->OsGpuContext[i].pPatchLocationList = |
| 1461 |
(PATCHLOCATIONLIST*)MOS_AllocAndZeroMemory(sizeof(PATCHLOCATIONLIST) * PATCHLOCATIONLIST_SIZE); |
| 1462 |
if (nullptr == pContext->OsGpuContext[i].pPatchLocationList) |
| 1463 |
{ |
| 1464 |
MOS_OS_ASSERTMESSAGE("pContext->OsGpuContext[%d].pPatchLocationList malloc failed.", i); |
| 1465 |
eStatus = MOS_STATUS_NO_SPACE; |
| 1466 |
goto finish; |
| 1467 |
} |
| 1468 |
pContext->OsGpuContext[i].uiMaxPatchLocationsize = PATCHLOCATIONLIST_SIZE; |
| 1469 |
|
| 1470 |
pContext->OsGpuContext[i].pResources = |
| 1471 |
(PMOS_RESOURCE)MOS_AllocAndZeroMemory(sizeof(MOS_RESOURCE) * ALLOCATIONLIST_SIZE); |
| 1472 |
if (nullptr == pContext->OsGpuContext[i].pResources) |
| 1473 |
{ |
| 1474 |
MOS_OS_ASSERTMESSAGE("pContext->OsGpuContext[%d].pResources malloc failed.", i); |
| 1475 |
eStatus = MOS_STATUS_NO_SPACE; |
| 1476 |
goto finish; |
| 1477 |
} |
| 1478 |
|
| 1479 |
pContext->OsGpuContext[i].pbWriteMode = |
| 1480 |
(int32_t*)MOS_AllocAndZeroMemory(sizeof(int32_t) * ALLOCATIONLIST_SIZE); |
| 1481 |
if (nullptr == pContext->OsGpuContext[i].pbWriteMode) |
| 1482 |
{ |
| 1483 |
MOS_OS_ASSERTMESSAGE("pContext->OsGpuContext[%d].pbWriteMode malloc failed.", i); |
| 1484 |
eStatus = MOS_STATUS_NO_SPACE; |
| 1485 |
goto finish; |
| 1486 |
} |
| 1487 |
|
| 1488 |
pContext->OsGpuContext[i].uiGPUStatusTag = 1; |
| 1489 |
} |
| 1490 |
} |
| 1491 |
|
| 1492 |
#ifndef ANDROID |
| 1493 |
{ |
| 1494 |
pContext->bKMDHasVCS2 = mos_has_bsd2(pContext->bufmgr); |
| 1495 |
} |
| 1496 |
if (pContext->bKMDHasVCS2) |
| 1497 |
{ |
| 1498 |
eStatus = CreateIPC(pContext); |
| 1499 |
MOS_CHK_STATUS_SAFE(eStatus); |
| 1500 |
} |
| 1501 |
#endif |
| 1502 |
|
| 1503 |
pContext->pTranscryptedKernels = nullptr; |
| 1504 |
pContext->uiTranscryptedKernelsSize = 0; |
| 1505 |
|
| 1506 |
// For Media Memory compression |
| 1507 |
pContext->ppMediaMemDecompState = pOsDriverContext->ppMediaMemDecompState; |
| 1508 |
pContext->pfnMemoryDecompress = pOsDriverContext->pfnMemoryDecompress; |
| 1509 |
pContext->pfnMediaMemoryCopy = pOsDriverContext->pfnMediaMemoryCopy; |
| 1510 |
pContext->pfnMediaMemoryCopy2D = pOsDriverContext->pfnMediaMemoryCopy2D; |
| 1511 |
|
| 1512 |
// Set interface functions |
| 1513 |
pContext->pfnDestroy = Linux_Destroy; |
| 1514 |
pContext->pfnGetCommandBuffer = Linux_GetCommandBuffer; |
| 1515 |
pContext->pfnReturnCommandBuffer = Linux_ReturnCommandBuffer; |
| 1516 |
pContext->pfnFlushCommandBuffer = Linux_FlushCommandBuffer; |
| 1517 |
pContext->pfnInsertCmdBufferToPool = Linux_InsertCmdBufferToPool; |
| 1518 |
pContext->pfnWaitAndReleaseCmdBuffer = Linux_WaitAndReleaseCmdBuffer; |
| 1519 |
pContext->pfnRefresh = Linux_Refresh; |
| 1520 |
pContext->GetDmaBufID = Linux_GetDmaBufID; |
| 1521 |
pContext->SetDmaBufID = Linux_SetDmaBufID; |
| 1522 |
pContext->SetPerfHybridKernelID = Linux_SetPerfHybridKernelID; |
| 1523 |
pContext->pfnGetGpuCtxBufferTag = Linux_GetGpuCtxBufferTag; |
| 1524 |
pContext->pfnIncGpuCtxBufferTag = Linux_IncGpuCtxBufferTag; |
| 1525 |
pContext->GetGPUTag = Linux_GetGPUTag; |
| 1526 |
pContext->GetGmmClientContext = Linux_GetGmmClientContext; |
| 1527 |
|
| 1528 |
finish: |
| 1529 |
if (!modularizedGpuCtxEnabled) |
| 1530 |
{ |
| 1531 |
// init context failed, roll back |
| 1532 |
if (eStatus != MOS_STATUS_SUCCESS) |
| 1533 |
Mos_Specific_ClearGpuContext(pContext); |
| 1534 |
} |
| 1535 |
|
| 1536 |
return eStatus; |
| 1537 |
} |
| 1538 |
//============= PRIVATE FUNCTIONS <END>========================================= |
| 1539 |
|
| 1540 |
//! |
| 1541 |
//! \brief Set GPU context |
| 1542 |
//! \details Set GPU context for the following rendering operations |
| 1543 |
//! \param MOS_OS_CONTEXT * pContext |
| 1544 |
//! [in] Pointer to OS context structure |
| 1545 |
//! \param MOS_GPU_CONTEXT GpuContext |
| 1546 |
//! [in] GPU Context |
| 1547 |
//! \return MOS_STATUS |
| 1548 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1549 |
//! |
| 1550 |
MOS_STATUS Mos_Specific_SetGpuContext( |
| 1551 |
PMOS_INTERFACE pOsInterface, |
| 1552 |
MOS_GPU_CONTEXT GpuContext) |
| 1553 |
{ |
| 1554 |
MOS_OS_FUNCTION_ENTER; |
| 1555 |
|
| 1556 |
MOS_OS_CHK_NULL_RETURN(pOsInterface); |
| 1557 |
|
| 1558 |
if (GpuContext == MOS_GPU_CONTEXT_INVALID_HANDLE) |
| 1559 |
{ |
| 1560 |
MOS_OS_ASSERTMESSAGE("Invalid input parameter GpuContext."); |
| 1561 |
return MOS_STATUS_INVALID_PARAMETER; |
| 1562 |
} |
| 1563 |
|
| 1564 |
// Set GPU context handle |
| 1565 |
pOsInterface->CurrentGpuContextOrdinal = GpuContext; |
| 1566 |
|
| 1567 |
if (pOsInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 1568 |
{ |
| 1569 |
MOS_OS_CHK_NULL_RETURN(pOsInterface->osContextPtr); |
| 1570 |
|
| 1571 |
auto pOsContextSpecific = static_cast<OsContextSpecific*>(pOsInterface->osContextPtr); |
| 1572 |
MOS_OS_CHK_NULL_RETURN(pOsContextSpecific); |
| 1573 |
|
| 1574 |
// Set GPU context handle |
| 1575 |
pOsInterface->CurrentGpuContextHandle = pOsContextSpecific->GetGpuContextHandle(GpuContext); |
| 1576 |
|
| 1577 |
if (pOsInterface->apoMosEnabled) |
| 1578 |
{ |
| 1579 |
if(MEDIA_IS_SKU(&pOsInterface->pOsContext->m_skuTable, FtrProtectedGEMContextPatch)) |
| 1580 |
{ |
| 1581 |
GpuContextSpecificNext* GpuCtxSpecific = MosInterface::GetGpuContext(pOsInterface->osStreamState, pOsInterface->CurrentGpuContextHandle); |
| 1582 |
MOS_OS_CHK_STATUS_RETURN(GpuCtxSpecific->PatchGPUContextProtection(pOsInterface->osStreamState)); |
| 1583 |
} |
| 1584 |
MOS_OS_CHK_STATUS_RETURN(MosInterface::SetGpuContext( |
| 1585 |
pOsInterface->osStreamState, |
| 1586 |
pOsContextSpecific->GetGpuContextHandle(GpuContext))); |
| 1587 |
} |
| 1588 |
} |
| 1589 |
|
| 1590 |
return MOS_STATUS_SUCCESS; |
| 1591 |
} |
| 1592 |
|
| 1593 |
MOS_STATUS Mos_Specific_SetGpuContextFromHandle(MOS_INTERFACE *osInterface, |
| 1594 |
MOS_GPU_CONTEXT contextName, |
| 1595 |
GPU_CONTEXT_HANDLE contextHandle) |
| 1596 |
{ |
| 1597 |
MOS_OS_FUNCTION_ENTER; |
| 1598 |
MOS_OS_CHK_NULL_RETURN(osInterface); |
| 1599 |
|
| 1600 |
if (MOS_GPU_CONTEXT_INVALID_HANDLE == contextName) |
| 1601 |
{ |
| 1602 |
MOS_OS_ASSERTMESSAGE("Invalid input parameter contextName."); |
| 1603 |
return MOS_STATUS_INVALID_PARAMETER; |
| 1604 |
} |
| 1605 |
|
| 1606 |
// Set GPU context handle |
| 1607 |
osInterface->CurrentGpuContextOrdinal = contextName; |
| 1608 |
|
| 1609 |
if (osInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 1610 |
{ |
| 1611 |
MOS_OS_CHK_NULL_RETURN(osInterface->osContextPtr); |
| 1612 |
|
| 1613 |
auto os_context_specific |
| 1614 |
= static_cast<OsContextSpecific*>(osInterface->osContextPtr); |
| 1615 |
MOS_OS_CHK_NULL_RETURN(os_context_specific); |
| 1616 |
|
| 1617 |
// Set GPU context handle |
| 1618 |
osInterface->CurrentGpuContextHandle = contextHandle; |
| 1619 |
|
| 1620 |
if (osInterface->apoMosEnabled) |
| 1621 |
{ |
| 1622 |
MOS_OS_CHK_STATUS_RETURN( |
| 1623 |
MosInterface::SetGpuContext(osInterface->osStreamState, |
| 1624 |
contextHandle)); |
| 1625 |
} |
| 1626 |
} |
| 1627 |
|
| 1628 |
return MOS_STATUS_SUCCESS; |
| 1629 |
} |
| 1630 |
|
| 1631 |
//! |
| 1632 |
//! \brief Get current GPU context |
| 1633 |
//! \details Get current GPU context for the following rendering operations |
| 1634 |
//! \param PMOS_INTERFACE pOsInterface |
| 1635 |
//! [in] Pointer to OS Interface |
| 1636 |
//! \return MOS_GPU_CONTEXT |
| 1637 |
//! Return current GPU context |
| 1638 |
//! |
| 1639 |
MOS_GPU_CONTEXT Mos_Specific_GetGpuContext( |
| 1640 |
PMOS_INTERFACE pOsInterface) |
| 1641 |
{ |
| 1642 |
if (pOsInterface == nullptr) |
| 1643 |
{ |
| 1644 |
MOS_OS_ASSERTMESSAGE("OsInterface is null."); |
| 1645 |
return MOS_GPU_CONTEXT_INVALID_HANDLE; |
| 1646 |
} |
| 1647 |
|
| 1648 |
return pOsInterface->CurrentGpuContextOrdinal; |
| 1649 |
} |
| 1650 |
|
| 1651 |
//! |
| 1652 |
//! \brief Set GPU context Handle |
| 1653 |
//! \details Set GPU context handle for the following rendering operations |
| 1654 |
//! \param PMOS_INTERFACE pOsInterface |
| 1655 |
//! [in] Pointer to OS Interface |
| 1656 |
//! \param GPU_CONTEXT_HANDLE gpuContextHandle |
| 1657 |
//! [in] GPU Context Handle |
| 1658 |
//! \param MOS_GPU_CONTEXT GpuContext |
| 1659 |
//! [in] GPU Context |
| 1660 |
//! \return MOS_STATUS |
| 1661 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1662 |
//! |
| 1663 |
MOS_STATUS Mos_Specific_SetGpuContextHandle( |
| 1664 |
PMOS_INTERFACE pOsInterface, |
| 1665 |
GPU_CONTEXT_HANDLE gpuContextHandle, |
| 1666 |
MOS_GPU_CONTEXT GpuContext) |
| 1667 |
{ |
| 1668 |
MOS_OS_FUNCTION_ENTER; |
| 1669 |
|
| 1670 |
if (Mos_Solo_IsEnabled(nullptr)) return MOS_STATUS_SUCCESS; |
| 1671 |
|
| 1672 |
MOS_OS_CHK_NULL_RETURN(pOsInterface); |
| 1673 |
MOS_OS_CHK_NULL_RETURN(pOsInterface->osContextPtr); |
| 1674 |
|
| 1675 |
auto pOsContextSpecific = static_cast<OsContextSpecific*>(pOsInterface->osContextPtr); |
| 1676 |
MOS_OS_CHK_NULL_RETURN(pOsContextSpecific); |
| 1677 |
|
| 1678 |
pOsContextSpecific->SetGpuContextHandle(GpuContext, gpuContextHandle); |
| 1679 |
|
| 1680 |
return MOS_STATUS_SUCCESS; |
| 1681 |
} |
| 1682 |
|
| 1683 |
//! |
| 1684 |
//! \brief Get GPU context pointer |
| 1685 |
//! \details Get GPU context pointer |
| 1686 |
//! \param PMOS_INTERFACE pOsInterface |
| 1687 |
//! [in] Pointer to OS Interface |
| 1688 |
//! \param GPU_CONTEXT_HANDLE gpuContextHandle |
| 1689 |
//! [in] GPU Context Handle |
| 1690 |
//! \return void * |
| 1691 |
//! a pointer to a gpu context |
| 1692 |
//! |
| 1693 |
void *Mos_Specific_GetGpuContextbyHandle( |
| 1694 |
PMOS_INTERFACE pOsInterface, |
| 1695 |
GPU_CONTEXT_HANDLE gpuContextHandle) |
| 1696 |
{ |
| 1697 |
MOS_OS_FUNCTION_ENTER; |
| 1698 |
|
| 1699 |
if (!pOsInterface) |
| 1700 |
{ |
| 1701 |
MOS_OS_ASSERTMESSAGE("Invalid nullptr"); |
| 1702 |
return nullptr; |
| 1703 |
} |
| 1704 |
|
| 1705 |
if (pOsInterface->apoMosEnabled) |
| 1706 |
{ |
| 1707 |
return MosInterface::GetGpuContext(pOsInterface->osStreamState, gpuContextHandle); |
| 1708 |
} |
| 1709 |
|
| 1710 |
OsContextSpecific *pOsContextSpecific = static_cast<OsContextSpecific *>(pOsInterface->osContextPtr); |
| 1711 |
if(!pOsContextSpecific) |
| 1712 |
{ |
| 1713 |
MOS_OS_ASSERTMESSAGE("Invalid nullptr"); |
| 1714 |
return nullptr; |
| 1715 |
} |
| 1716 |
|
| 1717 |
GpuContextMgr *gpuContextMgr = pOsContextSpecific->GetGpuContextMgr(); |
| 1718 |
if (!gpuContextMgr) |
| 1719 |
{ |
| 1720 |
MOS_OS_ASSERTMESSAGE("Invalid nullptr"); |
| 1721 |
return nullptr; |
| 1722 |
} |
| 1723 |
|
| 1724 |
GpuContext *gpuContext = gpuContextMgr->GetGpuContext(gpuContextHandle); |
| 1725 |
if (!gpuContext) |
| 1726 |
{ |
| 1727 |
MOS_OS_ASSERTMESSAGE("Invalid nullptr"); |
| 1728 |
return nullptr; |
| 1729 |
} |
| 1730 |
|
| 1731 |
return (void *)gpuContext; |
| 1732 |
} |
| 1733 |
|
| 1734 |
//! |
| 1735 |
//! \brief Get current GMM client context |
| 1736 |
//! \details Get current GMM client context |
| 1737 |
//! \param PMOS_INTERFACE pOsInterface |
| 1738 |
//! [in] Pointer to OS Interface |
| 1739 |
//! \return GMM_CLIENT_CONTEXT |
| 1740 |
//! Return current GMM client context |
| 1741 |
//! |
| 1742 |
GMM_CLIENT_CONTEXT *Mos_Specific_GetGmmClientContext( |
| 1743 |
PMOS_INTERFACE pOsInterface) |
| 1744 |
{ |
| 1745 |
if (pOsInterface == nullptr) |
| 1746 |
{ |
| 1747 |
MOS_OS_ASSERTMESSAGE("OsInterface is null."); |
| 1748 |
return nullptr; |
| 1749 |
} |
| 1750 |
|
| 1751 |
if (pOsInterface->apoMosEnabled) |
| 1752 |
{ |
| 1753 |
return MosInterface::GetGmmClientContext(pOsInterface->osStreamState); |
| 1754 |
} |
| 1755 |
|
| 1756 |
if (pOsInterface->modulizedMosEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 1757 |
{ |
| 1758 |
OsContextSpecific *pOsContextSpecific = static_cast<OsContextSpecific *>(pOsInterface->osContextPtr); |
| 1759 |
if (pOsContextSpecific) |
| 1760 |
{ |
| 1761 |
return pOsContextSpecific->GetGmmClientContext(); |
| 1762 |
} |
| 1763 |
} |
| 1764 |
else |
| 1765 |
{ |
| 1766 |
if (pOsInterface->pOsContext) |
| 1767 |
{ |
| 1768 |
return pOsInterface->pOsContext->GetGmmClientContext(pOsInterface->pOsContext); |
| 1769 |
} |
| 1770 |
} |
| 1771 |
return nullptr; |
| 1772 |
} |
| 1773 |
|
| 1774 |
//! |
| 1775 |
//! \brief Get Platform |
| 1776 |
//! \details Get platform info |
| 1777 |
//! \param PMOS_INTERFACE pOsInterface |
| 1778 |
//! [in] Pointer to OS Interface |
| 1779 |
//! \param PLATFORM pPlatform |
| 1780 |
//! [out] Pointer to platform |
| 1781 |
//! \return MOS_STATUS |
| 1782 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1783 |
//! |
| 1784 |
void Mos_Specific_GetPlatform( |
| 1785 |
PMOS_INTERFACE pOsInterface, |
| 1786 |
PLATFORM *pPlatform) |
| 1787 |
{ |
| 1788 |
MOS_STATUS eStatus; |
| 1789 |
|
| 1790 |
eStatus = MOS_STATUS_SUCCESS; |
| 1791 |
|
| 1792 |
MOS_OS_CHK_NULL(pOsInterface); |
| 1793 |
MOS_OS_CHK_NULL(pOsInterface->pOsContext); |
| 1794 |
MOS_OS_CHK_NULL(pPlatform); |
| 1795 |
|
| 1796 |
if (pOsInterface->apoMosEnabled) |
| 1797 |
{ |
| 1798 |
// apo wrapper |
| 1799 |
auto platform = MosInterface::GetPlatform(pOsInterface->osStreamState); |
| 1800 |
if (platform) |
| 1801 |
{ |
| 1802 |
*pPlatform = *platform; |
| 1803 |
} |
| 1804 |
return; |
| 1805 |
} |
| 1806 |
|
| 1807 |
*pPlatform = pOsInterface->pOsContext->m_platform; |
| 1808 |
|
| 1809 |
finish: |
| 1810 |
return; |
| 1811 |
} |
| 1812 |
|
| 1813 |
MOS_STATUS Mos_DestroyInterface(PMOS_INTERFACE pOsInterface) |
| 1814 |
{ |
| 1815 |
MOS_OS_CHK_NULL_RETURN(pOsInterface); |
| 1816 |
|
| 1817 |
MOS_STREAM_HANDLE streamState = pOsInterface->osStreamState; |
| 1818 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 1819 |
|
| 1820 |
auto deviceContext = streamState->osDeviceContext; |
| 1821 |
MOS_OS_CHK_NULL_RETURN(deviceContext); |
| 1822 |
|
| 1823 |
if (!Mos_Solo_IsEnabled((PMOS_CONTEXT)streamState->perStreamParameters)) |
| 1824 |
{ |
| 1825 |
OsContext *pOsContext = pOsInterface->osContextPtr; |
| 1826 |
MOS_OS_CHK_NULL_RETURN(pOsContext); |
| 1827 |
// APO MOS destory GPU contexts here instead of inside osContextPtr |
| 1828 |
OsContextSpecific *pOsContextSpecific = static_cast<OsContextSpecific *>(pOsContext); |
| 1829 |
|
| 1830 |
auto gpuContextMgr = deviceContext->GetGpuContextMgr(); |
| 1831 |
for (uint32_t i = 0; i < MOS_GPU_CONTEXT_MAX; i++) |
| 1832 |
{ |
| 1833 |
if (pOsContextSpecific->GetGpuContextHandleByIndex(i) != MOS_GPU_CONTEXT_INVALID_HANDLE) |
| 1834 |
{ |
| 1835 |
if (gpuContextMgr == nullptr) |
| 1836 |
{ |
| 1837 |
MOS_OS_ASSERTMESSAGE("GpuContextMgr is null when destroy GpuContext"); |
| 1838 |
break; |
| 1839 |
} |
| 1840 |
auto gpuContext = gpuContextMgr->GetGpuContext(pOsContextSpecific->GetGpuContextHandleByIndex(i)); |
| 1841 |
if (gpuContext == nullptr) |
| 1842 |
{ |
| 1843 |
MOS_OS_ASSERTMESSAGE("cannot find the gpuContext corresponding to the active gpuContextHandle"); |
| 1844 |
continue; |
| 1845 |
} |
| 1846 |
gpuContextMgr->DestroyGpuContext(gpuContext); |
| 1847 |
pOsContextSpecific->SetGpuContextHandleByIndex(i, MOS_GPU_CONTEXT_INVALID_HANDLE); |
| 1848 |
} |
| 1849 |
} |
| 1850 |
|
| 1851 |
pOsContext->CleanUp(); |
| 1852 |
|
| 1853 |
MOS_Delete(pOsContext); |
| 1854 |
pOsInterface->osContextPtr = nullptr; |
| 1855 |
} |
| 1856 |
|
| 1857 |
if (pOsInterface->npuInterface) |
| 1858 |
{ |
| 1859 |
MOS_Delete(pOsInterface->npuInterface); |
| 1860 |
} |
| 1861 |
|
| 1862 |
if (pOsInterface->hybridCmdMgr) |
| 1863 |
{ |
| 1864 |
MOS_Delete(pOsInterface->hybridCmdMgr); |
| 1865 |
} |
| 1866 |
|
| 1867 |
if (pOsInterface->osCpInterface) |
| 1868 |
{ |
| 1869 |
Delete_MosCpInterface(pOsInterface->osCpInterface); |
| 1870 |
pOsInterface->osCpInterface = NULL; |
| 1871 |
} |
| 1872 |
|
| 1873 |
PMOS_CONTEXT perStreamParameters = (PMOS_CONTEXT)streamState->perStreamParameters; |
| 1874 |
|
| 1875 |
if (perStreamParameters && perStreamParameters->bFreeContext) |
| 1876 |
{ |
| 1877 |
perStreamParameters->m_skuTable.reset(); |
| 1878 |
perStreamParameters->m_waTable.reset(); |
| 1879 |
Mos_Specific_ClearGpuContext(perStreamParameters); |
| 1880 |
|
| 1881 |
if (perStreamParameters->contextOffsetList.size()) |
| 1882 |
{ |
| 1883 |
perStreamParameters->contextOffsetList.clear(); |
| 1884 |
perStreamParameters->contextOffsetList.shrink_to_fit(); |
| 1885 |
} |
| 1886 |
|
| 1887 |
if(Mos_Solo_IsEnabled(perStreamParameters)) |
| 1888 |
{ |
| 1889 |
Linux_ReleaseCmdBufferPool(perStreamParameters); |
| 1890 |
PCOMMAND_BUFFER pCurrCB = nullptr; |
| 1891 |
PCOMMAND_BUFFER pNextCB = nullptr; |
| 1892 |
for (uint32_t i = 0; i < MOS_GPU_CONTEXT_MAX; i++) |
| 1893 |
{ |
| 1894 |
MOS_FreeMemAndSetNull(perStreamParameters->OsGpuContext[i].pCB); |
| 1895 |
|
| 1896 |
pCurrCB = perStreamParameters->OsGpuContext[i].pStartCB; |
| 1897 |
for (; (pCurrCB); pCurrCB = pNextCB) |
| 1898 |
{ |
| 1899 |
pNextCB = pCurrCB->pNext; |
| 1900 |
MOS_FreeMemAndSetNull(pCurrCB); |
| 1901 |
} |
| 1902 |
} |
| 1903 |
Linux_ReleaseGPUStatus(perStreamParameters); |
| 1904 |
} |
| 1905 |
if (perStreamParameters->intel_context) |
| 1906 |
{ |
| 1907 |
if (perStreamParameters->intel_context->vm_id != INVALID_VM) |
| 1908 |
{ |
| 1909 |
mos_vm_destroy(perStreamParameters->intel_context->bufmgr, perStreamParameters->intel_context->vm_id); |
| 1910 |
perStreamParameters->intel_context->vm_id = INVALID_VM; |
| 1911 |
} |
| 1912 |
mos_context_destroy(perStreamParameters->intel_context); |
| 1913 |
perStreamParameters->intel_context = nullptr; |
| 1914 |
} |
| 1915 |
MOS_Delete(perStreamParameters); |
| 1916 |
streamState->perStreamParameters = nullptr; |
| 1917 |
} |
| 1918 |
|
| 1919 |
MosInterface::DestroyVirtualEngineState(streamState); |
| 1920 |
MOS_FreeMemAndSetNull(pOsInterface->pVEInterf); |
| 1921 |
|
| 1922 |
MOS_OS_CHK_STATUS_RETURN(MosInterface::DestroyOsStreamState(streamState)); |
| 1923 |
pOsInterface->osStreamState = nullptr; |
| 1924 |
return MOS_STATUS_SUCCESS; |
| 1925 |
} |
| 1926 |
//! |
| 1927 |
//! \brief Destroys OS specific allocations |
| 1928 |
//! \details Destroys OS specific allocations including destroying OS context |
| 1929 |
//! \param PMOS_INTERFACE pOsInterface |
| 1930 |
//! [in] Pointer to OS Interface |
| 1931 |
//! \param int32_t bDestroyVscVppDeviceTag |
| 1932 |
//! [in] Destroy VscVppDeviceTagId Flag, no use in Linux |
| 1933 |
//! \return void |
| 1934 |
//! |
| 1935 |
void Mos_Specific_Destroy( |
| 1936 |
PMOS_INTERFACE pOsInterface, |
| 1937 |
int32_t bDestroyVscVppDeviceTag) |
| 1938 |
{ |
| 1939 |
MOS_UNUSED(bDestroyVscVppDeviceTag); |
| 1940 |
|
| 1941 |
if (nullptr == pOsInterface) |
| 1942 |
{ |
| 1943 |
MOS_OS_ASSERTMESSAGE("input parameter, pOsInterface is NULL."); |
| 1944 |
return; |
| 1945 |
} |
| 1946 |
|
| 1947 |
if (pOsInterface->apoMosEnabled) |
| 1948 |
{ |
| 1949 |
MOS_STATUS status = Mos_DestroyInterface(pOsInterface); |
| 1950 |
if (status != MOS_STATUS_SUCCESS) |
| 1951 |
{ |
| 1952 |
MOS_OS_ASSERTMESSAGE("Mos Destroy Interface failed."); |
| 1953 |
} |
| 1954 |
return; |
| 1955 |
} |
| 1956 |
|
| 1957 |
if (pOsInterface->modulizedMosEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 1958 |
{ |
| 1959 |
OsContext* pOsContext = pOsInterface->osContextPtr; |
| 1960 |
if (pOsContext == nullptr) |
| 1961 |
{ |
| 1962 |
MOS_OS_ASSERTMESSAGE("Unable to get the active OS context."); |
| 1963 |
return; |
| 1964 |
} |
| 1965 |
|
| 1966 |
// APO MOS destory GPU contexts here instead of inside osContextPtr |
| 1967 |
if (pOsInterface->apoMosEnabled) |
| 1968 |
{ |
| 1969 |
OsContextSpecific* pOsContextSpecific = static_cast<OsContextSpecific*>(pOsContext); |
| 1970 |
if (pOsInterface->osStreamState == nullptr) |
| 1971 |
{ |
| 1972 |
MOS_OS_ASSERTMESSAGE("osStreamState is null when destroy GpuContext"); |
| 1973 |
return; |
| 1974 |
} |
| 1975 |
if (pOsInterface->osStreamState->osDeviceContext == nullptr) |
| 1976 |
{ |
| 1977 |
MOS_OS_ASSERTMESSAGE("osDeviceContext is null when destroy GpuContext"); |
| 1978 |
return; |
| 1979 |
} |
| 1980 |
auto gpuContextMgr = pOsInterface->osStreamState->osDeviceContext->GetGpuContextMgr(); |
| 1981 |
for (uint32_t i = 0; i < MOS_GPU_CONTEXT_MAX; i++) |
| 1982 |
{ |
| 1983 |
if (pOsContextSpecific->GetGpuContextHandleByIndex(i) != MOS_GPU_CONTEXT_INVALID_HANDLE) |
| 1984 |
{ |
| 1985 |
if (gpuContextMgr == nullptr) |
| 1986 |
{ |
| 1987 |
MOS_OS_ASSERTMESSAGE("GpuContextMgr is null when destroy GpuContext"); |
| 1988 |
break; |
| 1989 |
} |
| 1990 |
auto gpuContext = gpuContextMgr->GetGpuContext(pOsContextSpecific->GetGpuContextHandleByIndex(i)); |
| 1991 |
if (gpuContext == nullptr) |
| 1992 |
{ |
| 1993 |
MOS_OS_ASSERTMESSAGE("cannot find the gpuContext corresponding to the active gpuContextHandle"); |
| 1994 |
continue; |
| 1995 |
} |
| 1996 |
gpuContextMgr->DestroyGpuContext(gpuContext); |
| 1997 |
pOsContextSpecific->SetGpuContextHandleByIndex(i, MOS_GPU_CONTEXT_INVALID_HANDLE); |
| 1998 |
} |
| 1999 |
} |
| 2000 |
} |
| 2001 |
pOsContext->CleanUp(); |
| 2002 |
|
| 2003 |
MOS_Delete(pOsContext); |
| 2004 |
pOsInterface->osContextPtr = nullptr; |
| 2005 |
} |
| 2006 |
|
| 2007 |
if (pOsInterface->npuInterface) |
| 2008 |
{ |
| 2009 |
MOS_Delete(pOsInterface->npuInterface); |
| 2010 |
} |
| 2011 |
|
| 2012 |
if (pOsInterface->hybridCmdMgr) |
| 2013 |
{ |
| 2014 |
MOS_Delete(pOsInterface->hybridCmdMgr); |
| 2015 |
} |
| 2016 |
|
| 2017 |
if (pOsInterface->osCpInterface) |
| 2018 |
{ |
| 2019 |
Delete_MosCpInterface(pOsInterface->osCpInterface); |
| 2020 |
pOsInterface->osCpInterface = NULL; |
| 2021 |
} |
| 2022 |
|
| 2023 |
if (pOsInterface && |
| 2024 |
pOsInterface->pOsContext && |
| 2025 |
pOsInterface->pOsContext->bFreeContext) |
| 2026 |
{ |
| 2027 |
pOsInterface->pOsContext->m_skuTable.reset(); |
| 2028 |
pOsInterface->pOsContext->m_waTable.reset(); |
| 2029 |
Mos_Specific_ClearGpuContext(pOsInterface->pOsContext); |
| 2030 |
bool modularizedGpuCtxEnabled = pOsInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr); |
| 2031 |
pOsInterface->pOsContext->pfnDestroy(pOsInterface->pOsContext, pOsInterface->modulizedMosEnabled, modularizedGpuCtxEnabled); |
| 2032 |
pOsInterface->pOsContext = nullptr; |
| 2033 |
} |
| 2034 |
if (pOsInterface->pVEInterf) |
| 2035 |
{ |
| 2036 |
if (pOsInterface->apoMosEnabled && pOsInterface->pVEInterf->veInterface) |
| 2037 |
{ |
| 2038 |
pOsInterface->pVEInterf->veInterface->Destroy(); |
| 2039 |
MOS_Delete(pOsInterface->pVEInterf->veInterface); |
| 2040 |
} |
| 2041 |
MOS_FreeMemAndSetNull(pOsInterface->pVEInterf); |
| 2042 |
} |
| 2043 |
|
| 2044 |
if (pOsInterface->apoMosEnabled) |
| 2045 |
{ |
| 2046 |
auto status = MosInterface::DestroyOsStreamState(pOsInterface->osStreamState); |
| 2047 |
if (status != MOS_STATUS_SUCCESS) |
| 2048 |
{ |
| 2049 |
MOS_OS_ASSERTMESSAGE("Failed to destroy stream state."); |
| 2050 |
return; |
| 2051 |
} |
| 2052 |
} |
| 2053 |
} |
| 2054 |
|
| 2055 |
//! |
| 2056 |
//! \brief Gets the SKU table |
| 2057 |
//! \details Gets the SKU table for the platform |
| 2058 |
//! \param PMOS_INTERFACE pOsInterface |
| 2059 |
//! [in] Pointer to OS Interface |
| 2060 |
//! \return MEDIA_FEATURE_TABLE * |
| 2061 |
//! Returns the pointer to sku table |
| 2062 |
//! |
| 2063 |
MEDIA_FEATURE_TABLE *Mos_Specific_GetSkuTable( |
| 2064 |
PMOS_INTERFACE pOsInterface) |
| 2065 |
{ |
| 2066 |
if (pOsInterface && pOsInterface->apoMosEnabled) |
| 2067 |
{ |
| 2068 |
// apo wrapper |
| 2069 |
return MosInterface::GetSkuTable(pOsInterface->osStreamState); |
| 2070 |
} |
| 2071 |
|
| 2072 |
if (pOsInterface && pOsInterface->pOsContext) |
| 2073 |
{ |
| 2074 |
return &pOsInterface->pOsContext->m_skuTable; |
| 2075 |
} |
| 2076 |
return nullptr; |
| 2077 |
} |
| 2078 |
|
| 2079 |
//! |
| 2080 |
//! \brief Gets the WA table |
| 2081 |
//! \details Gets the WA table for the platform |
| 2082 |
//! \param PMOS_INTERFACE pOsInterface |
| 2083 |
//! [in] Pointer to OS Interface |
| 2084 |
//! \return MEDIA_WA_TABLE * |
| 2085 |
//! Returns the pointer to WA table |
| 2086 |
//! |
| 2087 |
MEDIA_WA_TABLE *Mos_Specific_GetWaTable( |
| 2088 |
PMOS_INTERFACE pOsInterface) |
| 2089 |
{ |
| 2090 |
if (pOsInterface && pOsInterface->apoMosEnabled) |
| 2091 |
{ |
| 2092 |
// apo wrapper |
| 2093 |
return MosInterface::GetWaTable(pOsInterface->osStreamState); |
| 2094 |
} |
| 2095 |
|
| 2096 |
if (pOsInterface && pOsInterface->pOsContext) |
| 2097 |
{ |
| 2098 |
return &pOsInterface->pOsContext->m_waTable; |
| 2099 |
} |
| 2100 |
return nullptr; |
| 2101 |
} |
| 2102 |
|
| 2103 |
//! |
| 2104 |
//! \brief Gets the GT System Info |
| 2105 |
//! \details Gets the GT System Info |
| 2106 |
//! \param PMOS_INTERFACE pOsInterface |
| 2107 |
//! [in] OS Interface |
| 2108 |
//! \return MEDIA_SYSTEM_INFO * |
| 2109 |
//! pointer to the GT System Info |
| 2110 |
//! |
| 2111 |
MEDIA_SYSTEM_INFO *Mos_Specific_GetGtSystemInfo( |
| 2112 |
PMOS_INTERFACE pOsInterface) |
| 2113 |
{ |
| 2114 |
if( nullptr == pOsInterface) |
| 2115 |
{ |
| 2116 |
MOS_OS_ASSERTMESSAGE("input parameter pOsInterface is NULL."); |
| 2117 |
return nullptr; |
| 2118 |
} |
| 2119 |
|
| 2120 |
if (pOsInterface->apoMosEnabled) |
| 2121 |
{ |
| 2122 |
// apo wrapper |
| 2123 |
return MosInterface::GetGtSystemInfo(pOsInterface->osStreamState); |
| 2124 |
} |
| 2125 |
|
| 2126 |
if( nullptr == pOsInterface->pOsContext) |
| 2127 |
{ |
| 2128 |
MOS_OS_ASSERTMESSAGE("pOsContext is NULL."); |
| 2129 |
return nullptr; |
| 2130 |
} |
| 2131 |
|
| 2132 |
return &pOsInterface->pOsContext->m_gtSystemInfo; |
| 2133 |
} |
| 2134 |
|
| 2135 |
MOS_STATUS Mos_Specific_GetMediaEngineInfo( |
| 2136 |
PMOS_INTERFACE pOsInterface, MEDIA_ENGINE_INFO &info) |
| 2137 |
{ |
| 2138 |
if (pOsInterface == nullptr) |
| 2139 |
{ |
| 2140 |
MOS_OS_ASSERTMESSAGE("Invalid pointer!"); |
| 2141 |
return MOS_STATUS_INVALID_PARAMETER; |
| 2142 |
} |
| 2143 |
|
| 2144 |
if (pOsInterface->apoMosEnabled) |
| 2145 |
{ |
| 2146 |
// apo wrapper |
| 2147 |
MOS_OS_CHK_STATUS_RETURN(MosInterface::GetMediaEngineInfo(pOsInterface->osStreamState, info)); |
| 2148 |
return MOS_STATUS_SUCCESS; |
| 2149 |
} |
| 2150 |
|
| 2151 |
auto systemInfo = pOsInterface->pfnGetGtSystemInfo(pOsInterface); |
| 2152 |
MOS_OS_CHK_NULL_RETURN(systemInfo); |
| 2153 |
MosUtilities::MosZeroMemory(&info, sizeof(info)); |
| 2154 |
info.VDBoxInfo = systemInfo->VDBoxInfo; |
| 2155 |
info.VEBoxInfo = systemInfo->VEBoxInfo; |
| 2156 |
|
| 2157 |
return MOS_STATUS_SUCCESS; |
| 2158 |
} |
| 2159 |
|
| 2160 |
//! |
| 2161 |
//! \brief Resets OS States |
| 2162 |
//! \details Resets OS States for linux |
| 2163 |
//! \param PMOS_INTERFACE pOsInterface |
| 2164 |
//! [in] Pointer to OS Interface |
| 2165 |
//! \return void |
| 2166 |
//! |
| 2167 |
void Mos_Specific_ResetOsStates( |
| 2168 |
PMOS_INTERFACE pOsInterface) // [in] OS Interface |
| 2169 |
{ |
| 2170 |
MOS_OS_FUNCTION_ENTER; |
| 2171 |
|
| 2172 |
PMOS_OS_CONTEXT pOsContext; |
| 2173 |
PMOS_OS_GPU_CONTEXT pOsGpuContext; |
| 2174 |
|
| 2175 |
if (pOsInterface == nullptr || |
| 2176 |
pOsInterface->pOsContext == nullptr) |
| 2177 |
{ |
| 2178 |
return; |
| 2179 |
} |
| 2180 |
|
| 2181 |
if (pOsInterface->apoMosEnabled) |
| 2182 |
{ |
| 2183 |
auto status = MosInterface::ResetCommandBuffer(pOsInterface->osStreamState, 0); |
| 2184 |
if (MOS_FAILED(status)) |
| 2185 |
{ |
| 2186 |
MOS_OS_ASSERTMESSAGE("ResetCommandBuffer failed."); |
| 2187 |
} |
| 2188 |
return; |
| 2189 |
} |
| 2190 |
|
| 2191 |
if (pOsInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 2192 |
{ |
| 2193 |
auto gpuContext = Linux_GetGpuContext(pOsInterface, pOsInterface->CurrentGpuContextHandle); |
| 2194 |
if (gpuContext == nullptr) |
| 2195 |
{ |
| 2196 |
MOS_OS_ASSERTMESSAGE("GPU Context pointer is nullptr!"); |
| 2197 |
return; |
| 2198 |
} |
| 2199 |
|
| 2200 |
gpuContext->ResetGpuContextStatus(); |
| 2201 |
return; |
| 2202 |
} |
| 2203 |
|
| 2204 |
pOsContext = pOsInterface->pOsContext; |
| 2205 |
pOsGpuContext = &pOsContext->OsGpuContext[pOsInterface->CurrentGpuContextOrdinal]; |
| 2206 |
// Reset resource allocation |
| 2207 |
pOsGpuContext->uiNumAllocations = 0; |
| 2208 |
MOS_ZeroMemory(pOsGpuContext->pAllocationList, sizeof(ALLOCATION_LIST) * pOsGpuContext->uiMaxNumAllocations); |
| 2209 |
pOsGpuContext->uiCurrentNumPatchLocations = 0; |
| 2210 |
MOS_ZeroMemory(pOsGpuContext->pPatchLocationList, sizeof(PATCHLOCATIONLIST) * pOsGpuContext->uiMaxPatchLocationsize); |
| 2211 |
pOsGpuContext->uiResCount = 0; |
| 2212 |
|
| 2213 |
MOS_ZeroMemory(pOsGpuContext->pResources, sizeof(MOS_RESOURCE) * pOsGpuContext->uiMaxNumAllocations); |
| 2214 |
MOS_ZeroMemory(pOsGpuContext->pbWriteMode, sizeof(int32_t) * pOsGpuContext->uiMaxNumAllocations); |
| 2215 |
|
| 2216 |
if((pOsGpuContext->bCBFlushed == true) && pOsGpuContext->pCB->OsResource.bo) |
| 2217 |
{ |
| 2218 |
pOsGpuContext->pCB->OsResource.bo = nullptr; |
| 2219 |
} |
| 2220 |
|
| 2221 |
} |
| 2222 |
|
| 2223 |
//! |
| 2224 |
//! \brief Allocate resource |
| 2225 |
//! \details To Allocate Buffer, pass Format as Format_Buffer and set the iWidth as size of the buffer. |
| 2226 |
//! \param PMOS_INTERFACE pOsInterface |
| 2227 |
//! [in] Pointer to OS Interface |
| 2228 |
//! \param PMOS_ALLOC_GFXRES_PARAMS pParams |
| 2229 |
//! [in] Pointer to resource params |
| 2230 |
//! \param PMOS_RESOURCE pOsResource |
| 2231 |
//! [in/out] Pointer to OS resource |
| 2232 |
//! \return MOS_STATUS |
| 2233 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 2234 |
//! |
| 2235 |
MOS_STATUS Mos_Specific_AllocateResource( |
| 2236 |
PMOS_INTERFACE pOsInterface, |
| 2237 |
PMOS_ALLOC_GFXRES_PARAMS pParams, |
| 2238 |
#if MOS_MESSAGES_ENABLED |
| 2239 |
PCCHAR functionName, |
| 2240 |
PCCHAR filename, |
| 2241 |
int32_t line, |
| 2242 |
#endif // MOS_MESSAGES_ENABLED |
| 2243 |
PMOS_RESOURCE pOsResource) |
| 2244 |
{ |
| 2245 |
void * caller = nullptr; |
| 2246 |
const char * bufname; |
| 2247 |
void * ptr; |
| 2248 |
int32_t iSize = 0; |
| 2249 |
int32_t iPitch = 0; |
| 2250 |
MOS_STATUS eStatus; |
| 2251 |
MOS_LINUX_BO * bo = nullptr; |
| 2252 |
MOS_TILE_TYPE tileformat; |
| 2253 |
uint32_t tileformat_linux = 0; |
| 2254 |
int32_t iHeight = 0; |
| 2255 |
int32_t iAlignedHeight = 0; |
| 2256 |
GMM_RESCREATE_PARAMS GmmParams; |
| 2257 |
GMM_RESOURCE_INFO * pGmmResourceInfo = nullptr; |
| 2258 |
GMM_RESOURCE_TYPE resourceType = RESOURCE_INVALID; |
| 2259 |
int mem_type = MOS_MEMPOOL_VIDEOMEMORY; |
| 2260 |
|
| 2261 |
MOS_OS_FUNCTION_ENTER; |
| 2262 |
|
| 2263 |
MOS_ZeroMemory(&GmmParams, sizeof(GmmParams)); |
| 2264 |
|
| 2265 |
if( nullptr == pOsResource) |
| 2266 |
{ |
| 2267 |
MOS_OS_ASSERTMESSAGE("input parameter pOSResource is NULL."); |
| 2268 |
return MOS_STATUS_INVALID_PARAMETER; |
| 2269 |
} |
| 2270 |
|
| 2271 |
if( nullptr == pOsInterface) |
| 2272 |
{ |
| 2273 |
MOS_OS_ASSERTMESSAGE("input parameter pOsInterface is NULL."); |
| 2274 |
return MOS_STATUS_INVALID_PARAMETER; |
| 2275 |
} |
| 2276 |
|
| 2277 |
bufname = pParams->pBufName; |
| 2278 |
pOsResource->bConvertedFromDDIResource = false; |
| 2279 |
|
| 2280 |
bool osContextValid = false; |
| 2281 |
if (pOsInterface->osContextPtr != nullptr) |
| 2282 |
{ |
| 2283 |
if (pOsInterface->osContextPtr->GetOsContextValid() == true) |
| 2284 |
{ |
| 2285 |
osContextValid = true; |
| 2286 |
} |
| 2287 |
} |
| 2288 |
|
| 2289 |
if (pOsInterface->apoMosEnabled) |
| 2290 |
{ |
| 2291 |
pParams->bBypassMODImpl = !((pOsInterface->modulizedMosEnabled) && (!Mos_Solo_IsEnabled(nullptr)) && (osContextValid == true)); |
| 2292 |
|
| 2293 |
MOS_OS_CHK_NULL_RETURN(pOsInterface->osStreamState); |
| 2294 |
|
| 2295 |
pOsInterface->osStreamState->component = pOsInterface->Component; |
| 2296 |
|
| 2297 |
eStatus = MosInterface::AllocateResource( |
| 2298 |
pOsInterface->osStreamState, |
| 2299 |
pParams, |
| 2300 |
pOsResource |
| 2301 |
#if MOS_MESSAGES_ENABLED |
| 2302 |
, |
| 2303 |
functionName, |
| 2304 |
filename, |
| 2305 |
line |
| 2306 |
#endif // MOS_MESSAGES_ENABLED |
| 2307 |
); |
| 2308 |
|
| 2309 |
return eStatus; |
| 2310 |
} |
| 2311 |
|
| 2312 |
if ((pOsInterface->modulizedMosEnabled) && (!Mos_Solo_IsEnabled(nullptr)) && (osContextValid == true)) |
| 2313 |
{ |
| 2314 |
pOsResource->pGfxResource = GraphicsResource::CreateGraphicResource(GraphicsResource::osSpecificResource); |
| 2315 |
if (pOsResource->pGfxResource == nullptr) |
| 2316 |
{ |
| 2317 |
MOS_OS_ASSERTMESSAGE("input nullptr returned by GraphicsResource::CreateGraphicResource."); |
| 2318 |
return MOS_STATUS_INVALID_HANDLE; |
| 2319 |
} |
| 2320 |
|
| 2321 |
if (pOsInterface->osContextPtr == nullptr) |
| 2322 |
{ |
| 2323 |
MOS_OS_ASSERTMESSAGE("invalid osContextPtr."); |
| 2324 |
return MOS_STATUS_INVALID_HANDLE; |
| 2325 |
} |
| 2326 |
if (MosUtilities::m_mosMemAllocCounterGfx != nullptr) |
| 2327 |
{ |
| 2328 |
GraphicsResource::SetMemAllocCounterGfx(*MosUtilities::m_mosMemAllocCounterGfx); |
| 2329 |
} |
| 2330 |
GraphicsResource::CreateParams params(pParams); |
| 2331 |
eStatus = pOsResource->pGfxResource->Allocate(pOsInterface->osContextPtr, params); |
| 2332 |
if (eStatus != MOS_STATUS_SUCCESS) |
| 2333 |
{ |
| 2334 |
MOS_OS_ASSERTMESSAGE("Allocate graphic resource failed"); |
| 2335 |
return MOS_STATUS_INVALID_HANDLE; |
| 2336 |
} |
| 2337 |
|
| 2338 |
eStatus = pOsResource->pGfxResource->ConvertToMosResource(pOsResource); |
| 2339 |
if (eStatus != MOS_STATUS_SUCCESS) |
| 2340 |
{ |
| 2341 |
MOS_OS_ASSERTMESSAGE("Convert graphic resource failed"); |
| 2342 |
return MOS_STATUS_INVALID_HANDLE; |
| 2343 |
} |
| 2344 |
if (MosUtilities::m_mosMemAllocCounterGfx != nullptr) |
| 2345 |
{ |
| 2346 |
*MosUtilities::m_mosMemAllocCounterGfx = GraphicsResource::GetMemAllocCounterGfx(); |
| 2347 |
} |
| 2348 |
MOS_OS_CHK_NULL(pOsResource->pGmmResInfo); |
| 2349 |
MOS_MEMNINJA_GFX_ALLOC_MESSAGE(pOsResource->pGmmResInfo, bufname, pOsInterface->Component, |
| 2350 |
(uint32_t)pOsResource->pGmmResInfo->GetSizeSurface(), pParams->dwArraySize, functionName, filename, line); |
| 2351 |
|
| 2352 |
return eStatus; |
| 2353 |
} |
| 2354 |
|
| 2355 |
caller = nullptr; |
| 2356 |
tileformat_linux = TILING_NONE; |
| 2357 |
iAlignedHeight = iHeight = pParams->dwHeight; |
| 2358 |
eStatus = MOS_STATUS_SUCCESS; |
| 2359 |
resourceType = RESOURCE_2D; |
| 2360 |
tileformat = pParams->TileType; |
| 2361 |
|
| 2362 |
MOS_ZeroMemory(&GmmParams, sizeof(GmmParams)); |
| 2363 |
|
| 2364 |
if( nullptr == pOsInterface->pOsContext ) |
| 2365 |
{ |
| 2366 |
MOS_OS_ASSERTMESSAGE("input parameter pOsInterface is NULL."); |
| 2367 |
return MOS_STATUS_INVALID_PARAMETER; |
| 2368 |
} |
| 2369 |
switch (pParams->Format) |
| 2370 |
{ |
| 2371 |
case Format_Buffer: |
| 2372 |
case Format_RAW: |
| 2373 |
resourceType = RESOURCE_BUFFER; |
| 2374 |
iAlignedHeight = 1; |
| 2375 |
//indicate buffer Restriction is Vertex. |
| 2376 |
GmmParams.Flags.Gpu.State = true; |
| 2377 |
break; |
| 2378 |
case Format_L8: |
| 2379 |
case Format_L16: |
| 2380 |
case Format_STMM: |
| 2381 |
case Format_AI44: |
| 2382 |
case Format_IA44: |
| 2383 |
case Format_R5G6B5: |
| 2384 |
case Format_R8G8B8: |
| 2385 |
case Format_X8R8G8B8: |
| 2386 |
case Format_A8R8G8B8: |
| 2387 |
case Format_X8B8G8R8: |
| 2388 |
case Format_A8B8G8R8: |
| 2389 |
case Format_R32S: |
| 2390 |
case Format_R32F: |
| 2391 |
case Format_V8U8: |
| 2392 |
case Format_YUY2: |
| 2393 |
case Format_UYVY: |
| 2394 |
case Format_P8: |
| 2395 |
case Format_A8: |
| 2396 |
case Format_AYUV: |
| 2397 |
case Format_NV12: |
| 2398 |
case Format_NV21: |
| 2399 |
case Format_YV12: |
| 2400 |
case Format_Buffer_2D: |
| 2401 |
case Format_R32U: |
| 2402 |
case Format_444P: |
| 2403 |
case Format_422H: |
| 2404 |
case Format_422V: |
| 2405 |
case Format_IMC3: |
| 2406 |
case Format_411P: |
| 2407 |
case Format_411R: |
| 2408 |
case Format_RGBP: |
| 2409 |
case Format_BGRP: |
| 2410 |
case Format_R16U: |
| 2411 |
case Format_R8U: |
| 2412 |
case Format_R8UN: |
| 2413 |
case Format_P010: |
| 2414 |
case Format_P016: |
| 2415 |
case Format_Y216: |
| 2416 |
case Format_Y416: |
| 2417 |
case Format_P208: |
| 2418 |
case Format_Y210: |
| 2419 |
case Format_Y410: |
| 2420 |
case Format_R16F: |
| 2421 |
resourceType = RESOURCE_2D; |
| 2422 |
//indicate buffer Restriction is Planar surface restrictions. |
| 2423 |
GmmParams.Flags.Gpu.Video = true; |
| 2424 |
break; |
| 2425 |
default: |
| 2426 |
MOS_OS_ASSERTMESSAGE("Unsupported format"); |
| 2427 |
eStatus = MOS_STATUS_UNIMPLEMENTED; |
| 2428 |
goto finish; |
| 2429 |
} |
| 2430 |
|
| 2431 |
// Create GmmResourceInfo |
| 2432 |
GmmParams.BaseWidth = pParams->dwWidth; |
| 2433 |
GmmParams.BaseHeight = iAlignedHeight; |
| 2434 |
GmmParams.ArraySize = 1; |
| 2435 |
GmmParams.Type = resourceType; |
| 2436 |
GmmParams.Format = MosInterface::MosFmtToGmmFmt(pParams->Format); |
| 2437 |
|
| 2438 |
MOS_OS_CHECK_CONDITION(GmmParams.Format == GMM_FORMAT_INVALID, |
| 2439 |
"Unsupported format", |
| 2440 |
MOS_STATUS_UNKNOWN); |
| 2441 |
|
| 2442 |
switch(tileformat) |
| 2443 |
{ |
| 2444 |
case MOS_TILE_Y: |
| 2445 |
tileformat_linux = TILING_Y; |
| 2446 |
if (pParams->bIsCompressible && |
| 2447 |
MEDIA_IS_SKU(&pOsInterface->pOsContext->m_skuTable, FtrE2ECompression) && |
| 2448 |
MEDIA_IS_SKU(&pOsInterface->pOsContext->m_skuTable, FtrCompressibleSurfaceDefault)) |
| 2449 |
{ |
| 2450 |
GmmParams.Flags.Gpu.MMC = true; |
| 2451 |
GmmParams.Flags.Info.MediaCompressed = 1; |
| 2452 |
GmmParams.Flags.Gpu.CCS = 1; |
| 2453 |
GmmParams.Flags.Gpu.RenderTarget = 1; |
| 2454 |
GmmParams.Flags.Gpu.UnifiedAuxSurface = 1; |
| 2455 |
|
| 2456 |
if (pParams->CompressionMode == MOS_MMC_RC) |
| 2457 |
{ |
| 2458 |
GmmParams.Flags.Info.MediaCompressed = 0; |
| 2459 |
GmmParams.Flags.Info.RenderCompressed = 1; |
| 2460 |
} |
| 2461 |
else |
| 2462 |
{ |
| 2463 |
GmmParams.Flags.Info.MediaCompressed = 1; |
| 2464 |
GmmParams.Flags.Info.RenderCompressed = 0; |
| 2465 |
} |
| 2466 |
|
| 2467 |
if(MEDIA_IS_SKU(&pOsInterface->pOsContext->m_skuTable, FtrFlatPhysCCS)) |
| 2468 |
{ |
| 2469 |
GmmParams.Flags.Gpu.UnifiedAuxSurface = 0; |
| 2470 |
} |
| 2471 |
} |
| 2472 |
break; |
| 2473 |
case MOS_TILE_X: |
| 2474 |
GmmParams.Flags.Info.TiledX = true; |
| 2475 |
tileformat_linux = TILING_X; |
| 2476 |
break; |
| 2477 |
default: |
| 2478 |
GmmParams.Flags.Info.Linear = true; |
| 2479 |
tileformat_linux = TILING_NONE; |
| 2480 |
} |
| 2481 |
GmmParams.Flags.Info.LocalOnly = MEDIA_IS_SKU(&pOsInterface->pOsContext->m_skuTable, FtrLocalMemory); |
| 2482 |
|
| 2483 |
pOsResource->pGmmResInfo = pGmmResourceInfo = pOsInterface->pOsContext->pGmmClientContext->CreateResInfoObject(&GmmParams); |
| 2484 |
|
| 2485 |
MOS_OS_CHK_NULL(pGmmResourceInfo); |
| 2486 |
|
| 2487 |
switch (pGmmResourceInfo->GetTileType()) |
| 2488 |
{ |
| 2489 |
case GMM_TILED_X: |
| 2490 |
tileformat = MOS_TILE_X; |
| 2491 |
tileformat_linux = TILING_X; |
| 2492 |
break; |
| 2493 |
case GMM_TILED_Y: |
| 2494 |
tileformat = MOS_TILE_Y; |
| 2495 |
tileformat_linux = TILING_Y; |
| 2496 |
break; |
| 2497 |
case GMM_NOT_TILED: |
| 2498 |
tileformat = MOS_TILE_LINEAR; |
| 2499 |
tileformat_linux = TILING_NONE; |
| 2500 |
break; |
| 2501 |
default: |
| 2502 |
tileformat = MOS_TILE_Y; |
| 2503 |
tileformat_linux = TILING_Y; |
| 2504 |
break; |
| 2505 |
} |
| 2506 |
|
| 2507 |
if (pParams->TileType == MOS_TILE_Y) |
| 2508 |
{ |
| 2509 |
pGmmResourceInfo->SetMmcMode((GMM_RESOURCE_MMC_INFO)pParams->CompressionMode, 0); |
| 2510 |
} |
| 2511 |
|
| 2512 |
iPitch = GFX_ULONG_CAST(pGmmResourceInfo->GetRenderPitch()); |
| 2513 |
iSize = GFX_ULONG_CAST(pGmmResourceInfo->GetSizeSurface()); |
| 2514 |
iHeight = pGmmResourceInfo->GetBaseHeight(); |
| 2515 |
|
| 2516 |
MemoryPolicyParameter memPolicyPar; |
| 2517 |
MOS_ZeroMemory(&memPolicyPar, sizeof(MemoryPolicyParameter)); |
| 2518 |
|
| 2519 |
memPolicyPar.skuTable = &pOsInterface->pOsContext->m_skuTable; |
| 2520 |
memPolicyPar.waTable = &pOsInterface->pOsContext->m_waTable; |
| 2521 |
memPolicyPar.resInfo = pGmmResourceInfo; |
| 2522 |
memPolicyPar.resName = pParams->pBufName; |
| 2523 |
memPolicyPar.preferredMemType = pParams->dwMemType; |
| 2524 |
|
| 2525 |
mem_type = MemoryPolicyManager::UpdateMemoryPolicy(&memPolicyPar); |
| 2526 |
|
| 2527 |
// Only Linear and Y TILE supported |
| 2528 |
if( tileformat_linux == TILING_NONE ) |
| 2529 |
{ |
| 2530 |
struct mos_drm_bo_alloc alloc; |
| 2531 |
alloc.name = bufname; |
| 2532 |
alloc.size = iSize; |
| 2533 |
alloc.alignment = 4096; |
| 2534 |
alloc.ext.mem_type = mem_type; |
| 2535 |
bo = mos_bo_alloc(pOsInterface->pOsContext->bufmgr, &alloc); |
| 2536 |
} |
| 2537 |
else |
| 2538 |
{ |
| 2539 |
struct mos_drm_bo_alloc_tiled alloc_tiled; |
| 2540 |
alloc_tiled.name = bufname; |
| 2541 |
alloc_tiled.x = iPitch; |
| 2542 |
alloc_tiled.y = iSize/iPitch; |
| 2543 |
alloc_tiled.cpp = 1; |
| 2544 |
alloc_tiled.ext.tiling_mode = tileformat_linux; |
| 2545 |
alloc_tiled.ext.mem_type = mem_type; |
| 2546 |
|
| 2547 |
bo = mos_bo_alloc_tiled(pOsInterface->pOsContext->bufmgr, &alloc_tiled); |
| 2548 |
iPitch = (int32_t)alloc_tiled.pitch;; |
| 2549 |
} |
| 2550 |
|
| 2551 |
pOsResource->bMapped = false; |
| 2552 |
if (bo) |
| 2553 |
{ |
| 2554 |
pOsResource->Format = pParams->Format; |
| 2555 |
pOsResource->iWidth = pParams->dwWidth; |
| 2556 |
pOsResource->iHeight = iHeight; |
| 2557 |
pOsResource->iPitch = iPitch; |
| 2558 |
pOsResource->iCount = 0; |
| 2559 |
pOsResource->bufname = bufname; |
| 2560 |
pOsResource->bo = bo; |
| 2561 |
pOsResource->TileType = tileformat; |
| 2562 |
pOsResource->TileModeGMM = (MOS_TILE_MODE_GMM)pGmmResourceInfo->GetTileModeSurfaceState(); |
| 2563 |
pOsResource->bGMMTileEnabled = true; |
| 2564 |
pOsResource->pData = (uint8_t *)bo->virt; //It is useful for batch buffer to fill commands |
| 2565 |
if (pParams->ResUsageType == MOS_CODEC_RESOURCE_USAGE_BEGIN_CODEC || |
| 2566 |
pParams->ResUsageType >= MOS_HW_RESOURCE_USAGE_MEDIA_BATCH_BUFFERS) |
| 2567 |
{ |
| 2568 |
pOsResource->memObjCtrlState = MosInterface::GetCachePolicyMemoryObject(pOsInterface->pOsContext->pGmmClientContext, MOS_MP_RESOURCE_USAGE_DEFAULT); |
| 2569 |
pOsResource->mocsMosResUsageType = MOS_MP_RESOURCE_USAGE_DEFAULT; |
| 2570 |
} |
| 2571 |
else |
| 2572 |
{ |
| 2573 |
pOsResource->memObjCtrlState = MosInterface::GetCachePolicyMemoryObject(pOsInterface->pOsContext->pGmmClientContext, pParams->ResUsageType); |
| 2574 |
pOsResource->mocsMosResUsageType = pParams->ResUsageType; |
| 2575 |
} |
| 2576 |
|
| 2577 |
MOS_OS_VERBOSEMESSAGE("Alloc %7d bytes (%d x %d resource).",iSize, pParams->dwWidth, iHeight); |
| 2578 |
} |
| 2579 |
else |
| 2580 |
{ |
| 2581 |
MOS_OS_ASSERTMESSAGE("Fail to Alloc %7d bytes (%d x %d resource).",iSize, pParams->dwWidth, pParams->dwHeight); |
| 2582 |
eStatus = MOS_STATUS_NO_SPACE; |
| 2583 |
} |
| 2584 |
|
| 2585 |
MosUtilities::MosAtomicIncrement(MosUtilities::m_mosMemAllocCounterGfx); |
| 2586 |
MOS_MEMNINJA_GFX_ALLOC_MESSAGE(pOsResource->pGmmResInfo, bufname, pOsInterface->Component, |
| 2587 |
(uint32_t)pOsResource->pGmmResInfo->GetSizeSurface(), pParams->dwArraySize, functionName, filename, line); |
| 2588 |
|
| 2589 |
finish: |
| 2590 |
return eStatus; |
| 2591 |
} |
| 2592 |
|
| 2593 |
//! |
| 2594 |
//! \brief Get Resource Information |
| 2595 |
//! \details Linux get resource info |
| 2596 |
//! \param PMOS_INTERFACE pOsInterface |
| 2597 |
//! [in] Pointer to OS interface structure |
| 2598 |
//! \param PMOS_RESOURCE pOsResource |
| 2599 |
//! [in] Pointer to input OS resource |
| 2600 |
//! \param PMOS_SURFACE pResDetails |
| 2601 |
//! [out] Pointer to output resource information details |
| 2602 |
//! \return MOS_STATUS |
| 2603 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 2604 |
//! |
| 2605 |
MOS_STATUS Mos_Specific_GetResourceInfo( |
| 2606 |
PMOS_INTERFACE pOsInterface, |
| 2607 |
PMOS_RESOURCE pOsResource, |
| 2608 |
PMOS_SURFACE pResDetails) |
| 2609 |
{ |
| 2610 |
GMM_RESOURCE_INFO * pGmmResourceInfo = nullptr; |
| 2611 |
GMM_DISPLAY_FRAME gmmChannel = GMM_DISPLAY_FRAME_MAX; |
| 2612 |
GMM_REQ_OFFSET_INFO reqInfo[3] = {}; |
| 2613 |
GMM_RESOURCE_FLAG GmmFlags = {}; |
| 2614 |
MOS_STATUS eStatus; |
| 2615 |
|
| 2616 |
MOS_OS_FUNCTION_ENTER; |
| 2617 |
|
| 2618 |
eStatus = MOS_STATUS_SUCCESS; |
| 2619 |
|
| 2620 |
MOS_OS_CHK_NULL(pOsInterface); |
| 2621 |
MOS_OS_CHK_NULL(pOsResource); |
| 2622 |
MOS_OS_CHK_NULL(pResDetails); |
| 2623 |
|
| 2624 |
if (pOsInterface->apoMosEnabled) |
| 2625 |
{ |
| 2626 |
return MosInterface::GetResourceInfo(pOsInterface->osStreamState, pOsResource, *pResDetails); |
| 2627 |
} |
| 2628 |
|
| 2629 |
// Get Gmm resource info |
| 2630 |
pGmmResourceInfo = (GMM_RESOURCE_INFO*)pOsResource->pGmmResInfo; |
| 2631 |
MOS_OS_CHK_NULL(pGmmResourceInfo); |
| 2632 |
|
| 2633 |
GmmFlags = pGmmResourceInfo->GetResFlags(); |
| 2634 |
|
| 2635 |
pResDetails->dwWidth = GFX_ULONG_CAST(pGmmResourceInfo->GetBaseWidth()); |
| 2636 |
pResDetails->dwHeight = pGmmResourceInfo->GetBaseHeight(); |
| 2637 |
pResDetails->dwPitch = GFX_ULONG_CAST(pGmmResourceInfo->GetRenderPitch()); |
| 2638 |
pResDetails->dwSize = GFX_ULONG_CAST(pGmmResourceInfo->GetSizeSurface()); |
| 2639 |
pResDetails->dwDepth = MOS_MAX(1, pGmmResourceInfo->GetBaseDepth()); |
| 2640 |
pResDetails->dwLockPitch = GFX_ULONG_CAST(pGmmResourceInfo->GetRenderPitch()); |
| 2641 |
if (GFX_GET_CURRENT_RENDERCORE(pOsInterface->pfnGetGmmClientContext(pOsInterface)->GetPlatformInfo().Platform) < IGFX_GEN8_CORE) |
| 2642 |
{ |
| 2643 |
pResDetails->bArraySpacing = pGmmResourceInfo->IsArraySpacingSingleLod(); |
| 2644 |
} |
| 2645 |
if (GFX_GET_CURRENT_RENDERCORE(pOsInterface->pfnGetGmmClientContext(pOsInterface)->GetPlatformInfo().Platform) >= IGFX_GEN9_CORE) |
| 2646 |
{ |
| 2647 |
pResDetails->dwQPitch = pGmmResourceInfo->GetQPitch(); |
| 2648 |
} |
| 2649 |
|
| 2650 |
pResDetails->bCompressible = GmmFlags.Gpu.MMC ? |
| 2651 |
(pGmmResourceInfo->GetMmcHint(0) == GMM_MMC_HINT_ON) : false; |
| 2652 |
pResDetails->bIsCompressed = pGmmResourceInfo->IsMediaMemoryCompressed(0); |
| 2653 |
pResDetails->CompressionMode = (MOS_RESOURCE_MMC_MODE)pGmmResourceInfo->GetMmcMode(0); |
| 2654 |
|
| 2655 |
if (0 == pResDetails->dwPitch) |
| 2656 |
{ |
| 2657 |
MOS_OS_ASSERTMESSAGE("Pitch from GmmResource is 0, unexpected."); |
| 2658 |
return MOS_STATUS_INVALID_PARAMETER; |
| 2659 |
} |
| 2660 |
// check resource's tile type |
| 2661 |
pResDetails->TileModeGMM = (MOS_TILE_MODE_GMM)pGmmResourceInfo->GetTileModeSurfaceState(); |
| 2662 |
pResDetails->bGMMTileEnabled = true; |
| 2663 |
switch (pGmmResourceInfo->GetTileType()) |
| 2664 |
{ |
| 2665 |
case GMM_TILED_Y: |
| 2666 |
if (GmmFlags.Info.TiledYf) |
| 2667 |
{ |
| 2668 |
pResDetails->TileType = MOS_TILE_YF; |
| 2669 |
} |
| 2670 |
else if (GmmFlags.Info.TiledYs) |
| 2671 |
{ |
| 2672 |
pResDetails->TileType = MOS_TILE_YS; |
| 2673 |
} |
| 2674 |
else |
| 2675 |
{ |
| 2676 |
pResDetails->TileType = MOS_TILE_Y; |
| 2677 |
} |
| 2678 |
break; |
| 2679 |
case GMM_TILED_X: |
| 2680 |
pResDetails->TileType = MOS_TILE_X; |
| 2681 |
break; |
| 2682 |
case GMM_NOT_TILED: |
| 2683 |
pResDetails->TileType = MOS_TILE_LINEAR; |
| 2684 |
break; |
| 2685 |
default: |
| 2686 |
pResDetails->TileType = MOS_TILE_Y; |
| 2687 |
break; |
| 2688 |
} |
| 2689 |
pResDetails->Format = pOsResource->Format; |
| 2690 |
|
| 2691 |
MOS_ZeroMemory(reqInfo, sizeof(reqInfo)); |
| 2692 |
gmmChannel = GMM_DISPLAY_BASE; |
| 2693 |
// Get the base offset of the surface (plane Y) |
| 2694 |
reqInfo[2].ReqRender = true; |
| 2695 |
reqInfo[2].Plane = GMM_PLANE_Y; |
| 2696 |
reqInfo[2].Frame = gmmChannel; |
| 2697 |
reqInfo[2].CubeFace = __GMM_NO_CUBE_MAP; |
| 2698 |
reqInfo[2].ArrayIndex = 0; |
| 2699 |
pGmmResourceInfo->GetOffset(reqInfo[2]); |
| 2700 |
pResDetails->RenderOffset.YUV.Y.BaseOffset = reqInfo[2].Render.Offset; |
| 2701 |
|
| 2702 |
// Get U/UV plane information (plane offset, X/Y offset) |
| 2703 |
reqInfo[0].ReqRender = true; |
| 2704 |
reqInfo[0].Plane = GMM_PLANE_U; |
| 2705 |
reqInfo[0].Frame = gmmChannel; |
| 2706 |
reqInfo[0].CubeFace = __GMM_NO_CUBE_MAP; |
| 2707 |
reqInfo[0].ArrayIndex = 0; |
| 2708 |
pGmmResourceInfo->GetOffset(reqInfo[0]); |
| 2709 |
|
| 2710 |
pResDetails->RenderOffset.YUV.U.BaseOffset = reqInfo[0].Render.Offset; |
| 2711 |
pResDetails->RenderOffset.YUV.U.XOffset = reqInfo[0].Render.XOffset; |
| 2712 |
pResDetails->RenderOffset.YUV.U.YOffset = reqInfo[0].Render.YOffset; |
| 2713 |
|
| 2714 |
// Get V plane information (plane offset, X/Y offset) |
| 2715 |
reqInfo[1].ReqRender = true; |
| 2716 |
reqInfo[1].Plane = GMM_PLANE_V; |
| 2717 |
reqInfo[1].Frame = gmmChannel; |
| 2718 |
reqInfo[1].CubeFace = __GMM_NO_CUBE_MAP; |
| 2719 |
reqInfo[1].ArrayIndex = 0; |
| 2720 |
pGmmResourceInfo->GetOffset(reqInfo[1]); |
| 2721 |
|
| 2722 |
pResDetails->RenderOffset.YUV.V.BaseOffset = reqInfo[1].Render.Offset; |
| 2723 |
pResDetails->RenderOffset.YUV.V.XOffset = reqInfo[1].Render.XOffset; |
| 2724 |
pResDetails->RenderOffset.YUV.V.YOffset = reqInfo[1].Render.YOffset; |
| 2725 |
|
| 2726 |
finish: |
| 2727 |
return eStatus; |
| 2728 |
} |
| 2729 |
|
| 2730 |
//! |
| 2731 |
//! \brief Free the resource |
| 2732 |
//! \details Free the allocated resource |
| 2733 |
//! \param PMOS_INTERFACE pOsInterface |
| 2734 |
//! [in] Pointer to OS interface structure |
| 2735 |
//! \param PMOS_RESOURCE pOsResource |
| 2736 |
//! [in] Pointer to input OS resource |
| 2737 |
//! \return void |
| 2738 |
//! |
| 2739 |
void Mos_Specific_FreeResource( |
| 2740 |
PMOS_INTERFACE pOsInterface, |
| 2741 |
#if MOS_MESSAGES_ENABLED |
| 2742 |
PCCHAR functionName, |
| 2743 |
PCCHAR filename, |
| 2744 |
int32_t line, |
| 2745 |
#endif // MOS_MESSAGES_ENABLED |
| 2746 |
PMOS_RESOURCE pOsResource) |
| 2747 |
{ |
| 2748 |
MOS_OS_FUNCTION_ENTER; |
| 2749 |
|
| 2750 |
if( nullptr == pOsInterface ) |
| 2751 |
{ |
| 2752 |
MOS_OS_ASSERTMESSAGE("input parameter pOsInterface is NULL."); |
| 2753 |
return; |
| 2754 |
} |
| 2755 |
|
| 2756 |
if( nullptr == pOsResource ) |
| 2757 |
{ |
| 2758 |
MOS_OS_ASSERTMESSAGE("input parameter pOsResource is NULL."); |
| 2759 |
return; |
| 2760 |
} |
| 2761 |
|
| 2762 |
bool osContextValid = false; |
| 2763 |
if (pOsInterface->osContextPtr != nullptr) |
| 2764 |
{ |
| 2765 |
if (pOsInterface->osContextPtr->GetOsContextValid() == true) |
| 2766 |
{ |
| 2767 |
osContextValid = true; |
| 2768 |
} |
| 2769 |
} |
| 2770 |
|
| 2771 |
if (pOsInterface->apoMosEnabled) |
| 2772 |
{ |
| 2773 |
MosInterface::FreeResource( |
| 2774 |
pOsInterface->osStreamState, |
| 2775 |
pOsResource, |
| 2776 |
0 |
| 2777 |
#if MOS_MESSAGES_ENABLED |
| 2778 |
, |
| 2779 |
functionName, |
| 2780 |
filename, |
| 2781 |
line |
| 2782 |
#endif |
| 2783 |
); |
| 2784 |
|
| 2785 |
return; |
| 2786 |
} |
| 2787 |
|
| 2788 |
if ((pOsInterface->modulizedMosEnabled) |
| 2789 |
&& (!pOsResource->bConvertedFromDDIResource) |
| 2790 |
&& (osContextValid == true) |
| 2791 |
&& (!Mos_Solo_IsEnabled(nullptr)) |
| 2792 |
&& (pOsResource->pGfxResource)) |
| 2793 |
{ |
| 2794 |
if (pOsInterface->osContextPtr == nullptr) |
| 2795 |
{ |
| 2796 |
MOS_OS_ASSERTMESSAGE("invalid osContextPtr."); |
| 2797 |
return; |
| 2798 |
} |
| 2799 |
if (MosUtilities::m_mosMemAllocCounterGfx != nullptr) |
| 2800 |
{ |
| 2801 |
GraphicsResource::SetMemAllocCounterGfx(*MosUtilities::m_mosMemAllocCounterGfx); |
| 2802 |
} |
| 2803 |
if (pOsResource && pOsResource->pGfxResource) |
| 2804 |
{ |
| 2805 |
pOsResource->pGfxResource->Free(pOsInterface->osContextPtr); |
| 2806 |
} |
| 2807 |
else |
| 2808 |
{ |
| 2809 |
MOS_OS_VERBOSEMESSAGE("Received an empty Graphics Resource, skip free"); |
| 2810 |
} |
| 2811 |
MOS_Delete(pOsResource->pGfxResource); |
| 2812 |
pOsResource->pGfxResource = nullptr; |
| 2813 |
if (MosUtilities::m_mosMemAllocCounterGfx != nullptr) |
| 2814 |
{ |
| 2815 |
*MosUtilities::m_mosMemAllocCounterGfx = GraphicsResource::GetMemAllocCounterGfx(); |
| 2816 |
} |
| 2817 |
MOS_MEMNINJA_GFX_FREE_MESSAGE(pOsResource->pGmmResInfo, functionName, filename, line); |
| 2818 |
MOS_ZeroMemory(pOsResource, sizeof(*pOsResource)); |
| 2819 |
return; |
| 2820 |
} |
| 2821 |
|
| 2822 |
if (pOsResource && pOsResource->bo) |
| 2823 |
{ |
| 2824 |
OsContextSpecific *osCtx = static_cast<OsContextSpecific *>(pOsInterface->osContextPtr); |
| 2825 |
if(osCtx == nullptr) |
| 2826 |
{ |
| 2827 |
MOS_OS_ASSERTMESSAGE("osCtx is nullptr!"); |
| 2828 |
return; |
| 2829 |
} |
| 2830 |
else |
| 2831 |
{ |
| 2832 |
AuxTableMgr *auxTableMgr = osCtx->GetAuxTableMgr(); |
| 2833 |
|
| 2834 |
// Unmap Resource from Aux Table |
| 2835 |
if (auxTableMgr) |
| 2836 |
{ |
| 2837 |
auxTableMgr->UnmapResource(pOsResource->pGmmResInfo, pOsResource->bo); |
| 2838 |
} |
| 2839 |
} |
| 2840 |
|
| 2841 |
mos_bo_unreference((MOS_LINUX_BO *)(pOsResource->bo)); |
| 2842 |
|
| 2843 |
if ( pOsInterface->pOsContext != nullptr && pOsInterface->pOsContext->contextOffsetList.size()) |
| 2844 |
{ |
| 2845 |
MOS_CONTEXT *pOsCtx = pOsInterface->pOsContext; |
| 2846 |
auto item_ctx = pOsCtx->contextOffsetList.begin(); |
| 2847 |
|
| 2848 |
for (;item_ctx != pOsCtx->contextOffsetList.end();) |
| 2849 |
{ |
| 2850 |
if (item_ctx->target_bo == pOsResource->bo) |
| 2851 |
{ |
| 2852 |
item_ctx = pOsCtx->contextOffsetList.erase(item_ctx); |
| 2853 |
} |
| 2854 |
else |
| 2855 |
{ |
| 2856 |
item_ctx++; |
| 2857 |
} |
| 2858 |
} |
| 2859 |
} |
| 2860 |
|
| 2861 |
pOsResource->bo = nullptr; |
| 2862 |
if (pOsResource->pGmmResInfo != nullptr && |
| 2863 |
pOsInterface->pOsContext != nullptr && |
| 2864 |
pOsInterface->pOsContext->pGmmClientContext != nullptr) |
| 2865 |
{ |
| 2866 |
MosUtilities::MosAtomicDecrement(MosUtilities::m_mosMemAllocCounterGfx); |
| 2867 |
MOS_MEMNINJA_GFX_FREE_MESSAGE(pOsResource->pGmmResInfo, functionName, filename, line); |
| 2868 |
|
| 2869 |
pOsInterface->pOsContext->pGmmClientContext->DestroyResInfoObject(pOsResource->pGmmResInfo); |
| 2870 |
pOsResource->pGmmResInfo = nullptr; |
| 2871 |
} |
| 2872 |
} |
| 2873 |
|
| 2874 |
} |
| 2875 |
|
| 2876 |
//! |
| 2877 |
//! \brief Free OS resource |
| 2878 |
//! \details Free OS resource |
| 2879 |
//! \param PMOS_INTERFACE pOsInterface |
| 2880 |
//! [in] OS Interface |
| 2881 |
//! \param PMOS_RESOURCE pOsResource |
| 2882 |
//! [in/out] OS Resource to be freed |
| 2883 |
//! \param uint32_t uiFlag |
| 2884 |
//! [in] Flag to free resources. This one is useless on Linux, just for compatibility. |
| 2885 |
//! \return void |
| 2886 |
//! |
| 2887 |
void Mos_Specific_FreeResourceWithFlag( |
| 2888 |
PMOS_INTERFACE pOsInterface, |
| 2889 |
PMOS_RESOURCE pOsResource, |
| 2890 |
#if MOS_MESSAGES_ENABLED |
| 2891 |
PCCHAR functionName, |
| 2892 |
PCCHAR filename, |
| 2893 |
int32_t line, |
| 2894 |
#endif // MOS_MESSAGES_ENABLED |
| 2895 |
uint32_t uiFlag) |
| 2896 |
{ |
| 2897 |
MOS_UNUSED(uiFlag); |
| 2898 |
|
| 2899 |
if (pOsInterface == nullptr || |
| 2900 |
pOsResource == nullptr) |
| 2901 |
{ |
| 2902 |
return; |
| 2903 |
} |
| 2904 |
|
| 2905 |
#if MOS_MESSAGES_ENABLED |
| 2906 |
Mos_Specific_FreeResource(pOsInterface, functionName, filename, line, pOsResource); |
| 2907 |
#else |
| 2908 |
Mos_Specific_FreeResource(pOsInterface, pOsResource); |
| 2909 |
#endif // MOS_MESSAGES_ENABLED |
| 2910 |
} |
| 2911 |
|
| 2912 |
//! |
| 2913 |
//! \brief Locks Resource request |
| 2914 |
//! \details Locks Resource request |
| 2915 |
//! \param PMOS_INTERFACE pOsInterface |
| 2916 |
//! [in] pointer to OS Interface structure |
| 2917 |
//! \param PMOS_RESOURCE pOsResource |
| 2918 |
//! [in/out] Resource object |
| 2919 |
//! \param PMOS_LOCK_PARAMS pLockFlags |
| 2920 |
//! [in] Lock Flags |
| 2921 |
//! \return MOS_STATUS |
| 2922 |
//! MOS_STATUS_SUCCESS if successful |
| 2923 |
//! |
| 2924 |
MOS_STATUS Mos_Specific_LockSyncRequest( |
| 2925 |
PMOS_INTERFACE pOsInterface, |
| 2926 |
PMOS_RESOURCE pOsResource, |
| 2927 |
PMOS_LOCK_PARAMS pLockFlags) |
| 2928 |
{ |
| 2929 |
MOS_UNUSED(pOsInterface); |
| 2930 |
MOS_UNUSED(pOsInterface); |
| 2931 |
MOS_UNUSED(pOsInterface); |
| 2932 |
|
| 2933 |
return MOS_STATUS_SUCCESS; |
| 2934 |
} |
| 2935 |
|
| 2936 |
//! |
| 2937 |
//! \brief Lock resource |
| 2938 |
//! \details Lock allocated resource |
| 2939 |
//! \param PMOS_INTERFACE pOsInterface |
| 2940 |
//! [in] Pointer to OS interface structure |
| 2941 |
//! \param PMOS_RESOURCE pOsResource |
| 2942 |
//! [in] Pointer to input OS resource |
| 2943 |
//! \param PMOS_LOCK_PARAMS pLockFlags |
| 2944 |
//! [in] Lock Flags - MOS_LOCKFLAG_* flags |
| 2945 |
//! \return void * |
| 2946 |
//! |
| 2947 |
void *Mos_Specific_LockResource( |
| 2948 |
PMOS_INTERFACE pOsInterface, |
| 2949 |
PMOS_RESOURCE pOsResource, |
| 2950 |
PMOS_LOCK_PARAMS pLockFlags) |
| 2951 |
{ |
| 2952 |
void *pData = nullptr; |
| 2953 |
MOS_OS_CONTEXT *pContext = nullptr; |
| 2954 |
|
| 2955 |
MOS_OS_FUNCTION_ENTER; |
| 2956 |
|
| 2957 |
MOS_OS_ASSERT(pOsInterface); |
| 2958 |
MOS_OS_ASSERT(pOsResource); |
| 2959 |
MOS_OS_ASSERT(pOsInterface->pOsContext); |
| 2960 |
|
| 2961 |
if( nullptr == pOsInterface ) |
| 2962 |
{ |
| 2963 |
MOS_OS_ASSERTMESSAGE("input parameter pOsInterface is NULL."); |
| 2964 |
return nullptr; |
| 2965 |
} |
| 2966 |
|
| 2967 |
if( nullptr == pOsResource) |
| 2968 |
{ |
| 2969 |
MOS_OS_ASSERTMESSAGE("input parameter pOsInterface is NULL."); |
| 2970 |
return nullptr; |
| 2971 |
} |
| 2972 |
|
| 2973 |
bool osContextValid = false; |
| 2974 |
if (pOsInterface->osContextPtr != nullptr) |
| 2975 |
{ |
| 2976 |
if (pOsInterface->osContextPtr->GetOsContextValid() == true) |
| 2977 |
{ |
| 2978 |
osContextValid = true; |
| 2979 |
} |
| 2980 |
} |
| 2981 |
|
| 2982 |
if (pOsInterface->apoMosEnabled) |
| 2983 |
{ |
| 2984 |
return MosInterface::LockMosResource(pOsInterface->osStreamState, pOsResource, pLockFlags); |
| 2985 |
} |
| 2986 |
|
| 2987 |
if ((pOsInterface->modulizedMosEnabled) |
| 2988 |
&& (!pOsResource->bConvertedFromDDIResource) |
| 2989 |
&& (osContextValid == true) |
| 2990 |
&& (!Mos_Solo_IsEnabled(nullptr)) |
| 2991 |
&& (pOsResource->pGfxResource)) |
| 2992 |
{ |
| 2993 |
if (nullptr == pOsInterface->osContextPtr) |
| 2994 |
{ |
| 2995 |
MOS_OS_ASSERTMESSAGE("invalid osContextPtr, skip lock"); |
| 2996 |
} |
| 2997 |
|
| 2998 |
if (pOsResource->pGfxResource) |
| 2999 |
{ |
| 3000 |
GraphicsResource::LockParams params(pLockFlags); |
| 3001 |
pData = pOsResource->pGfxResource->Lock(pOsInterface->osContextPtr, params); |
| 3002 |
} |
| 3003 |
else |
| 3004 |
{ |
| 3005 |
MOS_OS_ASSERTMESSAGE("Received an empty Graphics Resource, skip lock"); |
| 3006 |
} |
| 3007 |
return pData; |
| 3008 |
} |
| 3009 |
|
| 3010 |
pContext = pOsInterface->pOsContext; |
| 3011 |
if (pOsResource && pOsResource->bo && pOsResource->pGmmResInfo) |
| 3012 |
{ |
| 3013 |
MOS_LINUX_BO *bo = pOsResource->bo; |
| 3014 |
GMM_RESOURCE_FLAG GmmFlags; |
| 3015 |
|
| 3016 |
MOS_ZeroMemory(&GmmFlags, sizeof(GmmFlags)); |
| 3017 |
GmmFlags = pOsResource->pGmmResInfo->GetResFlags(); |
| 3018 |
|
| 3019 |
// Do decompression for a compressed surface before lock |
| 3020 |
if (!pLockFlags->NoDecompress && |
| 3021 |
(((GmmFlags.Gpu.MMC || GmmFlags.Gpu.CCS) && GmmFlags.Gpu.UnifiedAuxSurface)|| |
| 3022 |
pOsResource->pGmmResInfo->IsMediaMemoryCompressed(0))) |
| 3023 |
{ |
| 3024 |
PMOS_CONTEXT pOsContext = pOsInterface->pOsContext; |
| 3025 |
|
| 3026 |
MOS_OS_ASSERT(pOsContext); |
| 3027 |
MOS_OS_ASSERT(pOsContext->ppMediaMemDecompState); |
| 3028 |
MOS_OS_ASSERT(pOsContext->pfnMemoryDecompress); |
| 3029 |
pOsContext->pfnMemoryDecompress(pOsContext, pOsResource); |
| 3030 |
} |
| 3031 |
|
| 3032 |
if(false == pOsResource->bMapped) |
| 3033 |
{ |
| 3034 |
if (pContext->bIsAtomSOC) |
| 3035 |
{ |
| 3036 |
mos_bo_map_gtt(bo); |
| 3037 |
} |
| 3038 |
else |
| 3039 |
{ |
| 3040 |
if (pOsResource->TileType != MOS_TILE_LINEAR && !pLockFlags->TiledAsTiled) |
| 3041 |
{ |
| 3042 |
if (pContext->bUseSwSwizzling) |
| 3043 |
{ |
| 3044 |
mos_bo_map(bo, (OSKM_LOCKFLAG_WRITEONLY&pLockFlags->WriteOnly)); |
| 3045 |
pOsResource->MmapOperation = MOS_MMAP_OPERATION_MMAP; |
| 3046 |
if (pOsResource->pSystemShadow == nullptr) |
| 3047 |
{ |
| 3048 |
pOsResource->pSystemShadow = (uint8_t *)MOS_AllocMemory(bo->size); |
| 3049 |
MOS_OS_CHECK_CONDITION((pOsResource->pSystemShadow == nullptr), "Failed to allocate shadow surface", nullptr); |
| 3050 |
} |
| 3051 |
if (pOsResource->pSystemShadow) |
| 3052 |
{ |
| 3053 |
int32_t flags = pContext->bTileYFlag ? 0 : 1; |
| 3054 |
MOS_OS_CHECK_CONDITION((pOsResource->TileType != MOS_TILE_Y), "Unsupported tile type", nullptr); |
| 3055 |
MOS_OS_CHECK_CONDITION((bo->size <= 0 || pOsResource->iPitch <= 0), "Invalid BO size or pitch", nullptr); |
| 3056 |
Mos_SwizzleData((uint8_t*)bo->virt, pOsResource->pSystemShadow, |
| 3057 |
MOS_TILE_Y, MOS_TILE_LINEAR, bo->size / pOsResource->iPitch, pOsResource->iPitch, flags); |
| 3058 |
} |
| 3059 |
} |
| 3060 |
else |
| 3061 |
{ |
| 3062 |
mos_bo_map_gtt(bo); |
| 3063 |
pOsResource->MmapOperation = MOS_MMAP_OPERATION_MMAP_GTT; |
| 3064 |
} |
| 3065 |
} |
| 3066 |
else if (pLockFlags->Uncached) |
| 3067 |
{ |
| 3068 |
mos_bo_map_wc(bo); |
| 3069 |
pOsResource->MmapOperation = MOS_MMAP_OPERATION_MMAP_WC; |
| 3070 |
} |
| 3071 |
else |
| 3072 |
{ |
| 3073 |
mos_bo_map(bo, (OSKM_LOCKFLAG_WRITEONLY&pLockFlags->WriteOnly)); |
| 3074 |
pOsResource->MmapOperation = MOS_MMAP_OPERATION_MMAP; |
| 3075 |
} |
| 3076 |
} |
| 3077 |
pOsResource->pData = pOsResource->pSystemShadow ? pOsResource->pSystemShadow : (uint8_t*)bo->virt; |
| 3078 |
pOsResource->bMapped = true; |
| 3079 |
} |
| 3080 |
|
| 3081 |
pData = pOsResource->pData; |
| 3082 |
|
| 3083 |
} |
| 3084 |
|
| 3085 |
finish: |
| 3086 |
MOS_OS_ASSERT(pData); |
| 3087 |
return pData; |
| 3088 |
} |
| 3089 |
|
| 3090 |
//! |
| 3091 |
//! \brief Unlock resource |
| 3092 |
//! \details Unlock the locked resource |
| 3093 |
//! \param PMOS_INTERFACE pOsInterface |
| 3094 |
//! [in] Pointer to OS interface structure |
| 3095 |
//! \param PMOS_RESOURCE pOsResource |
| 3096 |
//! [in] Pointer to input OS resource |
| 3097 |
//! \return MOS_STATUS |
| 3098 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 3099 |
//! |
| 3100 |
MOS_STATUS Mos_Specific_UnlockResource( |
| 3101 |
PMOS_INTERFACE pOsInterface, |
| 3102 |
PMOS_RESOURCE pOsResource) |
| 3103 |
{ |
| 3104 |
MOS_STATUS eStatus; |
| 3105 |
|
| 3106 |
eStatus = MOS_STATUS_SUCCESS; |
| 3107 |
|
| 3108 |
MOS_OS_CONTEXT *pContext = nullptr; |
| 3109 |
|
| 3110 |
MOS_OS_FUNCTION_ENTER; |
| 3111 |
|
| 3112 |
MOS_OS_CHK_NULL(pOsInterface); |
| 3113 |
MOS_OS_CHK_NULL(pOsResource); |
| 3114 |
MOS_OS_CHK_NULL(pOsInterface->pOsContext); |
| 3115 |
|
| 3116 |
if (pOsInterface->apoMosEnabled) |
| 3117 |
{ |
| 3118 |
return MosInterface::UnlockMosResource(pOsInterface->osStreamState, pOsResource); |
| 3119 |
} |
| 3120 |
|
| 3121 |
bool osContextValid; |
| 3122 |
osContextValid = false; |
| 3123 |
if (pOsInterface->osContextPtr != nullptr) |
| 3124 |
{ |
| 3125 |
if (pOsInterface->osContextPtr->GetOsContextValid() == true) |
| 3126 |
{ |
| 3127 |
osContextValid = true; |
| 3128 |
} |
| 3129 |
} |
| 3130 |
|
| 3131 |
if ((pOsInterface->modulizedMosEnabled) |
| 3132 |
&& (!pOsResource->bConvertedFromDDIResource) |
| 3133 |
&& (osContextValid == true) |
| 3134 |
&& (!Mos_Solo_IsEnabled(nullptr)) |
| 3135 |
&& (pOsResource->pGfxResource)) |
| 3136 |
{ |
| 3137 |
if (nullptr == pOsInterface->osContextPtr) |
| 3138 |
{ |
| 3139 |
MOS_OS_ASSERTMESSAGE("invalid osContextPtr, skip lock"); |
| 3140 |
} |
| 3141 |
|
| 3142 |
if (pOsResource->pGfxResource) |
| 3143 |
{ |
| 3144 |
eStatus = pOsResource->pGfxResource->Unlock(pOsInterface->osContextPtr); |
| 3145 |
} |
| 3146 |
else |
| 3147 |
{ |
| 3148 |
MOS_OS_VERBOSEMESSAGE("Received an empty Graphics Resource, skip unlock"); |
| 3149 |
} |
| 3150 |
return eStatus; |
| 3151 |
} |
| 3152 |
|
| 3153 |
pContext = pOsInterface->pOsContext; |
| 3154 |
|
| 3155 |
if(pOsResource->bo) |
| 3156 |
{ |
| 3157 |
if(true == pOsResource->bMapped) |
| 3158 |
{ |
| 3159 |
if (pContext->bIsAtomSOC) |
| 3160 |
{ |
| 3161 |
mos_bo_unmap_gtt(pOsResource->bo); |
| 3162 |
} |
| 3163 |
else |
| 3164 |
{ |
| 3165 |
if (pOsResource->pSystemShadow) |
| 3166 |
{ |
| 3167 |
int32_t flags = pContext->bTileYFlag ? 0 : 1; |
| 3168 |
Mos_SwizzleData(pOsResource->pSystemShadow, (uint8_t*)pOsResource->bo->virt, |
| 3169 |
MOS_TILE_LINEAR, MOS_TILE_Y, pOsResource->bo->size / pOsResource->iPitch, pOsResource->iPitch, flags); |
| 3170 |
MOS_FreeMemory(pOsResource->pSystemShadow); |
| 3171 |
pOsResource->pSystemShadow = nullptr; |
| 3172 |
} |
| 3173 |
|
| 3174 |
switch(pOsResource->MmapOperation) |
| 3175 |
{ |
| 3176 |
case MOS_MMAP_OPERATION_MMAP_GTT: |
| 3177 |
mos_bo_unmap_gtt(pOsResource->bo); |
| 3178 |
break; |
| 3179 |
case MOS_MMAP_OPERATION_MMAP_WC: |
| 3180 |
mos_bo_unmap_wc(pOsResource->bo); |
| 3181 |
break; |
| 3182 |
case MOS_MMAP_OPERATION_MMAP: |
| 3183 |
mos_bo_unmap(pOsResource->bo); |
| 3184 |
break; |
| 3185 |
default: |
| 3186 |
MOS_OS_ASSERTMESSAGE("Invalid mmap operation type"); |
| 3187 |
break; |
| 3188 |
} |
| 3189 |
} |
| 3190 |
pOsResource->bo->virt = nullptr; |
| 3191 |
pOsResource->bMapped = false; |
| 3192 |
} |
| 3193 |
pOsResource->pData = nullptr; |
| 3194 |
} |
| 3195 |
|
| 3196 |
finish: |
| 3197 |
return eStatus; |
| 3198 |
} |
| 3199 |
|
| 3200 |
//! |
| 3201 |
//! \brief Decompress Resource |
| 3202 |
//! \details Decompress Resource |
| 3203 |
//! \param PMOS_INTERFACE pOsInterface |
| 3204 |
//! [in] pointer to OS Interface structure |
| 3205 |
//! \param PMOS_RESOURCE pOsResource |
| 3206 |
//! [in/out] Resource object |
| 3207 |
//! \return MOS_STATUS |
| 3208 |
//! MOS_STATUS_SUCCESS if successful |
| 3209 |
//! |
| 3210 |
MOS_STATUS Mos_Specific_DecompResource( |
| 3211 |
PMOS_INTERFACE pOsInterface, |
| 3212 |
PMOS_RESOURCE pOsResource) |
| 3213 |
{ |
| 3214 |
MOS_STATUS eStatus = MOS_STATUS_UNKNOWN; |
| 3215 |
MOS_OS_CONTEXT *pContext = nullptr; |
| 3216 |
|
| 3217 |
//--------------------------------------- |
| 3218 |
MOS_OS_CHK_NULL(pOsInterface); |
| 3219 |
MOS_OS_CHK_NULL(pOsResource); |
| 3220 |
MOS_OS_CHK_NULL(pOsInterface->pOsContext); |
| 3221 |
//--------------------------------------- |
| 3222 |
|
| 3223 |
if (pOsInterface->apoMosEnabled) |
| 3224 |
{ |
| 3225 |
return MosInterface::DecompResource(pOsInterface->osStreamState, pOsResource); |
| 3226 |
} |
| 3227 |
|
| 3228 |
pContext = pOsInterface->pOsContext; |
| 3229 |
|
| 3230 |
if (pOsResource && pOsResource->bo && pOsResource->pGmmResInfo) |
| 3231 |
{ |
| 3232 |
MOS_LINUX_BO *bo = pOsResource->bo; |
| 3233 |
if (pOsResource->pGmmResInfo->IsMediaMemoryCompressed(0)) |
| 3234 |
{ |
| 3235 |
PMOS_CONTEXT pOsContext = pOsInterface->pOsContext; |
| 3236 |
|
| 3237 |
MOS_OS_CHK_NULL(pOsContext); |
| 3238 |
MOS_OS_CHK_NULL(pOsContext->ppMediaMemDecompState); |
| 3239 |
MOS_OS_CHK_NULL(pOsContext->pfnMemoryDecompress); |
| 3240 |
pOsContext->pfnMemoryDecompress(pOsContext, pOsResource); |
| 3241 |
} |
| 3242 |
} |
| 3243 |
|
| 3244 |
eStatus = MOS_STATUS_SUCCESS; |
| 3245 |
|
| 3246 |
finish: |
| 3247 |
return eStatus; |
| 3248 |
} |
| 3249 |
|
| 3250 |
//! |
| 3251 |
//! \brief Set auxiliary sync resource |
| 3252 |
//! \details Set auxiliary resource to sync with decompression |
| 3253 |
//! \param PMOS_INTERFACE pOsInterface |
| 3254 |
//! [in] pointer to OS Interface structure |
| 3255 |
//! \param PMOS_RESOURCE pOsResource |
| 3256 |
//! [in/out] Resource object |
| 3257 |
//! \return MOS_STATUS |
| 3258 |
//! MOS_STATUS_SUCCESS if successful |
| 3259 |
//! |
| 3260 |
MOS_STATUS Mos_Specific_SetDecompSyncRes( |
| 3261 |
PMOS_INTERFACE pOsInterface, |
| 3262 |
PMOS_RESOURCE syncResource) |
| 3263 |
{ |
| 3264 |
return MOS_STATUS_SUCCESS; |
| 3265 |
} |
| 3266 |
|
| 3267 |
//! |
| 3268 |
//! \brief Decompress and Copy Resource to Another Buffer |
| 3269 |
//! \details Decompress and Copy Resource to Another Buffer |
| 3270 |
//! \param PMOS_INTERFACE pOsInterface |
| 3271 |
//! [in] pointer to OS Interface structure |
| 3272 |
//! \param PMOS_RESOURCE inputOsResource |
| 3273 |
//! [in] Input Resource object |
| 3274 |
//! \param PMOS_RESOURCE outputOsResource |
| 3275 |
//! [out] output Resource object |
| 3276 |
//! \param [in] bOutputCompressed |
| 3277 |
//! true means apply compression on output surface, else output uncompressed surface |
| 3278 |
//! \return MOS_STATUS |
| 3279 |
//! MOS_STATUS_SUCCESS if successful |
| 3280 |
//! |
| 3281 |
MOS_STATUS Mos_Specific_DoubleBufferCopyResource( |
| 3282 |
PMOS_INTERFACE osInterface, |
| 3283 |
PMOS_RESOURCE inputOsResource, |
| 3284 |
PMOS_RESOURCE outputOsResource, |
| 3285 |
bool bOutputCompressed) |
| 3286 |
{ |
| 3287 |
MOS_STATUS eStatus = MOS_STATUS_UNKNOWN; |
| 3288 |
MOS_OS_CONTEXT *pContext = nullptr; |
| 3289 |
|
| 3290 |
//--------------------------------------- |
| 3291 |
MOS_OS_CHK_NULL(osInterface); |
| 3292 |
MOS_OS_CHK_NULL(inputOsResource); |
| 3293 |
MOS_OS_CHK_NULL(outputOsResource); |
| 3294 |
//--------------------------------------- |
| 3295 |
|
| 3296 |
if (osInterface->apoMosEnabled) |
| 3297 |
{ |
| 3298 |
return MosInterface::DoubleBufferCopyResource(osInterface->osStreamState, inputOsResource, outputOsResource, bOutputCompressed); |
| 3299 |
} |
| 3300 |
|
| 3301 |
pContext = osInterface->pOsContext; |
| 3302 |
|
| 3303 |
if (inputOsResource && inputOsResource->bo && inputOsResource->pGmmResInfo && |
| 3304 |
outputOsResource && outputOsResource->bo && outputOsResource->pGmmResInfo) |
| 3305 |
{ |
| 3306 |
// Double Buffer Copy can support any tile status surface with/without compression |
| 3307 |
pContext->pfnMediaMemoryCopy(pContext, inputOsResource, outputOsResource, bOutputCompressed); |
| 3308 |
} |
| 3309 |
|
| 3310 |
eStatus = MOS_STATUS_SUCCESS; |
| 3311 |
|
| 3312 |
finish: |
| 3313 |
return eStatus; |
| 3314 |
} |
| 3315 |
|
| 3316 |
//! |
| 3317 |
//! \brief Decompress and Copy Resource to Another Buffer |
| 3318 |
//! \details Decompress and Copy Resource to Another Buffer |
| 3319 |
//! \param PMOS_INTERFACE pOsInterface |
| 3320 |
//! [in] pointer to OS Interface structure |
| 3321 |
//! \param PMOS_RESOURCE inputOsResource |
| 3322 |
//! [in] Input Resource object |
| 3323 |
//! \param PMOS_RESOURCE outputOsResource |
| 3324 |
//! [out] output Resource object |
| 3325 |
//! \param [in] copyWidth |
| 3326 |
//! The 2D surface Width |
| 3327 |
//! \param [in] copyHeight |
| 3328 |
//! The 2D surface height |
| 3329 |
//! \param [in] copyInputOffset |
| 3330 |
//! The offset of copied surface from |
| 3331 |
//! \param [in] copyOutputOffset |
| 3332 |
//! The offset of copied to |
| 3333 |
//! \param [in] bOutputCompressed |
| 3334 |
//! true means apply compression on output surface, else output uncompressed surface |
| 3335 |
//! \return MOS_STATUS |
| 3336 |
//! MOS_STATUS_SUCCESS if successful |
| 3337 |
//! |
| 3338 |
MOS_STATUS Mos_Specific_MediaCopyResource2D( |
| 3339 |
PMOS_INTERFACE osInterface, |
| 3340 |
PMOS_RESOURCE inputOsResource, |
| 3341 |
PMOS_RESOURCE outputOsResource, |
| 3342 |
uint32_t copyWidth, |
| 3343 |
uint32_t copyHeight, |
| 3344 |
uint32_t bpp, |
| 3345 |
bool bOutputCompressed) |
| 3346 |
{ |
| 3347 |
MOS_STATUS eStatus = MOS_STATUS_UNKNOWN; |
| 3348 |
MOS_OS_CONTEXT *pContext = nullptr; |
| 3349 |
|
| 3350 |
//--------------------------------------- |
| 3351 |
MOS_OS_CHK_NULL(osInterface); |
| 3352 |
MOS_OS_CHK_NULL(inputOsResource); |
| 3353 |
MOS_OS_CHK_NULL(outputOsResource); |
| 3354 |
//--------------------------------------- |
| 3355 |
|
| 3356 |
if (osInterface->apoMosEnabled) |
| 3357 |
{ |
| 3358 |
return MosInterface::MediaCopyResource2D(osInterface->osStreamState, inputOsResource, outputOsResource, |
| 3359 |
copyWidth, copyHeight, bpp, bOutputCompressed); |
| 3360 |
} |
| 3361 |
|
| 3362 |
pContext = osInterface->pOsContext; |
| 3363 |
|
| 3364 |
if (inputOsResource && inputOsResource->bo && inputOsResource->pGmmResInfo && |
| 3365 |
outputOsResource && outputOsResource->bo && outputOsResource->pGmmResInfo) |
| 3366 |
{ |
| 3367 |
// Double Buffer Copy can support any tile status surface with/without compression |
| 3368 |
pContext->pfnMediaMemoryCopy2D(pContext, inputOsResource, outputOsResource, copyWidth, copyHeight, 0, 0, bpp, bOutputCompressed); |
| 3369 |
} |
| 3370 |
|
| 3371 |
eStatus = MOS_STATUS_SUCCESS; |
| 3372 |
|
| 3373 |
finish: |
| 3374 |
return eStatus; |
| 3375 |
} |
| 3376 |
|
| 3377 |
//! |
| 3378 |
//! \brief Copy mono picture |
| 3379 |
//! \details This is the copy function dedicated to mono picture copy |
| 3380 |
//! \param PMOS_INTERFACE pOsInterface |
| 3381 |
//! [in] pointer to OS Interface structure |
| 3382 |
//! \param PMOS_RESOURCE inputOsResource |
| 3383 |
//! [in] Input Resource object |
| 3384 |
//! \param PMOS_RESOURCE outputOsResource |
| 3385 |
//! [out] output Resource object |
| 3386 |
//! \param [in] copyWidth |
| 3387 |
//! The 2D surface Width |
| 3388 |
//! \param [in] copyHeight |
| 3389 |
//! The 2D surface height |
| 3390 |
//! \param [in] copyInputOffset |
| 3391 |
//! The offset of copied surface from |
| 3392 |
//! \param [in] copyOutputOffset |
| 3393 |
//! The offset of copied to |
| 3394 |
//! \param [in] bOutputCompressed |
| 3395 |
//! true means apply compression on output surface, else output uncompressed surface |
| 3396 |
//! \return MOS_STATUS |
| 3397 |
//! MOS_STATUS_SUCCESS if successful |
| 3398 |
//! |
| 3399 |
MOS_STATUS Mos_Specific_MonoSurfaceCopy( |
| 3400 |
PMOS_INTERFACE osInterface, |
| 3401 |
PMOS_RESOURCE inputOsResource, |
| 3402 |
PMOS_RESOURCE outputOsResource, |
| 3403 |
uint32_t copyWidth, |
| 3404 |
uint32_t copyHeight, |
| 3405 |
uint32_t copyInputOffset, |
| 3406 |
uint32_t copyOutputOffset, |
| 3407 |
bool bOutputCompressed) |
| 3408 |
{ |
| 3409 |
MOS_STATUS eStatus = MOS_STATUS_UNKNOWN; |
| 3410 |
MOS_OS_CONTEXT *pContext = nullptr; |
| 3411 |
|
| 3412 |
//--------------------------------------- |
| 3413 |
MOS_OS_CHK_NULL_RETURN(osInterface); |
| 3414 |
MOS_OS_CHK_NULL_RETURN(inputOsResource); |
| 3415 |
MOS_OS_CHK_NULL_RETURN(outputOsResource); |
| 3416 |
//--------------------------------------- |
| 3417 |
|
| 3418 |
if (osInterface->apoMosEnabled) |
| 3419 |
{ |
| 3420 |
return MosInterface::MonoSurfaceCopy(osInterface->osStreamState, inputOsResource, outputOsResource, copyWidth, copyHeight, copyInputOffset, copyOutputOffset, bOutputCompressed); |
| 3421 |
} |
| 3422 |
|
| 3423 |
pContext = osInterface->pOsContext; |
| 3424 |
|
| 3425 |
if (inputOsResource && inputOsResource->bo && inputOsResource->pGmmResInfo && |
| 3426 |
outputOsResource && outputOsResource->bo && outputOsResource->pGmmResInfo) |
| 3427 |
{ |
| 3428 |
// Double Buffer Copy can support any tile status surface with/without compression |
| 3429 |
pContext->pfnMediaMemoryCopy2D(pContext, inputOsResource, outputOsResource, copyWidth, copyHeight, 0, 0, 16, bOutputCompressed); |
| 3430 |
} |
| 3431 |
|
| 3432 |
eStatus = MOS_STATUS_SUCCESS; |
| 3433 |
|
| 3434 |
return eStatus; |
| 3435 |
} |
| 3436 |
|
| 3437 |
//! |
| 3438 |
//! \brief Get Mos Context |
| 3439 |
//! \details Get Mos Context info |
| 3440 |
//! \param PMOS_INTERFACE pOsInterface |
| 3441 |
//! [in] Pointer to OS interface structure |
| 3442 |
//! \param mosContext void ** |
| 3443 |
//! [out] pointer of mos_context |
| 3444 |
//! \return MOS_STATUS |
| 3445 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 3446 |
//! |
| 3447 |
MOS_STATUS Mos_Specific_GetMosContext( |
| 3448 |
PMOS_INTERFACE osInterface, |
| 3449 |
PMOS_CONTEXT* mosContext) |
| 3450 |
{ |
| 3451 |
MOS_OS_CHK_NULL_RETURN(osInterface); |
| 3452 |
if (osInterface->apoMosEnabled) |
| 3453 |
{ |
| 3454 |
void *apo_mos_context = nullptr; |
| 3455 |
MOS_OS_CHK_STATUS_RETURN(MosInterface::GetperStreamParameters(osInterface->osStreamState, &apo_mos_context)); |
| 3456 |
*mosContext = (PMOS_CONTEXT)apo_mos_context; |
| 3457 |
} |
| 3458 |
else |
| 3459 |
{ |
| 3460 |
*mosContext = (PMOS_CONTEXT)osInterface->pOsContext; |
| 3461 |
} |
| 3462 |
|
| 3463 |
return MOS_STATUS_SUCCESS; |
| 3464 |
} |
| 3465 |
|
| 3466 |
//! |
| 3467 |
//! \brief Set patch entry |
| 3468 |
//! \details Sets the patch entry in MS's patch list |
| 3469 |
//! \param PMOS_INTERFACE pOsInterface |
| 3470 |
//! [in] Pointer to OS interface structure |
| 3471 |
//! \param PMOS_PATCH_ENTRY_PARAMS pParams |
| 3472 |
//! [in] patch entry params |
| 3473 |
//! \return MOS_STATUS |
| 3474 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 3475 |
//! |
| 3476 |
MOS_STATUS Mos_Specific_SetPatchEntry( |
| 3477 |
PMOS_INTERFACE pOsInterface, |
| 3478 |
PMOS_PATCH_ENTRY_PARAMS pParams) |
| 3479 |
{ |
| 3480 |
MOS_OS_FUNCTION_ENTER; |
| 3481 |
|
| 3482 |
MOS_OS_CHK_NULL_RETURN(pOsInterface); |
| 3483 |
MOS_OS_CHK_NULL_RETURN(pParams); |
| 3484 |
|
| 3485 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 3486 |
if (!pParams->bUpperBoundPatch && pParams->presResource) |
| 3487 |
{ |
| 3488 |
uint32_t handle = pParams->presResource->bo?pParams->presResource->bo->handle:0; |
| 3489 |
uint32_t eventData[] = {handle, pParams->uiResourceOffset, |
| 3490 |
pParams->uiPatchOffset, pParams->bWrite, |
| 3491 |
pParams->HwCommandType, pParams->forceDwordOffset, |
| 3492 |
pParams->patchType}; |
| 3493 |
MOS_TraceEventExt(EVENT_RESOURCE_PATCH, EVENT_TYPE_INFO2, |
| 3494 |
&eventData, sizeof(eventData), |
| 3495 |
nullptr, 0); |
| 3496 |
} |
| 3497 |
#endif |
| 3498 |
if (pOsInterface->apoMosEnabled) |
| 3499 |
{ |
| 3500 |
return MosInterface::SetPatchEntry(pOsInterface->osStreamState, pParams); |
| 3501 |
} |
| 3502 |
|
| 3503 |
if (pOsInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 3504 |
{ |
| 3505 |
auto gpuContext = Linux_GetGpuContext(pOsInterface, pOsInterface->CurrentGpuContextHandle); |
| 3506 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 3507 |
|
| 3508 |
return (gpuContext->SetPatchEntry(pOsInterface, pParams)); |
| 3509 |
} |
| 3510 |
|
| 3511 |
PMOS_OS_CONTEXT pOsContext; |
| 3512 |
MOS_OS_GPU_CONTEXT *pOsGpuContext; |
| 3513 |
PPATCHLOCATIONLIST pPatchList; |
| 3514 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 3515 |
|
| 3516 |
pOsContext = pOsInterface->pOsContext; |
| 3517 |
pOsGpuContext = &pOsContext->OsGpuContext[pOsInterface->CurrentGpuContextOrdinal]; |
| 3518 |
pPatchList = pOsGpuContext->pPatchLocationList; |
| 3519 |
|
| 3520 |
pPatchList[pOsGpuContext->uiCurrentNumPatchLocations].AllocationIndex = pParams->uiAllocationIndex; |
| 3521 |
pPatchList[pOsGpuContext->uiCurrentNumPatchLocations].AllocationOffset = pParams->uiResourceOffset; |
| 3522 |
pPatchList[pOsGpuContext->uiCurrentNumPatchLocations].PatchOffset = pParams->uiPatchOffset; |
| 3523 |
pPatchList[pOsGpuContext->uiCurrentNumPatchLocations].uiWriteOperation = pParams->bWrite ? true : false; |
| 3524 |
|
| 3525 |
if (pOsInterface->osCpInterface && |
| 3526 |
pOsInterface->osCpInterface->IsHMEnabled()) |
| 3527 |
{ |
| 3528 |
pOsInterface->osCpInterface->RegisterPatchForHM( |
| 3529 |
(uint32_t*)(pParams->cmdBufBase + pParams->uiPatchOffset), |
| 3530 |
pParams->bWrite, |
| 3531 |
pParams->HwCommandType, |
| 3532 |
pParams->forceDwordOffset, |
| 3533 |
pParams->presResource, |
| 3534 |
&pPatchList[pOsGpuContext->uiCurrentNumPatchLocations]); |
| 3535 |
} |
| 3536 |
|
| 3537 |
pOsGpuContext->uiCurrentNumPatchLocations++; |
| 3538 |
|
| 3539 |
return eStatus; |
| 3540 |
} |
| 3541 |
|
| 3542 |
//! |
| 3543 |
//! \brief Update resource usage type |
| 3544 |
//! \details update the resource usage for cache policy |
| 3545 |
//! \param PMOS_RESOURCE pOsResource |
| 3546 |
//! [in/out] Pointer to OS Resource |
| 3547 |
//! \param MOS_HW_RESOURCE_DEF resUsageType |
| 3548 |
//! [in] resosuce usage type |
| 3549 |
//! \return MOS_STATUS |
| 3550 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 3551 |
//! |
| 3552 |
MOS_STATUS Mos_Specific_UpdateResourceUsageType( |
| 3553 |
PMOS_RESOURCE pOsResource, |
| 3554 |
MOS_HW_RESOURCE_DEF resUsageType) |
| 3555 |
{ |
| 3556 |
return MosInterface::UpdateResourceUsageType(pOsResource, resUsageType); |
| 3557 |
} |
| 3558 |
|
| 3559 |
//! |
| 3560 |
//! \brief Registers Resource |
| 3561 |
//! \details Set the Allocation Index in OS resource structure |
| 3562 |
//! \param PMOS_INTERFACE pOsInterface |
| 3563 |
//! [in] Pointer to OS Interface |
| 3564 |
//! \param PMOS_RESOURCE pOsResource |
| 3565 |
//! [in/out] Pointer to OS Resource |
| 3566 |
//! \param int32_t bWrite |
| 3567 |
//! [in] Write Flag |
| 3568 |
//! \param int32_t bWritebSetResourceSyncTag |
| 3569 |
//! [in] Resource registration Flag, no use for Linux |
| 3570 |
//! \return MOS_STATUS |
| 3571 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 3572 |
//! |
| 3573 |
MOS_STATUS Mos_Specific_RegisterResource ( |
| 3574 |
PMOS_INTERFACE pOsInterface, |
| 3575 |
PMOS_RESOURCE pOsResource, |
| 3576 |
int32_t bWrite, |
| 3577 |
int32_t bWritebSetResourceSyncTag) |
| 3578 |
{ |
| 3579 |
MOS_OS_FUNCTION_ENTER; |
| 3580 |
|
| 3581 |
MOS_OS_CHK_NULL_RETURN(pOsInterface); |
| 3582 |
MOS_OS_CHK_NULL_RETURN(pOsResource); |
| 3583 |
|
| 3584 |
if (pOsInterface->apoMosEnabled) |
| 3585 |
{ |
| 3586 |
#if MOS_COMMAND_RESINFO_DUMP_SUPPORTED |
| 3587 |
GpuCmdResInfoDumpNext::GetInstance(pOsInterface->pOsContext)->StoreCmdResPtr(pOsInterface, (const void *)pOsResource); |
| 3588 |
#endif // MOS_COMMAND_RESINFO_DUMP_SUPPORTED |
| 3589 |
|
| 3590 |
return MosInterface::RegisterResource( |
| 3591 |
pOsInterface->osStreamState, |
| 3592 |
pOsResource, |
| 3593 |
bWrite); |
| 3594 |
} |
| 3595 |
|
| 3596 |
if (pOsInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 3597 |
{ |
| 3598 |
auto gpuContext = Linux_GetGpuContext(pOsInterface, pOsInterface->CurrentGpuContextHandle); |
| 3599 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 3600 |
|
| 3601 |
#if MOS_COMMAND_RESINFO_DUMP_SUPPORTED |
| 3602 |
GpuCmdResInfoDump::GetInstance(pOsInterface->pOsContext)->StoreCmdResPtr(pOsInterface, (const void *)pOsResource); |
| 3603 |
#endif // MOS_COMMAND_RESINFO_DUMP_SUPPORTED |
| 3604 |
|
| 3605 |
return (gpuContext->RegisterResource(pOsResource, bWrite)); |
| 3606 |
} |
| 3607 |
|
| 3608 |
PMOS_OS_CONTEXT pOsContext = nullptr; |
| 3609 |
PMOS_RESOURCE pResources = nullptr; |
| 3610 |
uint32_t uiAllocation = 0; |
| 3611 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 3612 |
MOS_OS_GPU_CONTEXT *pOsGpuContext = nullptr; |
| 3613 |
MOS_UNUSED(bWritebSetResourceSyncTag); |
| 3614 |
|
| 3615 |
MOS_OS_ASSERT(pOsInterface); |
| 3616 |
MOS_OS_ASSERT(pOsInterface->pOsContext); |
| 3617 |
|
| 3618 |
pOsContext = pOsInterface->pOsContext; |
| 3619 |
|
| 3620 |
if (pOsInterface->CurrentGpuContextOrdinal == MOS_GPU_CONTEXT_INVALID_HANDLE) |
| 3621 |
{ |
| 3622 |
MOS_OS_ASSERTMESSAGE("CurrentGpuContextOrdinal exceed max."); |
| 3623 |
return MOS_STATUS_INVALID_PARAMETER; |
| 3624 |
} |
| 3625 |
pOsGpuContext = &pOsContext->OsGpuContext[pOsInterface->CurrentGpuContextOrdinal]; |
| 3626 |
|
| 3627 |
// Find previous registration |
| 3628 |
pResources = pOsGpuContext->pResources; |
| 3629 |
if( nullptr == pResources) |
| 3630 |
{ |
| 3631 |
MOS_OS_ASSERTMESSAGE("pResource is NULL."); |
| 3632 |
return MOS_STATUS_SUCCESS; |
| 3633 |
} |
| 3634 |
for (uiAllocation = 0; |
| 3635 |
uiAllocation < pOsGpuContext->uiResCount; |
| 3636 |
uiAllocation++, pResources++) |
| 3637 |
{ |
| 3638 |
if (pOsResource->bo == pResources->bo) break; |
| 3639 |
} |
| 3640 |
// Allocation list to be updated |
| 3641 |
if (uiAllocation < pOsGpuContext->uiMaxNumAllocations) |
| 3642 |
{ |
| 3643 |
// New buffer |
| 3644 |
if (uiAllocation == pOsGpuContext->uiResCount) |
| 3645 |
{ |
| 3646 |
pOsGpuContext->uiResCount++; |
| 3647 |
} |
| 3648 |
|
| 3649 |
// Set allocation |
| 3650 |
pOsResource->iAllocationIndex[pOsInterface->CurrentGpuContextOrdinal] = uiAllocation; |
| 3651 |
pOsGpuContext->pResources[uiAllocation] = *pOsResource; |
| 3652 |
pOsGpuContext->pbWriteMode[uiAllocation] |= bWrite; |
| 3653 |
pOsGpuContext->pAllocationList[uiAllocation].hAllocation = &pOsGpuContext->pResources[uiAllocation]; |
| 3654 |
pOsGpuContext->pAllocationList[uiAllocation].WriteOperation|= bWrite; |
| 3655 |
pOsGpuContext->uiNumAllocations = pOsGpuContext->uiResCount; |
| 3656 |
} |
| 3657 |
else |
| 3658 |
{ |
| 3659 |
MOS_OS_ASSERTMESSAGE("Reached max # registrations."); |
| 3660 |
eStatus = MOS_STATUS_UNKNOWN; |
| 3661 |
} |
| 3662 |
return eStatus; |
| 3663 |
} |
| 3664 |
|
| 3665 |
//! |
| 3666 |
//! \brief Verify command buffer size |
| 3667 |
//! \details Verifys the buffer to be used for rendering GPU commands is large enough |
| 3668 |
//! \param PMOS_INTERFACE pOsInterface |
| 3669 |
//! [in] Pointer to OS interface structure |
| 3670 |
//! \param uint32_t dwRequestedSize |
| 3671 |
//! [in] Buffer size requested |
| 3672 |
//! \return MOS_STATUS |
| 3673 |
//! Return MOS_STATUS_SUCCESS if successful (command buffer will be large enough to hold dwMaxSize) |
| 3674 |
//! otherwise failed |
| 3675 |
//! |
| 3676 |
MOS_STATUS Mos_Specific_VerifyCommandBufferSize( |
| 3677 |
PMOS_INTERFACE pOsInterface, |
| 3678 |
uint32_t dwRequestedSize, |
| 3679 |
uint32_t dwFlags) |
| 3680 |
{ |
| 3681 |
MOS_OS_FUNCTION_ENTER; |
| 3682 |
|
| 3683 |
MOS_OS_CHK_NULL_RETURN(pOsInterface); |
| 3684 |
|
| 3685 |
if (pOsInterface->apoMosEnabled) |
| 3686 |
{ |
| 3687 |
return MosInterface::VerifyCommandBufferSize(pOsInterface->osStreamState, 0, dwRequestedSize, dwFlags); |
| 3688 |
} |
| 3689 |
|
| 3690 |
if (pOsInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 3691 |
{ |
| 3692 |
auto gpuContext = Linux_GetGpuContext(pOsInterface, pOsInterface->CurrentGpuContextHandle); |
| 3693 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 3694 |
|
| 3695 |
return (gpuContext->VerifyCommandBufferSize(dwRequestedSize)); |
| 3696 |
} |
| 3697 |
|
| 3698 |
PMOS_OS_CONTEXT pOsContext = nullptr; |
| 3699 |
MOS_OS_GPU_CONTEXT OsGpuContext; |
| 3700 |
|
| 3701 |
//--------------------------------------- |
| 3702 |
MOS_UNUSED(dwFlags); |
| 3703 |
MOS_OS_ASSERT(pOsInterface); |
| 3704 |
MOS_OS_ASSERT(pOsInterface->pOsContext); |
| 3705 |
//--------------------------------------- |
| 3706 |
|
| 3707 |
if (pOsInterface->CurrentGpuContextOrdinal == MOS_GPU_CONTEXT_INVALID_HANDLE) |
| 3708 |
{ |
| 3709 |
MOS_OS_ASSERTMESSAGE("CurrentGpuContextOrdinal exceed max."); |
| 3710 |
return MOS_STATUS_INVALID_PARAMETER; |
| 3711 |
} |
| 3712 |
|
| 3713 |
pOsContext = pOsInterface->pOsContext; |
| 3714 |
OsGpuContext = pOsContext->OsGpuContext[pOsInterface->CurrentGpuContextOrdinal]; |
| 3715 |
|
| 3716 |
if (OsGpuContext.uiCommandBufferSize < dwRequestedSize) |
| 3717 |
{ |
| 3718 |
return MOS_STATUS_UNKNOWN; |
| 3719 |
} |
| 3720 |
|
| 3721 |
return MOS_STATUS_SUCCESS; |
| 3722 |
} |
| 3723 |
|
| 3724 |
//! |
| 3725 |
//! \brief Resets Resource Allocation |
| 3726 |
//! \details Resets Resource Allocation |
| 3727 |
//! \param PMOS_INTERFACE pOsInterface |
| 3728 |
//! [in] Pointer to OS interface structure |
| 3729 |
//! \param PMOS_RESOURCE pOsResource |
| 3730 |
//! [in] Pointer to input OS resource |
| 3731 |
//! \return void |
| 3732 |
//! |
| 3733 |
void Mos_Specific_ResetResourceAllocationIndex ( |
| 3734 |
PMOS_INTERFACE pOsInterface, |
| 3735 |
PMOS_RESOURCE pOsResource) |
| 3736 |
{ |
| 3737 |
int32_t i; |
| 3738 |
MOS_UNUSED(pOsInterface); |
| 3739 |
|
| 3740 |
if( nullptr == pOsResource) |
| 3741 |
{ |
| 3742 |
MOS_OS_ASSERTMESSAGE("pOsResource is NULL."); |
| 3743 |
return; |
| 3744 |
} |
| 3745 |
|
| 3746 |
for (i = 0; i < MOS_GPU_CONTEXT_MAX; i++) |
| 3747 |
{ |
| 3748 |
pOsResource->iAllocationIndex[i] = MOS_INVALID_ALLOC_INDEX; |
| 3749 |
} |
| 3750 |
} |
| 3751 |
|
| 3752 |
//! |
| 3753 |
//! \brief Get command buffer |
| 3754 |
//! \details Retrieves buffer to be used for rendering GPU commands |
| 3755 |
//! \param PMOS_INTERFACE pOsInterface |
| 3756 |
//! [in] Pointer to OS interface structure |
| 3757 |
//! \param PMOS_COMMAND_BUFFER pCmdBuffer |
| 3758 |
//! [out] Pointer to Command Buffer control structure |
| 3759 |
//! \return MOS_STATUS |
| 3760 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 3761 |
//! |
| 3762 |
MOS_STATUS Mos_Specific_GetCommandBuffer( |
| 3763 |
PMOS_INTERFACE pOsInterface, |
| 3764 |
PMOS_COMMAND_BUFFER pCmdBuffer, |
| 3765 |
uint32_t dwFlags) |
| 3766 |
{ |
| 3767 |
MOS_OS_FUNCTION_ENTER; |
| 3768 |
|
| 3769 |
MOS_OS_CHK_NULL_RETURN(pOsInterface); |
| 3770 |
MOS_OS_CHK_NULL_RETURN(pCmdBuffer); |
| 3771 |
|
| 3772 |
if (pOsInterface->apoMosEnabled) |
| 3773 |
{ |
| 3774 |
return MosInterface::GetCommandBuffer(pOsInterface->osStreamState, pCmdBuffer, dwFlags); |
| 3775 |
} |
| 3776 |
|
| 3777 |
if (pOsInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 3778 |
{ |
| 3779 |
auto gpuContext = Linux_GetGpuContext(pOsInterface, pOsInterface->CurrentGpuContextHandle); |
| 3780 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 3781 |
|
| 3782 |
return (gpuContext->GetCommandBuffer(pCmdBuffer, dwFlags)); |
| 3783 |
} |
| 3784 |
|
| 3785 |
PMOS_OS_CONTEXT pOsContext = nullptr; |
| 3786 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 3787 |
PMOS_OS_GPU_CONTEXT pOsGpuContext = nullptr; |
| 3788 |
uint32_t uiCommandBufferSize = 0; |
| 3789 |
|
| 3790 |
MOS_UNUSED(dwFlags); |
| 3791 |
MOS_OS_CHK_NULL(pOsInterface); |
| 3792 |
MOS_OS_CHK_NULL(pOsInterface->pOsContext); |
| 3793 |
MOS_OS_CHK_NULL(pCmdBuffer); |
| 3794 |
|
| 3795 |
if (pOsInterface->CurrentGpuContextOrdinal == MOS_GPU_CONTEXT_INVALID_HANDLE) |
| 3796 |
{ |
| 3797 |
MOS_OS_ASSERTMESSAGE("Invalid input parameter GpuContext."); |
| 3798 |
eStatus = MOS_STATUS_INVALID_PARAMETER; |
| 3799 |
goto finish; |
| 3800 |
} |
| 3801 |
|
| 3802 |
// Activate software context |
| 3803 |
pOsContext = pOsInterface->pOsContext; |
| 3804 |
pOsGpuContext = &pOsContext->OsGpuContext[pOsInterface->CurrentGpuContextOrdinal]; |
| 3805 |
uiCommandBufferSize = pOsGpuContext->uiCommandBufferSize; |
| 3806 |
|
| 3807 |
if(pOsGpuContext->bCBFlushed == true) |
| 3808 |
{ |
| 3809 |
if (pOsContext->pfnGetCommandBuffer(pOsContext, |
| 3810 |
pCmdBuffer, |
| 3811 |
uiCommandBufferSize)) |
| 3812 |
{ |
| 3813 |
MOS_OS_CHK_STATUS(pOsContext->pfnInsertCmdBufferToPool(pOsContext, pCmdBuffer)); |
| 3814 |
pOsGpuContext->bCBFlushed = false; |
| 3815 |
eStatus = MOS_SecureMemcpy(pOsGpuContext->pCB, sizeof(MOS_COMMAND_BUFFER), pCmdBuffer, sizeof(MOS_COMMAND_BUFFER)); |
| 3816 |
MOS_OS_CHECK_CONDITION((eStatus != MOS_STATUS_SUCCESS), "Failed to copy command buffer", eStatus); |
| 3817 |
} |
| 3818 |
else |
| 3819 |
{ |
| 3820 |
MOS_OS_ASSERTMESSAGE("Failed to activate command buffer."); |
| 3821 |
eStatus = MOS_STATUS_UNKNOWN; |
| 3822 |
goto finish; |
| 3823 |
} |
| 3824 |
} |
| 3825 |
|
| 3826 |
MOS_OS_CHK_STATUS(pOsInterface->pfnRegisterResource(pOsInterface, &(pOsGpuContext->pCB->OsResource), false, false)); |
| 3827 |
eStatus = MOS_SecureMemcpy(pCmdBuffer, sizeof(MOS_COMMAND_BUFFER), pOsGpuContext->pCB, sizeof(MOS_COMMAND_BUFFER)); |
| 3828 |
MOS_OS_CHECK_CONDITION((eStatus != MOS_STATUS_SUCCESS), "Failed to copy command buffer", eStatus); |
| 3829 |
|
| 3830 |
finish: |
| 3831 |
return eStatus; |
| 3832 |
} |
| 3833 |
|
| 3834 |
//! |
| 3835 |
//! \brief Set indirect state size |
| 3836 |
//! \details Sets indirect state size to be used for rendering purposes |
| 3837 |
//! \param PMOS_INTERFACE pOsInterface |
| 3838 |
//! [in] Pointer to OS interface structure |
| 3839 |
//! \param uint32_t uSize |
| 3840 |
//! [in] State size |
| 3841 |
//! \return MOS_STATUS |
| 3842 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 3843 |
//! |
| 3844 |
MOS_STATUS Mos_Specific_SetIndirectStateSize( |
| 3845 |
PMOS_INTERFACE pOsInterface, |
| 3846 |
uint32_t uSize) |
| 3847 |
{ |
| 3848 |
MOS_OS_FUNCTION_ENTER; |
| 3849 |
|
| 3850 |
MOS_OS_CHK_NULL_RETURN(pOsInterface); |
| 3851 |
|
| 3852 |
if (pOsInterface->apoMosEnabled) |
| 3853 |
{ |
| 3854 |
return MosInterface::SetupIndirectState(pOsInterface->osStreamState, uSize); |
| 3855 |
} |
| 3856 |
|
| 3857 |
if (pOsInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 3858 |
{ |
| 3859 |
auto gpuContext = Linux_GetGpuContext(pOsInterface, pOsInterface->CurrentGpuContextHandle); |
| 3860 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 3861 |
|
| 3862 |
MOS_OS_CHK_STATUS_RETURN(gpuContext->SetIndirectStateSize(uSize)); |
| 3863 |
} |
| 3864 |
|
| 3865 |
PMOS_CONTEXT pOsContext = nullptr; |
| 3866 |
MOS_STATUS eStatus; |
| 3867 |
|
| 3868 |
MOS_OS_CHK_NULL(pOsInterface); |
| 3869 |
|
| 3870 |
eStatus = MOS_STATUS_SUCCESS; |
| 3871 |
|
| 3872 |
pOsContext = pOsInterface->pOsContext; |
| 3873 |
MOS_OS_CHK_NULL(pOsContext); |
| 3874 |
|
| 3875 |
pOsContext->uIndirectStateSize = uSize; |
| 3876 |
|
| 3877 |
finish: |
| 3878 |
return eStatus; |
| 3879 |
} |
| 3880 |
|
| 3881 |
//! |
| 3882 |
//! \brief Set indirect state size |
| 3883 |
//! \details Retrieves indirect state to be used for rendering purposes |
| 3884 |
//! \param PMOS_INTERFACE pOsInterface |
| 3885 |
//! [in] Pointer to OS interface structure |
| 3886 |
//! \param uint32_t *puOffset |
| 3887 |
//! [out] Pointer to indirect buffer offset |
| 3888 |
//! \param uint32_t *puSize |
| 3889 |
//! [out] Pointer to indirect buffer size |
| 3890 |
//! \return MOS_STATUS |
| 3891 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 3892 |
//! |
| 3893 |
MOS_STATUS Mos_Specific_GetIndirectState( |
| 3894 |
PMOS_INTERFACE pOsInterface, |
| 3895 |
uint32_t *puOffset, |
| 3896 |
uint32_t *puSize) |
| 3897 |
{ |
| 3898 |
MOS_OS_FUNCTION_ENTER; |
| 3899 |
|
| 3900 |
MOS_OS_CHK_NULL_RETURN(pOsInterface); |
| 3901 |
MOS_OS_CHK_NULL_RETURN(puOffset); |
| 3902 |
MOS_OS_CHK_NULL_RETURN(puSize); |
| 3903 |
|
| 3904 |
if (pOsInterface->apoMosEnabled) |
| 3905 |
{ |
| 3906 |
uint32_t offset = 0; |
| 3907 |
uint32_t size = 0; |
| 3908 |
auto eStatus = MosInterface::GetIndirectState(pOsInterface->osStreamState, nullptr, offset, size); |
| 3909 |
*puOffset = offset; |
| 3910 |
*puSize = size; |
| 3911 |
return eStatus; |
| 3912 |
} |
| 3913 |
|
| 3914 |
if (pOsInterface->CurrentGpuContextHandle == MOS_GPU_CONTEXT_INVALID_HANDLE) |
| 3915 |
{ |
| 3916 |
MOS_OS_ASSERTMESSAGE("Invalid input parameter GpuContext."); |
| 3917 |
return MOS_STATUS_INVALID_PARAMETER; |
| 3918 |
} |
| 3919 |
|
| 3920 |
if (pOsInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 3921 |
{ |
| 3922 |
auto gpuContext = Linux_GetGpuContext(pOsInterface, pOsInterface->CurrentGpuContextHandle); |
| 3923 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 3924 |
|
| 3925 |
return (gpuContext->GetIndirectState(puOffset, puSize)); |
| 3926 |
} |
| 3927 |
|
| 3928 |
PMOS_CONTEXT pOsContext = nullptr; |
| 3929 |
MOS_OS_GPU_CONTEXT OsGpuContext; |
| 3930 |
|
| 3931 |
pOsContext = pOsInterface->pOsContext; |
| 3932 |
if (pOsContext) |
| 3933 |
{ |
| 3934 |
OsGpuContext = pOsContext->OsGpuContext[pOsInterface->CurrentGpuContextOrdinal]; |
| 3935 |
|
| 3936 |
if (puOffset) |
| 3937 |
{ |
| 3938 |
*puOffset = OsGpuContext.uiCommandBufferSize - pOsContext->uIndirectStateSize; |
| 3939 |
} |
| 3940 |
|
| 3941 |
if (puSize) |
| 3942 |
{ |
| 3943 |
*puSize = pOsContext->uIndirectStateSize; |
| 3944 |
} |
| 3945 |
} |
| 3946 |
return MOS_STATUS_SUCCESS; |
| 3947 |
} |
| 3948 |
|
| 3949 |
//! |
| 3950 |
//! \brief Get Resource Allocation Index |
| 3951 |
//! \details Get Resource Allocation Index |
| 3952 |
//! \param PMOS_INTERFACE pOsInterface |
| 3953 |
//! [in] Pointer to OS interface structure |
| 3954 |
//! \param PMOS_RESOURCE pResource |
| 3955 |
//! [in] Pointer to input OS resource |
| 3956 |
//! \return int32_t |
| 3957 |
//! return the allocation index |
| 3958 |
//! |
| 3959 |
int32_t Mos_Specific_GetResourceAllocationIndex( |
| 3960 |
PMOS_INTERFACE pOsInterface, |
| 3961 |
PMOS_RESOURCE pResource) |
| 3962 |
{ |
| 3963 |
MOS_OS_FUNCTION_ENTER; |
| 3964 |
|
| 3965 |
if (pResource && pOsInterface) |
| 3966 |
{ |
| 3967 |
|
| 3968 |
if (pOsInterface->CurrentGpuContextHandle == MOS_GPU_CONTEXT_INVALID_HANDLE) |
| 3969 |
{ |
| 3970 |
MOS_OS_ASSERTMESSAGE("Invalid input parameter GpuContext."); |
| 3971 |
return MOS_STATUS_INVALID_PARAMETER; |
| 3972 |
} |
| 3973 |
|
| 3974 |
return(pResource->iAllocationIndex[pOsInterface->CurrentGpuContextOrdinal]); |
| 3975 |
} |
| 3976 |
|
| 3977 |
return MOS_INVALID_ALLOC_INDEX; |
| 3978 |
|
| 3979 |
} |
| 3980 |
|
| 3981 |
//! |
| 3982 |
//! \brief Get Indirect State Pointer |
| 3983 |
//! \details Get Indirect State Pointer |
| 3984 |
//! \param PMOS_INTERFACE pOsInterface |
| 3985 |
//! [in] Pointer to OS interface structure |
| 3986 |
//! \param uint8_t **pIndirectState |
| 3987 |
//! [out] Pointer to Indirect State Buffer |
| 3988 |
//! \return MOS_STATUS |
| 3989 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 3990 |
//! |
| 3991 |
MOS_STATUS Mos_Specific_GetIndirectStatePointer( |
| 3992 |
PMOS_INTERFACE pOsInterface, |
| 3993 |
uint8_t **pIndirectState) |
| 3994 |
{ |
| 3995 |
PMOS_OS_CONTEXT pOsContext = nullptr; |
| 3996 |
MOS_OS_GPU_CONTEXT OsGpuContext = {}; |
| 3997 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 3998 |
|
| 3999 |
MOS_OS_FUNCTION_ENTER; |
| 4000 |
|
| 4001 |
MOS_OS_CHK_NULL_RETURN(pOsInterface); |
| 4002 |
MOS_OS_CHK_NULL_RETURN(pIndirectState); |
| 4003 |
|
| 4004 |
if (pOsInterface->apoMosEnabled) |
| 4005 |
{ |
| 4006 |
uint32_t offset = 0; |
| 4007 |
uint32_t size = 0; |
| 4008 |
return MosInterface::GetIndirectState(pOsInterface->osStreamState, pIndirectState, offset, size); |
| 4009 |
} |
| 4010 |
|
| 4011 |
if (pOsInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 4012 |
{ |
| 4013 |
auto gpuContext = Linux_GetGpuContext(pOsInterface, pOsInterface->CurrentGpuContextHandle); |
| 4014 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 4015 |
|
| 4016 |
return (gpuContext->GetIndirectStatePointer(pIndirectState)); |
| 4017 |
} |
| 4018 |
|
| 4019 |
eStatus = MOS_STATUS_UNKNOWN; |
| 4020 |
|
| 4021 |
pOsContext = (pOsInterface) ? pOsInterface->pOsContext : nullptr; |
| 4022 |
|
| 4023 |
if (pOsContext) |
| 4024 |
{ |
| 4025 |
if (pOsInterface->CurrentGpuContextHandle == MOS_GPU_CONTEXT_INVALID_HANDLE) |
| 4026 |
{ |
| 4027 |
MOS_OS_ASSERTMESSAGE("Invalid input parameter GpuContext."); |
| 4028 |
return MOS_STATUS_INVALID_PARAMETER; |
| 4029 |
} |
| 4030 |
|
| 4031 |
OsGpuContext = pOsContext->OsGpuContext[pOsInterface->CurrentGpuContextOrdinal]; |
| 4032 |
|
| 4033 |
if (OsGpuContext.pCB && OsGpuContext.pCB->pCmdBase) |
| 4034 |
{ |
| 4035 |
*pIndirectState = |
| 4036 |
(uint8_t*)OsGpuContext.pCB->pCmdBase + |
| 4037 |
OsGpuContext.uiCommandBufferSize - |
| 4038 |
pOsContext->uIndirectStateSize; |
| 4039 |
|
| 4040 |
eStatus = MOS_STATUS_SUCCESS; |
| 4041 |
} |
| 4042 |
} |
| 4043 |
|
| 4044 |
return eStatus; |
| 4045 |
} |
| 4046 |
|
| 4047 |
//! |
| 4048 |
//! \brief Return command buffer space |
| 4049 |
//! \details Return unused command buffer space |
| 4050 |
//! \param PMOS_INTERFACE pOsInterface |
| 4051 |
//! [in] Pointer to OS interface structure |
| 4052 |
//! \param PMOS_COMMAND_BUFFER pCmdBuffer |
| 4053 |
//! [out] Pointer to Command Buffer control structure |
| 4054 |
//! \return void |
| 4055 |
//! |
| 4056 |
void Mos_Specific_ReturnCommandBuffer( |
| 4057 |
PMOS_INTERFACE pOsInterface, |
| 4058 |
PMOS_COMMAND_BUFFER pCmdBuffer, |
| 4059 |
uint32_t dwFlags) |
| 4060 |
{ |
| 4061 |
MOS_OS_FUNCTION_ENTER; |
| 4062 |
|
| 4063 |
if (pOsInterface == nullptr || pCmdBuffer == nullptr) |
| 4064 |
{ |
| 4065 |
MOS_OS_ASSERTMESSAGE("Invalid parameters."); |
| 4066 |
return; |
| 4067 |
} |
| 4068 |
|
| 4069 |
// Need to ensure 4K extra padding for HW requirement. |
| 4070 |
if (pCmdBuffer && pCmdBuffer->iRemaining < EXTRA_PADDING_NEEDED) |
| 4071 |
{ |
| 4072 |
MOS_OS_ASSERTMESSAGE("Need to ensure 4K extra padding for HW requirement."); |
| 4073 |
} |
| 4074 |
|
| 4075 |
if (pOsInterface->apoMosEnabled) |
| 4076 |
{ |
| 4077 |
auto status = MosInterface::ReturnCommandBuffer(pOsInterface->osStreamState, pCmdBuffer, dwFlags); |
| 4078 |
if (MOS_FAILED(status)) |
| 4079 |
{ |
| 4080 |
MOS_OS_ASSERTMESSAGE("ReturnCommandBuffer failed."); |
| 4081 |
} |
| 4082 |
return; |
| 4083 |
} |
| 4084 |
|
| 4085 |
if (pOsInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 4086 |
{ |
| 4087 |
auto gpuContext = Linux_GetGpuContext(pOsInterface, pOsInterface->CurrentGpuContextHandle); |
| 4088 |
|
| 4089 |
if (gpuContext) |
| 4090 |
{ |
| 4091 |
gpuContext->ReturnCommandBuffer(pCmdBuffer, dwFlags); |
| 4092 |
} |
| 4093 |
else |
| 4094 |
{ |
| 4095 |
MOS_OS_ASSERTMESSAGE("Cannot get valid Gpu context!"); |
| 4096 |
} |
| 4097 |
|
| 4098 |
return; |
| 4099 |
} |
| 4100 |
|
| 4101 |
PMOS_OS_CONTEXT pOsContext = nullptr; |
| 4102 |
int32_t bResult; |
| 4103 |
|
| 4104 |
MOS_UNUSED(dwFlags); |
| 4105 |
|
| 4106 |
bResult = false; |
| 4107 |
|
| 4108 |
// Validate parameters |
| 4109 |
pOsContext = (pOsInterface) ? pOsInterface->pOsContext : nullptr; |
| 4110 |
if (pOsContext == nullptr || pCmdBuffer == nullptr) |
| 4111 |
{ |
| 4112 |
MOS_OS_ASSERTMESSAGE("Invalid parameters."); |
| 4113 |
goto finish; |
| 4114 |
} |
| 4115 |
|
| 4116 |
pOsContext->pfnReturnCommandBuffer(pOsContext,pOsInterface->CurrentGpuContextOrdinal, pCmdBuffer); |
| 4117 |
|
| 4118 |
finish: |
| 4119 |
return; |
| 4120 |
} |
| 4121 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 4122 |
MOS_LINUX_BO * Mos_GetNopCommandBuffer_Linux( |
| 4123 |
PMOS_INTERFACE pOsInterface) |
| 4124 |
{ |
| 4125 |
int j; |
| 4126 |
uint32_t *buf = nullptr; |
| 4127 |
MOS_LINUX_BO* bo = nullptr; |
| 4128 |
|
| 4129 |
j = 0; |
| 4130 |
|
| 4131 |
if(pOsInterface == nullptr || pOsInterface->pOsContext == nullptr) |
| 4132 |
{ |
| 4133 |
return nullptr; |
| 4134 |
} |
| 4135 |
|
| 4136 |
struct mos_drm_bo_alloc alloc; |
| 4137 |
alloc.name = "NOP_CMD_BO"; |
| 4138 |
alloc.size = 4096; |
| 4139 |
alloc.alignment = 4096; |
| 4140 |
alloc.ext.mem_type = MOS_MEMPOOL_SYSTEMMEMORY; |
| 4141 |
bo = mos_bo_alloc(pOsInterface->pOsContext->bufmgr, &alloc); |
| 4142 |
if(bo == nullptr) |
| 4143 |
{ |
| 4144 |
return nullptr; |
| 4145 |
} |
| 4146 |
|
| 4147 |
mos_bo_map(bo, 1); |
| 4148 |
buf = (uint32_t*)bo->virt; |
| 4149 |
if(buf == nullptr) |
| 4150 |
{ |
| 4151 |
mos_bo_unreference(bo); |
| 4152 |
return nullptr; |
| 4153 |
} |
| 4154 |
|
| 4155 |
buf[j++] = 0x05000000; // MI_BATCH_BUFFER_END |
| 4156 |
|
| 4157 |
mos_bo_unmap(bo); |
| 4158 |
|
| 4159 |
return bo; |
| 4160 |
} |
| 4161 |
|
| 4162 |
MOS_LINUX_BO * Mos_GetBadCommandBuffer_Linux( |
| 4163 |
PMOS_INTERFACE pOsInterface) |
| 4164 |
{ |
| 4165 |
int j; |
| 4166 |
uint32_t *buf = nullptr; |
| 4167 |
MOS_LINUX_BO* bo = nullptr; |
| 4168 |
|
| 4169 |
j = 0; |
| 4170 |
|
| 4171 |
if(pOsInterface == nullptr || pOsInterface->pOsContext == nullptr) |
| 4172 |
{ |
| 4173 |
return nullptr; |
| 4174 |
} |
| 4175 |
|
| 4176 |
struct mos_drm_bo_alloc alloc; |
| 4177 |
alloc.name = "BAD_CMD_BO"; |
| 4178 |
alloc.size = 4096; |
| 4179 |
alloc.alignment = 4096; |
| 4180 |
alloc.ext.mem_type = MOS_MEMPOOL_SYSTEMMEMORY; |
| 4181 |
bo = mos_bo_alloc(pOsInterface->pOsContext->bufmgr, &alloc); |
| 4182 |
if(bo == nullptr) |
| 4183 |
{ |
| 4184 |
return nullptr; |
| 4185 |
} |
| 4186 |
|
| 4187 |
mos_bo_map(bo, 1); |
| 4188 |
buf = (uint32_t*)bo->virt; |
| 4189 |
if(buf == nullptr) |
| 4190 |
{ |
| 4191 |
mos_bo_unreference(bo); |
| 4192 |
return nullptr; |
| 4193 |
} |
| 4194 |
|
| 4195 |
/* Hanging batch buffer */ |
| 4196 |
// Semaphore setup: |
| 4197 |
// Set up GTT buffer, polling mode with |
| 4198 |
// comparison: address > op data (0xffffffff), |
| 4199 |
// which should never resolve since nothing |
| 4200 |
// is bigger than 0xffffffff. This semaphore |
| 4201 |
// should result in a hang that TDR will have |
| 4202 |
// to handle. |
| 4203 |
// |
| 4204 |
// 31:29 = 0 |
| 4205 |
// 28:23 = 0x1c |
| 4206 |
// ---> 31:24 = 0x0e, 23=0x0 |
| 4207 |
// 22:22 = 0x1 (GTT, must be secure batch) |
| 4208 |
// 21:16 = 0x0 |
| 4209 |
// ---> 23:20 = 0x4, 19:16=0x0 |
| 4210 |
// 15:15 = 0x1 (polling mode) |
| 4211 |
// 14:12 = 0x0: memory data > op data (set op data = 0xffffffff and we should never have a match... if the comparison is unsigned) |
| 4212 |
// ---> 15:12 = 0x8 |
| 4213 |
// 11:08 = 0x0 |
| 4214 |
// 07:00 = 0x2 |
| 4215 |
// ---> 07:04 = 0x0, 03:00 = 0x2 |
| 4216 |
// 31:0 = 0xffffffff |
| 4217 |
// |
| 4218 |
buf[j++] = 0x0e008002; |
| 4219 |
|
| 4220 |
// semaphore data |
| 4221 |
// |
| 4222 |
buf[j++] = 0xffffffff; |
| 4223 |
|
| 4224 |
// semaphore address |
| 4225 |
// |
| 4226 |
buf[j++] = 0x0; |
| 4227 |
buf[j++] = 0x0; |
| 4228 |
|
| 4229 |
buf[j++] = 0x0; /* MI_NOOP */ |
| 4230 |
buf[j++] = 0x05000000; // MI_BATCH_BUFFER_END |
| 4231 |
|
| 4232 |
mos_bo_unmap(bo); |
| 4233 |
|
| 4234 |
return bo; |
| 4235 |
} |
| 4236 |
#endif // _DEBUG || _RELEASE_INTERNAL |
| 4237 |
|
| 4238 |
uint32_t Mos_Specific_GetVcsExecFlag(PMOS_INTERFACE pOsInterface, |
| 4239 |
PMOS_COMMAND_BUFFER pCmdBuffer, |
| 4240 |
MOS_GPU_NODE GpuNode) |
| 4241 |
{ |
| 4242 |
MOS_OS_ASSERT(pOsInterface); |
| 4243 |
MOS_OS_ASSERT(pCmdBuffer); |
| 4244 |
uint32_t VcsExecFlag = I915_EXEC_BSD | I915_EXEC_BSD_RING1; |
| 4245 |
|
| 4246 |
if (MOS_VDBOX_NODE_INVALID == pCmdBuffer->iVdboxNodeIndex) |
| 4247 |
{ |
| 4248 |
// That's those case when BB did not have any VDBOX# specific commands. |
| 4249 |
// Thus, we need to select VDBOX# here. Alternatively we can rely on KMD |
| 4250 |
// to make balancing for us, i.e. rely on Virtual Engine support. |
| 4251 |
pCmdBuffer->iVdboxNodeIndex = pOsInterface->pfnGetVdboxNodeId(pOsInterface, pCmdBuffer); |
| 4252 |
if (MOS_VDBOX_NODE_INVALID == pCmdBuffer->iVdboxNodeIndex) |
| 4253 |
{ |
| 4254 |
pCmdBuffer->iVdboxNodeIndex = (GpuNode == MOS_GPU_NODE_VIDEO)? |
| 4255 |
MOS_VDBOX_NODE_1: MOS_VDBOX_NODE_2; |
| 4256 |
} |
| 4257 |
} |
| 4258 |
|
| 4259 |
if (MOS_VDBOX_NODE_1 == pCmdBuffer->iVdboxNodeIndex) |
| 4260 |
{ |
| 4261 |
VcsExecFlag = I915_EXEC_BSD | I915_EXEC_BSD_RING1; |
| 4262 |
} |
| 4263 |
else if (MOS_VDBOX_NODE_2 == pCmdBuffer->iVdboxNodeIndex) |
| 4264 |
{ |
| 4265 |
VcsExecFlag = I915_EXEC_BSD | I915_EXEC_BSD_RING2; |
| 4266 |
} |
| 4267 |
|
| 4268 |
return VcsExecFlag; |
| 4269 |
} |
| 4270 |
|
| 4271 |
//! |
| 4272 |
//! \brief Submit command buffer |
| 4273 |
//! \details Submit the command buffer |
| 4274 |
//! \param PMOS_INTERFACE pOsInterface |
| 4275 |
//! [in] Pointer to OS interface structure |
| 4276 |
//! \param PMOS_COMMAND_BUFFER pCmdBuffer |
| 4277 |
//! [in] Pointer to Command Buffer control structure |
| 4278 |
//! \param int32_t bNullRendering |
| 4279 |
//! [in] boolean null rendering |
| 4280 |
//! \return MOS_STATUS |
| 4281 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 4282 |
//! |
| 4283 |
MOS_STATUS Mos_Specific_SubmitCommandBuffer( |
| 4284 |
PMOS_INTERFACE pOsInterface, |
| 4285 |
PMOS_COMMAND_BUFFER pCmdBuffer, |
| 4286 |
int32_t bNullRendering) |
| 4287 |
{ |
| 4288 |
MOS_OS_FUNCTION_ENTER; |
| 4289 |
|
| 4290 |
MOS_OS_CHK_NULL_RETURN(pOsInterface); |
| 4291 |
MOS_OS_CHK_NULL_RETURN(pCmdBuffer); |
| 4292 |
|
| 4293 |
if (pOsInterface->apoMosEnabled) |
| 4294 |
{ |
| 4295 |
return MosInterface::SubmitCommandBuffer(pOsInterface->osStreamState, pCmdBuffer, bNullRendering); |
| 4296 |
} |
| 4297 |
|
| 4298 |
if (pOsInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 4299 |
{ |
| 4300 |
auto gpuContext = Linux_GetGpuContext(pOsInterface, pOsInterface->CurrentGpuContextHandle); |
| 4301 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 4302 |
|
| 4303 |
#if MOS_COMMAND_RESINFO_DUMP_SUPPORTED |
| 4304 |
GpuCmdResInfoDump::GetInstance(pOsInterface->pOsContext)->Dump(pOsInterface); |
| 4305 |
GpuCmdResInfoDump::GetInstance(pOsInterface->pOsContext)->ClearCmdResPtrs(pOsInterface); |
| 4306 |
#endif // MOS_COMMAND_RESINFO_DUMP_SUPPORTED |
| 4307 |
|
| 4308 |
return (gpuContext->SubmitCommandBuffer(pOsInterface, pCmdBuffer, bNullRendering)); |
| 4309 |
} |
| 4310 |
MOS_OS_ASSERTMESSAGE("Not support this path"); |
| 4311 |
return MOS_STATUS_UNIMPLEMENTED; |
| 4312 |
} |
| 4313 |
|
| 4314 |
//! |
| 4315 |
//! \brief Wait and release command buffer |
| 4316 |
//! \details Wait and release command buffer |
| 4317 |
//! \param PMOS_INTERFACE pOsInterface |
| 4318 |
//! [in] Pointer to OS interface structure |
| 4319 |
//! \param PMOS_COMMAND_BUFFER pCmdBuffer |
| 4320 |
//! [in] Pointer to Command Buffer control structure |
| 4321 |
//! \return MOS_STATUS |
| 4322 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 4323 |
//! |
| 4324 |
MOS_STATUS Mos_Specific_WaitAndReleaseCmdBuffer( |
| 4325 |
PMOS_INTERFACE pOsInterface, |
| 4326 |
PMOS_COMMAND_BUFFER pCmdBuffer) |
| 4327 |
{ |
| 4328 |
MOS_OS_CHK_NULL_RETURN(pOsInterface); |
| 4329 |
MOS_OS_CHK_NULL_RETURN(pCmdBuffer); |
| 4330 |
if (pOsInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 4331 |
{ |
| 4332 |
auto cmd_bo = pCmdBuffer->OsResource.bo; |
| 4333 |
MOS_OS_CHK_NULL_RETURN(cmd_bo); |
| 4334 |
|
| 4335 |
// only wait rendering here, release will covered by gpucontext |
| 4336 |
mos_bo_wait_rendering(cmd_bo); |
| 4337 |
|
| 4338 |
return MOS_STATUS_SUCCESS; |
| 4339 |
} |
| 4340 |
|
| 4341 |
PMOS_CONTEXT pOsContext; |
| 4342 |
MOS_STATUS eStatus; |
| 4343 |
|
| 4344 |
eStatus = MOS_STATUS_SUCCESS; |
| 4345 |
|
| 4346 |
MOS_OS_CHK_NULL(pOsInterface); |
| 4347 |
MOS_OS_CHK_NULL(pCmdBuffer); |
| 4348 |
|
| 4349 |
pOsContext = pOsInterface->pOsContext; |
| 4350 |
MOS_OS_CHK_NULL(pOsContext); |
| 4351 |
|
| 4352 |
MOS_OS_CHK_STATUS(pOsContext->pfnWaitAndReleaseCmdBuffer(pOsContext, pCmdBuffer->iCmdIndex)); |
| 4353 |
|
| 4354 |
finish: |
| 4355 |
return eStatus; |
| 4356 |
} |
| 4357 |
|
| 4358 |
//! |
| 4359 |
//! \brief Get resource gfx address |
| 4360 |
//! \details Get resource gfx address |
| 4361 |
//! \param PMOS_INTERFACE pOsInterface |
| 4362 |
//! [in] Pointer to OS interface structure |
| 4363 |
//! \param PMOS_RESOURCE pResource |
| 4364 |
//! [in] Pointer to resource |
| 4365 |
//! \return uint64_t |
| 4366 |
//! Return resource gfx address |
| 4367 |
//! |
| 4368 |
uint64_t Mos_Specific_GetResourceGfxAddress( |
| 4369 |
PMOS_INTERFACE pOsInterface, |
| 4370 |
PMOS_RESOURCE pResource) |
| 4371 |
{ |
| 4372 |
MOS_OS_CHK_NULL_RETURN(pOsInterface); |
| 4373 |
MOS_OS_CHK_NULL_RETURN(pResource); |
| 4374 |
|
| 4375 |
if (pOsInterface->apoMosEnabled) |
| 4376 |
{ |
| 4377 |
return MosInterface::GetResourceGfxAddress(pOsInterface->osStreamState, pResource); |
| 4378 |
} |
| 4379 |
|
| 4380 |
if (!mos_bo_is_softpin(pResource->bo)) |
| 4381 |
{ |
| 4382 |
mos_bo_set_softpin(pResource->bo); |
| 4383 |
} |
| 4384 |
return pResource->bo->offset64; |
| 4385 |
} |
| 4386 |
|
| 4387 |
//! |
| 4388 |
//! \brief Get Clear Color Address |
| 4389 |
//! \details The clear color address |
| 4390 |
//! \param PMOS_INTERFACE pOsInterface |
| 4391 |
//! [in] OS Interface |
| 4392 |
//! \param PMOS_RESOURCE pResource |
| 4393 |
//! [in] OS resource structure |
| 4394 |
//! \return uint64_t |
| 4395 |
//! The clear color address |
| 4396 |
//! |
| 4397 |
uint64_t Mos_Specific_GetResourceClearAddress( |
| 4398 |
PMOS_INTERFACE pOsInterface, |
| 4399 |
PMOS_RESOURCE pResource) |
| 4400 |
{ |
| 4401 |
uint64_t ui64ClearColorAddress = 0; |
| 4402 |
return ui64ClearColorAddress; |
| 4403 |
} |
| 4404 |
|
| 4405 |
//! |
| 4406 |
//! \brief Resizes the buffer to be used for rendering GPU commands |
| 4407 |
//! \details return true if succeeded - command buffer will be large enough to hold dwMaxSize |
| 4408 |
//! return false if failed or invalid parameters |
| 4409 |
//! \param PMOS_INTERFACE pOsInterface |
| 4410 |
//! [in] Pointer to OS interface structure |
| 4411 |
//! \param uint32_t dwRequestedCommandBufferSize |
| 4412 |
//! [in] requested command buffer size |
| 4413 |
//! \param uint32_t dwRequestedPatchListSize |
| 4414 |
//! [in] requested patch list size |
| 4415 |
//! \return MOS_STATUS |
| 4416 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 4417 |
//! |
| 4418 |
MOS_STATUS Mos_Specific_ResizeCommandBufferAndPatchList( |
| 4419 |
PMOS_INTERFACE pOsInterface, |
| 4420 |
uint32_t dwRequestedCommandBufferSize, |
| 4421 |
uint32_t dwRequestedPatchListSize, |
| 4422 |
uint32_t dwFlags) |
| 4423 |
{ |
| 4424 |
MOS_OS_FUNCTION_ENTER; |
| 4425 |
|
| 4426 |
MOS_OS_CHK_NULL_RETURN(pOsInterface); |
| 4427 |
|
| 4428 |
if (pOsInterface->apoMosEnabled) |
| 4429 |
{ |
| 4430 |
return MosInterface::ResizeCommandBufferAndPatchList(pOsInterface->osStreamState, 0, dwRequestedCommandBufferSize, dwRequestedPatchListSize, dwFlags); |
| 4431 |
} |
| 4432 |
|
| 4433 |
if (pOsInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 4434 |
{ |
| 4435 |
auto gpuContext = Linux_GetGpuContext(pOsInterface, pOsInterface->CurrentGpuContextHandle); |
| 4436 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 4437 |
|
| 4438 |
return (gpuContext->ResizeCommandBufferAndPatchList(dwRequestedCommandBufferSize, dwRequestedPatchListSize, dwFlags)); |
| 4439 |
} |
| 4440 |
|
| 4441 |
PMOS_CONTEXT pOsContext; |
| 4442 |
PMOS_OS_GPU_CONTEXT pOsGpuContext; |
| 4443 |
PPATCHLOCATIONLIST pNewPatchList; |
| 4444 |
MOS_STATUS eStatus; |
| 4445 |
|
| 4446 |
MOS_OS_FUNCTION_ENTER; |
| 4447 |
|
| 4448 |
//--------------------------------------- |
| 4449 |
MOS_UNUSED(dwFlags); |
| 4450 |
MOS_OS_ASSERT(pOsInterface); |
| 4451 |
MOS_OS_ASSERT(pOsInterface->pOsContext); |
| 4452 |
//--------------------------------------- |
| 4453 |
|
| 4454 |
eStatus = MOS_STATUS_SUCCESS; |
| 4455 |
|
| 4456 |
pOsContext = pOsInterface->pOsContext; |
| 4457 |
pOsGpuContext = &(pOsContext->OsGpuContext[pOsInterface->CurrentGpuContextOrdinal]); |
| 4458 |
|
| 4459 |
// uiCommandBufferSize is used for allocate command buffer and submit command buffer, in this moment, command buffer has not allocated yet. |
| 4460 |
// Linux KMD requires command buffer size align to 8 bytes, or it will not execute the commands. |
| 4461 |
pOsGpuContext->uiCommandBufferSize = MOS_ALIGN_CEIL(dwRequestedCommandBufferSize, 8); |
| 4462 |
|
| 4463 |
if (dwRequestedPatchListSize > pOsGpuContext->uiMaxPatchLocationsize) |
| 4464 |
{ |
| 4465 |
pNewPatchList = (PPATCHLOCATIONLIST)realloc( |
| 4466 |
pOsGpuContext->pPatchLocationList, |
| 4467 |
sizeof(PATCHLOCATIONLIST) * dwRequestedPatchListSize); |
| 4468 |
if (nullptr == pNewPatchList) |
| 4469 |
{ |
| 4470 |
MOS_OS_ASSERTMESSAGE("pOsGpuContext->pPatchLocationList realloc failed."); |
| 4471 |
eStatus = MOS_STATUS_NO_SPACE; |
| 4472 |
goto finish; |
| 4473 |
} |
| 4474 |
|
| 4475 |
pOsGpuContext->pPatchLocationList = pNewPatchList; |
| 4476 |
|
| 4477 |
// now zero the extended portion |
| 4478 |
MOS_ZeroMemory( |
| 4479 |
(pOsGpuContext->pPatchLocationList + pOsGpuContext->uiMaxPatchLocationsize), |
| 4480 |
sizeof(PATCHLOCATIONLIST) * (dwRequestedPatchListSize - pOsGpuContext->uiMaxPatchLocationsize)); |
| 4481 |
pOsGpuContext->uiMaxPatchLocationsize = dwRequestedPatchListSize; |
| 4482 |
} |
| 4483 |
|
| 4484 |
finish: |
| 4485 |
return eStatus; |
| 4486 |
} |
| 4487 |
|
| 4488 |
//! |
| 4489 |
//! \brief Create GPU context |
| 4490 |
//! \details Create GPU context |
| 4491 |
//! \param PMOS_INTERFACE pOsInterface |
| 4492 |
//! [in] Pointer to OS interface structure |
| 4493 |
//! \param MOS_GPU_CONTEXT GpuContext |
| 4494 |
//! [in] GPU Context |
| 4495 |
//! \param MOS_GPU_NODE GpuNode |
| 4496 |
//! [in] GPU Node |
| 4497 |
//! \return MOS_STATUS |
| 4498 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 4499 |
//! |
| 4500 |
MOS_STATUS Mos_Specific_CreateGpuContext( |
| 4501 |
PMOS_INTERFACE pOsInterface, |
| 4502 |
MOS_GPU_CONTEXT mosGpuCxt, |
| 4503 |
MOS_GPU_NODE GpuNode, |
| 4504 |
PMOS_GPUCTX_CREATOPTIONS createOption) |
| 4505 |
{ |
| 4506 |
MOS_OS_FUNCTION_ENTER; |
| 4507 |
|
| 4508 |
MOS_OS_CHK_NULL_RETURN(pOsInterface); |
| 4509 |
|
| 4510 |
if (mosGpuCxt == MOS_GPU_CONTEXT_INVALID_HANDLE) |
| 4511 |
{ |
| 4512 |
MOS_OS_ASSERTMESSAGE("Invalid input parameter GpuContext."); |
| 4513 |
return MOS_STATUS_INVALID_PARAMETER; |
| 4514 |
} |
| 4515 |
|
| 4516 |
if (pOsInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 4517 |
{ |
| 4518 |
MOS_OS_CHK_NULL_RETURN(pOsInterface->osContextPtr); |
| 4519 |
|
| 4520 |
auto pOsContextSpecific = static_cast<OsContextSpecific*>(pOsInterface->osContextPtr); |
| 4521 |
MOS_OS_CHK_NULL_RETURN(pOsContextSpecific); |
| 4522 |
|
| 4523 |
auto gpuContextMgr = pOsContextSpecific->GetGpuContextMgr(); |
| 4524 |
if (!pOsInterface->apoMosEnabled) |
| 4525 |
{ |
| 4526 |
MOS_OS_CHK_NULL_RETURN(gpuContextMgr); |
| 4527 |
} |
| 4528 |
|
| 4529 |
auto cmdBufMgr = pOsContextSpecific->GetCmdBufMgr(); |
| 4530 |
if (!pOsInterface->apoMosEnabled) |
| 4531 |
{ |
| 4532 |
MOS_OS_CHK_NULL_RETURN(cmdBufMgr); |
| 4533 |
} |
| 4534 |
|
| 4535 |
MOS_OS_CHK_NULL_RETURN(createOption); |
| 4536 |
if (GpuNode == MOS_GPU_NODE_3D && createOption->SSEUValue != 0) |
| 4537 |
{ |
| 4538 |
struct drm_i915_gem_context_param_sseu sseu; |
| 4539 |
MOS_ZeroMemory(&sseu, sizeof(sseu)); |
| 4540 |
sseu.engine.engine_class = I915_ENGINE_CLASS_RENDER; |
| 4541 |
sseu.engine.engine_instance = 0; |
| 4542 |
|
| 4543 |
if (mos_get_context_param_sseu(pOsInterface->pOsContext->intel_context, &sseu)) |
| 4544 |
{ |
| 4545 |
MOS_OS_ASSERTMESSAGE("Failed to get sseu configuration."); |
| 4546 |
return MOS_STATUS_UNKNOWN; |
| 4547 |
}; |
| 4548 |
|
| 4549 |
if (mos_hweight8(pOsInterface->pOsContext->intel_context, sseu.subslice_mask) > createOption->packed.SubSliceCount) |
| 4550 |
{ |
| 4551 |
sseu.subslice_mask = mos_switch_off_n_bits(pOsInterface->pOsContext->intel_context, sseu.subslice_mask, |
| 4552 |
mos_hweight8(pOsInterface->pOsContext->intel_context, sseu.subslice_mask)-createOption->packed.SubSliceCount); |
| 4553 |
} |
| 4554 |
|
| 4555 |
if (mos_set_context_param_sseu(pOsInterface->pOsContext->intel_context, sseu)) |
| 4556 |
{ |
| 4557 |
MOS_OS_ASSERTMESSAGE("Failed to set sseu configuration."); |
| 4558 |
return MOS_STATUS_UNKNOWN; |
| 4559 |
}; |
| 4560 |
} |
| 4561 |
|
| 4562 |
createOption->gpuNode = GpuNode; |
| 4563 |
if (pOsInterface->apoMosEnabled) |
| 4564 |
{ |
| 4565 |
MOS_OS_CHK_NULL_RETURN(pOsInterface->osStreamState); |
| 4566 |
// Update ctxBasedScheduling from legacy OsInterface |
| 4567 |
pOsInterface->osStreamState->ctxBasedScheduling = pOsInterface->ctxBasedScheduling; |
| 4568 |
if (pOsContextSpecific->GetGpuContextHandle(mosGpuCxt) == MOS_GPU_CONTEXT_INVALID_HANDLE) |
| 4569 |
{ |
| 4570 |
auto osDeviceContext = pOsInterface->osStreamState->osDeviceContext; |
| 4571 |
MOS_OS_CHK_NULL_RETURN(osDeviceContext); |
| 4572 |
auto gpuContextMgr = osDeviceContext->GetGpuContextMgr(); |
| 4573 |
MOS_OS_CHK_NULL_RETURN(gpuContextMgr); |
| 4574 |
auto cmdBufMgr = osDeviceContext->GetCmdBufferMgr(); |
| 4575 |
MOS_OS_CHK_NULL_RETURN(cmdBufMgr); |
| 4576 |
|
| 4577 |
auto gpuContext = gpuContextMgr->CreateGpuContext(GpuNode, cmdBufMgr); |
| 4578 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 4579 |
|
| 4580 |
auto gpuContextSpecific = static_cast<GpuContextSpecificNext *>(gpuContext); |
| 4581 |
MOS_OS_CHK_NULL_RETURN(gpuContextSpecific); |
| 4582 |
|
| 4583 |
MOS_OS_CHK_STATUS_RETURN(gpuContextSpecific->Init(gpuContextMgr->GetOsContext(), pOsInterface->osStreamState, createOption)); |
| 4584 |
gpuContextSpecific->SetGpuContext(mosGpuCxt); |
| 4585 |
|
| 4586 |
pOsContextSpecific->SetGpuContextHandle(mosGpuCxt, gpuContextSpecific->GetGpuContextHandle()); |
| 4587 |
} |
| 4588 |
|
| 4589 |
return MOS_STATUS_SUCCESS; |
| 4590 |
} |
| 4591 |
|
| 4592 |
if (pOsContextSpecific->GetGpuContextHandle(mosGpuCxt) == MOS_GPU_CONTEXT_INVALID_HANDLE) |
| 4593 |
{ |
| 4594 |
auto gpuContext = gpuContextMgr->CreateGpuContext(GpuNode, cmdBufMgr, mosGpuCxt); |
| 4595 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 4596 |
|
| 4597 |
auto gpuContextSpecific = static_cast<GpuContextSpecific *>(gpuContext); |
| 4598 |
MOS_OS_CHK_NULL_RETURN(gpuContextSpecific); |
| 4599 |
|
| 4600 |
MOS_OS_CHK_STATUS_RETURN(gpuContextSpecific->Init(gpuContextMgr->GetOsContext(), pOsInterface, GpuNode, createOption)); |
| 4601 |
|
| 4602 |
pOsContextSpecific->SetGpuContextHandle(mosGpuCxt, gpuContextSpecific->GetGpuContextHandle()); |
| 4603 |
} |
| 4604 |
|
| 4605 |
return MOS_STATUS_SUCCESS; |
| 4606 |
} |
| 4607 |
|
| 4608 |
MOS_UNUSED(pOsInterface); |
| 4609 |
MOS_UNUSED(mosGpuCxt); |
| 4610 |
MOS_UNUSED(GpuNode); |
| 4611 |
MOS_UNUSED(createOption); |
| 4612 |
return MOS_STATUS_SUCCESS; |
| 4613 |
} |
| 4614 |
|
| 4615 |
GPU_CONTEXT_HANDLE |
| 4616 |
Mos_Specific_CreateGpuComputeContext(MOS_INTERFACE *osInterface, |
| 4617 |
MOS_GPU_CONTEXT contextName, |
| 4618 |
MOS_GPUCTX_CREATOPTIONS *createOption) |
| 4619 |
{ |
| 4620 |
MOS_OS_FUNCTION_ENTER; |
| 4621 |
MOS_OS_CHK_NULL_RETURN(osInterface); |
| 4622 |
|
| 4623 |
if (MOS_GPU_CONTEXT_CM_COMPUTE != contextName |
| 4624 |
&& MOS_GPU_CONTEXT_COMPUTE != contextName) |
| 4625 |
{ |
| 4626 |
MOS_OS_ASSERTMESSAGE("Invalid input parameter contextName."); |
| 4627 |
return MOS_GPU_CONTEXT_INVALID_HANDLE; |
| 4628 |
} |
| 4629 |
|
| 4630 |
if (osInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 4631 |
{ |
| 4632 |
if (nullptr == createOption) |
| 4633 |
{ |
| 4634 |
MOS_OS_ASSERTMESSAGE("Invalid pointer (nullptr)."); |
| 4635 |
return MOS_GPU_CONTEXT_INVALID_HANDLE; |
| 4636 |
} |
| 4637 |
|
| 4638 |
if (osInterface->apoMosEnabled) |
| 4639 |
{ |
| 4640 |
if (nullptr == osInterface->osStreamState) |
| 4641 |
{ |
| 4642 |
MOS_OS_ASSERTMESSAGE("Invalid pointer (nullptr)."); |
| 4643 |
return MOS_GPU_CONTEXT_INVALID_HANDLE; |
| 4644 |
} |
| 4645 |
|
| 4646 |
// Update ctxBasedScheduling from legacy OsInterface |
| 4647 |
osInterface->osStreamState->ctxBasedScheduling |
| 4648 |
= osInterface->ctxBasedScheduling; |
| 4649 |
|
| 4650 |
// Only wrapper will contain re-creation check based on stream Index and MOS_GPU_CONTEXT |
| 4651 |
createOption->gpuNode = MOS_GPU_NODE_COMPUTE; |
| 4652 |
GPU_CONTEXT_HANDLE context_handle = MOS_GPU_CONTEXT_INVALID_HANDLE; |
| 4653 |
MOS_STATUS status |
| 4654 |
= MosInterface::CreateGpuContext(osInterface->osStreamState, |
| 4655 |
*createOption, context_handle); |
| 4656 |
if (MOS_FAILED(status)) |
| 4657 |
{ |
| 4658 |
return MOS_GPU_CONTEXT_INVALID_HANDLE; |
| 4659 |
} |
| 4660 |
|
| 4661 |
auto os_device_context = osInterface->osStreamState->osDeviceContext; |
| 4662 |
auto gpu_context_mgr = os_device_context->GetGpuContextMgr(); |
| 4663 |
if (nullptr == gpu_context_mgr) |
| 4664 |
{ |
| 4665 |
return MOS_GPU_CONTEXT_INVALID_HANDLE; |
| 4666 |
} |
| 4667 |
GpuContextNext *context_next |
| 4668 |
= gpu_context_mgr->GetGpuContext(context_handle); |
| 4669 |
auto context_specific_next |
| 4670 |
= static_cast<GpuContextSpecificNext*>(context_next); |
| 4671 |
if (nullptr == context_specific_next) |
| 4672 |
{ |
| 4673 |
return MOS_GPU_CONTEXT_INVALID_HANDLE; |
| 4674 |
} |
| 4675 |
context_specific_next->SetGpuContext(contextName); |
| 4676 |
return context_handle; |
| 4677 |
} |
| 4678 |
else |
| 4679 |
{ |
| 4680 |
auto os_context_specific |
| 4681 |
= static_cast<OsContextSpecific*>(osInterface->osContextPtr); |
| 4682 |
if (nullptr == os_context_specific) |
| 4683 |
{ |
| 4684 |
return MOS_GPU_CONTEXT_INVALID_HANDLE; |
| 4685 |
} |
| 4686 |
auto gpu_context_mgr = os_context_specific->GetGpuContextMgr(); |
| 4687 |
if (nullptr == gpu_context_mgr) |
| 4688 |
{ |
| 4689 |
return MOS_GPU_CONTEXT_INVALID_HANDLE; |
| 4690 |
} |
| 4691 |
auto cmd_buffer_mgr = os_context_specific->GetCmdBufMgr(); |
| 4692 |
if (nullptr == cmd_buffer_mgr) |
| 4693 |
{ |
| 4694 |
return MOS_GPU_CONTEXT_INVALID_HANDLE; |
| 4695 |
} |
| 4696 |
|
| 4697 |
GpuContext *gpu_context |
| 4698 |
= gpu_context_mgr->CreateGpuContext(MOS_GPU_NODE_COMPUTE, |
| 4699 |
cmd_buffer_mgr, |
| 4700 |
contextName); |
| 4701 |
auto *context_specific = static_cast<GpuContextSpecific*>(gpu_context); |
| 4702 |
if (nullptr == context_specific) |
| 4703 |
{ |
| 4704 |
return MOS_GPU_CONTEXT_INVALID_HANDLE; |
| 4705 |
} |
| 4706 |
MOS_STATUS status |
| 4707 |
= context_specific->Init(gpu_context_mgr->GetOsContext(), |
| 4708 |
osInterface, MOS_GPU_NODE_COMPUTE, |
| 4709 |
createOption); |
| 4710 |
if (MOS_STATUS_SUCCESS != status) |
| 4711 |
{ |
| 4712 |
return MOS_GPU_CONTEXT_INVALID_HANDLE; |
| 4713 |
} |
| 4714 |
return context_specific->GetGpuContextHandle(); |
| 4715 |
} |
| 4716 |
} |
| 4717 |
return MOS_GPU_CONTEXT_INVALID_HANDLE; |
| 4718 |
} |
| 4719 |
|
| 4720 |
//! |
| 4721 |
//! \brief Destroy GPU context |
| 4722 |
//! \details Destroy GPU context |
| 4723 |
//! [in] Pointer to OS interface structure |
| 4724 |
//! \param MOS_GPU_CONTEXT GpuContext |
| 4725 |
//! [in] GPU Context |
| 4726 |
//! \return MOS_STATUS |
| 4727 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 4728 |
//! |
| 4729 |
MOS_STATUS Mos_Specific_DestroyGpuContext( |
| 4730 |
PMOS_INTERFACE pOsInterface, |
| 4731 |
MOS_GPU_CONTEXT mosGpuCxt) |
| 4732 |
{ |
| 4733 |
MOS_OS_FUNCTION_ENTER; |
| 4734 |
|
| 4735 |
MOS_OS_CHK_NULL_RETURN(pOsInterface); |
| 4736 |
|
| 4737 |
if (mosGpuCxt == MOS_GPU_CONTEXT_INVALID_HANDLE) |
| 4738 |
{ |
| 4739 |
MOS_OS_ASSERTMESSAGE("Invalid input parameter GpuContext."); |
| 4740 |
return MOS_STATUS_INVALID_PARAMETER; |
| 4741 |
} |
| 4742 |
|
| 4743 |
if (pOsInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 4744 |
{ |
| 4745 |
MOS_OS_CHK_NULL_RETURN(pOsInterface->osContextPtr); |
| 4746 |
|
| 4747 |
OsContextSpecific *pOsContextSpecific = static_cast<OsContextSpecific *>(pOsInterface->osContextPtr); |
| 4748 |
MOS_OS_CHK_NULL_RETURN(pOsContextSpecific); |
| 4749 |
|
| 4750 |
GPU_CONTEXT_HANDLE gpuContextHandle = pOsContextSpecific->GetGpuContextHandle(mosGpuCxt); |
| 4751 |
|
| 4752 |
if (pOsInterface->apoMosEnabled) |
| 4753 |
{ |
| 4754 |
return MosInterface::DestroyGpuContext(pOsInterface->osStreamState, gpuContextHandle); |
| 4755 |
} |
| 4756 |
|
| 4757 |
GpuContextMgr *gpuContextMgr = pOsContextSpecific->GetGpuContextMgr(); |
| 4758 |
MOS_OS_CHK_NULL_RETURN(gpuContextMgr); |
| 4759 |
GpuContext *gpuContext = gpuContextMgr->GetGpuContext(gpuContextHandle); |
| 4760 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 4761 |
|
| 4762 |
gpuContextMgr->DestroyGpuContext(gpuContext); |
| 4763 |
return MOS_STATUS_SUCCESS; |
| 4764 |
} |
| 4765 |
|
| 4766 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 4767 |
MOS_UNUSED(pOsInterface); |
| 4768 |
MOS_UNUSED(mosGpuCxt); |
| 4769 |
return eStatus; |
| 4770 |
} |
| 4771 |
|
| 4772 |
//! |
| 4773 |
//! \brief Get GPU context Manager |
| 4774 |
//! \param PMOS_INTERFACE pOsInterface |
| 4775 |
//! [in] Pointer to OS Interface |
| 4776 |
//! \return GpuContextMgr |
| 4777 |
//! GPU context Manager got from Os interface |
| 4778 |
//! |
| 4779 |
GpuContextMgr *Mos_Specific_GetGpuContextMgr( |
| 4780 |
PMOS_INTERFACE pOsInterface) |
| 4781 |
{ |
| 4782 |
MOS_OS_FUNCTION_ENTER; |
| 4783 |
|
| 4784 |
if (pOsInterface && pOsInterface->osContextPtr) |
| 4785 |
{ |
| 4786 |
auto pOsContextSpecific = static_cast<OsContextSpecific *>(pOsInterface->osContextPtr); |
| 4787 |
return pOsContextSpecific->GetGpuContextMgr(); |
| 4788 |
} |
| 4789 |
else |
| 4790 |
{ |
| 4791 |
return nullptr; |
| 4792 |
} |
| 4793 |
} |
| 4794 |
|
| 4795 |
//! |
| 4796 |
//! \brief Destroy GPU context by handle |
| 4797 |
//! \details Destroy GPU context by handle for legacy |
| 4798 |
//! \param PMOS_INTERFACE pOsInterface |
| 4799 |
//! [in] Pointer to OS interface structure |
| 4800 |
//! \param GPU_CONTEXT_HANDLE gpuContextHandle |
| 4801 |
//! [in] GPU Context handle |
| 4802 |
//! \return MOS_STATUS |
| 4803 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 4804 |
//! |
| 4805 |
MOS_STATUS Mos_Specific_DestroyGpuContextByHandle( |
| 4806 |
PMOS_INTERFACE pOsInterface, |
| 4807 |
GPU_CONTEXT_HANDLE gpuContextHandle) |
| 4808 |
{ |
| 4809 |
if (Mos_Solo_IsEnabled(nullptr)) return MOS_STATUS_SUCCESS; |
| 4810 |
if (pOsInterface && pOsInterface->apoMosEnabled) |
| 4811 |
{ |
| 4812 |
return MosInterface::DestroyGpuContext(pOsInterface->osStreamState, gpuContextHandle); |
| 4813 |
} |
| 4814 |
|
| 4815 |
auto gpuContextMgr = Mos_Specific_GetGpuContextMgr(pOsInterface); |
| 4816 |
|
| 4817 |
if (gpuContextMgr == nullptr) |
| 4818 |
{ |
| 4819 |
//No need to destory GPU context when adv_gpucontext not enabled in Os context |
| 4820 |
MOS_OS_NORMALMESSAGE("There is no Gpu context manager, adv gpu context not enabled, no need to destory GPU contexts."); |
| 4821 |
return MOS_STATUS_NULL_POINTER; |
| 4822 |
} |
| 4823 |
else |
| 4824 |
{ |
| 4825 |
auto gpuContext = gpuContextMgr->GetGpuContext(gpuContextHandle); |
| 4826 |
if (gpuContext != nullptr) |
| 4827 |
{ |
| 4828 |
gpuContextMgr->DestroyGpuContext(gpuContext); |
| 4829 |
} |
| 4830 |
else |
| 4831 |
{ |
| 4832 |
MOS_OS_ASSERTMESSAGE("Not found gpu Context to destory, something must be wrong"); |
| 4833 |
return MOS_STATUS_NULL_POINTER; |
| 4834 |
} |
| 4835 |
} |
| 4836 |
return MOS_STATUS_SUCCESS; |
| 4837 |
} |
| 4838 |
|
| 4839 |
//! |
| 4840 |
//! \brief Destroy Compute GPU context |
| 4841 |
//! \details Destroy Compute GPU context |
| 4842 |
//! [in] Pointer to OS interface structure |
| 4843 |
//! \param GPU_CONTEXT_HANDLE gpuContextHandle |
| 4844 |
//! [in] GPU Context handle |
| 4845 |
//! \return MOS_STATUS |
| 4846 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 4847 |
//! |
| 4848 |
MOS_STATUS Mos_Specific_DestroyGpuComputeContext( |
| 4849 |
PMOS_INTERFACE osInterface, |
| 4850 |
GPU_CONTEXT_HANDLE gpuContextHandle) |
| 4851 |
{ |
| 4852 |
MOS_OS_FUNCTION_ENTER; |
| 4853 |
|
| 4854 |
MOS_OS_CHK_NULL_RETURN(osInterface); |
| 4855 |
if(MOS_GPU_CONTEXT_INVALID_HANDLE == gpuContextHandle) |
| 4856 |
{ |
| 4857 |
MOS_OS_ASSERTMESSAGE("Invalid compute gpu context handle."); |
| 4858 |
return MOS_STATUS_INVALID_HANDLE; |
| 4859 |
} |
| 4860 |
if (!osInterface->modularizedGpuCtxEnabled || Mos_Solo_IsEnabled(nullptr)) |
| 4861 |
{ |
| 4862 |
return MOS_STATUS_SUCCESS; |
| 4863 |
} |
| 4864 |
|
| 4865 |
OsContextSpecific *pOsContextSpecific = static_cast<OsContextSpecific *>(osInterface->osContextPtr); |
| 4866 |
MOS_OS_CHK_NULL_RETURN(pOsContextSpecific); |
| 4867 |
|
| 4868 |
GPU_CONTEXT_HANDLE iGpuContextHandle = pOsContextSpecific->GetGpuContextHandle(MOS_GPU_CONTEXT_CM_COMPUTE); |
| 4869 |
if(iGpuContextHandle == gpuContextHandle) |
| 4870 |
{ |
| 4871 |
MOS_OS_ASSERTMESSAGE("It will be destroyed in osInterface destroy."); |
| 4872 |
return MOS_STATUS_SUCCESS; |
| 4873 |
} |
| 4874 |
|
| 4875 |
iGpuContextHandle = pOsContextSpecific->GetGpuContextHandle(MOS_GPU_CONTEXT_COMPUTE); |
| 4876 |
if(iGpuContextHandle == gpuContextHandle) |
| 4877 |
{ |
| 4878 |
MOS_OS_ASSERTMESSAGE("It will be destroyed in osInterface destroy."); |
| 4879 |
return MOS_STATUS_SUCCESS; |
| 4880 |
} |
| 4881 |
|
| 4882 |
if (osInterface->apoMosEnabled) |
| 4883 |
{ |
| 4884 |
auto gpuContext = MosInterface::GetGpuContext(osInterface->osStreamState, gpuContextHandle); |
| 4885 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 4886 |
|
| 4887 |
MOS_GPU_CONTEXT gpuContextName = gpuContext->GetGpuContextID(); |
| 4888 |
if(gpuContextName != MOS_GPU_CONTEXT_CM_COMPUTE && gpuContextName != MOS_GPU_CONTEXT_COMPUTE) |
| 4889 |
{ |
| 4890 |
MOS_OS_ASSERTMESSAGE("It is not compute gpu context and it will be destroyed in osInterface destroy."); |
| 4891 |
return MOS_STATUS_SUCCESS; |
| 4892 |
} |
| 4893 |
return MosInterface::DestroyGpuContext(osInterface->osStreamState, gpuContextHandle); |
| 4894 |
} |
| 4895 |
|
| 4896 |
GpuContextMgr *gpuContextMgr = pOsContextSpecific->GetGpuContextMgr(); |
| 4897 |
MOS_OS_CHK_NULL_RETURN(gpuContextMgr); |
| 4898 |
GpuContext *gpuContext = gpuContextMgr->GetGpuContext(gpuContextHandle); |
| 4899 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 4900 |
|
| 4901 |
MOS_GPU_CONTEXT gpuContextName = gpuContext->GetGpuContextID(); |
| 4902 |
if(gpuContextName != MOS_GPU_CONTEXT_CM_COMPUTE && gpuContextName != MOS_GPU_CONTEXT_COMPUTE) |
| 4903 |
{ |
| 4904 |
MOS_OS_ASSERTMESSAGE("It is not compute gpu context and it will be destroyed in osInterface destroy."); |
| 4905 |
return MOS_STATUS_SUCCESS; |
| 4906 |
} |
| 4907 |
|
| 4908 |
gpuContextMgr->DestroyGpuContext(gpuContext); |
| 4909 |
return MOS_STATUS_SUCCESS; |
| 4910 |
} |
| 4911 |
|
| 4912 |
//! |
| 4913 |
//! \brief Sets the perf tag |
| 4914 |
//! \details Sets the perf tag |
| 4915 |
//! \param PMOS_INTERFACE pOsInterface |
| 4916 |
//! [in] Pointer to OS interface structure |
| 4917 |
//! \param uint32_t PerfTag |
| 4918 |
//! [in] Perf tag |
| 4919 |
//! \return void |
| 4920 |
//! |
| 4921 |
void Mos_Specific_SetPerfTag( |
| 4922 |
PMOS_INTERFACE pOsInterface, |
| 4923 |
uint32_t PerfTag) |
| 4924 |
{ |
| 4925 |
uint32_t ComponentTag; |
| 4926 |
|
| 4927 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(pOsInterface); |
| 4928 |
|
| 4929 |
if (pOsInterface->apoMosEnabled) |
| 4930 |
{ |
| 4931 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(pOsInterface->osStreamState); |
| 4932 |
pOsInterface->osStreamState->component = pOsInterface->Component; |
| 4933 |
return MosInterface::SetPerfTag(pOsInterface->osStreamState, PerfTag); |
| 4934 |
} |
| 4935 |
|
| 4936 |
PMOS_CONTEXT pOsContext =(PMOS_CONTEXT)pOsInterface->pOsContext; |
| 4937 |
|
| 4938 |
if(pOsContext) |
| 4939 |
{ |
| 4940 |
switch (pOsInterface->Component) |
| 4941 |
{ |
| 4942 |
case COMPONENT_VPreP: |
| 4943 |
case COMPONENT_VPCommon: |
| 4944 |
ComponentTag = PERFTAG_VPREP; |
| 4945 |
break; |
| 4946 |
|
| 4947 |
case COMPONENT_LibVA: |
| 4948 |
ComponentTag = PERFTAG_LIBVA; |
| 4949 |
break; |
| 4950 |
|
| 4951 |
case COMPONENT_CM: |
| 4952 |
ComponentTag = PERFTAG_CM; |
| 4953 |
break; |
| 4954 |
|
| 4955 |
case COMPONENT_Decode: |
| 4956 |
ComponentTag = PERFTAG_DECODE; |
| 4957 |
break; |
| 4958 |
|
| 4959 |
case COMPONENT_Encode: |
| 4960 |
ComponentTag = PERFTAG_ENCODE; |
| 4961 |
break; |
| 4962 |
|
| 4963 |
default: |
| 4964 |
ComponentTag = 0xF000 & pOsContext->GetDmaBufID(pOsContext); |
| 4965 |
break; |
| 4966 |
} |
| 4967 |
|
| 4968 |
pOsContext->SetDmaBufID(pOsContext, ComponentTag | (PerfTag&0x0fff)); |
| 4969 |
} |
| 4970 |
|
| 4971 |
} |
| 4972 |
|
| 4973 |
//! |
| 4974 |
//! \brief Resets the perf tag |
| 4975 |
//! \details Resets the perf tag |
| 4976 |
//! \param PMOS_INTERFACE pOsInterface |
| 4977 |
//! [in] Pointer to OS interface structure |
| 4978 |
//! \return void |
| 4979 |
//! |
| 4980 |
void Mos_Specific_ResetPerfBufferID( |
| 4981 |
PMOS_INTERFACE pOsInterface) |
| 4982 |
{ |
| 4983 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(pOsInterface); |
| 4984 |
|
| 4985 |
if (pOsInterface->apoMosEnabled) |
| 4986 |
{ |
| 4987 |
return MosInterface::ResetPerfBufferID(pOsInterface->osStreamState); |
| 4988 |
} |
| 4989 |
|
| 4990 |
PMOS_CONTEXT pOsContext = (PMOS_CONTEXT)pOsInterface->pOsContext; |
| 4991 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(pOsContext); |
| 4992 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(pOsContext->pPerfData); |
| 4993 |
pOsContext->pPerfData->bufferID = 0; |
| 4994 |
return; |
| 4995 |
} |
| 4996 |
|
| 4997 |
//! |
| 4998 |
//! \brief Increment the perf tag for buffer ID |
| 4999 |
//! \details Increment the perf tag for buffer ID |
| 5000 |
//! \param PMOS_INTERFACE pOsInterface |
| 5001 |
//! [in] Pointer to OS interface structure |
| 5002 |
//! \return void |
| 5003 |
//! |
| 5004 |
void Mos_Specific_IncPerfBufferID( |
| 5005 |
PMOS_INTERFACE pOsInterface) |
| 5006 |
{ |
| 5007 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(pOsInterface); |
| 5008 |
|
| 5009 |
if (pOsInterface->apoMosEnabled) |
| 5010 |
{ |
| 5011 |
return MosInterface::IncPerfBufferID(pOsInterface->osStreamState); |
| 5012 |
} |
| 5013 |
|
| 5014 |
PMOS_CONTEXT pOsContext = (PMOS_CONTEXT)pOsInterface->pOsContext; |
| 5015 |
|
| 5016 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(pOsContext); |
| 5017 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(pOsContext->pPerfData); |
| 5018 |
|
| 5019 |
pOsContext->pPerfData->bufferID++; |
| 5020 |
return; |
| 5021 |
} |
| 5022 |
|
| 5023 |
//! |
| 5024 |
//! \brief Increment the perf tag for Frame ID |
| 5025 |
//! \details Increment the perf tag for frame ID |
| 5026 |
//! \param PMOS_INTERFACE pOsInterface |
| 5027 |
//! [in] Pointer to OS interface structure |
| 5028 |
//! \return void |
| 5029 |
//! |
| 5030 |
void Mos_Specific_IncPerfFrameID( |
| 5031 |
PMOS_INTERFACE pOsInterface) |
| 5032 |
{ |
| 5033 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(pOsInterface); |
| 5034 |
|
| 5035 |
if (pOsInterface->apoMosEnabled) |
| 5036 |
{ |
| 5037 |
return MosInterface::IncPerfFrameID(pOsInterface->osStreamState); |
| 5038 |
} |
| 5039 |
|
| 5040 |
PMOS_CONTEXT pOsContext = (PMOS_CONTEXT)pOsInterface->pOsContext; |
| 5041 |
|
| 5042 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(pOsContext); |
| 5043 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(pOsContext->pPerfData); |
| 5044 |
|
| 5045 |
pOsContext->pPerfData->frameID++; |
| 5046 |
|
| 5047 |
} |
| 5048 |
|
| 5049 |
//! |
| 5050 |
//! \brief Gets the perf tag |
| 5051 |
//! \details Gets the perf tag |
| 5052 |
//! \param PMOS_INTERFACE pOsInterface |
| 5053 |
//! [in] Pointer to OS interface structure |
| 5054 |
//! \return uint32_t |
| 5055 |
//! Return perf tag |
| 5056 |
//! |
| 5057 |
uint32_t Mos_Specific_GetPerfTag( |
| 5058 |
PMOS_INTERFACE pOsInterface) |
| 5059 |
{ |
| 5060 |
uint32_t perfTag; |
| 5061 |
|
| 5062 |
if (pOsInterface == nullptr) |
| 5063 |
{ |
| 5064 |
MOS_OS_ASSERTMESSAGE("pOsInterface invalid nullptr"); |
| 5065 |
return 0; |
| 5066 |
} |
| 5067 |
|
| 5068 |
if (pOsInterface->apoMosEnabled) |
| 5069 |
{ |
| 5070 |
return MosInterface::GetPerfTag(pOsInterface->osStreamState); |
| 5071 |
} |
| 5072 |
|
| 5073 |
PMOS_CONTEXT osContext = (PMOS_CONTEXT)pOsInterface->pOsContext; |
| 5074 |
|
| 5075 |
if (osContext == nullptr) |
| 5076 |
{ |
| 5077 |
return 0; |
| 5078 |
} |
| 5079 |
|
| 5080 |
perfTag = *(uint32_t *)(osContext->pPerfData); |
| 5081 |
return perfTag; |
| 5082 |
} |
| 5083 |
|
| 5084 |
//! |
| 5085 |
//! \brief Set Hybrid Kernel ID |
| 5086 |
//! \details Set Hybrid Kernel ID |
| 5087 |
//! \param PMOS_INTERFACE pOsInterface |
| 5088 |
//! [in] OS Interface |
| 5089 |
//! \param uint32_t KernelID |
| 5090 |
//! [in] Hybrid Decoder Kernel ID |
| 5091 |
//! \return void |
| 5092 |
//! |
| 5093 |
void Mos_Specific_SetPerfHybridKernelID( |
| 5094 |
PMOS_INTERFACE pOsInterface, |
| 5095 |
uint32_t KernelID) |
| 5096 |
{ |
| 5097 |
PMOS_CONTEXT pOsContext; |
| 5098 |
|
| 5099 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(pOsInterface); |
| 5100 |
|
| 5101 |
if (pOsInterface->apoMosEnabled) |
| 5102 |
{ |
| 5103 |
return MosInterface::SetPerfHybridKernelID(pOsInterface->osStreamState, KernelID); |
| 5104 |
} |
| 5105 |
|
| 5106 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(pOsInterface->pOsContext); |
| 5107 |
|
| 5108 |
pOsContext = (PMOS_CONTEXT)pOsInterface->pOsContext; |
| 5109 |
pOsContext->SetPerfHybridKernelID(pOsContext,KernelID); |
| 5110 |
} |
| 5111 |
|
| 5112 |
//! |
| 5113 |
//! \brief Check if Perf Tag is already set |
| 5114 |
//! \details Check if Perf Tag is already set |
| 5115 |
//! \param PMOS_INTERFACE pOsInterface |
| 5116 |
//! [in] OS Interface |
| 5117 |
//! \return int32_t |
| 5118 |
//! |
| 5119 |
int32_t Mos_Specific_IsPerfTagSet( |
| 5120 |
PMOS_INTERFACE pOsInterface) |
| 5121 |
{ |
| 5122 |
uint32_t ComponentTag; |
| 5123 |
int32_t bRet = false; |
| 5124 |
PMOS_CONTEXT pOsContext; |
| 5125 |
|
| 5126 |
if(pOsInterface == nullptr) |
| 5127 |
{ |
| 5128 |
MOS_OS_ASSERTMESSAGE("pOsInterface invalid nullptr"); |
| 5129 |
return bRet; |
| 5130 |
} |
| 5131 |
|
| 5132 |
if (pOsInterface->apoMosEnabled) |
| 5133 |
{ |
| 5134 |
return MosInterface::IsPerfTagSet(pOsInterface->osStreamState); |
| 5135 |
} |
| 5136 |
|
| 5137 |
MOS_OS_ASSERT(pOsInterface->pOsContext); |
| 5138 |
|
| 5139 |
pOsContext = (pOsInterface) ? (PMOS_CONTEXT)pOsInterface->pOsContext : nullptr; |
| 5140 |
bRet = false; |
| 5141 |
|
| 5142 |
if (pOsContext) |
| 5143 |
{ |
| 5144 |
ComponentTag = 0xF000 & pOsContext->GetDmaBufID(pOsContext); |
| 5145 |
|
| 5146 |
switch (ComponentTag) |
| 5147 |
{ |
| 5148 |
case PERFTAG_ENCODE: |
| 5149 |
case PERFTAG_DECODE: |
| 5150 |
bRet = true; |
| 5151 |
break; |
| 5152 |
|
| 5153 |
default: |
| 5154 |
bRet = false; |
| 5155 |
break; |
| 5156 |
} |
| 5157 |
} |
| 5158 |
|
| 5159 |
return bRet; |
| 5160 |
} |
| 5161 |
|
| 5162 |
//! |
| 5163 |
//! \brief Check for GPU context valid |
| 5164 |
//! \details Always returns MOS_STATUS_SUCCESS on Linux. |
| 5165 |
// This interface is implemented for compatibility. |
| 5166 |
//! \param PMOS_INTERFACE pOsInterface |
| 5167 |
//! [in] pointer to Os interface structure |
| 5168 |
//! \param MOS_GPU_CONTEXT GpuContext |
| 5169 |
//! [in] Gpu Context |
| 5170 |
//! \return MOS_STATUS |
| 5171 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 5172 |
//! |
| 5173 |
MOS_STATUS Mos_Specific_IsGpuContextValid( |
| 5174 |
PMOS_INTERFACE pOsInterface, |
| 5175 |
MOS_GPU_CONTEXT GpuContext) |
| 5176 |
{ |
| 5177 |
MOS_UNUSED(pOsInterface); |
| 5178 |
MOS_UNUSED(GpuContext); |
| 5179 |
return MOS_STATUS_SUCCESS; |
| 5180 |
} |
| 5181 |
|
| 5182 |
//! |
| 5183 |
//! \brief Unified OS Resources sync |
| 5184 |
//! \details Tag based synchronization at the resource level |
| 5185 |
//! \param PMOS_INTERFACE pOsInterface |
| 5186 |
//! [in] Pointer to OS Interface |
| 5187 |
//! \param PMOS_RESOURCE pOsResource |
| 5188 |
//! [in] Pointer to OS Resource |
| 5189 |
//! \param MOS_GPU_CONTEXT requestorGPUCtx |
| 5190 |
//! [in] GPU Context |
| 5191 |
//! \param int32_t bWriteOperation |
| 5192 |
//! [in] true if write operation |
| 5193 |
//! \return void |
| 5194 |
//! |
| 5195 |
void Mos_Specific_SyncOnResource( |
| 5196 |
PMOS_INTERFACE pOsInterface, |
| 5197 |
PMOS_RESOURCE pOsResource, |
| 5198 |
MOS_GPU_CONTEXT requestorGPUCtx, |
| 5199 |
int32_t bWriteOperation) |
| 5200 |
{ |
| 5201 |
MOS_UNUSED(pOsInterface); |
| 5202 |
MOS_UNUSED(pOsResource); |
| 5203 |
MOS_UNUSED(requestorGPUCtx); |
| 5204 |
MOS_UNUSED(bWriteOperation); |
| 5205 |
} |
| 5206 |
|
| 5207 |
//! |
| 5208 |
//! \brief Synchronize GPU context |
| 5209 |
//! \details Synchronize GPU context |
| 5210 |
//! \param PMOS_INTERFACE pOsInterface |
| 5211 |
//! [in] OS Interface |
| 5212 |
//! \param MOS_GPU_CONTEXT busyGPUCtx |
| 5213 |
//! [in] Busy context id being requested to sync with |
| 5214 |
//! \param MOS_GPU_CONTEXT requestorGPUCtx |
| 5215 |
//! [in] Requestor context id |
| 5216 |
//! \return void |
| 5217 |
//! |
| 5218 |
void Mos_Specific_SyncGpuContext( |
| 5219 |
PMOS_INTERFACE pOsInterface, |
| 5220 |
MOS_GPU_CONTEXT busyGPUCtx, |
| 5221 |
MOS_GPU_CONTEXT requestorGPUCtx) |
| 5222 |
{ |
| 5223 |
MOS_UNUSED(pOsInterface); |
| 5224 |
MOS_UNUSED(busyGPUCtx); |
| 5225 |
MOS_UNUSED(requestorGPUCtx); |
| 5226 |
} |
| 5227 |
|
| 5228 |
//! |
| 5229 |
//! \brief Checks for HW enabled |
| 5230 |
//! \details Checks for HW enabled |
| 5231 |
//! \param PMOS_INTERFACE pOsInterface |
| 5232 |
//! [in] pointer to Os interface structure |
| 5233 |
//! \return int32_t |
| 5234 |
//! Returns true id HW enabled if CP mode |
| 5235 |
//! |
| 5236 |
int32_t Mos_Specific_IsNullHWEnabled( |
| 5237 |
PMOS_INTERFACE pOsInterface) |
| 5238 |
{ |
| 5239 |
MOS_UNUSED(pOsInterface); |
| 5240 |
return false; |
| 5241 |
} |
| 5242 |
|
| 5243 |
//! |
| 5244 |
//! \brief Get GPU status buffer |
| 5245 |
//! \details Gets the status buffer for the resource |
| 5246 |
//! \param PMOS_INTERFACE pOsInterface |
| 5247 |
//! [in] Pointer to OS Interface |
| 5248 |
//! \param PMOS_RESOURCE pOsResource |
| 5249 |
//! [out] Pointer to OS Resource |
| 5250 |
//! \return MOS_STATUS |
| 5251 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 5252 |
//! |
| 5253 |
MOS_STATUS Mos_Specific_GetGpuStatusBufferResource( |
| 5254 |
PMOS_INTERFACE pOsInterface, |
| 5255 |
PMOS_RESOURCE &pOsResource) |
| 5256 |
{ |
| 5257 |
MOS_OS_FUNCTION_ENTER; |
| 5258 |
|
| 5259 |
MOS_OS_CHK_NULL_RETURN(pOsInterface); |
| 5260 |
|
| 5261 |
if (pOsInterface->apoMosEnabled) |
| 5262 |
{ |
| 5263 |
return MosInterface::GetGpuStatusBufferResource(pOsInterface->osStreamState, pOsResource, pOsInterface->osStreamState->currentGpuContextHandle); |
| 5264 |
} |
| 5265 |
|
| 5266 |
if (pOsInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 5267 |
{ |
| 5268 |
auto gpuContext = Linux_GetGpuContext(pOsInterface, pOsInterface->CurrentGpuContextHandle); |
| 5269 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 5270 |
|
| 5271 |
auto resource = gpuContext->GetStatusBufferResource(); |
| 5272 |
MOS_OS_CHK_NULL_RETURN(resource); |
| 5273 |
|
| 5274 |
pOsResource = gpuContext->GetStatusBufferMosResource(); |
| 5275 |
MOS_OS_CHK_NULL_RETURN(pOsResource); |
| 5276 |
MOS_ZeroMemory(pOsResource, sizeof(MOS_RESOURCE)); |
| 5277 |
|
| 5278 |
MOS_OS_CHK_STATUS_RETURN(resource->ConvertToMosResource(pOsResource)); |
| 5279 |
|
| 5280 |
return MOS_STATUS_SUCCESS; |
| 5281 |
} |
| 5282 |
|
| 5283 |
PMOS_CONTEXT pOsContext; |
| 5284 |
|
| 5285 |
MOS_OS_ASSERT(pOsInterface); |
| 5286 |
MOS_OS_ASSERT(pOsInterface->pOsContext); |
| 5287 |
|
| 5288 |
pOsContext = pOsInterface->pOsContext; |
| 5289 |
|
| 5290 |
pOsResource = pOsContext->pGPUStatusBuffer; |
| 5291 |
return MOS_STATUS_SUCCESS; |
| 5292 |
} |
| 5293 |
|
| 5294 |
//! |
| 5295 |
//! \brief Get GPU status tag offset |
| 5296 |
//! \details Gets the status tag offset |
| 5297 |
//! \param PMOS_INTERFACE pOsInterface |
| 5298 |
//! [in] Pointer to OS Interface |
| 5299 |
//! \param MOS_GPU_CONTEXT GpuContext |
| 5300 |
//! [in] GPU Context |
| 5301 |
//! \return uint32_t |
| 5302 |
//! Returns the tag offset |
| 5303 |
//! |
| 5304 |
uint32_t Mos_Specific_GetGpuStatusTagOffset( |
| 5305 |
PMOS_INTERFACE pOsInterface, |
| 5306 |
MOS_GPU_CONTEXT GpuContext) |
| 5307 |
{ |
| 5308 |
MOS_OS_FUNCTION_ENTER; |
| 5309 |
|
| 5310 |
MOS_OS_CHK_NULL_RETURN(pOsInterface); |
| 5311 |
|
| 5312 |
uint32_t offset = 0; |
| 5313 |
|
| 5314 |
if (pOsInterface->apoMosEnabled) |
| 5315 |
{ |
| 5316 |
// always 0 in apo |
| 5317 |
return 0; |
| 5318 |
} |
| 5319 |
// A gobal status buffer for all GPU contexts is no longer used when modulized GPU context enabled, |
| 5320 |
// replace with separate buffer corresponding to each GPU context and the offset will be 0 |
| 5321 |
if (!pOsInterface->modularizedGpuCtxEnabled || Mos_Solo_IsEnabled(nullptr)) |
| 5322 |
{ |
| 5323 |
offset = sizeof(MOS_GPU_STATUS_DATA) * GpuContext; |
| 5324 |
} |
| 5325 |
|
| 5326 |
return offset; |
| 5327 |
} |
| 5328 |
|
| 5329 |
//! |
| 5330 |
//! \brief Get GPU status tag |
| 5331 |
//! \details Gets the status tag |
| 5332 |
//! \param PMOS_INTERFACE pOsInterface |
| 5333 |
//! [in] Pointer to OS Interface |
| 5334 |
//! \param MOS_GPU_CONTEXT GpuContext |
| 5335 |
//! [in] GPU Context |
| 5336 |
//! \return uint32_t |
| 5337 |
//! Returns the tag |
| 5338 |
//! |
| 5339 |
uint32_t Mos_Specific_GetGpuStatusTag( |
| 5340 |
PMOS_INTERFACE pOsInterface, |
| 5341 |
MOS_GPU_CONTEXT mosGpuCtx) |
| 5342 |
{ |
| 5343 |
MOS_OS_FUNCTION_ENTER; |
| 5344 |
|
| 5345 |
MOS_OS_ASSERT(pOsInterface); |
| 5346 |
|
| 5347 |
if (mosGpuCtx == MOS_GPU_CONTEXT_INVALID_HANDLE) |
| 5348 |
{ |
| 5349 |
MOS_OS_ASSERTMESSAGE("Invalid input parameter GpuContext."); |
| 5350 |
return -1; |
| 5351 |
} |
| 5352 |
|
| 5353 |
if (pOsInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 5354 |
{ |
| 5355 |
if (pOsInterface->osContextPtr == nullptr) |
| 5356 |
{ |
| 5357 |
MOS_OS_ASSERTMESSAGE("invalid input parameters!"); |
| 5358 |
return 0; |
| 5359 |
} |
| 5360 |
|
| 5361 |
auto osCxtSpecific = static_cast<OsContextSpecific*>(pOsInterface->osContextPtr); |
| 5362 |
|
| 5363 |
auto handle = osCxtSpecific->GetGpuContextHandle(mosGpuCtx); |
| 5364 |
|
| 5365 |
if (pOsInterface->apoMosEnabled) |
| 5366 |
{ |
| 5367 |
return MosInterface::GetGpuStatusTag(pOsInterface->osStreamState, handle); |
| 5368 |
} |
| 5369 |
|
| 5370 |
auto gpuContext = Linux_GetGpuContext(pOsInterface, handle); |
| 5371 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 5372 |
|
| 5373 |
return gpuContext->GetGpuStatusTag(); |
| 5374 |
} |
| 5375 |
|
| 5376 |
PMOS_CONTEXT pOsContext; |
| 5377 |
|
| 5378 |
MOS_OS_ASSERT(pOsInterface->pOsContext); |
| 5379 |
//------------------------------------ |
| 5380 |
|
| 5381 |
pOsContext = pOsInterface->pOsContext; |
| 5382 |
|
| 5383 |
return pOsContext->pfnGetGpuCtxBufferTag(pOsContext, mosGpuCtx); |
| 5384 |
} |
| 5385 |
|
| 5386 |
//! |
| 5387 |
//! \brief Increment GPU status tag |
| 5388 |
//! \details Increment the status tag |
| 5389 |
//! \param PMOS_INTERFACE pOsInterface |
| 5390 |
//! [in] Pointer to OS Interface |
| 5391 |
//! \param MOS_GPU_CONTEXT GpuContext |
| 5392 |
//! [in] GPU Context |
| 5393 |
//! \return void |
| 5394 |
//! |
| 5395 |
void Mos_Specific_IncrementGpuStatusTag( |
| 5396 |
PMOS_INTERFACE pOsInterface, |
| 5397 |
MOS_GPU_CONTEXT mosGpuCtx) |
| 5398 |
{ |
| 5399 |
MOS_OS_FUNCTION_ENTER; |
| 5400 |
|
| 5401 |
MOS_OS_ASSERT(pOsInterface); |
| 5402 |
|
| 5403 |
if (mosGpuCtx == MOS_GPU_CONTEXT_INVALID_HANDLE) |
| 5404 |
{ |
| 5405 |
MOS_OS_ASSERTMESSAGE("Invalid input parameter GpuContext."); |
| 5406 |
return; |
| 5407 |
} |
| 5408 |
|
| 5409 |
if (pOsInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 5410 |
{ |
| 5411 |
if (pOsInterface->osContextPtr == nullptr) |
| 5412 |
{ |
| 5413 |
MOS_OS_ASSERTMESSAGE("invalid input parameters!"); |
| 5414 |
return; |
| 5415 |
} |
| 5416 |
|
| 5417 |
auto osCxtSpecific = static_cast<OsContextSpecific*>(pOsInterface->osContextPtr); |
| 5418 |
|
| 5419 |
auto handle = osCxtSpecific->GetGpuContextHandle(mosGpuCtx); |
| 5420 |
|
| 5421 |
if (pOsInterface->apoMosEnabled) |
| 5422 |
{ |
| 5423 |
MosInterface::IncrementGpuStatusTag(pOsInterface->osStreamState, handle); |
| 5424 |
return; |
| 5425 |
} |
| 5426 |
|
| 5427 |
auto gpuContext = Linux_GetGpuContext(pOsInterface, handle); |
| 5428 |
|
| 5429 |
if (gpuContext) |
| 5430 |
{ |
| 5431 |
gpuContext->IncrementGpuStatusTag(); |
| 5432 |
} |
| 5433 |
else |
| 5434 |
{ |
| 5435 |
MOS_OS_ASSERTMESSAGE("Cannot get valid Gpu context!"); |
| 5436 |
} |
| 5437 |
} |
| 5438 |
|
| 5439 |
PMOS_CONTEXT pOsContext; |
| 5440 |
|
| 5441 |
//------------------------------------ |
| 5442 |
MOS_OS_ASSERT(pOsInterface); |
| 5443 |
MOS_OS_ASSERT(pOsInterface->pOsContext); |
| 5444 |
//------------------------------------ |
| 5445 |
|
| 5446 |
pOsContext = pOsInterface->pOsContext; |
| 5447 |
|
| 5448 |
pOsContext->pfnIncGpuCtxBufferTag(pOsContext, mosGpuCtx); |
| 5449 |
} |
| 5450 |
|
| 5451 |
//! |
| 5452 |
//! \brief Get GPU status Sync tag |
| 5453 |
//! \details This function will return the GPU status tag which is updated when corresponding |
| 5454 |
//! GPU packet is done. User can use this flag to check if some GPU packet is done. |
| 5455 |
//! \param PMOS_INTERFACE pOsInterface |
| 5456 |
//! [in] Pointer to OS Interface |
| 5457 |
//! \param MOS_GPU_CONTEXT GpuContext |
| 5458 |
//! [in] GPU Context |
| 5459 |
//! \return uint32_t |
| 5460 |
//! Returns the tag |
| 5461 |
//! |
| 5462 |
uint32_t Mos_Specific_GetGpuStatusSyncTag( |
| 5463 |
PMOS_INTERFACE pOsInterface, |
| 5464 |
MOS_GPU_CONTEXT gpuContext) |
| 5465 |
{ |
| 5466 |
MOS_OS_FUNCTION_ENTER; |
| 5467 |
PMOS_CONTEXT pOsContext = nullptr; |
| 5468 |
|
| 5469 |
if(!pOsInterface || !pOsInterface->pOsContext) |
| 5470 |
{ |
| 5471 |
MOS_OS_ASSERTMESSAGE("Invalid nullptr"); |
| 5472 |
return 0; |
| 5473 |
} |
| 5474 |
pOsContext = pOsInterface->pOsContext; |
| 5475 |
|
| 5476 |
return pOsContext->GetGPUTag(pOsInterface, gpuContext); |
| 5477 |
} |
| 5478 |
|
| 5479 |
//! |
| 5480 |
//! \brief Sets the resource sync tag |
| 5481 |
//! \details Dummy implementation on Linux for compatibility. |
| 5482 |
//! \param PMOS_INTERFACE pOsInterface |
| 5483 |
//! [in] Pointer to OS Interface |
| 5484 |
//! \param PMOS_SYNC_PARAMS pParams |
| 5485 |
//! [in] Pointer to sync params |
| 5486 |
//! \return void |
| 5487 |
//! |
| 5488 |
void Mos_Specific_SetResourceSyncTag( |
| 5489 |
PMOS_INTERFACE pOsInterface, |
| 5490 |
PMOS_SYNC_PARAMS pParams) |
| 5491 |
{ |
| 5492 |
MOS_UNUSED(pOsInterface); |
| 5493 |
MOS_UNUSED(pParams); |
| 5494 |
return ; |
| 5495 |
} |
| 5496 |
|
| 5497 |
//! |
| 5498 |
//! \brief Perform overlay sync |
| 5499 |
//! \details Dummy implementation on Linux for compatibility. |
| 5500 |
//! \param PMOS_INTERFACE pOsInterface |
| 5501 |
//! [in] Pointer to OS Interface |
| 5502 |
//! \param PMOS_SYNC_PARAMS pParams |
| 5503 |
//! [in] Pointer to sync params |
| 5504 |
//! \return MOS_STATUS |
| 5505 |
//! Return MOS_STATUS_SUCCESS |
| 5506 |
//! |
| 5507 |
MOS_STATUS Mos_Specific_PerformOverlaySync( |
| 5508 |
PMOS_INTERFACE pOsInterface, |
| 5509 |
PMOS_SYNC_PARAMS pParams) |
| 5510 |
{ |
| 5511 |
MOS_UNUSED(pOsInterface); |
| 5512 |
MOS_UNUSED(pParams); |
| 5513 |
return MOS_STATUS_SUCCESS; |
| 5514 |
} |
| 5515 |
|
| 5516 |
//! |
| 5517 |
//! \brief Signal OS Engine |
| 5518 |
//! \details Dummy implementation on Linux for compatibility. |
| 5519 |
//! \param PMOS_INTERFACE pOsInterface |
| 5520 |
//! [in] Pointer to OS Interface |
| 5521 |
//! \param PMOS_SYNC_PARAMS pParams |
| 5522 |
//! [in] Pointer to sync params |
| 5523 |
//! \return MOS_STATUS |
| 5524 |
//! Return MOS_STATUS_SUCCESS |
| 5525 |
//! |
| 5526 |
MOS_STATUS Mos_Specific_EngineSignal( |
| 5527 |
PMOS_INTERFACE pOsInterface, |
| 5528 |
PMOS_SYNC_PARAMS pParams) |
| 5529 |
{ |
| 5530 |
MOS_UNUSED(pOsInterface); |
| 5531 |
MOS_UNUSED(pParams); |
| 5532 |
return MOS_STATUS_SUCCESS; |
| 5533 |
} |
| 5534 |
|
| 5535 |
//! |
| 5536 |
//! \brief Wait on sync |
| 5537 |
//! \details Dummy implementation on Linux for compatibility. |
| 5538 |
//! \param PMOS_INTERFACE pOsInterface |
| 5539 |
//! [in] Pointer to OS Interface |
| 5540 |
//! \param PMOS_SYNC_PARAMS pParams |
| 5541 |
//! [in] Pointer to sync params |
| 5542 |
//! \return MOS_STATUS |
| 5543 |
//! Return MOS_STATUS_SUCCESS |
| 5544 |
//! |
| 5545 |
MOS_STATUS Mos_Specific_EngineWait( |
| 5546 |
PMOS_INTERFACE pOsInterface, |
| 5547 |
PMOS_SYNC_PARAMS pParams) |
| 5548 |
{ |
| 5549 |
MOS_UNUSED(pOsInterface); |
| 5550 |
MOS_UNUSED(pParams); |
| 5551 |
return MOS_STATUS_SUCCESS; |
| 5552 |
} |
| 5553 |
|
| 5554 |
//! |
| 5555 |
//! \brief Signal on resource |
| 5556 |
//! \details Dummy implementation on Linux for compatibility. |
| 5557 |
//! \param PMOS_INTERFACE pOsInterface |
| 5558 |
//! [in] Pointer to OS Interface |
| 5559 |
//! \param PMOS_SYNC_PARAMS pParams |
| 5560 |
//! [in] Pointer to sync params |
| 5561 |
//! \return MOS_STATUS |
| 5562 |
//! Return MOS_STATUS_SUCCESS |
| 5563 |
//! |
| 5564 |
MOS_STATUS Mos_Specific_ResourceSignal( |
| 5565 |
PMOS_INTERFACE pOsInterface, |
| 5566 |
PMOS_SYNC_PARAMS pParams) |
| 5567 |
{ |
| 5568 |
MOS_UNUSED(pOsInterface); |
| 5569 |
MOS_UNUSED(pParams); |
| 5570 |
return MOS_STATUS_SUCCESS; |
| 5571 |
} |
| 5572 |
|
| 5573 |
//! |
| 5574 |
//! \brief Wait on resource |
| 5575 |
//! \details Dummy implementation on Linux for compatibility. |
| 5576 |
//! \param PMOS_INTERFACE pOsInterface |
| 5577 |
//! [in] Pointer to OS Interface |
| 5578 |
//! \param PMOS_SYNC_PARAMS pParams |
| 5579 |
//! [in] Pointer to sync params |
| 5580 |
//! \return MOS_STATUS |
| 5581 |
//! Return MOS_STATUS_SUCCESS |
| 5582 |
//! |
| 5583 |
MOS_STATUS Mos_Specific_ResourceWait( |
| 5584 |
PMOS_INTERFACE pOsInterface, |
| 5585 |
PMOS_SYNC_PARAMS pParams) |
| 5586 |
{ |
| 5587 |
MOS_UNUSED(pOsInterface); |
| 5588 |
MOS_UNUSED(pParams); |
| 5589 |
return MOS_STATUS_SUCCESS; |
| 5590 |
} |
| 5591 |
|
| 5592 |
//! |
| 5593 |
//! \brief Create Sync Resource |
| 5594 |
//! \details Dummy implementation on Linux for compatibility. |
| 5595 |
//! \param PMOS_INTERFACE pOsInterface |
| 5596 |
//! [in] Pointer to OS Interface |
| 5597 |
//! \param PMOS_RESOURCE pOsResource |
| 5598 |
//! [in] Pointer to OS resource |
| 5599 |
//! \return MOS_STATUS |
| 5600 |
//! Return MOS_STATUS_SUCCESS |
| 5601 |
//! |
| 5602 |
MOS_STATUS Mos_Specific_CreateSyncResource( |
| 5603 |
PMOS_INTERFACE pOsInterface, |
| 5604 |
PMOS_RESOURCE pOsResource) |
| 5605 |
{ |
| 5606 |
MOS_UNUSED(pOsInterface); |
| 5607 |
MOS_UNUSED(pOsResource); |
| 5608 |
return MOS_STATUS_SUCCESS; |
| 5609 |
} |
| 5610 |
|
| 5611 |
//! |
| 5612 |
//! \brief Destroy Sync resource |
| 5613 |
//! \details Dummy implementation on Linux for compatibility. |
| 5614 |
//! \param PMOS_INTERFACE pOsInterface |
| 5615 |
//! [in] Pointer to OS Interface |
| 5616 |
//! \param PMOS_RESOURCE pOsResource |
| 5617 |
//! [in] Pointer to OS resource |
| 5618 |
//! \return MOS_STATUS |
| 5619 |
//! Return MOS_STATUS_SUCCESS |
| 5620 |
//! |
| 5621 |
MOS_STATUS Mos_Specific_DestroySyncResource( |
| 5622 |
PMOS_INTERFACE pOsInterface, |
| 5623 |
PMOS_RESOURCE pOsResource) |
| 5624 |
{ |
| 5625 |
MOS_UNUSED(pOsInterface); |
| 5626 |
MOS_UNUSED(pOsResource); |
| 5627 |
return MOS_STATUS_SUCCESS; |
| 5628 |
} |
| 5629 |
|
| 5630 |
//! |
| 5631 |
//! \brief Initializes the tags for Hybrid Decode multi-threading sync |
| 5632 |
//! \details Initializes the tags for Hybrid Decode multi-threading sync |
| 5633 |
//! \param PMOS_INTERFACE pOsInterface |
| 5634 |
//! [in] OS Interface |
| 5635 |
//! \param PMOS_RESOURCE pOsResource |
| 5636 |
//! [in] Pointer to OS resource |
| 5637 |
//! \param uint8_t ucRenderTargetIndex |
| 5638 |
//! [in] Index of render target in pSemHandleList for pOsResource |
| 5639 |
//! \param PMOS_SEMAPHORE *pCurFrmSem |
| 5640 |
//! [in] List of semaphore handles used for current frame sync |
| 5641 |
//! \param PMOS_SEMAPHORE *pRefFrmSem |
| 5642 |
//! [in] List of semaphore handles used for reference frame sync |
| 5643 |
//! \param PMOS_MUTEX *pFrmMutex |
| 5644 |
//! [in] List of mutex handles of frame lock mutex |
| 5645 |
//! \return MOS_STATUS |
| 5646 |
//! |
| 5647 |
MOS_STATUS Mos_Specific_InitializeMultiThreadingSyncTags( |
| 5648 |
PMOS_INTERFACE pOsInterface, |
| 5649 |
PMOS_RESOURCE pOsResource, |
| 5650 |
uint8_t ucRenderTargetIndex, |
| 5651 |
PMOS_SEMAPHORE *pCurFrmSem, |
| 5652 |
PMOS_SEMAPHORE *pRefFrmSem, |
| 5653 |
PMOS_MUTEX *pFrmMutex) |
| 5654 |
{ |
| 5655 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 5656 |
|
| 5657 |
MOS_OS_CHK_NULL(pOsInterface); |
| 5658 |
MOS_OS_CHK_NULL(pOsResource); |
| 5659 |
MOS_OS_CHK_NULL(pCurFrmSem); |
| 5660 |
MOS_OS_CHK_NULL(pRefFrmSem); |
| 5661 |
|
| 5662 |
if(*pOsResource->ppReferenceFrameSemaphore == nullptr) |
| 5663 |
{ |
| 5664 |
*pOsResource->ppReferenceFrameSemaphore = MosUtilities::MosCreateSemaphore(1, 1); |
| 5665 |
} |
| 5666 |
|
| 5667 |
if(*pOsResource->ppCurrentFrameSemaphore == nullptr) |
| 5668 |
{ |
| 5669 |
*pOsResource->ppCurrentFrameSemaphore = MosUtilities::MosCreateSemaphore(1, 1); |
| 5670 |
} |
| 5671 |
|
| 5672 |
if((*pOsResource->ppReferenceFrameSemaphore != nullptr) && (*pOsResource->ppCurrentFrameSemaphore != nullptr)) |
| 5673 |
{ |
| 5674 |
pCurFrmSem[ucRenderTargetIndex] = *pOsResource->ppCurrentFrameSemaphore; |
| 5675 |
pRefFrmSem[ucRenderTargetIndex] = *pOsResource->ppReferenceFrameSemaphore; |
| 5676 |
pFrmMutex[ucRenderTargetIndex] = nullptr; |
| 5677 |
} |
| 5678 |
|
| 5679 |
finish: |
| 5680 |
return eStatus; |
| 5681 |
} |
| 5682 |
|
| 5683 |
//! |
| 5684 |
//! \brief Wait current frame's semaphore for Hybrid Decode multi-threading sync |
| 5685 |
//! \details Wait current frame's semaphore for Hybrid Decode multi-threading sync |
| 5686 |
//! \param PMOS_RESOURCE pOsResource |
| 5687 |
//! [in] Pointer to OS resource |
| 5688 |
//! \return MOS_STATUS |
| 5689 |
//! |
| 5690 |
MOS_STATUS Mos_Specific_MultiThreadingWaitCurrentFrame( |
| 5691 |
PMOS_RESOURCE pOsResource) |
| 5692 |
{ |
| 5693 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 5694 |
|
| 5695 |
MOS_OS_CHK_NULL(pOsResource); |
| 5696 |
|
| 5697 |
MOS_OS_CHK_STATUS(MosUtilities::MosWaitSemaphore(*pOsResource->ppCurrentFrameSemaphore, INFINITE)); |
| 5698 |
|
| 5699 |
finish: |
| 5700 |
return eStatus; |
| 5701 |
} |
| 5702 |
|
| 5703 |
//! |
| 5704 |
//! \brief Post current frame's semaphore for Hybrid Decode multi-threading sync |
| 5705 |
//! \details Post current frame's semaphore for Hybrid Decode multi-threading sync |
| 5706 |
//! \param PMOS_RESOURCE pOsResource |
| 5707 |
//! [in] Pointer to OS resource |
| 5708 |
//! \return MOS_STATUS |
| 5709 |
//! |
| 5710 |
MOS_STATUS Mos_Specific_MultiThreadingPostCurrentFrame( |
| 5711 |
PMOS_RESOURCE pOsResource) |
| 5712 |
{ |
| 5713 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 5714 |
|
| 5715 |
MOS_OS_CHK_NULL(pOsResource); |
| 5716 |
|
| 5717 |
MOS_OS_CHK_STATUS(MosUtilities::MosPostSemaphore(*pOsResource->ppCurrentFrameSemaphore, 1)); |
| 5718 |
|
| 5719 |
finish: |
| 5720 |
return eStatus; |
| 5721 |
} |
| 5722 |
|
| 5723 |
//! |
| 5724 |
//! \brief Sets hybrid decoder running flag |
| 5725 |
//! \details Sets hybrid decoder running flag to indicate there is a hybrid decoder |
| 5726 |
//! is running |
| 5727 |
//! \param PMOS_INTERFACE pOsInterface |
| 5728 |
//! [in] OS Interface |
| 5729 |
//! \param int32_t bFlag |
| 5730 |
//! [in] hybrid decoder (HEVC or VP9) running flag |
| 5731 |
//! \return MOS_STATUS |
| 5732 |
//! |
| 5733 |
MOS_STATUS Mos_Specific_SetHybridDecoderRunningFlag( |
| 5734 |
PMOS_INTERFACE pOsInterface, |
| 5735 |
int32_t bFlag) |
| 5736 |
{ |
| 5737 |
PMOS_CONTEXT pOsContext; |
| 5738 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 5739 |
|
| 5740 |
MOS_OS_CHK_NULL(pOsInterface); |
| 5741 |
MOS_OS_CHK_NULL(pOsInterface->pOsContext); |
| 5742 |
|
| 5743 |
pOsContext = pOsInterface->pOsContext; |
| 5744 |
pOsContext->bHybridDecoderRunningFlag = bFlag; |
| 5745 |
|
| 5746 |
finish: |
| 5747 |
return eStatus; |
| 5748 |
} |
| 5749 |
|
| 5750 |
//! |
| 5751 |
//! \brief Gets hybrid decoder running flag |
| 5752 |
//! \details Gets hybrid decoder running flag to decide if hybrid decoder is being used |
| 5753 |
//! \param PMOS_INTERFACE pOsInterface |
| 5754 |
//! [in] OS Interface |
| 5755 |
//! \param int32_t bFlag |
| 5756 |
//! [in] hybrid decoder (HEVC or VP9) running flag |
| 5757 |
//! \return MOS_STATUS |
| 5758 |
//! |
| 5759 |
MOS_STATUS Mos_Specific_GetHybridDecoderRunningFlag( |
| 5760 |
PMOS_INTERFACE pOsInterface, |
| 5761 |
int32_t *pFlag) |
| 5762 |
{ |
| 5763 |
PMOS_CONTEXT pOsContext; |
| 5764 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 5765 |
|
| 5766 |
MOS_OS_CHK_NULL(pFlag); |
| 5767 |
*pFlag = false; |
| 5768 |
|
| 5769 |
MOS_OS_CHK_NULL(pOsInterface); |
| 5770 |
MOS_OS_CHK_NULL(pOsInterface->pOsContext); |
| 5771 |
|
| 5772 |
pOsContext = pOsInterface->pOsContext; |
| 5773 |
*pFlag = pOsContext->bHybridDecoderRunningFlag; |
| 5774 |
|
| 5775 |
finish: |
| 5776 |
return eStatus; |
| 5777 |
} |
| 5778 |
|
| 5779 |
//! |
| 5780 |
//! \brief Multi thread resource sync method |
| 5781 |
//! \details Dummy implementation on Linux for compatibility. |
| 5782 |
//! \param PMOS_INTERFACE pOsInterface |
| 5783 |
//! [in] OS Interface |
| 5784 |
//! \param PMOS_RESOURCE pOsResource |
| 5785 |
//! [in] Pointer to OS resource |
| 5786 |
//! \return MOS_STATUS |
| 5787 |
//! |
| 5788 |
MOS_STATUS Mos_Specific_MultiThreadResourceSync( |
| 5789 |
PMOS_INTERFACE pOsInterface, |
| 5790 |
PMOS_RESOURCE pOsResource) |
| 5791 |
{ |
| 5792 |
MOS_UNUSED(pOsInterface); |
| 5793 |
MOS_UNUSED(pOsResource); |
| 5794 |
return MOS_STATUS_SUCCESS; |
| 5795 |
} |
| 5796 |
|
| 5797 |
//! |
| 5798 |
//! \brief Registers a complete notification event |
| 5799 |
//! \details Registers a complete notification event |
| 5800 |
//! \param PMOS_INTERFACE pOsInterface |
| 5801 |
//! [in] Pointer to OS Interface |
| 5802 |
//! \param MOS_GPU_CONTEXT GpuContext |
| 5803 |
//! [in] GPU Context |
| 5804 |
//! \return MOS_STATUS |
| 5805 |
//! Return MOS_STATUS_SUCCESS |
| 5806 |
//! |
| 5807 |
MOS_STATUS Mos_Specific_RegisterBBCompleteNotifyEvent( |
| 5808 |
PMOS_INTERFACE pOsInterface, |
| 5809 |
MOS_GPU_CONTEXT GpuContext) |
| 5810 |
{ |
| 5811 |
MOS_UNUSED(pOsInterface); |
| 5812 |
MOS_UNUSED(GpuContext); |
| 5813 |
return MOS_STATUS_SUCCESS; |
| 5814 |
} |
| 5815 |
|
| 5816 |
//! |
| 5817 |
//! \brief Waits on a complete notification event |
| 5818 |
//! \details Waits on a complete notification event |
| 5819 |
//! \param PMOS_INTERFACE pOsInterface |
| 5820 |
//! [in] Pointer to OS Interface |
| 5821 |
//! \param uint32_t uiTimeOut |
| 5822 |
//! [in] Time to wait (ms) |
| 5823 |
//! \return MOS_STATUS |
| 5824 |
//! Return MOS_STATUS_SUCCESS |
| 5825 |
//! |
| 5826 |
MOS_STATUS Mos_Specific_WaitForBBCompleteNotifyEvent( |
| 5827 |
PMOS_INTERFACE pOsInterface, |
| 5828 |
MOS_GPU_CONTEXT GpuContext, |
| 5829 |
uint32_t uiTimeOut) |
| 5830 |
{ |
| 5831 |
MOS_UNUSED(pOsInterface); |
| 5832 |
MOS_UNUSED(GpuContext); |
| 5833 |
usleep(1000 * uiTimeOut); |
| 5834 |
|
| 5835 |
return MOS_STATUS_SUCCESS; |
| 5836 |
} |
| 5837 |
|
| 5838 |
MOS_STATUS Mos_Specific_WaitAllCmdCompletion_Os( |
| 5839 |
PMOS_INTERFACE pOsInterface) |
| 5840 |
{ |
| 5841 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 5842 |
|
| 5843 |
return eStatus; |
| 5844 |
} |
| 5845 |
|
| 5846 |
//! |
| 5847 |
//! \brief Get interface version |
| 5848 |
//! \details Get interface version |
| 5849 |
//! |
| 5850 |
//! \param PMOS_INTERFACE pOsInterface |
| 5851 |
//! [in] OS Interface |
| 5852 |
//! |
| 5853 |
//! \return uint32_t |
| 5854 |
//! Read-only OS runtime interface version, it's meaning diff from OS and API |
| 5855 |
//! |
| 5856 |
uint32_t Mos_Specific_GetInterfaceVersion( |
| 5857 |
PMOS_INTERFACE pOsInterface) |
| 5858 |
{ |
| 5859 |
MOS_UNUSED(pOsInterface); |
| 5860 |
return 0; |
| 5861 |
} |
| 5862 |
|
| 5863 |
//! |
| 5864 |
//! \brief Sets the flags to skip the sync on a particular resource |
| 5865 |
//! \details This is required to avoid updating resource tags/masks for a given resource |
| 5866 |
//! This way we dont end up putting unnecessary sync points by syncing on this particular resource |
| 5867 |
//! \param PMOS_ALLOC_GFXRES_PARAMS pAllocParams |
| 5868 |
//! [in] allocation parameters |
| 5869 |
//! \return MOS_STATUS |
| 5870 |
//! Return MOS_STATUS_SUCCESS if success else failure reason |
| 5871 |
//! |
| 5872 |
MOS_STATUS Mos_Specific_SkipResourceSync( |
| 5873 |
PMOS_RESOURCE pOsResource) |
| 5874 |
{ |
| 5875 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 5876 |
|
| 5877 |
//--------------------------------------- |
| 5878 |
MOS_OS_CHK_NULL(pOsResource); |
| 5879 |
//--------------------------------------- |
| 5880 |
|
| 5881 |
mos_bo_set_object_async(pOsResource->bo); |
| 5882 |
|
| 5883 |
finish: |
| 5884 |
return eStatus; |
| 5885 |
} |
| 5886 |
|
| 5887 |
//! |
| 5888 |
//! \brief Gets the HW rendering flags |
| 5889 |
//! \details Gets the HW rendering flags |
| 5890 |
//! \param PMOS_INTERFACE pOsInterface |
| 5891 |
//! [in] Pointer to OS Interface |
| 5892 |
//! \return MOS_NULL_RENDERING_FLAGS |
| 5893 |
//! Returns the null rendering flags |
| 5894 |
//! |
| 5895 |
MOS_NULL_RENDERING_FLAGS Mos_Specific_GetNullHWRenderFlags( |
| 5896 |
PMOS_INTERFACE pOsInterface) |
| 5897 |
{ |
| 5898 |
return pOsInterface->NullHWAccelerationEnable; |
| 5899 |
} |
| 5900 |
|
| 5901 |
//! |
| 5902 |
//! \brief Debug hook to note type of surface state or sampler state being |
| 5903 |
//! used. |
| 5904 |
//! \details Sets the Command buffer debug info |
| 5905 |
//! \param PMOS_INTERFACE pOsInterface |
| 5906 |
//! [in] Pointer to OS Interface |
| 5907 |
//! \param int32_t bSamplerState |
| 5908 |
//! [in] Sampler state |
| 5909 |
//! \param int32_t bSurfaceState |
| 5910 |
//! [in] Surface state |
| 5911 |
//! \param uint32_t dwStateIndex |
| 5912 |
//! [in] State index |
| 5913 |
//! \param uint32_t dwType |
| 5914 |
//! [in] dword type |
| 5915 |
//! \return MOS_STATUS |
| 5916 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 5917 |
//! |
| 5918 |
MOS_STATUS Mos_Specific_SetCmdBufferDebugInfo( |
| 5919 |
PMOS_INTERFACE pOsInterface, |
| 5920 |
int32_t bSamplerState, |
| 5921 |
int32_t bSurfaceState, |
| 5922 |
uint32_t dwStateIndex, |
| 5923 |
uint32_t dwType) |
| 5924 |
{ |
| 5925 |
MOS_UNUSED(pOsInterface); |
| 5926 |
MOS_UNUSED(bSamplerState); |
| 5927 |
MOS_UNUSED(bSurfaceState); |
| 5928 |
MOS_UNUSED(dwStateIndex); |
| 5929 |
MOS_UNUSED(dwType); |
| 5930 |
// stub function. implemented for simulation but not driver. |
| 5931 |
return MOS_STATUS_SUCCESS; |
| 5932 |
} |
| 5933 |
|
| 5934 |
//! |
| 5935 |
//! \brief Command buffer debug |
| 5936 |
//! \details Debug hook to get type of surface state or sampler state being |
| 5937 |
//! used. |
| 5938 |
//! \param PMOS_INTERFACE pOsInterface |
| 5939 |
//! \param int32_t bSamplerState |
| 5940 |
//! \param int32_t bSurfaceState |
| 5941 |
//! \param uint32_t dwStateIndex |
| 5942 |
//! \return uint32_t |
| 5943 |
//! |
| 5944 |
uint32_t Mos_Specific_GetCmdBufferDebugInfo( |
| 5945 |
PMOS_INTERFACE pOsInterface, |
| 5946 |
int32_t bSamplerState, |
| 5947 |
int32_t bSurfaceState, |
| 5948 |
uint32_t dwStateIndex) |
| 5949 |
{ |
| 5950 |
MOS_UNUSED(pOsInterface); |
| 5951 |
MOS_UNUSED(bSamplerState); |
| 5952 |
MOS_UNUSED(bSurfaceState); |
| 5953 |
MOS_UNUSED(dwStateIndex); |
| 5954 |
// stub function. implemented for simulation but not driver. |
| 5955 |
return 0; |
| 5956 |
} |
| 5957 |
|
| 5958 |
//! |
| 5959 |
//! \brief Set PAK/MFX context for Encoder which can be used for Synchronization |
| 5960 |
//! \details On Linux, the synchronization is handled in KMD, no job in UMD |
| 5961 |
//! \param PMOS_INTERFACE pOsInterface |
| 5962 |
//! [in] pointer to OS interface structure |
| 5963 |
//! \param MOS_GPU_CONTEXT GpuContext |
| 5964 |
//! [in] GPU context |
| 5965 |
//! \return MOS_STATUS |
| 5966 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 5967 |
//! |
| 5968 |
void Mos_Specific_SetEncodePakContext( |
| 5969 |
PMOS_INTERFACE pOsInterface, |
| 5970 |
MOS_GPU_CONTEXT GpuContext) |
| 5971 |
{ |
| 5972 |
MOS_UNUSED(pOsInterface); |
| 5973 |
MOS_UNUSED(GpuContext); |
| 5974 |
return; |
| 5975 |
} |
| 5976 |
|
| 5977 |
//! |
| 5978 |
//! \brief Set VME/ENC context for Encoder which can be used for Synchronization |
| 5979 |
//! \details On Linux, the synchronization is handled in KMD, no job in UMD |
| 5980 |
//! \param PMOS_INTERFACE pOsInterface |
| 5981 |
//! [in] pointer to OS interface structure |
| 5982 |
//! \param MOS_GPU_CONTEXT GpuContext |
| 5983 |
//! [in] GPU context |
| 5984 |
//! \return MOS_STATUS |
| 5985 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 5986 |
//! |
| 5987 |
void Mos_Specific_SetEncodeEncContext( |
| 5988 |
PMOS_INTERFACE pOsInterface, |
| 5989 |
MOS_GPU_CONTEXT GpuContext) |
| 5990 |
{ |
| 5991 |
MOS_UNUSED(pOsInterface); |
| 5992 |
MOS_UNUSED(GpuContext); |
| 5993 |
return; |
| 5994 |
} |
| 5995 |
|
| 5996 |
//! |
| 5997 |
//! \brief Verifys the patch list to be used for rendering GPU commands is large enough |
| 5998 |
//! \details |
| 5999 |
//! \param PMOS_INTERFACE pOsInterface |
| 6000 |
//! [in] pointer to OS interface structure |
| 6001 |
//! \param uint32_t dwRequestedSize |
| 6002 |
//! [in] patch list size to be verified |
| 6003 |
//! \return MOS_STATUS |
| 6004 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 6005 |
//! |
| 6006 |
MOS_STATUS Mos_Specific_VerifyPatchListSize( |
| 6007 |
PMOS_INTERFACE pOsInterface, |
| 6008 |
uint32_t dwRequestedSize) |
| 6009 |
{ |
| 6010 |
MOS_OS_FUNCTION_ENTER; |
| 6011 |
|
| 6012 |
MOS_OS_CHK_NULL_RETURN(pOsInterface); |
| 6013 |
|
| 6014 |
if (pOsInterface->apoMosEnabled) |
| 6015 |
{ |
| 6016 |
// No APO MOS interface support for this func, implement in wrapper |
| 6017 |
auto streamState = pOsInterface->osStreamState; |
| 6018 |
|
| 6019 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 6020 |
MOS_OS_CHK_NULL_RETURN(streamState->osDeviceContext); |
| 6021 |
|
| 6022 |
auto osDeviceContext = streamState->osDeviceContext; |
| 6023 |
|
| 6024 |
auto gpuContextMgr = osDeviceContext->GetGpuContextMgr(); |
| 6025 |
if (gpuContextMgr) |
| 6026 |
{ |
| 6027 |
auto gpuCtx = gpuContextMgr->GetGpuContext(streamState->currentGpuContextHandle); |
| 6028 |
|
| 6029 |
auto gpuCtxSpecific = static_cast<GpuContextSpecificNext *>(gpuCtx); |
| 6030 |
MOS_OS_CHK_NULL_RETURN(gpuCtxSpecific); |
| 6031 |
return (gpuCtxSpecific->VerifyPatchListSize(dwRequestedSize)); |
| 6032 |
} |
| 6033 |
} |
| 6034 |
if (pOsInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 6035 |
{ |
| 6036 |
auto gpuContext = Linux_GetGpuContext(pOsInterface, pOsInterface->CurrentGpuContextHandle); |
| 6037 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 6038 |
|
| 6039 |
return (gpuContext->VerifyPatchListSize(dwRequestedSize)); |
| 6040 |
} |
| 6041 |
|
| 6042 |
MOS_STATUS eStatus; |
| 6043 |
PMOS_OS_CONTEXT pOsContext; |
| 6044 |
PMOS_OS_GPU_CONTEXT pOsGpuContext; |
| 6045 |
|
| 6046 |
MOS_OS_CHK_NULL(pOsInterface); |
| 6047 |
|
| 6048 |
eStatus = MOS_STATUS_SUCCESS; |
| 6049 |
|
| 6050 |
pOsContext = pOsInterface->pOsContext; |
| 6051 |
MOS_OS_CHK_NULL(pOsContext); |
| 6052 |
|
| 6053 |
pOsGpuContext = &(pOsContext->OsGpuContext[pOsInterface->CurrentGpuContextOrdinal]); |
| 6054 |
if (dwRequestedSize > pOsGpuContext->uiMaxPatchLocationsize) |
| 6055 |
{ |
| 6056 |
eStatus = MOS_STATUS_UNKNOWN; |
| 6057 |
} |
| 6058 |
|
| 6059 |
finish: |
| 6060 |
return eStatus; |
| 6061 |
} |
| 6062 |
|
| 6063 |
//! |
| 6064 |
//! \brief reset command buffer space |
| 6065 |
//! \details resets the command buffer space |
| 6066 |
//! \param PMOS_INTERFACE pOsInterface |
| 6067 |
//! [in] pointer to OS interface structure |
| 6068 |
//! \param PMOS_COMMAND_BUFFER pCmdBuffer |
| 6069 |
//! [in] pointer to command buffer structure |
| 6070 |
//! \return MOS_STATUS |
| 6071 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 6072 |
//! |
| 6073 |
MOS_STATUS Mos_Specific_ResetCommandBuffer( |
| 6074 |
PMOS_INTERFACE pOsInterface, |
| 6075 |
PMOS_COMMAND_BUFFER pCmdBuffer) |
| 6076 |
{ |
| 6077 |
PMOS_OS_CONTEXT pOsContext; |
| 6078 |
PMOS_OS_GPU_CONTEXT pOsGpuContext; |
| 6079 |
MOS_UNUSED(pCmdBuffer); |
| 6080 |
MOS_OS_FUNCTION_ENTER; |
| 6081 |
|
| 6082 |
MOS_OS_CHK_NULL_RETURN(pOsInterface); |
| 6083 |
MOS_OS_CHK_NULL_RETURN(pCmdBuffer); |
| 6084 |
|
| 6085 |
if (pOsInterface->apoMosEnabled) |
| 6086 |
{ |
| 6087 |
return MosInterface::ResetCommandBuffer(pOsInterface->osStreamState, pCmdBuffer); |
| 6088 |
} |
| 6089 |
|
| 6090 |
if (pOsInterface->CurrentGpuContextOrdinal == MOS_GPU_CONTEXT_INVALID_HANDLE) |
| 6091 |
{ |
| 6092 |
MOS_OS_ASSERTMESSAGE("Invalid input parameter GpuContext."); |
| 6093 |
return MOS_STATUS_INVALID_PARAMETER; |
| 6094 |
} |
| 6095 |
|
| 6096 |
if (pOsInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 6097 |
{ |
| 6098 |
auto gpuContext = Linux_GetGpuContext(pOsInterface, pOsInterface->CurrentGpuContextHandle); |
| 6099 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 6100 |
|
| 6101 |
return gpuContext->ResetCommandBuffer(); |
| 6102 |
} |
| 6103 |
|
| 6104 |
pOsContext = pOsInterface->pOsContext; |
| 6105 |
pOsGpuContext = &pOsContext->OsGpuContext[pOsInterface->CurrentGpuContextOrdinal]; |
| 6106 |
|
| 6107 |
pOsGpuContext->bCBFlushed = true; |
| 6108 |
|
| 6109 |
finish: |
| 6110 |
return MOS_STATUS_SUCCESS; |
| 6111 |
} |
| 6112 |
|
| 6113 |
//! |
| 6114 |
//! \brief Get the memory compression mode |
| 6115 |
//! \details Gets the memory compression mode from GMM |
| 6116 |
//! \param PMOS_INTERFACE pOsInterface |
| 6117 |
//! [in] pointer to OS interface structure |
| 6118 |
//! \param PMOS_RESOURCE pOsResource |
| 6119 |
//! [in] pointer to input OS resource |
| 6120 |
//! \param PMOS_MEMCOMP_STATE pResMmcMode |
| 6121 |
//! [out] the memory compression mode gotten from OS resource |
| 6122 |
//! \return MOS_STATUS |
| 6123 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 6124 |
//! |
| 6125 |
MOS_STATUS Mos_Specific_GetMemoryCompressionMode( |
| 6126 |
PMOS_INTERFACE pOsInterface, |
| 6127 |
PMOS_RESOURCE pOsResource, |
| 6128 |
PMOS_MEMCOMP_STATE pResMmcMode) |
| 6129 |
{ |
| 6130 |
PGMM_RESOURCE_INFO pGmmResourceInfo; |
| 6131 |
GMM_RESOURCE_FLAG flags; |
| 6132 |
MOS_STATUS eStatus = MOS_STATUS_UNKNOWN; |
| 6133 |
MOS_OS_FUNCTION_ENTER; |
| 6134 |
|
| 6135 |
MOS_OS_CHK_NULL_RETURN(pOsResource); |
| 6136 |
MOS_OS_CHK_NULL_RETURN(pResMmcMode); |
| 6137 |
MOS_OS_CHK_NULL_RETURN(pOsInterface); |
| 6138 |
|
| 6139 |
MediaFeatureTable* skuTable = nullptr; |
| 6140 |
skuTable = pOsInterface->pfnGetSkuTable(pOsInterface); |
| 6141 |
MOS_OS_CHK_NULL_RETURN(skuTable); |
| 6142 |
|
| 6143 |
if (pOsInterface->apoMosEnabled) |
| 6144 |
{ |
| 6145 |
return MosInterface::GetMemoryCompressionMode(pOsInterface->osStreamState, pOsResource, *pResMmcMode); |
| 6146 |
} |
| 6147 |
|
| 6148 |
// Get Gmm resource info |
| 6149 |
pGmmResourceInfo = (GMM_RESOURCE_INFO*)pOsResource->pGmmResInfo; |
| 6150 |
MOS_OS_CHK_NULL_RETURN(pGmmResourceInfo); |
| 6151 |
|
| 6152 |
flags = pOsResource->pGmmResInfo->GetResFlags(); |
| 6153 |
|
| 6154 |
if (!flags.Gpu.MMC || !flags.Gpu.CCS) |
| 6155 |
{ |
| 6156 |
*pResMmcMode = MOS_MEMCOMP_DISABLED; |
| 6157 |
return MOS_STATUS_SUCCESS; |
| 6158 |
} |
| 6159 |
|
| 6160 |
if (flags.Info.MediaCompressed || flags.Info.RenderCompressed) |
| 6161 |
{ |
| 6162 |
*pResMmcMode = flags.Info.RenderCompressed ? MOS_MEMCOMP_RC : MOS_MEMCOMP_MC; |
| 6163 |
} |
| 6164 |
else |
| 6165 |
{ |
| 6166 |
switch (pGmmResourceInfo->GetMmcMode(0)) |
| 6167 |
{ |
| 6168 |
case GMM_MMC_HORIZONTAL: |
| 6169 |
*pResMmcMode = MOS_MEMCOMP_HORIZONTAL; |
| 6170 |
break; |
| 6171 |
case GMM_MMC_VERTICAL: |
| 6172 |
*pResMmcMode = MOS_MEMCOMP_VERTICAL; |
| 6173 |
break; |
| 6174 |
case GMM_MMC_DISABLED: |
| 6175 |
default: |
| 6176 |
*pResMmcMode = MOS_MEMCOMP_DISABLED; |
| 6177 |
break; |
| 6178 |
} |
| 6179 |
} |
| 6180 |
|
| 6181 |
uint32_t MmcFormat = 0; |
| 6182 |
GMM_RESOURCE_FORMAT gmmResFmt; |
| 6183 |
|
| 6184 |
gmmResFmt = pGmmResourceInfo->GetResourceFormat(); |
| 6185 |
|
| 6186 |
if (*pResMmcMode == MOS_MEMCOMP_MC && |
| 6187 |
(!MEDIA_IS_SKU(skuTable, FtrFlatPhysCCS))) |
| 6188 |
{ |
| 6189 |
MmcFormat = static_cast<uint32_t>(pOsInterface->pfnGetGmmClientContext(pOsInterface)->GetMediaSurfaceStateCompressionFormat(gmmResFmt)); |
| 6190 |
*pResMmcMode = (MmcFormat != 0) ? *pResMmcMode : MOS_MEMCOMP_DISABLED; |
| 6191 |
} |
| 6192 |
|
| 6193 |
eStatus = MOS_STATUS_SUCCESS; |
| 6194 |
|
| 6195 |
|
| 6196 |
finish: |
| 6197 |
return eStatus; |
| 6198 |
} |
| 6199 |
|
| 6200 |
//! |
| 6201 |
//! \brief Set the memory compression mode in GMM |
| 6202 |
//! \details Set the memory compression mode |
| 6203 |
//! \param PMOS_INTERFACE pOsInterface |
| 6204 |
//! [in] pointer to OS interface structure |
| 6205 |
//! \param PMOS_RESOURCE pOsResource |
| 6206 |
//! [in] pointer to input OS resource |
| 6207 |
//! \param MOS_MEMCOMP_STATE ResMmcMode |
| 6208 |
//! [in] the memory compression mode to be set into OS resource |
| 6209 |
//! \return MOS_STATUS |
| 6210 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 6211 |
//! |
| 6212 |
MOS_STATUS Mos_Specific_SetMemoryCompressionMode( |
| 6213 |
PMOS_INTERFACE pOsInterface, |
| 6214 |
PMOS_RESOURCE pOsResource, |
| 6215 |
MOS_MEMCOMP_STATE ResMmcMode) |
| 6216 |
{ |
| 6217 |
PGMM_RESOURCE_INFO pGmmResourceInfo = nullptr; |
| 6218 |
GMM_RESOURCE_MMC_INFO GmmResMmcMode = GMM_MMC_DISABLED; |
| 6219 |
MOS_STATUS eStatus = MOS_STATUS_UNKNOWN; |
| 6220 |
MOS_OS_FUNCTION_ENTER; |
| 6221 |
MOS_OS_CHK_NULL(pOsResource); |
| 6222 |
MOS_OS_CHK_NULL(pOsInterface); |
| 6223 |
|
| 6224 |
if (pOsInterface->apoMosEnabled) |
| 6225 |
{ |
| 6226 |
return MosInterface::SetMemoryCompressionMode(pOsInterface->osStreamState, pOsResource, ResMmcMode); |
| 6227 |
} |
| 6228 |
|
| 6229 |
// Get Gmm resource info |
| 6230 |
pGmmResourceInfo = (GMM_RESOURCE_INFO*)pOsResource->pGmmResInfo; |
| 6231 |
MOS_OS_CHK_NULL(pGmmResourceInfo); |
| 6232 |
|
| 6233 |
switch (ResMmcMode) |
| 6234 |
{ |
| 6235 |
case MOS_MEMCOMP_HORIZONTAL: |
| 6236 |
GmmResMmcMode = GMM_MMC_HORIZONTAL; |
| 6237 |
break; |
| 6238 |
case MOS_MEMCOMP_VERTICAL: |
| 6239 |
GmmResMmcMode = GMM_MMC_VERTICAL; |
| 6240 |
break; |
| 6241 |
case MOS_MEMCOMP_DISABLED: |
| 6242 |
default: |
| 6243 |
GmmResMmcMode = GMM_MMC_DISABLED; |
| 6244 |
break; |
| 6245 |
} |
| 6246 |
|
| 6247 |
pGmmResourceInfo->SetMmcMode(GmmResMmcMode, 0); |
| 6248 |
|
| 6249 |
eStatus = MOS_STATUS_SUCCESS; |
| 6250 |
|
| 6251 |
finish: |
| 6252 |
return eStatus; |
| 6253 |
} |
| 6254 |
|
| 6255 |
//! |
| 6256 |
//! \brief Set the memory compression hint in GMM on Linux or Gralloc on Android |
| 6257 |
//! \details Indicate if the surface is compressible |
| 6258 |
//! \param PMOS_INTERFACE pOsInterface |
| 6259 |
//! [in] pointer to OS interface structure |
| 6260 |
//! \param PMOS_RESOURCE pOsResource |
| 6261 |
//! [in] pointer to input OS resource |
| 6262 |
//! \param int32_t bHintOn |
| 6263 |
//! [in] the memory compression hint to be set |
| 6264 |
//! \return MOS_STATUS |
| 6265 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 6266 |
//! |
| 6267 |
MOS_STATUS Mos_Specific_SetMemoryCompressionHint( |
| 6268 |
PMOS_INTERFACE pOsInterface, |
| 6269 |
PMOS_RESOURCE pOsResource, |
| 6270 |
int32_t bHintOn) |
| 6271 |
{ |
| 6272 |
PGMM_RESOURCE_INFO pGmmResourceInfo = nullptr; |
| 6273 |
uint32_t uiArrayIndex = 0; |
| 6274 |
MOS_STATUS eStatus; |
| 6275 |
MOS_OS_FUNCTION_ENTER; |
| 6276 |
eStatus = MOS_STATUS_UNKNOWN; |
| 6277 |
MOS_OS_CHK_NULL(pOsResource); |
| 6278 |
MOS_OS_CHK_NULL(pOsInterface); |
| 6279 |
|
| 6280 |
if (pOsInterface->apoMosEnabled) |
| 6281 |
{ |
| 6282 |
return MosInterface::SetMemoryCompressionHint(pOsInterface->osStreamState, pOsResource, bHintOn); |
| 6283 |
} |
| 6284 |
|
| 6285 |
// Get Gmm resource info |
| 6286 |
pGmmResourceInfo = (GMM_RESOURCE_INFO*)pOsResource->pGmmResInfo; |
| 6287 |
MOS_OS_CHK_NULL(pGmmResourceInfo); |
| 6288 |
|
| 6289 |
pGmmResourceInfo->SetMmcHint(bHintOn ? GMM_MMC_HINT_ON : GMM_MMC_HINT_OFF, uiArrayIndex); |
| 6290 |
|
| 6291 |
eStatus = MOS_STATUS_SUCCESS; |
| 6292 |
|
| 6293 |
finish: |
| 6294 |
return eStatus; |
| 6295 |
} |
| 6296 |
|
| 6297 |
//! |
| 6298 |
//! \brief Get the memory compression format |
| 6299 |
//! \details Gets the memory compression format from GMM |
| 6300 |
//! \param PMOS_INTERFACE pOsInterface |
| 6301 |
//! [in] pointer to OS interface structure |
| 6302 |
//! \param PMOS_RESOURCE pOsResource |
| 6303 |
//! [in] pointer to input OS resource |
| 6304 |
//! \param uint32_t *pResMmcFormat |
| 6305 |
//! [out] the memory compression format gotten from GMM resource |
| 6306 |
//! \return MOS_STATUS |
| 6307 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 6308 |
//! |
| 6309 |
MOS_STATUS Mos_Specific_GetMemoryCompressionFormat( |
| 6310 |
PMOS_INTERFACE pOsInterface, |
| 6311 |
PMOS_RESOURCE pOsResource, |
| 6312 |
uint32_t *pResMmcFormat) |
| 6313 |
{ |
| 6314 |
|
| 6315 |
PGMM_RESOURCE_INFO pGmmResourceInfo; |
| 6316 |
MOS_STATUS eStatus = MOS_STATUS_UNKNOWN; |
| 6317 |
MOS_OS_FUNCTION_ENTER; |
| 6318 |
MOS_OS_CHK_NULL(pOsResource); |
| 6319 |
MOS_OS_CHK_NULL(pOsInterface); |
| 6320 |
MOS_OS_CHK_NULL(pResMmcFormat); |
| 6321 |
|
| 6322 |
if (pOsInterface->apoMosEnabled) |
| 6323 |
{ |
| 6324 |
return MosInterface::GetMemoryCompressionFormat(pOsInterface->osStreamState, pOsResource, pResMmcFormat); |
| 6325 |
} |
| 6326 |
|
| 6327 |
// Get Gmm resource info |
| 6328 |
pGmmResourceInfo = (GMM_RESOURCE_INFO*)pOsResource->pGmmResInfo; |
| 6329 |
MOS_OS_CHK_NULL(pGmmResourceInfo); |
| 6330 |
|
| 6331 |
MOS_OS_CHK_NULL(pOsInterface->pfnGetGmmClientContext(pOsInterface)); |
| 6332 |
// Get compression format from GMM RESOURCE FORMAT |
| 6333 |
GMM_RESOURCE_FORMAT gmmResFmt; |
| 6334 |
gmmResFmt = pGmmResourceInfo->GetResourceFormat(); |
| 6335 |
MOS_MEMCOMP_STATE MmcMode; |
| 6336 |
uint32_t MmcFormat; |
| 6337 |
Mos_Specific_GetMemoryCompressionMode(pOsInterface, pOsResource, &MmcMode); |
| 6338 |
switch (MmcMode) |
| 6339 |
{ |
| 6340 |
case MOS_MEMCOMP_MC: |
| 6341 |
MmcFormat = static_cast<uint32_t>(pOsInterface->pfnGetGmmClientContext(pOsInterface)->GetMediaSurfaceStateCompressionFormat(gmmResFmt)); |
| 6342 |
break; |
| 6343 |
case MOS_MEMCOMP_RC: |
| 6344 |
MmcFormat = static_cast<uint32_t>(pOsInterface->pfnGetGmmClientContext(pOsInterface)->GetSurfaceStateCompressionFormat(gmmResFmt)); |
| 6345 |
break; |
| 6346 |
default: |
| 6347 |
MmcFormat = 0; |
| 6348 |
} |
| 6349 |
|
| 6350 |
if (MmcFormat > 0x1F) |
| 6351 |
{ |
| 6352 |
MOS_OS_ASSERTMESSAGE("Get a incorrect Compression format(%d) from GMM", MmcFormat); |
| 6353 |
} |
| 6354 |
else |
| 6355 |
{ |
| 6356 |
*pResMmcFormat = MmcFormat; |
| 6357 |
MOS_OS_VERBOSEMESSAGE("GMM compression mode %d, compression format %d", MmcMode, MmcFormat); |
| 6358 |
} |
| 6359 |
|
| 6360 |
eStatus = MOS_STATUS_SUCCESS; |
| 6361 |
|
| 6362 |
finish: |
| 6363 |
return eStatus; |
| 6364 |
|
| 6365 |
} |
| 6366 |
|
| 6367 |
#ifdef ANDROID |
| 6368 |
//! |
| 6369 |
//! \brief Create GPU node association. |
| 6370 |
//! \details Create GPU node association. |
| 6371 |
//! \param PMOS_INTERFACE pOsInterface |
| 6372 |
//! [in] OS Interface |
| 6373 |
//! \param MOS_MEDIA_OPERATION MediaOperation |
| 6374 |
//! [in] Media operation |
| 6375 |
//! \param MOS_GPU_NODE *pVideoNodeOrdinal |
| 6376 |
//! [out] VCS node ordinal |
| 6377 |
//! \return MOS_STATUS |
| 6378 |
//! MOS_STATUS_SUCCESS if success, otherwise error code |
| 6379 |
//! |
| 6380 |
MOS_STATUS Mos_Specific_CreateVideoNodeAssociation( |
| 6381 |
PMOS_INTERFACE pOsInterface, |
| 6382 |
int32_t bSetVideoNode, |
| 6383 |
MOS_GPU_NODE *pVideoNodeOrdinal) |
| 6384 |
{ |
| 6385 |
MOS_UNUSED(pOsInterface); |
| 6386 |
MOS_UNUSED(bSetVideoNode); |
| 6387 |
MOS_OS_ASSERT(pVideoNodeOrdinal); |
| 6388 |
|
| 6389 |
// return VDBox #1 for now. |
| 6390 |
*pVideoNodeOrdinal = MOS_GPU_NODE_VIDEO; |
| 6391 |
|
| 6392 |
return MOS_STATUS_SUCCESS; |
| 6393 |
} |
| 6394 |
|
| 6395 |
//! |
| 6396 |
//! \brief Destroy GPU node association. |
| 6397 |
//! \details Destroy GPU node association. |
| 6398 |
//! \param PMOS_INTERFACE pOsInterface |
| 6399 |
//! [in] OS Interface |
| 6400 |
//! \param MOS_GPU_NODE VideoNodeOrdinal |
| 6401 |
//! [in] VCS node ordinal |
| 6402 |
//! \return MOS_STATUS |
| 6403 |
//! MOS_STATUS_SUCCESS if success, otherwise error code |
| 6404 |
//! |
| 6405 |
MOS_STATUS Mos_Specific_DestroyVideoNodeAssociation( |
| 6406 |
PMOS_INTERFACE pOsInterface, |
| 6407 |
MOS_GPU_NODE VideoNodeOrdinal) |
| 6408 |
{ |
| 6409 |
MOS_UNUSED(pOsInterface); |
| 6410 |
MOS_UNUSED(VideoNodeOrdinal); |
| 6411 |
return MOS_STATUS_SUCCESS; |
| 6412 |
} |
| 6413 |
|
| 6414 |
#else |
| 6415 |
|
| 6416 |
//! |
| 6417 |
//! \brief Create GPU node association. |
| 6418 |
//! \details Create GPU node association. |
| 6419 |
//! \param PMOS_INTERFACE pOsInterface |
| 6420 |
//! [in] OS Interface |
| 6421 |
//! \param MOS_MEDIA_OPERATION MediaOperation |
| 6422 |
//! [in] Media operation |
| 6423 |
//! \param MOS_GPU_NODE *pVideoNodeOrdinal |
| 6424 |
//! [out] VCS node ordinal |
| 6425 |
//! \return MOS_STATUS |
| 6426 |
//! MOS_STATUS_SUCCESS if success, otherwise error code |
| 6427 |
//! |
| 6428 |
MOS_STATUS Mos_Specific_CreateVideoNodeAssociation( |
| 6429 |
PMOS_INTERFACE pOsInterface, |
| 6430 |
int32_t bSetVideoNode, |
| 6431 |
MOS_GPU_NODE *pVideoNodeOrdinal) |
| 6432 |
{ |
| 6433 |
PMOS_OS_CONTEXT pOsContext; |
| 6434 |
PVDBOX_WORKLOAD pVDBoxWorkLoad = nullptr; |
| 6435 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 6436 |
|
| 6437 |
MOS_OS_FUNCTION_ENTER; |
| 6438 |
|
| 6439 |
MOS_OS_ASSERT(pOsInterface); |
| 6440 |
MOS_OS_ASSERT(pVideoNodeOrdinal); |
| 6441 |
|
| 6442 |
pOsContext = pOsInterface->pOsContext; |
| 6443 |
|
| 6444 |
if (false == pOsContext->bKMDHasVCS2) |
| 6445 |
{ |
| 6446 |
*pVideoNodeOrdinal = MOS_GPU_NODE_VIDEO; |
| 6447 |
goto finish; |
| 6448 |
} |
| 6449 |
|
| 6450 |
// If node selection is forced or we have only one VDBox, turn balancing off. |
| 6451 |
// After that check debug flags. |
| 6452 |
if (pOsInterface->bEnableVdboxBalancing) |
| 6453 |
{ |
| 6454 |
pOsContext->bPerCmdBufferBalancing = !bSetVideoNode && pOsContext->bKMDHasVCS2 && pOsInterface->pfnGetVdboxNodeId; |
| 6455 |
} |
| 6456 |
else |
| 6457 |
{ |
| 6458 |
pOsContext->bPerCmdBufferBalancing = 0; |
| 6459 |
} |
| 6460 |
|
| 6461 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 6462 |
if (pOsInterface->eForceVdbox == MOS_FORCE_VDBOX_1) |
| 6463 |
{ |
| 6464 |
bSetVideoNode = true; |
| 6465 |
*pVideoNodeOrdinal = MOS_GPU_NODE_VIDEO; |
| 6466 |
pOsContext->bPerCmdBufferBalancing = 0; |
| 6467 |
} |
| 6468 |
else if (pOsInterface->eForceVdbox == MOS_FORCE_VDBOX_2) |
| 6469 |
{ |
| 6470 |
bSetVideoNode = true; |
| 6471 |
*pVideoNodeOrdinal = MOS_GPU_NODE_VIDEO2; |
| 6472 |
pOsContext->bPerCmdBufferBalancing = 0; |
| 6473 |
} |
| 6474 |
#endif // _DEBUG || _RELEASE_INTERNAL |
| 6475 |
|
| 6476 |
if (pOsContext->semid == MOS_LINUX_IPC_INVALID_ID) |
| 6477 |
{ |
| 6478 |
MOS_OS_ASSERTMESSAGE("Invalid semid in OsContext."); |
| 6479 |
eStatus = MOS_STATUS_UNKNOWN; |
| 6480 |
goto finish; |
| 6481 |
} |
| 6482 |
|
| 6483 |
LockSemaphore(pOsContext->semid); |
| 6484 |
|
| 6485 |
pVDBoxWorkLoad = (PVDBOX_WORKLOAD)pOsContext->pShm; |
| 6486 |
MOS_OS_ASSERT(pVDBoxWorkLoad); |
| 6487 |
|
| 6488 |
if (bSetVideoNode) |
| 6489 |
{ |
| 6490 |
if (*pVideoNodeOrdinal == MOS_GPU_NODE_VIDEO) |
| 6491 |
{ |
| 6492 |
pVDBoxWorkLoad->uiVDBoxCount[0]++; |
| 6493 |
} |
| 6494 |
else if (*pVideoNodeOrdinal == MOS_GPU_NODE_VIDEO2) |
| 6495 |
{ |
| 6496 |
pVDBoxWorkLoad->uiVDBoxCount[1]++; |
| 6497 |
} |
| 6498 |
else |
| 6499 |
{ |
| 6500 |
MOS_OS_ASSERTMESSAGE("VDBoxWorkLoad not set."); |
| 6501 |
} |
| 6502 |
} |
| 6503 |
else |
| 6504 |
{ |
| 6505 |
if (pVDBoxWorkLoad->uiVDBoxCount[0] < pVDBoxWorkLoad->uiVDBoxCount[1]) |
| 6506 |
{ |
| 6507 |
*pVideoNodeOrdinal = MOS_GPU_NODE_VIDEO; |
| 6508 |
pVDBoxWorkLoad->uiVDBoxCount[0]++; |
| 6509 |
} |
| 6510 |
else if (pVDBoxWorkLoad->uiVDBoxCount[0] == pVDBoxWorkLoad->uiVDBoxCount[1]) |
| 6511 |
{ |
| 6512 |
// this ping-pong method improves much performance for multi-session HD to HD xcode |
| 6513 |
if (pVDBoxWorkLoad->uiRingIndex == 0) |
| 6514 |
{ |
| 6515 |
*pVideoNodeOrdinal = MOS_GPU_NODE_VIDEO; |
| 6516 |
pVDBoxWorkLoad->uiVDBoxCount[0]++; |
| 6517 |
pVDBoxWorkLoad->uiRingIndex = 1; |
| 6518 |
} |
| 6519 |
else |
| 6520 |
{ |
| 6521 |
*pVideoNodeOrdinal = MOS_GPU_NODE_VIDEO2; |
| 6522 |
pVDBoxWorkLoad->uiVDBoxCount[1]++; |
| 6523 |
pVDBoxWorkLoad->uiRingIndex = 0; |
| 6524 |
} |
| 6525 |
} |
| 6526 |
else |
| 6527 |
{ |
| 6528 |
*pVideoNodeOrdinal = MOS_GPU_NODE_VIDEO2; |
| 6529 |
pVDBoxWorkLoad->uiVDBoxCount[1]++; |
| 6530 |
} |
| 6531 |
} |
| 6532 |
|
| 6533 |
UnLockSemaphore(pOsContext->semid); |
| 6534 |
|
| 6535 |
finish: |
| 6536 |
return eStatus; |
| 6537 |
} |
| 6538 |
|
| 6539 |
//! |
| 6540 |
//! \brief Destroy GPU node association. |
| 6541 |
//! \details Destroy GPU node association. |
| 6542 |
//! \param PMOS_INTERFACE pOsInterface |
| 6543 |
//! [in] OS Interface |
| 6544 |
//! \param MOS_GPU_NODE VideoNodeOrdinal |
| 6545 |
//! [in] VCS node ordinal |
| 6546 |
//! \return MOS_STATUS |
| 6547 |
//! MOS_STATUS_SUCCESS if success, otherwise error code |
| 6548 |
//! |
| 6549 |
MOS_STATUS Mos_Specific_DestroyVideoNodeAssociation( |
| 6550 |
PMOS_INTERFACE pOsInterface, |
| 6551 |
MOS_GPU_NODE VideoNodeOrdinal) |
| 6552 |
{ |
| 6553 |
PMOS_OS_CONTEXT pOsContext = nullptr; |
| 6554 |
PVDBOX_WORKLOAD pVDBoxWorkLoad = nullptr; |
| 6555 |
|
| 6556 |
MOS_OS_FUNCTION_ENTER; |
| 6557 |
MOS_OS_CHK_NULL_RETURN(pOsInterface); |
| 6558 |
MOS_OS_CHK_NULL_RETURN(pOsInterface->pOsContext); |
| 6559 |
pOsContext = pOsInterface->pOsContext; |
| 6560 |
|
| 6561 |
// not do workload balancing in UMD just return; |
| 6562 |
if (pOsContext->bKMDHasVCS2 == false) |
| 6563 |
{ |
| 6564 |
return MOS_STATUS_SUCCESS; |
| 6565 |
} |
| 6566 |
|
| 6567 |
if (pOsContext->semid == MOS_LINUX_IPC_INVALID_ID) |
| 6568 |
{ |
| 6569 |
MOS_OS_ASSERTMESSAGE("Invalid semid in OsContext."); |
| 6570 |
return MOS_STATUS_UNKNOWN; |
| 6571 |
} |
| 6572 |
|
| 6573 |
LockSemaphore(pOsContext->semid); |
| 6574 |
|
| 6575 |
pVDBoxWorkLoad = (PVDBOX_WORKLOAD)pOsContext->pShm; |
| 6576 |
MOS_OS_ASSERT(pVDBoxWorkLoad); |
| 6577 |
|
| 6578 |
if (VideoNodeOrdinal == MOS_GPU_NODE_VIDEO) |
| 6579 |
{ |
| 6580 |
pVDBoxWorkLoad->uiVDBoxCount[0]--; |
| 6581 |
} |
| 6582 |
else |
| 6583 |
{ |
| 6584 |
pVDBoxWorkLoad->uiVDBoxCount[1]--; |
| 6585 |
} |
| 6586 |
|
| 6587 |
UnLockSemaphore(pOsContext->semid); |
| 6588 |
|
| 6589 |
return MOS_STATUS_SUCCESS; |
| 6590 |
} |
| 6591 |
#endif |
| 6592 |
|
| 6593 |
MOS_VDBOX_NODE_IND Mos_Specific_GetVdboxNodeId( |
| 6594 |
PMOS_INTERFACE pOsInterface, |
| 6595 |
PMOS_COMMAND_BUFFER pCmdBuffer) |
| 6596 |
{ |
| 6597 |
MOS_VDBOX_NODE_IND idx = MOS_VDBOX_NODE_INVALID; |
| 6598 |
|
| 6599 |
MOS_OS_CHK_NULL_NO_STATUS(pCmdBuffer); |
| 6600 |
MOS_OS_CHK_NULL_NO_STATUS(pOsInterface); |
| 6601 |
MOS_OS_CHK_NULL_NO_STATUS(pOsInterface->pOsContext); |
| 6602 |
|
| 6603 |
// If we have assigned vdbox index for the given cmdbuf, return it immediately |
| 6604 |
if (MOS_VDBOX_NODE_INVALID != pCmdBuffer->iVdboxNodeIndex) { |
| 6605 |
idx = pCmdBuffer->iVdboxNodeIndex; |
| 6606 |
return idx; |
| 6607 |
} |
| 6608 |
|
| 6609 |
finish: |
| 6610 |
return idx; |
| 6611 |
} |
| 6612 |
|
| 6613 |
//! |
| 6614 |
//! \brief Get the memory object |
| 6615 |
//! \details Get the memory object for cache policy |
| 6616 |
//! \param MOS_HW_RESOURCE_DEF MosUsage |
| 6617 |
//! [in] HW resource |
| 6618 |
//! [in] Gmm client context |
| 6619 |
//! \return MEMORY_OBJECT_CONTROL_STATE |
| 6620 |
//! Return the memory object |
| 6621 |
//! |
| 6622 |
MEMORY_OBJECT_CONTROL_STATE Mos_Specific_CachePolicyGetMemoryObject( |
| 6623 |
MOS_HW_RESOURCE_DEF MosUsage, |
| 6624 |
GMM_CLIENT_CONTEXT *pGmmClientContext) |
| 6625 |
{ |
| 6626 |
// Force convert to stream handle for wrapper |
| 6627 |
return MosInterface::GetCachePolicyMemoryObject(pGmmClientContext, MosUsage); |
| 6628 |
} |
| 6629 |
|
| 6630 |
//! |
| 6631 |
//! \brief Get the L1 config |
| 6632 |
//! \details Get the L1 config for cache policy |
| 6633 |
//! \param MOS_HW_RESOURCE_DEF MosUsage |
| 6634 |
//! [in] HW resource |
| 6635 |
//! [in] Gmm client context |
| 6636 |
//! \return uint8_t |
| 6637 |
//! L1_CACHE_CONTROL |
| 6638 |
//! |
| 6639 |
uint8_t Mos_Specific_CachePolicyGetL1Config( |
| 6640 |
MOS_HW_RESOURCE_DEF MosUsage, |
| 6641 |
GMM_CLIENT_CONTEXT *pGmmClientContext) |
| 6642 |
{ |
| 6643 |
return 0; |
| 6644 |
} |
| 6645 |
|
| 6646 |
|
| 6647 |
//*----------------------------------------------------------------------------- |
| 6648 |
//| Purpose : Loads library |
| 6649 |
//| Returns : Instance to handle |
| 6650 |
//*----------------------------------------------------------------------------- |
| 6651 |
//! |
| 6652 |
//! \brief |
| 6653 |
//! \details |
| 6654 |
//! \param const char *pFileName |
| 6655 |
//! \return HINSTANCE |
| 6656 |
//! |
| 6657 |
MOS_STATUS Mos_Specific_LoadLibrary( |
| 6658 |
PMOS_INTERFACE pOsInterface, |
| 6659 |
PCCHAR pFileName, |
| 6660 |
void **ppvModule) |
| 6661 |
{ |
| 6662 |
char *error; |
| 6663 |
MOS_UNUSED(pOsInterface); |
| 6664 |
//--------------------------------- |
| 6665 |
MOS_OS_ASSERT(pFileName); |
| 6666 |
//--------------------------------- |
| 6667 |
|
| 6668 |
return MosInterface::MosLoadLibrary(nullptr, pFileName, ppvModule); |
| 6669 |
} |
| 6670 |
|
| 6671 |
//*----------------------------------------------------------------------------- |
| 6672 |
//| Purpose : Frees library |
| 6673 |
//| Returns : Result of the operation |
| 6674 |
//*----------------------------------------------------------------------------- |
| 6675 |
//! |
| 6676 |
//! \brief |
| 6677 |
//! \details |
| 6678 |
//! \param HINSTANCE hInstance |
| 6679 |
//! \return MOS_STATUS |
| 6680 |
//! |
| 6681 |
MOS_STATUS Mos_Specific_FreeLibrary( |
| 6682 |
void *hInstance) |
| 6683 |
{ |
| 6684 |
int32_t bStatus; |
| 6685 |
|
| 6686 |
//--------------------------------- |
| 6687 |
MOS_OS_ASSERT(hInstance); |
| 6688 |
//--------------------------------- |
| 6689 |
|
| 6690 |
return MosInterface::MosFreeLibrary(hInstance); |
| 6691 |
} |
| 6692 |
|
| 6693 |
//! |
| 6694 |
//! \brief Determines if the GPU Hung |
| 6695 |
//! \param PMOS_INTERFACE pOsInterface |
| 6696 |
//! [in] Pointer to OS Interface |
| 6697 |
//! \return int32_t |
| 6698 |
//! Return if the GPU Hung |
| 6699 |
//! |
| 6700 |
int32_t Mos_Specific_IsGPUHung( |
| 6701 |
PMOS_INTERFACE pOsInterface) |
| 6702 |
{ |
| 6703 |
uint32_t dwResetCount = 0; |
| 6704 |
uint32_t dwActiveBatch = 0; |
| 6705 |
uint32_t dwPendingBatch = 0; |
| 6706 |
int32_t bResult = false; |
| 6707 |
int32_t ret = 0; |
| 6708 |
|
| 6709 |
if (pOsInterface == nullptr) |
| 6710 |
{ |
| 6711 |
MOS_OS_ASSERTMESSAGE("Mos_Specific_IsGPUHung: pOsInterface == NULL"); |
| 6712 |
return false; |
| 6713 |
} |
| 6714 |
|
| 6715 |
if (pOsInterface->apoMosEnabled) |
| 6716 |
{ |
| 6717 |
return MosInterface::IsGPUHung(pOsInterface->osStreamState); |
| 6718 |
} |
| 6719 |
|
| 6720 |
MOS_LINUX_CONTEXT *intel_i915_ctx = pOsInterface->pOsContext->intel_context; |
| 6721 |
if (pOsInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 6722 |
{ |
| 6723 |
auto gpuContext = Linux_GetGpuContext(pOsInterface, pOsInterface->CurrentGpuContextHandle); |
| 6724 |
if(gpuContext != nullptr && gpuContext->GetI915Context(0) != nullptr) |
| 6725 |
{ |
| 6726 |
intel_i915_ctx = gpuContext->GetI915Context(0); |
| 6727 |
} |
| 6728 |
} |
| 6729 |
|
| 6730 |
dwResetCount = dwActiveBatch = dwPendingBatch = 0; |
| 6731 |
|
| 6732 |
ret = mos_get_reset_stats(intel_i915_ctx, &dwResetCount, |
| 6733 |
&dwActiveBatch, &dwPendingBatch); |
| 6734 |
if (ret) |
| 6735 |
{ |
| 6736 |
MOS_OS_NORMALMESSAGE("mos_get_reset_stats return error(%d)\n", ret); |
| 6737 |
goto finish; |
| 6738 |
} |
| 6739 |
|
| 6740 |
//Chip reset will count this value, but maybe caused by ctx in other process. |
| 6741 |
//In this case, reset has no impact on current process |
| 6742 |
if (dwResetCount != pOsInterface->dwGPUResetCount) |
| 6743 |
{ |
| 6744 |
pOsInterface->dwGPUResetCount = dwResetCount; |
| 6745 |
} |
| 6746 |
|
| 6747 |
//Thses two values are ctx specific, it must reset in current process if either changes |
| 6748 |
if (dwActiveBatch != pOsInterface->dwGPUActiveBatch || |
| 6749 |
dwPendingBatch != pOsInterface->dwGPUPendingBatch) |
| 6750 |
{ |
| 6751 |
pOsInterface->dwGPUActiveBatch = dwActiveBatch; |
| 6752 |
pOsInterface->dwGPUPendingBatch = dwPendingBatch; |
| 6753 |
bResult = true; |
| 6754 |
} |
| 6755 |
|
| 6756 |
finish: |
| 6757 |
return bResult; |
| 6758 |
} |
| 6759 |
|
| 6760 |
uint64_t Mos_Specific_GetAuxTableBaseAddr( |
| 6761 |
PMOS_INTERFACE osInterface) |
| 6762 |
{ |
| 6763 |
if (osInterface == nullptr) |
| 6764 |
{ |
| 6765 |
MOS_OS_NORMALMESSAGE("Invalid osInterface"); |
| 6766 |
return 0; |
| 6767 |
} |
| 6768 |
if(osInterface->apoMosEnabled) |
| 6769 |
{ |
| 6770 |
return MosInterface::GetAuxTableBaseAddr(osInterface->osStreamState); |
| 6771 |
} |
| 6772 |
|
| 6773 |
if (osInterface->osContextPtr == nullptr) |
| 6774 |
{ |
| 6775 |
MOS_OS_NORMALMESSAGE("Invalid osInterface"); |
| 6776 |
return 0; |
| 6777 |
} |
| 6778 |
auto osCtx = static_cast<OsContextSpecific *>(osInterface->osContextPtr); |
| 6779 |
AuxTableMgr *auxTableMgr = osCtx->GetAuxTableMgr(); |
| 6780 |
|
| 6781 |
return auxTableMgr ? auxTableMgr->GetAuxTableBase() : 0; |
| 6782 |
} |
| 6783 |
|
| 6784 |
//! |
| 6785 |
//! \brief Get gpu context priority from KMD |
| 6786 |
//! \param [in] pOsInterface |
| 6787 |
//! Pointer to OS interface |
| 6788 |
//! \param [out] pPriority |
| 6789 |
//! the priority of the current context. |
| 6790 |
//! |
| 6791 |
void Mos_Specific_GetGpuPriority( |
| 6792 |
PMOS_INTERFACE pOsInterface, |
| 6793 |
int32_t* pPriority) |
| 6794 |
{ |
| 6795 |
MOS_OS_ASSERT(pOsInterface); |
| 6796 |
|
| 6797 |
if (pOsInterface->apoMosEnabled) |
| 6798 |
{ |
| 6799 |
return MosInterface::GetGpuPriority(pOsInterface->osStreamState, pPriority); |
| 6800 |
} |
| 6801 |
|
| 6802 |
if (pOsInterface->osContextPtr) |
| 6803 |
{ |
| 6804 |
auto osCxtSpecific = static_cast<OsContextSpecific*>(pOsInterface->osContextPtr); |
| 6805 |
osCxtSpecific->GetGpuPriority(pPriority); |
| 6806 |
} |
| 6807 |
else |
| 6808 |
{ |
| 6809 |
MOS_OS_ASSERTMESSAGE("OS context is nullptr."); |
| 6810 |
} |
| 6811 |
} |
| 6812 |
|
| 6813 |
//! |
| 6814 |
//! \brief Set gpu priority to KMD |
| 6815 |
//! \param [in] pOsInterface |
| 6816 |
//! Pointer to OS interface |
| 6817 |
//! \param [in] priority |
| 6818 |
//! the priority set to current context. |
| 6819 |
//! |
| 6820 |
void Mos_Specific_SetGpuPriority( |
| 6821 |
PMOS_INTERFACE pOsInterface, |
| 6822 |
int32_t priority) |
| 6823 |
{ |
| 6824 |
MOS_OS_ASSERT(pOsInterface); |
| 6825 |
|
| 6826 |
if (pOsInterface->apoMosEnabled) |
| 6827 |
{ |
| 6828 |
return MosInterface::SetGpuPriority(pOsInterface->osStreamState, priority); |
| 6829 |
} |
| 6830 |
|
| 6831 |
if (pOsInterface->osContextPtr) |
| 6832 |
{ |
| 6833 |
auto osCxtSpecific = static_cast<OsContextSpecific*>(pOsInterface->osContextPtr); |
| 6834 |
osCxtSpecific->SetGpuPriority(priority); |
| 6835 |
} |
| 6836 |
else |
| 6837 |
{ |
| 6838 |
MOS_OS_ASSERTMESSAGE("OS context is nullptr."); |
| 6839 |
} |
| 6840 |
} |
| 6841 |
|
| 6842 |
//! |
| 6843 |
//! \brief Set slice count to shared memory and KMD |
| 6844 |
//! \param [in] pOsInterface |
| 6845 |
//! Pointer to OS interface |
| 6846 |
//! \param [in,out] pSliceCount |
| 6847 |
//! Pointer to the slice count. Input the slice count for current |
| 6848 |
//! context, output the ruling slice count shared by all contexts. |
| 6849 |
//! |
| 6850 |
void Mos_Specific_SetSliceCount( |
| 6851 |
PMOS_INTERFACE pOsInterface, |
| 6852 |
uint32_t *pSliceCount) |
| 6853 |
{ |
| 6854 |
MOS_OS_ASSERT(pOsInterface); |
| 6855 |
MOS_OS_ASSERT(pSliceCount); |
| 6856 |
|
| 6857 |
if (pOsInterface->osContextPtr) |
| 6858 |
{ |
| 6859 |
pOsInterface->osContextPtr->SetSliceCount(pSliceCount); |
| 6860 |
} |
| 6861 |
else |
| 6862 |
{ |
| 6863 |
MOS_OS_ASSERTMESSAGE("OS context is nullptr."); |
| 6864 |
} |
| 6865 |
} |
| 6866 |
|
| 6867 |
void Mos_Specific_NotifyStreamIndexSharing( |
| 6868 |
PMOS_INTERFACE pOsInterface) |
| 6869 |
{ |
| 6870 |
MOS_UNUSED(pOsInterface); |
| 6871 |
} |
| 6872 |
|
| 6873 |
MOS_STATUS Mos_Specific_CheckVirtualEngineSupported( |
| 6874 |
PMOS_INTERFACE osInterface) |
| 6875 |
{ |
| 6876 |
MOS_OS_CHK_NULL_RETURN(osInterface); |
| 6877 |
|
| 6878 |
auto skuTable = osInterface->pfnGetSkuTable(osInterface); |
| 6879 |
MOS_OS_CHK_NULL_RETURN(skuTable); |
| 6880 |
if (MEDIA_IS_SKU(skuTable, FtrContextBasedScheduling)) |
| 6881 |
{ |
| 6882 |
osInterface->bSupportVirtualEngine = true; |
| 6883 |
} |
| 6884 |
else |
| 6885 |
{ |
| 6886 |
osInterface->bSupportVirtualEngine = false; |
| 6887 |
} |
| 6888 |
|
| 6889 |
return MOS_STATUS_SUCCESS; |
| 6890 |
} |
| 6891 |
|
| 6892 |
MediaUserSettingSharedPtr Mos_Specific_GetUserSettingInstance( |
| 6893 |
PMOS_INTERFACE osInterface) |
| 6894 |
{ |
| 6895 |
MOS_OS_FUNCTION_ENTER; |
| 6896 |
if (!osInterface) |
| 6897 |
{ |
| 6898 |
MOS_OS_ASSERTMESSAGE("Invalid osInterface ptr"); |
| 6899 |
return nullptr; |
| 6900 |
} |
| 6901 |
|
| 6902 |
if (osInterface->apoMosEnabled) |
| 6903 |
{ |
| 6904 |
return MosInterface::MosGetUserSettingInstance(osInterface->osStreamState); |
| 6905 |
} |
| 6906 |
return MosInterface::MosGetUserSettingInstance(osInterface->pOsContext); |
| 6907 |
} |
| 6908 |
|
| 6909 |
static MOS_STATUS Mos_Specific_InitInterface_Ve( |
| 6910 |
PMOS_INTERFACE osInterface) |
| 6911 |
{ |
| 6912 |
PLATFORM Platform; |
| 6913 |
MOS_STATUS eStatus; |
| 6914 |
MOS_STATUS eStatusUserFeature; |
| 6915 |
uint32_t regValue = 0; |
| 6916 |
MediaUserSettingSharedPtr userSettingPtr = nullptr; |
| 6917 |
|
| 6918 |
MOS_OS_FUNCTION_ENTER; |
| 6919 |
|
| 6920 |
eStatus = MOS_STATUS_SUCCESS; |
| 6921 |
eStatusUserFeature = MOS_STATUS_SUCCESS; |
| 6922 |
|
| 6923 |
MOS_OS_CHK_NULL_RETURN(osInterface); |
| 6924 |
userSettingPtr = osInterface->pfnGetUserSettingInstance(osInterface); |
| 6925 |
|
| 6926 |
// Get platform information |
| 6927 |
memset(&Platform, 0, sizeof(PLATFORM)); |
| 6928 |
if (!Mos_Solo_IsEnabled(nullptr)) |
| 6929 |
{ |
| 6930 |
osInterface->pfnGetPlatform(osInterface, &Platform); |
| 6931 |
} |
| 6932 |
|
| 6933 |
if (GFX_IS_GEN_11_OR_LATER(Platform) || Mos_Solo_IsEnabled(nullptr)) |
| 6934 |
{ |
| 6935 |
//keep this as false until VE is enabled by all media components |
| 6936 |
osInterface->bSupportVirtualEngine = false; |
| 6937 |
osInterface->bUseHwSemaForResSyncInVE = false; |
| 6938 |
osInterface->pVEInterf = nullptr; |
| 6939 |
osInterface->VEEnable = false; |
| 6940 |
|
| 6941 |
auto skuTable = osInterface->pfnGetSkuTable(osInterface); |
| 6942 |
MOS_OS_CHK_NULL_RETURN(skuTable); |
| 6943 |
if (MEDIA_IS_SKU(skuTable, FtrGucSubmission)) |
| 6944 |
{ |
| 6945 |
osInterface->bParallelSubmission = true; |
| 6946 |
} |
| 6947 |
|
| 6948 |
//Read Scalable/Legacy Decode mode on Gen11+ |
| 6949 |
//1:by default for scalable decode mode |
| 6950 |
//0:for legacy decode mode |
| 6951 |
regValue = 0; |
| 6952 |
eStatusUserFeature = ReadUserSetting( |
| 6953 |
userSettingPtr, |
| 6954 |
regValue, |
| 6955 |
__MEDIA_USER_FEATURE_VALUE_ENABLE_HCP_SCALABILITY_DECODE, |
| 6956 |
MediaUserSetting::Group::Device); |
| 6957 |
|
| 6958 |
osInterface->bHcpDecScalabilityMode = regValue ? MOS_SCALABILITY_ENABLE_MODE_DEFAULT : MOS_SCALABILITY_ENABLE_MODE_FALSE; |
| 6959 |
if(osInterface->bHcpDecScalabilityMode |
| 6960 |
&& (eStatusUserFeature == MOS_STATUS_SUCCESS)) |
| 6961 |
{ |
| 6962 |
//user's value to enable scalability |
| 6963 |
osInterface->bHcpDecScalabilityMode = MOS_SCALABILITY_ENABLE_MODE_USER_FORCE; |
| 6964 |
} |
| 6965 |
|
| 6966 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 6967 |
osInterface->frameSplit = false; |
| 6968 |
ReadUserSetting( |
| 6969 |
userSettingPtr, |
| 6970 |
osInterface->frameSplit, |
| 6971 |
__MEDIA_USER_FEATURE_VALUE_ENABLE_LINUX_FRAME_SPLIT, |
| 6972 |
MediaUserSetting::Group::Device); |
| 6973 |
|
| 6974 |
regValue = 0; |
| 6975 |
ReadUserSettingForDebug( |
| 6976 |
userSettingPtr, |
| 6977 |
regValue, |
| 6978 |
__MEDIA_USER_FEATURE_VALUE_ENABLE_GUC_SUBMISSION, |
| 6979 |
MediaUserSetting::Group::Device); |
| 6980 |
osInterface->bParallelSubmission = osInterface->bParallelSubmission && regValue; |
| 6981 |
|
| 6982 |
// read the "Force VEBOX" user feature key |
| 6983 |
// 0: not force |
| 6984 |
regValue = 0; |
| 6985 |
ReadUserSettingForDebug( |
| 6986 |
userSettingPtr, |
| 6987 |
regValue, |
| 6988 |
__MEDIA_USER_FEATURE_VALUE_FORCE_VEBOX, |
| 6989 |
MediaUserSetting::Group::Device); |
| 6990 |
osInterface->eForceVebox = (MOS_FORCE_VEBOX)regValue; |
| 6991 |
|
| 6992 |
//KMD Virtual Engine DebugOverride |
| 6993 |
// 0: not Override |
| 6994 |
ReadUserSettingForDebug( |
| 6995 |
userSettingPtr, |
| 6996 |
osInterface->bEnableDbgOvrdInVE, |
| 6997 |
__MEDIA_USER_FEATURE_VALUE_ENABLE_VE_DEBUG_OVERRIDE, |
| 6998 |
MediaUserSetting::Group::Device); |
| 6999 |
#endif |
| 7000 |
|
| 7001 |
// UMD Vebox Virtual Engine Scalability Mode |
| 7002 |
// 0: disable. can set to 1 only when KMD VE is enabled. |
| 7003 |
regValue = 0; |
| 7004 |
eStatusUserFeature = ReadUserSetting( |
| 7005 |
userSettingPtr, |
| 7006 |
regValue, |
| 7007 |
__MEDIA_USER_FEATURE_VALUE_ENABLE_VEBOX_SCALABILITY_MODE, |
| 7008 |
MediaUserSetting::Group::Device); |
| 7009 |
|
| 7010 |
osInterface->bVeboxScalabilityMode = regValue ? MOS_SCALABILITY_ENABLE_MODE_DEFAULT : MOS_SCALABILITY_ENABLE_MODE_FALSE; |
| 7011 |
|
| 7012 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 7013 |
if(osInterface->bVeboxScalabilityMode |
| 7014 |
&& (eStatusUserFeature == MOS_STATUS_SUCCESS)) |
| 7015 |
{ |
| 7016 |
//user's value to enable scalability |
| 7017 |
osInterface->bVeboxScalabilityMode = MOS_SCALABILITY_ENABLE_MODE_USER_FORCE; |
| 7018 |
|
| 7019 |
if (osInterface->eForceVebox == MOS_FORCE_VEBOX_NONE) |
| 7020 |
{ |
| 7021 |
osInterface->eForceVebox = MOS_FORCE_VEBOX_1_2; |
| 7022 |
} |
| 7023 |
} |
| 7024 |
else if ((!osInterface->bVeboxScalabilityMode) |
| 7025 |
&& (eStatusUserFeature == MOS_STATUS_SUCCESS)) |
| 7026 |
{ |
| 7027 |
osInterface->eForceVebox = MOS_FORCE_VEBOX_NONE; |
| 7028 |
} |
| 7029 |
|
| 7030 |
// read the "Force VEBOX" user feature key |
| 7031 |
// 0: not force |
| 7032 |
regValue = 0; |
| 7033 |
ReadUserSettingForDebug( |
| 7034 |
userSettingPtr, |
| 7035 |
regValue, |
| 7036 |
__MEDIA_USER_FEATURE_VALUE_FORCE_VEBOX, |
| 7037 |
MediaUserSetting::Group::Device); |
| 7038 |
osInterface->eForceVebox = (MOS_FORCE_VEBOX)regValue; |
| 7039 |
#endif |
| 7040 |
} |
| 7041 |
|
| 7042 |
return eStatus; |
| 7043 |
} |
| 7044 |
|
| 7045 |
bool Mos_Specific_IsMismatchOrderProgrammingSupported() |
| 7046 |
{ |
| 7047 |
return MosInterface::IsMismatchOrderProgrammingSupported(); |
| 7048 |
} |
| 7049 |
|
| 7050 |
bool Mos_Specific_pfnIsMultipleCodecDevicesInUse( |
| 7051 |
PMOS_INTERFACE pOsInterface) |
| 7052 |
{ |
| 7053 |
MOS_OS_FUNCTION_ENTER; |
| 7054 |
|
| 7055 |
return false; |
| 7056 |
} |
| 7057 |
|
| 7058 |
MOS_STATUS Mos_Specific_pfnSetMultiEngineEnabled( |
| 7059 |
PMOS_INTERFACE pOsInterface, |
| 7060 |
MOS_COMPONENT component, |
| 7061 |
bool enabled) |
| 7062 |
{ |
| 7063 |
MOS_OS_FUNCTION_ENTER; |
| 7064 |
|
| 7065 |
return MOS_STATUS_SUCCESS; |
| 7066 |
} |
| 7067 |
|
| 7068 |
MOS_STATUS Mos_Specific_pfnGetMultiEngineStatus( |
| 7069 |
PMOS_INTERFACE pOsInterface, |
| 7070 |
PLATFORM *platform, |
| 7071 |
MOS_COMPONENT component, |
| 7072 |
bool &isMultiDevices, |
| 7073 |
bool &isMultiEngine) |
| 7074 |
{ |
| 7075 |
MOS_OS_FUNCTION_ENTER; |
| 7076 |
|
| 7077 |
return MOS_STATUS_SUCCESS; |
| 7078 |
} |
| 7079 |
|
| 7080 |
MOS_GPU_NODE Mos_Specific_pfnGetLatestVirtualNode( |
| 7081 |
PMOS_INTERFACE pOsInterface, |
| 7082 |
MOS_COMPONENT component) |
| 7083 |
{ |
| 7084 |
MOS_OS_FUNCTION_ENTER; |
| 7085 |
|
| 7086 |
return MOS_GPU_NODE_MAX; |
| 7087 |
} |
| 7088 |
|
| 7089 |
void Mos_Specific_pfnSetLatestVirtualNode( |
| 7090 |
PMOS_INTERFACE pOsInterface, |
| 7091 |
MOS_GPU_NODE node) |
| 7092 |
{ |
| 7093 |
MOS_OS_FUNCTION_ENTER; |
| 7094 |
} |
| 7095 |
|
| 7096 |
MOS_GPU_NODE Mos_Specific_pfnGetDecoderVirtualNodePerStream( |
| 7097 |
PMOS_INTERFACE pOsInterface) |
| 7098 |
{ |
| 7099 |
MOS_OS_FUNCTION_ENTER; |
| 7100 |
|
| 7101 |
return MOS_GPU_NODE_MAX; |
| 7102 |
} |
| 7103 |
|
| 7104 |
void Mos_Specific_pfnSetDecoderVirtualNodePerStream( |
| 7105 |
PMOS_INTERFACE pOsInterface, |
| 7106 |
MOS_GPU_NODE node) |
| 7107 |
{ |
| 7108 |
MOS_OS_FUNCTION_ENTER; |
| 7109 |
} |
| 7110 |
|
| 7111 |
bool Mos_Specific_IsAsyncDevice(PMOS_INTERFACE pOsInterface) |
| 7112 |
{ |
| 7113 |
return false; |
| 7114 |
} |
| 7115 |
|
| 7116 |
bool Mos_Specific_IsGpuSyncByCmd( |
| 7117 |
PMOS_INTERFACE osInterface, |
| 7118 |
GPU_CONTEXT_HANDLE gpuContextHandle) |
| 7119 |
{ |
| 7120 |
return false; |
| 7121 |
} |
| 7122 |
|
| 7123 |
void Mos_Specific_OnNativeFenceSyncBBAdded(PMOS_COMMAND_BUFFER pCmdBuffer, uint64_t gfxAddr) |
| 7124 |
{ |
| 7125 |
} |
| 7126 |
|
| 7127 |
void Mos_Specific_DisableNativeFenceSyncByCmd( |
| 7128 |
PMOS_INTERFACE osInterface, |
| 7129 |
GPU_CONTEXT_HANDLE gpuContextHandle) |
| 7130 |
{ |
| 7131 |
} |
| 7132 |
|
| 7133 |
//! \brief Unified OS Initializes OS Linux Interface |
| 7134 |
//! \details Linux OS Interface initilization |
| 7135 |
//! \param PMOS_INTERFACE pOsInterface |
| 7136 |
//! [in] Pointer to OS Interface |
| 7137 |
//! \param PMOS_CONTEXT pOsDriverContext |
| 7138 |
//! [in] Pointer to Driver context |
| 7139 |
//! \return MOS_STATUS |
| 7140 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 7141 |
//! |
| 7142 |
MOS_STATUS Mos_Specific_InitInterface( |
| 7143 |
PMOS_INTERFACE pOsInterface, |
| 7144 |
PMOS_CONTEXT pOsDriverContext) |
| 7145 |
{ |
| 7146 |
PMOS_OS_CONTEXT pOsContext = nullptr; |
| 7147 |
PMOS_USER_FEATURE_INTERFACE pOsUserFeatureInterface = nullptr; |
| 7148 |
MOS_STATUS eStatus = MOS_STATUS_UNKNOWN; |
| 7149 |
MediaFeatureTable *pSkuTable = nullptr; |
| 7150 |
uint32_t dwResetCount = 0; |
| 7151 |
int32_t ret = 0; |
| 7152 |
bool modularizedGpuCtxEnabled = false; |
| 7153 |
MediaUserSettingSharedPtr userSettingPtr = nullptr; |
| 7154 |
bool bSimIsActive = false; |
| 7155 |
bool useCustomerValue = false; |
| 7156 |
uint32_t regValue = 0; |
| 7157 |
char *pMediaWatchdog = nullptr; |
| 7158 |
long int watchdog = 0; |
| 7159 |
|
| 7160 |
MOS_OS_FUNCTION_ENTER; |
| 7161 |
|
| 7162 |
MOS_OS_CHK_NULL(pOsInterface); |
| 7163 |
MOS_OS_CHK_NULL(pOsDriverContext); |
| 7164 |
|
| 7165 |
userSettingPtr = pOsDriverContext->m_userSettingPtr; |
| 7166 |
|
| 7167 |
// Initialize OS interface functions |
| 7168 |
pOsInterface->pfnSetGpuContext = Mos_Specific_SetGpuContext; |
| 7169 |
pOsInterface->pfnSetGpuContextFromHandle = Mos_Specific_SetGpuContextFromHandle; |
| 7170 |
pOsInterface->pfnGetGpuContext = Mos_Specific_GetGpuContext; |
| 7171 |
pOsInterface->pfnSetEncodePakContext = Mos_Specific_SetEncodePakContext; |
| 7172 |
pOsInterface->pfnSetEncodeEncContext = Mos_Specific_SetEncodeEncContext; |
| 7173 |
pOsInterface->pfnGetGmmClientContext = Mos_Specific_GetGmmClientContext; |
| 7174 |
|
| 7175 |
pOsInterface->pfnGetPlatform = Mos_Specific_GetPlatform; |
| 7176 |
pOsInterface->pfnDestroy = Mos_Specific_Destroy; |
| 7177 |
pOsInterface->pfnGetSkuTable = Mos_Specific_GetSkuTable; |
| 7178 |
pOsInterface->pfnGetWaTable = Mos_Specific_GetWaTable; |
| 7179 |
pOsInterface->pfnGetGtSystemInfo = Mos_Specific_GetGtSystemInfo; |
| 7180 |
pOsInterface->pfnGetMediaEngineInfo = Mos_Specific_GetMediaEngineInfo; |
| 7181 |
pOsInterface->pfnResetOsStates = Mos_Specific_ResetOsStates; |
| 7182 |
pOsInterface->pfnAllocateResource = Mos_Specific_AllocateResource; |
| 7183 |
pOsInterface->pfnGetResourceInfo = Mos_Specific_GetResourceInfo; |
| 7184 |
pOsInterface->pfnFreeResource = Mos_Specific_FreeResource; |
| 7185 |
pOsInterface->pfnFreeResourceWithFlag = Mos_Specific_FreeResourceWithFlag; |
| 7186 |
pOsInterface->pfnLockSyncRequest = Mos_Specific_LockSyncRequest; |
| 7187 |
pOsInterface->pfnLockResource = Mos_Specific_LockResource; |
| 7188 |
pOsInterface->pfnUnlockResource = Mos_Specific_UnlockResource; |
| 7189 |
pOsInterface->pfnDecompResource = Mos_Specific_DecompResource; |
| 7190 |
pOsInterface->pfnSetDecompSyncRes = Mos_Specific_SetDecompSyncRes; |
| 7191 |
pOsInterface->pfnDoubleBufferCopyResource = Mos_Specific_DoubleBufferCopyResource; |
| 7192 |
pOsInterface->pfnMediaCopyResource2D = Mos_Specific_MediaCopyResource2D; |
| 7193 |
pOsInterface->pfnMonoSurfaceCopy = Mos_Specific_MonoSurfaceCopy; |
| 7194 |
pOsInterface->pfnGetMosContext = Mos_Specific_GetMosContext; |
| 7195 |
pOsInterface->pfnUpdateResourceUsageType = Mos_Specific_UpdateResourceUsageType; |
| 7196 |
pOsInterface->pfnRegisterResource = Mos_Specific_RegisterResource; |
| 7197 |
pOsInterface->pfnResetResourceAllocationIndex = Mos_Specific_ResetResourceAllocationIndex; |
| 7198 |
pOsInterface->pfnGetResourceAllocationIndex = Mos_Specific_GetResourceAllocationIndex; |
| 7199 |
pOsInterface->pfnGetResourceGfxAddress = Mos_Specific_GetResourceGfxAddress; |
| 7200 |
pOsInterface->pfnGetResourceClearAddress = Mos_Specific_GetResourceClearAddress; |
| 7201 |
pOsInterface->pfnGetCommandBuffer = Mos_Specific_GetCommandBuffer; |
| 7202 |
pOsInterface->pfnResetCommandBuffer = Mos_Specific_ResetCommandBuffer; |
| 7203 |
pOsInterface->pfnReturnCommandBuffer = Mos_Specific_ReturnCommandBuffer; |
| 7204 |
pOsInterface->pfnSubmitCommandBuffer = Mos_Specific_SubmitCommandBuffer; |
| 7205 |
pOsInterface->pfnWaitAndReleaseCmdBuffer = Mos_Specific_WaitAndReleaseCmdBuffer; |
| 7206 |
pOsInterface->pfnVerifyCommandBufferSize = Mos_Specific_VerifyCommandBufferSize; |
| 7207 |
pOsInterface->pfnResizeCommandBufferAndPatchList = Mos_Specific_ResizeCommandBufferAndPatchList; |
| 7208 |
pOsInterface->pfnSetPerfTag = Mos_Specific_SetPerfTag; |
| 7209 |
pOsInterface->pfnResetPerfBufferID = Mos_Specific_ResetPerfBufferID; |
| 7210 |
pOsInterface->pfnIncPerfFrameID = Mos_Specific_IncPerfFrameID; |
| 7211 |
pOsInterface->pfnIncPerfBufferID = Mos_Specific_IncPerfBufferID; |
| 7212 |
pOsInterface->pfnGetPerfTag = Mos_Specific_GetPerfTag; |
| 7213 |
pOsInterface->pfnSetPerfHybridKernelID = Mos_Specific_SetPerfHybridKernelID; |
| 7214 |
pOsInterface->pfnIsPerfTagSet = Mos_Specific_IsPerfTagSet; |
| 7215 |
pOsInterface->pfnSetIndirectStateSize = Mos_Specific_SetIndirectStateSize; |
| 7216 |
pOsInterface->pfnGetIndirectState = Mos_Specific_GetIndirectState; |
| 7217 |
pOsInterface->pfnGetIndirectStatePointer = Mos_Specific_GetIndirectStatePointer; |
| 7218 |
pOsInterface->pfnSetPatchEntry = Mos_Specific_SetPatchEntry; |
| 7219 |
pOsInterface->pfnGetInterfaceVersion = Mos_Specific_GetInterfaceVersion; |
| 7220 |
|
| 7221 |
pOsInterface->pfnLoadLibrary = Mos_Specific_LoadLibrary; |
| 7222 |
pOsInterface->pfnFreeLibrary = Mos_Specific_FreeLibrary; |
| 7223 |
pOsInterface->pfnCheckVirtualEngineSupported = Mos_Specific_CheckVirtualEngineSupported; |
| 7224 |
|
| 7225 |
//GPU context and synchronization functions |
| 7226 |
pOsInterface->pfnCreateGpuContext = Mos_Specific_CreateGpuContext; |
| 7227 |
pOsInterface->pfnCreateGpuComputeContext = Mos_Specific_CreateGpuComputeContext; |
| 7228 |
pOsInterface->pfnDestroyGpuContext = Mos_Specific_DestroyGpuContext; |
| 7229 |
pOsInterface->pfnDestroyGpuContextByHandle = Mos_Specific_DestroyGpuContextByHandle; |
| 7230 |
pOsInterface->pfnDestroyGpuComputeContext = Mos_Specific_DestroyGpuComputeContext; |
| 7231 |
pOsInterface->pfnIsGpuContextValid = Mos_Specific_IsGpuContextValid; |
| 7232 |
pOsInterface->pfnSyncOnResource = Mos_Specific_SyncOnResource; |
| 7233 |
pOsInterface->pfnSyncGpuContext = Mos_Specific_SyncGpuContext; |
| 7234 |
pOsInterface->pfnGetGpuStatusBufferResource = Mos_Specific_GetGpuStatusBufferResource; |
| 7235 |
pOsInterface->pfnGetGpuStatusTagOffset = Mos_Specific_GetGpuStatusTagOffset; |
| 7236 |
pOsInterface->pfnGetGpuStatusTag = Mos_Specific_GetGpuStatusTag; |
| 7237 |
pOsInterface->pfnIncrementGpuStatusTag = Mos_Specific_IncrementGpuStatusTag; |
| 7238 |
pOsInterface->pfnGetGpuStatusSyncTag = Mos_Specific_GetGpuStatusSyncTag; |
| 7239 |
pOsInterface->pfnSetResourceSyncTag = Mos_Specific_SetResourceSyncTag; |
| 7240 |
pOsInterface->pfnPerformOverlaySync = Mos_Specific_PerformOverlaySync; |
| 7241 |
pOsInterface->pfnEngineSignal = Mos_Specific_EngineSignal; |
| 7242 |
pOsInterface->pfnEngineWait = Mos_Specific_EngineWait; |
| 7243 |
pOsInterface->pfnWaitAllCmdCompletion = Mos_Specific_WaitAllCmdCompletion_Os; |
| 7244 |
pOsInterface->pfnResourceSignal = Mos_Specific_ResourceSignal; |
| 7245 |
pOsInterface->pfnResourceWait = Mos_Specific_ResourceWait; |
| 7246 |
pOsInterface->pfnCreateSyncResource = Mos_Specific_CreateSyncResource; |
| 7247 |
pOsInterface->pfnDestroySyncResource = Mos_Specific_DestroySyncResource; |
| 7248 |
pOsInterface->pfnInitializeMultiThreadingSyncTags = Mos_Specific_InitializeMultiThreadingSyncTags; |
| 7249 |
pOsInterface->pfnMultiThreadingWaitCurrentFrame = Mos_Specific_MultiThreadingWaitCurrentFrame; |
| 7250 |
pOsInterface->pfnMultiThreadingPostCurrentFrame = Mos_Specific_MultiThreadingPostCurrentFrame; |
| 7251 |
pOsInterface->pfnSetHybridDecoderRunningFlag = Mos_Specific_SetHybridDecoderRunningFlag; |
| 7252 |
pOsInterface->pfnGetHybridDecoderRunningFlag = Mos_Specific_GetHybridDecoderRunningFlag; |
| 7253 |
pOsInterface->pfnMultiThreadResourceSync = Mos_Specific_MultiThreadResourceSync; |
| 7254 |
|
| 7255 |
pOsInterface->pfnCachePolicyGetMemoryObject = Mos_Specific_CachePolicyGetMemoryObject; |
| 7256 |
pOsInterface->pfnVerifyPatchListSize = Mos_Specific_VerifyPatchListSize; |
| 7257 |
pOsInterface->pfnGetMemoryCompressionMode = Mos_Specific_GetMemoryCompressionMode; |
| 7258 |
pOsInterface->pfnSetMemoryCompressionMode = Mos_Specific_SetMemoryCompressionMode; |
| 7259 |
pOsInterface->pfnSetMemoryCompressionHint = Mos_Specific_SetMemoryCompressionHint; |
| 7260 |
pOsInterface->pfnGetMemoryCompressionFormat = Mos_Specific_GetMemoryCompressionFormat; |
| 7261 |
pOsInterface->pfnCreateVideoNodeAssociation = Mos_Specific_CreateVideoNodeAssociation; |
| 7262 |
pOsInterface->pfnDestroyVideoNodeAssociation = Mos_Specific_DestroyVideoNodeAssociation; |
| 7263 |
pOsInterface->pfnGetVdboxNodeId = Mos_Specific_GetVdboxNodeId; |
| 7264 |
|
| 7265 |
pOsInterface->pfnGetNullHWRenderFlags = Mos_Specific_GetNullHWRenderFlags; |
| 7266 |
pOsInterface->pfnSetCmdBufferDebugInfo = Mos_Specific_SetCmdBufferDebugInfo; |
| 7267 |
pOsInterface->pfnGetCmdBufferDebugInfo = Mos_Specific_GetCmdBufferDebugInfo; |
| 7268 |
|
| 7269 |
pOsInterface->pfnRegisterBBCompleteNotifyEvent = Mos_Specific_RegisterBBCompleteNotifyEvent; |
| 7270 |
pOsInterface->pfnWaitForBBCompleteNotifyEvent = Mos_Specific_WaitForBBCompleteNotifyEvent; |
| 7271 |
pOsInterface->pfnCachePolicyGetMemoryObject = Mos_Specific_CachePolicyGetMemoryObject; |
| 7272 |
pOsInterface->pfnCachePolicyGetL1Config = Mos_Specific_CachePolicyGetL1Config; |
| 7273 |
pOsInterface->pfnSkipResourceSync = Mos_Specific_SkipResourceSync; |
| 7274 |
pOsInterface->pfnIsGPUHung = Mos_Specific_IsGPUHung; |
| 7275 |
pOsInterface->pfnGetAuxTableBaseAddr = Mos_Specific_GetAuxTableBaseAddr; |
| 7276 |
pOsInterface->pfnSetSliceCount = Mos_Specific_SetSliceCount; |
| 7277 |
pOsInterface->pfnGetResourceIndex = Mos_Specific_GetResourceIndex; |
| 7278 |
pOsInterface->pfnGetGpuPriority = Mos_Specific_GetGpuPriority; |
| 7279 |
pOsInterface->pfnSetGpuPriority = Mos_Specific_SetGpuPriority; |
| 7280 |
pOsInterface->pfnIsSetMarkerEnabled = Mos_Specific_IsSetMarkerEnabled; |
| 7281 |
pOsInterface->pfnGetMarkerResource = Mos_Specific_GetMarkerResource; |
| 7282 |
pOsInterface->pfnNotifyStreamIndexSharing = Mos_Specific_NotifyStreamIndexSharing; |
| 7283 |
|
| 7284 |
pOsInterface->pfnSetGpuContextHandle = Mos_Specific_SetGpuContextHandle; |
| 7285 |
pOsInterface->pfnGetGpuContextbyHandle = Mos_Specific_GetGpuContextbyHandle; |
| 7286 |
|
| 7287 |
pOsInterface->pfnGetUserSettingInstance = Mos_Specific_GetUserSettingInstance; |
| 7288 |
|
| 7289 |
pOsInterface->pfnIsMismatchOrderProgrammingSupported = Mos_Specific_IsMismatchOrderProgrammingSupported; |
| 7290 |
pOsInterface->pfnIsMultipleCodecDevicesInUse = Mos_Specific_pfnIsMultipleCodecDevicesInUse; |
| 7291 |
pOsInterface->pfnSetMultiEngineEnabled = Mos_Specific_pfnSetMultiEngineEnabled; |
| 7292 |
pOsInterface->pfnGetMultiEngineStatus = Mos_Specific_pfnGetMultiEngineStatus; |
| 7293 |
pOsInterface->pfnGetLatestVirtualNode = Mos_Specific_pfnGetLatestVirtualNode; |
| 7294 |
pOsInterface->pfnSetLatestVirtualNode = Mos_Specific_pfnSetLatestVirtualNode; |
| 7295 |
pOsInterface->pfnGetDecoderVirtualNodePerStream = Mos_Specific_pfnGetDecoderVirtualNodePerStream; |
| 7296 |
pOsInterface->pfnSetDecoderVirtualNodePerStream = Mos_Specific_pfnSetDecoderVirtualNodePerStream; |
| 7297 |
|
| 7298 |
pOsInterface->pfnGetResType = GetResType; |
| 7299 |
pOsInterface->pfnGetTsFrequency = Mos_Specific_GetTsFrequency; |
| 7300 |
pOsInterface->pfnSetHintParams = Mos_Specific_SetHintParams; |
| 7301 |
pOsInterface->pfnIsResourceReleasable = Mos_Specific_IsResourceReleasable; |
| 7302 |
pOsInterface->pfnVirtualEngineInit = Mos_Specific_Virtual_Engine_Init; |
| 7303 |
pOsInterface->pfnDestroyVeInterface = Mos_Specific_DestroyVeInterface; |
| 7304 |
pOsInterface->pfnVirtualEngineInterfaceInitialize = Mos_VirtualEngineInterface_Initialize; |
| 7305 |
|
| 7306 |
pOsInterface->pfnCreateCmDevice = CreateCmDevice; |
| 7307 |
pOsInterface->pfnDestroyCmDevice = DestroyCmDevice; |
| 7308 |
pOsInterface->pfnInitCmInterface = InitCmOsDDIInterface; |
| 7309 |
|
| 7310 |
pOsInterface->pfnIsAsynDevice = Mos_Specific_IsAsyncDevice; |
| 7311 |
pOsInterface->pfnIsGpuSyncByCmd = Mos_Specific_IsGpuSyncByCmd; |
| 7312 |
pOsInterface->pfnOnNativeFenceSyncBBAdded = Mos_Specific_OnNativeFenceSyncBBAdded; |
| 7313 |
pOsInterface->pfnDisableNativeFenceSyncByCmd = Mos_Specific_DisableNativeFenceSyncByCmd; |
| 7314 |
|
| 7315 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 7316 |
pOsInterface->pfnGetEngineLogicId = Mos_Specific_GetEngineLogicId; |
| 7317 |
#endif |
| 7318 |
pOsContext = nullptr; |
| 7319 |
pOsUserFeatureInterface = (PMOS_USER_FEATURE_INTERFACE)&pOsInterface->UserFeatureInterface; |
| 7320 |
|
| 7321 |
MOS_OS_NORMALMESSAGE("mm:Mos_Specific_InitInterface called."); |
| 7322 |
|
| 7323 |
pOsInterface->modularizedGpuCtxEnabled = true; |
| 7324 |
pOsInterface->veDefaultEnable = true; |
| 7325 |
pOsInterface->phasedSubmission = true; |
| 7326 |
|
| 7327 |
pOsInterface->apoMosEnabled = pOsDriverContext->m_apoMosEnabled; |
| 7328 |
if (pOsInterface->apoMosEnabled) |
| 7329 |
{ |
| 7330 |
MOS_OS_CHK_NULL(pOsDriverContext->m_osDeviceContext); |
| 7331 |
pOsInterface->bNullHwIsEnabled = pOsDriverContext->m_osDeviceContext->GetNullHwIsEnabled(); |
| 7332 |
pOsInterface->streamStateIniter = true; |
| 7333 |
MOS_OS_CHK_STATUS(MosInterface::CreateOsStreamState( |
| 7334 |
&pOsInterface->osStreamState, |
| 7335 |
(MOS_DEVICE_HANDLE)pOsDriverContext->m_osDeviceContext, |
| 7336 |
(MOS_INTERFACE_HANDLE)pOsInterface, |
| 7337 |
pOsInterface->Component, |
| 7338 |
pOsDriverContext)); |
| 7339 |
|
| 7340 |
// Set interface functions for legacy HAL |
| 7341 |
pOsContext = (PMOS_OS_CONTEXT)pOsInterface->osStreamState->perStreamParameters; |
| 7342 |
MOS_OS_CHK_NULL_RETURN(pOsContext); |
| 7343 |
|
| 7344 |
pOsContext->GetGPUTag = Linux_GetGPUTag; |
| 7345 |
} |
| 7346 |
else |
| 7347 |
{ |
| 7348 |
// Create Linux OS Context |
| 7349 |
pOsContext = MOS_New(MOS_OS_CONTEXT); |
| 7350 |
MOS_OS_CHK_NULL_RETURN(pOsContext); |
| 7351 |
} |
| 7352 |
|
| 7353 |
if (pOsInterface->modulizedMosEnabled && !Mos_Solo_IsEnabled(nullptr)) |
| 7354 |
{ |
| 7355 |
OsContext *osContextPtr = OsContext::GetOsContextObject(); |
| 7356 |
if (osContextPtr == nullptr) |
| 7357 |
{ |
| 7358 |
MOS_OS_ASSERTMESSAGE("Unable to get the active OS context."); |
| 7359 |
eStatus = MOS_STATUS_INVALID_PARAMETER; |
| 7360 |
goto finish; |
| 7361 |
} |
| 7362 |
|
| 7363 |
pOsInterface->osContextPtr = osContextPtr; |
| 7364 |
|
| 7365 |
if (pOsInterface->osContextPtr->GetOsContextValid() == false) |
| 7366 |
{ |
| 7367 |
eStatus = pOsInterface->osContextPtr->Init(pOsDriverContext); |
| 7368 |
if (MOS_STATUS_SUCCESS != eStatus) |
| 7369 |
{ |
| 7370 |
MOS_OS_ASSERTMESSAGE("Unable to initialize MODS context."); |
| 7371 |
eStatus = MOS_STATUS_INVALID_PARAMETER; |
| 7372 |
goto finish; |
| 7373 |
} |
| 7374 |
} |
| 7375 |
|
| 7376 |
//ApoMos do it in CreateOsStreamState |
| 7377 |
if (!pOsInterface->apoMosEnabled) |
| 7378 |
{ |
| 7379 |
OsContextSpecific *pOsContextSpecific = static_cast<OsContextSpecific *>(pOsInterface->osContextPtr); |
| 7380 |
pOsContext->intel_context = pOsContextSpecific->GetDrmContext(); |
| 7381 |
pOsContext->pGmmClientContext = pOsDriverContext->pGmmClientContext; |
| 7382 |
} |
| 7383 |
} |
| 7384 |
else |
| 7385 |
{ |
| 7386 |
pOsContext->pGmmClientContext = pOsDriverContext->pGmmClientContext; |
| 7387 |
} |
| 7388 |
|
| 7389 |
#if MOS_MEDIASOLO_SUPPORTED |
| 7390 |
if (pOsInterface->bSoloInUse) |
| 7391 |
{ |
| 7392 |
bSimIsActive = pOsInterface->bSimIsActive; |
| 7393 |
useCustomerValue = true; |
| 7394 |
} |
| 7395 |
#endif |
| 7396 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 7397 |
ReadUserSettingForDebug( |
| 7398 |
userSettingPtr, |
| 7399 |
pOsInterface->bSimIsActive, |
| 7400 |
__MEDIA_USER_FEATURE_VALUE_SIM_ENABLE, |
| 7401 |
MediaUserSetting::Group::Device, |
| 7402 |
bSimIsActive, |
| 7403 |
useCustomerValue); |
| 7404 |
#endif |
| 7405 |
if (!pOsInterface->apoMosEnabled) |
| 7406 |
{ |
| 7407 |
pOsContext->bSimIsActive = pOsInterface->bSimIsActive; |
| 7408 |
} |
| 7409 |
|
| 7410 |
// Initialize |
| 7411 |
if (!pOsInterface->apoMosEnabled) |
| 7412 |
{ |
| 7413 |
modularizedGpuCtxEnabled = pOsInterface->modularizedGpuCtxEnabled && !Mos_Solo_IsEnabled(pOsContext); |
| 7414 |
eStatus = Linux_InitContext(pOsContext, pOsDriverContext, pOsInterface->modulizedMosEnabled && !Mos_Solo_IsEnabled(pOsContext), modularizedGpuCtxEnabled); |
| 7415 |
if( MOS_STATUS_SUCCESS != eStatus ) |
| 7416 |
{ |
| 7417 |
MOS_OS_ASSERTMESSAGE("Unable to initialize context."); |
| 7418 |
goto finish; |
| 7419 |
} |
| 7420 |
|
| 7421 |
pOsContext->bFreeContext = true; |
| 7422 |
|
| 7423 |
//Added by Ben for video memory allocation |
| 7424 |
pOsContext->bufmgr = pOsDriverContext->bufmgr; |
| 7425 |
mos_bufmgr_enable_reuse(pOsDriverContext->bufmgr); |
| 7426 |
} |
| 7427 |
|
| 7428 |
pOsInterface->pOsContext = pOsContext; |
| 7429 |
|
| 7430 |
pOsInterface->bUsesPatchList = true; |
| 7431 |
pOsInterface->bUsesGfxAddress = false; |
| 7432 |
pOsInterface->bNoParsingAssistanceInKmd = true; |
| 7433 |
pOsInterface->bUsesCmdBufHeaderInResize = false; |
| 7434 |
pOsInterface->bUsesCmdBufHeader = false; |
| 7435 |
pOsInterface->dwNumNalUnitBytesIncluded = MOS_NAL_UNIT_LENGTH - MOS_NAL_UNIT_STARTCODE_LENGTH; |
| 7436 |
|
| 7437 |
pOsInterface->bInlineCodecStatusUpdate = true; |
| 7438 |
pOsInterface->bAllowExtraPatchToSameLoc = false; |
| 7439 |
|
| 7440 |
pOsUserFeatureInterface->bIsNotificationSupported = false; |
| 7441 |
pOsUserFeatureInterface->pOsInterface = pOsInterface; |
| 7442 |
|
| 7443 |
pOsUserFeatureInterface->pfnEnableNotification = MosUtilities::MosUserFeatureEnableNotification; |
| 7444 |
pOsUserFeatureInterface->pfnDisableNotification = MosUtilities::MosUserFeatureDisableNotification; |
| 7445 |
pOsUserFeatureInterface->pfnParsePath = MosUtilities::MosUserFeatureParsePath; |
| 7446 |
|
| 7447 |
// Init reset count for the context |
| 7448 |
ret = mos_get_reset_stats(pOsInterface->pOsContext->intel_context, &dwResetCount, nullptr, nullptr); |
| 7449 |
if (ret) |
| 7450 |
{ |
| 7451 |
MOS_OS_NORMALMESSAGE("mos_get_reset_stats return error(%d)\n", ret); |
| 7452 |
dwResetCount = 0; |
| 7453 |
} |
| 7454 |
pOsInterface->dwGPUResetCount = dwResetCount; |
| 7455 |
pOsInterface->dwGPUActiveBatch = 0; |
| 7456 |
pOsInterface->dwGPUPendingBatch = 0; |
| 7457 |
|
| 7458 |
// enable it on Linux |
| 7459 |
pOsInterface->bMediaReset = true; |
| 7460 |
pOsInterface->trinityPath = TRINITY_DISABLED; |
| 7461 |
pOsInterface->umdMediaResetEnable = true; |
| 7462 |
|
| 7463 |
pMediaWatchdog = getenv("INTEL_MEDIA_RESET_WATCHDOG"); |
| 7464 |
if (pMediaWatchdog != nullptr) |
| 7465 |
{ |
| 7466 |
watchdog = strtol(pMediaWatchdog, nullptr, 0); |
| 7467 |
if (watchdog == 0) |
| 7468 |
{ |
| 7469 |
pOsInterface->bMediaReset = false; |
| 7470 |
pOsInterface->umdMediaResetEnable = false; |
| 7471 |
} |
| 7472 |
} |
| 7473 |
|
| 7474 |
// Check SKU table to detect if simulation environment (HAS) is enabled |
| 7475 |
pSkuTable = pOsInterface->pfnGetSkuTable(pOsInterface); |
| 7476 |
MOS_OS_CHK_NULL(pSkuTable); |
| 7477 |
|
| 7478 |
// disable Media Reset for non-xe platform who has no media reset support on Linux |
| 7479 |
if(!MEDIA_IS_SKU(pSkuTable, FtrSWMediaReset)) |
| 7480 |
{ |
| 7481 |
pOsInterface->bMediaReset = false; |
| 7482 |
pOsInterface->umdMediaResetEnable = false; |
| 7483 |
} |
| 7484 |
|
| 7485 |
pOsInterface->hybridCmdMgr = MOS_New(HybridCmdMgr); |
| 7486 |
if (pOsInterface->hybridCmdMgr == nullptr) |
| 7487 |
{ |
| 7488 |
MOS_OS_ASSERTMESSAGE("fail to create HybridCmdMgr."); |
| 7489 |
return MOS_STATUS_UNKNOWN; |
| 7490 |
} |
| 7491 |
|
| 7492 |
pOsInterface->npuInterface = MOS_New(L0NpuInterface, pOsInterface); |
| 7493 |
if (pOsInterface->npuInterface == nullptr) |
| 7494 |
{ |
| 7495 |
MOS_OS_ASSERTMESSAGE("fail to create level zerp npu interface."); |
| 7496 |
return MOS_STATUS_UNKNOWN; |
| 7497 |
} |
| 7498 |
|
| 7499 |
// initialize MOS_CP interface |
| 7500 |
pOsInterface->osCpInterface = Create_MosCpInterface(pOsInterface); |
| 7501 |
if (pOsInterface->osCpInterface == nullptr) |
| 7502 |
{ |
| 7503 |
MOS_OS_ASSERTMESSAGE("fail to create osCpInterface."); |
| 7504 |
return MOS_STATUS_UNKNOWN; |
| 7505 |
} |
| 7506 |
|
| 7507 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 7508 |
// read the "Force VDBOX" user feature key |
| 7509 |
// 0: not force |
| 7510 |
ReadUserSettingForDebug( |
| 7511 |
userSettingPtr, |
| 7512 |
pOsInterface->eForceVdbox, |
| 7513 |
__MEDIA_USER_FEATURE_VALUE_FORCE_VDBOX, |
| 7514 |
MediaUserSetting::Group::Device); |
| 7515 |
|
| 7516 |
// Force TileYf/Ys |
| 7517 |
// 0: Tile Y 1: Tile Yf 2 Tile Ys |
| 7518 |
ReadUserSettingForDebug( |
| 7519 |
userSettingPtr, |
| 7520 |
pOsInterface->dwForceTileYfYs, |
| 7521 |
__MEDIA_USER_FEATURE_VALUE_FORCE_YFYS, |
| 7522 |
MediaUserSetting::Group::Device); |
| 7523 |
|
| 7524 |
// Null HW Driver |
| 7525 |
// 0: Disable |
| 7526 |
ReadUserSettingForDebug( |
| 7527 |
userSettingPtr, |
| 7528 |
pOsInterface->NullHWAccelerationEnable.Value, |
| 7529 |
__MEDIA_USER_FEATURE_VALUE_NULL_HW_ACCELERATION_ENABLE, |
| 7530 |
MediaUserSetting::Group::Device); |
| 7531 |
|
| 7532 |
#endif // (_DEBUG || _RELEASE_INTERNAL) |
| 7533 |
|
| 7534 |
#if MOS_MEDIASOLO_SUPPORTED |
| 7535 |
Mos_Solo_Initialize(pOsInterface); |
| 7536 |
#endif // MOS_MEDIASOLO_SUPPORTED |
| 7537 |
if (!pOsInterface->apoMosEnabled) |
| 7538 |
{ |
| 7539 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 7540 |
// read the "Disable KMD Watchdog" user feature key |
| 7541 |
regValue = 0; |
| 7542 |
ReadUserSettingForDebug( |
| 7543 |
userSettingPtr, |
| 7544 |
regValue, |
| 7545 |
__MEDIA_USER_FEATURE_VALUE_DISABLE_KMD_WATCHDOG, |
| 7546 |
MediaUserSetting::Group::Device); |
| 7547 |
|
| 7548 |
pOsContext->bDisableKmdWatchdog = regValue ? true : false; |
| 7549 |
|
| 7550 |
// read "Linux PerformanceTag Enable" user feature key |
| 7551 |
regValue = 0; |
| 7552 |
ReadUserSettingForDebug( |
| 7553 |
userSettingPtr, |
| 7554 |
regValue, |
| 7555 |
__MEDIA_USER_FEATURE_VALUE_LINUX_PERFORMANCETAG_ENABLE, |
| 7556 |
MediaUserSetting::Group::Device); |
| 7557 |
|
| 7558 |
pOsContext->uEnablePerfTag = regValue; |
| 7559 |
#endif |
| 7560 |
} |
| 7561 |
eStatus = Mos_Specific_InitInterface_Ve(pOsInterface); |
| 7562 |
if(eStatus != MOS_STATUS_SUCCESS) |
| 7563 |
{ |
| 7564 |
goto finish; |
| 7565 |
} |
| 7566 |
|
| 7567 |
eStatus = MOS_STATUS_SUCCESS; |
| 7568 |
|
| 7569 |
finish: |
| 7570 |
if( MOS_STATUS_SUCCESS != eStatus && nullptr != pOsContext ) |
| 7571 |
{ |
| 7572 |
MOS_Delete(pOsContext); |
| 7573 |
} |
| 7574 |
if (MOS_STATUS_SUCCESS != eStatus) |
| 7575 |
{ |
| 7576 |
if (nullptr != pOsInterface->npuInterface) |
| 7577 |
{ |
| 7578 |
MOS_Delete(pOsInterface->npuInterface); |
| 7579 |
} |
| 7580 |
if (nullptr != pOsInterface->hybridCmdMgr) |
| 7581 |
{ |
| 7582 |
MOS_Delete(pOsInterface->hybridCmdMgr); |
| 7583 |
} |
| 7584 |
} |
| 7585 |
return eStatus; |
| 7586 |
} |
| 7587 |
|
| 7588 |
//! |
| 7589 |
//! \brief Convert to MOS tile type |
| 7590 |
//! \details Convert from Linux to MOS tile type |
| 7591 |
//! \param uint32_t type |
| 7592 |
//! [in] tile type |
| 7593 |
//! \return MOS_TILE_TYPE |
| 7594 |
//! Return MOS tile type |
| 7595 |
//! |
| 7596 |
MOS_TILE_TYPE LinuxToMosTileType(uint32_t type) |
| 7597 |
{ |
| 7598 |
switch (type) { |
| 7599 |
case TILING_NONE: |
| 7600 |
return MOS_TILE_LINEAR; |
| 7601 |
case TILING_X: |
| 7602 |
return MOS_TILE_X; |
| 7603 |
case TILING_Y: |
| 7604 |
return MOS_TILE_Y; |
| 7605 |
default: |
| 7606 |
return MOS_TILE_INVALID; |
| 7607 |
} |
| 7608 |
}; |
| 7609 |
|
| 7610 |
//! |
| 7611 |
//! \brief Get resource index |
| 7612 |
//! \details Get resource index of MOS_RESOURCE |
| 7613 |
//! \param PMOS_RESOURCE osResource |
| 7614 |
//! [in] Pointer to OS resource |
| 7615 |
//! \return uint32_t |
| 7616 |
//! Resource index |
| 7617 |
//! |
| 7618 |
uint32_t Mos_Specific_GetResourceIndex( |
| 7619 |
PMOS_RESOURCE osResource) |
| 7620 |
{ |
| 7621 |
return 0; |
| 7622 |
} |
| 7623 |
|
| 7624 |
uint32_t Mos_Specific_GetResourcePitch( |
| 7625 |
PMOS_RESOURCE pOsResource) |
| 7626 |
{ |
| 7627 |
MOS_OS_FUNCTION_ENTER; |
| 7628 |
|
| 7629 |
MOS_OS_ASSERT(pOsResource); |
| 7630 |
|
| 7631 |
return pOsResource->iPitch; |
| 7632 |
} |
| 7633 |
|
| 7634 |
void Mos_Specific_SetResourceWidth( |
| 7635 |
PMOS_RESOURCE pOsResource, |
| 7636 |
uint32_t dwWidth) |
| 7637 |
{ |
| 7638 |
MOS_OS_FUNCTION_ENTER; |
| 7639 |
|
| 7640 |
MOS_OS_ASSERT(pOsResource); |
| 7641 |
|
| 7642 |
pOsResource->iWidth = dwWidth; |
| 7643 |
} |
| 7644 |
|
| 7645 |
void Mos_Specific_SetResourceFormat( |
| 7646 |
PMOS_RESOURCE pOsResource, |
| 7647 |
MOS_FORMAT mosFormat) |
| 7648 |
{ |
| 7649 |
MOS_OS_FUNCTION_ENTER; |
| 7650 |
|
| 7651 |
MOS_OS_ASSERT(pOsResource); |
| 7652 |
|
| 7653 |
pOsResource->Format = mosFormat; |
| 7654 |
} |
| 7655 |
|
| 7656 |
//! |
| 7657 |
//! \brief Get SetMarker enabled flag |
| 7658 |
//! \details Get SetMarker enabled flag from OsInterface |
| 7659 |
//! \param PMOS_INTERFACE pOsInterface |
| 7660 |
//! [in] OS Interface |
| 7661 |
//! \return bool |
| 7662 |
//! SetMarker enabled flag |
| 7663 |
//! |
| 7664 |
bool Mos_Specific_IsSetMarkerEnabled( |
| 7665 |
PMOS_INTERFACE pOsInterface) |
| 7666 |
{ |
| 7667 |
return false; |
| 7668 |
} |
| 7669 |
|
| 7670 |
//! |
| 7671 |
//! \brief Get SetMarker resource address |
| 7672 |
//! \details Get SetMarker resource address from OsInterface |
| 7673 |
//! \param PMOS_INTERFACE pOsInterface |
| 7674 |
//! [in] OS Interface |
| 7675 |
//! \return PMOS_RESOURCE |
| 7676 |
//! SetMarker resource address |
| 7677 |
//! |
| 7678 |
PMOS_RESOURCE Mos_Specific_GetMarkerResource( |
| 7679 |
PMOS_INTERFACE pOsInterface) |
| 7680 |
{ |
| 7681 |
return 0; |
| 7682 |
} |
| 7683 |
|
| 7684 |
//! |
| 7685 |
//! \brief Get TimeStamp frequency base |
| 7686 |
//! \details Get TimeStamp frequency base from OsInterface |
| 7687 |
//! \param PMOS_INTERFACE pOsInterface |
| 7688 |
//! [in] OS Interface |
| 7689 |
//! \return uint32_t |
| 7690 |
//! time stamp frequency base |
| 7691 |
//! |
| 7692 |
uint32_t Mos_Specific_GetTsFrequency(PMOS_INTERFACE osInterface) |
| 7693 |
{ |
| 7694 |
uint32_t freq = 0; |
| 7695 |
int ret = mos_get_ts_frequency(osInterface->pOsContext->bufmgr, &freq); |
| 7696 |
if(ret == 0) |
| 7697 |
{ |
| 7698 |
return freq; |
| 7699 |
} |
| 7700 |
else |
| 7701 |
{ |
| 7702 |
// fail to query it from KMD |
| 7703 |
return 0; |
| 7704 |
} |
| 7705 |
} |
| 7706 |
|
| 7707 |
//! |
| 7708 |
//! \brief Checks whether the requested resource is releasable |
| 7709 |
//! \param PMOS_INTERFACE pOsInterface |
| 7710 |
//! [in] OS Interface |
| 7711 |
//! \param PMOS_RESOURCE pOsResource |
| 7712 |
//! [in] Pointer to OS Resource |
| 7713 |
//! \return MOS_STATUS |
| 7714 |
//! MOS_STATUS_SUCCESS if requested can be released, otherwise MOS_STATUS_UNKNOWN |
| 7715 |
//! |
| 7716 |
MOS_STATUS Mos_Specific_IsResourceReleasable( |
| 7717 |
PMOS_INTERFACE pOsInterface, |
| 7718 |
PMOS_RESOURCE pOsResource) |
| 7719 |
{ |
| 7720 |
return MOS_STATUS_SUCCESS; |
| 7721 |
} |
| 7722 |
|
| 7723 |
MOS_USER_FEATURE_KEY_PATH_INFO *Mos_GetDeviceUfPathInfo( |
| 7724 |
PMOS_CONTEXT mosContext) |
| 7725 |
{ |
| 7726 |
MOS_UNUSED(mosContext); |
| 7727 |
//NOT IMPLEMENTED |
| 7728 |
return nullptr; |
| 7729 |
} |
| 7730 |
|
| 7731 |
#if MOS_COMMAND_RESINFO_DUMP_SUPPORTED |
| 7732 |
struct GpuCmdResInfoDump::GpuCmdResInfo |
| 7733 |
{ |
| 7734 |
int32_t iWidth; |
| 7735 |
int32_t iHeight; |
| 7736 |
int32_t iSize; |
| 7737 |
int32_t iPitch; |
| 7738 |
int32_t iDepth; |
| 7739 |
MOS_FORMAT Format; |
| 7740 |
int32_t iCount; |
| 7741 |
int32_t iAllocationIndex[MOS_GPU_CONTEXT_MAX]; |
| 7742 |
uint32_t dwGfxAddress; |
| 7743 |
const char *bufname; |
| 7744 |
uint32_t isTiled; |
| 7745 |
MOS_TILE_TYPE TileType; |
| 7746 |
uint32_t bMapped; |
| 7747 |
uint32_t name; |
| 7748 |
uint64_t user_provided_va; |
| 7749 |
bool bConvertedFromDDIResource; |
| 7750 |
}; |
| 7751 |
|
| 7752 |
void GpuCmdResInfoDump::StoreCmdResPtr(PMOS_INTERFACE pOsInterface, const void *pRes) const |
| 7753 |
{ |
| 7754 |
if (!m_dumpEnabled) |
| 7755 |
{ |
| 7756 |
return; |
| 7757 |
} |
| 7758 |
auto gpuContext = Linux_GetGpuContext(pOsInterface, pOsInterface->CurrentGpuContextHandle); |
| 7759 |
MOS_OS_ASSERT(gpuContext != nullptr); |
| 7760 |
|
| 7761 |
auto pResTmp1 = (const MOS_RESOURCE *)(pRes); |
| 7762 |
auto pResTmp2 = (GpuCmdResInfo *)MOS_AllocMemory(sizeof(GpuCmdResInfo)); |
| 7763 |
|
| 7764 |
pResTmp2->iWidth = pResTmp1->iWidth; |
| 7765 |
pResTmp2->iHeight = pResTmp1->iHeight; |
| 7766 |
pResTmp2->iSize = pResTmp1->iSize; |
| 7767 |
pResTmp2->iPitch = pResTmp1->iPitch; |
| 7768 |
pResTmp2->iDepth = pResTmp1->iDepth; |
| 7769 |
pResTmp2->Format = pResTmp1->Format; |
| 7770 |
pResTmp2->iCount = pResTmp1->iCount; |
| 7771 |
for (auto i = 0; i < MOS_GPU_CONTEXT_MAX; i++) |
| 7772 |
{ |
| 7773 |
pResTmp2->iAllocationIndex[i] = pResTmp1->iAllocationIndex[i]; |
| 7774 |
} |
| 7775 |
pResTmp2->dwGfxAddress = pResTmp1->dwGfxAddress; |
| 7776 |
pResTmp2->bufname = pResTmp1->bufname; |
| 7777 |
pResTmp2->isTiled = pResTmp1->isTiled; |
| 7778 |
pResTmp2->TileType = pResTmp1->TileType; |
| 7779 |
pResTmp2->bMapped = pResTmp1->bMapped; |
| 7780 |
pResTmp2->name = pResTmp1->name; |
| 7781 |
pResTmp2->user_provided_va = pResTmp1->user_provided_va; |
| 7782 |
pResTmp2->bConvertedFromDDIResource = pResTmp1->bConvertedFromDDIResource; |
| 7783 |
|
| 7784 |
gpuContext->PushCmdResPtr((const void *)pResTmp2); |
| 7785 |
} |
| 7786 |
|
| 7787 |
void GpuCmdResInfoDump::ClearCmdResPtrs(PMOS_INTERFACE pOsInterface) const |
| 7788 |
{ |
| 7789 |
if (!m_dumpEnabled) |
| 7790 |
{ |
| 7791 |
return; |
| 7792 |
} |
| 7793 |
|
| 7794 |
auto gpuContext = Linux_GetGpuContext(pOsInterface, pOsInterface->CurrentGpuContextHandle); |
| 7795 |
MOS_OS_ASSERT(gpuContext != nullptr); |
| 7796 |
|
| 7797 |
auto &cmdResInfoPtrs = gpuContext->GetCmdResPtrs(); |
| 7798 |
|
| 7799 |
for (auto e : cmdResInfoPtrs) |
| 7800 |
{ |
| 7801 |
MOS_FreeMemory((void *)e); |
| 7802 |
} |
| 7803 |
|
| 7804 |
gpuContext->ClearCmdResPtrs(); |
| 7805 |
} |
| 7806 |
|
| 7807 |
void GpuCmdResInfoDump::Dump(const void *cmdResInfoPtr, std::ofstream &outputFile) const |
| 7808 |
{ |
| 7809 |
using std::endl; |
| 7810 |
|
| 7811 |
auto pRes = (const GpuCmdResInfo *)(cmdResInfoPtr); |
| 7812 |
|
| 7813 |
outputFile << "Gpu Resource Pointer : " << pRes << endl; |
| 7814 |
outputFile << "iWidth : " << pRes->iWidth << endl; |
| 7815 |
outputFile << "iHeight : " << pRes->iHeight << endl; |
| 7816 |
outputFile << "iSize : " << pRes->iSize << endl; |
| 7817 |
outputFile << "iPitch : " << pRes->iPitch << endl; |
| 7818 |
outputFile << "iDepth : " << pRes->iDepth << endl; |
| 7819 |
outputFile << "Format : " << (int32_t)pRes->Format << endl; |
| 7820 |
outputFile << "iCount : " << pRes->iCount << endl; |
| 7821 |
outputFile << "iAllocationIndex : "; |
| 7822 |
for (auto i = 0; i < MOS_GPU_CONTEXT_MAX; i++) |
| 7823 |
{ |
| 7824 |
outputFile << pRes->iAllocationIndex[i] << " "; |
| 7825 |
} |
| 7826 |
outputFile << endl; |
| 7827 |
outputFile << "dwGfxAddress : " << pRes->dwGfxAddress << endl; |
| 7828 |
outputFile << "bufname : " << pRes->bufname << endl; |
| 7829 |
outputFile << "isTiled : " << pRes->isTiled << endl; |
| 7830 |
outputFile << "TileType : " << GetTileType(pRes->TileType) << endl; |
| 7831 |
outputFile << "bMapped : " << pRes->bMapped << endl; |
| 7832 |
outputFile << "name : " << pRes->name << endl; |
| 7833 |
outputFile << "user_provided_va : " << pRes->user_provided_va << endl; |
| 7834 |
outputFile << "bConvertedFromDDIResource : " << pRes->bConvertedFromDDIResource << endl; |
| 7835 |
outputFile << endl; |
| 7836 |
} |
| 7837 |
|
| 7838 |
const std::vector<const void *> &GpuCmdResInfoDump::GetCmdResPtrs(PMOS_INTERFACE pOsInterface) const |
| 7839 |
{ |
| 7840 |
const auto *gpuContext = Linux_GetGpuContext(pOsInterface, pOsInterface->CurrentGpuContextHandle); |
| 7841 |
MOS_OS_ASSERT(gpuContext != nullptr); |
| 7842 |
|
| 7843 |
return gpuContext->GetCmdResPtrs(); |
| 7844 |
} |
| 7845 |
#endif // MOS_COMMAND_RESINFO_DUMP_SUPPORTED |
| 7846 |
|
| 7847 |
MOS_STATUS Mos_Specific_Virtual_Engine_Init( |
| 7848 |
PMOS_INTERFACE pOsInterface, |
| 7849 |
PMOS_VIRTUALENGINE_HINT_PARAMS* veHitParams, |
| 7850 |
MOS_VIRTUALENGINE_INIT_PARAMS& veInParams) |
| 7851 |
{ |
| 7852 |
MOS_OS_CHK_NULL_RETURN(pOsInterface); |
| 7853 |
if (pOsInterface->apoMosEnabled) |
| 7854 |
{ |
| 7855 |
MOS_OS_CHK_NULL_RETURN(pOsInterface->osStreamState); |
| 7856 |
MOS_VE_HANDLE veState = nullptr; |
| 7857 |
MOS_OS_CHK_STATUS_RETURN(MosInterface::CreateVirtualEngineState( |
| 7858 |
pOsInterface->osStreamState, &veInParams, veState)); |
| 7859 |
|
| 7860 |
MOS_OS_CHK_STATUS_RETURN(MosInterface::GetVeHintParams(pOsInterface->osStreamState, veInParams.bScalabilitySupported, veHitParams)); |
| 7861 |
} |
| 7862 |
else |
| 7863 |
{ |
| 7864 |
MOS_OS_CHK_STATUS_RETURN(Mos_VirtualEngineInterface_Initialize(pOsInterface, &veInParams)); |
| 7865 |
PMOS_VIRTUALENGINE_INTERFACE veInterface = pOsInterface->pVEInterf; |
| 7866 |
MOS_OS_CHK_NULL_RETURN(veInterface); |
| 7867 |
if (veInterface->pfnVEGetHintParams) |
| 7868 |
{ |
| 7869 |
MOS_OS_CHK_STATUS_RETURN(veInterface->pfnVEGetHintParams(veInterface, veInParams.bScalabilitySupported, veHitParams)); |
| 7870 |
} |
| 7871 |
} |
| 7872 |
|
| 7873 |
return MOS_STATUS_SUCCESS; |
| 7874 |
} |
| 7875 |
|
| 7876 |
MOS_STATUS Mos_Specific_SetHintParams( |
| 7877 |
PMOS_INTERFACE pOsInterface, |
| 7878 |
PMOS_VIRTUALENGINE_SET_PARAMS veParams) |
| 7879 |
{ |
| 7880 |
MOS_OS_FUNCTION_ENTER; |
| 7881 |
MOS_OS_CHK_NULL_RETURN(pOsInterface); |
| 7882 |
if (pOsInterface->apoMosEnabled) |
| 7883 |
{ |
| 7884 |
MOS_OS_CHK_NULL_RETURN(pOsInterface->osStreamState); |
| 7885 |
MOS_OS_CHK_STATUS_RETURN(MosInterface::SetVeHintParams(pOsInterface->osStreamState, veParams)); |
| 7886 |
} |
| 7887 |
else |
| 7888 |
{ |
| 7889 |
PMOS_VIRTUALENGINE_INTERFACE veInterface = pOsInterface->pVEInterf; |
| 7890 |
MOS_OS_CHK_NULL_RETURN(veInterface); |
| 7891 |
if (veInterface->pfnVESetHintParams) |
| 7892 |
{ |
| 7893 |
MOS_OS_CHK_STATUS_RETURN(veInterface->pfnVESetHintParams(veInterface, veParams)); |
| 7894 |
} |
| 7895 |
} |
| 7896 |
|
| 7897 |
return MOS_STATUS_SUCCESS; |
| 7898 |
} |
| 7899 |
|
| 7900 |
MOS_STATUS Mos_Specific_DestroyVeInterface( |
| 7901 |
PMOS_VIRTUALENGINE_INTERFACE *veInterface) |
| 7902 |
{ |
| 7903 |
MOS_OS_FUNCTION_ENTER; |
| 7904 |
if (*veInterface) |
| 7905 |
{ |
| 7906 |
if ((*veInterface)->pfnVEDestroy) |
| 7907 |
{ |
| 7908 |
(*veInterface)->pfnVEDestroy(*veInterface); |
| 7909 |
} |
| 7910 |
MOS_FreeMemAndSetNull(*veInterface); |
| 7911 |
} |
| 7912 |
|
| 7913 |
return MOS_STATUS_SUCCESS; |
| 7914 |
} |
| 7915 |
|
| 7916 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 7917 |
MOS_STATUS Mos_Specific_GetEngineLogicId( |
| 7918 |
PMOS_INTERFACE pOsInterface, |
| 7919 |
uint8_t& id) |
| 7920 |
{ |
| 7921 |
if (pOsInterface->apoMosEnabled) |
| 7922 |
{ |
| 7923 |
if (MosInterface::GetVeEngineCount(pOsInterface->osStreamState) != 1) |
| 7924 |
{ |
| 7925 |
MOS_OS_ASSERTMESSAGE("VeEngineCount is not equal to 1."); |
| 7926 |
} |
| 7927 |
id = MosInterface::GetEngineLogicId(pOsInterface->osStreamState, 0); |
| 7928 |
} |
| 7929 |
else |
| 7930 |
{ |
| 7931 |
PMOS_VIRTUALENGINE_INTERFACE veInterface = pOsInterface->pVEInterf; |
| 7932 |
if (veInterface->ucEngineCount != 1) |
| 7933 |
{ |
| 7934 |
MOS_OS_ASSERTMESSAGE("ucEngineCount is not equal to 1."); |
| 7935 |
} |
| 7936 |
id = veInterface->EngineLogicId[0]; |
| 7937 |
} |
| 7938 |
|
| 7939 |
return MOS_STATUS_SUCCESS; |
| 7940 |
} |
| 7941 |
#endif |