Use drm tip kernel headers as default 1/2

Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
Szymon Morek
2021-11-02 15:59:57 +00:00
committed by Compute-Runtime-Automation
parent a3c3fe18ce
commit 8fdfc3b053
18 changed files with 141 additions and 40 deletions

View File

@@ -45,6 +45,9 @@ set(NEO_CORE_OS_INTERFACE_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id_linux.cpp
${CMAKE_CURRENT_SOURCE_DIR}/kmd_notify_properties_linux.cpp
${CMAKE_CURRENT_SOURCE_DIR}/linux_inc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/local_memory_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/local_memory_helper.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}local_memory_helper_default.cpp
${CMAKE_CURRENT_SOURCE_DIR}/engine_info.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}engine_info_impl.h
${CMAKE_CURRENT_SOURCE_DIR}/flags${BRANCH_DIR_SUFFIX}drm_query_flags.h
@@ -100,8 +103,6 @@ if(I915_LOCAL_MEM_EXP)
${CMAKE_CURRENT_SOURCE_DIR}/drm_query_exp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_tip.h
${CMAKE_CURRENT_SOURCE_DIR}/memory_info_impl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/local_memory_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/local_memory_helper.cpp
)
else()
list(APPEND NEO_CORE_OS_INTERFACE_LINUX

View File

@@ -8,7 +8,14 @@
#include "shared/source/os_interface/linux/local_memory_helper.h"
namespace NEO {
extern LocalMemoryHelper *localMemoryHelperFactory[IGFX_MAX_PRODUCT];
static EnableProductLocalMemoryHelper<IGFX_DG1> enableLocalMemHelperDG1;
struct EnableProductLocalMemoryHelperDg1 {
EnableProductLocalMemoryHelperDg1() {
LocalMemoryHelper *plocalMemHelper = LocalMemoryHelperImpl<IGFX_DG1>::get();
localMemoryHelperFactory[IGFX_DG1] = plocalMemHelper;
}
};
static EnableProductLocalMemoryHelperDg1 enableLocalMemoryHelperDg1;
} // namespace NEO

View File

@@ -8,7 +8,14 @@
#include "shared/source/os_interface/linux/local_memory_helper.h"
namespace NEO {
extern LocalMemoryHelper *localMemoryHelperFactory[IGFX_MAX_PRODUCT];
static EnableProductLocalMemoryHelper<IGFX_XE_HP_SDV> enableLocalMemHelperXeHpSdv;
struct EnableProductLocalMemoryHelperXeHpSdv {
EnableProductLocalMemoryHelperXeHpSdv() {
LocalMemoryHelper *plocalMemHelper = LocalMemoryHelperImpl<IGFX_XE_HP_SDV>::get();
localMemoryHelperFactory[IGFX_XE_HP_SDV] = plocalMemHelper;
}
};
static EnableProductLocalMemoryHelperXeHpSdv enableLocalMemoryHelperXeHpSdv;
} // namespace NEO

View File

@@ -13,6 +13,14 @@ namespace NEO {
LocalMemoryHelper *localMemoryHelperFactory[IGFX_MAX_PRODUCT] = {};
LocalMemoryHelper *LocalMemoryHelper::get(PRODUCT_FAMILY product) {
auto localMemHelper = localMemoryHelperFactory[product];
if (!localMemHelper) {
return LocalMemoryHelperDefault::get();
}
return localMemHelper;
}
uint32_t LocalMemoryHelper::ioctl(Drm *drm, unsigned long request, void *arg) {
return drm->ioctl(request, arg);
}

View File

@@ -20,14 +20,9 @@ extern LocalMemoryHelper *localMemoryHelperFactory[IGFX_MAX_PRODUCT];
class LocalMemoryHelper {
public:
static LocalMemoryHelper *get(PRODUCT_FAMILY product) {
auto localMemHelper = localMemoryHelperFactory[product];
if (!localMemHelper) {
return localMemoryHelperFactory[IGFX_DG1];
}
return localMemHelper;
}
static LocalMemoryHelper *get(PRODUCT_FAMILY product);
static uint32_t ioctl(Drm *drm, unsigned long request, void *arg);
virtual uint32_t createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) = 0;
virtual std::unique_ptr<uint8_t[]> translateIfRequired(uint8_t *dataQuery, int32_t length) = 0;
};
@@ -43,11 +38,14 @@ class LocalMemoryHelperImpl : public LocalMemoryHelper {
std::unique_ptr<uint8_t[]> translateIfRequired(uint8_t *dataQuery, int32_t length) override;
};
template <PRODUCT_FAMILY gfxProduct>
struct EnableProductLocalMemoryHelper {
EnableProductLocalMemoryHelper() {
LocalMemoryHelper *plocalMemHelper = LocalMemoryHelperImpl<gfxProduct>::get();
localMemoryHelperFactory[gfxProduct] = plocalMemHelper;
class LocalMemoryHelperDefault : public LocalMemoryHelper {
public:
static LocalMemoryHelper *get() {
static LocalMemoryHelperDefault instance;
return &instance;
}
uint32_t createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) override;
std::unique_ptr<uint8_t[]> translateIfRequired(uint8_t *dataQuery, int32_t length) override;
};
} // namespace NEO

View File

@@ -0,0 +1,24 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/os_interface/linux/drm_neo.h"
#include "shared/source/os_interface/linux/local_memory_helper.h"
namespace NEO {
uint32_t LocalMemoryHelperDefault::createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) {
DEBUG_BREAK_IF(true);
return -1;
}
std::unique_ptr<uint8_t[]> LocalMemoryHelperDefault::translateIfRequired(uint8_t *dataQuery, int32_t length) {
DEBUG_BREAK_IF(true);
return std::unique_ptr<uint8_t[]>(dataQuery);
}
} // namespace NEO

View File

@@ -7,9 +7,6 @@
#include "shared/source/os_interface/linux/memory_info_impl.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/os_interface/linux/local_memory_helper.h"
#include "drm/i915_drm.h"
namespace NEO {
@@ -23,11 +20,6 @@ MemoryInfoImpl::MemoryInfoImpl(const drm_i915_memory_region_info *regionInfo, si
});
}
uint32_t MemoryInfoImpl::createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) {
auto pHwInfo = drm->getRootDeviceEnvironment().getHardwareInfo();
return LocalMemoryHelper::get(pHwInfo->platform.eProductFamily)->createGemExt(drm, data, dataSize, allocSize, handle);
}
void MemoryInfoImpl::assignRegionsFromDistances(const void *distanceInfosPtr, size_t size) {
}

View File

@@ -11,6 +11,7 @@
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/os_interface/linux/drm_neo.h"
#include "shared/source/os_interface/linux/local_memory_helper.h"
#include "shared/source/os_interface/linux/memory_info.h"
#include "drm/i915_drm.h"
@@ -30,7 +31,10 @@ class MemoryInfoImpl : public MemoryInfo {
void assignRegionsFromDistances(const void *distanceInfosPtr, size_t size);
uint32_t createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) override;
uint32_t createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) override {
auto pHwInfo = drm->getRootDeviceEnvironment().getHardwareInfo();
return LocalMemoryHelper::get(pHwInfo->platform.eProductFamily)->createGemExt(drm, data, dataSize, allocSize, handle);
}
drm_i915_gem_memory_class_instance getMemoryRegionClassAndInstance(uint32_t memoryBank, const HardwareInfo &hwInfo) {
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);