--- ./source/private_module/bdm/sdm/hdm/hdm_debug.c	2018-02-09 07:36:26.000000000 +0000
+++ ./source/private_module/bdm/sdm/hdm/hdm_debug.c.hotpatch	2020-01-03 02:04:06.000000000 +0000
@@ -1047,7 +1047,7 @@
 
     return RETURN_OK;
 }
-
+int32_t hdmDebugPowerCtrlPatch(int32_t argc, char *argv[]);
 /**************************************************************************
     : ִӲµ
 : argc: 
@@ -1064,27 +1064,27 @@
     uint8_t ctrlFlag = 0;
     int32_t ret;
     HDM_DBG_RESULT_S myContext;
-
+    
+    if(RETURN_OK == hdmDebugPowerCtrlPatch(argc, argv))
+    {
+        return RETURN_OK;
+    }    
     memset(&myContext, 0, sizeof(HDM_DBG_RESULT_S));
     myContext.result = FALSE;
     LVOS_InitCompletion(&myContext.completion);
-    
     if (argc < 5)
     {
         return RETURN_ERROR;
     }
-
     frameId = (uint32_t)LVOS_StrToU64(argv[2]);
     slotId = (uint32_t)LVOS_StrToU64(argv[3]);
     ctrlFlag = (uint8_t)LVOS_StrToU64(argv[4]);
-  
     ret = hdmPowerCtrl(frameId, slotId, ctrlFlag, FALSE, &myContext, hdmDebugResultDone);
     if(BDM_DISK_POWER_RESULT_OK != ret)
     {
         DBG_Print("Send disk power ctrl cmd fail\n");
         return RETURN_OK;
     }
-
     LVOS_WaitForCompletion(&myContext.completion);
     DBG_Print("Disk Power ctrl %s\n", BDM_DISK_POWER_RESULT_OK == myContext.result ? "succeed" : "fail");
     DBG_LogInfo(LOG_ID_HDM_002C, "Somebody set disk(frameId:%u, slot:%u) power ctrl (flag:%u), ret(%u).",
@@ -5991,4 +5991,32 @@
 
 
 
+extern void hdmParseTempParaPatch(uint32_t patchFlag);
+
+/**************************************************************************
+    : ڲ
+: argc: argv: Ĳ
+: 
+  ֵ: RETURN_OK ִгɹ RETURN_ERROR ִʧ
+    : 
+**************************************************************************/
+int32_t hdmDebugPowerCtrlPatch(int32_t argc, char *argv[])
+{
+    uint32_t patchFlag = 0;
+    
+    if (argc != 4 || strcmp(argv[2], "sph018") != 0)
+    {
+        
+        return RETURN_ERROR;
+    }  
+     
+    patchFlag = (uint32_t)LVOS_StrToU64(argv[3]);
+    DBG_LogInfo(LOG_ID_HDM_0324, "HdmSph018: will update hdmTmpPara, flag %d.", patchFlag);
+    hdmParseTempParaPatch(patchFlag);
+    DBG_LogInfo(LOG_ID_HDM_0324, "HdmSph018: complete update hdmTmpPara, flag %d.", patchFlag);
+
+    return RETURN_OK;    
+}
+
+
 
--- ./source/private_module/bdm/sdm/hdm/hdm_disk_config.c	2018-02-09 07:36:26.000000000 +0000
+++ ./source/private_module/bdm/sdm/hdm/hdm_disk_config.c.hotpatch	2020-01-03 02:04:06.000000000 +0000
@@ -1017,7 +1017,7 @@
 {
     g_hdmTmpPara[index].type = type;
 }
-
+extern HDM_TEMP_THRESHOLD_SAVE_S g_tempThreshSavePatch[];
 /**************************************************************************
    : hdmParseThrehdForModel
      : ¶
@@ -1029,7 +1029,7 @@
 **************************************************************************/
 static int32_t hdmParseThrehdForModel(const char *lineBuffer, int32_t  index, DISK_TEMP_THRESH_E type)
 {
-    HDM_TEMP_THRESHOLD_SAVE_S *cfgSave = g_tempThreshSave;
+    HDM_TEMP_THRESHOLD_SAVE_S *cfgSave = g_tempThreshSavePatch;
     const char *linePos = NULL;
     char buffer[HDM_DISK_CONFIG_LINE_LEN];
     int32_t ret = RETURN_OK;
@@ -1249,3 +1249,132 @@
     spin_lock_destroy(&g_diskConfigLock);
 }
 
