diff --git a/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp b/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp index 5b95f536d9..2f534b5009 100644 --- a/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp +++ b/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp @@ -137,9 +137,6 @@ bool IoctlHelperXe::initialize() { xeLog("DRM_XE_QUERY_CONFIG_MAX_EXEC_QUEUE_PRIORITY\t\t%#llx\n", config->info[DRM_XE_QUERY_CONFIG_MAX_EXEC_QUEUE_PRIORITY]); - chipsetId = config->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] & 0xffff; - revId = static_cast((config->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] >> 16) & 0xff); - hasVram = config->info[DRM_XE_QUERY_CONFIG_FLAGS] & DRM_XE_QUERY_CONFIG_FLAG_HAS_VRAM ? 1 : 0; maxExecQueuePriority = config->info[DRM_XE_QUERY_CONFIG_MAX_EXEC_QUEUE_PRIORITY] & 0xffff; memset(&queryConfig, 0, sizeof(queryConfig)); @@ -151,8 +148,8 @@ bool IoctlHelperXe::initialize() { IoctlHelper::ioctl(DrmIoctl::query, &queryConfig); auto hwInfo = this->drm.getRootDeviceEnvironment().getMutableHardwareInfo(); - hwInfo->platform.usDeviceID = chipsetId; - hwInfo->platform.usRevId = revId; + hwInfo->platform.usDeviceID = config->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] & 0xffff; + hwInfo->platform.usRevId = static_cast((config->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] >> 16) & 0xff); hwInfo->capabilityTable.gpuAddressSpace = (1ull << config->info[DRM_XE_QUERY_CONFIG_VA_BITS]) - 1; return true; @@ -209,6 +206,9 @@ std::unique_ptr IoctlHelperXe::createEngineInfo(bool isSysmanEnabled StackVec, 2> enginesPerTile{}; std::bitset<8> multiTileMask{}; + auto hwInfo = drm.getRootDeviceEnvironment().getMutableHardwareInfo(); + auto defaultEngineClass = getDefaultEngineClass(hwInfo->capabilityTable.defaultEngineType); + for (auto i = 0u; i < numberHwEngines; i++) { const auto &engine = queryEngines->engines[i].instance; auto tile = engine.gt_id; @@ -228,11 +228,13 @@ std::unique_ptr IoctlHelperXe::createEngineInfo(bool isSysmanEnabled enginesPerTile.resize(tile + 1); } enginesPerTile[tile].push_back(engineClassInstance); - allEngines.push_back(engine); + if (!defaultEngine && engineClassInstance.engineClass == defaultEngineClass) { + defaultEngine = std::make_unique(); + *defaultEngine = engine; + } } } - - auto hwInfo = drm.getRootDeviceEnvironment().getMutableHardwareInfo(); + UNRECOVERABLE_IF(!defaultEngine); if (hwInfo->featureTable.flags.ftrMultiTileArch) { auto &multiTileArchInfo = hwInfo->gtSystemInfo.MultiTileArchInfo; multiTileArchInfo.IsValid = true; @@ -240,8 +242,6 @@ std::unique_ptr IoctlHelperXe::createEngineInfo(bool isSysmanEnabled multiTileArchInfo.TileMask = static_cast(multiTileMask.to_ulong()); } - setDefaultEngine(drm.getRootDeviceEnvironment().getHardwareInfo()->capabilityTable.defaultEngineType); - return std::make_unique(&drm, enginesPerTile); } @@ -471,28 +471,15 @@ void IoctlHelperXe::updateBindInfo(uint32_t handle, uint64_t userPtr, uint64_t s bindInfo.push_back(b); } -void IoctlHelperXe::setDefaultEngine(const aub_stream::EngineType &defaultEngineType) { - uint32_t defaultEngineClass; - +uint16_t IoctlHelperXe::getDefaultEngineClass(const aub_stream::EngineType &defaultEngineType) { if (defaultEngineType == aub_stream::EngineType::ENGINE_CCS) { - defaultEngineClass = DRM_XE_ENGINE_CLASS_COMPUTE; + return DRM_XE_ENGINE_CLASS_COMPUTE; } else if (defaultEngineType == aub_stream::EngineType::ENGINE_RCS) { - defaultEngineClass = DRM_XE_ENGINE_CLASS_RENDER; + return DRM_XE_ENGINE_CLASS_RENDER; } else { /* So far defaultEngineType is either ENGINE_RCS or ENGINE_CCS */ UNRECOVERABLE_IF(true); - } - - for (auto i = 0u; i < allEngines.size(); i++) { - if (allEngines[i].engine_class == defaultEngineClass) { - defaultEngine = &allEngines[i]; - xeLog("Found default engine of class %s\n", xeGetClassName(defaultEngineClass)); - break; - } - } - - if (defaultEngine == nullptr) { - UNRECOVERABLE_IF(true); + return 0; } } @@ -905,25 +892,19 @@ int IoctlHelperXe::ioctl(DrmIoctl request, void *arg) { xeLog(" => IoctlHelperXe::%s 0x%x\n", __FUNCTION__, request); switch (request) { case DrmIoctl::getparam: { - struct GetParam *d = (struct GetParam *)arg; + auto getParam = reinterpret_cast(arg); ret = 0; - switch (d->param) { - case static_cast(DrmParam::paramChipsetId): - *d->value = chipsetId; - break; - case static_cast(DrmParam::paramRevision): - *d->value = revId; - break; + switch (getParam->param) { case static_cast(DrmParam::paramCsTimestampFrequency): { uint64_t frequency = 0; if (getTimestampFrequency(frequency)) { - *d->value = static_cast(frequency); + *getParam->value = static_cast(frequency); } } break; default: ret = -1; } - xeLog(" -> IoctlHelperXe::ioctl Getparam 0x%x/0x%x r=%d\n", d->param, *d->value, ret); + xeLog(" -> IoctlHelperXe::ioctl Getparam 0x%x/0x%x r=%d\n", getParam->param, *getParam->value, ret); } break; case DrmIoctl::query: { @@ -1330,10 +1311,6 @@ std::string IoctlHelperXe::getDrmParamString(DrmParam drmParam) const { return "MmapOffsetWb"; case DrmParam::mmapOffsetWc: return "MmapOffsetWc"; - case DrmParam::paramChipsetId: - return "ParamChipsetId"; - case DrmParam::paramRevision: - return "ParamRevision"; case DrmParam::paramHasPooledEu: return "ParamHasPooledEu"; case DrmParam::paramEuTotal: diff --git a/shared/source/os_interface/linux/xe/ioctl_helper_xe.h b/shared/source/os_interface/linux/xe/ioctl_helper_xe.h index f9232636ae..91d359bac1 100644 --- a/shared/source/os_interface/linux/xe/ioctl_helper_xe.h +++ b/shared/source/os_interface/linux/xe/ioctl_helper_xe.h @@ -157,25 +157,17 @@ class IoctlHelperXe : public IoctlHelper { uint64_t value; }; - void setDefaultEngine(const aub_stream::EngineType &defaultEngineType); + uint16_t getDefaultEngineClass(const aub_stream::EngineType &defaultEngineType); void setContextProperties(const OsContextLinux &osContext, void *extProperties, uint32_t &extIndexInOut); - int chipsetId = 0; - int revId = 0; - int defaultAlignment = 0; - int hasVram = 0; int maxExecQueuePriority = 0; - uint32_t xeVmId = 0; - int xeFileHandle = 0; std::mutex xeLock; std::vector bindInfo; - int instance = 0; uint32_t xeTimestampFrequency = 0; std::vector hwconfig; std::vector contextParamEngine; - std::vector allEngines; - drm_xe_engine_class_instance *defaultEngine = nullptr; + std::unique_ptr defaultEngine; struct DebugMetadata { DrmResourceClass type; diff --git a/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp b/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp index 115398110b..fbc23143be 100644 --- a/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp @@ -359,8 +359,6 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingAnyMethodThenDummyValueIsRe verifyDrmParamString("MemoryClassSystem", DrmParam::memoryClassSystem); verifyDrmParamString("MmapOffsetWb", DrmParam::mmapOffsetWb); verifyDrmParamString("MmapOffsetWc", DrmParam::mmapOffsetWc); - verifyDrmParamString("ParamChipsetId", DrmParam::paramChipsetId); - verifyDrmParamString("ParamRevision", DrmParam::paramRevision); verifyDrmParamString("ParamHasPooledEu", DrmParam::paramHasPooledEu); verifyDrmParamString("ParamEuTotal", DrmParam::paramEuTotal); verifyDrmParamString("ParamSubsliceTotal", DrmParam::paramSubsliceTotal); @@ -665,12 +663,10 @@ TEST(IoctlHelperXeTest, whenCallingIoctlThenProperValueIsReturned) { EXPECT_EQ(-1, ret); test.param = static_cast(DrmParam::paramChipsetId); ret = mockXeIoctlHelper->ioctl(DrmIoctl::getparam, &test); - EXPECT_EQ(0, ret); - EXPECT_EQ(dstvalue, 0); + EXPECT_EQ(-1, ret); test.param = static_cast(DrmParam::paramRevision); ret = mockXeIoctlHelper->ioctl(DrmIoctl::getparam, &test); - EXPECT_EQ(0, ret); - EXPECT_EQ(dstvalue, 0); + EXPECT_EQ(-1, ret); test.param = static_cast(DrmParam::paramHasPageFault); ret = mockXeIoctlHelper->ioctl(DrmIoctl::getparam, &test); EXPECT_EQ(-1, ret); @@ -1667,23 +1663,12 @@ TEST(IoctlHelperXeTest, whenSetDefaultEngineIsCalledThenProperEngineIsSet) { auto engineInfo = xeIoctlHelper->createEngineInfo(true); ASSERT_NE(nullptr, engineInfo); - xeIoctlHelper->setDefaultEngine(aub_stream::EngineType::ENGINE_CCS); - EXPECT_EQ(DRM_XE_ENGINE_CLASS_COMPUTE, xeIoctlHelper->defaultEngine->engine_class); - xeIoctlHelper->setDefaultEngine(aub_stream::EngineType::ENGINE_RCS); - EXPECT_EQ(DRM_XE_ENGINE_CLASS_RENDER, xeIoctlHelper->defaultEngine->engine_class); + EXPECT_EQ(DRM_XE_ENGINE_CLASS_COMPUTE, xeIoctlHelper->getDefaultEngineClass(aub_stream::EngineType::ENGINE_CCS)); + EXPECT_EQ(DRM_XE_ENGINE_CLASS_RENDER, xeIoctlHelper->getDefaultEngineClass(aub_stream::EngineType::ENGINE_RCS)); - EXPECT_THROW(xeIoctlHelper->setDefaultEngine(aub_stream::EngineType::ENGINE_BCS), std::exception); - EXPECT_THROW(xeIoctlHelper->setDefaultEngine(aub_stream::EngineType::ENGINE_VCS), std::exception); - EXPECT_THROW(xeIoctlHelper->setDefaultEngine(aub_stream::EngineType::ENGINE_VECS), std::exception); -} - -TEST(IoctlHelperXeTest, givenNoEnginesWhenSetDefaultEngineIsCalledThenAbortIsThrown) { - auto executionEnvironment = std::make_unique(); - DrmMockXe drm{*executionEnvironment->rootDeviceEnvironments[0]}; - auto xeIoctlHelper = std::make_unique(drm); - - auto defaultEngineType = executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->capabilityTable.defaultEngineType; - EXPECT_THROW(xeIoctlHelper->setDefaultEngine(defaultEngineType), std::exception); + EXPECT_THROW(xeIoctlHelper->getDefaultEngineClass(aub_stream::EngineType::ENGINE_BCS), std::exception); + EXPECT_THROW(xeIoctlHelper->getDefaultEngineClass(aub_stream::EngineType::ENGINE_VCS), std::exception); + EXPECT_THROW(xeIoctlHelper->getDefaultEngineClass(aub_stream::EngineType::ENGINE_VECS), std::exception); } TEST(IoctlHelperXeTest, whenGettingPreemptionSupportThenTrueIsReturned) { diff --git a/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.h b/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.h index 1cb2d4cadf..e9a8ddbc12 100644 --- a/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.h +++ b/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.h @@ -31,12 +31,12 @@ struct MockIoctlHelperXe : IoctlHelperXe { using IoctlHelperXe::contextParamEngine; using IoctlHelperXe::debugMetadata; using IoctlHelperXe::defaultEngine; + using IoctlHelperXe::getDefaultEngineClass; using IoctlHelperXe::getFdFromVmExport; using IoctlHelperXe::IoctlHelperXe; using IoctlHelperXe::maxContextSetProperties; using IoctlHelperXe::maxExecQueuePriority; using IoctlHelperXe::setContextProperties; - using IoctlHelperXe::setDefaultEngine; using IoctlHelperXe::UserFenceExtension; using IoctlHelperXe::xeGetBindFlagsName; using IoctlHelperXe::xeGetBindOperationName;