Skip to content

Commit

Permalink
mctp i2c: notify user space on TX failure
Browse files Browse the repository at this point in the history
Currently, there is no error handling mechanism for TX failures, causing
user space to remain unaware of these failures until a timeout occurs.
This leads to unnecessary waiting and delays.

This update sends an immediate error notification to user space upon TX
failure, reducing wait times and improving response handling for failed
tx.

Signed-off-by: Jian Zhang <zhangjian.3032@bytedance.com>
Signed-off-by: NipaLocal <nipa@local>
  • Loading branch information
zhangjian3032 authored and NipaLocal committed Nov 13, 2024
1 parent f6a61a3 commit cefae06
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/net/mctp/mctp-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ static void mctp_i2c_xmit(struct mctp_i2c_dev *midev, struct sk_buff *skb)
struct mctp_i2c_hdr *hdr;
struct i2c_msg msg = {0};
u8 *pecp;
struct sock *sk;
int rc;

fs = mctp_i2c_get_tx_flow_state(midev, skb);
Expand Down Expand Up @@ -551,6 +552,14 @@ static void mctp_i2c_xmit(struct mctp_i2c_dev *midev, struct sk_buff *skb)
dev_warn_ratelimited(&midev->adapter->dev,
"__i2c_transfer failed %d\n", rc);
stats->tx_errors++;

sk = skb->sk;
if (sk) {
sk->sk_err = -rc;
if (!sock_flag(sk, SOCK_DEAD))
sk_error_report(sk);
}

} else {
stats->tx_bytes += skb->len;
stats->tx_packets++;
Expand Down

0 comments on commit cefae06

Please sign in to comment.