Debian Codegraph @

level_zero/sysman/test/unit_tests/sources/ras/linux/test_zes_ras.cpp

raw
1 /*
2 * Copyright (C) 2023 Intel Corporation
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 */
7
8 #include "shared/test/common/libult/linux/drm_mock.h"
9
10 #include "level_zero/sysman/source/sysman_const.h"
11 #include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_fixture.h"
12 #include "level_zero/sysman/test/unit_tests/sources/ras/linux/mock_sysman_ras.h"
13
14 class OsRas;
15
16 namespace L0 {
17 namespace Sysman {
18 namespace ult {
19
20 constexpr uint32_t mockHandleCount = 2u;
21 constexpr uint32_t mockHandleCountForSubDevice = 4u;
22 struct SysmanRasFixture : public SysmanDeviceFixture {
23 protected:
24 std::unique_ptr<MockRasFsAccess> pFsAccess;
25 std::unique_ptr<MockRasSysfsAccess> pSysfsAccess;
26 std::unique_ptr<MockRasPmuInterfaceImp> pPmuInterface;
27 std::unique_ptr<MockRasFwInterface> pRasFwUtilInterface;
28 MockRasNeoDrm *pDrm = nullptr;
29 L0::Sysman::FsAccessInterface *pFsAccessOriginal = nullptr;
30 L0::Sysman::SysFsAccessInterface *pSysfsAccessOriginal = nullptr;
31 L0::Sysman::PmuInterface *pOriginalPmuInterface = nullptr;
32 L0::Sysman::FirmwareUtil *pFwUtilOriginal = nullptr;
33 L0::Sysman::SysmanDevice *device = nullptr;
34
35 void SetUp() override {
36 SysmanDeviceFixture::SetUp();
37
38 pFsAccessOriginal = pLinuxSysmanImp->pFsAccess;
39 pFsAccess = std::make_unique<MockRasFsAccess>();
40 pLinuxSysmanImp->pFsAccess = pFsAccess.get();
41
42 pSysfsAccessOriginal = pLinuxSysmanImp->pSysfsAccess;
43 pSysfsAccess = std::make_unique<MockRasSysfsAccess>();
44 pLinuxSysmanImp->pSysfsAccess = pSysfsAccess.get();
45
46 pRasFwUtilInterface = std::make_unique<MockRasFwInterface>();
47
48 pDrm = new MockRasNeoDrm(const_cast<NEO::RootDeviceEnvironment &>(pSysmanDeviceImp->getRootDeviceEnvironment()));
49 pDrm->setupIoctlHelper(pSysmanDeviceImp->getRootDeviceEnvironment().getHardwareInfo()->platform.eProductFamily);
50
51 pFwUtilOriginal = pLinuxSysmanImp->pFwUtilInterface;
52 pLinuxSysmanImp->pFwUtilInterface = pRasFwUtilInterface.get();
53
54 pOriginalPmuInterface = pLinuxSysmanImp->pPmuInterface;
55 pPmuInterface = std::make_unique<MockRasPmuInterfaceImp>(pLinuxSysmanImp);
56 pLinuxSysmanImp->pPmuInterface = pPmuInterface.get();
57
58 auto &osInterface = pSysmanDeviceImp->getRootDeviceEnvironment().osInterface;
59 osInterface->setDriverModel(std::unique_ptr<MockRasNeoDrm>(pDrm));
60
61 pSysmanDeviceImp->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.isIntegratedDevice = false;
62 device = pSysmanDevice;
63 }
64 void TearDown() override {
65 pLinuxSysmanImp->pFsAccess = pFsAccessOriginal;
66 pLinuxSysmanImp->pSysfsAccess = pSysfsAccessOriginal;
67 pLinuxSysmanImp->pPmuInterface = pOriginalPmuInterface;
68 pLinuxSysmanImp->pFwUtilInterface = pFwUtilOriginal;
69 SysmanDeviceFixture::TearDown();
70 }
71 std::vector<zes_ras_handle_t> getRasHandles(uint32_t count) {
72 std::vector<zes_ras_handle_t> handles(count, nullptr);
73 EXPECT_EQ(zesDeviceEnumRasErrorSets(device->toHandle(), &count, handles.data()), ZE_RESULT_SUCCESS);
74 return handles;
75 }
76 };
77
78 HWTEST2_F(SysmanRasFixture, GivenValidSysmanHandleWhenRetrievingRasHandlesInThenSuccessReturn, IsGtRasSupportedProduct) {
79 uint32_t count = 0;
80 ze_result_t result = zesDeviceEnumRasErrorSets(device->toHandle(), &count, NULL);
81 EXPECT_EQ(ZE_RESULT_SUCCESS, result);
82 EXPECT_EQ(count, mockHandleCount);
83
84 uint32_t testcount = count + 1;
85 result = zesDeviceEnumRasErrorSets(device->toHandle(), &testcount, NULL);
86 EXPECT_EQ(ZE_RESULT_SUCCESS, result);
87 EXPECT_EQ(testcount, mockHandleCount);
88 auto handles = getRasHandles(mockHandleCount);
89 for (auto handle : handles) {
90 EXPECT_NE(handle, nullptr);
91 }
92 }
93
94 HWTEST2_F(SysmanRasFixture, GivenValidRasHandleWhenGettingRasPropertiesThenSuccessIsReturned, IsGtRasSupportedProduct) {
95 auto handles = getRasHandles(mockHandleCount);
96 bool correctable = true;
97
98 for (auto handle : handles) {
99 ASSERT_NE(nullptr, handle);
100 zes_ras_properties_t properties = {};
101 EXPECT_EQ(ZE_RESULT_SUCCESS, zesRasGetProperties(handle, &properties));
102 EXPECT_EQ(properties.pNext, nullptr);
103 EXPECT_EQ(properties.onSubdevice, false);
104 EXPECT_EQ(properties.subdeviceId, 0u);
105 if (correctable == true) {
106 EXPECT_EQ(properties.type, ZES_RAS_ERROR_TYPE_CORRECTABLE);
107 correctable = false;
108 } else {
109 EXPECT_EQ(properties.type, ZES_RAS_ERROR_TYPE_UNCORRECTABLE);
110 }
111 }
112 }
113
114 HWTEST2_F(SysmanRasFixture, GivenValidOsSysmanPointerWhenRetrievingSupportedRasErrorsForGtAndIfReadSymLinkFailsThenNoSupportedErrorTypeIsReturned, IsGtRasSupportedProduct) {
115 std::set<zes_ras_error_type_t> errorType = {};
116
117 pSysfsAccess->mockReadSymLinkResult = true;
118
119 L0::Sysman::LinuxRasSourceGt::getSupportedRasErrorTypes(errorType, pOsSysman, false, 0);
120 EXPECT_EQ(errorType.size(), 0u);
121 }
122
123 HWTEST2_F(SysmanRasFixture, GivenValidOsSysmanPointerWhenRetrievingSupportedRasErrorsForGtAndIfListDirectoryFailsThenNoSupportedErrorTypeIsReturned, IsGtRasSupportedProduct) {
124 std::set<zes_ras_error_type_t> errorType = {};
125
126 pFsAccess->mockReadDirectoryFailure = true;
127
128 L0::Sysman::LinuxRasSourceGt::getSupportedRasErrorTypes(errorType, pOsSysman, false, 0);
129 EXPECT_EQ(errorType.size(), 0u);
130 }
131
132 HWTEST2_F(SysmanRasFixture, GivenValidOsSysmanPointerWhenRetrievingSupportedRasErrorsForHbmAndFwInterfaceIsAbsentThenNoSupportedErrorTypeIsReturned, IsPVC) {
133 std::set<zes_ras_error_type_t> errorType = {};
134 pDrm->setMemoryType(NEO::DeviceBlobConstants::MemoryType::hbm2e);
135 pLinuxSysmanImp->pFwUtilInterface = nullptr;
136
137 L0::Sysman::LinuxRasSourceHbm::getSupportedRasErrorTypes(errorType, pOsSysman, false, 0);
138 EXPECT_EQ(errorType.size(), 0u);
139 }
140
141 HWTEST2_F(SysmanRasFixture, GivenValidSysmanHandleWhenRetrievingRasHandlesIfRasEventsAreAbsentThenZeroHandlesAreCreated, IsGtRasSupportedProduct) {
142 pFsAccess->mockReadDirectoryWithoutRasEvents = true;
143
144 pLinuxSysmanImp->pFwUtilInterface = nullptr;
145 pSysmanDeviceImp->pRasHandleContext->handleList.clear();
146 pSysmanDeviceImp->pRasHandleContext->init(pOsSysman->getSubDeviceCount());
147 uint32_t count = 0;
148 ze_result_t result = zesDeviceEnumRasErrorSets(device->toHandle(), &count, NULL);
149 EXPECT_EQ(ZE_RESULT_SUCCESS, result);
150 EXPECT_EQ(count, 0u);
151 uint32_t testcount = count + 1;
152 result = zesDeviceEnumRasErrorSets(device->toHandle(), &testcount, NULL);
153 EXPECT_EQ(ZE_RESULT_SUCCESS, result);
154 EXPECT_EQ(testcount, 0u);
155 }
156
157 HWTEST2_F(SysmanRasFixture, GivenValidSysmanHandleWhenRetrievingRasHandlesIfRasEventsAndHbmAreAbsentThenZeroHandlesAreCreated, IsNotPVC) {
158 pRasFwUtilInterface->mockMemorySuccess = true;
159 pFsAccess->mockReadDirectoryWithoutRasEvents = true;
160
161 pSysmanDeviceImp->pRasHandleContext->handleList.clear();
162 pSysmanDeviceImp->pRasHandleContext->init(pOsSysman->getSubDeviceCount());
163 uint32_t count = 0;
164 ze_result_t result = zesDeviceEnumRasErrorSets(device->toHandle(), &count, NULL);
165 EXPECT_EQ(ZE_RESULT_SUCCESS, result);
166 EXPECT_EQ(count, 0u);
167 }
168
169 HWTEST2_F(SysmanRasFixture, GivenValidSysmanHandleWhenRetrievingRasHandlesIfHbmAndFwInterfaceArePresentThenSuccessIsReturned, IsPVC) {
170 pDrm->setMemoryType(NEO::DeviceBlobConstants::MemoryType::hbm2e);
171 pRasFwUtilInterface->mockMemorySuccess = true;
172
173 uint32_t count = 0;
174 ze_result_t result = zesDeviceEnumRasErrorSets(device->toHandle(), &count, NULL);
175 EXPECT_EQ(ZE_RESULT_SUCCESS, result);
176 EXPECT_EQ(count, mockHandleCount);
177 }
178
179 HWTEST2_F(SysmanRasFixture, GivenValidSysmanHandleWhenRetrievingRasHandlesIfRasEventsAreAbsentAndQuerySystemInfoSucceedsButMemSysInfoIsNullThenZeroHandlesAreCreated, IsPVC) {
180 pDrm->setMemoryType(NEO::DeviceBlobConstants::MemoryType::hbm2e);
181 pFsAccess->mockReadDirectoryWithoutRasEvents = true;
182 pDrm->mockQuerySystemInfoReturnValue.push_back(true);
183
184 pLinuxSysmanImp->pFwUtilInterface = nullptr;
185 uint32_t count = 0;
186 ze_result_t result = zesDeviceEnumRasErrorSets(device->toHandle(), &count, NULL);
187 EXPECT_EQ(ZE_RESULT_SUCCESS, result);
188 EXPECT_EQ(count, 0u);
189 }
190
191 HWTEST2_F(SysmanRasFixture, GivenValidRasHandleWhenCallingzesRasGetStateForGtThenSuccessIsReturned, IsGtRasSupportedProduct) {
192
193 VariableBackup<decltype(NEO::SysCalls::sysCallsReadlink)> mockReadLink(&NEO::SysCalls::sysCallsReadlink, [](const char *path, char *buf, size_t bufsize) -> int {
194 constexpr size_t sizeofPath = sizeof("/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:01.0/0000:03:00.0");
195 strcpy_s(buf, sizeofPath, "/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:01.0/0000:03:00.0");
196 return sizeofPath;
197 });
198
199 VariableBackup<decltype(NEO::SysCalls::sysCallsPread)> mockPread(&NEO::SysCalls::sysCallsPread, [](int fd, void *buf, size_t count, off_t offset) -> ssize_t {
200 std::ostringstream oStream;
201 oStream << pmuDriverType;
202 std::string value = oStream.str();
203 memcpy(buf, value.data(), count);
204 return count;
205 });
206
207 pPmuInterface->mockPmuReadCorrectable = true;
208 pRasFwUtilInterface->mockMemorySuccess = false;
209
210 auto handles = getRasHandles(mockHandleCount);
211 bool correctable = true;
212 for (auto handle : handles) {
213 ASSERT_NE(nullptr, handle);
214 zes_ras_state_t state = {};
215 EXPECT_EQ(ZE_RESULT_SUCCESS, zesRasGetState(handle, 0, &state));
216 if (correctable == true) {
217 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_CACHE_ERRORS], 0u);
218 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_RESET], 0u);
219 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_PROGRAMMING_ERRORS], 0u);
220 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_COMPUTE_ERRORS], correctableGrfErrorCount + correctableEuErrorCount + initialCorrectableComputeErrors);
221 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_NON_COMPUTE_ERRORS], 0u);
222 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_DISPLAY_ERRORS], 0u);
223 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_DRIVER_ERRORS], 0u);
224 correctable = false;
225 } else {
226 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_CACHE_ERRORS], fatalTlb + initialUncorrectableCacheErrors);
227 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_RESET], fatalEngineResetCount + initialEngineReset);
228 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_PROGRAMMING_ERRORS], euAttention + initialProgrammingErrors);
229 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_COMPUTE_ERRORS], fatalEuErrorCount + initialUncorrectableComputeErrors);
230 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_NON_COMPUTE_ERRORS], socFatalPsfCsc0Count + initialUncorrectableNonComputeErrors);
231 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_DISPLAY_ERRORS], 0u);
232 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_DRIVER_ERRORS], driverMigration + driverGgtt + driverRps + initialUncorrectableDriverErrors);
233 }
234 }
235 }
236
237 HWTEST2_F(SysmanRasFixture, GivenValidRasHandleWhenCallingRasGetStateForGtAfterClearThenSuccessIsReturned, IsGtRasSupportedProduct) {
238
239 VariableBackup<decltype(NEO::SysCalls::sysCallsReadlink)> mockReadLink(&NEO::SysCalls::sysCallsReadlink, [](const char *path, char *buf, size_t bufsize) -> int {
240 constexpr size_t sizeofPath = sizeof("/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:01.0/0000:03:00.0");
241 strcpy_s(buf, sizeofPath, "/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:01.0/0000:03:00.0");
242 return sizeofPath;
243 });
244
245 VariableBackup<decltype(NEO::SysCalls::sysCallsPread)> mockPread(&NEO::SysCalls::sysCallsPread, [](int fd, void *buf, size_t count, off_t offset) -> ssize_t {
246 std::ostringstream oStream;
247 oStream << pmuDriverType;
248 std::string value = oStream.str();
249 memcpy(buf, value.data(), count);
250 return count;
251 });
252
253 pPmuInterface->mockPmuReadAfterClear = true;
254
255 auto handles = getRasHandles(mockHandleCount);
256 bool correctable = true;
257 ze_bool_t clear = 0;
258 for (auto handle : handles) {
259 ASSERT_NE(nullptr, handle);
260 zes_ras_state_t state = {};
261 EXPECT_EQ(ZE_RESULT_SUCCESS, zesRasGetState(handle, clear, &state));
262 if (correctable == true) {
263 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_RESET], 0u);
264 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_PROGRAMMING_ERRORS], 0u);
265 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_DRIVER_ERRORS], 0u);
266 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_COMPUTE_ERRORS], correctableGrfErrorCount + correctableEuErrorCount + initialCorrectableComputeErrors);
267 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_NON_COMPUTE_ERRORS], 0u);
268 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_CACHE_ERRORS], 0u);
269 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_DISPLAY_ERRORS], 0u);
270 correctable = false;
271 } else {
272 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_RESET], fatalEngineResetCount + initialEngineReset);
273 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_PROGRAMMING_ERRORS], euAttention + initialProgrammingErrors);
274 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_DRIVER_ERRORS], driverMigration + driverGgtt + driverRps + initialUncorrectableDriverErrors);
275 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_COMPUTE_ERRORS], fatalEuErrorCount + initialUncorrectableComputeErrors);
276 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_NON_COMPUTE_ERRORS], socFatalPsfCsc0Count + initialUncorrectableNonComputeErrors);
277 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_CACHE_ERRORS], fatalTlb + initialUncorrectableCacheErrors);
278 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_DISPLAY_ERRORS], 0u);
279 }
280 }
281 correctable = true;
282 clear = 1;
283 for (auto handle : handles) {
284 zes_ras_state_t state = {};
285 EXPECT_EQ(ZE_RESULT_SUCCESS, zesRasGetState(handle, clear, &state));
286 if (correctable == true) {
287 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_CACHE_ERRORS], 0u);
288 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_RESET], 0u);
289 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_PROGRAMMING_ERRORS], 0u);
290 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_COMPUTE_ERRORS], 0u);
291 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_NON_COMPUTE_ERRORS], 0u);
292 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_DISPLAY_ERRORS], 0u);
293 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_DRIVER_ERRORS], 0u);
294 correctable = false;
295 } else {
296 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_CACHE_ERRORS], 0u);
297 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_RESET], 0u);
298 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_PROGRAMMING_ERRORS], 0u);
299 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_COMPUTE_ERRORS], 0u);
300 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_NON_COMPUTE_ERRORS], 0u);
301 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_DISPLAY_ERRORS], 0u);
302 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_DRIVER_ERRORS], 0u);
303 }
304 }
305 }
306
307 HWTEST2_F(SysmanRasFixture, GivenValidRasHandleWhenCallingzesRasGetStateForHbmThenSuccessIsReturned, IsPVC) {
308
309 pPmuInterface->mockPmuReadResult = true;
310 pRasFwUtilInterface->mockMemorySuccess = true;
311 pDrm->setMemoryType(NEO::DeviceBlobConstants::MemoryType::hbm2e);
312
313 auto handles = getRasHandles(mockHandleCount);
314 bool correctable = true;
315 for (auto handle : handles) {
316 ASSERT_NE(nullptr, handle);
317 zes_ras_state_t state = {};
318 EXPECT_EQ(ZE_RESULT_SUCCESS, zesRasGetState(handle, 0, &state));
319 if (correctable == true) {
320 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_NON_COMPUTE_ERRORS], hbmCorrectableErrorCount);
321 correctable = false;
322 } else {
323 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_NON_COMPUTE_ERRORS], hbmUncorrectableErrorCount);
324 }
325 }
326 }
327
328 HWTEST2_F(SysmanRasFixture, GivenValidRasHandleWhenCallingzesRasGetStateForHbmWithClearThenSuccessIsReturned, IsPVC) {
329
330 pPmuInterface->mockPmuReadResult = true;
331 pRasFwUtilInterface->mockMemorySuccess = true;
332 pDrm->setMemoryType(NEO::DeviceBlobConstants::MemoryType::hbm2e);
333
334 auto handles = getRasHandles(mockHandleCount);
335 bool correctable = true;
336 ze_bool_t clear = 0;
337 for (auto handle : handles) {
338 ASSERT_NE(nullptr, handle);
339 zes_ras_state_t state = {};
340 EXPECT_EQ(ZE_RESULT_SUCCESS, zesRasGetState(handle, clear, &state));
341 if (correctable == true) {
342 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_NON_COMPUTE_ERRORS], hbmCorrectableErrorCount);
343 correctable = false;
344 } else {
345 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_NON_COMPUTE_ERRORS], hbmUncorrectableErrorCount);
346 }
347 }
348
349 correctable = true;
350 clear = 1;
351 for (auto handle : handles) {
352 zes_ras_state_t state = {};
353 EXPECT_EQ(ZE_RESULT_SUCCESS, zesRasGetState(handle, clear, &state));
354 if (correctable == true) {
355 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_NON_COMPUTE_ERRORS], 0u);
356 correctable = false;
357 } else {
358 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_NON_COMPUTE_ERRORS], 0u);
359 }
360 }
361 }
362
363 HWTEST2_F(SysmanRasFixture, GivenValidRasHandleWhenCallingzesRasGeStateWithClearOptionWithoutPermissionsThenFailureIsReturned, IsGtRasSupportedProduct) {
364
365 pFsAccess->mockRootUser = true;
366
367 auto handles = getRasHandles(mockHandleCount);
368 ze_bool_t clear = 1;
369 for (auto handle : handles) {
370 ASSERT_NE(nullptr, handle);
371 zes_ras_state_t state = {};
372 EXPECT_EQ(ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS, zesRasGetState(handle, clear, &state));
373 }
374 }
375
376 HWTEST2_F(SysmanRasFixture, GivenValidRasHandleWhenCallingzesRasGetStateForGtInterfaceAndUnableToRetrieveConfigValuesAndOtherInterfacesAreAbsentThenFailureIsReturned, IsGtRasSupportedProduct) {
377
378 pFsAccess->mockReadFileFailure = true;
379
380 auto handles = getRasHandles(mockHandleCount);
381 for (auto handle : handles) {
382 ASSERT_NE(nullptr, handle);
383 zes_ras_state_t state = {};
384 EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesRasGetState(handle, 0, &state));
385 }
386 }
387
388 HWTEST2_F(SysmanRasFixture, GivenValidRasHandleWhenCallingzesRasGetStateForGtInterfaceAndPerfEventOpenFailsAndOtherInterfacesAreAbsentThenFailureIsReturned, IsGtRasSupportedProduct) {
389
390 pPmuInterface->mockPerfEvent = true;
391
392 auto handles = getRasHandles(mockHandleCount);
393 for (auto handle : handles) {
394 ASSERT_NE(nullptr, handle);
395 zes_ras_state_t state = {};
396 EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesRasGetState(handle, 0, &state));
397 }
398 }
399
400 HWTEST2_F(SysmanRasFixture, GivenValidRasHandleWhenCallingzesRasGetStateForGtInterfaceAndPmuReadFailsAndOtherInterfacesAreAbsentThenFailureIsReturned, IsGtRasSupportedProduct) {
401 VariableBackup<decltype(NEO::SysCalls::sysCallsReadlink)> mockReadLink(&NEO::SysCalls::sysCallsReadlink, [](const char *path, char *buf, size_t bufsize) -> int {
402 constexpr size_t sizeofPath = sizeof("/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:01.0/0000:03:00.0");
403 strcpy_s(buf, sizeofPath, "/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:01.0/0000:03:00.0");
404 return sizeofPath;
405 });
406
407 VariableBackup<decltype(NEO::SysCalls::sysCallsPread)> mockPread(&NEO::SysCalls::sysCallsPread, [](int fd, void *buf, size_t count, off_t offset) -> ssize_t {
408 std::ostringstream oStream;
409 oStream << pmuDriverType;
410 std::string value = oStream.str();
411 memcpy(buf, value.data(), count);
412 return count;
413 });
414
415 pPmuInterface->mockPmuReadResult = true;
416 auto handles = getRasHandles(mockHandleCount);
417 for (auto handle : handles) {
418 ASSERT_NE(nullptr, handle);
419 zes_ras_state_t state = {};
420 EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesRasGetState(handle, 0, &state));
421 }
422 }
423
424 HWTEST2_F(SysmanRasFixture, GivenValidRasHandleWhenCallingzesRasGetStateForGtInterfaceWithClearAndPmuReadFailsAndOtherInterfacesAreAbsentThenFailureIsReturned, IsGtRasSupportedProduct) {
425
426 VariableBackup<decltype(NEO::SysCalls::sysCallsReadlink)> mockReadLink(&NEO::SysCalls::sysCallsReadlink, [](const char *path, char *buf, size_t bufsize) -> int {
427 constexpr size_t sizeofPath = sizeof("/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:01.0/0000:03:00.0");
428 strcpy_s(buf, sizeofPath, "/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:01.0/0000:03:00.0");
429 return sizeofPath;
430 });
431
432 VariableBackup<decltype(NEO::SysCalls::sysCallsPread)> mockPread(&NEO::SysCalls::sysCallsPread, [](int fd, void *buf, size_t count, off_t offset) -> ssize_t {
433 std::ostringstream oStream;
434 oStream << pmuDriverType;
435 std::string value = oStream.str();
436 memcpy(buf, value.data(), count);
437 return count;
438 });
439
440 pPmuInterface->mockPmuReadResult = true;
441 auto handles = getRasHandles(mockHandleCount);
442 for (auto handle : handles) {
443 ASSERT_NE(nullptr, handle);
444 zes_ras_state_t state = {};
445 EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesRasGetState(handle, 1, &state));
446 }
447 }
448
449 HWTEST2_F(SysmanRasFixture, GivenValidRasHandleWhenCallingzesGetRasStateForGtInterfaceAndPMUGetEventTypeFailsAndOtherInterfacesAreAbsentThenFailureIsReturned, IsGtRasSupportedProduct) {
450
451 pFsAccess->mockReadVal = true;
452
453 auto handles = getRasHandles(mockHandleCount);
454 for (auto handle : handles) {
455 ASSERT_NE(nullptr, handle);
456 zes_ras_state_t state = {};
457 EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesRasGetState(handle, 0, &state));
458 }
459 }
460
461 HWTEST2_F(SysmanRasFixture, GivenValidRasHandleWhenCallingzesGetRasStateAndFirmwareInterfaceIsAbsentOtherInterfacesAreAlsoAbsentThenFailureIsReturned, IsGtRasSupportedProduct) {
462
463 pFsAccess->mockReadVal = true;
464
465 pLinuxSysmanImp->pFwUtilInterface = nullptr;
466 auto handles = getRasHandles(mockHandleCount);
467 for (auto handle : handles) {
468 ASSERT_NE(nullptr, handle);
469 zes_ras_state_t state = {};
470 EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesRasGetState(handle, 0, &state));
471 }
472 }
473
474 HWTEST2_F(SysmanRasFixture, GivenValidRasHandleWhenCallingzesRasGetConfigAfterzesRasSetConfigThenSuccessIsReturned, IsGtRasSupportedProduct) {
475 auto handles = getRasHandles(mockHandleCount);
476 for (auto handle : handles) {
477 ASSERT_NE(nullptr, handle);
478 zes_ras_config_t setConfig = {};
479 zes_ras_config_t getConfig = {};
480 setConfig.totalThreshold = 50;
481 memset(setConfig.detailedThresholds.category, 1, maxRasErrorCategoryCount * sizeof(uint64_t));
482
483 EXPECT_EQ(ZE_RESULT_SUCCESS, zesRasSetConfig(handle, &setConfig));
484 EXPECT_EQ(ZE_RESULT_SUCCESS, zesRasGetConfig(handle, &getConfig));
485 EXPECT_EQ(setConfig.totalThreshold, getConfig.totalThreshold);
486 int compare = std::memcmp(setConfig.detailedThresholds.category, getConfig.detailedThresholds.category, maxRasErrorCategoryCount * sizeof(uint64_t));
487 EXPECT_EQ(0, compare);
488 }
489 }
490
491 HWTEST2_F(SysmanRasFixture, GivenValidRasHandleWhenCallingzesRasSetConfigWithoutPermissionThenFailureIsReturned, IsGtRasSupportedProduct) {
492
493 pFsAccess->mockRootUser = true;
494
495 auto handles = getRasHandles(mockHandleCount);
496
497 for (auto handle : handles) {
498 ASSERT_NE(nullptr, handle);
499 zes_ras_config_t setConfig = {};
500 setConfig.totalThreshold = 50;
501 memset(setConfig.detailedThresholds.category, 1, maxRasErrorCategoryCount * sizeof(uint64_t));
502 EXPECT_EQ(ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS, zesRasSetConfig(handle, &setConfig));
503 }
504 }
505
506 HWTEST2_F(SysmanRasFixture, SysmanRasFixture_GivenValidRasHandleWhenCallingzesRasGetStateAndReadSymLinkFailsDuringInitAndOtherInterfacesAreAbsentThenVerifyNoHandlesAreReturned, IsGtRasSupportedProduct) {
507
508 pSysfsAccess->mockReadSymLinkStatus = ZE_RESULT_ERROR_NOT_AVAILABLE;
509
510 uint32_t count = 0;
511 ze_result_t result = zesDeviceEnumRasErrorSets(device->toHandle(), &count, NULL);
512 EXPECT_EQ(ZE_RESULT_SUCCESS, result);
513 EXPECT_EQ(0u, count);
514 }
515
516 HWTEST2_F(SysmanRasFixture, GivenValidRasHandleWhenCallingzesRasGetStateAndListDirectoryFailsDuringInitAndOtherInterfacesAreAbsentThenVerifyNoHandlesAreReturned, IsGtRasSupportedProduct) {
517
518 pFsAccess->mockListDirectoryStatus = ZE_RESULT_ERROR_NOT_AVAILABLE;
519 uint32_t count = 0;
520 ze_result_t result = zesDeviceEnumRasErrorSets(device->toHandle(), &count, NULL);
521 EXPECT_EQ(ZE_RESULT_SUCCESS, result);
522 EXPECT_EQ(0u, count);
523 }
524
525 HWTEST2_F(SysmanRasFixture, GivenValidRasHandleAndHandleCountZeroWhenCallingReInitThenValidCountIsReturnedAndVerifyzesDeviceEnumRasErrorSetsSucceeds, IsGtRasSupportedProduct) {
526 uint32_t count = 0;
527 ze_result_t result = zesDeviceEnumRasErrorSets(device->toHandle(), &count, NULL);
528 EXPECT_EQ(ZE_RESULT_SUCCESS, result);
529 EXPECT_EQ(count, mockHandleCount);
530
531 for (const auto &handle : pSysmanDeviceImp->pRasHandleContext->handleList) {
532 delete handle;
533 }
534 pSysmanDeviceImp->pRasHandleContext->handleList.clear();
535 pSysmanDeviceImp->pRasHandleContext->init(pOsSysman->getSubDeviceCount());
536
537 count = 0;
538 result = zesDeviceEnumRasErrorSets(device->toHandle(), &count, NULL);
539 EXPECT_EQ(ZE_RESULT_SUCCESS, result);
540 EXPECT_EQ(count, mockHandleCount);
541 }
542
543 HWTEST2_F(SysmanRasFixture, GivenValidRasHandleAndRasUtilInterfaceIsNullWhenRequestingCountWithzesGetStateStateThenVerifyGetStateReturnsFailure, isRasNotSupportedProduct) {
544 bool isSubDevice = true;
545 uint32_t subDeviceId = 0u;
546
547 auto pLinuxRasImp = std::make_unique<PublicLinuxRasImp>(pOsSysman, ZES_RAS_ERROR_TYPE_CORRECTABLE, isSubDevice, subDeviceId);
548 pLinuxRasImp->rasSources.clear();
549 pLinuxRasImp->rasSources.push_back(std::make_unique<L0::Sysman::LinuxRasSourceGt>(pLinuxSysmanImp, ZES_RAS_ERROR_TYPE_CORRECTABLE, isSubDevice, subDeviceId));
550 pLinuxRasImp->rasSources.push_back(std::make_unique<L0::Sysman::LinuxRasSourceHbm>(pLinuxSysmanImp, ZES_RAS_ERROR_TYPE_CORRECTABLE, isSubDevice, subDeviceId));
551
552 zes_ras_state_t state = {};
553 EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pLinuxRasImp->osRasGetState(state, 0));
554 }
555
556 HWTEST2_F(SysmanRasFixture, GivenValidRasHandleWhenCallingZesGetRasStateAndFirmwareInterfaceIsAbsentOtherInterfacesAreAlsoAbsentThenCallFails, IsPVC) {
557 pDrm->setMemoryType(NEO::DeviceBlobConstants::MemoryType::hbm2e);
558 pFsAccess->mockReadVal = true;
559 VariableBackup<L0::Sysman::FsAccessInterface *> fsBackup(&pLinuxSysmanImp->pFsAccess);
560 pLinuxSysmanImp->pFsAccess = pFsAccess.get();
561
562 VariableBackup<L0::Sysman::FirmwareUtil *> fwBackup(&pLinuxSysmanImp->pFwUtilInterface);
563 pLinuxSysmanImp->pFwUtilInterface = nullptr;
564
565 VariableBackup<L0::Sysman::SysFsAccessInterface *> sysfsBackup(&pLinuxSysmanImp->pSysfsAccess);
566 pLinuxSysmanImp->pSysfsAccess = pSysfsAccess.get();
567
568 auto handles = getRasHandles(mockHandleCount);
569 for (const auto &handle : handles) {
570 ASSERT_NE(nullptr, handle);
571 zes_ras_state_t state = {};
572 EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesRasGetState(handle, 1, &state));
573 }
574 }
575
576 struct SysmanRasMultiDeviceFixture : public SysmanMultiDeviceFixture {
577 protected:
578 std::unique_ptr<MockRasFsAccess> pFsAccess;
579 std::unique_ptr<MockRasSysfsAccess> pSysfsAccess;
580 std::unique_ptr<MockRasPmuInterfaceImp> pPmuInterface;
581 std::unique_ptr<MockRasFwInterface> pRasFwUtilInterface;
582 MockRasNeoDrm *pDrm = nullptr;
583 L0::Sysman::FsAccessInterface *pFsAccessOriginal = nullptr;
584 L0::Sysman::SysFsAccessInterface *pSysfsAccessOriginal = nullptr;
585 L0::Sysman::PmuInterface *pOriginalPmuInterface = nullptr;
586 L0::Sysman::FirmwareUtil *pFwUtilOriginal = nullptr;
587 Drm *pOriginalDrm = nullptr;
588 L0::Sysman::SysmanDevice *device = nullptr;
589
590 void SetUp() override {
591 SysmanMultiDeviceFixture::SetUp();
592 pDrm = new MockRasNeoDrm(const_cast<NEO::RootDeviceEnvironment &>(pSysmanDeviceImp->getRootDeviceEnvironment()));
593 pDrm->setupIoctlHelper(pSysmanDeviceImp->getRootDeviceEnvironment().getHardwareInfo()->platform.eProductFamily);
594
595 pFsAccessOriginal = pLinuxSysmanImp->pFsAccess;
596 pFsAccess = std::make_unique<MockRasFsAccess>();
597 pLinuxSysmanImp->pFsAccess = pFsAccess.get();
598
599 pSysfsAccessOriginal = pLinuxSysmanImp->pSysfsAccess;
600 pSysfsAccess = std::make_unique<MockRasSysfsAccess>();
601 pLinuxSysmanImp->pSysfsAccess = pSysfsAccess.get();
602
603 pFwUtilOriginal = pLinuxSysmanImp->pFwUtilInterface;
604 pRasFwUtilInterface = std::make_unique<MockRasFwInterface>();
605 pLinuxSysmanImp->pFwUtilInterface = pRasFwUtilInterface.get();
606
607 pOriginalPmuInterface = pLinuxSysmanImp->pPmuInterface;
608 pPmuInterface = std::make_unique<MockRasPmuInterfaceImp>(pLinuxSysmanImp);
609 pLinuxSysmanImp->pPmuInterface = pPmuInterface.get();
610
611 auto &osInterface = pSysmanDeviceImp->getRootDeviceEnvironment().osInterface;
612 osInterface->setDriverModel(std::unique_ptr<MockRasNeoDrm>(pDrm));
613 device = pSysmanDevice;
614
615 pFsAccess->mockReadDirectoryForMultiDevice = true;
616
617 pSysmanDeviceImp->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.isIntegratedDevice = false;
618 }
619 void TearDown() override {
620 pLinuxSysmanImp->pFsAccess = pFsAccessOriginal;
621 pLinuxSysmanImp->pSysfsAccess = pSysfsAccessOriginal;
622 pLinuxSysmanImp->pPmuInterface = pOriginalPmuInterface;
623 pLinuxSysmanImp->pFwUtilInterface = pFwUtilOriginal;
624 SysmanMultiDeviceFixture::TearDown();
625 }
626 std::vector<zes_ras_handle_t> getRasHandles(uint32_t count) {
627 std::vector<zes_ras_handle_t> handles(count, nullptr);
628 EXPECT_EQ(zesDeviceEnumRasErrorSets(device->toHandle(), &count, handles.data()), ZE_RESULT_SUCCESS);
629 return handles;
630 }
631 };
632 HWTEST2_F(SysmanRasMultiDeviceFixture, GivenValidSysmanHandleWithMultiDeviceWhenRetrievingRasHandlesThenSuccessIsReturned, IsGtRasSupportedProduct) {
633
634 L0::Sysman::RasHandleContext *pRasHandleContext = new L0::Sysman::RasHandleContext(pSysmanDeviceImp->pOsSysman);
635 uint32_t count = 0;
636 ze_result_t result = pRasHandleContext->rasGet(&count, nullptr);
637 EXPECT_EQ(ZE_RESULT_SUCCESS, result);
638 EXPECT_EQ((count > 0), true);
639 delete pRasHandleContext;
640 }
641 HWTEST2_F(SysmanRasMultiDeviceFixture, GivenValidSysmanHandleWhenRetrievingRasHandlesThenSuccessIsReturned, IsGtRasSupportedProduct) {
642 uint32_t count = 0;
643 ze_result_t result = zesDeviceEnumRasErrorSets(device->toHandle(), &count, NULL);
644 EXPECT_EQ(ZE_RESULT_SUCCESS, result);
645 EXPECT_EQ(count, mockHandleCountForSubDevice);
646
647 uint32_t testcount = count + 1;
648 result = zesDeviceEnumRasErrorSets(device->toHandle(), &testcount, NULL);
649 EXPECT_EQ(ZE_RESULT_SUCCESS, result);
650 EXPECT_EQ(testcount, mockHandleCountForSubDevice);
651 auto handles = getRasHandles(mockHandleCountForSubDevice);
652 for (auto handle : handles) {
653 EXPECT_NE(handle, nullptr);
654 }
655 }
656 HWTEST2_F(SysmanRasMultiDeviceFixture, GivenValidHandleWhenGettingRasPropertiesThenSuccessIsReturned, IsGtRasSupportedProduct) {
657 zes_ras_properties_t properties = {};
658 bool isSubDevice = true;
659 uint32_t subDeviceId = 0u;
660 PublicLinuxRasImp *pLinuxRasImp = new PublicLinuxRasImp(pOsSysman, ZES_RAS_ERROR_TYPE_CORRECTABLE, isSubDevice, subDeviceId);
661 EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxRasImp->osRasGetProperties(properties));
662 EXPECT_EQ(properties.subdeviceId, subDeviceId);
663 EXPECT_EQ(properties.onSubdevice, isSubDevice);
664 EXPECT_EQ(properties.type, ZES_RAS_ERROR_TYPE_CORRECTABLE);
665 delete pLinuxRasImp;
666 }
667
668 HWTEST2_F(SysmanRasMultiDeviceFixture, GivenValidRasHandleWhenCallingzesRasGetStateForGtThenSuccessIsReturned, IsGtRasSupportedProduct) {
669
670 VariableBackup<decltype(NEO::SysCalls::sysCallsReadlink)> mockReadLink(&NEO::SysCalls::sysCallsReadlink, [](const char *path, char *buf, size_t bufsize) -> int {
671 constexpr size_t sizeofPath = sizeof("/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:01.0/0000:03:00.0");
672 strcpy_s(buf, sizeofPath, "/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:01.0/0000:03:00.0");
673 return sizeofPath;
674 });
675
676 VariableBackup<decltype(NEO::SysCalls::sysCallsPread)> mockPread(&NEO::SysCalls::sysCallsPread, [](int fd, void *buf, size_t count, off_t offset) -> ssize_t {
677 std::ostringstream oStream;
678 oStream << pmuDriverType;
679 std::string value = oStream.str();
680 memcpy(buf, value.data(), count);
681 return count;
682 });
683
684 pPmuInterface->mockPmuReadTile = true;
685 pSysfsAccess->isMultiTileArch = true;
686
687 auto handles = getRasHandles(mockHandleCountForSubDevice);
688 uint32_t handleIndex = 0u;
689 for (auto handle : handles) {
690 ASSERT_NE(nullptr, handle);
691 zes_ras_state_t state = {};
692 EXPECT_EQ(ZE_RESULT_SUCCESS, zesRasGetState(handle, 0, &state));
693 if (handleIndex == 0u) {
694 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_CACHE_ERRORS], correctablel3Bank + initialCorrectableCacheErrorTile0); // No. of correctable error type for subdevice 0
695 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_RESET], 0u);
696 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_PROGRAMMING_ERRORS], 0u);
697 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_COMPUTE_ERRORS], correctableGrfErrorCount + correctableEuErrorCount + initialCorrectableComputeErrorsTile0);
698 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_NON_COMPUTE_ERRORS], correctableGscSramEcc + initialCorrectableNonComputeErrorsTile0);
699 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_DISPLAY_ERRORS], 0u);
700 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_DRIVER_ERRORS], 0u);
701 } else if (handleIndex == 1u) {
702 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_CACHE_ERRORS], fatalTlb + initialUncorrectableCacheErrorsTile0); // No. of uncorrectable error type for subdevice 0
703 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_RESET], fatalEngineResetCount + initialEngineResetTile0);
704 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_PROGRAMMING_ERRORS], euAttention + initialProgrammingErrorsTile0);
705 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_COMPUTE_ERRORS], fatalSubslice + fatalEuErrorCount + initialUncorrectableComputeErrorsTile0);
706 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_NON_COMPUTE_ERRORS], socFatalPsfCsc0Count + nonFatalGscAonParity + nonFataGscSelfmBist + initialUncorrectableNonComputeErrorsTile0);
707 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_DISPLAY_ERRORS], 0u);
708 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_DRIVER_ERRORS], driverMigration + driverGgtt + driverRps + initialUncorrectableDriverErrorsTile0);
709 } else if (handleIndex == 2u) {
710 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_CACHE_ERRORS], 0u); // No. of correctable error type for subdevice 1
711 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_RESET], 0u);
712 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_PROGRAMMING_ERRORS], 0u);
713 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_COMPUTE_ERRORS], correctableSubsliceTile1 + correctableGucErrorCountTile1 + correctableSamplerErrorCountTile1 + initialCorrectableComputeErrorsTile1);
714 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_NON_COMPUTE_ERRORS], 0u);
715 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_DISPLAY_ERRORS], 0u);
716 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_DRIVER_ERRORS], 0u);
717 } else if (handleIndex == 3u) {
718 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_CACHE_ERRORS], fatalL3BankTile1 + fatalIdiParityErrorCountTile1 + initialUncorrectableCacheErrorsTile1); // No. of uncorrectable error type for subdevice 1
719 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_RESET], fatalEngineResetCountTile1 + initialEngineResetTile1);
720 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_PROGRAMMING_ERRORS], euAttentionTile1 + initialProgrammingErrorsTile1);
721 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_COMPUTE_ERRORS], fatalGucErrorCountTile1 + initialUncorrectableComputeErrorsTile1);
722 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_NON_COMPUTE_ERRORS], socFatalMdfiWestCountTile1 + socFatalPunitTile1 + initialUncorrectableNonComputeErrorsTile1);
723 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_DISPLAY_ERRORS], 0u);
724 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_DRIVER_ERRORS], driverMigration + driverEngineOther + initialUncorrectableDriverErrorsTile1);
725 }
726 handleIndex++;
727 }
728 }
729
730 HWTEST2_F(SysmanRasMultiDeviceFixture, GivenValidRasHandleWhenCallingzesRasGetStateForHbmThenSuccessIsReturned, IsPVC) {
731
732 pPmuInterface->mockPmuReadResult = true;
733 pRasFwUtilInterface->mockMemorySuccess = true;
734 pDrm->setMemoryType(NEO::DeviceBlobConstants::MemoryType::hbm2e);
735 auto handles = getRasHandles(mockHandleCountForSubDevice);
736 uint32_t handleIndex = 0u;
737
738 for (auto handle : handles) {
739 ASSERT_NE(nullptr, handle);
740 zes_ras_state_t state = {};
741 EXPECT_EQ(ZE_RESULT_SUCCESS, zesRasGetState(handle, 0, &state));
742 if (handleIndex == 0u) {
743 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_NON_COMPUTE_ERRORS], hbmCorrectableErrorCount); // No. of correctable error type for subdevice 0
744 } else if (handleIndex == 1u) {
745 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_NON_COMPUTE_ERRORS], hbmUncorrectableErrorCount); // No. of uncorrectable error type for subdevice 0
746 } else if (handleIndex == 2u) {
747 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_NON_COMPUTE_ERRORS], hbmCorrectableErrorCount); // No. of correctable error type for subdevice 1
748 } else if (handleIndex == 3u) {
749 EXPECT_EQ(state.category[ZES_RAS_ERROR_CAT_NON_COMPUTE_ERRORS], hbmUncorrectableErrorCount); // No. of uncorrectable error type for subdevice 1
750 }
751 handleIndex++;
752 }
753 }
754
755 } // namespace ult
756 } // namespace Sysman
757 } // namespace L0