Skip to content

Commit 70cf43f

Browse files
Remove redundant query for device id and revision
Related-To: NEO-6999 Signed-off-by: Mateusz Jablonski <[email protected]>
1 parent 5bee8eb commit 70cf43f

28 files changed

+201
-525
lines changed

opencl/test/unit_test/linux/main_linux_dll.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,18 +544,32 @@ TEST_F(DrmTests, GivenUnknownDeviceWhenCreatingDrmThenNullIsReturned) {
544544
DebugManager.flags.PrintDebugMessages.set(true);
545545

546546
VariableBackup<decltype(deviceId)> backupDeviceId(&deviceId);
547+
VariableBackup<decltype(revisionId)> backupRevisionId(&revisionId);
547548

548549
deviceId = -1;
550+
revisionId = -1;
549551

550552
::testing::internal::CaptureStderr();
551553
::testing::internal::CaptureStdout();
552554
auto drm = DrmWrap::createDrm(*rootDeviceEnvironment);
553555
EXPECT_EQ(drm, nullptr);
554556
std::string errStr = ::testing::internal::GetCapturedStderr();
555-
EXPECT_TRUE(hasSubstr(errStr, std::string("FATAL: Unknown device: deviceId: ffffffff, revisionId: 0000")));
557+
EXPECT_TRUE(hasSubstr(errStr, std::string("FATAL: Unknown device: deviceId: ffffffff, revisionId: ffff")));
556558
::testing::internal::GetCapturedStdout();
557559
}
558560

