2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2024-12-19 00:08:06 +08:00
|
|
|
* Copyright (C) 2018-2024 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-10-22 22:13:05 +08:00
|
|
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
2022-12-07 19:51:44 +08:00
|
|
|
#include "shared/source/execution_environment/execution_environment.h"
|
2020-03-04 15:51:02 +08:00
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
2023-02-02 00:23:01 +08:00
|
|
|
#include "shared/source/helpers/gfx_core_helper.h"
|
2024-12-19 00:08:06 +08:00
|
|
|
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
2021-01-21 20:10:13 +08:00
|
|
|
#include "shared/test/common/helpers/default_hw_info.h"
|
2021-09-24 09:16:09 +08:00
|
|
|
#include "shared/test/common/libult/linux/drm_mock.h"
|
2020-02-23 22:20:22 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-03-30 15:00:26 +08:00
|
|
|
class DrmMockDefault : public DrmMock {
|
2017-12-21 07:45:38 +08:00
|
|
|
public:
|
2021-10-22 00:09:45 +08:00
|
|
|
DrmMockDefault(std::unique_ptr<HwDeviceIdDrm> &&hwDeviceIdIn, RootDeviceEnvironment &rootDeviceEnvironment) : DrmMock(rootDeviceEnvironment) {
|
2021-06-25 23:33:33 +08:00
|
|
|
storedRetVal = 0;
|
|
|
|
storedRetValForDeviceID = 0;
|
|
|
|
storedRetValForDeviceRevID = 0;
|
|
|
|
storedRetValForPooledEU = 0;
|
|
|
|
storedRetValForMinEUinPool = 0;
|
2022-01-27 00:25:28 +08:00
|
|
|
|
2021-10-22 00:09:45 +08:00
|
|
|
if (hwDeviceIdIn != nullptr)
|
|
|
|
this->hwDeviceId = std::move(hwDeviceIdIn);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-02-12 00:48:40 +08:00
|
|
|
Drm **pDrmToReturnFromCreateFunc = nullptr;
|
2021-03-18 17:22:18 +08:00
|
|
|
bool disableBindDefaultInTests = true;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2021-10-21 20:37:31 +08:00
|
|
|
Drm *Drm::create(std::unique_ptr<HwDeviceIdDrm> &&hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) {
|
2024-12-19 00:08:06 +08:00
|
|
|
DebugManagerStateRestore restore;
|
|
|
|
debugManager.flags.IgnoreProductSpecificIoctlHelper.set(true);
|
2023-01-03 18:27:35 +08:00
|
|
|
rootDeviceEnvironment.setHwInfoAndInitHelpers(defaultHwInfo.get());
|
2020-02-12 00:48:40 +08:00
|
|
|
if (pDrmToReturnFromCreateFunc) {
|
|
|
|
return *pDrmToReturnFromCreateFunc;
|
|
|
|
}
|
2021-10-22 00:09:45 +08:00
|
|
|
auto drm = new DrmMockDefault(std::move(hwDeviceId), rootDeviceEnvironment);
|
2020-11-23 22:31:20 +08:00
|
|
|
|
2021-03-17 01:47:26 +08:00
|
|
|
const HardwareInfo *hwInfo = rootDeviceEnvironment.getHardwareInfo();
|
2021-04-09 21:46:28 +08:00
|
|
|
|
2022-01-29 05:00:05 +08:00
|
|
|
drm->setupIoctlHelper(hwInfo->platform.eProductFamily);
|
2022-01-21 20:39:11 +08:00
|
|
|
|
2021-06-01 00:58:10 +08:00
|
|
|
drm->queryAdapterBDF();
|
|
|
|
|
2021-04-09 21:46:28 +08:00
|
|
|
drm->queryMemoryInfo();
|
2021-03-17 01:47:26 +08:00
|
|
|
|
2021-11-12 06:11:38 +08:00
|
|
|
drm->queryPageFaultSupport();
|
|
|
|
|
2023-04-12 18:03:29 +08:00
|
|
|
if (rootDeviceEnvironment.executionEnvironment.isDebuggingEnabled()) {
|
2023-12-12 19:37:31 +08:00
|
|
|
if (drm->getRootDeviceEnvironment().executionEnvironment.getDebuggingMode() == DebuggingMode::offline) {
|
2023-04-12 18:03:29 +08:00
|
|
|
drm->setPerContextVMRequired(false);
|
|
|
|
} else {
|
|
|
|
if (drm->isVmBindAvailable()) {
|
|
|
|
drm->setPerContextVMRequired(true);
|
|
|
|
}
|
|
|
|
}
|
2020-11-23 22:31:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!drm->isPerContextVMRequired()) {
|
2023-10-26 21:04:39 +08:00
|
|
|
drm->createVirtualMemoryAddressSpace(GfxCoreHelper::getSubDevicesCount(hwInfo));
|
2020-07-15 14:07:53 +08:00
|
|
|
}
|
2021-11-02 15:54:20 +08:00
|
|
|
|
2020-07-07 15:34:31 +08:00
|
|
|
return drm;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
2020-09-17 20:56:32 +08:00
|
|
|
|
|
|
|
void Drm::overrideBindSupport(bool &useVmBind) {
|
2021-03-18 17:22:18 +08:00
|
|
|
if (disableBindDefaultInTests) {
|
|
|
|
useVmBind = false;
|
|
|
|
}
|
2023-11-30 16:32:25 +08:00
|
|
|
if (debugManager.flags.UseVmBind.get() == 1) {
|
2020-09-17 20:56:32 +08:00
|
|
|
useVmBind = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|