diff --git a/level_zero/tools/source/sysman/linux/os_sysman_imp.cpp b/level_zero/tools/source/sysman/linux/os_sysman_imp.cpp index 30df9bae0a..9929780848 100644 --- a/level_zero/tools/source/sysman/linux/os_sysman_imp.cpp +++ b/level_zero/tools/source/sysman/linux/os_sysman_imp.cpp @@ -24,6 +24,9 @@ ze_result_t LinuxSysmanImp::init() { pDevice = Device::fromHandle(pParentSysmanDeviceImp->hCoreDevice); DEBUG_BREAK_IF(nullptr == pDevice); NEO::OSInterface &OsInterface = pDevice->getOsInterface(); + if (OsInterface.getDriverModel()->getDriverModelType() != NEO::DriverModelType::DRM) { + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } pDrm = OsInterface.getDriverModel()->as(); int myDeviceFd = pDrm->getFileDescriptor(); std::string myDeviceName; diff --git a/level_zero/tools/test/unit_tests/sources/sysman/linux/test_sysman.cpp b/level_zero/tools/test/unit_tests/sources/sysman/linux/test_sysman.cpp index 0625ad611f..92e2dbb5fc 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/linux/test_sysman.cpp +++ b/level_zero/tools/test/unit_tests/sources/sysman/linux/test_sysman.cpp @@ -272,5 +272,26 @@ TEST_F(SysmanMultiDeviceFixture, GivenValidEffectiveUserIdCheckWhetherPermission } } +class UnknownDriverModel : public DriverModel { + public: + UnknownDriverModel() : DriverModel(DriverModelType::UNKNOWN) {} + void setGmmInputArgs(void *args) override {} + uint32_t getDeviceHandle() const override { return 0u; } + PhysicalDevicePciBusInfo getPciBusInfo() const override { + PhysicalDevicePciBusInfo pciBusInfo(PhysicalDevicePciBusInfo::InvalidValue, PhysicalDevicePciBusInfo::InvalidValue, PhysicalDevicePciBusInfo::InvalidValue, PhysicalDevicePciBusInfo::InvalidValue); + return pciBusInfo; + } +}; + +using SysmanUnknownDriverModelTest = Test; +TEST_F(SysmanUnknownDriverModelTest, GivenDriverModelTypeIsNotDrmWhenExecutingSysmanOnLinuxThenErrorIsReturned) { + neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->osInterface = std::make_unique(); + auto &osInterface = device->getOsInterface(); + osInterface.setDriverModel(std::make_unique()); + auto pSysmanDeviceImp = std::make_unique(device->toHandle()); + auto pLinuxSysmanImp = static_cast(pSysmanDeviceImp->pOsSysman); + EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pLinuxSysmanImp->init()); +} + } // namespace ult } // namespace L0