mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Remove redundant device and revision id members from Drm class
Drm should set these values directly to hw info in root device environment Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
0225423e94
commit
6450be2414
@ -32,46 +32,46 @@ const DeviceDescriptor deviceDescriptorTable[] = {
|
||||
{0, nullptr, nullptr}};
|
||||
|
||||
Drm *Drm::create(std::unique_ptr<HwDeviceIdDrm> &&hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) {
|
||||
std::unique_ptr<Drm> drmObject;
|
||||
std::unique_ptr<Drm> drm;
|
||||
if (DebugManager.flags.EnableNullHardware.get() == true) {
|
||||
drmObject.reset(new DrmNullDevice(std::move(hwDeviceId), rootDeviceEnvironment));
|
||||
drm.reset(new DrmNullDevice(std::move(hwDeviceId), rootDeviceEnvironment));
|
||||
} else {
|
||||
drmObject.reset(new Drm(std::move(hwDeviceId), rootDeviceEnvironment));
|
||||
drm.reset(new Drm(std::move(hwDeviceId), rootDeviceEnvironment));
|
||||
}
|
||||
|
||||
if (!drmObject->queryDeviceIdAndRevision()) {
|
||||
if (!drm->queryDeviceIdAndRevision()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto hwInfo = rootDeviceEnvironment.getMutableHardwareInfo();
|
||||
if (!DeviceFactory::isAllowedDeviceId(hwInfo->platform.usDeviceID, DebugManager.flags.FilterDeviceId.get())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!DeviceFactory::isAllowedDeviceId(drmObject->deviceId, DebugManager.flags.FilterDeviceId.get())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const DeviceDescriptor *device = nullptr;
|
||||
const char *devName = "";
|
||||
for (auto &d : deviceDescriptorTable) {
|
||||
if (drmObject->deviceId == d.deviceId) {
|
||||
device = &d;
|
||||
devName = d.devName;
|
||||
const DeviceDescriptor *deviceDescriptor = nullptr;
|
||||
const char *deviceName = "";
|
||||
for (auto &deviceDescriptorEntry : deviceDescriptorTable) {
|
||||
if (hwInfo->platform.usDeviceID == deviceDescriptorEntry.deviceId) {
|
||||
deviceDescriptor = &deviceDescriptorEntry;
|
||||
deviceName = deviceDescriptorEntry.devName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int ret = 0;
|
||||
if (device) {
|
||||
ret = drmObject->setupHardwareInfo(device, true);
|
||||
if (deviceDescriptor) {
|
||||
ret = drm->setupHardwareInfo(deviceDescriptor, true);
|
||||
if (ret != 0) {
|
||||
return nullptr;
|
||||
}
|
||||
rootDeviceEnvironment.getMutableHardwareInfo()->capabilityTable.deviceName = devName;
|
||||
hwInfo->capabilityTable.deviceName = deviceName;
|
||||
} else {
|
||||
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr,
|
||||
"FATAL: Unknown device: deviceId: %04x, revisionId: %04x\n", drmObject->deviceId, drmObject->revisionId);
|
||||
"FATAL: Unknown device: deviceId: %04x, revisionId: %04x\n", hwInfo->platform.usDeviceID, hwInfo->platform.usRevId);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Detect device parameters
|
||||
int hasExecSoftPin = 0;
|
||||
ret = drmObject->getExecSoftPin(hasExecSoftPin);
|
||||
ret = drm->getExecSoftPin(hasExecSoftPin);
|
||||
if (ret != 0) {
|
||||
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query Soft Pin parameter!\n");
|
||||
return nullptr;
|
||||
@ -84,42 +84,42 @@ Drm *Drm::create(std::unique_ptr<HwDeviceIdDrm> &&hwDeviceId, RootDeviceEnvironm
|
||||
}
|
||||
|
||||
// Activate the Turbo Boost Frequency feature
|
||||
ret = drmObject->enableTurboBoost();
|
||||
ret = drm->enableTurboBoost();
|
||||
if (ret != 0) {
|
||||
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Failed to request OCL Turbo Boost\n");
|
||||
}
|
||||
|
||||
if (!drmObject->queryMemoryInfo()) {
|
||||
drmObject->setPerContextVMRequired(true);
|
||||
if (!drm->queryMemoryInfo()) {
|
||||
drm->setPerContextVMRequired(true);
|
||||
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Failed to query memory info\n");
|
||||
}
|
||||
|
||||
if (!drmObject->queryEngineInfo()) {
|
||||
drmObject->setPerContextVMRequired(true);
|
||||
if (!drm->queryEngineInfo()) {
|
||||
drm->setPerContextVMRequired(true);
|
||||
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Failed to query engine info\n");
|
||||
}
|
||||
|
||||
drmObject->checkContextDebugSupport();
|
||||
drm->checkContextDebugSupport();
|
||||
|
||||
drmObject->queryPageFaultSupport();
|
||||
drm->queryPageFaultSupport();
|
||||
|
||||
if (rootDeviceEnvironment.executionEnvironment.isDebuggingEnabled()) {
|
||||
if (drmObject->isVmBindAvailable()) {
|
||||
drmObject->setPerContextVMRequired(true);
|
||||
if (drm->isVmBindAvailable()) {
|
||||
drm->setPerContextVMRequired(true);
|
||||
} else {
|
||||
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Debugging not supported\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (!drmObject->isPerContextVMRequired()) {
|
||||
if (!drmObject->createVirtualMemoryAddressSpace(HwHelper::getSubDevicesCount(rootDeviceEnvironment.getHardwareInfo()))) {
|
||||
if (!drm->isPerContextVMRequired()) {
|
||||
if (!drm->createVirtualMemoryAddressSpace(HwHelper::getSubDevicesCount(rootDeviceEnvironment.getHardwareInfo()))) {
|
||||
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "INFO: Device doesn't support GEM Virtual Memory\n");
|
||||
}
|
||||
}
|
||||
|
||||
drmObject->queryAdapterBDF();
|
||||
drm->queryAdapterBDF();
|
||||
|
||||
return drmObject.release();
|
||||
return drm.release();
|
||||
}
|
||||
|
||||
void Drm::overrideBindSupport(bool &useVmBind) {
|
||||
|
@ -133,16 +133,21 @@ int Drm::getExecSoftPin(int &execSoftPin) {
|
||||
}
|
||||
|
||||
bool Drm::queryI915DeviceIdAndRevision() {
|
||||
auto ret = getParamIoctl(DrmParam::ParamChipsetId, &this->deviceId);
|
||||
HardwareInfo *hwInfo = rootDeviceEnvironment.getMutableHardwareInfo();
|
||||
int deviceId = hwInfo->platform.usDeviceID;
|
||||
int revisionId = hwInfo->platform.usRevId;
|
||||
auto ret = getParamIoctl(DrmParam::ParamChipsetId, &deviceId);
|
||||
if (ret != 0) {
|
||||
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query device ID parameter!\n");
|
||||
return false;
|
||||
}
|
||||
ret = getParamIoctl(DrmParam::ParamRevision, &this->revisionId);
|
||||
ret = getParamIoctl(DrmParam::ParamRevision, &revisionId);
|
||||
if (ret != 0) {
|
||||
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query device Rev ID parameter!\n");
|
||||
return false;
|
||||
}
|
||||
hwInfo->platform.usDeviceID = deviceId;
|
||||
hwInfo->platform.usRevId = revisionId;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -390,12 +395,14 @@ int Drm::getErrno() {
|
||||
}
|
||||
|
||||
int Drm::setupHardwareInfo(const DeviceDescriptor *device, bool setupFeatureTableAndWorkaroundTable) {
|
||||
rootDeviceEnvironment.setHwInfo(device->pHwInfo);
|
||||
HardwareInfo *hwInfo = rootDeviceEnvironment.getMutableHardwareInfo();
|
||||
int ret;
|
||||
auto deviceId = hwInfo->platform.usDeviceID;
|
||||
auto revisionId = hwInfo->platform.usRevId;
|
||||
|
||||
hwInfo->platform.usDeviceID = this->deviceId;
|
||||
hwInfo->platform.usRevId = this->revisionId;
|
||||
rootDeviceEnvironment.setHwInfo(device->pHwInfo);
|
||||
|
||||
hwInfo->platform.usDeviceID = deviceId;
|
||||
hwInfo->platform.usRevId = revisionId;
|
||||
|
||||
const auto productFamily = hwInfo->platform.eProductFamily;
|
||||
setupIoctlHelper(productFamily);
|
||||
@ -407,7 +414,7 @@ int Drm::setupHardwareInfo(const DeviceDescriptor *device, bool setupFeatureTabl
|
||||
if (!status) {
|
||||
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Topology query failed!\n");
|
||||
|
||||
ret = getEuTotal(topologyData.euCount);
|
||||
auto ret = getEuTotal(topologyData.euCount);
|
||||
if (ret != 0) {
|
||||
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query EU total parameter!\n");
|
||||
return ret;
|
||||
|
@ -330,9 +330,6 @@ class Drm : public DriverModel {
|
||||
RootDeviceEnvironment &rootDeviceEnvironment;
|
||||
uint64_t uuid = 0;
|
||||
|
||||
int deviceId = 0;
|
||||
int revisionId = 0;
|
||||
|
||||
bool sliceCountChangeSupported = false;
|
||||
bool preemptionSupported = false;
|
||||
bool nonPersistentContextsSupported = false;
|
||||
|
@ -32,7 +32,6 @@ class DrmMock : public Drm {
|
||||
using Drm::classHandles;
|
||||
using Drm::completionFenceSupported;
|
||||
using Drm::contextDebugSupported;
|
||||
using Drm::deviceId;
|
||||
using Drm::engineInfo;
|
||||
using Drm::fenceVal;
|
||||
using Drm::generateElfUUID;
|
||||
@ -48,7 +47,6 @@ class DrmMock : public Drm {
|
||||
using Drm::queryAndSetVmBindPatIndexProgrammingSupport;
|
||||
using Drm::queryDeviceIdAndRevision;
|
||||
using Drm::requirePerContextVM;
|
||||
using Drm::revisionId;
|
||||
using Drm::setupIoctlHelper;
|
||||
using Drm::sliceCountChangeSupported;
|
||||
using Drm::systemInfo;
|
||||
|
@ -281,20 +281,21 @@ TEST(DrmTest, givenSysfsNodeReadFailsWithImproperDataWhenGetDeviceMemoryMaxClock
|
||||
TEST(DrmTest, WhenGettingRevisionIdThenCorrectIdIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
DrmMock *pDrm = new DrmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto pDrm = std::make_unique<DrmMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
EXPECT_NE(nullptr, pDrm);
|
||||
|
||||
auto hwInfo = pDrm->getRootDeviceEnvironment().getMutableHardwareInfo();
|
||||
|
||||
pDrm->storedDeviceID = 0x1234;
|
||||
pDrm->storedDeviceRevID = 0xB;
|
||||
pDrm->deviceId = 0;
|
||||
pDrm->revisionId = 0;
|
||||
|
||||
hwInfo->platform.usDeviceID = 0;
|
||||
hwInfo->platform.usRevId = 0;
|
||||
|
||||
EXPECT_TRUE(pDrm->queryDeviceIdAndRevision());
|
||||
|
||||
EXPECT_EQ(pDrm->storedDeviceID, pDrm->deviceId);
|
||||
EXPECT_EQ(pDrm->storedDeviceRevID, pDrm->revisionId);
|
||||
|
||||
delete pDrm;
|
||||
EXPECT_EQ(pDrm->storedDeviceID, hwInfo->platform.usDeviceID);
|
||||
EXPECT_EQ(pDrm->storedDeviceRevID, hwInfo->platform.usRevId);
|
||||
}
|
||||
|
||||
TEST(DrmTest, GivenDrmWhenAskedForGttSizeThenReturnCorrectValue) {
|
||||
|
Reference in New Issue
Block a user