| 1 |
/* |
| 2 |
* Copyright (C) 2023-2024 Intel Corporation |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: MIT |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
#pragma once |
| 9 |
|
| 10 |
#include "shared/source/os_interface/linux/ioctl_helper.h" |
| 11 |
#include "shared/source/os_interface/linux/system_info.h" |
| 12 |
#include "shared/test/common/test_macros/hw_test.h" |
| 13 |
|
| 14 |
#include "level_zero/sysman/source/api/ras/linux/sysman_os_ras_imp.h" |
| 15 |
#include "level_zero/sysman/source/api/ras/sysman_ras.h" |
| 16 |
#include "level_zero/sysman/source/api/ras/sysman_ras_imp.h" |
| 17 |
#include "level_zero/sysman/source/shared/linux/pmu/sysman_pmu_imp.h" |
| 18 |
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h" |
| 19 |
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h" |
| 20 |
#include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_hw_device_id.h" |
| 21 |
|
| 22 |
using namespace NEO; |
| 23 |
|
| 24 |
namespace L0 { |
| 25 |
namespace Sysman { |
| 26 |
namespace ult { |
| 27 |
|
| 28 |
using IsGtRasSupportedProduct = IsWithinProducts<IGFX_DG1, IGFX_PVC>; |
| 29 |
using isRasNotSupportedProduct = IsNotWithinProducts<IGFX_DG1, IGFX_PVC>; |
| 30 |
|
| 31 |
const std::string deviceDir("device"); |
| 32 |
const std::string eventsDir("/sys/devices/i915_0000_03_00.0/events"); |
| 33 |
constexpr int64_t mockPmuFd = 10; |
| 34 |
constexpr uint64_t correctableGrfErrorCount = 100u; |
| 35 |
constexpr uint64_t correctableEuErrorCount = 75u; |
| 36 |
constexpr uint64_t fatalEuErrorCount = 50u; |
| 37 |
constexpr uint64_t fatalTlb = 3u; |
| 38 |
constexpr uint64_t socFatalPsfCsc0Count = 5u; |
| 39 |
constexpr uint64_t fatalEngineResetCount = 45u; |
| 40 |
constexpr uint64_t correctableGrfErrorCountTile0 = 90u; |
| 41 |
constexpr uint64_t correctableEuErrorCountTile0 = 70u; |
| 42 |
constexpr uint64_t fatalEuErrorCountTile0 = 55u; |
| 43 |
constexpr uint64_t fatalEngineResetCountTile0 = 72u; |
| 44 |
constexpr uint64_t correctableSamplerErrorCountTile1 = 30u; |
| 45 |
constexpr uint64_t correctableGscSramEcc = 2u; |
| 46 |
constexpr uint64_t nonFatalGscAonParity = 2u; |
| 47 |
constexpr uint64_t nonFataGscSelfmBist = 3u; |
| 48 |
constexpr uint64_t correctablel3Bank = 2u; |
| 49 |
constexpr uint64_t fatalSubslice = 3u; |
| 50 |
constexpr uint64_t fatalL3BankTile1 = 1u; |
| 51 |
constexpr uint64_t correctableSubsliceTile1 = 2u; |
| 52 |
constexpr uint64_t fatalGucErrorCountTile1 = 40u; |
| 53 |
constexpr uint64_t fatalIdiParityErrorCountTile1 = 60u; |
| 54 |
constexpr uint64_t correctableGucErrorCountTile1 = 25u; |
| 55 |
constexpr uint64_t fatalEngineResetCountTile1 = 85u; |
| 56 |
constexpr uint64_t socFatalMdfiEastCount = 3u; |
| 57 |
constexpr uint64_t socFatalMdfiWestCountTile1 = 0u; |
| 58 |
constexpr uint64_t socFatalPunitTile1 = 3u; |
| 59 |
constexpr uint64_t fatalFpuTile0 = 1u; |
| 60 |
constexpr uint64_t euAttention = 10u; |
| 61 |
constexpr uint64_t euAttentionTile0 = 5u; |
| 62 |
constexpr uint64_t euAttentionTile1 = 2u; |
| 63 |
constexpr uint64_t driverMigration = 2u; |
| 64 |
constexpr uint64_t driverGgtt = 1u; |
| 65 |
constexpr uint64_t driverRps = 2u; |
| 66 |
constexpr uint64_t driverEngineOther = 3u; |
| 67 |
constexpr uint64_t initialUncorrectableCacheErrors = 2u; |
| 68 |
constexpr uint64_t initialEngineReset = 2u; |
| 69 |
constexpr uint64_t initialProgrammingErrors = 7u; |
| 70 |
constexpr uint64_t initialUncorrectableNonComputeErrors = 3u; |
| 71 |
constexpr uint64_t initialUncorrectableFabricErrors = 8u; |
| 72 |
constexpr uint64_t initialUncorrectableComputeErrors = 7u; |
| 73 |
constexpr uint64_t initialCorrectableComputeErrors = 6u; |
| 74 |
constexpr uint64_t initialUncorrectableDriverErrors = 5u; |
| 75 |
|
| 76 |
constexpr uint64_t initialUncorrectableCacheErrorsTile0 = 2u; |
| 77 |
constexpr uint64_t initialCorrectableCacheErrorTile0 = 2u; |
| 78 |
constexpr uint64_t initialEngineResetTile0 = 2u; |
| 79 |
constexpr uint64_t initialProgrammingErrorsTile0 = 7u; |
| 80 |
constexpr uint64_t initialUncorrectableNonComputeErrorsTile0 = 10u; |
| 81 |
constexpr uint64_t initialCorrectableNonComputeErrorsTile0 = 2u; |
| 82 |
constexpr uint64_t initialUncorrectableComputeErrorsTile0 = 8u; |
| 83 |
constexpr uint64_t initialUncorrectableFabricErrorsTile0 = 8u; |
| 84 |
constexpr uint64_t initialCorrectableComputeErrorsTile0 = 6u; |
| 85 |
constexpr uint64_t initialUncorrectableDriverErrorsTile0 = 5u; |
| 86 |
constexpr uint64_t initialUncorrectableCacheErrorsTile1 = 1u; |
| 87 |
constexpr uint64_t initialEngineResetTile1 = 4u; |
| 88 |
constexpr uint64_t initialProgrammingErrorsTile1 = 5u; |
| 89 |
constexpr uint64_t initialCorrectableComputeErrorsTile1 = 7u; |
| 90 |
constexpr uint64_t initialUncorrectableNonComputeErrorsTile1 = 3u; |
| 91 |
constexpr uint64_t initialUncorrectableFabricErrorsTile1 = 2u; |
| 92 |
constexpr uint64_t initialUncorrectableComputeErrorsTile1 = 6u; |
| 93 |
constexpr uint64_t initialUncorrectableDriverErrorsTile1 = 4u; |
| 94 |
constexpr uint64_t timeStamp = 1000u; |
| 95 |
constexpr uint32_t pmuDriverType = 16u; |
| 96 |
constexpr uint64_t hbmCorrectableErrorCount = 2; |
| 97 |
constexpr uint64_t hbmUncorrectableErrorCount = 3; |
| 98 |
|
| 99 |
struct MockRasPmuInterfaceImp : public L0::Sysman::PmuInterfaceImp { |
| 100 |
using PmuInterfaceImp::perfEventOpen; |
| 101 |
MockRasPmuInterfaceImp(L0::Sysman::LinuxSysmanImp *pLinuxSysmanImp) : PmuInterfaceImp(pLinuxSysmanImp) {} |
| 102 |
|
| 103 |
int32_t mockPmuReadCount = 0; |
| 104 |
int32_t mockPmuReadCountAfterClear = 0; |
| 105 |
int32_t mockPmuReadTileCount = 0; |
| 106 |
|
| 107 |
bool mockPmuReadCorrectable = false; |
| 108 |
bool mockPmuReadAfterClear = false; |
| 109 |
bool mockPmuReadResult = false; |
| 110 |
bool mockPerfEvent = false; |
| 111 |
bool mockPmuReadTile = false; |
| 112 |
|
| 113 |
int64_t perfEventOpen(perf_event_attr *attr, pid_t pid, int cpu, int groupFd, uint64_t flags) override { |
| 114 |
|
| 115 |
if (mockPerfEvent == true) { |
| 116 |
return mockedPerfEventOpenAndFailureReturn(attr, pid, cpu, groupFd, flags); |
| 117 |
} |
| 118 |
|
| 119 |
return mockPmuFd; |
| 120 |
} |
| 121 |
|
| 122 |
int64_t mockedPerfEventOpenAndFailureReturn(perf_event_attr *attr, pid_t pid, int cpu, int groupFd, uint64_t flags) { |
| 123 |
return -1; |
| 124 |
} |
| 125 |
|
| 126 |
int mockedPmuReadForCorrectableAndSuccessReturn(int fd, uint64_t *data, ssize_t sizeOfdata) { |
| 127 |
memset(data, 0, sizeOfdata); |
| 128 |
data[1] = timeStamp; |
| 129 |
data[2] = correctableGrfErrorCount; |
| 130 |
data[3] = correctableEuErrorCount; |
| 131 |
return 0; |
| 132 |
} |
| 133 |
|
| 134 |
int mockedPmuReadForUncorrectableAndSuccessReturn(int fd, uint64_t *data, ssize_t sizeOfdata) { |
| 135 |
memset(data, 0, sizeOfdata); |
| 136 |
data[1] = timeStamp; |
| 137 |
data[2] = fatalEngineResetCount; |
| 138 |
data[3] = euAttention; |
| 139 |
data[4] = driverMigration; |
| 140 |
data[5] = driverGgtt; |
| 141 |
data[6] = driverRps; |
| 142 |
data[7] = 0; |
| 143 |
data[8] = fatalEuErrorCount; |
| 144 |
data[9] = socFatalPsfCsc0Count; |
| 145 |
data[10] = fatalTlb; |
| 146 |
data[11] = 0; |
| 147 |
data[12] = socFatalMdfiEastCount; |
| 148 |
return 0; |
| 149 |
} |
| 150 |
|
| 151 |
int mockedPmuReadForCorrectableTile0AndSuccessReturn(int fd, uint64_t *data, ssize_t sizeOfdata) { |
| 152 |
memset(data, 0, sizeOfdata); |
| 153 |
data[1] = timeStamp; |
| 154 |
data[2] = correctableGrfErrorCount; |
| 155 |
data[3] = correctableEuErrorCount; |
| 156 |
data[4] = correctableGscSramEcc; |
| 157 |
data[5] = correctablel3Bank; |
| 158 |
return 0; |
| 159 |
} |
| 160 |
|
| 161 |
int mockedPmuReadForUncorrectableTile0AndSuccessReturn(int fd, uint64_t *data, ssize_t sizeOfdata) { |
| 162 |
memset(data, 0, sizeOfdata); |
| 163 |
data[1] = timeStamp; |
| 164 |
data[2] = fatalEngineResetCount; |
| 165 |
data[3] = euAttention; |
| 166 |
data[4] = driverMigration; |
| 167 |
data[5] = driverGgtt; |
| 168 |
data[6] = driverRps; |
| 169 |
data[7] = 0; |
| 170 |
data[8] = fatalSubslice; |
| 171 |
data[9] = fatalEuErrorCount; |
| 172 |
data[10] = socFatalPsfCsc0Count; |
| 173 |
data[11] = nonFatalGscAonParity; |
| 174 |
data[12] = nonFataGscSelfmBist; |
| 175 |
data[13] = fatalTlb; |
| 176 |
data[14] = 0; |
| 177 |
data[15] = socFatalMdfiEastCount; |
| 178 |
return 0; |
| 179 |
} |
| 180 |
|
| 181 |
int mockedPmuReadForCorrectableTile1AndSuccessReturn(int fd, uint64_t *data, ssize_t sizeOfdata) { |
| 182 |
memset(data, 0, sizeOfdata); |
| 183 |
data[1] = timeStamp; |
| 184 |
data[2] = correctableGucErrorCountTile1; |
| 185 |
data[3] = correctableSamplerErrorCountTile1; |
| 186 |
data[4] = correctableSubsliceTile1; |
| 187 |
return 0; |
| 188 |
} |
| 189 |
|
| 190 |
int mockedPmuReadForUncorrectableTile1AndSuccessReturn(int fd, uint64_t *data, ssize_t sizeOfdata) { |
| 191 |
memset(data, 0, sizeOfdata); |
| 192 |
data[1] = timeStamp; |
| 193 |
data[2] = fatalEngineResetCountTile1; |
| 194 |
data[3] = euAttentionTile1; |
| 195 |
data[4] = driverMigration; |
| 196 |
data[5] = driverEngineOther; |
| 197 |
data[6] = fatalGucErrorCountTile1; |
| 198 |
data[7] = socFatalPunitTile1; |
| 199 |
data[8] = fatalIdiParityErrorCountTile1; |
| 200 |
data[9] = fatalL3BankTile1; |
| 201 |
data[10] = socFatalMdfiWestCountTile1; |
| 202 |
return 0; |
| 203 |
} |
| 204 |
|
| 205 |
int mockedPmuReadAfterClearAndSuccessReturn(int fd, uint64_t *data, ssize_t sizeOfdata) { |
| 206 |
memset(data, 0, sizeOfdata); |
| 207 |
return 0; |
| 208 |
} |
| 209 |
|
| 210 |
int mockedPmuReadAndFailureReturn(int fd, uint64_t *data, ssize_t sizeOfdata) { |
| 211 |
return -1; |
| 212 |
} |
| 213 |
|
| 214 |
int pmuRead(int fd, uint64_t *data, ssize_t sizeOfdata) override { |
| 215 |
|
| 216 |
if (mockPmuReadResult == true) { |
| 217 |
return mockedPmuReadAndFailureReturn(fd, data, sizeOfdata); |
| 218 |
} |
| 219 |
|
| 220 |
if (mockPmuReadCorrectable == true) { |
| 221 |
if (mockPmuReadCount == 0) { |
| 222 |
mockPmuReadCount++; |
| 223 |
return mockedPmuReadForCorrectableAndSuccessReturn(fd, data, sizeOfdata); |
| 224 |
} |
| 225 |
|
| 226 |
else if (mockPmuReadCount == 1) { |
| 227 |
mockPmuReadCount++; |
| 228 |
return mockedPmuReadForUncorrectableAndSuccessReturn(fd, data, sizeOfdata); |
| 229 |
} |
| 230 |
} |
| 231 |
|
| 232 |
if ((mockPmuReadAfterClear == true) && (mockPmuReadTile == false)) { |
| 233 |
if (mockPmuReadCountAfterClear == 0) { |
| 234 |
mockPmuReadCountAfterClear++; |
| 235 |
return mockedPmuReadForCorrectableAndSuccessReturn(fd, data, sizeOfdata); |
| 236 |
} |
| 237 |
|
| 238 |
else if (mockPmuReadCountAfterClear == 1) { |
| 239 |
mockPmuReadCountAfterClear++; |
| 240 |
return mockedPmuReadForUncorrectableAndSuccessReturn(fd, data, sizeOfdata); |
| 241 |
} |
| 242 |
|
| 243 |
else { |
| 244 |
mockPmuReadCountAfterClear++; |
| 245 |
return mockedPmuReadAfterClearAndSuccessReturn(fd, data, sizeOfdata); |
| 246 |
} |
| 247 |
} |
| 248 |
|
| 249 |
if (mockPmuReadTile == true) { |
| 250 |
if (mockPmuReadAfterClear == true) { |
| 251 |
mockPmuReadCountAfterClear++; |
| 252 |
} |
| 253 |
if ((mockPmuReadTileCount == 0) && (mockPmuReadCountAfterClear < 4)) { |
| 254 |
mockPmuReadTileCount++; |
| 255 |
return mockedPmuReadForCorrectableTile0AndSuccessReturn(fd, data, sizeOfdata); |
| 256 |
} |
| 257 |
|
| 258 |
else if ((mockPmuReadTileCount == 1) && (mockPmuReadCountAfterClear < 4)) { |
| 259 |
mockPmuReadTileCount++; |
| 260 |
return mockedPmuReadForUncorrectableTile0AndSuccessReturn(fd, data, sizeOfdata); |
| 261 |
} |
| 262 |
|
| 263 |
else if ((mockPmuReadTileCount == 2) && (mockPmuReadCountAfterClear < 4)) { |
| 264 |
mockPmuReadTileCount++; |
| 265 |
return mockedPmuReadForCorrectableTile1AndSuccessReturn(fd, data, sizeOfdata); |
| 266 |
} |
| 267 |
|
| 268 |
else if ((mockPmuReadTileCount == 3) && (mockPmuReadCountAfterClear < 4)) { |
| 269 |
mockPmuReadTileCount++; |
| 270 |
return mockedPmuReadForUncorrectableTile1AndSuccessReturn(fd, data, sizeOfdata); |
| 271 |
} else { |
| 272 |
return mockedPmuReadAfterClearAndSuccessReturn(fd, data, sizeOfdata); |
| 273 |
} |
| 274 |
} |
| 275 |
return 0; |
| 276 |
} |
| 277 |
}; |
| 278 |
|
| 279 |
struct MockRasSysfsAccess : public L0::Sysman::SysFsAccessInterface { |
| 280 |
|
| 281 |
ze_result_t mockReadSymLinkStatus = ZE_RESULT_SUCCESS; |
| 282 |
bool mockReadSymLinkResult = false; |
| 283 |
bool isMultiTileArch = false; |
| 284 |
|
| 285 |
ze_result_t readSymLink(const std::string file, std::string &val) override { |
| 286 |
|
| 287 |
if (mockReadSymLinkStatus != ZE_RESULT_SUCCESS) { |
| 288 |
return mockReadSymLinkStatus; |
| 289 |
} |
| 290 |
|
| 291 |
if (mockReadSymLinkResult == true) { |
| 292 |
return getValStringSymLinkFailure(file, val); |
| 293 |
} |
| 294 |
|
| 295 |
if (file.compare(deviceDir) == 0) { |
| 296 |
val = "/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:01.0/0000:03:00.0"; |
| 297 |
return ZE_RESULT_SUCCESS; |
| 298 |
} |
| 299 |
return ZE_RESULT_ERROR_NOT_AVAILABLE; |
| 300 |
} |
| 301 |
|
| 302 |
ze_result_t getValStringSymLinkFailure(const std::string file, std::string &val) { |
| 303 |
return ZE_RESULT_ERROR_NOT_AVAILABLE; |
| 304 |
} |
| 305 |
|
| 306 |
ze_result_t multiTileSysfsRead(const std::string file, uint64_t &val) { |
| 307 |
if (file.compare("gt/gt0/error_counter/correctable_eu_grf") == 0) { |
| 308 |
val = 5u; |
| 309 |
return ZE_RESULT_SUCCESS; |
| 310 |
} else if (file.compare("gt/gt0/error_counter/correctable_eu_ic") == 0) { |
| 311 |
val = 1u; |
| 312 |
return ZE_RESULT_SUCCESS; |
| 313 |
} else if (file.compare("gt/gt0/error_counter/fatal_eu_ic") == 0) { |
| 314 |
val = 5u; |
| 315 |
return ZE_RESULT_SUCCESS; |
| 316 |
} else if (file.compare("gt/gt0/error_counter/fatal_tlb") == 0) { |
| 317 |
val = 2u; |
| 318 |
return ZE_RESULT_SUCCESS; |
| 319 |
} else if (file.compare("gt/gt0/error_counter/engine_reset") == 0) { |
| 320 |
val = 2u; |
| 321 |
return ZE_RESULT_SUCCESS; |
| 322 |
} else if (file.compare("gt/gt1/error_counter/correctable_sampler") == 0) { |
| 323 |
val = 2u; |
| 324 |
return ZE_RESULT_SUCCESS; |
| 325 |
} else if (file.compare("gt/gt1/error_counter/fatal_guc") == 0) { |
| 326 |
val = 6u; |
| 327 |
return ZE_RESULT_SUCCESS; |
| 328 |
} else if (file.compare("gt/gt1/error_counter/fatal_idi_parity") == 0) { |
| 329 |
val = 1u; |
| 330 |
return ZE_RESULT_SUCCESS; |
| 331 |
} else if (file.compare("gt/gt1/error_counter/correctable_guc") == 0) { |
| 332 |
val = 3u; |
| 333 |
return ZE_RESULT_SUCCESS; |
| 334 |
} else if (file.compare("gt/gt1/error_counter/engine_reset") == 0) { |
| 335 |
val = 4u; |
| 336 |
return ZE_RESULT_SUCCESS; |
| 337 |
} else if (file.compare("gt/gt0/error_counter/eu_attention") == 0) { |
| 338 |
val = 7u; |
| 339 |
return ZE_RESULT_SUCCESS; |
| 340 |
} else if (file.compare("gt/gt1/error_counter/eu_attention") == 0) { |
| 341 |
val = 5u; |
| 342 |
return ZE_RESULT_SUCCESS; |
| 343 |
} else if (file.compare("gt/gt0/error_counter/soc_fatal_mdfi_east") == 0) { |
| 344 |
val = 5u; |
| 345 |
return ZE_RESULT_SUCCESS; |
| 346 |
} else if (file.compare("gt/gt0/error_counter/soc_fatal_psf_csc_0") == 0) { |
| 347 |
val = 3u; |
| 348 |
return ZE_RESULT_SUCCESS; |
| 349 |
} else if (file.compare("gt/gt1/error_counter/soc_fatal_punit") == 0) { |
| 350 |
val = 3u; |
| 351 |
return ZE_RESULT_SUCCESS; |
| 352 |
} else if (file.compare("gt/gt1/error_counter/soc_fatal_mdfi_west") == 0) { |
| 353 |
val = 2u; |
| 354 |
return ZE_RESULT_SUCCESS; |
| 355 |
} else if (file.compare("gt/gt0/error_counter/fatal_fpu") == 0) { |
| 356 |
val = 2u; |
| 357 |
return ZE_RESULT_SUCCESS; |
| 358 |
} else if (file.compare("gt/gt0/error_counter/fatal_l3_fabric") == 0) { |
| 359 |
val = 3u; |
| 360 |
return ZE_RESULT_SUCCESS; |
| 361 |
} else if (file.compare("gt/gt0/error_counter/driver_ggtt") == 0) { |
| 362 |
val = 2u; |
| 363 |
return ZE_RESULT_SUCCESS; |
| 364 |
} else if (file.compare("gt/gt0/error_counter/driver_rps") == 0) { |
| 365 |
val = 2u; |
| 366 |
return ZE_RESULT_SUCCESS; |
| 367 |
} else if (file.compare("error_counter/driver_object_migration") == 0) { |
| 368 |
val = 1u; |
| 369 |
return ZE_RESULT_SUCCESS; |
| 370 |
} else if (file.compare("gt/gt1/error_counter/driver_engine_other") == 0) { |
| 371 |
val = 3u; |
| 372 |
return ZE_RESULT_SUCCESS; |
| 373 |
} else if (file.compare("gt/gt0/error_counter/gsc_correctable_sram_ecc") == 0) { |
| 374 |
val = 2u; |
| 375 |
return ZE_RESULT_SUCCESS; |
| 376 |
} else if (file.compare("gt/gt0/error_counter/gsc_nonfatal_aon_parity") == 0) { |
| 377 |
val = 3u; |
| 378 |
return ZE_RESULT_SUCCESS; |
| 379 |
} else if (file.compare("gt/gt0/error_counter/gsc_nonfatal_selfmbist") == 0) { |
| 380 |
val = 4u; |
| 381 |
return ZE_RESULT_SUCCESS; |
| 382 |
} else if (file.compare("gt/gt0/error_counter/correctable_l3bank") == 0) { |
| 383 |
val = 2u; |
| 384 |
return ZE_RESULT_SUCCESS; |
| 385 |
} else if (file.compare("gt/gt0/error_counter/fatal_subslice") == 0) { |
| 386 |
val = 1u; |
| 387 |
return ZE_RESULT_SUCCESS; |
| 388 |
} else if (file.compare("gt/gt1/error_counter/fatal_l3bank") == 0) { |
| 389 |
val = 0u; |
| 390 |
return ZE_RESULT_SUCCESS; |
| 391 |
} else if (file.compare("gt/gt1/error_counter/correctable_subslice") == 0) { |
| 392 |
val = 2u; |
| 393 |
return ZE_RESULT_SUCCESS; |
| 394 |
} |
| 395 |
return ZE_RESULT_ERROR_NOT_AVAILABLE; |
| 396 |
} |
| 397 |
|
| 398 |
ze_result_t sysfsRead(const std::string file, uint64_t &val) { |
| 399 |
if (file.compare("gt/gt0/error_counter/correctable_eu_grf") == 0) { |
| 400 |
val = 5u; |
| 401 |
return ZE_RESULT_SUCCESS; |
| 402 |
} else if (file.compare("gt/gt0/error_counter/correctable_eu_ic") == 0) { |
| 403 |
val = 1u; |
| 404 |
return ZE_RESULT_SUCCESS; |
| 405 |
} else if (file.compare("gt/gt0/error_counter/fatal_eu_ic") == 0) { |
| 406 |
val = 5u; |
| 407 |
return ZE_RESULT_SUCCESS; |
| 408 |
} else if (file.compare("gt/gt0/error_counter/fatal_tlb") == 0) { |
| 409 |
val = 2u; |
| 410 |
return ZE_RESULT_SUCCESS; |
| 411 |
} else if (file.compare("gt/gt0/error_counter/engine_reset") == 0) { |
| 412 |
val = 2u; |
| 413 |
return ZE_RESULT_SUCCESS; |
| 414 |
} else if (file.compare("gt/gt1/error_counter/correctable_sampler") == 0) { |
| 415 |
val = 2u; |
| 416 |
return ZE_RESULT_SUCCESS; |
| 417 |
} else if (file.compare("gt/gt1/error_counter/fatal_guc") == 0) { |
| 418 |
val = 6u; |
| 419 |
return ZE_RESULT_SUCCESS; |
| 420 |
} else if (file.compare("gt/gt1/error_counter/fatal_idi_parity") == 0) { |
| 421 |
val = 1u; |
| 422 |
return ZE_RESULT_SUCCESS; |
| 423 |
} else if (file.compare("gt/gt1/error_counter/correctable_guc") == 0) { |
| 424 |
val = 3u; |
| 425 |
return ZE_RESULT_SUCCESS; |
| 426 |
} else if (file.compare("gt/gt1/error_counter/engine_reset") == 0) { |
| 427 |
val = 4u; |
| 428 |
return ZE_RESULT_SUCCESS; |
| 429 |
} else if (file.compare("gt/gt0/error_counter/eu_attention") == 0) { |
| 430 |
val = 7u; |
| 431 |
return ZE_RESULT_SUCCESS; |
| 432 |
} else if (file.compare("gt/gt1/error_counter/eu_attention") == 0) { |
| 433 |
val = 5u; |
| 434 |
return ZE_RESULT_SUCCESS; |
| 435 |
} else if (file.compare("gt/gt0/error_counter/soc_fatal_mdfi_east") == 0) { |
| 436 |
val = 5u; |
| 437 |
return ZE_RESULT_SUCCESS; |
| 438 |
} else if (file.compare("gt/gt0/error_counter/soc_fatal_psf_csc_0") == 0) { |
| 439 |
val = 3u; |
| 440 |
return ZE_RESULT_SUCCESS; |
| 441 |
} else if (file.compare("gt/gt1/error_counter/soc_fatal_punit") == 0) { |
| 442 |
val = 3u; |
| 443 |
return ZE_RESULT_SUCCESS; |
| 444 |
} else if (file.compare("gt/gt1/error_counter/soc_fatal_mdfi_west") == 0) { |
| 445 |
val = 2u; |
| 446 |
return ZE_RESULT_SUCCESS; |
| 447 |
} else if (file.compare("gt/gt0/error_counter/fatal_fpu") == 0) { |
| 448 |
val = 2u; |
| 449 |
return ZE_RESULT_SUCCESS; |
| 450 |
} else if (file.compare("gt/gt0/error_counter/fatal_l3_fabric") == 0) { |
| 451 |
val = 3u; |
| 452 |
return ZE_RESULT_SUCCESS; |
| 453 |
} else if (file.compare("gt/gt0/error_counter/driver_ggtt") == 0) { |
| 454 |
val = 2u; |
| 455 |
return ZE_RESULT_SUCCESS; |
| 456 |
} else if (file.compare("gt/gt0/error_counter/driver_rps") == 0) { |
| 457 |
val = 2u; |
| 458 |
return ZE_RESULT_SUCCESS; |
| 459 |
} else if (file.compare("error_counter/driver_object_migration") == 0) { |
| 460 |
val = 1u; |
| 461 |
return ZE_RESULT_SUCCESS; |
| 462 |
} else if (file.compare("gt/gt1/error_counter/driver_engine_other") == 0) { |
| 463 |
val = 3u; |
| 464 |
return ZE_RESULT_SUCCESS; |
| 465 |
} |
| 466 |
return ZE_RESULT_ERROR_NOT_AVAILABLE; |
| 467 |
} |
| 468 |
ze_result_t read(const std::string file, uint64_t &val) override { |
| 469 |
if (isMultiTileArch == true) { |
| 470 |
return multiTileSysfsRead(file, val); |
| 471 |
} |
| 472 |
return sysfsRead(file, val); |
| 473 |
} |
| 474 |
}; |
| 475 |
|
| 476 |
struct MockRasFsAccess : public L0::Sysman::FsAccessInterface { |
| 477 |
|
| 478 |
ze_result_t mockListDirectoryStatus = ZE_RESULT_SUCCESS; |
| 479 |
bool mockReadDirectoryFailure = false; |
| 480 |
bool mockReadFileFailure = false; |
| 481 |
bool mockReadDirectoryWithoutRasEvents = false; |
| 482 |
bool mockRootUser = false; |
| 483 |
bool mockReadVal = false; |
| 484 |
bool mockReadDirectoryForMultiDevice = false; |
| 485 |
|
| 486 |
bool directoryExists(const std::string path) override { |
| 487 |
// disables fabric errors |
| 488 |
return false; |
| 489 |
} |
| 490 |
|
| 491 |
ze_result_t listDirectory(const std::string directory, std::vector<std::string> &events) override { |
| 492 |
|
| 493 |
if (mockListDirectoryStatus != ZE_RESULT_SUCCESS) { |
| 494 |
return mockListDirectoryStatus; |
| 495 |
} |
| 496 |
|
| 497 |
if (mockReadDirectoryFailure == true) { |
| 498 |
return readDirectoryFailure(directory, events); |
| 499 |
} |
| 500 |
|
| 501 |
if (mockReadDirectoryWithoutRasEvents == true) { |
| 502 |
return readDirectoryWithoutRasEvents(directory, events); |
| 503 |
} |
| 504 |
|
| 505 |
if (mockReadDirectoryForMultiDevice == true) { |
| 506 |
return readDirectorySuccessForMultiDevice(directory, events); |
| 507 |
} |
| 508 |
|
| 509 |
if (directory.compare(eventsDir) == 0) { |
| 510 |
events.push_back("bcs0-busy"); |
| 511 |
events.push_back("error--correctable-eu-grf"); |
| 512 |
events.push_back("error--correctable-eu-ic"); |
| 513 |
events.push_back("error--soc-fatal-mdfi-east"); |
| 514 |
events.push_back("error--soc-fatal-psf-csc-0"); |
| 515 |
events.push_back("error--fatal-eu-ic"); |
| 516 |
events.push_back("error--fatal-tlb"); |
| 517 |
events.push_back("error--engine-reset"); |
| 518 |
events.push_back("error--eu-attention"); |
| 519 |
events.push_back("error--driver-object-migration"); |
| 520 |
events.push_back("error--driver-ggtt"); |
| 521 |
events.push_back("error--driver-rps"); |
| 522 |
events.push_back("error--fatal-fpu"); |
| 523 |
events.push_back("error--fatal-l3-fabric"); |
| 524 |
events.push_back("ccs0-busy"); |
| 525 |
return ZE_RESULT_SUCCESS; |
| 526 |
} |
| 527 |
return ZE_RESULT_ERROR_NOT_AVAILABLE; |
| 528 |
} |
| 529 |
|
| 530 |
ze_result_t readDirectoryWithoutRasEvents(const std::string directory, std::vector<std::string> &events) { |
| 531 |
if (directory.compare(eventsDir) == 0) { |
| 532 |
events.push_back("bcs0-busy"); |
| 533 |
events.push_back("ccs0-busy"); |
| 534 |
return ZE_RESULT_SUCCESS; |
| 535 |
} |
| 536 |
return ZE_RESULT_ERROR_NOT_AVAILABLE; |
| 537 |
} |
| 538 |
|
| 539 |
ze_result_t readDirectorySuccessForMultiDevice(const std::string directory, std::vector<std::string> &events) { |
| 540 |
if (directory.compare(eventsDir) == 0) { |
| 541 |
events.push_back("bcs0-busy"); |
| 542 |
events.push_back("error-gt0--correctable-eu-grf"); |
| 543 |
events.push_back("error-gt0--correctable-eu-grf"); |
| 544 |
events.push_back("error-gt0--correctable-eu-ic"); |
| 545 |
events.push_back("error-gt0--soc-fatal-mdfi-east"); |
| 546 |
events.push_back("error-gt0--soc-fatal-psf-csc-0"); |
| 547 |
events.push_back("error-gt0--fatal-eu-ic"); |
| 548 |
events.push_back("error-gt0--fatal-tlb"); |
| 549 |
events.push_back("error-gt0--engine-reset"); |
| 550 |
events.push_back("error-gt0--eu-attention"); |
| 551 |
events.push_back("error-gt0--fatal-fpu"); |
| 552 |
events.push_back("error-gt0--fatal-l3-fabric"); |
| 553 |
events.push_back("error--driver-object-migration"); |
| 554 |
events.push_back("error-gt0--driver-ggtt"); |
| 555 |
events.push_back("error-gt0--driver-rps"); |
| 556 |
events.push_back("error-gt1--correctable-sampler"); |
| 557 |
events.push_back("error-gt1--soc-fatal-mdfi-west"); |
| 558 |
events.push_back("error-gt1--soc-fatal-punit"); |
| 559 |
events.push_back("error-gt1--fatal-guc"); |
| 560 |
events.push_back("error-gt1--fatal-idi-parity"); |
| 561 |
events.push_back("error-gt1--correctable-guc"); |
| 562 |
events.push_back("error-gt1--engine-reset"); |
| 563 |
events.push_back("error-gt1--eu-attention"); |
| 564 |
events.push_back("error-gt1--driver-engine-other"); |
| 565 |
events.push_back("error-gt0--gsc-correctable-sram-ecc"); |
| 566 |
events.push_back("error-gt0--gsc-nonfatal-aon-parity"); |
| 567 |
events.push_back("error-gt0--gsc-nonfatal-selfmbist"); |
| 568 |
events.push_back("error-gt0--correctable-l3bank"); |
| 569 |
events.push_back("error-gt0--fatal-subslice"); |
| 570 |
events.push_back("error-gt1--fatal-l3bank"); |
| 571 |
events.push_back("error-gt1--correctable-subslice"); |
| 572 |
return ZE_RESULT_SUCCESS; |
| 573 |
} |
| 574 |
return ZE_RESULT_ERROR_NOT_AVAILABLE; |
| 575 |
} |
| 576 |
|
| 577 |
ze_result_t readDirectoryFailure(const std::string directory, std::vector<std::string> &events) { |
| 578 |
return ZE_RESULT_ERROR_NOT_AVAILABLE; |
| 579 |
} |
| 580 |
|
| 581 |
ze_result_t read(const std::string file, std::string &config) override { |
| 582 |
|
| 583 |
if (mockReadFileFailure == true) { |
| 584 |
return readFileFailure(file, config); |
| 585 |
} |
| 586 |
|
| 587 |
config = "config=0x0000000000000001"; |
| 588 |
return ZE_RESULT_SUCCESS; |
| 589 |
} |
| 590 |
|
| 591 |
ze_result_t readFileFailure(const std::string, std::string &config) { |
| 592 |
return ZE_RESULT_ERROR_NOT_AVAILABLE; |
| 593 |
} |
| 594 |
|
| 595 |
ze_result_t read(const std::string file, uint32_t &val) override { |
| 596 |
|
| 597 |
if (mockReadVal == true) { |
| 598 |
return readValFailure(file, val); |
| 599 |
} |
| 600 |
|
| 601 |
val = pmuDriverType; |
| 602 |
return ZE_RESULT_SUCCESS; |
| 603 |
} |
| 604 |
|
| 605 |
ze_result_t readValFailure(const std::string file, uint32_t &val) { |
| 606 |
val = 0; |
| 607 |
return ZE_RESULT_ERROR_NOT_AVAILABLE; |
| 608 |
} |
| 609 |
|
| 610 |
bool isRootUser() override { |
| 611 |
|
| 612 |
if (mockRootUser == true) { |
| 613 |
return userIsNotRoot(); |
| 614 |
} |
| 615 |
|
| 616 |
return true; |
| 617 |
} |
| 618 |
|
| 619 |
bool userIsNotRoot() { |
| 620 |
return false; |
| 621 |
} |
| 622 |
|
| 623 |
MockRasFsAccess() = default; |
| 624 |
}; |
| 625 |
|
| 626 |
struct MockRasFwInterface : public L0::Sysman::FirmwareUtil { |
| 627 |
|
| 628 |
bool mockMemorySuccess = false; |
| 629 |
|
| 630 |
ze_result_t mockGetMemoryErrorSuccess(zes_ras_error_type_t category, uint64_t subDeviceCount, uint64_t subDeviceId, uint64_t &count) { |
| 631 |
if (category == ZES_RAS_ERROR_TYPE_CORRECTABLE) { |
| 632 |
count = hbmCorrectableErrorCount; |
| 633 |
} |
| 634 |
if (category == ZES_RAS_ERROR_TYPE_UNCORRECTABLE) { |
| 635 |
count = hbmUncorrectableErrorCount; |
| 636 |
} |
| 637 |
return ZE_RESULT_SUCCESS; |
| 638 |
} |
| 639 |
|
| 640 |
ze_result_t fwGetMemoryErrorCount(zes_ras_error_type_t category, uint32_t subDeviceCount, uint32_t subDeviceId, uint64_t &count) override { |
| 641 |
|
| 642 |
if (mockMemorySuccess == true) { |
| 643 |
return mockGetMemoryErrorSuccess(category, subDeviceCount, subDeviceId, count); |
| 644 |
} |
| 645 |
|
| 646 |
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; |
| 647 |
} |
| 648 |
|
| 649 |
MockRasFwInterface() = default; |
| 650 |
|
| 651 |
ADDMETHOD_NOBASE(fwDeviceInit, ze_result_t, ZE_RESULT_SUCCESS, ()); |
| 652 |
ADDMETHOD_NOBASE(getFwVersion, ze_result_t, ZE_RESULT_SUCCESS, (std::string fwType, std::string &firmwareVersion)); |
| 653 |
ADDMETHOD_NOBASE(getFlashFirmwareProgress, ze_result_t, ZE_RESULT_SUCCESS, (uint32_t * pCompletionPercent)); |
| 654 |
ADDMETHOD_NOBASE(flashFirmware, ze_result_t, ZE_RESULT_SUCCESS, (std::string fwType, void *pImage, uint32_t size)); |
| 655 |
ADDMETHOD_NOBASE(fwIfrApplied, ze_result_t, ZE_RESULT_SUCCESS, (bool &ifrStatus)); |
| 656 |
ADDMETHOD_NOBASE(fwSupportedDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::vector<std::string> & supportedDiagTests)); |
| 657 |
ADDMETHOD_NOBASE(fwRunDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::string & osDiagType, zes_diag_result_t *pResult)); |
| 658 |
ADDMETHOD_NOBASE_VOIDRETURN(getDeviceSupportedFwTypes, (std::vector<std::string> & fwTypes)); |
| 659 |
ADDMETHOD_NOBASE(fwGetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t * currentState, uint8_t *pendingState)); |
| 660 |
ADDMETHOD_NOBASE(fwSetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t newState, uint8_t *currentState, uint8_t *pendingState)); |
| 661 |
ADDMETHOD_NOBASE_VOIDRETURN(fwGetMemoryHealthIndicator, (zes_mem_health_t * health)); |
| 662 |
}; |
| 663 |
|
| 664 |
struct MockRasNeoDrm : public Drm { |
| 665 |
using Drm::setupIoctlHelper; |
| 666 |
uint32_t mockMemoryType = NEO::DeviceBlobConstants::MemoryType::lpddr5; |
| 667 |
const int mockFd = 33; |
| 668 |
std::vector<bool> mockQuerySystemInfoReturnValue{}; |
| 669 |
bool isRepeated = false; |
| 670 |
bool mockReturnEmptyRegions = false; |
| 671 |
MockRasNeoDrm(RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<MockSysmanHwDeviceIdDrm>(mockFd, ""), rootDeviceEnvironment) {} |
| 672 |
|
| 673 |
void setMemoryType(uint32_t memory) { |
| 674 |
mockMemoryType = memory; |
| 675 |
} |
| 676 |
|
| 677 |
std::vector<uint64_t> getMemoryRegionsReturnsEmpty() { |
| 678 |
return {}; |
| 679 |
} |
| 680 |
|
| 681 |
bool querySystemInfo() override { |
| 682 |
bool returnValue = true; |
| 683 |
if (!mockQuerySystemInfoReturnValue.empty()) { |
| 684 |
returnValue = mockQuerySystemInfoReturnValue.front(); |
| 685 |
if (isRepeated != true) { |
| 686 |
mockQuerySystemInfoReturnValue.erase(mockQuerySystemInfoReturnValue.begin()); |
| 687 |
} |
| 688 |
return returnValue; |
| 689 |
} |
| 690 |
|
| 691 |
uint32_t hwBlob[] = {NEO::DeviceBlobConstants::maxMemoryChannels, 1, 8, NEO::DeviceBlobConstants::memoryType, 0, mockMemoryType}; |
| 692 |
std::vector<uint32_t> inputBlobData(reinterpret_cast<uint32_t *>(hwBlob), reinterpret_cast<uint32_t *>(ptrOffset(hwBlob, sizeof(hwBlob)))); |
| 693 |
this->systemInfo.reset(new SystemInfo(inputBlobData)); |
| 694 |
return returnValue; |
| 695 |
} |
| 696 |
}; |
| 697 |
|
| 698 |
class PublicLinuxRasImp : public L0::Sysman::LinuxRasImp { |
| 699 |
public: |
| 700 |
PublicLinuxRasImp(L0::Sysman::OsSysman *pOsSysman, zes_ras_error_type_t type, ze_bool_t onSubdevice, uint32_t subdeviceId) : LinuxRasImp(pOsSysman, type, onSubdevice, subdeviceId) {} |
| 701 |
using LinuxRasImp::pFsAccess; |
| 702 |
using LinuxRasImp::rasSources; |
| 703 |
}; |
| 704 |
|
| 705 |
} // namespace ult |
| 706 |
} // namespace Sysman |
| 707 |
} // namespace L0 |