Skip to content

Commit

Permalink
[VP] UMD_OCA Implement
Browse files Browse the repository at this point in the history
1. Add UMD_OCA support in mos.
2. Add UMD_OCA support for VP RCS case (No CM based) and Vebox/SFC case.
3. It is disabled by default.

Change-Id: I10df7a0a487d3a89e7040d45ef7caeef1995cbc6
  • Loading branch information
xiaoton1 authored and intel-mediadev committed May 23, 2019
1 parent f5ba66b commit d4df345
Show file tree
Hide file tree
Showing 46 changed files with 1,117 additions and 72 deletions.
8 changes: 8 additions & 0 deletions media_driver/agnostic/common/hw/mhw_mmio.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ typedef struct _MHW_MI_MMIOREGISTERS
uint32_t generalPurposeRegister0HiOffset;
uint32_t generalPurposeRegister4LoOffset;
uint32_t generalPurposeRegister4HiOffset;
uint32_t generalPurposeRegister11LoOffset; //!< __OCA_BUFFER_ADDR_LOW_MMIO
uint32_t generalPurposeRegister11HiOffset; //!< __OCA_BUFFER_ADDR_HIGH_MMIO
uint32_t generalPurposeRegister12LoOffset; //!< __OCA_BUFFER_IND_STATE_SECTION_OFFSET_MMIO
uint32_t generalPurposeRegister12HiOffset; //!< __OCA_BUFFER_BB_SECTION_OFFSET_MMIO
} MHW_MI_MMIOREGISTERS, *PMHW_MI_MMIOREGISTERS;


Expand Down Expand Up @@ -107,6 +111,10 @@ struct MmioRegistersMfx
uint32_t generalPurposeRegister0HiOffset = 0;
uint32_t generalPurposeRegister4LoOffset = 0;
uint32_t generalPurposeRegister4HiOffset = 0;
uint32_t generalPurposeRegister11LoOffset = 0; //!< __OCA_BUFFER_ADDR_LOW_MMIO
uint32_t generalPurposeRegister11HiOffset = 0; //!< __OCA_BUFFER_ADDR_HIGH_MMIO
uint32_t generalPurposeRegister12LoOffset = 0; //!< __OCA_BUFFER_IND_STATE_SECTION_OFFSET_MMIO
uint32_t generalPurposeRegister12HiOffset = 0; //!< __OCA_BUFFER_BB_SECTION_OFFSET_MMIO
uint32_t mfcImageStatusMaskRegOffset = 0;
uint32_t mfcImageStatusCtrlRegOffset = 0;
uint32_t mfcAvcNumSlicesRegOffset = 0;
Expand Down
8 changes: 8 additions & 0 deletions media_driver/agnostic/common/hw/mhw_render.h
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,14 @@ class MhwRenderInterface
//!
void SetOsInterface(PMOS_INTERFACE osInterface) { m_osInterface = osInterface;}

//!
//! \brief Get mmio registers address
//! \details Get mmio registers address
//! \return [out] PMHW_MI_MMIOREGISTERS*
//! mmio registers got.
//!
virtual PMHW_MI_MMIOREGISTERS GetMmioRegisters() = 0;

protected:
//!
//! \brief Initializes the Render interface
Expand Down
1 change: 1 addition & 0 deletions media_driver/agnostic/common/os/media_srcs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ set(TMP_HEADERS_
${CMAKE_CURRENT_LIST_DIR}/mos_gpucontextmgr.h
${CMAKE_CURRENT_LIST_DIR}/mos_cmdbufmgr.h
${CMAKE_CURRENT_LIST_DIR}/mos_commandbuffer.h
${CMAKE_CURRENT_LIST_DIR}/mos_oca_interface.h
)

set(SOURCES_
Expand Down
3 changes: 2 additions & 1 deletion media_driver/agnostic/common/os/mos_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ typedef enum _MOS_STATUS
MOS_STATUS_CLIENT_AR_NO_SPACE = 28,
MOS_STATUS_HUC_KERNEL_FAILED = 29,
MOS_STATUS_NOT_ENOUGH_BUFFER = 30,
MOS_STATUS_UNKNOWN = 31
MOS_STATUS_UNINITIALIZED = 31,
MOS_STATUS_UNKNOWN = 32
} MOS_STATUS;

