| 1 |
/* |
| 2 |
* Copyright (c) 2009-2021, Intel Corporation |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 5 |
* copy of this software and associated documentation files (the "Software"), |
| 6 |
* to deal in the Software without restriction, including without limitation |
| 7 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 9 |
* Software is furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice shall be included |
| 12 |
* in all copies or substantial portions of the Software. |
| 13 |
* |
| 14 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 |
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 |
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 |
* OTHER DEALINGS IN THE SOFTWARE. |
| 21 |
*/ |
| 22 |
//! |
| 23 |
//! \file mos_oca_interface.h |
| 24 |
//! \brief Common interface and structure for OCA |
| 25 |
//! |
| 26 |
|
| 27 |
#ifndef __MOS_OCA_INTERFACE_H__ |
| 28 |
#define __MOS_OCA_INTERFACE_H__ |
| 29 |
|
| 30 |
#include "mos_oca_defs.h" |
| 31 |
|
| 32 |
class MosOcaInterface |
| 33 |
{ |
| 34 |
public: |
| 35 |
//! |
| 36 |
//! \brief Destructor |
| 37 |
//! |
| 38 |
virtual ~MosOcaInterface() {} |
| 39 |
|
| 40 |
//! |
| 41 |
//! \brief Get the idle oca buffer, which is neither used by hw nor locked, and lock it for edit. |
| 42 |
//! \param [in] pMosContext |
| 43 |
//! pointer to MOS_INTERFACE |
| 44 |
//! \param [in] CurrentGpuContextHandle |
| 45 |
//! Gpu context handle |
| 46 |
//! \return MOS_OCA_BUFFER_HANDLE |
| 47 |
//! return the handle for oca buffer |
| 48 |
//! |
| 49 |
virtual MOS_OCA_BUFFER_HANDLE LockOcaBufAvailable(PMOS_CONTEXT pMosContext, uint32_t CurrentGpuContextHandle) |
| 50 |
{ |
| 51 |
return 0; |
| 52 |
} |
| 53 |
|
| 54 |
//! |
| 55 |
//! \brief Unlock the oca buffer when edit complete. |
| 56 |
//! \param [in] hOcaBuf |
| 57 |
//! Oca buffer handle. |
| 58 |
//! \return MOS_STATUS |
| 59 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 60 |
//! |
| 61 |
virtual MOS_STATUS UnlockOcaBuf(MOS_OCA_BUFFER_HANDLE hOcaBuf) |
| 62 |
{ |
| 63 |
return MOS_STATUS_UNIMPLEMENTED; |
| 64 |
} |
| 65 |
|
| 66 |
virtual void UnlockPendingOcaBuffers(PMOS_CONTEXT mosCtx, struct MOS_OCA_EXEC_LIST_INFO *info, int count) |
| 67 |
{ |
| 68 |
MOS_OS_ASSERTMESSAGE("MosOcaInterface::UnlockPendingOcaBuffers should not be called!"); |
| 69 |
} |
| 70 |
|
| 71 |
virtual MOS_STATUS UnlockOcaBufferWithDelay(MOS_OCA_BUFFER_HANDLE ocaBufHandle) |
| 72 |
{ |
| 73 |
return MOS_STATUS_UNIMPLEMENTED; |
| 74 |
} |
| 75 |
|
| 76 |
//! |
| 77 |
//! \brief Oca operation which should be called at the beginning of 1st level batch buffer start. |
| 78 |
//! \param [out] gpuVaOcaBuffer |
| 79 |
//! The gfx virtual address of oca buffer, which should be set to GPR11 by LRI at the |
| 80 |
//! beginning of 1st level batch buffer no matter return value is MOS_STATUS_SUCCESS or not. |
| 81 |
//! \param [in] hOcaBuf |
| 82 |
//! Oca buffer handle. |
| 83 |
//! \param [in] pMosContext |
| 84 |
//! Pointer to MOS_CONTEXT. |
| 85 |
//! \param [in] pMosResource |
| 86 |
//! Pointer to the MOS_RESOURCE. |
| 87 |
//! \param [in] offsetOf1stLevelBB |
| 88 |
//! Offset for current BB in pMosResource. |
| 89 |
//! \param [in] bUseSizeOfResource |
| 90 |
//! If true, use size of pMosResource for batch buffer, else use sizeOf1stLevelBB. |
| 91 |
//! \param [in] sizeOf1stLevelBB |
| 92 |
//! Size of BB. Ignore if bUseSizeOfResource == true. |
| 93 |
//! \return MOS_STATUS |
| 94 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 95 |
//! |
| 96 |
virtual MOS_STATUS On1stLevelBBStart(uint64_t &gpuVaOcaBuffer, MOS_OCA_BUFFER_HANDLE hOcaBuf, PMOS_CONTEXT pMosContext, void *pMosResource, |
| 97 |
uint32_t offsetOf1stLevelBB, bool bUseSizeOfResource, uint32_t sizeOf1stLevelBB) |
| 98 |
{ |
| 99 |
// The GPR11 need to be reset to 0 to disable UMD_OCA for current workload. |
| 100 |
gpuVaOcaBuffer = 0; |
| 101 |
return MOS_STATUS_UNIMPLEMENTED; |
| 102 |
} |
| 103 |
|
| 104 |
//! |
| 105 |
//! \brief Oca operation which should be called before adding batch buffer end command for 1st |
| 106 |
//! level batch buffer. |
| 107 |
//! \param [in] hOcaBuf |
| 108 |
//! Oca buffer handle. |
| 109 |
//! \param [in] mosCtx |
| 110 |
//! DDI device context. |
| 111 |
//! \return MOS_STATUS |
| 112 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 113 |
//! |
| 114 |
virtual MOS_STATUS On1stLevelBBEnd(MOS_OCA_BUFFER_HANDLE hOcaBuf, PMOS_CONTEXT mosCtx) |
| 115 |
{ |
| 116 |
return MOS_STATUS_UNIMPLEMENTED; |
| 117 |
} |
| 118 |
|
| 119 |
//! |
| 120 |
//! \brief Oca operation which should be called before sending start sub level batch buffer command. |
| 121 |
//! \param [in] hOcaBuf |
| 122 |
//! Oca buffer handle. |
| 123 |
//! \param [in] pMosContext |
| 124 |
//! Pointer to MOS_CONTEXT. |
| 125 |
//! \param [in] pMosResource |
| 126 |
//! Pointer to the MOS_RESOURCE. |
| 127 |
//! \param [in] offsetOfSubLevelBB |
| 128 |
//! Offset for current BB in pMosResource. |
| 129 |
//! \param [in] bUseSizeOfResource |
| 130 |
//! If true, use size of pMosResource for batch buffer, else use sizeOfIndirectState. |
| 131 |
//! \param [in] sizeOfSubLevelBB |
| 132 |
//! Size of BB. Ignore if bUseSizeOfResource == true. |
| 133 |
//! \return MOS_STATUS |
| 134 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 135 |
//! |
| 136 |
virtual MOS_STATUS OnSubLevelBBStart(MOS_OCA_BUFFER_HANDLE hOcaBuf, PMOS_CONTEXT pMosContext, void *pMosResource, uint32_t offsetOfSubLevelBB, bool bUseSizeOfResource, uint32_t sizeOfSubLevelBB) |
| 137 |
{ |
| 138 |
return MOS_STATUS_UNIMPLEMENTED; |
| 139 |
} |
| 140 |
|
| 141 |
//! |
| 142 |
//! \brief Oca operation which should be called when indirect states being added. |
| 143 |
//! \param [in] hOcaBuf |
| 144 |
//! Oca buffer handle. |
| 145 |
//! \param [in] pMosContext |
| 146 |
//! Pointer to MOS_CONTEXT. |
| 147 |
//! \param [in] pMosResource |
| 148 |
//! Pointer to the MOS_RESOURCE. |
| 149 |
//! \param [in] offsetOfIndirectState |
| 150 |
//! Offset for current state in pMosResource. |
| 151 |
//! \param [in] bUseSizeOfResource |
| 152 |
//! If true, use size of pMosResource for indirect state, else use sizeOfIndirectState. |
| 153 |
//! \param [in] sizeOfIndirectState |
| 154 |
//! Size of indirect state. Ignore if bUseSizeOfResource == true. |
| 155 |
//! \return MOS_STATUS |
| 156 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 157 |
//! |
| 158 |
virtual MOS_STATUS OnIndirectState(MOS_OCA_BUFFER_HANDLE hOcaBuf, PMOS_CONTEXT pMosContext, void *pMosResource, uint32_t offsetOfIndirectState, bool bUseSizeOfResource, uint32_t sizeOfIndirectState) |
| 159 |
{ |
| 160 |
return MOS_STATUS_UNIMPLEMENTED; |
| 161 |
} |
| 162 |
|
| 163 |
//! |
| 164 |
//! \brief Oca operation which should be called before adding dispatch states, |
| 165 |
//! e.g. VEB_DI_IECP_STATE and MEDIA_OBJECT_WALKER. |
| 166 |
//! \param [out] offsetInIndirectStateHeap |
| 167 |
//! The start offset of current dispatch in indirect state heap, which should be set to low 32 bits |
| 168 |
//! of GPR12 by LRI before dispatch commands being added. |
| 169 |
//! OCA_HEAP_INVALID_OFFSET means no need to configure GPR12, otherwise the register need be configured |
| 170 |
//! no matter return value being MOS_STATUS_SUCCESS or not. |
| 171 |
//! \param [in] hOcaBuf |
| 172 |
//! Oca buffer handle. |
| 173 |
//! \param [in] mosCtx |
| 174 |
//! DDI device context. |
| 175 |
//! \return MOS_STATUS |
| 176 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 177 |
//! |
| 178 |
virtual MOS_STATUS OnDispatch(uint32_t &offsetInIndirectStateHeap, MOS_OCA_BUFFER_HANDLE hOcaBuf, PMOS_CONTEXT mosCtx) |
| 179 |
{ |
| 180 |
offsetInIndirectStateHeap = OCA_HEAP_INVALID_OFFSET; |
| 181 |
return MOS_STATUS_UNIMPLEMENTED; |
| 182 |
} |
| 183 |
|
| 184 |
//! |
| 185 |
//! \brief Add string to oca log section |
| 186 |
//! \param [in] hOcaBuf |
| 187 |
//! Oca buffer handle. |
| 188 |
//! \param [in] mosCtx |
| 189 |
//! DDI device context. |
| 190 |
//! \param [in] str |
| 191 |
//! string to be added. |
| 192 |
//! \param [in] maxCount |
| 193 |
//! size of the buffer pointed by str. |
| 194 |
//! \return MOS_STATUS |
| 195 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 196 |
//! |
| 197 |
virtual MOS_STATUS TraceMessage(MOS_OCA_BUFFER_HANDLE hOcaBuf, PMOS_CONTEXT mosCtx, const char *str, uint32_t maxCount) |
| 198 |
{ |
| 199 |
return MOS_STATUS_UNIMPLEMENTED; |
| 200 |
} |
| 201 |
|
| 202 |
//! |
| 203 |
//! \brief Add resource to dump list. |
| 204 |
//! \param [in] hOcaBuf |
| 205 |
//! Oca buffer handle. |
| 206 |
//! \param [in] mosCtx |
| 207 |
//! DDI device context. |
| 208 |
//! \param [in] resource |
| 209 |
//! Reference to MOS_RESOURCE. |
| 210 |
//! \param [in] hwCmdType |
| 211 |
//! Hw command Type. |
| 212 |
//! \param [in] locationInCmd |
| 213 |
//! Location in command. |
| 214 |
//! \param [in] offsetInRes |
| 215 |
//! Offset in resource. |
| 216 |
//! \return MOS_STATUS |
| 217 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 218 |
//! |
| 219 |
virtual MOS_STATUS AddResourceToDumpList(MOS_OCA_BUFFER_HANDLE hOcaBuf, PMOS_CONTEXT mosCtx, MOS_RESOURCE &resource, MOS_HW_COMMAND hwCmdType, uint32_t locationInCmd, uint32_t offsetInRes) |
| 220 |
{ |
| 221 |
return MOS_STATUS_UNIMPLEMENTED; |
| 222 |
} |
| 223 |
|
| 224 |
//! |
| 225 |
//! \brief Add resource to dump list. |
| 226 |
//! \param [in] hOcaBuf |
| 227 |
//! Oca buffer handle. |
| 228 |
//! \param [in] mosCtx |
| 229 |
//! DDI device context. |
| 230 |
//! \param [in] resource |
| 231 |
//! Reference to MOS_RESOURCE. |
| 232 |
//! \param [in] hwCmdType |
| 233 |
//! Hw command Type. |
| 234 |
//! \param [in] locationInCmd |
| 235 |
//! Location in command. |
| 236 |
//! \param [in] offsetInRes |
| 237 |
//! Offset in resource. |
| 238 |
//! \return MOS_STATUS |
| 239 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 240 |
//! |
| 241 |
virtual MOS_STATUS AddBufferResourceToDumpList(MOS_OCA_BUFFER_HANDLE hOcaBuf, PMOS_CONTEXT mosCtx, MOS_RESOURCE &resource, MOS_HW_COMMAND hwCmdType, uint32_t locationInCmd, uint32_t offsetInRes) |
| 242 |
{ |
| 243 |
return MOS_STATUS_UNIMPLEMENTED; |
| 244 |
} |
| 245 |
|
| 246 |
//! |
| 247 |
//! \brief Add data block to oca log section. |
| 248 |
//! \param [in] hOcaBuf |
| 249 |
//! Oca buffer handle. |
| 250 |
//! \param [in] mosCtx |
| 251 |
//! DDI device context. |
| 252 |
//! \param [in] pHeader |
| 253 |
//! Log header. It can be extended by user. The acutal size of header is pHeader->m_HeaderSize. |
| 254 |
//! \param [in] pData |
| 255 |
//! Data block without log header. The acutal size of data block is pHeader->m_DataSize. |
| 256 |
//! \return MOS_STATUS |
| 257 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 258 |
//! |
| 259 |
virtual MOS_STATUS DumpDataBlock(MOS_OCA_BUFFER_HANDLE hOcaBuf, PMOS_CONTEXT mosCtx, PMOS_OCA_LOG_HEADER pHeader, void *pData) |
| 260 |
{ |
| 261 |
return MOS_STATUS_UNIMPLEMENTED; |
| 262 |
} |
| 263 |
|
| 264 |
//! |
| 265 |
//! \brief Get the mutex for oca buffer handles protection. |
| 266 |
//! \return PMOS_MUTEX |
| 267 |
//! Return PMOS_MUTEX if successful, otherwise nullptr |
| 268 |
//! |
| 269 |
virtual PMOS_MUTEX GetMutex() |
| 270 |
{ |
| 271 |
return nullptr; |
| 272 |
} |
| 273 |
|
| 274 |
//! |
| 275 |
//! \brief Insert OCA buffer handle into m_hOcaMap |
| 276 |
//! \param [in] key |
| 277 |
//! The key of m_hOcaMap. |
| 278 |
//! \param [in] handle |
| 279 |
//! Oca buffer handle. |
| 280 |
//! \return MOS_STATUS |
| 281 |
//! Return MOS_STATUS_SUCCESS if insert successfully, otherwise insert failed. |
| 282 |
//! |
| 283 |
virtual MOS_STATUS InsertOcaBufHandleMap(uint32_t *key, MOS_OCA_BUFFER_HANDLE handle) = 0; |
| 284 |
|
| 285 |
//! |
| 286 |
//! \brief Remove OCA buffer handle from m_hOcaMap |
| 287 |
//! \param [in] key |
| 288 |
//! The key of m_hOcaMap. |
| 289 |
//! \return MOS_STATUS |
| 290 |
//! Return MOS_STATUS_SUCCESS if erase successfully, otherwise erase failed. |
| 291 |
//! |
| 292 |
virtual MOS_STATUS RemoveOcaBufHandleFromMap(uint32_t *key) = 0; |
| 293 |
|
| 294 |
//! |
| 295 |
//! \brief Get OCA buffer handle from m_hOcaMap |
| 296 |
//! \param [in] key |
| 297 |
//! The key of m_hOcaMap. |
| 298 |
//! \return MOS_OCA_BUFFER_HANDLE |
| 299 |
//! Return oca buffer handle. |
| 300 |
//! |
| 301 |
virtual MOS_OCA_BUFFER_HANDLE GetOcaBufHandleFromMap(uint32_t *key) = 0; |
| 302 |
|
| 303 |
//! |
| 304 |
//! \brief Get OCA status. |
| 305 |
//! \return MOS_STATUS |
| 306 |
//! Return oca status |
| 307 |
//! |
| 308 |
virtual MOS_STATUS GetOCAStatus() = 0; |
| 309 |
|
| 310 |
//! |
| 311 |
//! \brief Set OCA status |
| 312 |
//! \param [in] status |
| 313 |
//! oca status. |
| 314 |
//! \return void |
| 315 |
//! |
| 316 |
virtual void SetOCAStatus(MOS_STATUS status) = 0; |
| 317 |
|
| 318 |
//! |
| 319 |
//! \brief Set OCA error line number |
| 320 |
//! \param [in] num |
| 321 |
//! line number |
| 322 |
//! \return void |
| 323 |
//! |
| 324 |
virtual void SetOCAErrorLineNumber(uint32_t num) = 0; |
| 325 |
}; |
| 326 |
|
| 327 |
#endif // #ifndef __MOS_OCA_INTERFACE_H__ |