From 61b6acbdcfdb6a7f0b7c642de366e0d0e1f1a9c4 Mon Sep 17 00:00:00 2001 From: Ksawlii Date: Sun, 24 Nov 2024 00:23:11 +0100 Subject: [PATCH] Revert "i2c: xiic: Try re-initialization on bus busy timeout" This reverts commit 697cea0298287719bf8daaec7958de1b481241f4. --- drivers/i2c/busses/i2c-xiic.c | 41 +++++++++++++---------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index 9130563fb..41104f9f6 100755 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -540,11 +540,23 @@ static int xiic_bus_busy(struct xiic_i2c *i2c) return (sr & XIIC_SR_BUS_BUSY_MASK) ? -EBUSY : 0; } -static int xiic_wait_not_busy(struct xiic_i2c *i2c) +static int xiic_busy(struct xiic_i2c *i2c) { int tries = 3; int err; + if (i2c->tx_msg || i2c->rx_msg) + return -EBUSY; + + /* In single master mode bus can only be busy, when in use by this + * driver. If the register indicates bus being busy for some reason we + * should ignore it, since bus will never be released and i2c will be + * stuck forever. + */ + if (i2c->singlemaster) { + return 0; + } + /* for instance if previous transfer was terminated due to TX error * it might be that the bus is on it's way to become available * give it at most 3 ms to wake @@ -698,36 +710,13 @@ static int xiic_start_xfer(struct xiic_i2c *i2c, struct i2c_msg *msgs, int num) mutex_lock(&i2c->lock); - if (i2c->tx_msg || i2c->rx_msg) { + ret = xiic_busy(i2c); + if (ret) { dev_err(i2c->adap.dev.parent, "cannot start a transfer while busy\n"); - ret = -EBUSY; goto out; } - /* In single master mode bus can only be busy, when in use by this - * driver. If the register indicates bus being busy for some reason we - * should ignore it, since bus will never be released and i2c will be - * stuck forever. - */ - if (!i2c->singlemaster) { - ret = xiic_wait_not_busy(i2c); - if (ret) { - /* If the bus is stuck in a busy state, such as due to spurious low - * pulses on the bus causing a false start condition to be detected, - * then try to recover by re-initializing the controller and check - * again if the bus is still busy. - */ - dev_warn(i2c->adap.dev.parent, "I2C bus busy timeout, reinitializing\n"); - ret = xiic_reinit(i2c); - if (ret) - goto out; - ret = xiic_wait_not_busy(i2c); - if (ret) - goto out; - } - } - i2c->tx_msg = msgs; i2c->rx_msg = NULL; i2c->nmsgs = num;