561+
TEST_F(DrmTests, GivenKnownDeviceWhenCreatingDrmThenHwInfoIsProperlySet) {
562+
VariableBackup<decltype(revisionId)> backupRevisionId(&revisionId);
563+
564+
revisionId = 123;
565+
566+
auto drm = DrmWrap::createDrm(*rootDeviceEnvironment);
567+
EXPECT_NE(drm, nullptr);
568+
569+
EXPECT_EQ(revisionId, rootDeviceEnvironment->getHardwareInfo()->platform.usRevId);
570+
EXPECT_EQ(deviceId, rootDeviceEnvironment->getHardwareInfo()->platform.usDeviceID);
571+
}
572+
559573
TEST_F(DrmTests, GivenNoSoftPinWhenCreatingDrmThenNullIsReturned) {
560574
VariableBackup<decltype(haveSoftPin)> backupHaveSoftPin(&haveSoftPin);
561575
haveSoftPin = 0;

opencl/test/unit_test/linux/mock_os_layer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ int (*openFull)(const char *pathname, int flags, ...) = nullptr;
2222
int fakeFd = 1023;
2323
int haveDri = 0; // index of dri to serve, -1 - none
2424
int deviceId = NEO::deviceDescriptorTable[0].deviceId; // default supported DeviceID
25+
int revisionId = 17;
2526
int haveSoftPin = 1;
2627
int havePreemption = I915_SCHEDULER_CAP_ENABLED |
2728
I915_SCHEDULER_CAP_PRIORITY |
@@ -150,7 +151,7 @@ int drmGetParam(NEO::GetParam *param) {
150151
ret = failOnSubsliceTotal;
151152
break;
152153
case I915_PARAM_REVISION:
153-
*param->value = 0x0;
154+
*param->value = revisionId;
154155
ret = failOnRevisionId;
155156
break;
156157
case I915_PARAM_HAS_EXEC_SOFTPIN:

opencl/test/unit_test/linux/mock_os_layer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ extern int drmOtherRequests(unsigned long int request, ...);
2727
extern int fakeFd;
2828
extern int haveDri; // index of dri to serve, -1 - none
2929
extern int deviceId; // known DeviceID
30+
extern int revisionId;
3031
extern int haveSoftPin;
3132
extern int vmId;
3233
extern int failOnDeviceId;

shared/source/dll/linux/drm_neo_create.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,10 @@ Drm *Drm::create(std::unique_ptr<HwDeviceIdDrm> &&hwDeviceId, RootDeviceEnvironm
6666
}
6767
}
6868
if (device) {
69-
ret = drmObject->setupHardwareInfo(const_cast<DeviceDescriptor *>(device), true);
69+
ret = drmObject->setupHardwareInfo(device, true);
7070
if (ret != 0) {
7171
return nullptr;
7272
}
73-
rootDeviceEnvironment.setHwInfo(device->pHwInfo);
7473
rootDeviceEnvironment.getMutableHardwareInfo()->capabilityTable.deviceName = devName;
7574
} else {
7675
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr,

shared/source/os_interface/linux/drm_neo.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,14 @@ int Drm::getErrno() {
358358
return errno;
359359
}
360360

361-
int Drm::setupHardwareInfo(DeviceDescriptor *device, bool setupFeatureTableAndWorkaroundTable) {
362-
HardwareInfo *hwInfo = const_cast<HardwareInfo *>(device->pHwInfo);
361+
int Drm::setupHardwareInfo(const DeviceDescriptor *device, bool setupFeatureTableAndWorkaroundTable) {
362+
rootDeviceEnvironment.setHwInfo(device->pHwInfo);
363+
HardwareInfo *hwInfo = rootDeviceEnvironment.getMutableHardwareInfo();
363364
int ret;
364365

366+
hwInfo->platform.usDeviceID = this->deviceId;
367+
hwInfo->platform.usRevId = this->revisionId;
368+
365369
const auto productFamily = hwInfo->platform.eProductFamily;
366370
setupIoctlHelper(productFamily);
367371

@@ -389,7 +393,6 @@ int Drm::setupHardwareInfo(DeviceDescriptor *device, bool setupFeatureTableAndWo
389393
hwInfo->gtSystemInfo.SubSliceCount = static_cast<uint32_t>(topologyData.subSliceCount);
390394
hwInfo->gtSystemInfo.DualSubSliceCount = static_cast<uint32_t>(topologyData.subSliceCount);
391395
hwInfo->gtSystemInfo.EUCount = static_cast<uint32_t>(topologyData.euCount);
392-
rootDeviceEnvironment.setHwInfo(hwInfo);
393396

394397
status = querySystemInfo();
395398
if (status) {

shared/source/os_interface/linux/drm_neo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class Drm : public DriverModel {
131131
uint32_t getVirtualMemoryAddressSpace(uint32_t vmId);
132132
MOCKABLE_VIRTUAL int bindBufferObject(OsContext *osContext, uint32_t vmHandleId, BufferObject *bo);
133133
MOCKABLE_VIRTUAL int unbindBufferObject(OsContext *osContext, uint32_t vmHandleId, BufferObject *bo);
134-
int setupHardwareInfo(DeviceDescriptor *, bool);
134+
int setupHardwareInfo(const DeviceDescriptor *, bool);
135135
void setupSystemInfo(HardwareInfo *hwInfo, SystemInfo *sysInfo);
136136
void setupCacheInfo(const HardwareInfo &hwInfo);
137137
MOCKABLE_VIRTUAL void getPrelimVersion(std::string &prelimVersion);

shared/source/os_interface/linux/hw_info_config_drm.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,6 @@ int HwInfoConfig::configureHwInfoDrm(const HardwareInfo *inHwInfo, HardwareInfo
7474
auto gtSystemInfo = &outHwInfo->gtSystemInfo;
7575
auto featureTable = &outHwInfo->featureTable;
7676

77-
int val = 0;
78-
ret = drm->getDeviceID(val);
79-
if (ret != 0 || val == 0) {
80-
*outHwInfo = {};
81-
return (ret == 0) ? -1 : ret;
82-
}
83-
platform->usDeviceID = static_cast<unsigned short>(val);
84-
ret = drm->getDeviceRevID(val);
85-
if (ret != 0) {
86-
*outHwInfo = {};
87-
return ret;
88-
}
89-
platform->usRevId = static_cast<unsigned short>(val);
90-
9177
Drm::QueryTopologyData topologyData = {};
9278

9379
bool status = drm->queryTopology(*outHwInfo, topologyData);

shared/test/common/libult/linux/drm_mock.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ int DrmMock::ioctl(DrmIoctl request, void *arg) {
243243
auto queryItemArg = reinterpret_cast<QueryItem *>(queryArg->itemsPtr);
244244
storedQueryItem = *queryItemArg;
245245

246-
auto realEuCount = rootDeviceEnvironment.getHardwareInfo()->gtSystemInfo.EUCount;
246+
auto realEuCount = std::max(rootDeviceEnvironment.getHardwareInfo()->gtSystemInfo.EUCount, static_cast<uint32_t>(this->storedEUVal));
247247
auto dataSize = static_cast<size_t>(std::ceil(realEuCount / 8.0));
248248

249249
if (queryItemArg->length == 0) {

shared/test/unit_test/gen11/ehl/linux/hw_info_config_tests_ehl.cpp

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ struct HwInfoConfigTestLinuxEhl : HwInfoConfigTestLinux {
1414
void SetUp() override {
1515
HwInfoConfigTestLinux::SetUp();
1616

17-
drm->storedDeviceID = IEHL_1x4x8_SUPERSKU_DEVICE_A0_ID;
18-
1917
drm->storedSSVal = 8;
2018
}
2119
};
@@ -24,8 +22,6 @@ EHLTEST_F(HwInfoConfigTestLinuxEhl, GivenEhlThenHwInfoIsCorrect) {
2422
auto hwInfoConfig = HwInfoConfigHw<IGFX_ELKHARTLAKE>::get();
2523
int ret = hwInfoConfig->configureHwInfoDrm(&pInHwInfo, &outHwInfo, osInterface);
2624
EXPECT_EQ(0, ret);
27-
EXPECT_EQ((unsigned short)drm->storedDeviceID, outHwInfo.platform.usDeviceID);
28-
EXPECT_EQ((unsigned short)drm->storedDeviceRevID, outHwInfo.platform.usRevId);
2925
EXPECT_EQ((uint32_t)drm->storedEUVal, outHwInfo.gtSystemInfo.EUCount);
3026
EXPECT_EQ((uint32_t)drm->storedSSVal, outHwInfo.gtSystemInfo.SubSliceCount);
3127
EXPECT_EQ(1u, outHwInfo.gtSystemInfo.SliceCount);
@@ -34,19 +30,9 @@ EHLTEST_F(HwInfoConfigTestLinuxEhl, GivenEhlThenHwInfoIsCorrect) {
3430
EHLTEST_F(HwInfoConfigTestLinuxEhl, GivenInvalidDeviceIdWhenConfiguringHwInfoThenNegativeOneReturned) {
3531
auto hwInfoConfig = HwInfoConfigHw<IGFX_ELKHARTLAKE>::get();
3632

37-
drm->storedRetValForDeviceID = -1;
38-
int ret = hwInfoConfig->configureHwInfoDrm(&pInHwInfo, &outHwInfo, osInterface);
39-
EXPECT_EQ(-1, ret);
40-
41-
drm->storedRetValForDeviceID = 0;
42-
drm->storedRetValForDeviceRevID = -1;
43-
ret = hwInfoConfig->configureHwInfoDrm(&pInHwInfo, &outHwInfo, osInterface);
44-
EXPECT_EQ(-1, ret);
45-
46-
drm->storedRetValForDeviceRevID = 0;
4733
drm->failRetTopology = true;
4834
drm->storedRetValForEUVal = -1;
49-
ret = hwInfoConfig->configureHwInfoDrm(&pInHwInfo, &outHwInfo, osInterface);
35+
auto ret = hwInfoConfig->configureHwInfoDrm(&pInHwInfo, &outHwInfo, osInterface);
5036
EXPECT_EQ(-1, ret);
5137

5238
drm->storedRetValForEUVal = 0;
@@ -63,11 +49,12 @@ TEST(EhlHwInfoTests, WhenGtIsSetupThenGtSystemInfoIsCorrect) {
6349
executionEnvironment->prepareRootDeviceEnvironments(1);
6450
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
6551
DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
66-
GT_SYSTEM_INFO &gtSystemInfo = hwInfo.gtSystemInfo;
6752
DeviceDescriptor device = {0, &hwInfo, &EHL_HW_CONFIG::setupHardwareInfo};
6853

6954
int ret = drm.setupHardwareInfo(&device, false);
7055

56+
const auto &gtSystemInfo = executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->gtSystemInfo;
57+
7158
EXPECT_EQ(ret, 0);
7259
EXPECT_GT(gtSystemInfo.EUCount, 0u);
7360
EXPECT_GT(gtSystemInfo.ThreadCount, 0u);

shared/test/unit_test/gen11/icllp/linux/hw_info_config_tests_icllp.cpp

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,13 @@ using namespace NEO;
1313
struct HwInfoConfigTestLinuxIcllp : HwInfoConfigTestLinux {
1414
void SetUp() override {
1515
HwInfoConfigTestLinux::SetUp();
16-
17-
drm->storedDeviceID = IICL_LP_GT1_MOB_DEVICE_F0_ID;
1816
}
1917
};
2018

2119
ICLLPTEST_F(HwInfoConfigTestLinuxIcllp, GivenIcllpThenHwInfoIsCorrect) {
2220
auto hwInfoConfig = HwInfoConfig::get(productFamily);
2321
int ret = hwInfoConfig->configureHwInfoDrm(&pInHwInfo, &outHwInfo, osInterface);
2422
EXPECT_EQ(0, ret);
25-
EXPECT_EQ((unsigned short)drm->storedDeviceID, outHwInfo.platform.usDeviceID);
26-
EXPECT_EQ((unsigned short)drm->storedDeviceRevID, outHwInfo.platform.usRevId);
2723
EXPECT_EQ((uint32_t)drm->storedEUVal, outHwInfo.gtSystemInfo.EUCount);
2824
EXPECT_EQ((uint32_t)drm->storedSSVal, outHwInfo.gtSystemInfo.SubSliceCount);
2925
EXPECT_EQ(1u, outHwInfo.gtSystemInfo.SliceCount);
@@ -35,19 +31,9 @@ ICLLPTEST_F(HwInfoConfigTestLinuxIcllp, GivenIcllpThenHwInfoIsCorrect) {
3531
ICLLPTEST_F(HwInfoConfigTestLinuxIcllp, GivenInvalidDeviceIdWhenConfiguringHwInfoThenNegativeOneReturned) {
3632
auto hwInfoConfig = HwInfoConfig::get(productFamily);
3733

38-
drm->storedRetValForDeviceID = -1;
39-
int ret = hwInfoConfig->configureHwInfoDrm(&pInHwInfo, &outHwInfo, osInterface);
40-
EXPECT_EQ(-1, ret);
41-
42-
drm->storedRetValForDeviceID = 0;
43-
drm->storedRetValForDeviceRevID = -1;
44-
ret = hwInfoConfig->configureHwInfoDrm(&pInHwInfo, &outHwInfo, osInterface);
45-
EXPECT_EQ(-1, ret);
46-
47-
drm->storedRetValForDeviceRevID = 0;
4834
drm->failRetTopology = true;
4935
drm->storedRetValForEUVal = -1;
50-
ret = hwInfoConfig->configureHwInfoDrm(&pInHwInfo, &outHwInfo, osInterface);
36+
auto ret = hwInfoConfig->configureHwInfoDrm(&pInHwInfo, &outHwInfo, osInterface);
5137
EXPECT_EQ(-1, ret);
5238

5339
drm->storedRetValForEUVal = 0;
@@ -61,16 +47,16 @@ class IcllpHwInfoTests : public ::testing::Test {};
6147
typedef ::testing::Types<ICLLP_1x8x8, ICLLP_1x4x8, ICLLP_1x6x8> icllpTestTypes;
6248
TYPED_TEST_CASE(IcllpHwInfoTests, icllpTestTypes);
6349
TYPED_TEST(IcllpHwInfoTests, WhenGettingSystemInfoThenParamsAreValid) {
64-
HardwareInfo hwInfo = *defaultHwInfo;
6550
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
6651
executionEnvironment->prepareRootDeviceEnvironments(1);
6752
DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
6853
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
69-
GT_SYSTEM_INFO &gtSystemInfo = hwInfo.gtSystemInfo;
70-
DeviceDescriptor device = {0, &hwInfo, &TypeParam::setupHardwareInfo};
54+
DeviceDescriptor device = {0, &TypeParam::hwInfo, &TypeParam::setupHardwareInfo};
7155

7256
int ret = drm.setupHardwareInfo(&device, false);
7357

58+
const auto &gtSystemInfo = executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->gtSystemInfo;
59+
7460
EXPECT_EQ(ret, 0);
7561
EXPECT_GT(gtSystemInfo.EUCount, 0u);
7662
EXPECT_GT(gtSystemInfo.ThreadCount, 0u);

shared/test/unit_test/gen11/lkf/linux/hw_info_config_tests_lkf.cpp

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ struct HwInfoConfigTestLinuxLkf : HwInfoConfigTestLinux {
1414
void SetUp() override {
1515
HwInfoConfigTestLinux::SetUp();
1616

17-
drm->storedDeviceID = ILKF_1x8x8_DESK_DEVICE_F0_ID;
18-
1917
drm->storedSSVal = 8;
2018
}
2119
};
@@ -24,8 +22,6 @@ LKFTEST_F(HwInfoConfigTestLinuxLkf, configureHwInfoLkf) {
2422
auto hwInfoConfig = HwInfoConfigHw<IGFX_LAKEFIELD>::get();
2523
int ret = hwInfoConfig->configureHwInfoDrm(&pInHwInfo, &outHwInfo, osInterface);
2624
EXPECT_EQ(0, ret);
27-
EXPECT_EQ((unsigned short)drm->storedDeviceID, outHwInfo.platform.usDeviceID);
28-
EXPECT_EQ((unsigned short)drm->storedDeviceRevID, outHwInfo.platform.usRevId);
2925
EXPECT_EQ((uint32_t)drm->storedEUVal, outHwInfo.gtSystemInfo.EUCount);
3026
EXPECT_EQ((uint32_t)drm->storedSSVal, outHwInfo.gtSystemInfo.SubSliceCount);
3127
EXPECT_EQ(1u, outHwInfo.gtSystemInfo.SliceCount);
@@ -36,19 +32,9 @@ LKFTEST_F(HwInfoConfigTestLinuxLkf, configureHwInfoLkf) {
3632
LKFTEST_F(HwInfoConfigTestLinuxLkf, negative) {
3733
auto hwInfoConfig = HwInfoConfigHw<IGFX_LAKEFIELD>::get();
3834

39-
drm->storedRetValForDeviceID = -1;
40-
int ret = hwInfoConfig->configureHwInfoDrm(&pInHwInfo, &outHwInfo, osInterface);
41-
EXPECT_EQ(-1, ret);
42-
43-
drm->storedRetValForDeviceID = 0;
44-
drm->storedRetValForDeviceRevID = -1;
45-
ret = hwInfoConfig->configureHwInfoDrm(&pInHwInfo, &outHwInfo, osInterface);
46-
EXPECT_EQ(-1, ret);
47-
48-
drm->storedRetValForDeviceRevID = 0;
4935
drm->failRetTopology = true;
5036
drm->storedRetValForEUVal = -1;
51-
ret = hwInfoConfig->configureHwInfoDrm(&pInHwInfo, &outHwInfo, osInterface);
37+
auto ret = hwInfoConfig->configureHwInfoDrm(&pInHwInfo, &outHwInfo, osInterface);
5238
EXPECT_EQ(-1, ret);
5339

5440
drm->storedRetValForEUVal = 0;
@@ -67,11 +53,12 @@ TYPED_TEST(LkfHwInfoTests, gtSetupIsCorrect) {
6753
executionEnvironment->prepareRootDeviceEnvironments(1);
6854
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
6955
DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
70-
GT_SYSTEM_INFO &gtSystemInfo = hwInfo.gtSystemInfo;
7156
DeviceDescriptor device = {0, &hwInfo, &TypeParam::setupHardwareInfo};
7257

7358
int ret = drm.setupHardwareInfo(&device, false);
7459

60+
const auto &gtSystemInfo = executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->gtSystemInfo;
61+
7562
EXPECT_EQ(ret, 0);
7663
EXPECT_GT(gtSystemInfo.EUCount, 0u);
7764
EXPECT_GT(gtSystemInfo.ThreadCount, 0u);

0 commit comments

Comments
 (0)