Zane Shelley | d84ed6e | 2020-06-08 13:41:48 -0500 | [diff] [blame] | 1 | #include <assert.h> |
Zane Shelley | 9fb7393 | 2020-09-15 13:34:57 -0500 | [diff] [blame] | 2 | #include <unistd.h> |
Ben Tyner | 87eabc6 | 2020-05-14 17:56:54 -0500 | [diff] [blame] | 3 | |
Zane Shelley | ebff0d3 | 2021-11-21 10:52:07 -0600 | [diff] [blame^] | 4 | #include <analyzer/analyzer_main.hpp> |
Zane Shelley | a9b4434 | 2021-08-08 17:15:52 -0500 | [diff] [blame] | 5 | #include <analyzer/ras-data/ras-data-parser.hpp> |
Zane Shelley | 4ed4be5 | 2021-02-15 17:53:40 -0600 | [diff] [blame] | 6 | #include <analyzer/service_data.hpp> |
Ben Tyner | 7029e52 | 2021-08-09 19:18:24 -0500 | [diff] [blame] | 7 | #include <attn/attn_dump.hpp> |
Ben Tyner | 0205f3b | 2020-02-24 10:24:47 -0600 | [diff] [blame] | 8 | #include <hei_main.hpp> |
Zane Shelley | f4bd5ff | 2020-11-05 22:26:04 -0600 | [diff] [blame] | 9 | #include <util/pdbg.hpp> |
Zane Shelley | d84ed6e | 2020-06-08 13:41:48 -0500 | [diff] [blame] | 10 | #include <util/trace.hpp> |
Ben Tyner | 0205f3b | 2020-02-24 10:24:47 -0600 | [diff] [blame] | 11 | |
| 12 | namespace analyzer |
| 13 | { |
| 14 | |
Zane Shelley | f4bd5ff | 2020-11-05 22:26:04 -0600 | [diff] [blame] | 15 | //------------------------------------------------------------------------------ |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 16 | |
Zane Shelley | f4bd5ff | 2020-11-05 22:26:04 -0600 | [diff] [blame] | 17 | // Forward references for externally defined functions. |
Ben Tyner | 87eabc6 | 2020-05-14 17:56:54 -0500 | [diff] [blame] | 18 | |
Zane Shelley | d3b9bac | 2020-11-17 21:59:12 -0600 | [diff] [blame] | 19 | /** |
| 20 | * @brief Will get the list of active chip and initialize the isolator. |
| 21 | * @param o_chips The returned list of active chips. |
| 22 | */ |
Zane Shelley | 171a2e0 | 2020-11-13 13:56:13 -0600 | [diff] [blame] | 23 | void initializeIsolator(std::vector<libhei::Chip>& o_chips); |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 24 | |
Zane Shelley | d3b9bac | 2020-11-17 21:59:12 -0600 | [diff] [blame] | 25 | /** |
Zane Shelley | 65fefb2 | 2021-10-18 15:35:26 -0500 | [diff] [blame] | 26 | * @brief Will get the list of active chip and initialize the isolator. |
| 27 | * @param i_isoData The data gathered during isolation (for FFDC). |
| 28 | * @param o_rootCause The returned root cause signature. |
| 29 | * @return True, if root cause has been found. False, otherwise. |
| 30 | */ |
| 31 | bool filterRootCause(const libhei::IsolationData& i_isoData, |
| 32 | libhei::Signature& o_rootCause); |
| 33 | |
| 34 | /** |
Zane Shelley | d3b9bac | 2020-11-17 21:59:12 -0600 | [diff] [blame] | 35 | * @brief Will create and submit a PEL using the given data. |
Zane Shelley | d3b9bac | 2020-11-17 21:59:12 -0600 | [diff] [blame] | 36 | * @param i_isoData The data gathered during isolation (for FFDC). |
Zane Shelley | 4ed4be5 | 2021-02-15 17:53:40 -0600 | [diff] [blame] | 37 | * @param i_servData Data regarding service actions gathered during analysis. |
Zane Shelley | 611b344 | 2021-11-19 16:02:01 -0600 | [diff] [blame] | 38 | * @return The platform log ID. Will return zero if no PEL is generated. |
Zane Shelley | d3b9bac | 2020-11-17 21:59:12 -0600 | [diff] [blame] | 39 | */ |
Zane Shelley | 611b344 | 2021-11-19 16:02:01 -0600 | [diff] [blame] | 40 | uint32_t createPel(const libhei::IsolationData& i_isoData, |
| 41 | const ServiceData& i_servData); |
Zane Shelley | d3b9bac | 2020-11-17 21:59:12 -0600 | [diff] [blame] | 42 | |
Zane Shelley | d84ed6e | 2020-06-08 13:41:48 -0500 | [diff] [blame] | 43 | //------------------------------------------------------------------------------ |
| 44 | |
Zane Shelley | ebff0d3 | 2021-11-21 10:52:07 -0600 | [diff] [blame^] | 45 | const char* __attn(libhei::AttentionType_t i_type) |
Zane Shelley | 2f26318 | 2020-07-10 21:41:21 -0500 | [diff] [blame] | 46 | { |
| 47 | const char* str = ""; |
Zane Shelley | ebff0d3 | 2021-11-21 10:52:07 -0600 | [diff] [blame^] | 48 | switch (i_type) |
Zane Shelley | 2f26318 | 2020-07-10 21:41:21 -0500 | [diff] [blame] | 49 | { |
| 50 | case libhei::ATTN_TYPE_CHECKSTOP: |
| 51 | str = "CHECKSTOP"; |
| 52 | break; |
| 53 | case libhei::ATTN_TYPE_UNIT_CS: |
| 54 | str = "UNIT_CS"; |
| 55 | break; |
| 56 | case libhei::ATTN_TYPE_RECOVERABLE: |
| 57 | str = "RECOVERABLE"; |
| 58 | break; |
| 59 | case libhei::ATTN_TYPE_SP_ATTN: |
| 60 | str = "SP_ATTN"; |
| 61 | break; |
| 62 | case libhei::ATTN_TYPE_HOST_ATTN: |
| 63 | str = "HOST_ATTN"; |
| 64 | break; |
| 65 | default: |
Zane Shelley | ebff0d3 | 2021-11-21 10:52:07 -0600 | [diff] [blame^] | 66 | trace::err("Unsupported attention type: %u", i_type); |
Zane Shelley | 2f26318 | 2020-07-10 21:41:21 -0500 | [diff] [blame] | 67 | assert(0); |
| 68 | } |
| 69 | return str; |
| 70 | } |
| 71 | |
Zane Shelley | 2f26318 | 2020-07-10 21:41:21 -0500 | [diff] [blame] | 72 | //------------------------------------------------------------------------------ |
| 73 | |
Zane Shelley | ebff0d3 | 2021-11-21 10:52:07 -0600 | [diff] [blame^] | 74 | const char* __analysisType(AnalysisType i_type) |
| 75 | { |
| 76 | const char* str = ""; |
| 77 | switch (i_type) |
| 78 | { |
| 79 | case AnalysisType::SYSTEM_CHECKSTOP: |
| 80 | str = "SYSTEM_CHECKSTOP"; |
| 81 | break; |
| 82 | case AnalysisType::TERMINATE_IMMEDIATE: |
| 83 | str = "TERMINATE_IMMEDIATE"; |
| 84 | break; |
| 85 | case AnalysisType::MANUAL: |
| 86 | str = "MANUAL"; |
| 87 | break; |
| 88 | default: |
| 89 | trace::err("Unsupported analysis type: %u", i_type); |
| 90 | assert(0); |
| 91 | } |
| 92 | return str; |
| 93 | } |
| 94 | |
| 95 | //------------------------------------------------------------------------------ |
| 96 | |
| 97 | uint32_t analyzeHardware(AnalysisType i_type, attn::DumpParameters& o_dump) |
Zane Shelley | 9fb7393 | 2020-09-15 13:34:57 -0500 | [diff] [blame] | 98 | { |
Zane Shelley | 611b344 | 2021-11-19 16:02:01 -0600 | [diff] [blame] | 99 | uint32_t o_plid = 0; // default, zero indicates PEL was not created |
Zane Shelley | 9fb7393 | 2020-09-15 13:34:57 -0500 | [diff] [blame] | 100 | |
Zane Shelley | e5411f0 | 2021-08-04 22:41:35 -0500 | [diff] [blame] | 101 | if (!util::pdbg::queryHardwareAnalysisSupported()) |
| 102 | { |
| 103 | trace::err("Hardware error analysis is not supported on this system"); |
Zane Shelley | 611b344 | 2021-11-19 16:02:01 -0600 | [diff] [blame] | 104 | return o_plid; |
Zane Shelley | e5411f0 | 2021-08-04 22:41:35 -0500 | [diff] [blame] | 105 | } |
| 106 | |
Zane Shelley | ebff0d3 | 2021-11-21 10:52:07 -0600 | [diff] [blame^] | 107 | trace::inf(">>> enter analyzeHardware(%s)", __analysisType(i_type)); |
Zane Shelley | e5411f0 | 2021-08-04 22:41:35 -0500 | [diff] [blame] | 108 | |
| 109 | // Initialize the isolator and get all of the chips to be analyzed. |
| 110 | trace::inf("Initializing the isolator..."); |
| 111 | std::vector<libhei::Chip> chips; |
| 112 | initializeIsolator(chips); |
| 113 | |
| 114 | // Isolate attentions. |
| 115 | trace::inf("Isolating errors: # of chips=%u", chips.size()); |
| 116 | libhei::IsolationData isoData{}; |
| 117 | libhei::isolate(chips, isoData); |
| 118 | |
Zane Shelley | 65fefb2 | 2021-10-18 15:35:26 -0500 | [diff] [blame] | 119 | // For debug, trace out the original list of signatures before filtering. |
| 120 | for (const auto& sig : isoData.getSignatureList()) |
| 121 | { |
| 122 | trace::inf("Signature: %s 0x%0" PRIx32 " %s", |
| 123 | util::pdbg::getPath(sig.getChip()), sig.toUint32(), |
| 124 | __attn(sig.getAttnType())); |
| 125 | } |
| 126 | |
Zane Shelley | e5411f0 | 2021-08-04 22:41:35 -0500 | [diff] [blame] | 127 | // Filter for root cause attention. |
Zane Shelley | cb45738 | 2020-11-02 20:55:06 -0600 | [diff] [blame] | 128 | libhei::Signature rootCause{}; |
Zane Shelley | 611b344 | 2021-11-19 16:02:01 -0600 | [diff] [blame] | 129 | bool attnFound = filterRootCause(isoData, rootCause); |
Zane Shelley | cb45738 | 2020-11-02 20:55:06 -0600 | [diff] [blame] | 130 | |
| 131 | if (!attnFound) |
Zane Shelley | 9fb7393 | 2020-09-15 13:34:57 -0500 | [diff] [blame] | 132 | { |
Zane Shelley | e5411f0 | 2021-08-04 22:41:35 -0500 | [diff] [blame] | 133 | // It is possible for TI handling, or manually initiated analysis via |
| 134 | // the command line, that there will not be an active attention. In |
| 135 | // which case, we will do nothing and let the caller of this function |
| 136 | // determine if this is the expected behavior. |
Zane Shelley | 9fb7393 | 2020-09-15 13:34:57 -0500 | [diff] [blame] | 137 | trace::inf("No active attentions found"); |
| 138 | } |
| 139 | else |
| 140 | { |
Zane Shelley | 9fb7393 | 2020-09-15 13:34:57 -0500 | [diff] [blame] | 141 | trace::inf("Root cause attention: %s 0x%0" PRIx32 " %s", |
Zane Shelley | cb45738 | 2020-11-02 20:55:06 -0600 | [diff] [blame] | 142 | util::pdbg::getPath(rootCause.getChip()), |
| 143 | rootCause.toUint32(), __attn(rootCause.getAttnType())); |
| 144 | |
Zane Shelley | 9513582 | 2021-08-23 09:00:05 -0500 | [diff] [blame] | 145 | // Resolve any service actions required by the root cause. |
Zane Shelley | a9b4434 | 2021-08-08 17:15:52 -0500 | [diff] [blame] | 146 | RasDataParser rasData{}; |
Zane Shelley | ca49619 | 2021-08-09 12:05:52 -0500 | [diff] [blame] | 147 | ServiceData servData{rootCause, isoData.queryCheckstop()}; |
Zane Shelley | a9b4434 | 2021-08-08 17:15:52 -0500 | [diff] [blame] | 148 | rasData.getResolution(rootCause)->resolve(servData); |
Zane Shelley | d3b9bac | 2020-11-17 21:59:12 -0600 | [diff] [blame] | 149 | |
| 150 | // Create and commit a PEL. |
Zane Shelley | 611b344 | 2021-11-19 16:02:01 -0600 | [diff] [blame] | 151 | o_plid = createPel(isoData, servData); |
Ben Tyner | 7029e52 | 2021-08-09 19:18:24 -0500 | [diff] [blame] | 152 | |
Zane Shelley | 611b344 | 2021-11-19 16:02:01 -0600 | [diff] [blame] | 153 | if (0 == o_plid) |
| 154 | { |
| 155 | trace::err("Failed to create PEL"); |
| 156 | } |
| 157 | else |
| 158 | { |
| 159 | trace::inf("PEL created: PLID=0x%0" PRIx32, o_plid); |
Zane Shelley | bf3326f | 2021-11-12 13:41:39 -0600 | [diff] [blame] | 160 | |
Zane Shelley | 611b344 | 2021-11-19 16:02:01 -0600 | [diff] [blame] | 161 | // Gather/return information needed for dump. A hardware dump will |
| 162 | // always be used for system checkstop attenions. Software dumps |
| 163 | // will be reserved for MP-IPLs during TI analysis. |
| 164 | // TODO: Need ID from root cause. At the moment, HUID does not exist |
| 165 | // in devtree. Will need a better ID definition. |
Zane Shelley | ebff0d3 | 2021-11-21 10:52:07 -0600 | [diff] [blame^] | 166 | o_dump.unitId = 0; |
| 167 | o_dump.dumpType = attn::DumpType::Hardware; |
Zane Shelley | 611b344 | 2021-11-19 16:02:01 -0600 | [diff] [blame] | 168 | } |
Zane Shelley | 9fb7393 | 2020-09-15 13:34:57 -0500 | [diff] [blame] | 169 | } |
| 170 | |
Zane Shelley | e5411f0 | 2021-08-04 22:41:35 -0500 | [diff] [blame] | 171 | // All done, clean up the isolator. |
| 172 | trace::inf("Uninitializing isolator..."); |
| 173 | libhei::uninitialize(); |
Ben Tyner | 87eabc6 | 2020-05-14 17:56:54 -0500 | [diff] [blame] | 174 | |
Zane Shelley | 2f26318 | 2020-07-10 21:41:21 -0500 | [diff] [blame] | 175 | trace::inf("<<< exit analyzeHardware()"); |
| 176 | |
Zane Shelley | 611b344 | 2021-11-19 16:02:01 -0600 | [diff] [blame] | 177 | return o_plid; |
Ben Tyner | 0205f3b | 2020-02-24 10:24:47 -0600 | [diff] [blame] | 178 | } |
| 179 | |
Ben Tyner | eea4542 | 2021-04-15 10:54:14 -0500 | [diff] [blame] | 180 | //------------------------------------------------------------------------------ |
| 181 | |
| 182 | /** |
| 183 | * @brief Get error isolator build information |
| 184 | * |
| 185 | * @return Pointer to build information |
| 186 | */ |
| 187 | const char* getBuildInfo() |
| 188 | { |
| 189 | return libhei::getBuildInfo(); |
| 190 | } |
| 191 | |
Ben Tyner | 0205f3b | 2020-02-24 10:24:47 -0600 | [diff] [blame] | 192 | } // namespace analyzer |