Commit 3dcfe179 authored by Vadim Pasternak's avatar Vadim Pasternak Committed by David S. Miller

mlxsw: core: Set different thermal polling time based on bus frequency capability

Add low frequency bus capability in order to allow core functionality
separation based on bus type. Driver could run over PCIe, which is
considered as high frequency bus or I2C, which is considered as low
frequency bus. In the last case time setting, for example, for thermal
polling interval, should be increased.

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: default avatarVadim Pasternak <vadimp@mellanox.com>
Reviewed-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d93c19a1
...@@ -344,6 +344,7 @@ struct mlxsw_bus_info { ...@@ -344,6 +344,7 @@ struct mlxsw_bus_info {
struct mlxsw_fw_rev fw_rev; struct mlxsw_fw_rev fw_rev;
u8 vsd[MLXSW_CMD_BOARDINFO_VSD_LEN]; u8 vsd[MLXSW_CMD_BOARDINFO_VSD_LEN];
u8 psid[MLXSW_CMD_BOARDINFO_PSID_LEN]; u8 psid[MLXSW_CMD_BOARDINFO_PSID_LEN];
u8 low_frequency;
}; };
struct mlxsw_hwmon; struct mlxsw_hwmon;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "core.h" #include "core.h"
#define MLXSW_THERMAL_POLL_INT 1000 /* ms */ #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_TEMP 110000 /* 110C */
#define MLXSW_THERMAL_MAX_STATE 10 #define MLXSW_THERMAL_MAX_STATE 10
#define MLXSW_THERMAL_MAX_DUTY 255 #define MLXSW_THERMAL_MAX_DUTY 255
...@@ -76,6 +77,7 @@ struct mlxsw_thermal { ...@@ -76,6 +77,7 @@ struct mlxsw_thermal {
struct mlxsw_core *core; struct mlxsw_core *core;
const struct mlxsw_bus_info *bus_info; const struct mlxsw_bus_info *bus_info;
struct thermal_zone_device *tzdev; struct thermal_zone_device *tzdev;
int polling_delay;
struct thermal_cooling_device *cdevs[MLXSW_MFCR_PWMS_MAX]; struct thermal_cooling_device *cdevs[MLXSW_MFCR_PWMS_MAX];
u8 cooling_levels[MLXSW_THERMAL_MAX_STATE + 1]; u8 cooling_levels[MLXSW_THERMAL_MAX_STATE + 1];
struct mlxsw_thermal_trip trips[MLXSW_THERMAL_NUM_TRIPS]; struct mlxsw_thermal_trip trips[MLXSW_THERMAL_NUM_TRIPS];
...@@ -172,7 +174,7 @@ static int mlxsw_thermal_set_mode(struct thermal_zone_device *tzdev, ...@@ -172,7 +174,7 @@ static int mlxsw_thermal_set_mode(struct thermal_zone_device *tzdev,
mutex_lock(&tzdev->lock); mutex_lock(&tzdev->lock);
if (mode == THERMAL_DEVICE_ENABLED) if (mode == THERMAL_DEVICE_ENABLED)
tzdev->polling_delay = MLXSW_THERMAL_POLL_INT; tzdev->polling_delay = thermal->polling_delay;
else else
tzdev->polling_delay = 0; tzdev->polling_delay = 0;
...@@ -423,13 +425,17 @@ int mlxsw_thermal_init(struct mlxsw_core *core, ...@@ -423,13 +425,17 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
thermal->cooling_levels[i] = max(MLXSW_THERMAL_SPEED_MIN_LEVEL, thermal->cooling_levels[i] = max(MLXSW_THERMAL_SPEED_MIN_LEVEL,
i); i);
thermal->polling_delay = bus_info->low_frequency ?
MLXSW_THERMAL_SLOW_POLL_INT :
MLXSW_THERMAL_POLL_INT;
thermal->tzdev = thermal_zone_device_register("mlxsw", thermal->tzdev = thermal_zone_device_register("mlxsw",
MLXSW_THERMAL_NUM_TRIPS, MLXSW_THERMAL_NUM_TRIPS,
MLXSW_THERMAL_TRIP_MASK, MLXSW_THERMAL_TRIP_MASK,
thermal, thermal,
&mlxsw_thermal_ops, &mlxsw_thermal_ops,
NULL, 0, NULL, 0,
MLXSW_THERMAL_POLL_INT); thermal->polling_delay);
if (IS_ERR(thermal->tzdev)) { if (IS_ERR(thermal->tzdev)) {
err = PTR_ERR(thermal->tzdev); err = PTR_ERR(thermal->tzdev);
dev_err(dev, "Failed to register thermal zone\n"); dev_err(dev, "Failed to register thermal zone\n");
......
...@@ -503,6 +503,7 @@ static int mlxsw_i2c_probe(struct i2c_client *client, ...@@ -503,6 +503,7 @@ static int mlxsw_i2c_probe(struct i2c_client *client,
mlxsw_i2c->bus_info.device_kind = id->name; mlxsw_i2c->bus_info.device_kind = id->name;
mlxsw_i2c->bus_info.device_name = client->name; mlxsw_i2c->bus_info.device_name = client->name;
mlxsw_i2c->bus_info.dev = &client->dev; mlxsw_i2c->bus_info.dev = &client->dev;
mlxsw_i2c->bus_info.low_frequency = true;
mlxsw_i2c->dev = &client->dev; mlxsw_i2c->dev = &client->dev;
err = mlxsw_core_bus_device_register(&mlxsw_i2c->bus_info, err = mlxsw_core_bus_device_register(&mlxsw_i2c->bus_info,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment