1
0
mirror of https://github.com/corundum/corundum.git synced 2025-02-06 08:38:23 +08:00

Retry hot reset a few times if necessary

This commit is contained in:
Alex Forencich 2021-09-13 13:51:36 -07:00
parent 5435db91cb
commit 3d64e5fc30

View File

@ -1250,6 +1250,8 @@ int main(int argc, char *argv[])
sleep(1); sleep(1);
for (int tries = 5; tries > 0; tries--)
{
printf("Performing hot reset on upstream port...\n"); printf("Performing hot reset on upstream port...\n");
pcie_hot_reset(port_path); pcie_hot_reset(port_path);
@ -1269,9 +1271,16 @@ int main(int argc, char *argv[])
// PCIe device will have a config space, so check for that // PCIe device will have a config space, so check for that
snprintf(path, sizeof(path), "%s/config", device_path); snprintf(path, sizeof(path), "%s/config", device_path);
if (access(path, F_OK) != -1) if (access(path, F_OK) == 0)
{ {
printf("Success, device is online!\n"); printf("Success, device is online!\n");
break;
}
else
{
if (tries > 0)
{
printf("Rescan failed, attempting another reset (up to %d more)\n", tries);
} }
else else
{ {
@ -1280,6 +1289,9 @@ int main(int argc, char *argv[])
goto err; goto err;
} }
} }
}
}
err: err: