From 6ff3e00062b894a880937ce41f748e26105b579a Mon Sep 17 00:00:00 2001 From: Caleb Palmer Date: Tue, 21 Jul 2015 09:56:08 -0500 Subject: PRD: Improve MDIA Timeout Design Change-Id: Ia622a1285469ffe405ec2ce7435f2445f8ec1ac7 RTC: 127342 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/19199 Tested-by: Jenkins Server Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Tested-by: FSP CI Jenkins Reviewed-by: Zane Shelley Reviewed-by: A. Patrick Williams III --- src/usr/diag/mdia/mdiamonitor.H | 9 ++++++++- src/usr/diag/mdia/mdiasm.C | 21 +++++++++++++-------- 2 files changed, 21 insertions(+), 9 deletions(-) (limited to 'src/usr') diff --git a/src/usr/diag/mdia/mdiamonitor.H b/src/usr/diag/mdia/mdiamonitor.H index eef7d2ebb..bc2b8b771 100755 --- a/src/usr/diag/mdia/mdiamonitor.H +++ b/src/usr/diag/mdia/mdiamonitor.H @@ -5,7 +5,9 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* COPYRIGHT International Business Machines Corp. 2012,2014 */ +/* Contributors Listed Below - COPYRIGHT 2012,2015 */ +/* [+] International Business Machines Corp. */ +/* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ /* you may not use this file except in compliance with the License. */ @@ -86,6 +88,11 @@ class CommandMonitor */ virtual ~CommandMonitor(); + /** + * @brief invalid monitor id + */ + static const uint64_t INVALID_MONITOR_ID = 0; + protected: /** diff --git a/src/usr/diag/mdia/mdiasm.C b/src/usr/diag/mdia/mdiasm.C index 4e5b6b85d..c879fc42b 100644 --- a/src/usr/diag/mdia/mdiasm.C +++ b/src/usr/diag/mdia/mdiasm.C @@ -819,9 +819,7 @@ errlHndl_t StateMachine::doMaintCommand(WorkFlowProperties & i_wfp) mutex_lock(&iv_mutex); - uint64_t monitorId = getMonitor().addMonitor(mbaTO); - - i_wfp.timer = monitorId; + uint64_t monitorId = CommandMonitor::INVALID_MONITOR_ID; i_wfp.timeoutCnt = 0; // reset for new work item workItem = *i_wfp.workItem; restart = i_wfp.restartCommand; @@ -1010,10 +1008,17 @@ errlHndl_t StateMachine::doMaintCommand(WorkFlowProperties & i_wfp) // Command and address configured. // Invoke the command. - fapirc = cmd->setupAndExecuteCmd(); err = fapiRcToErrl(fapirc); + // Start a timeout monitor + mutex_lock(&iv_mutex); + + monitorId = getMonitor().addMonitor(mbaTO); + i_wfp.timer = monitorId; + + mutex_unlock(&iv_mutex); + if(err) { MDIA_FAST("sm: setupAndExecuteCmd %p failed", cmd); @@ -1022,18 +1027,18 @@ errlHndl_t StateMachine::doMaintCommand(WorkFlowProperties & i_wfp) } while(0); - mutex_lock(&iv_mutex); - if(err) { + mutex_lock(&iv_mutex); + MDIA_FAST("sm: Running Maint Cmd failed"); getMonitor().removeMonitor(monitorId); i_wfp.data = NULL; - } - mutex_unlock(&iv_mutex); + mutex_unlock(&iv_mutex); + } if(err && cmd) { -- cgit v1.2.1