-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathocc_manager.cpp
1788 lines (1604 loc) · 53.1 KB
/
occ_manager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "config.h"
#include "occ_manager.hpp"
#include "i2c_occ.hpp"
#include "occ_dbus.hpp"
#include "occ_errors.hpp"
#include "utils.hpp"
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/lg2.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
#include <chrono>
#include <cmath>
#include <filesystem>
#include <fstream>
#include <regex>
namespace open_power
{
namespace occ
{
constexpr uint32_t fruTypeNotAvailable = 0xFF;
constexpr auto fruTypeSuffix = "fru_type";
constexpr auto faultSuffix = "fault";
constexpr auto inputSuffix = "input";
constexpr auto maxSuffix = "max";
const auto HOST_ON_FILE = "/run/openbmc/host@0-on";
using namespace phosphor::logging;
using namespace std::literals::chrono_literals;
template <typename T>
T readFile(const std::string& path)
{
std::ifstream ifs;
ifs.exceptions(std::ifstream::failbit | std::ifstream::badbit |
std::ifstream::eofbit);
T data;
try
{
ifs.open(path);
ifs >> data;
ifs.close();
}
catch (const std::exception& e)
{
auto err = errno;
throw std::system_error(err, std::generic_category());
}
return data;
}
void Manager::createPldmHandle()
{
#ifdef PLDM
pldmHandle = std::make_unique<pldm::Interface>(
std::bind(std::mem_fn(&Manager::updateOCCActive), this,
std::placeholders::_1, std::placeholders::_2),
std::bind(std::mem_fn(&Manager::sbeHRESETResult), this,
std::placeholders::_1, std::placeholders::_2),
std::bind(std::mem_fn(&Manager::updateOccSafeMode), this,
std::placeholders::_1),
event);
#endif
}
// findAndCreateObjects():
// Takes care of getting the required objects created and
// finds the available devices/processors.
// (function is called everytime the discoverTimer expires)
// - create the PowerMode object to control OCC modes
// - create statusObjects for each OCC device found
// - waits for OCC Active sensors PDRs to become available
// - restart discoverTimer if all data is not available yet
void Manager::findAndCreateObjects()
{
#ifndef POWER10
for (auto id = 0; id < MAX_CPUS; ++id)
{
// Create one occ per cpu
auto occ = std::string(OCC_NAME) + std::to_string(id);
createObjects(occ);
}
#else
if (!pmode)
{
// Create the power mode object
pmode = std::make_unique<powermode::PowerMode>(
*this, powermode::PMODE_PATH, powermode::PIPS_PATH, event);
}
if (!fs::exists(HOST_ON_FILE))
{
static bool statusObjCreated = false;
if (!statusObjCreated)
{
// Create the OCCs based on on the /dev/occX devices
auto occs = findOCCsInDev();
if (occs.empty() || (prevOCCSearch.size() != occs.size()))
{
// Something changed or no OCCs yet, try again in 10s.
// Note on the first pass prevOCCSearch will be empty,
// so there will be at least one delay to give things
// a chance to settle.
prevOCCSearch = occs;
lg2::info(
"Manager::findAndCreateObjects(): Waiting for OCCs (currently {QTY})",
"QTY", occs.size());
discoverTimer->restartOnce(10s);
}
else
{
// All OCCs appear to be available, create status objects
// createObjects requires OCC0 first.
std::sort(occs.begin(), occs.end());
lg2::info(
"Manager::findAndCreateObjects(): Creating {QTY} OCC Status Objects",
"QTY", occs.size());
for (auto id : occs)
{
createObjects(std::string(OCC_NAME) + std::to_string(id));
}
statusObjCreated = true;
waitingForAllOccActiveSensors = true;
// Find/update the processor path associated with each OCC
for (auto& obj : statusObjects)
{
obj->updateProcAssociation();
}
}
}
if (statusObjCreated && waitingForAllOccActiveSensors)
{
static bool tracedHostWait = false;
if (utils::isHostRunning())
{
if (tracedHostWait)
{
lg2::info(
"Manager::findAndCreateObjects(): Host is running");
tracedHostWait = false;
}
checkAllActiveSensors();
}
else
{
if (!tracedHostWait)
{
lg2::info(
"Manager::findAndCreateObjects(): Waiting for host to start");
tracedHostWait = true;
}
discoverTimer->restartOnce(30s);
#ifdef PLDM
if (throttlePldmTraceTimer->isEnabled())
{
// Host is no longer running, disable throttle timer and
// make sure traces are not throttled
lg2::info("findAndCreateObjects(): disabling sensor timer");
throttlePldmTraceTimer->setEnabled(false);
pldmHandle->setTraceThrottle(false);
}
#endif
}
}
}
else
{
lg2::info(
"Manager::findAndCreateObjects(): Waiting for {FILE} to complete...",
"FILE", HOST_ON_FILE);
discoverTimer->restartOnce(10s);
}
#endif
}
#ifdef POWER10
// Check if all occActive sensors are available
void Manager::checkAllActiveSensors()
{
static bool allActiveSensorAvailable = false;
static bool tracedSensorWait = false;
static bool waitingForHost = false;
if (open_power::occ::utils::isHostRunning())
{
if (waitingForHost)
{
waitingForHost = false;
lg2::info("checkAllActiveSensors(): Host is now running");
}
// Start with the assumption that all are available
allActiveSensorAvailable = true;
for (auto& obj : statusObjects)
{
if ((!obj->occActive()) && (!obj->getPldmSensorReceived()))
{
auto instance = obj->getOccInstanceID();
// Check if sensor was queued while waiting for discovery
auto match = queuedActiveState.find(instance);
if (match != queuedActiveState.end())
{
queuedActiveState.erase(match);
lg2::info(
"checkAllActiveSensors(): OCC{INST} is ACTIVE (queued)",
"INST", instance);
obj->occActive(true);
}
else
{
allActiveSensorAvailable = false;
if (!tracedSensorWait)
{
lg2::info(
"checkAllActiveSensors(): Waiting on OCC{INST} Active sensor",
"INST", instance);
tracedSensorWait = true;
#ifdef PLDM
// Make sure PLDM traces are not throttled
pldmHandle->setTraceThrottle(false);
// Start timer to throttle PLDM traces when timer
// expires
onPldmTimeoutCreatePel = false;
throttlePldmTraceTimer->restartOnce(5min);
#endif
}
#ifdef PLDM
// Ignore active sensor check if the OCCs are being reset
if (!resetInProgress)
{
pldmHandle->checkActiveSensor(obj->getOccInstanceID());
}
#endif
break;
}
}
}
}
else
{
if (!waitingForHost)
{
waitingForHost = true;
lg2::info("checkAllActiveSensors(): Waiting for host to start");
#ifdef PLDM
if (throttlePldmTraceTimer->isEnabled())
{
// Host is no longer running, disable throttle timer and
// make sure traces are not throttled
lg2::info("checkAllActiveSensors(): disabling sensor timer");
throttlePldmTraceTimer->setEnabled(false);
pldmHandle->setTraceThrottle(false);
}
#endif
}
}
if (allActiveSensorAvailable)
{
// All sensors were found, disable the discovery timer
if (discoverTimer->isEnabled())
{
discoverTimer->setEnabled(false);
}
#ifdef PLDM
if (throttlePldmTraceTimer->isEnabled())
{
// Disable throttle timer and make sure traces are not throttled
throttlePldmTraceTimer->setEnabled(false);
pldmHandle->setTraceThrottle(false);
}
#endif
if (waitingForAllOccActiveSensors)
{
lg2::info(
"checkAllActiveSensors(): OCC Active sensors are available");
waitingForAllOccActiveSensors = false;
if (resetRequired)
{
initiateOccRequest(resetInstance);
if (!waitForAllOccsTimer->isEnabled())
{
lg2::warning(
"occsNotAllRunning: Restarting waitForAllOccTimer");
// restart occ wait timer to check status after reset
// completes
waitForAllOccsTimer->restartOnce(60s);
}
}
}
queuedActiveState.clear();
tracedSensorWait = false;
}
else
{
// Not all sensors were available, so keep waiting
if (!tracedSensorWait)
{
lg2::info(
"checkAllActiveSensors(): Waiting for OCC Active sensors to become available");
tracedSensorWait = true;
}
discoverTimer->restartOnce(10s);
}
}
#endif
std::vector<int> Manager::findOCCsInDev()
{
std::vector<int> occs;
std::regex expr{R"(occ(\d+)$)"};
for (auto& file : fs::directory_iterator("/dev"))
{
std::smatch match;
std::string path{file.path().string()};
if (std::regex_search(path, match, expr))
{
auto num = std::stoi(match[1].str());
// /dev numbering starts at 1, ours starts at 0.
occs.push_back(num - 1);
}
}
return occs;
}
int Manager::cpuCreated(sdbusplus::message_t& msg)
{
namespace fs = std::filesystem;
sdbusplus::message::object_path o;
msg.read(o);
fs::path cpuPath(std::string(std::move(o)));
auto name = cpuPath.filename().string();
auto index = name.find(CPU_NAME);
name.replace(index, std::strlen(CPU_NAME), OCC_NAME);
createObjects(name);
return 0;
}
void Manager::createObjects(const std::string& occ)
{
auto path = fs::path(OCC_CONTROL_ROOT) / occ;
statusObjects.emplace_back(std::make_unique<Status>(
event, path.c_str(), *this,
#ifdef POWER10
pmode,
#endif
std::bind(std::mem_fn(&Manager::statusCallBack), this,
std::placeholders::_1, std::placeholders::_2)
#ifdef PLDM
,
// Callback will set flag indicating reset needs to be done
// instead of immediately issuing a reset via PLDM.
std::bind(std::mem_fn(&Manager::resetOccRequest), this,
std::placeholders::_1)
#endif
));
// Create the power cap monitor object
if (!pcap)
{
pcap = std::make_unique<open_power::occ::powercap::PowerCap>(
*statusObjects.back());
}
if (statusObjects.back()->isMasterOcc())
{
lg2::info("Manager::createObjects(): OCC{INST} is the master", "INST",
statusObjects.back()->getOccInstanceID());
_pollTimer->setEnabled(false);
#ifdef POWER10
// Set the master OCC on the PowerMode object
pmode->setMasterOcc(path);
#endif
}
passThroughObjects.emplace_back(std::make_unique<PassThrough>(
path.c_str()
#ifdef POWER10
,
pmode
#endif
));
}
// If a reset is not already outstanding, set a flag to indicate that a reset is
// needed.
void Manager::resetOccRequest(instanceID instance)
{
if (!resetRequired)
{
resetRequired = true;
resetInstance = instance;
lg2::error(
"resetOccRequest: PM Complex reset was requested due to OCC{INST}",
"INST", instance);
}
else if (instance != resetInstance)
{
lg2::warning(
"resetOccRequest: Ignoring PM Complex reset request for OCC{INST}, because reset already outstanding for OCC{RINST}",
"INST", instance, "RINST", resetInstance);
}
}
// If a reset has not been started, initiate an OCC reset via PLDM
void Manager::initiateOccRequest(instanceID instance)
{
if (!resetInProgress)
{
resetInProgress = true;
resetInstance = instance;
lg2::error(
"initiateOccRequest: Initiating PM Complex reset due to OCC{INST}",
"INST", instance);
#ifdef PLDM
pldmHandle->resetOCC(instance);
#endif
resetRequired = false;
}
else
{
lg2::warning(
"initiateOccRequest: Ignoring PM Complex reset request for OCC{INST}, because reset already in process for OCC{RINST}",
"INST", instance, "RINST", resetInstance);
}
}
void Manager::statusCallBack(instanceID instance, bool status)
{
if (status == true)
{
if (resetInProgress)
{
lg2::info(
"statusCallBack: Ignoring OCC{INST} activate because a reset has been initiated due to OCC{RINST}",
"INST", instance, "RINST", resetInstance);
return;
}
// OCC went active
++activeCount;
#ifdef POWER10
if (activeCount == 1)
{
// First OCC went active (allow some time for all OCCs to go active)
waitForAllOccsTimer->restartOnce(60s);
}
#endif
if (activeCount == statusObjects.size())
{
#ifdef POWER10
// All OCCs are now running
if (waitForAllOccsTimer->isEnabled())
{
// stop occ wait timer
waitForAllOccsTimer->setEnabled(false);
}
// All OCCs have been found, check if we need a reset
if (resetRequired)
{
initiateOccRequest(resetInstance);
if (!waitForAllOccsTimer->isEnabled())
{
lg2::warning(
"occsNotAllRunning: Restarting waitForAllOccTimer");
// restart occ wait timer
waitForAllOccsTimer->restartOnce(60s);
}
}
else
{
// Verify master OCC and start presence monitor
validateOccMaster();
}
#else
// Verify master OCC and start presence monitor
validateOccMaster();
#endif
}
// Start poll timer if not already started
if (!_pollTimer->isEnabled())
{
lg2::info("Manager: OCCs will be polled every {TIME} seconds",
"TIME", pollInterval);
// Send poll and start OCC poll timer
pollerTimerExpired();
}
}
else
{
// OCC went away
if (activeCount > 0)
{
--activeCount;
}
else
{
lg2::info("OCC{INST} disabled, and no other OCCs are active",
"INST", instance);
}
if (activeCount == 0)
{
// No OCCs are running
if (resetInProgress)
{
// All OCC active sensors are clear (reset should be in
// progress)
lg2::info(
"statusCallBack: Clearing resetInProgress (activeCount={COUNT}, OCC{INST}, status={STATUS})",
"COUNT", activeCount, "INST", instance, "STATUS", status);
resetInProgress = false;
resetInstance = 255;
}
// Stop OCC poll timer
if (_pollTimer->isEnabled())
{
lg2::info(
"Manager::statusCallBack(): OCCs are not running, stopping poll timer");
_pollTimer->setEnabled(false);
}
#ifdef POWER10
// stop wait timer
if (waitForAllOccsTimer->isEnabled())
{
waitForAllOccsTimer->setEnabled(false);
}
#endif
}
else if (resetInProgress)
{
lg2::info(
"statusCallBack: Skipping clear of resetInProgress (activeCount={COUNT}, OCC{INST}, status={STATUS})",
"COUNT", activeCount, "INST", instance, "STATUS", status);
}
#ifdef READ_OCC_SENSORS
// Clear OCC sensors
setSensorValueToNaN(instance);
#endif
}
#ifdef POWER10
if (waitingForAllOccActiveSensors)
{
if (utils::isHostRunning())
{
checkAllActiveSensors();
}
}
#endif
}
#ifdef I2C_OCC
void Manager::initStatusObjects()
{
// Make sure we have a valid path string
static_assert(sizeof(DEV_PATH) != 0);
auto deviceNames = i2c_occ::getOccHwmonDevices(DEV_PATH);
for (auto& name : deviceNames)
{
i2c_occ::i2cToDbus(name);
name = std::string(OCC_NAME) + '_' + name;
auto path = fs::path(OCC_CONTROL_ROOT) / name;
statusObjects.emplace_back(
std::make_unique<Status>(event, path.c_str(), *this));
}
// The first device is master occ
pcap = std::make_unique<open_power::occ::powercap::PowerCap>(
*statusObjects.front());
#ifdef POWER10
pmode = std::make_unique<powermode::PowerMode>(*this, powermode::PMODE_PATH,
powermode::PIPS_PATH);
// Set the master OCC on the PowerMode object
pmode->setMasterOcc(path);
#endif
}
#endif
#ifdef PLDM
void Manager::sbeTimeout(unsigned int instance)
{
auto obj = std::find_if(statusObjects.begin(), statusObjects.end(),
[instance](const auto& obj) {
return instance == obj->getOccInstanceID();
});
if (obj != statusObjects.end() && (*obj)->occActive())
{
lg2::info("SBE timeout, requesting HRESET (OCC{INST})", "INST",
instance);
#ifdef PHAL_SUPPORT
setSBEState(instance, SBE_STATE_NOT_USABLE);
#endif
// Stop communication with this OCC
(*obj)->occActive(false);
pldmHandle->sendHRESET(instance);
}
}
bool Manager::updateOCCActive(instanceID instance, bool status)
{
auto obj = std::find_if(statusObjects.begin(), statusObjects.end(),
[instance](const auto& obj) {
return instance == obj->getOccInstanceID();
});
const bool hostRunning = open_power::occ::utils::isHostRunning();
if (obj != statusObjects.end())
{
if (!hostRunning && (status == true))
{
lg2::warning(
"updateOCCActive: Host is not running yet (OCC{INST} active={STAT}), clearing sensor received",
"INST", instance, "STAT", status);
(*obj)->setPldmSensorReceived(false);
if (!waitingForAllOccActiveSensors)
{
lg2::info(
"updateOCCActive: Waiting for Host and all OCC Active Sensors");
waitingForAllOccActiveSensors = true;
}
#ifdef POWER10
discoverTimer->restartOnce(30s);
#endif
return false;
}
else
{
(*obj)->setPldmSensorReceived(true);
return (*obj)->occActive(status);
}
}
else
{
if (hostRunning)
{
lg2::warning(
"updateOCCActive: No status object to update for OCC{INST} (active={STAT})",
"INST", instance, "STAT", status);
}
else
{
if (status == true)
{
lg2::warning(
"updateOCCActive: No status objects and Host is not running yet (OCC{INST} active={STAT})",
"INST", instance, "STAT", status);
}
}
if (status == true)
{
// OCC went active
queuedActiveState.insert(instance);
}
else
{
auto match = queuedActiveState.find(instance);
if (match != queuedActiveState.end())
{
// OCC was disabled
queuedActiveState.erase(match);
}
}
return false;
}
}
// Called upon pldm event To set powermode Safe Mode State for system.
void Manager::updateOccSafeMode(bool safeMode)
{
#ifdef POWER10
pmode->updateDbusSafeMode(safeMode);
#endif
// Update the processor throttle status on dbus
for (auto& obj : statusObjects)
{
obj->updateThrottle(safeMode, THROTTLED_SAFE);
}
}
void Manager::sbeHRESETResult(instanceID instance, bool success)
{
if (success)
{
lg2::info("HRESET succeeded (OCC{INST})", "INST", instance);
#ifdef PHAL_SUPPORT
setSBEState(instance, SBE_STATE_BOOTED);
#endif
// Re-enable communication with this OCC
auto obj = std::find_if(statusObjects.begin(), statusObjects.end(),
[instance](const auto& obj) {
return instance == obj->getOccInstanceID();
});
if (obj != statusObjects.end() && (!(*obj)->occActive()))
{
(*obj)->occActive(true);
}
return;
}
#ifdef PHAL_SUPPORT
setSBEState(instance, SBE_STATE_FAILED);
if (sbeCanDump(instance))
{
lg2::info("HRESET failed (OCC{INST}), triggering SBE dump", "INST",
instance);
auto& bus = utils::getBus();
uint32_t src6 = instance << 16;
uint32_t logId =
FFDC::createPEL("org.open_power.Processor.Error.SbeChipOpTimeout",
src6, "SBE command timeout");
try
{
constexpr auto interface = "xyz.openbmc_project.Dump.Create";
constexpr auto function = "CreateDump";
std::string service =
utils::getService(OP_DUMP_OBJ_PATH, interface);
auto method = bus.new_method_call(service.c_str(), OP_DUMP_OBJ_PATH,
interface, function);
std::map<std::string, std::variant<std::string, uint64_t>>
createParams{
{"com.ibm.Dump.Create.CreateParameters.ErrorLogId",
uint64_t(logId)},
{"com.ibm.Dump.Create.CreateParameters.DumpType",
"com.ibm.Dump.Create.DumpType.SBE"},
{"com.ibm.Dump.Create.CreateParameters.FailingUnitId",
uint64_t(instance)},
};
method.append(createParams);
auto response = bus.call(method);
}
catch (const sdbusplus::exception_t& e)
{
constexpr auto ERROR_DUMP_DISABLED =
"xyz.openbmc_project.Dump.Create.Error.Disabled";
if (e.name() == ERROR_DUMP_DISABLED)
{
lg2::info("Dump is disabled, skipping");
}
else
{
lg2::error("Dump failed");
}
}
}
#endif
// SBE Reset failed, try PM Complex reset
lg2::error("sbeHRESETResult: Forcing PM Complex reset");
resetOccRequest(instance);
}
#ifdef PHAL_SUPPORT
bool Manager::sbeCanDump(unsigned int instance)
{
struct pdbg_target* proc = getPdbgTarget(instance);
if (!proc)
{
// allow the dump in the error case
return true;
}
try
{
if (!openpower::phal::sbe::isDumpAllowed(proc))
{
return false;
}
if (openpower::phal::pdbg::isSbeVitalAttnActive(proc))
{
return false;
}
}
catch (openpower::phal::exception::SbeError& e)
{
lg2::info("Failed to query SBE state");
}
// allow the dump in the error case
return true;
}
void Manager::setSBEState(unsigned int instance, enum sbe_state state)
{
struct pdbg_target* proc = getPdbgTarget(instance);
if (!proc)
{
return;
}
try
{
openpower::phal::sbe::setState(proc, state);
}
catch (const openpower::phal::exception::SbeError& e)
{
lg2::error("Failed to set SBE state: {ERROR}", "ERROR", e.what());
}
}
struct pdbg_target* Manager::getPdbgTarget(unsigned int instance)
{
if (!pdbgInitialized)
{
try
{
openpower::phal::pdbg::init();
pdbgInitialized = true;
}
catch (const openpower::phal::exception::PdbgError& e)
{
lg2::error("pdbg initialization failed");
return nullptr;
}
}
struct pdbg_target* proc = nullptr;
pdbg_for_each_class_target("proc", proc)
{
if (pdbg_target_index(proc) == instance)
{
return proc;
}
}
lg2::error("Failed to get pdbg target");
return nullptr;
}
#endif
#endif
void Manager::pollerTimerExpired()
{
if (!_pollTimer)
{
lg2::error("pollerTimerExpired() ERROR: Timer not defined");
return;
}
#ifdef POWER10
if (resetRequired)
{
lg2::error("pollerTimerExpired() - Initiating PM Complex reset");
initiateOccRequest(resetInstance);
if (!waitForAllOccsTimer->isEnabled())
{
lg2::warning("pollerTimerExpired: Restarting waitForAllOccTimer");
// restart occ wait timer
waitForAllOccsTimer->restartOnce(60s);
}
return;
}
#endif
for (auto& obj : statusObjects)
{
if (!obj->occActive())
{
// OCC is not running yet
#ifdef READ_OCC_SENSORS
auto id = obj->getOccInstanceID();
setSensorValueToNaN(id);
#endif
continue;
}
// Read sysfs to force kernel to poll OCC
obj->readOccState();
#ifdef READ_OCC_SENSORS
// Read occ sensor values
getSensorValues(obj);
#endif
}
if (activeCount > 0)
{
// Restart OCC poll timer
_pollTimer->restartOnce(std::chrono::seconds(pollInterval));
}
else
{
// No OCCs running, so poll timer will not be restarted
lg2::info(
"Manager::pollerTimerExpired: poll timer will not be restarted");
}
}
#ifdef READ_OCC_SENSORS
void Manager::readTempSensors(const fs::path& path, uint32_t occInstance)
{
// There may be more than one sensor with the same FRU type
// and label so make two passes: the first to read the temps
// from sysfs, and the second to put them on D-Bus after
// resolving any conflicts.
std::map<std::string, double> sensorData;
std::regex expr{"temp\\d+_label$"}; // Example: temp5_label
for (auto& file : fs::directory_iterator(path))
{
if (!std::regex_search(file.path().string(), expr))
{
continue;
}
uint32_t labelValue{0};
try
{
labelValue = readFile<uint32_t>(file.path());
}
catch (const std::system_error& e)
{
lg2::debug(
"readTempSensors: Failed reading {PATH}, errno = {ERROR}",
"PATH", file.path().string(), "ERROR", e.code().value());
continue;
}
const std::string& tempLabel = "label";
const std::string filePathString = file.path().string().substr(
0, file.path().string().length() - tempLabel.length());
uint32_t fruTypeValue{0};
try
{
fruTypeValue = readFile<uint32_t>(filePathString + fruTypeSuffix);
}
catch (const std::system_error& e)
{
lg2::debug(
"readTempSensors: Failed reading {PATH}, errno = {ERROR}",
"PATH", filePathString + fruTypeSuffix, "ERROR",
e.code().value());
continue;
}
std::string sensorPath =
OCC_SENSORS_ROOT + std::string("/temperature/");
std::string dvfsTempPath;
if (fruTypeValue == VRMVdd)
{
sensorPath.append(
"vrm_vdd" + std::to_string(occInstance) + "_temp");
}
else if (fruTypeValue == processorIoRing)