2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2024-03-10 21:30:08 +00:00
|
|
|
* Copyright (C) 2018-2024 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-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
|
|
|
|
#include "shared/source/execution_environment/execution_environment.h"
|
|
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
|
|
|
|
#include "shared/source/gmm_helper/gmm_helper.h"
|
2024-09-03 14:25:07 +00:00
|
|
|
#include "shared/source/helpers/compiler_product_helper.h"
|
2023-02-01 16:23:01 +00:00
|
|
|
#include "shared/source/helpers/gfx_core_helper.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/helpers/hw_info.h"
|
2022-01-31 17:43:42 +00:00
|
|
|
#include "shared/source/os_interface/device_factory.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/os_interface/linux/drm_neo.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2020-07-30 15:02:11 +02:00
|
|
|
#include "hw_cmds.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
#include <array>
|
2019-02-11 16:49:23 +01:00
|
|
|
#include <cstdio>
|
|
|
|
|
#include <cstring>
|
|
|
|
|
#include <memory>
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2018-02-05 08:54:46 +01:00
|
|
|
const DeviceDescriptor deviceDescriptorTable[] = {
|
2022-01-26 16:25:28 +00:00
|
|
|
#define NAMEDDEVICE(devId, gt, devName) {devId, >::hwInfo, >::setupHardwareInfo, devName},
|
|
|
|
|
#define DEVICE(devId, gt) {devId, >::hwInfo, >::setupHardwareInfo, ""},
|
2019-01-23 12:22:15 +01:00
|
|
|
#include "devices.inl"
|
2017-12-21 00:45:38 +01:00
|
|
|
#undef DEVICE
|
2020-11-09 17:35:33 +00:00
|
|
|
#undef NAMEDDEVICE
|
2024-03-10 21:30:08 +00:00
|
|
|
{0, nullptr, nullptr, ""}};
|
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) {
|
2024-09-12 12:02:13 +00:00
|
|
|
std::unique_ptr<Drm> drm{new Drm(std::move(hwDeviceId), rootDeviceEnvironment)};
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2022-08-08 19:04:04 +00:00
|
|
|
if (!drm->queryDeviceIdAndRevision()) {
|
2022-01-31 17:43:42 +00:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
2024-07-03 11:44:23 +00:00
|
|
|
|
|
|
|
|
const auto usDeviceID = rootDeviceEnvironment.getHardwareInfo()->platform.usDeviceID;
|
|
|
|
|
const auto usRevId = rootDeviceEnvironment.getHardwareInfo()->platform.usRevId;
|
|
|
|
|
if (!DeviceFactory::isAllowedDeviceId(usDeviceID, debugManager.flags.FilterDeviceId.get())) {
|
2017-12-21 00:45:38 +01:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-08 19:04:04 +00:00
|
|
|
const DeviceDescriptor *deviceDescriptor = nullptr;
|
|
|
|
|
for (auto &deviceDescriptorEntry : deviceDescriptorTable) {
|
2024-07-03 11:44:23 +00:00
|
|
|
if (usDeviceID == deviceDescriptorEntry.deviceId) {
|
2022-08-08 19:04:04 +00:00
|
|
|
deviceDescriptor = &deviceDescriptorEntry;
|
2017-12-21 00:45:38 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-03 10:34:24 +00:00
|
|
|
if (!deviceDescriptor) {
|
2023-11-30 08:32:25 +00:00
|
|
|
printDebugString(debugManager.flags.PrintDebugMessages.get(), stderr,
|
2024-07-03 11:44:23 +00:00
|
|
|
"FATAL: Unknown device: deviceId: %04x, revisionId: %04x\n", usDeviceID, usRevId);
|
2017-12-21 00:45:38 +01:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-03 10:34:24 +00:00
|
|
|
if (drm->setupHardwareInfo(deviceDescriptor, true)) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (drm->enableTurboBoost()) {
|
2023-11-30 08:32:25 +00:00
|
|
|
printDebugString(debugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Failed to request OCL Turbo Boost\n");
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
2022-08-08 19:04:04 +00:00
|
|
|
drm->checkContextDebugSupport();
|
2021-01-25 20:43:48 +00:00
|
|
|
|
2022-08-08 19:04:04 +00:00
|
|
|
drm->queryPageFaultSupport();
|
2024-07-17 15:24:49 +00:00
|
|
|
auto &compilerProductHelper = rootDeviceEnvironment.getHelper<CompilerProductHelper>();
|
|
|
|
|
if (rootDeviceEnvironment.executionEnvironment.isDebuggingEnabled() && !compilerProductHelper.isHeaplessModeEnabled()) {
|
2023-12-12 11:37:31 +00:00
|
|
|
if (drm->getRootDeviceEnvironment().executionEnvironment.getDebuggingMode() == DebuggingMode::offline) {
|
2023-04-12 10:03:29 +00:00
|
|
|
drm->setPerContextVMRequired(false);
|
2020-11-23 14:31:20 +00:00
|
|
|
} else {
|
2023-04-12 10:03:29 +00:00
|
|
|
if (drm->isVmBindAvailable()) {
|
|
|
|
|
drm->setPerContextVMRequired(true);
|
|
|
|
|
} else {
|
2023-11-30 08:32:25 +00:00
|
|
|
printDebugString(debugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Debugging not supported\n");
|
2023-04-12 10:03:29 +00:00
|
|
|
}
|
2020-11-23 14:31:20 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-20 07:07:59 +00:00
|
|
|
drm->isSetPairAvailable();
|
2023-03-08 04:06:00 +00:00
|
|
|
drm->isChunkingAvailable();
|
2022-09-20 07:07:59 +00:00
|
|
|
|
2024-06-06 16:26:42 +00:00
|
|
|
drm->configureScratchPagePolicy();
|
|
|
|
|
drm->configureGpuFaultCheckThreshold();
|
|
|
|
|
|
2022-08-08 19:04:04 +00:00
|
|
|
if (!drm->isPerContextVMRequired()) {
|
2023-10-26 15:04:39 +02:00
|
|
|
if (!drm->createVirtualMemoryAddressSpace(GfxCoreHelper::getSubDevicesCount(rootDeviceEnvironment.getHardwareInfo()))) {
|
2023-11-30 08:32:25 +00:00
|
|
|
printDebugString(debugManager.flags.PrintDebugMessages.get(), stderr, "%s", "INFO: Device doesn't support GEM Virtual Memory\n");
|
2020-07-15 08:07:53 +02:00
|
|
|
}
|
2020-07-14 04:36:16 +02:00
|
|
|
}
|
2021-05-31 16:58:10 +00:00
|
|
|
|
2022-08-08 19:04:04 +00:00
|
|
|
drm->queryAdapterBDF();
|
2021-05-31 16:58:10 +00:00
|
|
|
|
2022-08-08 19:04:04 +00:00
|
|
|
return drm.release();
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
2020-09-17 14:56:32 +02:00
|
|
|
|
|
|
|
|
void Drm::overrideBindSupport(bool &useVmBind) {
|
2023-11-30 08:32:25 +00:00
|
|
|
if (debugManager.flags.UseVmBind.get() != -1) {
|
|
|
|
|
useVmBind = debugManager.flags.UseVmBind.get();
|
2020-09-17 14:56:32 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|