//!
Expand Down
211 changes: 211 additions & 0 deletions media_driver/agnostic/common/os/mos_oca_interface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
/*
* Copyright (c) 2009-2019, 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_oca_interface.h
//! \brief Common interface and structure for OCA
//!

#ifndef __MOS_OCA_INTERFACE_H__
#define __MOS_OCA_INTERFACE_H__

typedef uint64_t MOS_OCA_BUFFER_HANDLE;
#define OCA_HEAP_INVALID_OFFSET ((uint32_t)-1)

typedef struct _MOS_OCA_LOG_HEADER
{
uint32_t m_Type; //!< Oca log type. Refer to MOS_OCA_LOG_TYPE.
uint32_t m_HeaderSize; //!< The size for extented message header.
uint32_t m_DataSize; //!< The size of data block without message header.
}MOS_OCA_LOG_HEADER, *PMOS_OCA_LOG_HEADER;

class MosOcaInterface
{
public:
//!
//! \brief Destructor
//!
virtual ~MosOcaInterface() {}

//!
//! \brief Get the idle oca buffer, which is neither used by hw nor locked, and lock it for edit.
//! \param [in] pMosContext
//! pointer to MOS_INTERFACE
//! \param [in] CurrentGpuContextHandle
//! Gpu context handle
//! \return MOS_OCA_BUFFER_HANDLE
//! return the handle for oca buffer
//!
virtual MOS_OCA_BUFFER_HANDLE LockOcaBufAvailable(PMOS_CONTEXT pMosContext, uint32_t CurrentGpuContextHandle)
{
return 0;
}

//!
//! \brief Unlock the oca buffer when edit complete.
//! \param [in] hOcaBuf
//! Oca buffer handle.
//! \return MOS_STATUS
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed
//!
virtual MOS_STATUS UnlockOcaBuf(MOS_OCA_BUFFER_HANDLE hOcaBuf)
{
return MOS_STATUS_UNIMPLEMENTED;
}

//!
//! \brief Oca operation which should be called at the beginning of 1st level batch buffer start.
//! \param [out] gpuVaOcaBuffer
//! The gfx virtual address of oca buffer, which should be set to GPR11 by LRI at the
//! beginning of 1st level batch buffer no matter return value is MOS_STATUS_SUCCESS or not.
//! \param [in] hOcaBuf
//! Oca buffer handle.
//! \param [in] pMosContext
//! Pointer to MOS_CONTEXT.
//! \param [in] pMosResource
//! Pointer to the MOS_RESOURCE.
//! \param [in] offsetOf1stLevelBB
//! Offset for current BB in pMosResource.
//! \param [in] bUseSizeOfResource
//! If true, use size of pMosResource for batch buffer, else use sizeOf1stLevelBB.
//! \param [in] sizeOf1stLevelBB
//! Size of BB. Ignore if bUseSizeOfResource == true.
//! \return MOS_STATUS
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed
//!
virtual MOS_STATUS On1stLevelBBStart(uint64_t &gpuVaOcaBuffer, MOS_OCA_BUFFER_HANDLE hOcaBuf, PMOS_CONTEXT pMosContext, void *pMosResource,
uint32_t offsetOf1stLevelBB, bool bUseSizeOfResource, uint32_t sizeOf1stLevelBB)
{
// The GPR11 need to be reset to 0 to disable UMD_OCA for current workload.
gpuVaOcaBuffer = 0;
return MOS_STATUS_UNIMPLEMENTED;
}

//!
//! \brief Oca operation which should be called before adding batch buffer end command for 1st
//! level batch buffer.
//! \param [in] hOcaBuf
//! Oca buffer handle.
//! \return MOS_STATUS
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed
//!
virtual MOS_STATUS On1stLevelBBEnd(MOS_OCA_BUFFER_HANDLE hOcaBuf)
{
return MOS_STATUS_UNIMPLEMENTED;
}

//!
//! \brief Oca operation which should be called before sending start sub level batch buffer command.
//! \param [in] hOcaBuf
//! Oca buffer handle.
//! \param [in] pMosContext
//! Pointer to MOS_CONTEXT.
//! \param [in] pMosResource
//! Pointer to the MOS_RESOURCE.
//! \param [in] offsetOfSubLevelBB
//! Offset for current BB in pMosResource.
//! \param [in] bUseSizeOfResource
//! If true, use size of pMosResource for batch buffer, else use sizeOfIndirectState.
//! \param [in] sizeOfSubLevelBB
//! Size of BB. Ignore if bUseSizeOfResource == true.
//! \return MOS_STATUS
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed
//!
MOS_STATUS OnSubLevelBBStart(MOS_OCA_BUFFER_HANDLE hOcaBuf, PMOS_CONTEXT pMosContext, void *pMosResource, uint32_t offsetOfSubLevelBB, bool bUseSizeOfResource, uint32_t sizeOfSubLevelBB)
{
return MOS_STATUS_UNIMPLEMENTED;
}

//!
//! \brief Oca operation which should be called when indirect states being added.
//! \param [in] hOcaBuf
//! Oca buffer handle.
//! \param [in] pMosContext
//! Pointer to MOS_CONTEXT.
//! \param [in] pMosResource
//! Pointer to the MOS_RESOURCE.
//! \param [in] offsetOfIndirectState
//! Offset for current state in pMosResource.
//! \param [in] bUseSizeOfResource
//! If true, use size of pMosResource for indirect state, else use sizeOfIndirectState.
//! \param [in] sizeOfIndirectState
//! Size of indirect state. Ignore if bUseSizeOfResource == true.
//! \return MOS_STATUS
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed
//!
virtual MOS_STATUS OnIndirectState(MOS_OCA_BUFFER_HANDLE hOcaBuf, PMOS_CONTEXT pMosContext, void *pMosResource, uint32_t offsetOfIndirectState, bool bUseSizeOfResource, uint32_t sizeOfIndirectState)
{
return MOS_STATUS_UNIMPLEMENTED;
}

//!
//! \brief Oca operation which should be called before adding dispatch states,
//! e.g. VEB_DI_IECP_STATE and MEDIA_OBJECT_WALKER.
//! \param [out] offsetInIndirectStateHeap
//! The start offset of current dispatch in indirect state heap, which should be set to low 32 bits
//! of GPR12 by LRI before dispatch commands being added.
//! OCA_HEAP_INVALID_OFFSET means no need to configure GPR12, otherwise the register need be configured
//! no matter return value being MOS_STATUS_SUCCESS or not.
//! \param [in] hOcaBuf
//! Oca buffer handle.
//! \return MOS_STATUS
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed
//!
virtual MOS_STATUS OnDispatch(uint32_t &offsetInIndirectStateHeap, MOS_OCA_BUFFER_HANDLE hOcaBuf)
{
offsetInIndirectStateHeap = OCA_HEAP_INVALID_OFFSET;
return MOS_STATUS_UNIMPLEMENTED;
}

//!
//! \brief Add string to oca log section
//! \param [in] hOcaBuf
//! Oca buffer handle.
//! \param [in] str
//! string to be added.
//! \param [in] maxCount
//! size of the buffer pointed by str.
//! \return MOS_STATUS
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed
//!
virtual MOS_STATUS TraceMessage(MOS_OCA_BUFFER_HANDLE hOcaBuf, const char *str, uint32_t maxCount)
{
return MOS_STATUS_UNIMPLEMENTED;
}

//!
//! \brief Add data block to oca log section.
//! \param [in] hOcaBuf
//! Oca buffer handle.
//! \param [in] pHeader
//! Log header. It can be extended by user. The acutal size of header is pHeader->m_HeaderSize.
//! \param [in] pData
//! Data block without log header. The acutal size of data block is pHeader->m_DataSize.
//! \return MOS_STATUS
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed
//!
virtual MOS_STATUS DumpDataBlock(MOS_OCA_BUFFER_HANDLE hOcaBuf, PMOS_OCA_LOG_HEADER pHeader, void *pData)
{
return MOS_STATUS_UNIMPLEMENTED;
}
};

#endif // #ifndef __MOS_OCA_INTERFACE_H__
3 changes: 3 additions & 0 deletions media_driver/agnostic/common/os/mos_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
#include "mos_os_specific.h"
#include "mos_os_virtualengine_specific.h"

#include "mos_oca_interface.h"

#define MOS_NAL_UNIT_LENGTH 4
#define MOS_NAL_UNIT_STARTCODE_LENGTH 3
#define MOS_MAX_PATH_LENGTH 256
Expand Down Expand Up @@ -238,6 +240,7 @@ typedef struct _MOS_COMMAND_BUFFER
MOS_VDBOX_NODE_IND iVdboxNodeIndex; //!< Which VDBOX buffer is binded to

MOS_COMMAND_BUFFER_ATTRIBUTES Attributes; //!< Attributes for the command buffer to be provided to KMD at submission
MOS_OCA_BUFFER_HANDLE hOcaBuf; //!< Oca buffer handle for current command
} MOS_COMMAND_BUFFER;

//!
Expand Down
3 changes: 2 additions & 1 deletion media_driver/agnostic/common/os/mos_os_trace_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ typedef enum _MEDIA_EVENT
EVENT_DDE_CB_REPORT_ENCRYPTION_STATUS,
EVENT_DDE_CB_REPORT_LINK_STATUS,
EVENT_DDE_CB_SEND_DATA,
EVENT_DDE_MESSAGE //! event for debug message
EVENT_DDE_MESSAGE, //! event for debug message
EVENT_OCA_LAST_ERROR //! event for last OCA error.
} MEDIA_EVENT;

typedef enum _MEDIA_EVENT_TYPE
Expand Down
3 changes: 3 additions & 0 deletions media_driver/agnostic/common/os/mos_util_user_feature_keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,7 @@
//User feature key for enable simulating random memory allocation failure
#define __MEDIA_USER_FEATURE_VALUE_SIMULATE_RANDOM_ALLOC_MEMORY_FAIL "Simulate Random Alloc Memory Fail"

//User feature key for enable/disable UMD_OCA
#define __MEDIA_USER_FEATURE_VALUE_ENABLE_UMD_OCA "Enable UMD_OCA"

#endif // __MOS_UTIL_USER_FEATURE_KEYS_H__
11 changes: 10 additions & 1 deletion media_driver/agnostic/common/os/mos_utilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -3465,7 +3465,7 @@ static MOS_USER_FEATURE_VALUE MOSUserFeatureDescFields[__MOS_USER_FEATURE_KEY_MA
MOS_USER_FEATURE_VALUE_TYPE_UINT32,
"0",
"Enable MOS to simualte random memory allocate fail. "),
MOS_DECLARE_UF_KEY_DBGONLY(__MEDIA_USER_FEATURE_VALUE_EXTERNAL_COPY_SYNC_ID,
MOS_DECLARE_UF_KEY_DBGONLY(__MEDIA_USER_FEATURE_VALUE_EXTERNAL_COPY_SYNC_ID,
"External Copy Sync",
__MEDIA_USER_FEATURE_SUBKEY_INTERNAL,
__MEDIA_USER_FEATURE_SUBKEY_INTERNAL,
Expand All @@ -3474,6 +3474,15 @@ static MOS_USER_FEATURE_VALUE MOSUserFeatureDescFields[__MOS_USER_FEATURE_KEY_MA
MOS_USER_FEATURE_VALUE_TYPE_UINT32,
"0",
"Enable GPU polling based sync for external raw surface copy."),
MOS_DECLARE_UF_KEY(__MEDIA_USER_FEATURE_VALUE_ENABLE_UMD_OCA_ID,
__MEDIA_USER_FEATURE_VALUE_ENABLE_UMD_OCA,
__MEDIA_USER_FEATURE_SUBKEY_INTERNAL,
__MEDIA_USER_FEATURE_SUBKEY_REPORT,
"MOS",
MOS_USER_FEATURE_TYPE_USER,
MOS_USER_FEATURE_VALUE_TYPE_UINT32,
"0",
"Enable UMD_OCA in media driver. This key is not valid on Linux."),
};

#define MOS_NUM_USER_FEATURE_VALUES (sizeof(MOSUserFeatureDescFields) / sizeof(MOSUserFeatureDescFields[0]))
Expand Down
1 change: 1 addition & 0 deletions media_driver/agnostic/common/os/mos_utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ typedef enum _MOS_USER_FEATURE_VALUE_ID
__MEDIA_USER_FEATURE_VALUE_SUPER_RESOLUTION_MODE_ID,
__MEDIA_USER_FEATURE_VALUE_SIMULATE_RANDOM_ALLOC_MEMORY_FAIL_ID,
__MEDIA_USER_FEATURE_VALUE_EXTERNAL_COPY_SYNC_ID,
__MEDIA_USER_FEATURE_VALUE_ENABLE_UMD_OCA_ID,
__MOS_USER_FEATURE_KEY_MAX_ID,
} MOS_USER_FEATURE_VALUE_ID;

Expand Down
2 changes: 2 additions & 0 deletions media_driver/agnostic/common/renderhal/media_srcs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ set(TMP_SOURCES_
${CMAKE_CURRENT_LIST_DIR}/renderhal.cpp
${CMAKE_CURRENT_LIST_DIR}/renderhal_dsh.cpp
${CMAKE_CURRENT_LIST_DIR}/renderhal_common.cpp
${CMAKE_CURRENT_LIST_DIR}/renderhal_oca_support.cpp
)

set(TMP_HEADERS_
${CMAKE_CURRENT_LIST_DIR}/renderhal.h
${CMAKE_CURRENT_LIST_DIR}/renderhal_dsh.h
${CMAKE_CURRENT_LIST_DIR}/renderhal_platform_interface.h
${CMAKE_CURRENT_LIST_DIR}/vphal_renderhal_common.h
${CMAKE_CURRENT_LIST_DIR}/renderhal_oca_support.h
)


Expand Down
Loading

0 comments on commit d4df345

Please sign in to comment.