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