Use different thermal monitoring based on bus type.
For I2C bus time is set to 20 seconds, while for PCIe 1 second polling
interval is used.

Signed-off-by: Vadim Pasternak <vad...@mellanox.com>
Acked-by: Jiri Pirko <j...@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c 
b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
index d866c98..152591d8 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
@@ -41,6 +41,7 @@
 #include "core.h"
 
 #define MLXSW_THERMAL_POLL_INT 1000    /* ms */
+#define MLXSW_THERMAL_SLOW_POLL_INT    20000   /* ms */
 #define MLXSW_THERMAL_MAX_TEMP 110000  /* 110C */
 #define MLXSW_THERMAL_MAX_STATE        10
 #define MLXSW_THERMAL_MAX_DUTY 255
@@ -95,6 +96,7 @@ struct mlxsw_thermal {
        struct mlxsw_core *core;
        const struct mlxsw_bus_info *bus_info;
        struct thermal_zone_device *tzdev;
+       int polling_delay;
        struct thermal_cooling_device *cdevs[MLXSW_MFCR_PWMS_MAX];
        struct mlxsw_thermal_trip trips[MLXSW_THERMAL_NUM_TRIPS];
        enum thermal_device_mode mode;
@@ -190,7 +192,7 @@ static int mlxsw_thermal_set_mode(struct 
thermal_zone_device *tzdev,
        mutex_lock(&tzdev->lock);
 
        if (mode == THERMAL_DEVICE_ENABLED)
-               tzdev->polling_delay = MLXSW_THERMAL_POLL_INT;
+               tzdev->polling_delay = thermal->polling_delay;
        else
                tzdev->polling_delay = 0;
 
@@ -397,13 +399,18 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
                }
        }
 
+       if (bus_info->low_frequency)
+               thermal->polling_delay = MLXSW_THERMAL_SLOW_POLL_INT;
+       else
+               thermal->polling_delay = MLXSW_THERMAL_POLL_INT;
+
        thermal->tzdev = thermal_zone_device_register("mlxsw",
                                                      MLXSW_THERMAL_NUM_TRIPS,
                                                      MLXSW_THERMAL_TRIP_MASK,
                                                      thermal,
                                                      &mlxsw_thermal_ops,
                                                      NULL, 0,
-                                                     MLXSW_THERMAL_POLL_INT);
+                                                     thermal->polling_delay);
        if (IS_ERR(thermal->tzdev)) {
                err = PTR_ERR(thermal->tzdev);
                dev_err(dev, "Failed to register thermal zone\n");
-- 
2.1.4

Reply via email to