Revert "Prelim DRM debug support"

Signed-off-by: Daniel Chabrowski daniel.chabrowski@intel.com
Related-To: NEO-6591

This reverts commit 5e021be0cd.
This commit is contained in:
Daniel Chabrowski
2022-02-25 13:40:36 +01:00
committed by Compute-Runtime-Automation
parent 82e3b10c5a
commit d603bb2f34
16 changed files with 31 additions and 665 deletions

View File

@@ -9,7 +9,6 @@
#include "shared/source/helpers/basic_math.h"
#include "shared/source/helpers/ptr_math.h"
#include "shared/source/helpers/string.h"
#include "shared/source/os_interface/linux/cache_info_impl.h"
#include "shared/test/common/libult/linux/drm_mock_helper.h"
@@ -48,13 +47,6 @@ int DrmMockPrelimContext::handlePrelimRequest(unsigned long request, void *arg)
return vmBindQueryReturn;
}
} break;
case DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM: {
auto gp = static_cast<drm_i915_gem_context_param *>(arg);
if (gp->param == PRELIM_I915_CONTEXT_PARAM_DEBUG_FLAGS) {
gp->value = contextDebugSupported ? PRELIM_I915_CONTEXT_PARAM_DEBUG_FLAG_SIP << 32 : 0;
return 0;
}
} break;
case PRELIM_DRM_IOCTL_I915_GEM_CLOS_RESERVE: {
auto closReserveArg = static_cast<prelim_drm_i915_gem_clos_reserve *>(arg);
closIndex++;
@@ -94,41 +86,6 @@ int DrmMockPrelimContext::handlePrelimRequest(unsigned long request, void *arg)
vmUnbindCalled++;
return vmUnbindReturn;
} break;
case PRELIM_DRM_IOCTL_I915_UUID_REGISTER: {
auto uuidControl = reinterpret_cast<prelim_drm_i915_uuid_control *>(arg);
if (uuidControl->uuid_class != uint32_t(PRELIM_I915_UUID_CLASS_STRING) && uuidControl->uuid_class > uuidHandle) {
return -1;
}
uuidControl->handle = uuidHandle++;
receivedRegisterUuid = UuidControl{
{},
uuidControl->uuid_class,
reinterpret_cast<void *>(uuidControl->ptr),
uuidControl->size,
uuidControl->handle,
uuidControl->flags,
uuidControl->extensions,
};
memcpy_s(receivedRegisterUuid->uuid, sizeof(receivedRegisterUuid->uuid), uuidControl->uuid, sizeof(uuidControl->uuid));
return uuidControlReturn;
} break;
case PRELIM_DRM_IOCTL_I915_UUID_UNREGISTER: {
auto uuidControl = reinterpret_cast<prelim_drm_i915_uuid_control *>(arg);
receivedUnregisterUuid = UuidControl{
{},
uuidControl->uuid_class,
reinterpret_cast<void *>(uuidControl->ptr),
uuidControl->size,
uuidControl->handle,
uuidControl->flags,
uuidControl->extensions,
};
memcpy_s(receivedUnregisterUuid->uuid, sizeof(receivedUnregisterUuid->uuid), uuidControl->uuid, sizeof(uuidControl->uuid));
return uuidControlReturn;
} break;
default:
return -1;
@@ -300,7 +257,3 @@ uint32_t DrmPrelimHelper::getDistanceInfoQueryId() {
uint32_t DrmPrelimHelper::getComputeEngineClass() {
return PRELIM_I915_ENGINE_CLASS_COMPUTE;
}
uint32_t DrmPrelimHelper::getStringUuidClass() {
return PRELIM_I915_UUID_CLASS_STRING;
}

View File

@@ -11,27 +11,14 @@
#include "shared/source/helpers/hw_info.h"
#include "shared/source/os_interface/linux/cache_info.h"
#include <optional>
using namespace NEO;
struct UuidControl {
char uuid[36]{};
uint32_t uuidClass{0};
void *ptr{nullptr};
uint64_t size{0};
uint32_t handle{0};
uint32_t flags{0};
uint64_t extensions{0};
};
struct DrmMockPrelimContext {
const HardwareInfo *hwInfo;
const RootDeviceEnvironment &rootDeviceEnvironment;
const CacheInfo *cacheInfo;
const bool &failRetTopology;
const BcsInfoMask &supportedCopyEnginesMask;
const bool &contextDebugSupported;
uint16_t closIndex{0};
uint16_t maxNumWays{32};
@@ -50,12 +37,6 @@ struct DrmMockPrelimContext {
int hasPageFaultQueryValue{0};
int hasPageFaultQueryReturn{0};
uint32_t uuidHandle{1};
std::optional<UuidControl> receivedRegisterUuid{};
std::optional<UuidControl> receivedUnregisterUuid{};
int uuidControlReturn{0};
bool failDistanceInfoQuery{false};
bool disableCcsSupport{false};
@@ -67,5 +48,4 @@ namespace DrmPrelimHelper {
uint32_t getQueryComputeSlicesIoctl();
uint32_t getDistanceInfoQueryId();
uint32_t getComputeEngineClass();
uint32_t getStringUuidClass();
}; // namespace DrmPrelimHelper

View File

@@ -43,7 +43,6 @@ class DrmQueryMock : public DrmMock {
getCacheInfo(),
failRetTopology,
supportedCopyEnginesMask,
contextDebugSupported,
};
static constexpr uint32_t maxEngineCount{9};

View File

@@ -10,7 +10,6 @@ set(NEO_CORE_OS_INTERFACE_TESTS_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/device_factory_tests_linux.h
${CMAKE_CURRENT_SOURCE_DIR}/drm_bind_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_command_stream_l0_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_debug_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_engine_info_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_memory_info_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_mock_impl.h
@@ -24,7 +23,6 @@ set(NEO_CORE_OS_INTERFACE_TESTS_LINUX
if(NEO_ENABLE_i915_PRELIM_DETECTION)
list(APPEND NEO_CORE_OS_INTERFACE_TESTS_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/drm_cache_info_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_debug_prelim_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_query_topology_prelim_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_with_prelim_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ioctl_helper_tests_prelim.cpp

View File

@@ -1,236 +0,0 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/linux/drm_debug.h"
#include "shared/test/common/libult/linux/drm_query_mock.h"
#include "shared/test/common/test_macros/matchers.h"
#include "shared/test/common/test_macros/test.h"
#include "gtest/gtest.h"
using namespace NEO;
struct DrmDebugPrelimTest : public ::testing::Test {
public:
void SetUp() override {
executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get());
}
void TearDown() override {
}
protected:
std::unique_ptr<ExecutionEnvironment> executionEnvironment;
};
TEST_F(DrmDebugPrelimTest, GivenDrmWhenRegisteringClassesThenHandlesAreStored) {
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
auto handle = drm.context.uuidHandle;
EXPECT_EQ(0u, drm.classHandles.size());
auto result = drm.registerResourceClasses();
EXPECT_TRUE(result);
EXPECT_EQ(classNamesToUuid.size(), drm.classHandles.size());
for (size_t i = 0; i < classNamesToUuid.size(); i++) {
EXPECT_EQ(drm.classHandles[i], handle);
handle++;
}
ASSERT_TRUE(drm.context.receivedRegisterUuid);
EXPECT_THAT(drm.context.receivedRegisterUuid->uuid, testing::HasSubstr(classNamesToUuid[classNamesToUuid.size() - 1].second));
}
TEST_F(DrmDebugPrelimTest, GivenUnsupportedUUIDRegisterIoctlWhenRegisteringClassesThenErrorIsReturnedAndClassHandlesAreEmpty) {
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
drm.context.uuidControlReturn = -1;
EXPECT_EQ(0u, drm.classHandles.size());
auto result = drm.registerResourceClasses();
EXPECT_FALSE(result);
EXPECT_EQ(0u, drm.classHandles.size());
}
TEST_F(DrmDebugPrelimTest, GivenNoClassesRegisteredWhenRegisteringResourceThenRegisterUUIDIoctlIsNotCalledAndZeroHandleReturned) {
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
auto registeredHandle = drm.registerResource(Drm::ResourceClass::Isa, nullptr, 0);
EXPECT_EQ(0u, registeredHandle);
EXPECT_EQ(0u, drm.ioctlCallsCount);
}
TEST_F(DrmDebugPrelimTest, GivenDrmWhenRegisteringResourceWithoutDataThenRegisterUUIDIoctlIsCalled) {
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
const auto result = drm.registerResourceClasses();
EXPECT_TRUE(result);
const auto handle = drm.context.uuidHandle;
auto registeredHandle = drm.registerResource(Drm::ResourceClass::Isa, nullptr, 0);
EXPECT_EQ(handle + 1, drm.context.uuidHandle);
EXPECT_EQ(handle, registeredHandle);
const auto &receivedUuid = drm.context.receivedRegisterUuid;
ASSERT_TRUE(receivedUuid);
EXPECT_EQ(nullptr, receivedUuid->ptr);
EXPECT_EQ(0u, receivedUuid->size);
EXPECT_THAT(receivedUuid->uuid, testing::HasSubstr(std::string("00000000-0000-0000")));
EXPECT_EQ(drm.classHandles[static_cast<uint32_t>(Drm::ResourceClass::Isa)], receivedUuid->uuidClass);
}
TEST_F(DrmDebugPrelimTest, GivenDrmWhenRegisteringResourceWithDataThenRegisterUUIDIoctlIsCalledWithCorrectData) {
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
auto result = drm.registerResourceClasses();
EXPECT_TRUE(result);
auto handle = drm.context.uuidHandle;
uint64_t data = 0x12345678;
auto registeredHandle = drm.registerResource(Drm::ResourceClass::Isa, &data, sizeof(uint64_t));
EXPECT_EQ(handle + 1, drm.context.uuidHandle);
EXPECT_EQ(handle, registeredHandle);
const auto &receivedUuid = drm.context.receivedRegisterUuid;
ASSERT_TRUE(receivedUuid);
EXPECT_EQ(&data, receivedUuid->ptr);
EXPECT_EQ(sizeof(uint64_t), receivedUuid->size);
EXPECT_THAT(receivedUuid->uuid, testing::HasSubstr(std::string("00000000-0000-0000")));
EXPECT_EQ(drm.classHandles[static_cast<uint32_t>(Drm::ResourceClass::Isa)], receivedUuid->uuidClass);
EXPECT_EQ(0u, receivedUuid->flags);
EXPECT_EQ(0u, receivedUuid->extensions);
}
TEST_F(DrmDebugPrelimTest, GivenDrmWhenUnregisteringResourceThenUnregisterUUIDIoctlIsCalled) {
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
auto result = drm.registerResourceClasses();
EXPECT_TRUE(result);
uint64_t data = 0x12345678;
auto registeredHandle = drm.registerResource(Drm::ResourceClass::Isa, &data, sizeof(uint64_t));
drm.unregisterResource(registeredHandle);
const auto &receivedUuid = drm.context.receivedUnregisterUuid;
ASSERT_TRUE(receivedUuid);
EXPECT_EQ(registeredHandle, receivedUuid->handle);
EXPECT_EQ(nullptr, receivedUuid->ptr);
EXPECT_EQ(0u, receivedUuid->size);
EXPECT_EQ(0u, receivedUuid->uuidClass);
EXPECT_EQ(0u, receivedUuid->flags);
EXPECT_EQ(0u, receivedUuid->extensions);
}
TEST_F(DrmDebugPrelimTest, GivenDrmWhenNotifyFirstCommandQueueCreatedCalledThenCorrectUuidIsRegisteredWithCorrectData) {
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
auto handle = drm.context.uuidHandle;
auto registeredHandle = drm.notifyFirstCommandQueueCreated();
EXPECT_EQ(handle + 1, drm.context.uuidHandle);
EXPECT_EQ(handle, registeredHandle);
const auto &receivedUuid = drm.context.receivedRegisterUuid;
ASSERT_TRUE(receivedUuid);
EXPECT_EQ(DrmPrelimHelper::getStringUuidClass(), receivedUuid->uuidClass);
EXPECT_EQ(receivedUuid->size, strlen(uuidL0CommandQueueName));
EXPECT_EQ(0, memcmp(reinterpret_cast<const char *>(receivedUuid->ptr), uuidL0CommandQueueName, receivedUuid->size));
EXPECT_EQ(0, memcmp(receivedUuid->uuid, uuidL0CommandQueueHash, sizeof(receivedUuid->uuid)));
}
TEST_F(DrmDebugPrelimTest, GivenDrmWhenNotifyLastCommandQueueDestroyedCalledThenCorrectUuidIsUnregistered) {
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
drm.notifyLastCommandQueueDestroyed(1234u);
EXPECT_EQ(1234u, drm.context.receivedUnregisterUuid->handle);
}
TEST_F(DrmDebugPrelimTest, GivenDrmWhenRegisteringIsaCookieThenRegisterUUIDIoctlIsCalled) {
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
auto result = drm.registerResourceClasses();
EXPECT_TRUE(result);
auto prevIoctls = drm.ioctlCallsCount;
auto registeredHandle = drm.registerIsaCookie(3);
EXPECT_EQ(prevIoctls + 1u, drm.ioctlCallsCount);
EXPECT_EQ(drm.context.uuidHandle - 1, registeredHandle);
EXPECT_EQ(3u, drm.context.receivedRegisterUuid->uuidClass);
}
TEST_F(DrmDebugPrelimTest, GivenDrmWhenRegisteringElfResourceWithoutDataThenRegisterUUIDIoctlIsCalled) {
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
auto result = drm.registerResourceClasses();
EXPECT_TRUE(result);
auto handle = drm.context.uuidHandle;
auto registeredHandle = drm.registerResource(Drm::ResourceClass::Elf, nullptr, 0);
EXPECT_EQ(handle + 1, drm.context.uuidHandle);
EXPECT_EQ(handle, registeredHandle);
EXPECT_EQ(nullptr, drm.context.receivedRegisterUuid->ptr);
EXPECT_EQ(0u, drm.context.receivedRegisterUuid->size);
}
TEST(DrmPrelimTest, givenContextDebugAvailableWhenCheckedForSupportThenTrueIsReturned) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->setDebuggingEnabled();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
executionEnvironment->calculateMaxOsContextCount();
executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
auto *drm = new DrmQueryMock(*executionEnvironment->rootDeviceEnvironments[0]);
drm->contextDebugSupported = true;
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
auto prevIoctls = drm->ioctlCallsCount;
auto contextParamCallsBefore = drm->receivedContextParamRequestCount;
drm->checkContextDebugSupport();
EXPECT_EQ(prevIoctls + 1u, drm->ioctlCallsCount);
EXPECT_EQ(contextParamCallsBefore + 1u, drm->receivedContextParamRequestCount);
EXPECT_TRUE(drm->isContextDebugSupported());
EXPECT_EQ(prevIoctls + 1u, drm->ioctlCallsCount);
}
TEST(DrmPrelimTest, givenContextDebugNotAvailableWhenCheckedForSupportThenTrueIsReturned) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->setDebuggingEnabled();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
executionEnvironment->calculateMaxOsContextCount();
executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
auto *drm = new DrmQueryMock(*executionEnvironment->rootDeviceEnvironments[0]);
drm->contextDebugSupported = false;
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
auto prevIoctls = drm->ioctlCallsCount;
auto contextParamCallsBefore = drm->receivedContextParamRequestCount;
drm->checkContextDebugSupport();
EXPECT_EQ(prevIoctls + 1u, drm->ioctlCallsCount);
EXPECT_EQ(contextParamCallsBefore + 1u, drm->receivedContextParamRequestCount);
EXPECT_FALSE(drm->isContextDebugSupported());
EXPECT_EQ(prevIoctls + 1u, drm->ioctlCallsCount);
}

View File

@@ -1,72 +0,0 @@
/*
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/linux/drm_neo.h"
#include "shared/test/common/libult/linux/drm_mock.h"
#include "gtest/gtest.h"
using namespace NEO;
struct DrmDebugTest : public ::testing::Test {
public:
void SetUp() override {
executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get());
}
void TearDown() override {
}
protected:
std::unique_ptr<ExecutionEnvironment> executionEnvironment;
};
TEST_F(DrmDebugTest, whenRegisterResourceClassesCalledThenTrueIsReturned) {
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
auto result = drmMock.registerResourceClasses();
EXPECT_TRUE(result);
}
TEST_F(DrmDebugTest, whenRegisterResourceCalledThenImplementationIsEmpty) {
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
auto handle = drmMock.registerResource(Drm::ResourceClass::MaxSize, nullptr, 0);
EXPECT_EQ(0u, handle);
drmMock.unregisterResource(handle);
EXPECT_EQ(0u, drmMock.ioctlCallsCount);
}
TEST_F(DrmDebugTest, whenRegisterIsaCookieCalledThenImplementationIsEmpty) {
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
const uint32_t isaHandle = 2;
auto handle = drmMock.registerIsaCookie(isaHandle);
EXPECT_EQ(0u, handle);
EXPECT_EQ(0u, drmMock.ioctlCallsCount);
}
TEST_F(DrmDebugTest, whenCheckingContextDebugSupportThenNoIoctlIsCalled) {
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
drmMock.checkContextDebugSupport();
EXPECT_FALSE(drmMock.isContextDebugSupported());
EXPECT_EQ(0u, drmMock.ioctlCallsCount);
}
TEST_F(DrmDebugTest, whenNotifyCommandQueueCreateDestroyAreCalledThenImplementationsAreEmpty) {
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
auto handle = drmMock.notifyFirstCommandQueueCreated();
EXPECT_EQ(0u, handle);
EXPECT_EQ(0u, drmMock.ioctlCallsCount);
drmMock.notifyLastCommandQueueDestroyed(0);
EXPECT_EQ(0u, drmMock.ioctlCallsCount);
}

View File

@@ -7,7 +7,6 @@
#include "shared/source/os_interface/linux/ioctl_helper.h"
#include "shared/source/os_interface/linux/ioctl_strings.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/test_macros/test.h"
#include "third_party/uapi/prelim/drm/i915_drm.h"

View File

@@ -327,46 +327,3 @@ TEST(IoctlHelperTestsUpstream, givenUpstreamWhenGettingEuStallFdParameterThenZer
IoctlHelperUpstream ioctlHelper{};
EXPECT_EQ(0u, ioctlHelper.getEuStallFdParameter());
}
TEST(IoctlHelperTestsUpstream, whenRegisterUuidIsCalledThenReturnNullHandle) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
IoctlHelperUpstream ioctlHelper{};
{
const auto [retVal, handle] = ioctlHelper.registerUuid(drm.get(), "", 0, 0, 0);
EXPECT_EQ(0u, retVal);
EXPECT_EQ(0u, handle);
}
{
const auto [retVal, handle] = ioctlHelper.registerStringClassUuid(drm.get(), "", 0, 0);
EXPECT_EQ(0u, retVal);
EXPECT_EQ(0u, handle);
}
}
TEST(IoctlHelperTestsUpstream, whenUnregisterUuidIsCalledThenZeroIsReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
IoctlHelperUpstream ioctlHelper{};
EXPECT_EQ(0, ioctlHelper.unregisterUuid(drm.get(), 0));
}
TEST(IoctlHelperTestsUpstream, whenIsContextDebugSupportedIsCalledThenFalseIsReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
IoctlHelperUpstream ioctlHelper{};
EXPECT_EQ(false, ioctlHelper.isContextDebugSupported(drm.get()));
}
TEST(IoctlHelperTestsUpstream, whenSetContextDebugFlagIsCalledThenZeroIsReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
IoctlHelperUpstream ioctlHelper{};
EXPECT_EQ(0, ioctlHelper.setContextDebugFlag(drm.get(), 0));
}