1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464
|
/*
* Copyright (c) 2017-2018, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
//!
//! \file mos_context_specific.h
//! \brief Container for Linux/Android specific parameters shared across different GPU contexts of the same device instance
//!
#ifndef __MOS_CONTEXT_SPECIFIC_H__
#define __MOS_CONTEXT_SPECIFIC_H__
#include "mos_os_specific.h"
#include "mos_context.h"
#include "mos_auxtable_mgr.h"
class GraphicsResourceSpecific;
class CmdBufMgr;
class GpuContextMgr;
class OsContextSpecific : public OsContext
{
friend class GraphicsResourceSpecific;
//!
//! \brief SW semaphore key for share memory btw dual VDBox
//!
constexpr static uint32_t m_dualVdboxKey= ('D'<<24|'V'<<8|'X'<<0);
//!
//! \brief SW semaphore key for share memory to store SSEU configration
//!
constexpr static uint32_t m_sseuKey= ('S'<<24|'S'<<16|'E'<<8|'U'<<0);
//!
//! \brief shared memory size
//!
constexpr static uint32_t m_sseuShmSize = 256;
//!
//! \brief slice count value timeout critera in milliseconds
//!
constexpr static uint64_t m_sliceCountTimeoutMS = 1000;
#ifndef ANDROID
//!
//! \brief Initial share memory handle
//!
constexpr static void* MOS_LINUX_SHM_INVALID = (void *)nullptr;
//!
//! \brief Initial share memory ID
//!
constexpr static int32_t MOS_LINUX_IPC_INVALID_ID = -1;
//!
//! \brief maximum number to try to get a valid semaphore
//!
constexpr static uint32_t MOS_LINUX_SEM_MAX_TRIES = 10;
#endif
public:
//!
//! \brief Do not disable kmd watchdog, that is to say, pass
//! < 0: I915_EXEC_ENABLE_WATCHDOG flag to KMD;
//! < 1: Disable kmd watchdog;
//! that is to say, DO NOT pass I915_EXEC_ENABLE_WATCHDOG flag to KMD;
struct PerfInfo {
bool m_disableKmdWatchdog;
uint32_t m_enablePerfTag;
} ;
//!
//! \brief Constructor
//!
OsContextSpecific();
//!
//! \brief Destructor
//!
~OsContextSpecific();
//!
//! \brief Initialize the MOS Context
//! \param [in] pOsDriverContext
//! ptr to MOS_CONTEXT created inside DDI
//! \return MOS_Success in pass case, MOS error status in fail cases
//!
MOS_STATUS Init(PMOS_CONTEXT osDriverContext);
//!
//! \brief Destroy the os specific MOS context
//!
void Destroy();
//!
//! \brief Get the performance information
//!
struct PerfInfo GetPerfInfo() { return m_performanceInfo; }
//!
//! \brief Get the performance information
//!
void SetPerfInfo(const struct PerfInfo &performanceInfo)
{
MOS_SecureMemcpy(&m_performanceInfo, sizeof(struct PerfInfo), &performanceInfo, sizeof(struct PerfInfo));
}
//!
//! \brief Return whether we need 64bit relocation
//!
bool Is64BitRelocUsed() { return m_use64BitRelocs; }
//!
//! \brief Return whether the KMD support the 2nd VCS
//!
bool IsKmdWithVcs2() { return m_kmdHasVCS2; }
//!
//! \brief Return the semaphore ID we use to protect the IPC creation process
//! \return sem id
//!
int32_t GetSemId() { return m_semId; }
//!
//! \brief Return the shm ID for the IPC
//! \return shm id
int32_t GetShmId() { return m_shmId; }
//!
//! \brief Return the shm object for the IPC
//! \return shm id
//!
void *GetShmPtr() { return m_shm; }
//!
//! \brief Return the function ptr for memory decompression function
//!
void *GetpfnMemoryDecompaddr() { return (void *)m_memoryDecompress; }
MOS_LINUX_CONTEXT *GetDrmContext() { return m_intelContext; }
GPU_CONTEXT_HANDLE GetGpuContextHandle(MOS_GPU_CONTEXT GpuContext)
{
return m_GpuContextHandle[GpuContext];
}
void SetGpuContextHandle(MOS_GPU_CONTEXT GpuContext, GPU_CONTEXT_HANDLE gpuContextHandle)
{
m_GpuContextHandle[GpuContext] = gpuContextHandle;
}
GPU_CONTEXT_HANDLE GetGpuContextHandleByIndex(uint32_t index)
{
return (index < MOS_GPU_CONTEXT_MAX) ? m_GpuContextHandle[index] : MOS_GPU_CONTEXT_INVALID_HANDLE;
}
void SetGpuContextHandleByIndex(uint32_t index, GPU_CONTEXT_HANDLE gpuContextHandle)
{
if (index < MOS_GPU_CONTEXT_MAX)
{
m_GpuContextHandle[index] = gpuContextHandle;
}
}
GpuContextMgr *GetGpuContextMgr() { return m_gpuContextMgr; }
CmdBufMgr* GetCmdBufMgr(){return m_cmdBufMgr;}
GMM_CLIENT_CONTEXT* GetGmmClientContext() { return m_pGmmClientContext; };
AuxTableMgr* GetAuxTableMgr() { return m_auxTableMgr; }
bool UseSwSwizzling() { return m_useSwSwizzling; }
bool GetTileYFlag() { return m_tileYFlag; }
#ifndef ANDROID
//!
//! \brief Set slice count to shared memory and KMD
//! \param [in,out] pSliceCount
//! Pointer to the slice count. Input the slice count for current
//! context, output the ruling slice count shared by all contexts.
//!
void SetSliceCount(uint32_t *pSliceCount);
#endif
//!
//! \brief Get the context priority from KMD
//! \param [in, out] pPriority
//! Pointer to the priority of current gpu context.
//!
void GetGpuPriority(int32_t *pPriority);
//!
//! \brief Get the context priority from KMD
//! \param [in] priority
//! the priority set to current gpu context.
//!
void SetGpuPriority(int32_t priority);
private:
#ifndef ANDROID
//!
//! \brief connect and create share memory for driver secure IPC
//! \param [in] key
//! used to generate key_value for share memory
//! \param [in] key
//! share memory size
//! \param [out] pShmid
//! ptr to int value for share memory id
//! \param [out] ppShm
//! ptr to ptr for share memory
//! \return MOS_SUCCESS in success case, MOS error status in fail cases
//!
MOS_STATUS ConnectCreateShm(long key, uint32_t size, int32_t * pShmid, void* *ppShm);
//!
//! \brief destory the share memory
//! \param [in] pShmid
//! ptr to int value for share memory id
//! \param [in] ppShm
//! ptr to ptr for share memory
//! \return MOS_SUCCESS in success case, MOS error status in fail cases
//!
MOS_STATUS DetachDestroyShm(int32_t shmid, void* pShm);
//!
//! \brief connect and create semaphore for driver secure IPC
//! \param [in] key
//! used to generate key_value for share memory
//! \param [out] pSemid
//! ptr to sem id created
//! \return MOS_SUCCESS in success case, MOS error status in fail cases
//!
MOS_STATUS ConnectCreateSemaphore(long key, int32_t *pSemid);
//!
//! \brief create driver secure IPC
//! \return MOS_SUCCESS in success case, MOS error status in fail cases
//!
MOS_STATUS CreateIPC();
//!
//! \brief unlock the semaphore used in driver IPC
//! \param [in] semid
//! semaphore id to be unlocked
//! \return MOS_SUCCESS in success case, MOS error status in fail cases
//!
MOS_STATUS UnLockSemaphore(int32_t semid);
//!
//! \brief lock the semaphore used in driver IPC
//! \param [in] semid
//! semaphore id to be locked
//! \return MOS_SUCCESS in success case, MOS error status in fail cases
//!
MOS_STATUS LockSemaphore(int32_t semid);
//!
//! \brief destroy the IPC instance
//!
void DestroyIPC();
//!
//! \brief attach to the share memory instance
//! \param shmid
//! [in] share memory id to be attached
//! \return share memory attached
//!
short ShmAttachedNumber(unsigned int shmid);
//!
//! \brief destroy the semaphore
//! \param shmid
//! [in] Semaphore id to be destoried
//!
MOS_STATUS DestroySemaphore(unsigned int semid);
//!
//! \brief create driver secure IPC for SSEU setting
//! \return MOS_SUCCESS in success case, MOS error status in fail cases
//!
MOS_STATUS CreateSSEUIPC();
//!
//! \brief destroy the SSEU IPC instance
//!
void DestroySSEUIPC();
#endif // #ifndef ANDROID
//!
//! \brief Performance specific switch for debug purpose
//!
struct PerfInfo m_performanceInfo = {};
//!
//! \brief Performance specific information for debug purpose
//!
PERF_DATA m_perfData = {};
//!
//! \brief switch for 64bit KMD relocation
//!
bool m_use64BitRelocs = false;
//!
//! \brief tiling/untiling with CPU
//!
bool m_useSwSwizzling = false;
//!
//! \brief Sku tile Y flag
//!
bool m_tileYFlag = true;
//!
//! \brief flag to mark the existance of the second VDBox
//!
bool m_kmdHasVCS2 = false;
//!
//! \brief Semophore ID for secure IPC
//!
int32_t m_semId = 0;
//!
//! \brief Share memory ID for secure IPC
//!
int32_t m_shmId = 0;
//!
//! \brief Share memory ptr for secure IPC
//!
void* m_shm = nullptr;
//!
//! \brief Support slice count set in KMD
//!
bool m_sliceCountSetSupported = 0;
//!
//! \brief Enable/Disable dynamic slice shutdown and static slice config
//! -1 Use timer-based dynamic slice shutdown
//! 0 [default] Use default slices count
//! >0 Static slice shutdown, N for N slices
//!
int m_enableDymanicSliceShutdown = 0;
//!
//! \brief sseu for current context
//!
uint64_t m_sseu = 0;
//!
//! \brief Semophore ID for ruling SSEU configration
//!
int32_t m_sseuSemId = 0;
//!
//! \brief Share memory ID for ruling SSEU configration
//!
int32_t m_sseuShmId = 0;
//!
//! \brief Share memory ptr to the ruling SSEU configration
//!
void* m_sseuShm = nullptr;
//!
//! \brief Hybrid Decoder Multi-Threading Enable Flag
//!
bool m_hybridDecMultiThreadEnabled = false;
//!
//! \brief Flag to indicate if hybrid decoder is running
//!
bool m_hybridDecoderRunningFlag = false;
//!
//! \brief the function ptr for memory decompression function
//!
void (* m_memoryDecompress)(
PMOS_CONTEXT pOsContext,
PMOS_RESOURCE pOsResource) = nullptr;
//!
//! \brief the function ptr for surface copy function
//!
void (* m_mediaMemCopy )(
PMOS_CONTEXT pOsContext,
PMOS_RESOURCE pInputResource,
PMOS_RESOURCE pOutputResource,
bool bOutputCompressed) = nullptr;
//!
//! \brief the function ptr for Media Memory 2D copy function
//!
void (* m_mediaMemCopy2D)(
PMOS_CONTEXT pOsContext,
PMOS_RESOURCE pInputResource,
PMOS_RESOURCE pOutputResource,
uint32_t copyWidth,
uint32_t copyHeight,
uint32_t copyInputOffset,
uint32_t copyOutputOffset,
uint32_t bpp,
bool bOutputCompressed) = nullptr;
//!
//! \brief ptr to ptr of memory decompression state
//!
void* *m_mediaMemDecompState = nullptr;
//!
//! \brief ptr to mos context(kept for memory decompression function, to be cleaned up)
//!
PMOS_CONTEXT m_mosContext = nullptr;
//!
//! \brief the function ptr for memory decompression function
//!
uint32_t *m_transcryptedKernels = nullptr;
//!
//! \brief Size in bytes of the cached version of transcrypted and authenticated kernels
//!
uint32_t m_transcryptedKernelsSize = 0;
//!
//! \brief ptr to DRM bufmgr
//!
MOS_BUFMGR *m_bufmgr = nullptr;
//!
//! \brief ptr to intel context
//!
MOS_LINUX_CONTEXT *m_intelContext = nullptr;
//!
//! \brief drm device fd
//!
uint32_t m_fd = 0;
//!
//!UMD specific ClientContext object in GMM
//!
GMM_CLIENT_CONTEXT *m_pGmmClientContext = nullptr;
AuxTableMgr *m_auxTableMgr = nullptr;
GPU_CONTEXT_HANDLE m_GpuContextHandle[MOS_GPU_CONTEXT_MAX]; // Index to GPU Context (GpuContextHandles)
GpuContextMgr *m_gpuContextMgr = nullptr;
CmdBufMgr *m_cmdBufMgr = nullptr;
bool m_apoMosEnabled = false;
};
#endif // #ifndef __MOS_CONTEXT_SPECIFIC_H__
|