fix: setup gpu address space based on config info from xe kmd

Related-To: NEO-10496
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2024-03-21 17:40:02 +00:00
committed by Compute-Runtime-Automation
parent 1e343053ba
commit 92d37b20a6
3 changed files with 36 additions and 0 deletions

View File

@@ -1799,3 +1799,22 @@ TEST(IoctlHelperXeTest, whenCallingGetStatusAndFlagsForResetStatsThenZeroIsRetur
EXPECT_FALSE(ioctlHelper->validPageFault(0u));
}
TEST(IoctlHelperXeTest, whenInitializeThenProperHwInfoIsSet) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
DrmMockXe drm{*executionEnvironment->rootDeviceEnvironments[0]};
drm.ioctlHelper = std::make_unique<MockIoctlHelperXe>(drm);
auto hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo();
hwInfo->platform.usDeviceID = 0;
hwInfo->platform.usRevId = 0;
hwInfo->capabilityTable.gpuAddressSpace = 0;
auto ioctlHelper = static_cast<MockIoctlHelperXe *>(drm.ioctlHelper.get());
ioctlHelper->initialize();
EXPECT_EQ(drm.revId, hwInfo->platform.usRevId);
EXPECT_EQ(drm.devId, hwInfo->platform.usDeviceID);
EXPECT_EQ((1ull << 48) - 1, hwInfo->capabilityTable.gpuAddressSpace);
}

View File

@@ -49,6 +49,12 @@ inline constexpr uint32_t testValueGemCreate = 0x8273;
class DrmMockXe : public DrmMockCustom {
public:
DrmMockXe(RootDeviceEnvironment &rootDeviceEnvironment) : DrmMockCustom(rootDeviceEnvironment) {
auto xeQueryConfig = reinterpret_cast<drm_xe_query_config *>(queryConfig);
xeQueryConfig->num_params = 5;
xeQueryConfig->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] = (revId << 16) | devId;
xeQueryConfig->info[DRM_XE_QUERY_CONFIG_VA_BITS] = 48;
auto xeQueryEngines = reinterpret_cast<drm_xe_query_engines *>(queryEngines);
xeQueryEngines->num_engines = 11;
xeQueryEngines->engines[0] = {{DRM_XE_ENGINE_CLASS_RENDER, 0, 0}, {}};
@@ -184,6 +190,12 @@ class DrmMockXe : public DrmMockCustom {
case DrmIoctl::query: {
struct drm_xe_device_query *deviceQuery = static_cast<struct drm_xe_device_query *>(arg);
switch (deviceQuery->query) {
case DRM_XE_DEVICE_QUERY_CONFIG:
if (deviceQuery->data) {
memcpy_s(reinterpret_cast<void *>(deviceQuery->data), deviceQuery->size, queryConfig, sizeof(queryConfig));
}
deviceQuery->size = sizeof(queryConfig);
break;
case DRM_XE_DEVICE_QUERY_ENGINES:
if (deviceQuery->data) {
memcpy_s(reinterpret_cast<void *>(deviceQuery->data), deviceQuery->size, queryEngines, sizeof(queryEngines));
@@ -266,6 +278,10 @@ class DrmMockXe : public DrmMockCustom {
int setIoctlAnswer = 0;
int gemVmBindReturn = 0;
const uint16_t revId = 0x12;
const uint16_t devId = 0xabc;
uint64_t queryConfig[6]{}; // 1 qword for num params and 1 qwords per param
static_assert(sizeof(drm_xe_engine) == 4 * sizeof(uint64_t), "");
uint64_t queryEngines[45]{}; // 1 qword for num engines and 4 qwords per engine
static_assert(sizeof(drm_xe_mem_region) == 11 * sizeof(uint64_t), "");