/** @file\r
Library functions which relates with driver health.\r
\r
-Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
\r
Status = ComponentName->GetControllerName (\r
ComponentName,\r
- ControllerHandle, \r
+ ControllerHandle,\r
ChildHandle,\r
BestLanguage,\r
&ControllerName\r
\r
ControllerName = BmGetControllerName (\r
DriverHealthInfo->DriverHealthHandle,\r
- DriverHealthInfo->ControllerHandle, \r
+ DriverHealthInfo->ControllerHandle,\r
DriverHealthInfo->ChildHandle\r
);\r
\r
\r
/**\r
Collect the Driver Health status of a single controller.\r
- \r
+\r
@param DriverHealthInfo A pointer to the array containing all of the platform driver health information.\r
@param Count Return the updated array count.\r
@param DriverHealthHandle The handle on which the Driver Health protocol instance is retrieved.\r
(VOID **) &DriverHealth\r
);\r
ASSERT_EFI_ERROR (Status);\r
- \r
+\r
\r
if (ControllerHandle == NULL) {\r
//\r
EFI_STATUS Status;\r
UINTN NumHandles;\r
EFI_HANDLE *DriverHealthHandles;\r
- EFI_DRIVER_HEALTH_STATUS HealthStatus;\r
UINTN DriverHealthIndex;\r
EFI_HANDLE *Handles;\r
UINTN HandleCount;\r
NumHandles = 0;\r
HandleCount = 0;\r
\r
- HealthStatus = EfiDriverHealthStatusHealthy;\r
-\r
Status = gBS->LocateHandleBuffer (\r
ByProtocol,\r
&gEfiDriverHealthProtocolGuid,\r
\r
/**\r
Repair all the controllers according to the Driver Health status queried.\r
+\r
+ @param ReconnectRepairCount To record the number of recursive call of\r
+ this function itself.\r
**/\r
VOID\r
BmRepairAllControllers (\r
- VOID\r
+ UINTN ReconnectRepairCount\r
)\r
{\r
EFI_STATUS Status;\r
BOOLEAN RebootRequired;\r
EFI_HII_HANDLE *HiiHandles;\r
EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2;\r
+ UINT32 MaxRepairCount;\r
+ UINT32 RepairCount;\r
\r
//\r
// Configure PcdDriverHealthConfigureForm to ZeroGuid to disable driver health check.\r
//\r
- if (CompareGuid (PcdGetPtr (PcdDriverHealthConfigureForm), &gZeroGuid)) {\r
+ if (IsZeroGuid (PcdGetPtr (PcdDriverHealthConfigureForm))) {\r
return;\r
}\r
\r
Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &FormBrowser2);\r
ASSERT_EFI_ERROR (Status);\r
\r
+ MaxRepairCount = PcdGet32 (PcdMaxRepairCount);\r
+ RepairCount = 0;\r
+\r
do {\r
RepairRequired = FALSE;\r
ConfigurationRequired = FALSE;\r
if (DriverHealthInfo[Index].HealthStatus == EfiDriverHealthStatusConfigurationRequired) {\r
ConfigurationRequired = TRUE;\r
}\r
- \r
+\r
if (DriverHealthInfo[Index].HealthStatus == EfiDriverHealthStatusRepairRequired) {\r
RepairRequired = TRUE;\r
\r
FreePool (HiiHandles);\r
}\r
}\r
- \r
+\r
EfiBootManagerFreeDriverHealthInfo (DriverHealthInfo, Count);\r
- } while (RepairRequired || ConfigurationRequired);\r
+ RepairCount++;\r
+ } while ((RepairRequired || ConfigurationRequired) && ((MaxRepairCount == 0) || (RepairCount < MaxRepairCount)));\r
\r
RebootRequired = FALSE;\r
ReconnectRequired = FALSE;\r
EfiBootManagerFreeDriverHealthInfo (DriverHealthInfo, Count);\r
\r
\r
- if (ReconnectRequired) {\r
- BmRepairAllControllers ();\r
- }\r
-\r
DEBUG_CODE (\r
CHAR16 *ControllerName;\r
\r
EfiBootManagerFreeDriverHealthInfo (DriverHealthInfo, Count);\r
);\r
\r
+ if (ReconnectRequired) {\r
+ if (ReconnectRepairCount < MAX_RECONNECT_REPAIR) {\r
+ BmRepairAllControllers (ReconnectRepairCount + 1);\r
+ } else {\r
+ DEBUG ((DEBUG_ERROR, "[%a:%d] Repair failed after %d retries.\n",\r
+ __FUNCTION__, __LINE__, ReconnectRepairCount));\r
+ }\r
+ }\r
+\r
if (RebootRequired) {\r
DEBUG ((EFI_D_INFO, "[BDS] One of the Driver Health instances requires rebooting.\n"));\r
gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);\r