* [PATCH] net: mctp-i2c: fix duplicate reception of old data
@ 2026-01-08 10:18 Jian Zhang
2026-01-09 0:07 ` Jeremy Kerr
2026-01-13 3:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 4+ messages in thread
From: Jian Zhang @ 2026-01-08 10:18 UTC (permalink / raw)
To: Jeremy Kerr, Matt Johnston, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
The MCTP I2C slave callback did not handle I2C_SLAVE_READ_REQUESTED
events. As a result, i2c read event will trigger repeated reception of
old data, reset rx_pos when a read request is received.
Signed-off-by: Jian Zhang <zhangjian.3032@bytedance.com>
---
drivers/net/mctp/mctp-i2c.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/mctp/mctp-i2c.c b/drivers/net/mctp/mctp-i2c.c
index f782d93f826e..ecda1cc36391 100644
--- a/drivers/net/mctp/mctp-i2c.c
+++ b/drivers/net/mctp/mctp-i2c.c
@@ -242,6 +242,9 @@ static int mctp_i2c_slave_cb(struct i2c_client *client,
return 0;
switch (event) {
+ case I2C_SLAVE_READ_REQUESTED:
+ midev->rx_pos = 0;
+ break;
case I2C_SLAVE_WRITE_RECEIVED:
if (midev->rx_pos < MCTP_I2C_BUFSZ) {
midev->rx_buffer[midev->rx_pos] = *val;
@@ -279,6 +282,9 @@ static int mctp_i2c_recv(struct mctp_i2c_dev *midev)
size_t recvlen;
int status;
+ if (midev->rx_pos == 0)
+ return 0;
+
/* + 1 for the PEC */
if (midev->rx_pos < MCTP_I2C_MINLEN + 1) {
ndev->stats.rx_length_errors++;
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] net: mctp-i2c: fix duplicate reception of old data
2026-01-08 10:18 [PATCH] net: mctp-i2c: fix duplicate reception of old data Jian Zhang
@ 2026-01-09 0:07 ` Jeremy Kerr
2026-01-09 3:48 ` Jian Zhang
2026-01-13 3:30 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 4+ messages in thread
From: Jeremy Kerr @ 2026-01-09 0:07 UTC (permalink / raw)
To: Jian Zhang, Matt Johnston, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
Hi Jian,
> The MCTP I2C slave callback did not handle I2C_SLAVE_READ_REQUESTED
> events. As a result, i2c read event will trigger repeated reception
> of old data, reset rx_pos when a read request is received.
Makes sense. You're just invoking any i2c read from the peer controller
to trigger this, is that right?
Cheers,
Jeremy
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: mctp-i2c: fix duplicate reception of old data
2026-01-09 0:07 ` Jeremy Kerr
@ 2026-01-09 3:48 ` Jian Zhang
0 siblings, 0 replies; 4+ messages in thread
From: Jian Zhang @ 2026-01-09 3:48 UTC (permalink / raw)
To: Jeremy Kerr
Cc: Matt Johnston, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
Hi Jeremy,
> > The MCTP I2C slave callback did not handle I2C_SLAVE_READ_REQUESTED
> > events. As a result, i2c read event will trigger repeated reception
> > of old data, reset rx_pos when a read request is received.
>
> Makes sense. You're just invoking any i2c read from the peer controller
> to trigger this, is that right?
Yes, the peer just send a i2c read, like `i2cdetect -r -y 4`.
Jian.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: mctp-i2c: fix duplicate reception of old data
2026-01-08 10:18 [PATCH] net: mctp-i2c: fix duplicate reception of old data Jian Zhang
2026-01-09 0:07 ` Jeremy Kerr
@ 2026-01-13 3:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-13 3:30 UTC (permalink / raw)
To: Jian Zhang
Cc: jk, matt, andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
linux-kernel
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 8 Jan 2026 18:18:29 +0800 you wrote:
> The MCTP I2C slave callback did not handle I2C_SLAVE_READ_REQUESTED
> events. As a result, i2c read event will trigger repeated reception of
> old data, reset rx_pos when a read request is received.
>
> Signed-off-by: Jian Zhang <zhangjian.3032@bytedance.com>
> ---
> drivers/net/mctp/mctp-i2c.c | 6 ++++++
> 1 file changed, 6 insertions(+)
Here is the summary with links:
- net: mctp-i2c: fix duplicate reception of old data
https://git.kernel.org/netdev/net-next/c/ae4744e173fa
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-01-13 3:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-08 10:18 [PATCH] net: mctp-i2c: fix duplicate reception of old data Jian Zhang
2026-01-09 0:07 ` Jeremy Kerr
2026-01-09 3:48 ` Jian Zhang
2026-01-13 3:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox