-
Notifications
You must be signed in to change notification settings - Fork 215
Expand file tree
/
Copy path0037-mlxsw-i2c-Limit-single-transaction-buffer-size.patch
More file actions
57 lines (48 loc) · 1.95 KB
/
0037-mlxsw-i2c-Limit-single-transaction-buffer-size.patch
File metadata and controls
57 lines (48 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
From 1a589f97c28418f9d50b8efa25e6e437dfc700e3 Mon Sep 17 00:00:00 2001
From: Vadim Pasternak <vadimp@nvidia.com>
Date: Mon, 14 Aug 2023 10:44:41 +0000
Subject: [PATH backport v6.1 37/41] mlxsw: i2c: Limit single transaction
buffer size
Link: https://github.com/jpirko/linux_mlxsw/commit/162fc0c49b08baf613b1fba211f4d9852845b5b8
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.
Fixes: 3029a693beda ("mlxsw: i2c: Allow flexible setting of I2C transactions size")
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
---
drivers/net/ethernet/mellanox/mlxsw/i2c.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/i2c.c b/drivers/net/ethernet/mellanox/mlxsw/i2c.c
index 26e05f129e35..d9a71ad9adae 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/i2c.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/i2c.c
@@ -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,9 +654,10 @@ static int mlxsw_i2c_probe(struct i2c_client *client,
return -EOPNOTSUPP;
}
- mlxsw_i2c->block_size = max_t(u16, MLXSW_I2C_BLK_DEF,
- min_t(u16, quirks->max_read_len,
- quirks->max_write_len));
+ mlxsw_i2c->block_size = min_t(u16, min_t(u16, quirks->max_read_len,
+ quirks->max_write_len),
+ MLXSW_I2C_BLK_MAX);
+
} else {
mlxsw_i2c->block_size = MLXSW_I2C_BLK_DEF;
}
--
2.20.1