Skip to content

Commit

Permalink
[Media Common] [VP] Separate gpu context creation function and remove…
Browse files Browse the repository at this point in the history
… WR code

Separate gpu context creation function and remove WR code for new kernel
  • Loading branch information
LhGu authored and intel-mediadev committed Aug 8, 2023
1 parent 5e2ef80 commit 5147757
Show file tree
Hide file tree
Showing 15 changed files with 87 additions and 75 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ cmake_dependent_option( BUILD_KERNELS
option (BUILD_CMRTLIB "Build and Install cmrtlib together with media driver" ON)

option (ENABLE_PRODUCTION_KMD "Enable Production KMD header files" OFF)
option (ENABLE_XE_KMD "Enable XE KMD header files" ON)

include(GNUInstallDirs)

Expand Down
4 changes: 4 additions & 0 deletions media_driver/cmake/linux/media_feature_flags_linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ if(NOT ENABLE_NONFREE_KERNELS)
add_definitions(-D_FULL_OPEN_SOURCE)
endif()

if(ENABLE_NEW_KMD AND NOT ENABLE_PRODUCTION_KMD)
add_definitions(-DENABLE_NEW_KMD)
endif()

add_definitions(-D_MANUAL_SOFTLET_)

include(${MEDIA_EXT_CMAKE}/ext/linux/media_feature_flags_linux_ext.cmake OPTIONAL)
7 changes: 5 additions & 2 deletions media_driver/linux/ult/libdrm_mock/mos_bufmgr_mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -3852,14 +3852,17 @@ static void mos_bufmgr_set_platform_information(struct mos_bufmgr *bufmgr, uint6
* \param fd File descriptor of the opened DRM device.
*/
struct mos_bufmgr *
mos_bufmgr_gem_init(int fd, int batch_size)
mos_bufmgr_gem_init(int fd, int batch_size, int *device_type)
{
struct mos_bufmgr_gem *bufmgr_gem;
struct drm_i915_gem_get_aperture aperture;
drm_i915_getparam_t gp;
int ret, tmp;
bool exec2 = false;

if (device_type != nullptr)
{
*device_type = DEVICE_TYPE_I915;
}
pthread_mutex_lock(&bufmgr_list_mutex);

bufmgr_gem = mos_bufmgr_gem_find(fd);
Expand Down
1 change: 0 additions & 1 deletion media_softlet/agnostic/common/os/media_srcs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ set(TMP_SOURCES_
${CMAKE_CURRENT_LIST_DIR}/mos_graphicsresource_next.cpp
${CMAKE_CURRENT_LIST_DIR}/mos_os_next.cpp
${CMAKE_CURRENT_LIST_DIR}/mos_utilities_inner.cpp
${CMAKE_CURRENT_LIST_DIR}/mos_gpucontext_next.cpp
${CMAKE_CURRENT_LIST_DIR}/mos_gpucontextmgr_next.cpp
${CMAKE_CURRENT_LIST_DIR}/mos_cmdbufmgr_next.cpp
${CMAKE_CURRENT_LIST_DIR}/mos_commandbuffer_next.cpp
Expand Down
6 changes: 3 additions & 3 deletions media_softlet/agnostic/common/os/mos_cmdbufmgr_next.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ class CmdBufMgrNext
return m_handle;
}

//! \brief Corresponding os context
OsContextNext *m_osContext = nullptr;

protected:
//!
//! \brief Self define compare method as std:sort input
Expand Down Expand Up @@ -208,9 +211,6 @@ class CmdBufMgrNext
//! \brief Flag to indicate cmd buf mgr initialized or not
bool m_initialized = false;

//! \brief Corresponding os context
OsContextNext *m_osContext = nullptr;

//! \brief cmd buffer handle
uint64_t m_handle = 0;
MEDIA_CLASS_DEFINE_END(CmdBufMgrNext)
Expand Down
44 changes: 0 additions & 44 deletions media_softlet/agnostic/common/os/mos_gpucontext_next.cpp

This file was deleted.

17 changes: 0 additions & 17 deletions media_softlet/agnostic/common/os/mos_gpucontext_next.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,6 @@ class GpuContextNext
//!
virtual ~GpuContextNext(){}

//!
//! \brief Static entrypoint, get the gpu context object
//! \param [in] gpuNode
//! Gpu node
//! \param [in] cmdBufMgr
//! Command buffer manager
//! \param [in] reusedContext
//! Reused gpu context
//! \return GpuContextNext*
//! the os specific object for gpu context
//!
static class GpuContextNext* Create(
const MOS_GPU_NODE gpuNode,
CmdBufMgrNext *cmdBufMgr,
GpuContextNext *reusedContext,
OsContextNext *osContext = nullptr);

//!
//! \brief Clear gpu context
//!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ GpuContextNext *GpuContextMgrNext::CreateGpuContext(
reusedContext = SelectContextToReuse();
}

GpuContextNext *gpuContext = GpuContextNext::Create(gpuNode, cmdBufMgr, reusedContext, m_osContext);
GpuContextNext *gpuContext = GpuContextSpecificNext::Create(gpuNode, cmdBufMgr, reusedContext);
if (gpuContext == nullptr)
{
MOS_OS_ASSERTMESSAGE("nullptr returned by GpuContext::Create.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ int mos_bo_references(struct mos_linux_bo *bo, struct mos_linux_bo *target_bo);
int mos_bo_pad_to_size(struct mos_linux_bo *bo, uint64_t pad_to_size);

/* drm_intel_bufmgr_gem.c */
struct mos_bufmgr *mos_bufmgr_gem_init(int fd, int batch_size);
struct mos_bufmgr *mos_bufmgr_gem_init(int fd, int batch_size, int *device_type = nullptr);
struct mos_linux_bo *mos_bo_create_from_name(struct mos_bufmgr *bufmgr,
const char *name,
unsigned int handle);
Expand Down
9 changes: 7 additions & 2 deletions media_softlet/linux/common/os/i915/mos_bufmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -5393,9 +5393,14 @@ mos_bufmgr_gem_init_i915(int fd, int batch_size)
}

struct mos_bufmgr *
mos_bufmgr_gem_init(int fd, int batch_size)
mos_bufmgr_gem_init(int fd, int batch_size, int *device_type)
{
if(DEVICE_TYPE_I915 == mos_query_device_type(fd))
int type = mos_query_device_type(fd);
if (device_type != nullptr)
{
*device_type = type;
}
if(DEVICE_TYPE_I915 == type)
{
return mos_bufmgr_gem_init_i915(fd, batch_size);
}
Expand Down
9 changes: 7 additions & 2 deletions media_softlet/linux/common/os/i915_production/mos_bufmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -5449,9 +5449,14 @@ mos_bufmgr_gem_init_i915(int fd, int batch_size)
}

struct mos_bufmgr *
mos_bufmgr_gem_init(int fd, int batch_size)
mos_bufmgr_gem_init(int fd, int batch_size, int *device_type)
{
if(DEVICE_TYPE_I915 == mos_query_device_type(fd))
int type = mos_query_device_type(fd);
if (device_type != nullptr)
{
*device_type = type;
}
if(DEVICE_TYPE_I915 == type)
{
return mos_bufmgr_gem_init_i915(fd, batch_size);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ MOS_STATUS OsContextSpecificNext::Init(DDI_DEVICE_CONTEXT ddiDriverContext)

userSettingPtr = MosInterface::MosGetUserSettingInstance(osDriverContext);

m_bufmgr = mos_bufmgr_gem_init(m_fd, BATCH_BUFFER_SIZE);
m_bufmgr = mos_bufmgr_gem_init(m_fd, BATCH_BUFFER_SIZE, &m_deviceType);
if (nullptr == m_bufmgr)
{
MOS_OS_ASSERTMESSAGE("Not able to allocate buffer manager, fd=0x%d", m_fd);
Expand Down
9 changes: 9 additions & 0 deletions media_softlet/linux/common/os/mos_context_specific_next.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ class OsContextSpecificNext : public OsContextNext
return m_fd;
}

int GetDeviceType()
{
return m_deviceType;
}

private:
//!
//! \brief Performance specific switch for debug purpose
Expand Down Expand Up @@ -136,6 +141,10 @@ class OsContextSpecificNext : public OsContextNext
//!
int32_t m_fd = -1;

//!
//! \brief device type
//!
int m_deviceType = DEVICE_TYPE_COUNT;
AuxTableMgr *m_auxTableMgr = nullptr;
PERF_DATA *m_perfData = nullptr;
MEDIA_CLASS_DEFINE_END(OsContextSpecificNext)
Expand Down
33 changes: 33 additions & 0 deletions media_softlet/linux/common/os/mos_gpucontext_specific_next.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
#include "mos_os_virtualengine_next.h"
#include "mos_interface.h"
#include "mos_os_cp_interface_specific.h"
#ifdef ENABLE_NEW_KMD
// This header file is in close source temporarily. Could not find this header file in open source repo.
#include "mos_gpucontext_specific_next_xe.h"
#endif

#define MI_BATCHBUFFER_END 0x05000000
static pthread_mutex_t command_dump_mutex = PTHREAD_MUTEX_INITIALIZER;
Expand Down Expand Up @@ -96,6 +100,35 @@ GpuContextSpecificNext::~GpuContextSpecificNext()
Clear();
}

GpuContextNext *GpuContextSpecificNext::Create(
const MOS_GPU_NODE gpuNode,
CmdBufMgrNext *cmdBufMgr,
GpuContextNext *reusedContext)
{
MOS_OS_FUNCTION_ENTER;
if (nullptr == cmdBufMgr)
{
return nullptr;
}
OsContextSpecificNext *osDeviceContext = dynamic_cast<OsContextSpecificNext*>(cmdBufMgr->m_osContext);
if (nullptr == osDeviceContext)
{
return nullptr;
}
int type = osDeviceContext->GetDeviceType();
if (DEVICE_TYPE_I915 == type)
{
return MOS_New(GpuContextSpecificNext, gpuNode, cmdBufMgr, reusedContext);
}
#ifdef ENABLE_NEW_KMD
else if (DEVICE_TYPE_XE == type)
{
return MOS_New(GpuContextSpecificNextXe, gpuNode, cmdBufMgr, reusedContext);
}
#endif
return nullptr;
}

MOS_STATUS GpuContextSpecificNext::RecreateContext(bool bIsProtected, MOS_STREAM_HANDLE streamState)
{
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
Expand Down
16 changes: 16 additions & 0 deletions media_softlet/linux/common/os/mos_gpucontext_specific_next.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,22 @@ class GpuContextSpecificNext : public GpuContextNext
//!
~GpuContextSpecificNext();

//!
//! \brief Static entrypoint, get the gpu context object
//! \param [in] gpuNode
//! Gpu node
//! \param [in] cmdBufMgr
//! Command buffer manager
//! \param [in] reusedContext
//! Reused gpu context
//! \return GpuContextNext*
//! the os specific object for gpu context
//!
static GpuContextNext* Create(
const MOS_GPU_NODE gpuNode,
CmdBufMgrNext *cmdBufMgr,
GpuContextNext *reusedContext);

//!
//! \brief Initialize gpu context
//! \details Linux specific initialize for gpu context
Expand Down

0 comments on commit 5147757

Please sign in to comment.