+HDM_TEMP_THRESHOLD_SAVE_S g_tempThreshSavePatch[] =
+{
+    {"Model",               "=\r\n",    hdmSaveModelName},
+    {"DecTempThresh",       ":\r\n",    hdmSaveDecTempThresh},
+    {"IncTempThresh",       ":\r\n",    hdmSaveIncTempThresh},
+    {"OverDecTempThresh",   ":\r\n",    hdmSaveOverDecTempThresh},
+    {"OverIncTempThresh",   ":\r\n",    hdmSaveOverIncTempThresh},
+    {"",                    "",         NULL}
+};
+
+/*#define HDM_TEMP_THRESH_FILE_PATH_BAK    "/OSM/conf/Disk_Drive_Parameter.ini"*/
+#define HDM_TEMP_THRESH_FILE_PATH_BAK   "/OSM/conf/Disk_Drive_Parameter.ini_origin"
+#define HDM_TMP_PARA_PATCH_FLAG_START   (1)     /*װ*/
+#define HDM_TMP_PARA_PATCH_FLAG_ROLL    (2)     /*жز*/
+
+
+/**************************************************************************
+   : hdmParseTempParaPatchPrint
+     :  ӡļڴֵ
+**************************************************************************/
+void  hdmParseTempParaPatchPrint(void)
+{
+    uint32_t index = 0; 
+
+    if(g_hdmTmpPara == NULL)
+    {
+        return;
+    }
+    
+    for(index = 0; index < HDM_MAXNUM_TEMP_PARA; index++)
+    {
+        DBG_LogInfo(LOG_ID_HDM_0324, "HdmSph018: %s=%d:%d:%d:%d, type %d, index %d.",
+                    g_hdmTmpPara[index].model,
+                    g_hdmTmpPara[index].IncTempThresh,
+                    g_hdmTmpPara[index].DecTempThresh,
+                    g_hdmTmpPara[index].OverIncTempThresh,
+                    g_hdmTmpPara[index].OverDecTempThresh,
+                    g_hdmTmpPara[index].type, index);
+    }
+
+    return;
+}
+
+/**************************************************************************
+   : hdmParseTempParaPatch
+     :  µڴֵ
+**************************************************************************/
+void hdmParseTempParaPatch(uint32_t patchFlag)
+{
+    int32_t fd = 0;
+    int32_t ret = RETURN_OK;
+    char lineBuffer[HDM_DISK_CONFIG_LINE_LEN];
+    char *p = NULL;
+    int32_t  index = 0;
+    DISK_TEMP_THRESH_E type = DISK_TEMP_THRESH_GENERAL;
+    
+    /*װɹ󣬴򿪱µļ*/
+    if (patchFlag == HDM_TMP_PARA_PATCH_FLAG_START)
+    {
+        fd = LVOS_open(HDM_TEMP_THRESH_FILE_PATH, O_BINARY, MODE_EXIST);
+    }   
+    /*жǰ򿪱ݵļ*/
+    else if (patchFlag == HDM_TMP_PARA_PATCH_FLAG_ROLL)
+    {
+        fd = LVOS_open(HDM_TEMP_THRESH_FILE_PATH_BAK, O_BINARY, MODE_EXIST);
+    }
+    /*ֱӷ*/
+    else
+    {
+        DBG_LogError(LOG_ID_HDM_0324, "HdmSph018: para err, flag %d.", patchFlag);
+        return;
+    }
+    
+    if (fd < 0)
+    {   
+        DBG_LogError(LOG_ID_HDM_0324, "HdmSph018: open temperature parameter config file fail, flag %d.", patchFlag);
+        return;
+    }
+
+    memset(g_hdmTmpPara, 0, sizeof(HDM_DISK_TEMP_PARA_S) * HDM_MAXNUM_TEMP_PARA);
+    memset(lineBuffer, 0, HDM_DISK_CONFIG_LINE_LEN);
+
+    /* жȡϢ */
+    for (;;)
+    {
+        p = LVOS_readline(fd, lineBuffer, HDM_DISK_CONFIG_LINE_LEN);
+        if (NULL == p)
+        {
+            break;
+        }
+        lineBuffer[HDM_DISK_CONFIG_LINE_LEN - 1] = '\0';
+        
+        /* лע */
+        if (!hdmTempLineValid(lineBuffer))
+        {
+            hdmGetTempThreshType(lineBuffer, &type); /**/
+            continue;
+        }
+        /*֧Ϊ10*/
+        if (index >= HDM_MAXNUM_TEMP_PARA)
+        {     
+            DBG_LogError(LOG_ID_HDM_0328, "HdmSph018: Reserved buffer for temp para is not enough.");            
+            break;          
+        }
+        /*ݣֵg_hdmTmpParaӦֶ*/
+        if (RETURN_ERROR == hdmParseThrehdForModel(lineBuffer, index, type))
+        {       
+            DBG_LogError(LOG_ID_HDM_0327, "HdmSph018: Parse temp threshold file fail.");        
+            break;        
+        }
+
+        index++;
+    }
+   
+
+    /*ɣرļ*/
+    ret = LVOS_close(fd);
+    if (unlikely(RETURN_OK != ret))
+    {
+        DBG_LogError(LOG_ID_HDM_0359, "HdmSph018: Close temp threshold file fail.");
+    }
+
+    /*ӡg_hdmTmpParaĵǰڴֵ*/
+    hdmParseTempParaPatchPrint();
+    return;  
+}
+
+
+
--- ./source/private_module/bdm/sdm/hdm/stub_v3/stub_hdm_routine.c	2018-03-30 08:15:22.000000000 +0000
+++ ./source/private_module/bdm/sdm/hdm/stub_v3/stub_hdm_routine.c.hotpatch	2020-01-03 02:04:06.000000000 +0000
@@ -2105,26 +2105,26 @@
     uint32_t r = 0;
     uint32_t slot = 0;
     uint32_t cnt = 0;
