| 1 |
/* |
| 2 |
* Copyright (c) 2021, Intel Corporation |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 5 |
* copy of this software and associated documentation files (the "Software"), |
| 6 |
* to deal in the Software without restriction, including without limitation |
| 7 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 9 |
* Software is furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice shall be included |
| 12 |
* in all copies or substantial portions of the Software. |
| 13 |
* |
| 14 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 |
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 |
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 |
* OTHER DEALINGS IN THE SOFTWARE. |
| 21 |
*/ |
| 22 |
//! |
| 23 |
//! \file hal_oca_interface_next.cpp |
| 24 |
//! \brief Implementation of functions for Hal OCA Interface |
| 25 |
//! \details Implementation of functions for Hal OCA Interface |
| 26 |
//! |
| 27 |
|
| 28 |
#include <stdint.h> |
| 29 |
#include <map> |
| 30 |
#include <memory> |
| 31 |
#include <utility> |
| 32 |
#include "codec_def_common.h" |
| 33 |
#include "mhw_mi.h" |
| 34 |
#include "mos_defs.h" |
| 35 |
#include "mos_defs_specific.h" |
| 36 |
#include "mos_oca_interface.h" |
| 37 |
#include "mos_os_hw.h" |
| 38 |
#include "mos_os_specific.h" |
| 39 |
#include "mos_os.h" |
| 40 |
#include "hal_oca_interface_next.h" |
| 41 |
#include "mhw_mmio.h" |
| 42 |
#include "mos_interface.h" |
| 43 |
#include "mos_oca_interface_specific.h" |
| 44 |
#include "mos_oca_rtlog_mgr.h" |
| 45 |
#include "vp_debug.h" |
| 46 |
#include "codechal_oca_debug.h" |
| 47 |
#include "mhw_utilities_next.h" |
| 48 |
|
| 49 |
namespace mhw { namespace mi { class Itf; } } |
| 50 |
|
| 51 |
/****************************************************************************************************/ |
| 52 |
/* HalOcaInterfaceNextNext */ |
| 53 |
/****************************************************************************************************/ |
| 54 |
MOS_STATUS HalOcaInterfaceNext::MhwMiLoadRegisterImmCmd( |
| 55 |
std::shared_ptr<mhw::mi::Itf> miItf, |
| 56 |
PMOS_COMMAND_BUFFER pCmdBuffer, |
| 57 |
MHW_MI_LOAD_REGISTER_IMM_PARAMS *params) |
| 58 |
{ |
| 59 |
return MOS_STATUS_SUCCESS; |
| 60 |
} |
| 61 |
|
| 62 |
//! |
| 63 |
//! \brief Oca operation which should be called at the beginning of 1st level batch buffer start. |
| 64 |
//! \param [in/out] cmdBuffer |
| 65 |
//! Command buffer for current BB. ocaBufHandle in cmdBuffer will be updated. |
| 66 |
//! \param [in] mosContext |
| 67 |
//! Reference to MOS_CONTEXT. |
| 68 |
//! \param [in] gpuContextHandle |
| 69 |
//! Gpu context handle |
| 70 |
//! \param [in] miItf |
| 71 |
//! Reference to Mhw MiItf. |
| 72 |
//! \param [in] mmioRegisters |
| 73 |
//! mmio registers for current engine. |
| 74 |
//! \param [in] offsetOf1stLevelBB |
| 75 |
//! Offset for current BB in cmdBuffer. |
| 76 |
//! \param [in] bUseSizeOfCmdBuf |
| 77 |
//! If true, use size of cmdBuffer for batch buffer, else use sizeOf1stLevelBB. |
| 78 |
//! \param [in] sizeOf1stLevelBB |
| 79 |
//! Size of BB. Ignore if bUseSizeOfResource == true. |
| 80 |
//! \return void |
| 81 |
//! No return value. Handle all exception inside the function. |
| 82 |
//! |
| 83 |
void HalOcaInterfaceNext::On1stLevelBBStart(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, |
| 84 |
uint32_t gpuContextHandle, std::shared_ptr<mhw::mi::Itf> miItf, MHW_MI_MMIOREGISTERS &mmioRegisters, |
| 85 |
uint32_t offsetOf1stLevelBB, bool bUseSizeOfCmdBuf, uint32_t sizeOf1stLevelBB) |
| 86 |
{ |
| 87 |
HalOcaInterfaceNext::On1stLevelBBStart(cmdBuffer, *(PMOS_CONTEXT)mosContext, gpuContextHandle); |
| 88 |
} |
| 89 |
|
| 90 |
//! |
| 91 |
//! \brief Oca operation which should be called at the beginning of 1st level batch buffer start. |
| 92 |
//! \param [in/out] cmdBuffer |
| 93 |
//! Command buffer for current BB. ocaBufHandle in cmdBuffer will be updated. |
| 94 |
//! \param [in] mosContext |
| 95 |
//! Reference to MOS_CONTEXT. |
| 96 |
//! \param [in] gpuContextHandle |
| 97 |
//! Gpu context handle |
| 98 |
//! \param [in] miItf |
| 99 |
//! Reference to Mhw MiItf. |
| 100 |
//! \param [in] mmioRegisters |
| 101 |
//! mmio registers for current engine. |
| 102 |
//! \param [in] offsetOf1stLevelBB |
| 103 |
//! Offset for current BB in cmdBuffer. |
| 104 |
//! \param [in] bUseSizeOfCmdBuf |
| 105 |
//! If true, use size of cmdBuffer for batch buffer, else use sizeOf1stLevelBB. |
| 106 |
//! \param [in] sizeOf1stLevelBB |
| 107 |
//! Size of BB. Ignore if bUseSizeOfResource == true. |
| 108 |
//! \return void |
| 109 |
//! No return value. Handle all exception inside the function. |
| 110 |
//! |
| 111 |
void HalOcaInterfaceNext::On1stLevelBBStart(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, |
| 112 |
uint32_t gpuContextHandle, std::shared_ptr<mhw::mi::Itf> miItf, MmioRegistersMfx &mmioRegisters, |
| 113 |
uint32_t offsetOf1stLevelBB, bool bUseSizeOfCmdBuf, uint32_t sizeOf1stLevelBB) |
| 114 |
{ |
| 115 |
HalOcaInterfaceNext::On1stLevelBBStart(cmdBuffer, *(PMOS_CONTEXT)mosContext, gpuContextHandle); |
| 116 |
} |
| 117 |
|
| 118 |
//! |
| 119 |
//! \brief Oca operation which should be called before adding batch buffer end command for 1st |
| 120 |
//! level batch buffer. |
| 121 |
//! \param [in/out] cmdBuffer |
| 122 |
//! Command buffer for current BB. ocaBufHandle in cmdBuffer will be updated. |
| 123 |
//! \param [in] osInterface |
| 124 |
//! Reference to MOS_INTERFACE. |
| 125 |
//! \return void |
| 126 |
//! No return value. Handle all exception inside the function. |
| 127 |
//! |
| 128 |
void HalOcaInterfaceNext::On1stLevelBBEnd(MOS_COMMAND_BUFFER &cmdBuffer, MOS_INTERFACE &osInterface) |
| 129 |
{ |
| 130 |
if (nullptr == osInterface.pOsContext) |
| 131 |
{ |
| 132 |
OnOcaError(nullptr, MOS_STATUS_INVALID_PARAMETER, __FUNCTION__, __LINE__); |
| 133 |
return; |
| 134 |
} |
| 135 |
MOS_CONTEXT & mosContext = *osInterface.pOsContext; |
| 136 |
MosOcaInterface *pOcaInterface = &MosOcaInterfaceSpecific::GetInstance(); |
| 137 |
MOS_OCA_BUFFER_HANDLE ocaBufHandle = 0; |
| 138 |
MOS_STATUS status = MOS_STATUS_SUCCESS; |
| 139 |
|
| 140 |
if (nullptr == pOcaInterface || !((MosOcaInterfaceSpecific*)pOcaInterface)->IsOcaEnabled()) |
| 141 |
{ |
| 142 |
// Will come here for UMD_OCA not being enabled case. |
| 143 |
return; |
| 144 |
} |
| 145 |
if ((ocaBufHandle = GetOcaBufferHandle(cmdBuffer, (MOS_CONTEXT_HANDLE)&mosContext)) == MOS_OCA_INVALID_BUFFER_HANDLE) |
| 146 |
{ |
| 147 |
// May come here for workloads not enabling UMD_OCA. |
| 148 |
return; |
| 149 |
} |
| 150 |
|
| 151 |
status = pOcaInterface->On1stLevelBBEnd(ocaBufHandle, osInterface.pOsContext); |
| 152 |
if (MOS_FAILED(status)) |
| 153 |
{ |
| 154 |
// UnlockOcaBuf and RemoveOcaBufferHandle should also be called |
| 155 |
// for failure case to avoid oca buffer leak. |
| 156 |
OnOcaError(osInterface.pOsContext, status, __FUNCTION__, __LINE__); |
| 157 |
} |
| 158 |
status = pOcaInterface->UnlockOcaBufferWithDelay(ocaBufHandle); |
| 159 |
if (MOS_FAILED(status)) |
| 160 |
{ |
| 161 |
OnOcaError(osInterface.pOsContext, status, __FUNCTION__, __LINE__); |
| 162 |
} |
| 163 |
|
| 164 |
// remove the oca buffer handle |
| 165 |
RemoveOcaBufferHandle(cmdBuffer, mosContext); |
| 166 |
} |
| 167 |
|
| 168 |
//! |
| 169 |
//! \brief Oca operation which should be called before sending start sub level batch buffer command. |
| 170 |
//! \param [in] cmdBuffer |
| 171 |
//! Command buffer for current BB. |
| 172 |
//! \param [in] mosContext |
| 173 |
//! Reference to MOS_CONTEXT. |
| 174 |
//! \param [in] pMosResource |
| 175 |
//! Pointer to the MOS_RESOURCE. |
| 176 |
//! \param [in] offsetOfSubLevelBB |
| 177 |
//! Offset for current BB in pMosResource. |
| 178 |
//! \param [in] bUseSizeOfResource |
| 179 |
//! If true, use size of pMosResource for batch buffer, else use sizeOfIndirectState. |
| 180 |
//! \param [in] sizeOfSubLevelBB |
| 181 |
//! Size of BB. Ignore if bUseSizeOfResource == true. |
| 182 |
//! \return void |
| 183 |
//! No return value. Handle all exception inside the function. |
| 184 |
//! |
| 185 |
void HalOcaInterfaceNext::OnSubLevelBBStart(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, void *pMosResource, uint32_t offsetOfSubLevelBB, bool bUseSizeOfResource, uint32_t sizeOfSubLevelBB) |
| 186 |
{ |
| 187 |
MosInterface::SetObjectCapture((PMOS_RESOURCE)pMosResource); |
| 188 |
} |
| 189 |
|
| 190 |
//! |
| 191 |
//! \brief Oca operation which should be called when indirect states being added. |
| 192 |
//! \param [in] cmdBuffer |
| 193 |
//! Command buffer for current BB. |
| 194 |
//! \param [in] mosContext |
| 195 |
//! Reference to MOS_CONTEXT. |
| 196 |
//! \param [in] pMosResource |
| 197 |
//! Pointer to the MOS_RESOURCE. |
| 198 |
//! \param [in] offsetOfIndirectState |
| 199 |
//! Offset for current state in pMosResource. |
| 200 |
//! \param [in] bUseSizeOfResource |
| 201 |
//! If true, use size of pMosResource for indirect state, else use sizeOfIndirectState. |
| 202 |
//! \param [in] sizeOfIndirectState |
| 203 |
//! Size of indirect state. Ignore if bUseSizeOfResource == true. |
| 204 |
//! \return void |
| 205 |
//! No return value. Handle all exception inside the function. |
| 206 |
//! |
| 207 |
void HalOcaInterfaceNext::OnIndirectState(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, void *pMosResource, uint32_t offsetOfIndirectState, bool bUseSizeOfResource, uint32_t sizeOfIndirectState) |
| 208 |
{ |
| 209 |
MosInterface::SetObjectCapture((PMOS_RESOURCE)pMosResource); |
| 210 |
} |
| 211 |
|
| 212 |
//! |
| 213 |
//! \brief Oca operation which should be called before adding dispatch states, |
| 214 |
//! e.g. VEB_DI_IECP_STATE and MEDIA_OBJECT_WALKER. |
| 215 |
//! \param [in] cmdBuffer |
| 216 |
//! Command buffer for current BB. |
| 217 |
//! \param [in] mosContext |
| 218 |
//! Reference to MOS_CONTEXT. |
| 219 |
//! \param [in] miItf |
| 220 |
//! Reference to Mhw MiItf. |
| 221 |
//! \param [in] mmioRegisters |
| 222 |
//! mmio registers for current engine. |
| 223 |
//! \return void |
| 224 |
//! No return value. Handle all exception inside the function. |
| 225 |
//! |
| 226 |
void HalOcaInterfaceNext::OnDispatch(MOS_COMMAND_BUFFER &cmdBuffer, MOS_INTERFACE &osInterface, std::shared_ptr<mhw::mi::Itf> miItf, MHW_MI_MMIOREGISTERS &mmioRegisters) |
| 227 |
{ |
| 228 |
MOS_CONTEXT &mosContext = *osInterface.pOsContext; |
| 229 |
AddRTLogReource(cmdBuffer, (MOS_CONTEXT_HANDLE)&mosContext, osInterface); |
| 230 |
} |
| 231 |
|
| 232 |
//! |
| 233 |
//! \brief Add string to oca log section |
| 234 |
//! \param [in] cmdBuffer |
| 235 |
//! Command buffer for current BB. |
| 236 |
//! \param [in] mosContext |
| 237 |
//! Reference to MOS_CONTEXT. |
| 238 |
//! \param [in] str |
| 239 |
//! string to be added. |
| 240 |
//! \param [in] maxCount |
| 241 |
//! size of the buffer pointed by str. |
| 242 |
//! \return void |
| 243 |
//! No return value. Handle all exception inside the function. |
| 244 |
//! |
| 245 |
void HalOcaInterfaceNext::TraceMessage(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, const char *str, uint32_t maxCount) |
| 246 |
{ |
| 247 |
MosOcaInterface *pOcaInterface = &MosOcaInterfaceSpecific::GetInstance(); |
| 248 |
MOS_OCA_BUFFER_HANDLE ocaBufHandle = 0; |
| 249 |
MOS_STATUS status = MOS_STATUS_SUCCESS; |
| 250 |
|
| 251 |
if (nullptr == pOcaInterface || !((MosOcaInterfaceSpecific*)pOcaInterface)->IsOcaEnabled()) |
| 252 |
{ |
| 253 |
return; |
| 254 |
} |
| 255 |
if ((ocaBufHandle = GetOcaBufferHandle(cmdBuffer, mosContext)) == MOS_OCA_INVALID_BUFFER_HANDLE) |
| 256 |
{ |
| 257 |
// May come here for workloads not enabling UMD_OCA. |
| 258 |
return; |
| 259 |
} |
| 260 |
|
| 261 |
status = pOcaInterface->TraceMessage(ocaBufHandle, (PMOS_CONTEXT)mosContext, str, maxCount); |
| 262 |
if (MOS_FAILED(status)) |
| 263 |
{ |
| 264 |
OnOcaError(mosContext, status, __FUNCTION__, __LINE__); |
| 265 |
} |
| 266 |
} |
| 267 |
|
| 268 |
//! |
| 269 |
//! \brief Add vp kernel info to oca log section. |
| 270 |
//! \param [in] cmdBuffer |
| 271 |
//! Command buffer for current BB. |
| 272 |
//! \param [in] osInterface |
| 273 |
//! Reference to MOS_INTERFACE. |
| 274 |
//! \param [in] res |
| 275 |
//! Reference to MOS_RESOURCE. |
| 276 |
//! \param [in] hwCmdType |
| 277 |
//! Hw command type. |
| 278 |
//! \param [in] locationInCmd |
| 279 |
//! Location in command. |
| 280 |
//! \param [in] offsetInRes |
| 281 |
//! Offset in resource. |
| 282 |
//! \return void |
| 283 |
//! No return value. Handle all exception inside the function. |
| 284 |
//! |
| 285 |
void HalOcaInterfaceNext::DumpResourceInfo(MOS_COMMAND_BUFFER &cmdBuffer, MOS_INTERFACE &osInterface, MOS_RESOURCE &res, MOS_HW_COMMAND hwCmdType, uint32_t locationInCmd, uint32_t offsetInRes) |
| 286 |
{ |
| 287 |
if (nullptr == osInterface.pOsContext) |
| 288 |
{ |
| 289 |
OnOcaError(nullptr, MOS_STATUS_INVALID_PARAMETER, __FUNCTION__, __LINE__); |
| 290 |
return; |
| 291 |
} |
| 292 |
|
| 293 |
MOS_CONTEXT & mosContext = *osInterface.pOsContext; |
| 294 |
MosOcaInterface *pOcaInterface = &MosOcaInterfaceSpecific::GetInstance(); |
| 295 |
MOS_STATUS status = MOS_STATUS_SUCCESS; |
| 296 |
MOS_OCA_BUFFER_HANDLE ocaBufHandle = 0; |
| 297 |
|
| 298 |
if (nullptr == pOcaInterface || !((MosOcaInterfaceSpecific*)pOcaInterface)->IsOcaEnabled()) |
| 299 |
{ |
| 300 |
return; |
| 301 |
} |
| 302 |
|
| 303 |
if ((ocaBufHandle = GetOcaBufferHandle(cmdBuffer, (MOS_CONTEXT_HANDLE)&mosContext)) == MOS_OCA_INVALID_BUFFER_HANDLE) |
| 304 |
{ |
| 305 |
// May come here for workloads not enabling UMD_OCA. |
| 306 |
return; |
| 307 |
} |
| 308 |
|
| 309 |
if (Mos_ResourceIsNull(&res)) |
| 310 |
{ |
| 311 |
OnOcaError(&mosContext, MOS_STATUS_INVALID_PARAMETER, __FUNCTION__, __LINE__); |
| 312 |
return; |
| 313 |
} |
| 314 |
if (hwCmdType == MOS_BINDLESS_STATELESS_SURFACE && (res.Format == Format_Buffer || res.Format == Format_RAW)) |
| 315 |
{ |
| 316 |
status = pOcaInterface->AddBufferResourceToDumpList(ocaBufHandle, &mosContext, res, hwCmdType, cmdBuffer.iOffset, offsetInRes); |
| 317 |
} |
| 318 |
else |
| 319 |
{ |
| 320 |
status = pOcaInterface->AddResourceToDumpList(ocaBufHandle, &mosContext, res, hwCmdType, locationInCmd, offsetInRes); |
| 321 |
} |
| 322 |
if (MOS_FAILED(status)) |
| 323 |
{ |
| 324 |
OnOcaError(&mosContext, status, __FUNCTION__, __LINE__); |
| 325 |
} |
| 326 |
} |
| 327 |
|
| 328 |
//! |
| 329 |
//! \brief Insert bindless/stateless resource state heap into OcaBufferHandlerMap |
| 330 |
//! \param [in] key |
| 331 |
//! The base address of resource state heap |
| 332 |
//! \param [in] osInterface |
| 333 |
//! Reference to PMOS_INTERFACE. |
| 334 |
//! \param [in] cmdBuffer |
| 335 |
//! Command buffer for current BB. |
| 336 |
//! \return void |
| 337 |
//! No return value. Handle all exception inside the function. |
| 338 |
//! |
| 339 |
void HalOcaInterfaceNext::InsertResourceHeapToCurrentCmdBufferOcaBufferHandle(uint32_t *key, PMOS_INTERFACE osInterface, PMOS_COMMAND_BUFFER _cmdBuffer) |
| 340 |
{ |
| 341 |
if (nullptr == osInterface || nullptr == osInterface->pOsContext || nullptr == _cmdBuffer) |
| 342 |
{ |
| 343 |
OnOcaError(nullptr, MOS_STATUS_INVALID_PARAMETER, __FUNCTION__, __LINE__); |
| 344 |
return; |
| 345 |
} |
| 346 |
MOS_CONTEXT &mosContext = *osInterface->pOsContext; |
| 347 |
MosOcaInterface *pOcaInterface = &MosOcaInterfaceSpecific::GetInstance(); |
| 348 |
MOS_STATUS status = MOS_STATUS_SUCCESS; |
| 349 |
MOS_OCA_BUFFER_HANDLE hOcaBuf = 0; |
| 350 |
MOS_COMMAND_BUFFER &cmdBuffer = _cmdBuffer->cmdBuf1stLvl ? *_cmdBuffer->cmdBuf1stLvl : *_cmdBuffer; |
| 351 |
|
| 352 |
if (nullptr == pOcaInterface || (hOcaBuf = GetOcaBufferHandle(cmdBuffer, (MOS_CONTEXT_HANDLE)&mosContext)) == 0) |
| 353 |
{ |
| 354 |
// Will come here for UMD_OCA not being enabled case. |
| 355 |
return; |
| 356 |
} |
| 357 |
|
| 358 |
status = pOcaInterface->InsertOcaBufHandleMap(key, hOcaBuf); |
| 359 |
if (MOS_FAILED(status)) |
| 360 |
{ |
| 361 |
OnOcaError(&mosContext, status, __FUNCTION__, __LINE__); |
| 362 |
} |
| 363 |
} |
| 364 |
|
| 365 |
//! |
| 366 |
//! \brief Trace OCA Sku Value. |
| 367 |
//! \param [in] cmdBuffer |
| 368 |
//! Command buffer for current BB. |
| 369 |
//! \param [in] osInterface |
| 370 |
//! Reference to MOS_INTERFACE. |
| 371 |
//! \return void |
| 372 |
//! No return value. Handle all exception inside the function. |
| 373 |
//! |
| 374 |
void HalOcaInterfaceNext::TraceOcaSkuValue(MOS_COMMAND_BUFFER &cmdBuffer, MOS_INTERFACE &osInterface) |
| 375 |
{ |
| 376 |
} |
| 377 |
|
| 378 |
//! |
| 379 |
//! \brief Add vp kernel info to oca log section. |
| 380 |
//! \param [in] cmdBuffer |
| 381 |
//! Command buffer for current BB. |
| 382 |
//! \param [in] mosContext |
| 383 |
//! Reference to MOS_CONTEXT. |
| 384 |
//! \param [in] vpKernelID |
| 385 |
//! Value of enum VpKernelID. |
| 386 |
//! \param [in] fcKernelCount |
| 387 |
//! If vpKernelID == kernelCombinedFc, fcKernelCount is the kernel count for fc, otherwise, it's not used. |
| 388 |
//! \param [in] fcKernelList |
| 389 |
//! If vpKernelID == kernelCombinedFc, fcKernelList is the kernel list for fc, otherwise, it's not used. |
| 390 |
//! \param [in] aiKernelFeatureType |
| 391 |
//! Value of enum FeatureType for Ai Common Kernel. |
| 392 |
//! \return void |
| 393 |
//! No return value. Handle all exception inside the function. |
| 394 |
//! |
| 395 |
void HalOcaInterfaceNext::DumpVpKernelInfo(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, int vpKernelID, int fcKernelCount, int *fcKernelList, int aiKernelFeatureType) |
| 396 |
{ |
| 397 |
MosOcaInterface *pOcaInterface = &MosOcaInterfaceSpecific::GetInstance(); |
| 398 |
MOS_STATUS status = MOS_STATUS_SUCCESS; |
| 399 |
MOS_OCA_BUFFER_HANDLE ocaBufHandle = 0; |
| 400 |
uint32_t updateSize = 0; |
| 401 |
|
| 402 |
if (nullptr == pOcaInterface || !((MosOcaInterfaceSpecific*)pOcaInterface)->IsOcaEnabled()) |
| 403 |
{ |
| 404 |
return; |
| 405 |
} |
| 406 |
|
| 407 |
if ((ocaBufHandle = GetOcaBufferHandle(cmdBuffer, mosContext)) == MOS_OCA_INVALID_BUFFER_HANDLE) |
| 408 |
{ |
| 409 |
// May come here for workloads not enabling UMD_OCA. |
| 410 |
return; |
| 411 |
} |
| 412 |
|
| 413 |
if (kernelCombinedFc == vpKernelID && (fcKernelCount <= 0 || nullptr == fcKernelList)) |
| 414 |
{ |
| 415 |
OnOcaError(mosContext, MOS_STATUS_INVALID_PARAMETER, __FUNCTION__, __LINE__); |
| 416 |
return; |
| 417 |
} |
| 418 |
|
| 419 |
if (kernelCombinedFc != vpKernelID) |
| 420 |
{ |
| 421 |
fcKernelCount = 0; |
| 422 |
fcKernelList = nullptr; |
| 423 |
} |
| 424 |
|
| 425 |
MOS_OCA_LOG_HEADER_VP_KERNEL_INFO header = {}; |
| 426 |
header.header.type = MOS_OCA_LOG_TYPE_VP_KERNEL_INFO; |
| 427 |
header.header.headerSize = sizeof(MOS_OCA_LOG_HEADER_VP_KERNEL_INFO); |
| 428 |
header.header.dataSize = fcKernelCount * sizeof(int); |
| 429 |
header.vpKernelID = vpKernelID; |
| 430 |
if (aiKernelFeatureType > 0 && vpKernelID >= kernelAiCommon && vpKernelID <= kernelAiCommonEnd) |
| 431 |
{ |
| 432 |
header.aiKernelFeatureType = aiKernelFeatureType; |
| 433 |
} |
| 434 |
else |
| 435 |
{ |
| 436 |
header.fcKernelCount = fcKernelCount; |
| 437 |
} |
| 438 |
status = pOcaInterface->DumpDataBlock(ocaBufHandle, (PMOS_CONTEXT)mosContext, (PMOS_OCA_LOG_HEADER)&header, fcKernelList); |
| 439 |
if (MOS_FAILED(status)) |
| 440 |
{ |
| 441 |
OnOcaError(mosContext, status, __FUNCTION__, __LINE__); |
| 442 |
} |
| 443 |
} |
| 444 |
|
| 445 |
//! |
| 446 |
//! \brief Add vp kernel info to oca log section. |
| 447 |
//! \param [in] cmdBuffer |
| 448 |
//! Command buffer for current BB. |
| 449 |
//! \param [in] mosContext |
| 450 |
//! Reference to MOS_CONTEXT. |
| 451 |
//! \param [in] pControlValues |
| 452 |
//! Value of user features. |
| 453 |
//! \return void |
| 454 |
//! No return value. Handle all exception inside the function. |
| 455 |
//! |
| 456 |
void HalOcaInterfaceNext::DumpVpUserFeautreControlInfo(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, PMOS_OCA_LOG_USER_FEATURE_CONTROL_INFO pControlValues) |
| 457 |
{ |
| 458 |
MosOcaInterface *pOcaInterface = &MosOcaInterfaceSpecific::GetInstance(); |
| 459 |
MOS_STATUS status = MOS_STATUS_SUCCESS; |
| 460 |
MOS_OCA_BUFFER_HANDLE hOcaBuf = 0; |
| 461 |
|
| 462 |
if (nullptr == pOcaInterface || (hOcaBuf = GetOcaBufferHandle(cmdBuffer, mosContext)) == MOS_OCA_INVALID_BUFFER_HANDLE) |
| 463 |
{ |
| 464 |
// Will come here for UMD_OCA not being enabled case. |
| 465 |
return; |
| 466 |
} |
| 467 |
|
| 468 |
MOS_OCA_LOG_HEADER header = {}; |
| 469 |
header.type = MOS_OCA_LOG_TYPE_VP_USER_FEATURE_CONTROL_INFO; |
| 470 |
header.headerSize = sizeof(MOS_OCA_LOG_HEADER); |
| 471 |
header.dataSize = sizeof(MOS_OCA_LOG_USER_FEATURE_CONTROL_INFO); |
| 472 |
|
| 473 |
status = pOcaInterface->DumpDataBlock(hOcaBuf, (PMOS_CONTEXT)mosContext, (PMOS_OCA_LOG_HEADER)&header, pControlValues); |
| 474 |
if (MOS_FAILED(status)) |
| 475 |
{ |
| 476 |
OnOcaError(mosContext, status, __FUNCTION__, __LINE__); |
| 477 |
} |
| 478 |
} |
| 479 |
|
| 480 |
//! |
| 481 |
//! \brief Add vphal parameters to oca log section. |
| 482 |
//! \param [in] mosContext |
| 483 |
//! Reference to MOS_CONTEXT. |
| 484 |
//! \param [in] pVphalDumper |
| 485 |
//! Pointer to vphal dumper object. |
| 486 |
//! \return void |
| 487 |
//! No return value. Handle all exception inside the function. |
| 488 |
//! |
| 489 |
void HalOcaInterfaceNext::DumpVphalParam(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, void *pVphalDumper) |
| 490 |
{ |
| 491 |
MosOcaInterface *pOcaInterface = &MosOcaInterfaceSpecific::GetInstance(); |
| 492 |
MOS_STATUS status = MOS_STATUS_SUCCESS; |
| 493 |
MOS_OCA_BUFFER_HANDLE ocaBufHandle = 0; |
| 494 |
uint32_t updateSize = 0; |
| 495 |
|
| 496 |
if (nullptr == pOcaInterface || |
| 497 |
!((MosOcaInterfaceSpecific*)pOcaInterface)->IsOcaEnabled() || |
| 498 |
nullptr == pVphalDumper) |
| 499 |
{ |
| 500 |
return; |
| 501 |
} |
| 502 |
if ((ocaBufHandle = GetOcaBufferHandle(cmdBuffer, mosContext)) == MOS_OCA_INVALID_BUFFER_HANDLE) |
| 503 |
{ |
| 504 |
// May come here for workloads not enabling UMD_OCA. |
| 505 |
return; |
| 506 |
} |
| 507 |
|
| 508 |
VPHAL_OCA_RENDER_PARAM *pVphalParam = ((VphalOcaDumper *)pVphalDumper)->GetRenderParam(); |
| 509 |
if (nullptr == pVphalParam) |
| 510 |
{ |
| 511 |
return; |
| 512 |
} |
| 513 |
|
| 514 |
MOS_OCA_LOG_HEADER_VPHAL_PARAM header = {}; |
| 515 |
header.header.type = MOS_OCA_LOG_TYPE_VPHAL_PARAM; // 00000003 |
| 516 |
header.header.headerSize = sizeof(MOS_OCA_LOG_HEADER_VPHAL_PARAM); |
| 517 |
header.header.dataSize = pVphalParam->Header.size; |
| 518 |
status = pOcaInterface->DumpDataBlock(ocaBufHandle, (PMOS_CONTEXT)mosContext, (PMOS_OCA_LOG_HEADER)&header, pVphalParam); |
| 519 |
if (MOS_FAILED(status)) |
| 520 |
{ |
| 521 |
OnOcaError(mosContext, status, __FUNCTION__, __LINE__); |
| 522 |
} |
| 523 |
} |
| 524 |
|
| 525 |
//! |
| 526 |
//! \brief Add codechal parameters to oca log section. |
| 527 |
//! \param [in] cmdBuffer |
| 528 |
//! Command buffer for current BB. |
| 529 |
//! \param [in] mosContext |
| 530 |
//! Reference to MOS_CONTEXT. |
| 531 |
//! \param [in] pCodechalDumper |
| 532 |
//! Pointer to codechal dumper object. |
| 533 |
//! \return void |
| 534 |
//! No return value. Handle all exception inside the function. |
| 535 |
//! |
| 536 |
void HalOcaInterfaceNext::DumpCodechalParam(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, void *pCodechalDumper, CODECHAL_STANDARD codec) |
| 537 |
{ |
| 538 |
MosOcaInterface *pOcaInterface = &MosOcaInterfaceSpecific::GetInstance(); |
| 539 |
MOS_STATUS status = MOS_STATUS_SUCCESS; |
| 540 |
MOS_OCA_BUFFER_HANDLE ocaBufHandle = 0; |
| 541 |
uint32_t updateSize = 0; |
| 542 |
|
| 543 |
if (nullptr == pOcaInterface || |
| 544 |
!((MosOcaInterfaceSpecific*)pOcaInterface)->IsOcaEnabled() || |
| 545 |
nullptr == pCodechalDumper) |
| 546 |
{ |
| 547 |
return; |
| 548 |
} |
| 549 |
if ((ocaBufHandle = GetOcaBufferHandle(cmdBuffer, mosContext)) == MOS_OCA_INVALID_BUFFER_HANDLE) |
| 550 |
{ |
| 551 |
// May come here for workloads not enabling UMD_OCA. |
| 552 |
return; |
| 553 |
} |
| 554 |
|
| 555 |
CODECHAL_OCA_DECODE_HEADER *pCodechalParam = ((CodechalOcaDumper *)pCodechalDumper)->GetDecodeParam(); |
| 556 |
if (nullptr == pCodechalParam) |
| 557 |
{ |
| 558 |
return; |
| 559 |
} |
| 560 |
|
| 561 |
MOS_OCA_LOG_HEADER_CODECHAL_PARAM header = {}; |
| 562 |
header.header.type = MOS_OCA_LOG_TYPE_CODECHAL_PARAM; // 00000007 |
| 563 |
header.header.headerSize = sizeof(MOS_OCA_LOG_HEADER_CODECHAL_PARAM); |
| 564 |
header.header.dataSize = pCodechalParam->Header.size; |
| 565 |
header.codec = (uint32_t)codec; |
| 566 |
status = pOcaInterface->DumpDataBlock(ocaBufHandle, (PMOS_CONTEXT)mosContext, (PMOS_OCA_LOG_HEADER)&header, pCodechalParam); |
| 567 |
|
| 568 |
if (MOS_FAILED(status)) |
| 569 |
{ |
| 570 |
OnOcaError(mosContext, status, __FUNCTION__, __LINE__); |
| 571 |
} |
| 572 |
} |
| 573 |
|
| 574 |
bool HalOcaInterfaceNext::IsLargeResouceDumpSupported() |
| 575 |
{ |
| 576 |
return true; |
| 577 |
} |
| 578 |
|
| 579 |
void HalOcaInterfaceNext::AddRTLogReource(MOS_COMMAND_BUFFER &cmdBuffer, |
| 580 |
MOS_CONTEXT_HANDLE mosContext, |
| 581 |
MOS_INTERFACE &osInterface) |
| 582 |
{ |
| 583 |
if (!MosOcaRTLogMgr::IsOcaRTLogEnabled()) |
| 584 |
{ |
| 585 |
return; |
| 586 |
} |
| 587 |
MOS_STATUS status = MOS_STATUS_SUCCESS; |
| 588 |
PMOS_RESOURCE osResource = nullptr; |
| 589 |
uint32_t size = 0; |
| 590 |
if (!osInterface.osStreamState) |
| 591 |
{ |
| 592 |
return; |
| 593 |
} |
| 594 |
osInterface.pfnGetRtLogResourceInfo(&osInterface, osResource, size); |
| 595 |
if(osResource == nullptr || size == 0) |
| 596 |
{ |
| 597 |
return; |
| 598 |
} |
| 599 |
|
| 600 |
MOS_LINUX_BO *bo = cmdBuffer.OsResource.bo; |
| 601 |
if (bo == nullptr || |
| 602 |
bo->virt == nullptr || |
| 603 |
bo->size <= OCA_LOG_SECTION_SIZE_MAX) |
| 604 |
{ |
| 605 |
return; |
| 606 |
} |
| 607 |
OCA_LOG_SECTION_HEADER *header = (OCA_LOG_SECTION_HEADER *)((uint64_t)bo->virt + bo->size - OCA_LOG_SECTION_SIZE_MAX); |
| 608 |
if (header->magicNum != OCA_LOG_SECTION_MAGIC_NUMBER) |
| 609 |
{ |
| 610 |
return; |
| 611 |
} |
| 612 |
MHW_RESOURCE_PARAMS ResourceParams = {}; |
| 613 |
|
| 614 |
ResourceParams.dwOffset = 0; |
| 615 |
uint32_t cmd = 0; |
| 616 |
ResourceParams.presResource = osResource; |
| 617 |
ResourceParams.pdwCmd = &cmd; |
| 618 |
// Align logic in Mhw_AddResourceToCmd |
| 619 |
ResourceParams.dwLocationInCmd = ((int32_t)((uint8_t*)&header->rtlogPatchAddr - (uint8_t*)cmdBuffer.pCmdBase) - cmdBuffer.iOffset) / sizeof(uint32_t); |
| 620 |
ResourceParams.HwCommandType = MOS_OCA_RESERVED; |
| 621 |
ResourceParams.dwSharedMocsOffset = 1 - ResourceParams.dwLocationInCmd; |
| 622 |
|
| 623 |
if (osInterface.bUsesGfxAddress) |
| 624 |
{ |
| 625 |
status = Mhw_AddResourceToCmd_GfxAddress(&osInterface, &cmdBuffer, &ResourceParams); |
| 626 |
} |
| 627 |
else |
| 628 |
{ |
| 629 |
status = Mhw_AddResourceToCmd_PatchList(&osInterface, &cmdBuffer, &ResourceParams); |
| 630 |
} |
| 631 |
|
| 632 |
if (MOS_FAILED(status)) |
| 633 |
{ |
| 634 |
OnOcaError(mosContext, status, __FUNCTION__, __LINE__); |
| 635 |
} |
| 636 |
HalOcaInterfaceNext::OnIndirectState(cmdBuffer, mosContext, osResource, 0, false, size); |
| 637 |
} |
| 638 |
|
| 639 |
void HalOcaInterfaceNext::DumpCpParam(MosOcaInterface &ocaInterface, MOS_OCA_BUFFER_HANDLE &ocaBufHandle, PMOS_CONTEXT mosCtx, void *pCpDumper) |
| 640 |
{ |
| 641 |
} |
| 642 |
|
| 643 |
void HalOcaInterfaceNext::DumpCpIoMsg(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, void *pCpDumper, int type) |
| 644 |
{ |
| 645 |
} |
| 646 |
|
| 647 |
void HalOcaInterfaceNext::OnOcaError(MOS_CONTEXT_HANDLE mosCtx, MOS_STATUS status, const char *functionName, uint32_t lineNumber) |
| 648 |
{ |
| 649 |
MosOcaInterfaceSpecific::OnOcaError((PMOS_CONTEXT)mosCtx, status, functionName, lineNumber); |
| 650 |
} |
| 651 |
|
| 652 |
MOS_OCA_BUFFER_HANDLE HalOcaInterfaceNext::GetOcaBufferHandle(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext) |
| 653 |
{ |
| 654 |
MosOcaInterface *pOcaInterface = &MosOcaInterfaceSpecific::GetInstance(); |
| 655 |
if(pOcaInterface == nullptr) |
| 656 |
{ |
| 657 |
OnOcaError(mosContext, MOS_STATUS_NULL_POINTER, __FUNCTION__, __LINE__); |
| 658 |
return MOS_OCA_INVALID_BUFFER_HANDLE; |
| 659 |
} |
| 660 |
|
| 661 |
return pOcaInterface->GetOcaBufHandleFromMap(cmdBuffer.pCmdBase); |
| 662 |
} |
| 663 |
|
| 664 |
void HalOcaInterfaceNext::RemoveOcaBufferHandle(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT &mosContext) |
| 665 |
{ |
| 666 |
MosOcaInterface *pOcaInterface = &MosOcaInterfaceSpecific::GetInstance(); |
| 667 |
if(pOcaInterface == nullptr) |
| 668 |
{ |
| 669 |
OnOcaError(&mosContext, MOS_STATUS_NULL_POINTER, __FUNCTION__, __LINE__); |
| 670 |
return; |
| 671 |
} |
| 672 |
pOcaInterface->RemoveOcaBufHandleFromMap(cmdBuffer.pCmdBase); |
| 673 |
} |
| 674 |
|
| 675 |
//! |
| 676 |
//! \brief Oca operation which should be called at the beginning of 1st level batch buffer start. |
| 677 |
//! \param [in/out] cmdBuffer |
| 678 |
//! Command buffer for current BB. ocaBufHandle in cmdBuffer will be updated. |
| 679 |
//! \param [in] mosContext |
| 680 |
//! Reference to MOS_CONTEXT. |
| 681 |
//! \param [in] gpuContextHandle |
| 682 |
//! Gpu context handle |
| 683 |
//! \return void |
| 684 |
//! No return value. Handle all exception inside the function. |
| 685 |
//! |
| 686 |
void HalOcaInterfaceNext::On1stLevelBBStart(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT &mosContext, |
| 687 |
uint32_t gpuContextHandle) |
| 688 |
{ |
| 689 |
MosInterface::SetObjectCapture(&cmdBuffer.OsResource); |
| 690 |
MOS_STATUS status = MOS_STATUS_SUCCESS; |
| 691 |
MosOcaInterface *pOcaInterface = &MosOcaInterfaceSpecific::GetInstance(); |
| 692 |
MOS_OCA_BUFFER_HANDLE ocaBufHandle = 0; |
| 693 |
uint64_t ocaBase = 0; |
| 694 |
|
| 695 |
if (nullptr == pOcaInterface || !((MosOcaInterfaceSpecific*)pOcaInterface)->IsOcaEnabled()) |
| 696 |
{ |
| 697 |
return; |
| 698 |
} |
| 699 |
|
| 700 |
ocaBufHandle = GetOcaBufferHandle(cmdBuffer, (MOS_CONTEXT_HANDLE)&mosContext); |
| 701 |
if (ocaBufHandle != MOS_OCA_INVALID_BUFFER_HANDLE) |
| 702 |
{ |
| 703 |
// will come here when On1stLevelBBStart being called twice without On1stLevelBBEnd being called. |
| 704 |
OnOcaError(&mosContext, MOS_STATUS_INVALID_PARAMETER, __FUNCTION__, __LINE__); |
| 705 |
return; |
| 706 |
} |
| 707 |
else |
| 708 |
{ |
| 709 |
ocaBufHandle = pOcaInterface->LockOcaBufAvailable(&mosContext, gpuContextHandle); |
| 710 |
|
| 711 |
if (MOS_OCA_INVALID_BUFFER_HANDLE == ocaBufHandle) |
| 712 |
{ |
| 713 |
OnOcaError(&mosContext, MOS_STATUS_INVALID_HANDLE, __FUNCTION__, __LINE__); |
| 714 |
return; |
| 715 |
} |
| 716 |
if (MOS_FAILED(pOcaInterface->InsertOcaBufHandleMap(cmdBuffer.pCmdBase, ocaBufHandle))) |
| 717 |
{ |
| 718 |
OnOcaError(&mosContext, MOS_STATUS_INVALID_HANDLE, __FUNCTION__, __LINE__); |
| 719 |
return; |
| 720 |
} |
| 721 |
} |
| 722 |
|
| 723 |
status = pOcaInterface->On1stLevelBBStart(ocaBase, ocaBufHandle, &mosContext, &cmdBuffer.OsResource, 0, true, 0); |
| 724 |
if (MOS_FAILED(status)) |
| 725 |
{ |
| 726 |
RemoveOcaBufferHandle(cmdBuffer, mosContext); |
| 727 |
OnOcaError(&mosContext, status, __FUNCTION__, __LINE__); |
| 728 |
} |
| 729 |
} |
| 730 |
|
| 731 |
/****************************************************************************************************/ |
| 732 |
/* Private functions to ensure class singleton. */ |
| 733 |
/****************************************************************************************************/ |
| 734 |
HalOcaInterfaceNext::HalOcaInterfaceNext() |
| 735 |
{ |
| 736 |
} |
| 737 |
|
| 738 |
HalOcaInterfaceNext::HalOcaInterfaceNext(HalOcaInterfaceNext &) |
| 739 |
{ |
| 740 |
} |
| 741 |
|
| 742 |
HalOcaInterfaceNext& HalOcaInterfaceNext::operator= (HalOcaInterfaceNext &) |
| 743 |
{ |
| 744 |
return *this; |
| 745 |
} |