From: Cosmo Chou <chou.cosmo@gmail.com>
To: brendan.higgins@linux.dev, benh@kernel.crashing.org,
joel@jms.id.au, andi.shyti@kernel.org,
andrew@codeconstruct.com.au, linux@roeck-us.net, wsa@kernel.org,
jae.hyun.yoo@linux.intel.com
Cc: linux-i2c@vger.kernel.org, openbmc@lists.ozlabs.org,
linux-arm-kernel@lists.infradead.org,
linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org,
chou.cosmo@gmail.com, cosmo.chou@quantatw.com
Subject: [PATCH] i2c: aspeed: Acknowledge Tx ack late when in SLAVE_READ_PROCESSED
Date: Mon, 20 Nov 2023 17:17:46 +0800 [thread overview]
Message-ID: <20231120091746.2866232-1-chou.cosmo@gmail.com> (raw)
commit 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early
in interrupt handler") moved most interrupt acknowledgments to the
start of the interrupt handler to avoid race conditions. However,
slave Tx ack status shouldn't be cleared before SLAVE_READ_PROCESSED
is handled.
Acknowledge Tx ack status after handling SLAVE_READ_PROCESSED to fix
the problem that the next byte is not sent correctly.
Fixes: 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early in interrupt handler")
Signed-off-by: Cosmo Chou <chou.cosmo@gmail.com>
---
drivers/i2c/busses/i2c-aspeed.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
index 28e2a5fc4528..c2d74e4b7e50 100644
--- a/drivers/i2c/busses/i2c-aspeed.c
+++ b/drivers/i2c/busses/i2c-aspeed.c
@@ -337,6 +337,12 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status)
break;
}
+ /* Ack Tx ack */
+ if (irq_handled & ASPEED_I2CD_INTR_TX_ACK) {
+ writel(ASPEED_I2CD_INTR_TX_ACK, bus->base + ASPEED_I2C_INTR_STS_REG);
+ readl(bus->base + ASPEED_I2C_INTR_STS_REG);
+ }
+
return irq_handled;
}
#endif /* CONFIG_I2C_SLAVE */
@@ -602,13 +608,18 @@ static u32 aspeed_i2c_master_irq(struct aspeed_i2c_bus *bus, u32 irq_status)
static irqreturn_t aspeed_i2c_bus_irq(int irq, void *dev_id)
{
struct aspeed_i2c_bus *bus = dev_id;
- u32 irq_received, irq_remaining, irq_handled;
+ u32 irq_received, irq_remaining, irq_handled, irq_acked;
spin_lock(&bus->lock);
irq_received = readl(bus->base + ASPEED_I2C_INTR_STS_REG);
/* Ack all interrupts except for Rx done */
- writel(irq_received & ~ASPEED_I2CD_INTR_RX_DONE,
- bus->base + ASPEED_I2C_INTR_STS_REG);
+ irq_acked = irq_received & ~ASPEED_I2CD_INTR_RX_DONE;
+#if IS_ENABLED(CONFIG_I2C_SLAVE)
+ /* shouldn't ack Slave Tx Ack before it's handled */
+ if (bus->slave_state == ASPEED_I2C_SLAVE_READ_PROCESSED)
+ irq_acked &= ~ASPEED_I2CD_INTR_TX_ACK;
+#endif
+ writel(irq_acked, bus->base + ASPEED_I2C_INTR_STS_REG);
readl(bus->base + ASPEED_I2C_INTR_STS_REG);
irq_received &= ASPEED_I2CD_INTR_RECV_MASK;
irq_remaining = irq_received;
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2023-11-20 9:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-20 9:17 Cosmo Chou [this message]
2023-11-27 3:23 ` [PATCH] i2c: aspeed: Acknowledge Tx ack late when in SLAVE_READ_PROCESSED Andrew Jeffery
2023-11-27 7:04 ` Cosmo Chou
2023-11-27 8:08 ` Quan Nguyen
2023-11-27 23:00 ` Andrew Jeffery
2023-11-28 7:49 ` Quan Nguyen
2023-11-27 22:25 ` Andi Shyti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231120091746.2866232-1-chou.cosmo@gmail.com \
--to=chou.cosmo@gmail.com \
--cc=andi.shyti@kernel.org \
--cc=andrew@codeconstruct.com.au \
--cc=benh@kernel.crashing.org \
--cc=brendan.higgins@linux.dev \
--cc=cosmo.chou@quantatw.com \
--cc=jae.hyun.yoo@linux.intel.com \
--cc=joel@jms.id.au \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=openbmc@lists.ozlabs.org \
--cc=wsa@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).