Skip to content

Commit 146c7c3

Browse files
vadimp-nvidiadavem330
authored andcommitted
mlxsw: i2c: Fix chunk size setting in output mailbox buffer
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(). Fixes: 3029a69 ("mlxsw: i2c: Allow flexible setting of I2C transactions size") Signed-off-by: Vadim Pasternak <vadimp@nvidia.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: Petr Machata <petrm@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 786c96e commit 146c7c3

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • drivers/net/ethernet/mellanox/mlxsw

drivers/net/ethernet/mellanox/mlxsw/i2c.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ mlxsw_i2c_cmd(struct device *dev, u16 opcode, u32 in_mod, size_t in_mbox_size,
444444
} else {
445445
/* No input mailbox is case of initialization query command. */
446446
reg_size = MLXSW_I2C_MAX_DATA_SIZE;
447-
num = reg_size / mlxsw_i2c->block_size;
447+
num = DIV_ROUND_UP(reg_size, mlxsw_i2c->block_size);
448448

449449
if (mutex_lock_interruptible(&mlxsw_i2c->cmd.lock) < 0) {
450450
dev_err(&client->dev, "Could not acquire lock");

0 commit comments

Comments
 (0)