mlxsw: Assorted fixes
Subsystems (3)
Petr Machata
maintainercover mlxsw: Assorted fixes
This patchset contains several fixes for the mlxsw driver.
Patch #1 - Fixes buffer size in I2C mailbox buffer. Patch #2 - Sets limitation of chunk size in I2C transaction. Patch #3 - Fixes module label names based on MTCAP sensor counter
Vadim Pasternak (3):
mlxsw: i2c: Fix chunk size setting in output mailbox buffer
mlxsw: i2c: Limit single transaction buffer size
mlxsw: core_hwmon: Adjust module label names based on MTCAP sensor
counter
drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c | 3 ++- drivers/net/ethernet/mellanox/mlxsw/i2c.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-)
Signature · 1 line
2.41.0
Petr Machata
maintainerPATCH 1/3 mlxsw: i2c: Fix chunk size setting in output mailbox buffer
From: Vadim Pasternak <[email protected]>
The driver reads commands output from the output mailbox. If the size of the output mailbox is not a multiple of the transaction / block size, then the driver will not issue enough read transactions to read the entire output, which can result in driver initialization errors.
Fix by determining the number of transactions using DIV_ROUND_UP().
--- drivers/net/ethernet/mellanox/mlxsw/i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/i2c.c +1 -1
@@ -444,7 +444,7 @@ mlxsw_i2c_cmd(struct device *dev, u16 opcode, u32 in_mod, size_t in_mbox_size, }else {/* No input mailbox is case of initialization query command. */ reg_size =MLXSW_I2C_MAX_DATA_SIZE ; - num = reg_size / mlxsw_i2c->block_size; + num =DIV_ROUND_UP (reg_size, mlxsw_i2c->block_size);if (mutex_lock_interruptible (&mlxsw_i2c->cmd.lock) <0 ) {dev_err (&client->dev,"Could not acquire lock" );
Signature · 1 line
2.41.0
Petr Machata
maintainerPATCH 2/3 mlxsw: i2c: Limit single transaction buffer size
In reply to Petr MachataFrom: Vadim Pasternak <[email protected]>
Maximum size of buffer is obtained from underlying I2C adapter and in case adapter allows I2C transaction buffer size greater than 100 bytes, transaction will fail due to firmware limitation.
As a result driver will fail initialization.
Limit the maximum size of transaction buffer by 100 bytes to fit to firmware.
Remove unnecessary calculation:max_t(u16, MLXSW_I2C_BLK_DEF, quirk_size).
This condition can not happened.
--- drivers/net/ethernet/mellanox/mlxsw/i2c.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/i2c.c +2 -1
@@ -48,6 +48,7 @@#define MLXSW_I2C_MBOX_SIZE_BITS 12#define MLXSW_I2C_ADDR_BUF_SIZE 4#define MLXSW_I2C_BLK_DEF 32 +#define MLXSW_I2C_BLK_MAX 100#define MLXSW_I2C_RETRY 5#define MLXSW_I2C_TIMEOUT_MSECS 5000#define MLXSW_I2C_MAX_DATA_SIZE 256
@@ -653,7 +654,7 @@ static int mlxsw_i2c_probe(struct i2c_client *client)return -EOPNOTSUPP ; } - mlxsw_i2c->block_size =max_t (u16,MLXSW_I2C_BLK_DEF , + mlxsw_i2c->block_size =min_t (u16,MLXSW_I2C_BLK_MAX ,min_t (u16, quirks->max_read_len, quirks->max_write_len)); }else {
Signature · 1 line
2.41.0
Petr Machata
maintainerPATCH 3/3 mlxsw: core_hwmon: Adjust module label names based on MTCAP sensor counter
In reply to Petr MachataFrom: Vadim Pasternak <[email protected]>
Transceiver module temperature sensors are indexed after ASIC and platform sensors. The current label printing method does not take this into account and simply prints the index of the transceiver module sensor.
On new systems that have platform sensors this results in incorrect (shifted) transceiver module labels being printed:
$ sensors [...] front panel 002: +37.0°C (crit = +70.0°C, emerg = +75.0°C) front panel 003: +47.0°C (crit = +70.0°C, emerg = +75.0°C) [...]
Fix by taking the sensor count into account. After the fix:
$ sensors [...] front panel 001: +37.0°C (crit = +70.0°C, emerg = +75.0°C) front panel 002: +47.0°C (crit = +70.0°C, emerg = +75.0°C) [...]
--- drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +2 -1
@@ -405,7 +405,8 @@ mlxsw_hwmon_module_temp_label_show(struct device *dev, container_of(attr, struct mlxsw_hwmon_attr, dev_attr);return sprintf (buf,"front panel %03u\n" , - mlxsw_hwmon_attr->type_index); + mlxsw_hwmon_attr->type_index +1 - + mlxsw_hwmon_attr->mlxsw_hwmon_dev->sensor_count); } static ssize_t
Signature · 1 line
2.41.0
This series was applied to netdev/net.git (main) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:
Quoted 6 lines · On Thu, 24 Aug 2023 15:43:07 +0200 you wrote:
This patchset contains several fixes for the mlxsw driver.
Patch #1 - Fixes buffer size in I2C mailbox buffer. Patch #2 - Sets limitation of chunk size in I2C transaction. Patch #3 - Fixes module label names based on MTCAP sensor counter
Quoted 7 lines
Vadim Pasternak (3):
mlxsw: i2c: Fix chunk size setting in output mailbox buffer
mlxsw: i2c: Limit single transaction buffer size
mlxsw:core_hwmon: Adjust module label names based on MTCAP sensor
counter[...]
Here is the summary with links:
- [net,1/3] mlxsw: i2c: Fix chunk size setting in output mailbox buffer
https://git.kernel.org/netdev/net/c/146c7c330507 - [net,2/3] mlxsw: i2c: Limit single transaction buffer size https://git.kernel.org/netdev/net/c/d7248f1cc835 - [net,3/3] mlxsw: core_hwmon: Adjust module label names based on MTCAP sensor counter https://git.kernel.org/netdev/net/c/3fc134a07438
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html