mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-11 16:45:25 +08:00
feature(sysman): Support Global Operations module for windows zesInit
Related-To: LOCI-4194 Signed-off-by: Kulkarni, Ashwin Kumar <ashwin.kumar.kulkarni@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
09fcfbba6b
commit
24495b5954
@@ -35,7 +35,16 @@ void WddmGlobalOperationsImp::getWedgedStatus(zes_device_state_t *pState) {
|
||||
void WddmGlobalOperationsImp::getRepairStatus(zes_device_state_t *pState) {
|
||||
}
|
||||
ze_result_t WddmGlobalOperationsImp::reset(ze_bool_t force) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
uint32_t value = 0;
|
||||
KmdSysman::RequestProperty request;
|
||||
KmdSysman::ResponseProperty response;
|
||||
request.commandId = KmdSysman::Command::Set;
|
||||
request.componentId = KmdSysman::Component::GlobalOperationsComponent;
|
||||
request.requestId = KmdSysman::Requests::GlobalOperation::TriggerDeviceLevelReset;
|
||||
request.dataSize = sizeof(uint32_t);
|
||||
value = static_cast<uint32_t>(force);
|
||||
memcpy_s(request.dataBuffer, sizeof(uint32_t), &value, sizeof(uint32_t));
|
||||
return pKmdSysManager->requestSingle(request, response);
|
||||
}
|
||||
|
||||
ze_result_t WddmGlobalOperationsImp::scanProcessesState(std::vector<zes_process_state_t> &pProcessList) {
|
||||
@@ -47,6 +56,8 @@ ze_result_t WddmGlobalOperationsImp::deviceGetState(zes_device_state_t *pState)
|
||||
}
|
||||
|
||||
WddmGlobalOperationsImp::WddmGlobalOperationsImp(OsSysman *pOsSysman) {
|
||||
WddmSysmanImp *pWddmSysmanImp = static_cast<WddmSysmanImp *>(pOsSysman);
|
||||
pKmdSysManager = &pWddmSysmanImp->getKmdSysManager();
|
||||
}
|
||||
|
||||
OsGlobalOperations *OsGlobalOperations::create(OsSysman *pOsSysman) {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
|
||||
class KmdSysManager;
|
||||
class WddmGlobalOperationsImp : public OsGlobalOperations, NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
bool getSerialNumber(char (&serialNumber)[ZES_STRING_PROPERTY_SIZE]) override;
|
||||
@@ -31,6 +31,9 @@ class WddmGlobalOperationsImp : public OsGlobalOperations, NEO::NonCopyableOrMov
|
||||
WddmGlobalOperationsImp(OsSysman *pOsSysman);
|
||||
WddmGlobalOperationsImp() = default;
|
||||
~WddmGlobalOperationsImp() override = default;
|
||||
|
||||
protected:
|
||||
KmdSysManager *pKmdSysManager = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Sysman
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# Copyright (C) 2023 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
if(WIN32)
|
||||
target_sources(${TARGET_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_zes_global_operations.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_global_operations.h
|
||||
)
|
||||
endif()
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "level_zero/sysman/source/global_operations/sysman_global_operations_imp.h"
|
||||
#include "level_zero/sysman/source/global_operations/windows/sysman_os_global_operations_imp.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/windows/mock_kmd_sys_manager.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
struct MockGlobalOpsKmdSysManager : public MockKmdSysManager {
|
||||
|
||||
void setGlobalOperationsProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) override {
|
||||
uint8_t *pBuffer = reinterpret_cast<uint8_t *>(pRequest);
|
||||
pBuffer += sizeof(KmdSysman::GfxSysmanReqHeaderIn);
|
||||
|
||||
switch (pRequest->inRequestId) {
|
||||
case KmdSysman::Requests::GlobalOperation::TriggerDeviceLevelReset: {
|
||||
uint32_t *value = reinterpret_cast<uint32_t *>(pBuffer);
|
||||
*value = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
} break;
|
||||
default: {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/sysman/source/global_operations/windows/sysman_os_global_operations_imp.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/global_operations/windows/mock_global_operations.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/windows/mock_sysman_fixture.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
class SysmanGlobalOperationsFixture : public SysmanDeviceFixture {
|
||||
protected:
|
||||
L0::Sysman::OsGlobalOperations *pOsGlobalOperationsPrev = nullptr;
|
||||
L0::Sysman::GlobalOperations *pGlobalOperationsPrev = nullptr;
|
||||
L0::Sysman::GlobalOperationsImp *pGlobalOperationsImp;
|
||||
|
||||
std::unique_ptr<MockGlobalOpsKmdSysManager> pKmdSysManager = nullptr;
|
||||
L0::Sysman::KmdSysManager *pOriginalKmdSysManager = nullptr;
|
||||
|
||||
void SetUp() override {
|
||||
SysmanDeviceFixture::SetUp();
|
||||
}
|
||||
|
||||
void init(bool allowSetCalls) {
|
||||
pKmdSysManager.reset(new MockGlobalOpsKmdSysManager);
|
||||
|
||||
pKmdSysManager->allowSetCalls = allowSetCalls;
|
||||
|
||||
pOriginalKmdSysManager = pWddmSysmanImp->pKmdSysManager;
|
||||
pWddmSysmanImp->pKmdSysManager = pKmdSysManager.get();
|
||||
|
||||
pGlobalOperationsImp = static_cast<L0::Sysman::GlobalOperationsImp *>(pSysmanDeviceImp->pGlobalOperations);
|
||||
pOsGlobalOperationsPrev = pGlobalOperationsImp->pOsGlobalOperations;
|
||||
pGlobalOperationsImp->pOsGlobalOperations = nullptr;
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if (nullptr != pGlobalOperationsImp->pOsGlobalOperations) {
|
||||
delete pGlobalOperationsImp->pOsGlobalOperations;
|
||||
}
|
||||
pGlobalOperationsImp->pOsGlobalOperations = pOsGlobalOperationsPrev;
|
||||
pGlobalOperationsImp = nullptr;
|
||||
pWddmSysmanImp->pKmdSysManager = pOriginalKmdSysManager;
|
||||
SysmanDeviceFixture::TearDown();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenForceTrueAndDeviceInUseWhenCallingResetThenSuccessIsReturned) {
|
||||
init(true);
|
||||
ze_result_t result = zesDeviceReset(pSysmanDevice->toHandle(), true);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDeviceGetStateThenFailureIsReturned) {
|
||||
init(true);
|
||||
zes_device_state_t pState = {};
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesDeviceGetState(pSysmanDevice->toHandle(), &pState));
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDeviceProcessesGetStateThenFailureIsReturned) {
|
||||
init(true);
|
||||
uint32_t count = 0;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesDeviceProcessesGetState(pSysmanDevice->toHandle(), &count, nullptr));
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenProcessStartsMidResetWhenCallingResetThenSuccessIsReturned) {
|
||||
init(false);
|
||||
ze_result_t result = zesDeviceReset(pSysmanDevice->toHandle(), true);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, result);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
Reference in New Issue
Block a user