2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2020-01-21 15:24:52 +01:00
|
|
|
* Copyright (C) 2017-2020 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"
|
|
|
|
|
#include "shared/source/helpers/hw_cmds.h"
|
|
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
|
|
|
|
#include "shared/source/helpers/hw_info.h"
|
|
|
|
|
#include "shared/source/os_interface/linux/drm_neo.h"
|
|
|
|
|
#include "shared/source/os_interface/linux/drm_null_device.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
#include "drm/i915_drm.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[] = {
|
2018-08-27 12:11:07 +02:00
|
|
|
#define DEVICE(devId, gt, gtType) {devId, >::hwInfo, >::setupHardwareInfo, gtType},
|
2019-01-23 12:22:15 +01:00
|
|
|
#include "devices.inl"
|
2017-12-21 00:45:38 +01:00
|
|
|
#undef DEVICE
|
|
|
|
|
{0, nullptr, nullptr, GTTYPE_UNDEFINED}};
|
|
|
|
|
|
2020-02-07 14:32:02 +01:00
|
|
|
Drm *Drm::create(std::unique_ptr<HwDeviceId> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) {
|
2019-02-11 16:49:23 +01:00
|
|
|
std::unique_ptr<Drm> drmObject;
|
2017-12-21 00:45:38 +01:00
|
|
|
if (DebugManager.flags.EnableNullHardware.get() == true) {
|
2020-02-07 14:32:02 +01:00
|
|
|
drmObject.reset(new DrmNullDevice(std::move(hwDeviceId), rootDeviceEnvironment));
|
2017-12-21 00:45:38 +01:00
|
|
|
} else {
|
2020-02-07 14:32:02 +01:00
|
|
|
drmObject.reset(new Drm(std::move(hwDeviceId), rootDeviceEnvironment));
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get HW version (I915_drm.h)
|
|
|
|
|
int ret = drmObject->getDeviceID(drmObject->deviceId);
|
|
|
|
|
if (ret != 0) {
|
|
|
|
|
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query device ID parameter!\n");
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get HW Revision (I915_drm.h)
|
|
|
|
|
ret = drmObject->getDeviceRevID(drmObject->revisionId);
|
|
|
|
|
if (ret != 0) {
|
|
|
|
|
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query device Rev ID parameter!\n");
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const DeviceDescriptor *device = nullptr;
|
|
|
|
|
GTTYPE eGtType = GTTYPE_UNDEFINED;
|
2018-02-05 08:54:46 +01:00
|
|
|
for (auto &d : deviceDescriptorTable) {
|
2017-12-21 00:45:38 +01:00
|
|
|
if (drmObject->deviceId == d.deviceId) {
|
|
|
|
|
device = &d;
|
|
|
|
|
eGtType = d.eGtType;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (device) {
|
2019-10-18 10:15:09 +02:00
|
|
|
ret = drmObject->setupHardwareInfo(const_cast<DeviceDescriptor *>(device), true);
|
|
|
|
|
if (ret != 0) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
2017-12-21 00:45:38 +01:00
|
|
|
drmObject->setGtType(eGtType);
|
2020-01-30 15:04:19 +01:00
|
|
|
rootDeviceEnvironment.executionEnvironment.setHwInfo(device->pHwInfo);
|
2017-12-21 00:45:38 +01:00
|
|
|
} else {
|
2018-11-21 22:32:00 +01:00
|
|
|
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr,
|
2018-08-27 12:11:07 +02:00
|
|
|
"FATAL: Unknown device: deviceId: %04x, revisionId: %04x\n", drmObject->deviceId, drmObject->revisionId);
|
2017-12-21 00:45:38 +01:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Detect device parameters
|
|
|
|
|
int hasExecSoftPin = 0;
|
|
|
|
|
ret = drmObject->getExecSoftPin(hasExecSoftPin);
|
|
|
|
|
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
|
|
|
|
|
ret = drmObject->enableTurboBoost();
|
|
|
|
|
if (ret != 0) {
|
|
|
|
|
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Failed to request OCL Turbo Boost\n");
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-08 18:49:54 +01:00
|
|
|
if (!drmObject->queryEngineInfo()) {
|
|
|
|
|
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Failed to query engine info\n");
|
2019-10-10 16:01:54 +02:00
|
|
|
}
|
|
|
|
|
|
2019-05-08 16:00:24 +02:00
|
|
|
if (HwHelper::get(device->pHwInfo->platform.eRenderCoreFamily).getEnableLocalMemory(*device->pHwInfo)) {
|
2019-11-08 18:49:54 +01:00
|
|
|
if (!drmObject->queryMemoryInfo()) {
|
|
|
|
|
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Failed to query memory info\n");
|
2019-10-15 10:23:04 +02:00
|
|
|
}
|
2019-03-26 16:31:08 +01:00
|
|
|
}
|
2019-03-19 13:53:55 +01:00
|
|
|
|
2020-02-11 17:48:40 +01:00
|
|
|
return drmObject.release();
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|