diff mbox series

[net-next,2/8] bnxt_en: Fix invoking hwmon_notify_event

Message ID 20231020212757.173551-3-michael.chan@broadcom.com (mailing list archive)
State Accepted
Commit fd78ec3fbc470d33c42a312fd22506e3f3704374
Delegated to: Netdev Maintainers
Headers show
Series bnxt_en: Update for net-next | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1363 this patch: 1363
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 1388 this patch: 1388
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1390 this patch: 1390
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 35 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Michael Chan Oct. 20, 2023, 9:27 p.m. UTC
From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

FW sends the async event to the driver when the device temperature goes
above or below the threshold values.  Only notify hwmon if the
temperature is increasing to the next alert level, not when it is
decreasing.

Cc: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Kashyap Desai <kashyap.desai@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

Comments

Guenter Roeck Oct. 22, 2023, 3:52 p.m. UTC | #1
On 10/20/23 14:27, Michael Chan wrote:
> From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> 
> FW sends the async event to the driver when the device temperature goes
> above or below the threshold values.  Only notify hwmon if the
> temperature is increasing to the next alert level, not when it is
> decreasing.
> 
> Cc: Guenter Roeck <linux@roeck-us.net>
> Reviewed-by: Kashyap Desai <kashyap.desai@broadcom.com>
> Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
> Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> Signed-off-by: Michael Chan <michael.chan@broadcom.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   drivers/net/ethernet/broadcom/bnxt/bnxt.c | 16 +++++++++++-----
>   1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 7837e22f237b..65092150d451 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -2166,6 +2166,7 @@ static bool bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2)
>   	case ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_THERMAL_THRESHOLD: {
>   		u32 type = EVENT_DATA1_THERMAL_THRESHOLD_TYPE(data1);
>   		char *threshold_type;
> +		bool notify = false;
>   		char *dir_str;
>   
>   		switch (type) {
> @@ -2185,18 +2186,23 @@ static bool bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2)
>   			netdev_err(bp->dev, "Unknown Thermal threshold type event\n");
>   			return false;
>   		}
> -		if (EVENT_DATA1_THERMAL_THRESHOLD_DIR_INCREASING(data1))
> +		if (EVENT_DATA1_THERMAL_THRESHOLD_DIR_INCREASING(data1)) {
>   			dir_str = "above";
> -		else
> +			notify = true;
> +		} else {
>   			dir_str = "below";
> +		}
>   		netdev_warn(bp->dev, "Chip temperature has gone %s the %s thermal threshold!\n",
>   			    dir_str, threshold_type);
>   		netdev_warn(bp->dev, "Temperature (In Celsius), Current: %lu, threshold: %lu\n",
>   			    BNXT_EVENT_THERMAL_CURRENT_TEMP(data2),
>   			    BNXT_EVENT_THERMAL_THRESHOLD_TEMP(data2));
> -		bp->thermal_threshold_type = type;
> -		set_bit(BNXT_THERMAL_THRESHOLD_SP_EVENT, &bp->sp_event);
> -		return true;
> +		if (notify) {
> +			bp->thermal_threshold_type = type;
> +			set_bit(BNXT_THERMAL_THRESHOLD_SP_EVENT, &bp->sp_event);
> +			return true;
> +		}
> +		return false;
>   	}
>   	default:
>   		netdev_err(bp->dev, "FW reported unknown error type %u\n",
diff mbox series

Patch

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 7837e22f237b..65092150d451 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -2166,6 +2166,7 @@  static bool bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2)
 	case ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_THERMAL_THRESHOLD: {
 		u32 type = EVENT_DATA1_THERMAL_THRESHOLD_TYPE(data1);
 		char *threshold_type;
+		bool notify = false;
 		char *dir_str;
 
 		switch (type) {
@@ -2185,18 +2186,23 @@  static bool bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2)
 			netdev_err(bp->dev, "Unknown Thermal threshold type event\n");
 			return false;
 		}
-		if (EVENT_DATA1_THERMAL_THRESHOLD_DIR_INCREASING(data1))
+		if (EVENT_DATA1_THERMAL_THRESHOLD_DIR_INCREASING(data1)) {
 			dir_str = "above";
-		else
+			notify = true;
+		} else {
 			dir_str = "below";
+		}
 		netdev_warn(bp->dev, "Chip temperature has gone %s the %s thermal threshold!\n",
 			    dir_str, threshold_type);
 		netdev_warn(bp->dev, "Temperature (In Celsius), Current: %lu, threshold: %lu\n",
 			    BNXT_EVENT_THERMAL_CURRENT_TEMP(data2),
 			    BNXT_EVENT_THERMAL_THRESHOLD_TEMP(data2));
-		bp->thermal_threshold_type = type;
-		set_bit(BNXT_THERMAL_THRESHOLD_SP_EVENT, &bp->sp_event);
-		return true;
+		if (notify) {
+			bp->thermal_threshold_type = type;
+			set_bit(BNXT_THERMAL_THRESHOLD_SP_EVENT, &bp->sp_event);
+			return true;
+		}
+		return false;
 	}
 	default:
 		netdev_err(bp->dev, "FW reported unknown error type %u\n",