Skip to content

Commit

Permalink
Hold off OCC communication if targets not ready
Browse files Browse the repository at this point in the history
We need to prevent occ-control from trying to access OCC data while FSI
scan is in progress which we have seen happen after reset/reload.
The code change will prevent creating the OCC objects until the host-on
task has completed.

Change-Id: Ice647b2e64dbd6b7eb3ba6d278e375bab5810314
Signed-off-by: Chris Cain <cjcain@us.ibm.com>
  • Loading branch information
cjcain committed Feb 22, 2022
1 parent 1be4337 commit 1718fd8
Showing 1 changed file with 33 additions and 19 deletions.
52 changes: 33 additions & 19 deletions occ_manager.cpp
Expand Up @@ -27,6 +27,8 @@ 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;

Expand Down Expand Up @@ -63,31 +65,43 @@ void Manager::findAndCreateObjects()
createObjects(occ);
}
#else
// Create the OCCs based on on the /dev/occX devices
auto occs = findOCCsInDev();

if (occs.empty() || (prevOCCSearch.size() != occs.size()))
if (!fs::exists(HOST_ON_FILE))
{
// 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;
// Create the OCCs based on on the /dev/occX devices
auto occs = findOCCsInDev();

discoverTimer->restartOnce(10s);
}
else
{
discoverTimer.reset();

// createObjects requires OCC0 first.
std::sort(occs.begin(), occs.end());
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;

for (auto id : occs)
discoverTimer->restartOnce(10s);
}
else
{
createObjects(std::string(OCC_NAME) + std::to_string(id));
discoverTimer.reset();

// createObjects requires OCC0 first.
std::sort(occs.begin(), occs.end());

for (auto id : occs)
{
createObjects(std::string(OCC_NAME) + std::to_string(id));
}
}
}
else
{
log<level::INFO>(
fmt::format(
"Manager::findAndCreateObjects(): Waiting for {} to complete...",
HOST_ON_FILE)
.c_str());
discoverTimer->restartOnce(10s);
}
#endif
}

Expand Down

0 comments on commit 1718fd8

Please sign in to comment.