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