2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2020-01-21 22:24:52 +08:00
|
|
|
* Copyright (C) 2017-2020 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"
|
|
|
|
#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 18:39:32 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "drm/i915_drm.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[] = {
|
2018-08-27 18:11:07 +08:00
|
|
|
#define DEVICE(devId, gt, gtType) {devId, >::hwInfo, >::setupHardwareInfo, gtType},
|
2019-01-23 19:22:15 +08:00
|
|
|
#include "devices.inl"
|
2017-12-21 07:45:38 +08:00
|
|
|
#undef DEVICE
|
|
|
|
{0, nullptr, nullptr, GTTYPE_UNDEFINED}};
|
|
|
|
|
2020-02-07 21:32:02 +08:00
|
|
|
Drm *Drm::create(std::unique_ptr<HwDeviceId> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) {
|
2019-02-11 23:49:23 +08:00
|
|
|
std::unique_ptr<Drm> drmObject;
|
2017-12-21 07:45:38 +08:00
|
|
|
if (DebugManager.flags.EnableNullHardware.get() == true) {
|
2020-02-07 21:32:02 +08:00
|
|
|
drmObject.reset(new DrmNullDevice(std::move(hwDeviceId), rootDeviceEnvironment));
|
2017-12-21 07:45:38 +08:00
|
|
|
} else {
|
2020-02-07 21:32:02 +08:00
|
|
|
drmObject.reset(new Drm(std::move(hwDeviceId), rootDeviceEnvironment));
|
2017-12-21 07:45:38 +08: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 15:54:46 +08:00
|
|
|
for (auto &d : deviceDescriptorTable) {
|
2017-12-21 07:45:38 +08:00
|
|
|
if (drmObject->deviceId == d.deviceId) {
|
|
|
|
device = &d;
|
|
|
|
eGtType = d.eGtType;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (device) {
|
2019-10-18 16:15:09 +08:00
|
|
|
ret = drmObject->setupHardwareInfo(const_cast<DeviceDescriptor *>(device), true);
|
|
|
|
if (ret != 0) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
drmObject->setGtType(eGtType);
|
2020-03-04 15:51:02 +08:00
|
|
|
rootDeviceEnvironment.setHwInfo(device->pHwInfo);
|
2017-12-21 07:45:38 +08:00
|
|
|
} else {
|
2018-11-22 05:32:00 +08:00
|
|
|
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr,
|
2018-08-27 18:11:07 +08:00
|
|
|
"FATAL: Unknown device: deviceId: %04x, revisionId: %04x\n", drmObject->deviceId, drmObject->revisionId);
|
2017-12-21 07:45:38 +08: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 18:11:07 +08:00
|
|
|
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s",
|
|
|
|
"FATAL: Device doesn't support Soft-Pin but this is required.\n");
|
2017-12-21 07:45:38 +08: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-09 01:49:54 +08:00
|
|
|
if (!drmObject->queryEngineInfo()) {
|
|
|
|
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Failed to query engine info\n");
|
2019-10-10 22:01:54 +08:00
|
|
|
}
|
|
|
|
|
2019-05-08 22:00:24 +08:00
|
|
|
if (HwHelper::get(device->pHwInfo->platform.eRenderCoreFamily).getEnableLocalMemory(*device->pHwInfo)) {
|
2019-11-09 01:49:54 +08:00
|
|
|
if (!drmObject->queryMemoryInfo()) {
|
|
|
|
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Failed to query memory info\n");
|
2019-10-15 16:23:04 +08:00
|
|
|
}
|
2019-03-26 23:31:08 +08:00
|
|
|
}
|
2019-03-19 20:53:55 +08:00
|
|
|
|
2020-07-14 10:36:16 +08:00
|
|
|
if (!drmObject->createVirtualMemoryAddressSpace(HwHelper::getSubDevicesCount(rootDeviceEnvironment.getHardwareInfo()))) {
|
|
|
|
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "INFO: Device doesn't support GEM Virtual Memory\n");
|
|
|
|
}
|
2020-07-07 15:34:31 +08:00
|
|
|
|
2020-02-12 00:48:40 +08:00
|
|
|
return drmObject.release();
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|