diff --git a/media_driver/agnostic/common/cm/cm_kernel_ex.cpp b/media_driver/agnostic/common/cm/cm_kernel_ex.cpp index 2d9493bb702..b78ac740288 100644 --- a/media_driver/agnostic/common/cm/cm_kernel_ex.cpp +++ b/media_driver/agnostic/common/cm/cm_kernel_ex.cpp @@ -585,10 +585,8 @@ CmSurfaceState* CmKernelEx::GetSurfaceState(CmSurface *surface, uint32_t index) } default: { - break; } } - break; } case CM_ENUM_CLASS_TYPE_CMSURFACESAMPLER8X8: { diff --git a/media_driver/agnostic/common/cm/cm_kernel_rt.cpp b/media_driver/agnostic/common/cm/cm_kernel_rt.cpp index f520c802031..b84a5e848a2 100644 --- a/media_driver/agnostic/common/cm/cm_kernel_rt.cpp +++ b/media_driver/agnostic/common/cm/cm_kernel_rt.cpp @@ -2011,6 +2011,11 @@ int32_t CmKernelRT::SetArgsInternal( CM_KERNEL_INTERNAL_ARG_TYPE nArgType, uint3 ( m_args[ index ].unitKind == ARG_KIND_STATE_BUFFER ) ) && surfIndexValue ) { CmSafeMemSet((void *)arg.surfIndex, 0, size/sizeof(int32_t) * sizeof(uint16_t)); + if( surfIndexValue == nullptr ) + { + CM_ASSERTMESSAGE("Error: Pointer to surface index value is null."); + return CM_NULL_POINTER; + } CmSafeMemCopy((void *)arg.surfIndex, surfIndexValue, size/sizeof(int32_t) * sizeof(uint16_t)); } @@ -2072,6 +2077,11 @@ int32_t CmKernelRT::SetArgsInternal( CM_KERNEL_INTERNAL_ARG_TYPE nArgType, uint3 return CM_OUT_OF_HOST_MEMORY; } CmSafeMemSet((void *)arg.surfIndex, 0, size/sizeof(uint32_t) * sizeof(uint16_t) * m_threadCount); + if( surfIndexValue == nullptr ) + { + CM_ASSERTMESSAGE("Error: Pointer to surface index value is null."); + return CM_NULL_POINTER; + } CmSafeMemCopy((void *)(arg.surfIndex + size/sizeof(uint32_t) * nThreadID), surfIndexValue, size/sizeof(uint32_t) * sizeof(uint16_t)); } m_perThreadArgExists = true; @@ -2107,6 +2117,11 @@ int32_t CmKernelRT::SetArgsInternal( CM_KERNEL_INTERNAL_ARG_TYPE nArgType, uint3 ( m_args[ index ].unitKind == ARG_KIND_SURFACE_2D_SCOREBOARD) || ( m_args[ index ].unitKind == ARG_KIND_STATE_BUFFER ) ) && surfIndexValue ) { + if( surfIndexValue == nullptr ) + { + CM_ASSERTMESSAGE("Error: Pointer to surface index value is null."); + return CM_NULL_POINTER; + } CmSafeMemCopy((void *)(arg.surfIndex + size/sizeof(uint32_t) * nThreadID), surfIndexValue, size/sizeof(uint32_t) * sizeof(uint16_t)); } } diff --git a/media_driver/agnostic/common/cm/cm_program.cpp b/media_driver/agnostic/common/cm/cm_program.cpp index ccc87a535d1..5b807bb9d77 100644 --- a/media_driver/agnostic/common/cm/cm_program.cpp +++ b/media_driver/agnostic/common/cm/cm_program.cpp @@ -581,7 +581,7 @@ int32_t CmProgramRT::Initialize( void* cisaCode, const uint32_t cisaCodeSize, co } CmSafeMemSet( errorMsg, 0, CM_JIT_ERROR_MESSAGE_SIZE ); - FINALIZER_INFO *jitProfInfo = (FINALIZER_INFO *)malloc(sizeof(FINALIZER_INFO)); + FINALIZER_INFO *jitProfInfo = (FINALIZER_INFO *)malloc(CM_JIT_PROF_INFO_SIZE); if(jitProfInfo == nullptr) { CM_ASSERTMESSAGE("Error: Out of system memory."); @@ -590,7 +590,7 @@ int32_t CmProgramRT::Initialize( void* cisaCode, const uint32_t cisaCodeSize, co hr = CM_OUT_OF_HOST_MEMORY; goto finish; } - CmSafeMemSet(jitProfInfo, 0, sizeof(FINALIZER_INFO)); + CmSafeMemSet( jitProfInfo, 0, CM_JIT_PROF_INFO_SIZE ); void *extra_info = nullptr; CmNotifierGroup *notifiers = m_device->GetNotifiers(); diff --git a/media_driver/agnostic/common/cm/cm_queue_rt.cpp b/media_driver/agnostic/common/cm/cm_queue_rt.cpp index 360e076cf4c..d190c647b37 100644 --- a/media_driver/agnostic/common/cm/cm_queue_rt.cpp +++ b/media_driver/agnostic/common/cm/cm_queue_rt.cpp @@ -2301,7 +2301,6 @@ void BufferCopyThread(void* threadData) CmEvent* wait_event = (CmEvent*)(data->wait_event); CmEvent* notify_event = (CmEvent*)(data->event); CmEventRT* eventRT = dynamic_cast(notify_event); - CM_CHK_NULL_RETURN_VOID(eventRT); CmEventEx* eex = dynamic_cast(notify_event); uint32_t offset = data->offset; @@ -2464,6 +2463,15 @@ int32_t CmQueueRT::EnqueueBufferCopy(CmBuffer* buffer, size_t offset, const unsi CM_CHK_NULL_GOTOFINISH_CMERROR(task); CM_CHK_CMSTATUS_GOTOFINISH(task->AddKernel(kernel)); + if (option & CM_FASTCOPY_OPTION_DISABLE_TURBO_BOOST) + { + // disable turbo + CM_TASK_CONFIG taskConfig; + CmSafeMemSet(&taskConfig, 0, sizeof(CM_TASK_CONFIG)); + taskConfig.turboBoostFlag = CM_TURBO_BOOST_DISABLE; + task->SetProperty(taskConfig); + } + CM_CHK_CMSTATUS_GOTOFINISH(EnqueueFast(task, event, threadSpace)); } diff --git a/media_driver/agnostic/common/cm/cm_surface_3d_rt.cpp b/media_driver/agnostic/common/cm/cm_surface_3d_rt.cpp index c50dc82dffb..8c09e6ed5e1 100644 --- a/media_driver/agnostic/common/cm/cm_surface_3d_rt.cpp +++ b/media_driver/agnostic/common/cm/cm_surface_3d_rt.cpp @@ -126,7 +126,7 @@ CM_RT_API int32_t CmSurface3DRT::WriteSurface( const unsigned char* sysMem, return CM_INVALID_ARG_VALUE; } - uSizeInBytes = (uint64_t)(m_width * m_height * m_depth * pixel); + uSizeInBytes = m_width * m_height * m_depth * pixel; if (sysMemSize < uSizeInBytes) { CM_ASSERTMESSAGE("Error: Invalid copy size.") @@ -257,7 +257,7 @@ CM_RT_API int32_t CmSurface3DRT::ReadSurface( unsigned char* sysMem, CmEvent* ev return CM_INVALID_ARG_VALUE; } - uSizeInBytes = (uint64_t)(m_width * m_height * m_depth * pixel); + uSizeInBytes = m_width * m_height * m_depth * pixel; if (sysMemSize < uSizeInBytes) { CM_ASSERTMESSAGE("Error: Invalid copy size.") diff --git a/media_driver/agnostic/common/cm/cm_visa.cpp b/media_driver/agnostic/common/cm/cm_visa.cpp index df8c3b47a3e..92563f6a3ea 100644 --- a/media_driver/agnostic/common/cm/cm_visa.cpp +++ b/media_driver/agnostic/common/cm/cm_visa.cpp @@ -39,9 +39,8 @@ ISAfile::ISAfile(const ISAfile& other) { data = other.data; end = other.end; size = other.size; - unsigned int error_length = std::strlen(other.error) + 1; - char *perror = new char[error_length]; - MOS_SecureMemcpy(perror, error_length, other.error, error_length); + char *perror = new char[std::strlen(other.error)]; + MOS_SecureMemcpy(perror, sizeof(perror), other.error, sizeof(other.error)); error = perror; kernel_data_loaded = other.kernel_data_loaded; function_data_loaded = other.function_data_loaded; @@ -67,9 +66,8 @@ ISAfile& ISAfile::operator= (const ISAfile& other) { end = other.end; size = other.size; delete[] error; - unsigned int error_length = std::strlen(other.error) + 1; - char *perror = new char[error_length]; - MOS_SecureMemcpy(perror, error_length, other.error, error_length); + char *perror = new char[std::strlen(other.error)]; + MOS_SecureMemcpy(perror, sizeof perror, other.error, sizeof other.error); error = perror; kernel_data_loaded = other.kernel_data_loaded; function_data_loaded = other.function_data_loaded;