2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2022-01-27 00:25:28 +08:00
|
|
|
* Copyright (C) 2018-2022 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"
|
2020-03-04 15:51:02 +08:00
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
2020-07-07 15:34:31 +08:00
|
|
|
#include "shared/source/helpers/hw_helper.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-02-27 18:39:32 +08:00
|
|
|
#include "drm/i915_drm.h"
|
|
|
|
|
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) {
|
2020-03-25 00:52:43 +08:00
|
|
|
rootDeviceEnvironment.setHwInfo(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-21 20:39:11 +08:00
|
|
|
drm->setupIoctlHelper();
|
|
|
|
|
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();
|
|
|
|
|
2020-11-23 22:31:20 +08:00
|
|
|
if (drm->isVmBindAvailable() && rootDeviceEnvironment.executionEnvironment.isDebuggingEnabled()) {
|
|
|
|
drm->setPerContextVMRequired(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!drm->isPerContextVMRequired()) {
|
2021-03-17 01:47:26 +08:00
|
|
|
drm->createVirtualMemoryAddressSpace(HwHelper::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;
|
|
|
|
}
|
2020-09-17 20:56:32 +08:00
|
|
|
if (DebugManager.flags.UseVmBind.get() == 1) {
|
|
|
|
useVmBind = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|