-    DMI_SINGLE_DISK_TEMP_INFO_S *tmpBuf = buf;
-
+    DMI_SINGLE_DISK_TEMP_INFO_S tmpBuf;
+    int16_t maxTemper = -32768;  //int16Сֵ
     for (r = 0; r < rowMax; r++)
     {
         for (c = columnFirst; c <= columnLast; c++)
         {
             slot = r * HDM_LF_COLUMN_SLOT_MAX + c;
-            if (hdmRtFillDiskTemperatureInfo(wwn, slot, tmpBuf))
+            if (hdmRtFillDiskTemperatureInfo(wwn, slot, &tmpBuf))
             {
-                cnt++;
-                tmpBuf++;
+                cnt = 1;
+                if (tmpBuf.DiskSmartTemp > maxTemper) {
+                    maxTemper = tmpBuf.DiskSmartTemp;
+                    memcpy(buf, &tmpBuf, sizeof(DMI_SINGLE_DISK_TEMP_INFO_S)); }
+                DBG_LogDebug(LOG_ID_HDM_0329, "Disk slot(%u) with temperature %d, and max temperature is %d.",
+                             tmpBuf.DiskSlot, tmpBuf.DiskSmartTemp, maxTemper);
             }
         }
     }
-
-    if (cnt > HDM_LF_ONE_CYCLE_DISK_MAX)
-    {
-        cnt = HDM_LF_ONE_CYCLE_DISK_MAX;
-    }
-
+    /*ÿ15Ӳ̣BDMÿ·ĳӲ¶ʱֱ·15Ӳ¶Ϣ
+    15Ӳ¶ߵһӲ¶ϢͨDMI·SES*/
     return cnt;
 }
 
