2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2023-02-01 16:23:01 +00:00
|
|
|
* Copyright (C) 2018-2023 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"
|
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
|
2022-01-26 16:25:28 +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) {
|
2023-10-13 15:03:52 +00:00
|
|
|
auto drm = std::unique_ptr<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;
|
|
|
|
|
}
|
2022-08-08 19:04:04 +00:00
|
|
|
auto hwInfo = rootDeviceEnvironment.getMutableHardwareInfo();
|
|
|
|
|
if (!DeviceFactory::isAllowedDeviceId(hwInfo->platform.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;
|
|
|
|
|
const char *deviceName = "";
|
|
|
|
|
for (auto &deviceDescriptorEntry : deviceDescriptorTable) {
|
|
|
|
|
if (hwInfo->platform.usDeviceID == deviceDescriptorEntry.deviceId) {
|
|
|
|
|
deviceDescriptor = &deviceDescriptorEntry;
|
|
|
|
|
deviceName = deviceDescriptorEntry.devName;
|
2017-12-21 00:45:38 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-06-08 12:43:51 +00:00
|
|
|
int ret = 0;
|
2022-08-08 19:04:04 +00:00
|
|
|
if (deviceDescriptor) {
|
|
|
|
|
ret = drm->setupHardwareInfo(deviceDescriptor, true);
|
2019-10-18 10:15:09 +02:00
|
|
|
if (ret != 0) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
2022-08-08 19:04:04 +00:00
|
|
|
hwInfo->capabilityTable.deviceName = deviceName;
|
2017-12-21 00:45:38 +01:00
|
|
|
} else {
|
2018-11-21 22:32:00 +01:00
|
|
|
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr,
|
2022-08-08 19:04:04 +00:00
|
|
|
"FATAL: Unknown device: deviceId: %04x, revisionId: %04x\n", hwInfo->platform.usDeviceID, hwInfo->platform.usRevId);
|
2017-12-21 00:45:38 +01:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Detect device parameters
|
|
|
|
|
int hasExecSoftPin = 0;
|
2022-08-08 19:04:04 +00:00
|
|
|
ret = drm->getExecSoftPin(hasExecSoftPin);
|
2017-12-21 00:45:38 +01:00
|
|
|
if (ret != 0) {
|
|
|
|
|
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query Soft Pin parameter!\n");
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!hasExecSoftPin) {
|
2018-08-27 12:11:07 +02:00
|
|
|
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s",
|
|
|
|
|
"FATAL: Device doesn't support Soft-Pin but this is required.\n");
|
2017-12-21 00:45:38 +01:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Activate the Turbo Boost Frequency feature
|
2022-08-08 19:04:04 +00:00
|
|
|
ret = drm->enableTurboBoost();
|
2017-12-21 00:45:38 +01:00
|
|
|
if (ret != 0) {
|
|
|
|
|
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Failed to request OCL Turbo Boost\n");
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-08 19:04:04 +00:00
|
|
|
if (!drm->queryMemoryInfo()) {
|
|
|
|
|
drm->setPerContextVMRequired(true);
|
2021-04-09 13:46:28 +00:00
|
|
|
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Failed to query memory info\n");
|
2019-10-10 16:01:54 +02:00
|
|
|
}
|
|
|
|
|
|
2022-08-08 19:04:04 +00:00
|
|
|
if (!drm->queryEngineInfo()) {
|
|
|
|
|
drm->setPerContextVMRequired(true);
|
2021-04-09 13:46:28 +00:00
|
|
|
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Failed to query engine info\n");
|
2019-03-26 16:31:08 +01:00
|
|
|
}
|
2019-03-19 13:53:55 +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();
|
2021-11-11 22:11:38 +00:00
|
|
|
|
2020-11-23 14:31:20 +00:00
|
|
|
if (rootDeviceEnvironment.executionEnvironment.isDebuggingEnabled()) {
|
2023-04-12 10:03:29 +00:00
|
|
|
if (drm->getRootDeviceEnvironment().executionEnvironment.getDebuggingMode() == DebuggingMode::Offline) {
|
|
|
|
|
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 {
|
|
|
|
|
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Debugging not supported\n");
|
|
|
|
|
}
|
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
|
|
|
|
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()))) {
|
2020-07-15 08:07:53 +02:00
|
|
|
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "INFO: Device doesn't support GEM Virtual Memory\n");
|
|
|
|
|
}
|
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) {
|
|
|
|
|
if (DebugManager.flags.UseVmBind.get() != -1) {
|
|
|
|
|
useVmBind = DebugManager.flags.UseVmBind.get();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|