From 08faa004aa2ec4f754ebfb12efb918e63d2a73e6 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Fri, 18 May 2018 09:53:59 +0200 Subject: [PATCH] Linux dll tests: test turbo patch only on supported platforms use deviceId from first entry in deviceDescriptorTable as default deviceId correct using simplified mocs table Change-Id: I3a6e7cd599912380d48937767f201b44ee98e391 --- runtime/dll/linux/drm_neo_create.cpp | 2 +- unit_tests/linux/drm_null_device_tests.cpp | 2 +- unit_tests/linux/main_linux_dll.cpp | 60 ++++++++++++++++++++-- unit_tests/linux/mock_os_layer.cpp | 7 ++- unit_tests/linux/mock_os_layer.h | 4 +- 5 files changed, 63 insertions(+), 12 deletions(-) diff --git a/runtime/dll/linux/drm_neo_create.cpp b/runtime/dll/linux/drm_neo_create.cpp index 435a519838..1c4e2c0977 100644 --- a/runtime/dll/linux/drm_neo_create.cpp +++ b/runtime/dll/linux/drm_neo_create.cpp @@ -210,7 +210,7 @@ Drm *Drm::create(int32_t deviceOrdinal) { if (ret != 0) { //turbo patch not present, we are not on custom Kernel, switch to simplified Mocs selection //do this only for GEN9+ - if (eGtType >= GTTYPE_GTA) { + if (device->pHwInfo->pPlatform->eRenderCoreFamily >= IGFX_GEN9_CORE) { Gmm::useSimplifiedMocsTable = true; } printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Failed to request OCL Turbo Boost\n"); diff --git a/unit_tests/linux/drm_null_device_tests.cpp b/unit_tests/linux/drm_null_device_tests.cpp index c729f76ce2..ac1862759c 100644 --- a/unit_tests/linux/drm_null_device_tests.cpp +++ b/unit_tests/linux/drm_null_device_tests.cpp @@ -73,7 +73,7 @@ TEST_F(DrmNullDeviceTests, GIVENdrmNullDeviceWHENcallGetDeviceIdTHENreturnProper int deviceId = 0; int ret = drmNullDevice->getDeviceID(deviceId); EXPECT_EQ(0, ret); - EXPECT_EQ(0x1916, deviceId); + EXPECT_EQ(deviceDescriptorTable[0].deviceId, deviceId); } TEST_F(DrmNullDeviceTests, GIVENdrmNullDeviceWHENcallIoctlTHENalwaysSuccess) { diff --git a/unit_tests/linux/main_linux_dll.cpp b/unit_tests/linux/main_linux_dll.cpp index 2812c4ee34..b2c834df7a 100644 --- a/unit_tests/linux/main_linux_dll.cpp +++ b/unit_tests/linux/main_linux_dll.cpp @@ -26,6 +26,7 @@ #include "runtime/helpers/basic_math.h" #include "runtime/os_interface/linux/allocator_helper.h" #include "unit_tests/custom_event_listener.h" +#include "unit_tests/helpers/variable_backup.h" #include "test.h" using namespace OCLRT; @@ -199,6 +200,7 @@ TEST_F(DrmTests, failOnSoftPin) { } TEST_F(DrmTests, failOnParamBoost) { + VariableBackup useSimplifiedMocsTableBckp(&Gmm::useSimplifiedMocsTable); failOnParamBoost = -1; auto ptr = DrmWrap::createDrm(0); @@ -206,23 +208,73 @@ TEST_F(DrmTests, failOnParamBoost) { EXPECT_NE(ptr, nullptr); } -TEST_F(DrmTests, givenKernelNotSupportingTurboPatchWhenDeviceLowerThenGen9IsCreatedThenSimplifiedMocsSelectionIsFalse) { +#ifdef SUPPORT_BDW +TEST_F(DrmTests, givenKernelNotSupportingTurboPatchWhenBdwDeviceIsCreatedThenSimplifiedMocsSelectionIsFalse) { + VariableBackup useSimplifiedMocsTableBckp(&Gmm::useSimplifiedMocsTable); + useSimplifiedMocsTableBckp = false; deviceId = IBDW_GT3_WRK_DEVICE_F0_ID; failOnParamBoost = -1; auto ptr = DrmWrap::createDrm(0); EXPECT_NE(ptr, nullptr); EXPECT_FALSE(Gmm::useSimplifiedMocsTable); } +#endif -TEST_F(DrmTests, givenKernelNotSupportingTurboPatchWhenDeviceIsNewerThenGen9IsCreatedThenSimplifiedMocsSelectionIsTrue) { - Gmm::useSimplifiedMocsTable = false; +#ifdef SUPPORT_SKL +TEST_F(DrmTests, givenKernelNotSupportingTurboPatchWhenSklDeviceIsCreatedThenSimplifiedMocsSelectionIsTrue) { + VariableBackup useSimplifiedMocsTableBckp(&Gmm::useSimplifiedMocsTable); + useSimplifiedMocsTableBckp = false; + deviceId = ISKL_GT2_DT_DEVICE_F0_ID; + failOnParamBoost = -1; + auto ptr = DrmWrap::createDrm(0); + EXPECT_NE(ptr, nullptr); + EXPECT_TRUE(Gmm::useSimplifiedMocsTable); +} +#endif +#ifdef SUPPORT_KBL +TEST_F(DrmTests, givenKernelNotSupportingTurboPatchWhenKblDeviceIsCreatedThenSimplifiedMocsSelectionIsTrue) { + VariableBackup useSimplifiedMocsTableBckp(&Gmm::useSimplifiedMocsTable); + useSimplifiedMocsTableBckp = false; + deviceId = IKBL_GT1_ULT_DEVICE_F0_ID; + failOnParamBoost = -1; + auto ptr = DrmWrap::createDrm(0); + EXPECT_NE(ptr, nullptr); + EXPECT_TRUE(Gmm::useSimplifiedMocsTable); +} +#endif +#ifdef SUPPORT_BXT +TEST_F(DrmTests, givenKernelNotSupportingTurboPatchWhenBxtDeviceIsCreatedThenSimplifiedMocsSelectionIsTrue) { + VariableBackup useSimplifiedMocsTableBckp(&Gmm::useSimplifiedMocsTable); + useSimplifiedMocsTableBckp = false; deviceId = IBXT_X_DEVICE_F0_ID; failOnParamBoost = -1; auto ptr = DrmWrap::createDrm(0); EXPECT_NE(ptr, nullptr); EXPECT_TRUE(Gmm::useSimplifiedMocsTable); - Gmm::useSimplifiedMocsTable = false; } +#endif +#ifdef SUPPORT_GLK +TEST_F(DrmTests, givenKernelNotSupportingTurboPatchWhenGlkDeviceIsCreatedThenSimplifiedMocsSelectionIsTrue) { + VariableBackup useSimplifiedMocsTableBckp(&Gmm::useSimplifiedMocsTable); + useSimplifiedMocsTableBckp = false; + deviceId = IGLK_GT2_ULT_18EU_DEVICE_F0_ID; + failOnParamBoost = -1; + auto ptr = DrmWrap::createDrm(0); + EXPECT_NE(ptr, nullptr); + EXPECT_TRUE(Gmm::useSimplifiedMocsTable); +} +#endif +#ifdef SUPPORT_CFL +TEST_F(DrmTests, givenKernelNotSupportingTurboPatchWhenCflDeviceIsCreatedThenSimplifiedMocsSelectionIsTrue) { + VariableBackup useSimplifiedMocsTableBckp(&Gmm::useSimplifiedMocsTable); + useSimplifiedMocsTableBckp = false; + deviceId = ICFL_GT1_S61_DT_DEVICE_F0_ID; + failOnParamBoost = -1; + auto ptr = DrmWrap::createDrm(0); + EXPECT_NE(ptr, nullptr); + EXPECT_TRUE(Gmm::useSimplifiedMocsTable); +} +#endif TEST_F(DrmTests, givenKernelSupportingTurboPatchWhenDeviceIsCreatedThenSimplifiedMocsSelectionIsFalse) { auto ptr = DrmWrap::createDrm(0); diff --git a/unit_tests/linux/mock_os_layer.cpp b/unit_tests/linux/mock_os_layer.cpp index ee05443b28..e3ae9b7fd0 100644 --- a/unit_tests/linux/mock_os_layer.cpp +++ b/unit_tests/linux/mock_os_layer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -23,15 +23,14 @@ #include "mock_os_layer.h" #include #include - const char *devDri[2] = {"/dev/dri/renderD128", "/dev/dri/card0"}; int (*c_open)(const char *pathname, int flags, ...) = nullptr; int (*c_ioctl)(int fd, unsigned long int request, ...) = nullptr; int fakeFd = 1023; -int haveDri = 0; // index of dri to serve, -1 - none -int deviceId = 0x1916; // known DeviceID +int haveDri = 0; // index of dri to serve, -1 - none +int deviceId = OCLRT::deviceDescriptorTable[0].deviceId; // default supported DeviceID int haveSoftPin = 1; int havePreemption = 1; int failOnDeviceId = 0; diff --git a/unit_tests/linux/mock_os_layer.h b/unit_tests/linux/mock_os_layer.h index 7443dffbd8..d239bbe3b8 100644 --- a/unit_tests/linux/mock_os_layer.h +++ b/unit_tests/linux/mock_os_layer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -63,7 +63,7 @@ extern std::array drms; inline void resetOSMockGlobalState() { fakeFd = 1023; haveDri = 0; - deviceId = 0x1916; + deviceId = OCLRT::deviceDescriptorTable[0].deviceId; haveSoftPin = 1; failOnDeviceId = 0; failOnRevisionId = 0;