| From 7bb82504ca6165b55716c22444ccc10c42e4392e Mon Sep 17 00:00:00 2001 |
| From: Steven Niu <steven.niu.uj@renesas.com> |
| Date: Thu, 18 Sep 2025 17:53:12 +0800 |
| Subject: [PATCH 1/2] i3c: i3c-hub: Fix SMBus Agent tx timeout issue |
| |
| Background: |
| Sometimes the SMBus Agent may raise tx timeout issue. |
| |
| Root Cause: |
| The TX_DONE status is cleared in IBI handler. IBI handler works in |
| workqueue context and may be disturbed by a new I2C API calling thread. |
| This may result in a condition that the new I2C tx API is called before |
| last TX_DONE is cleared. In this condition, the new tx action done will |
| not trigger an IBI. |
| |
| Solution: |
| Remove the TX_DONE clearing action from IBI handler to the beginning of |
| SMBus Agent Tx action. |
| |
| Signed-off-by: Steven Niu <steven.niu.uj@renesas.com> |
| --- |
| drivers/i3c/i3c-hub.c | 12 +++++------- |
| 1 file changed, 5 insertions(+), 7 deletions(-) |
| |
| diff --git a/drivers/i3c/i3c-hub.c b/drivers/i3c/i3c-hub.c |
| index 793438419f2b..2c655eb047dd 100644 |
| --- a/drivers/i3c/i3c-hub.c |
| +++ b/drivers/i3c/i3c-hub.c |
| @@ -572,13 +572,6 @@ static void i3c_hub_agent_ibi(struct i3c_hub_smbus_agent *agent) |
| agent->tx_res = stat; |
| complete(&agent->completion); |
| spin_unlock_irqrestore(&agent->lock, flags); |
| - |
| - ret = regmap_write(hub->regmap, |
| - HUB_REG_TP_SMBUS_AGNT_STS(agent->port_nr), |
| - HUB_REG_AGENT_CNTRL_STATUS_FINISH); |
| - if (ret) |
| - dev_warn(&hub->i3cdev->dev, |
| - "TP[%d] - failed to clear finish status\n", agent->port_nr); |
| } |
| |
| #if IS_ENABLED(CONFIG_I2C_SLAVE) |
| @@ -727,6 +720,11 @@ static int i3c_hub_agent_i2c_xfer_one(struct i3c_hub_smbus_agent *agent, |
| } |
| |
| reinit_completion(&agent->completion); |
| + ret = regmap_write(hub->regmap, |
| + HUB_REG_TP_SMBUS_AGNT_STS(agent->port_nr), |
| + HUB_REG_AGENT_CNTRL_STATUS_FINISH); |
| + if (ret) |
| + dev_warn(dev, "TP[%d] - failed to clear finish status\n", agent->port_nr); |
| |
| /* start transfer */ |
| ret = regmap_write(hub->regmap, HUB_REG_TP_SMBUS_AGNT_TRANS_START, port_bit); |
| -- |
| 2.34.1 |
| |