From 1d6448567122a53530f8cc588f34787db11c707e Mon Sep 17 00:00:00 2001 From: Zi Zhou Date: Tue, 17 Apr 2018 22:29:59 -0700 Subject: [PATCH] Retry fan speed read when we see zero RPM, to make sure it's not a glitch --- .../builds/x86-64-accton-as6812-32x-fan.c | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-fan.c index f0555674..43d3fe32 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-fan.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-fan.c @@ -32,6 +32,7 @@ #include #include #include +#include #define FAN_MAX_NUMBER 5 #define FAN_SPEED_CPLD_TO_RPM_STEP 150 @@ -268,7 +269,7 @@ static int accton_as6812_32x_fan_write_value(u8 reg, u8 value) static void accton_as6812_32x_fan_update_device(struct device *dev) { int speed, r_speed, fault, r_fault, direction, ctrl_speed; - int i; + int i, retry_count; mutex_lock(&fan_data->update_lock); @@ -298,6 +299,7 @@ static void accton_as6812_32x_fan_update_device(struct device *dev) for (i = 0; i < FAN_MAX_NUMBER; i++) { + retry_count = 5; /* Update fan data */ @@ -314,12 +316,21 @@ static void accton_as6812_32x_fan_update_device(struct device *dev) /* fan speed */ - speed = accton_as6812_32x_fan_read_value(fan_speed_reg[i]); - r_speed = accton_as6812_32x_fan_read_value(fanr_speed_reg[i]); - if ( (speed < 0) || (r_speed < 0) ) - { - DEBUG_PRINT("[Error!!][%s][%d] \n", __FUNCTION__, __LINE__); - goto _exit; /* error */ + while (retry_count) { + retry_count--; + speed = accton_as6812_32x_fan_read_value(fan_speed_reg[i]); + r_speed = accton_as6812_32x_fan_read_value(fanr_speed_reg[i]); + if ( (speed < 0) || (r_speed < 0) ) + { + DEBUG_PRINT("[Error!!][%s][%d] \n", __FUNCTION__, __LINE__); + goto _exit; /* error */ + } + if ( (speed == 0) || (r_speed == 0) ) + { + msleep(200); + continue; + } + break; } DEBUG_PRINT("[fan%d:] speed:%d, r_speed=%d \n", i, speed, r_speed);