From: Jeremy Kerr <jk@codeconstruct.com.au>
To: Klaus Jensen <its@irrelevant.dk>, qemu-devel@nongnu.org
Cc: "Andrew Jeffery" <andrew@aj.id.au>,
"Keith Busch" <kbusch@kernel.org>,
"Corey Minyard" <cminyard@mvista.com>,
"Peter Delevoryas" <peter@pjd.dev>,
qemu-arm@nongnu.org, "Peter Maydell" <peter.maydell@linaro.org>,
qemu-block@nongnu.org, "Joel Stanley" <joel@jms.id.au>,
"Cédric Le Goater" <clg@kaod.org>,
"Klaus Jensen" <k.jensen@samsung.com>,
"Matt Johnston" <matt@codeconstruct.com.au>
Subject: Re: [PATCH RFC 2/3] hw/i2c: add mctp core
Date: Fri, 18 Nov 2022 14:15:43 +0800 [thread overview]
Message-ID: <be1a8590ee2f06d159987c45f85b4552695f8ed1.camel@codeconstruct.com.au> (raw)
In-Reply-To: <d8a8549c6fc29650131046ee00b7968ebedf886b.camel@codeconstruct.com.au>
Hi Klaus,
> With those changes, I can get control protocol going, and multi-
> packet messages work.
Ah, I also needed a change to the aspeed I2C driver, as I'm seeing
the interrupt handler being invoked with both a stop and a start event
pending.
Patch below; if this seems sensible I will propose upstream.
Cheers,
Jeremy
---
From 6331cf2499c182606979029d2aaed93ee3e544fa Mon Sep 17 00:00:00 2001
From: Jeremy Kerr <jk@codeconstruct.com.au>
Date: Fri, 18 Nov 2022 14:04:50 +0800
Subject: [PATCH] i2c: aspeed: Allow combined STOP & START irqs
Currently, if we enter our interrupt handler with both a stop and start
condition pending, the stop event handler will override the current
state, so we'll then lose the start condition.
This change handles the stop condition before anything else, which means
we can then restart the state machine on any pending start state.
Because of this, we no longer need the ASPEED_I2C_SLAVE_STOP state,
because we're just reverting directly to INACTIVE.
I have only seen this condition on emulation; it may be impossible to
hit on real HW.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
---
drivers/i2c/busses/i2c-aspeed.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
index 185dedfebbac..45f2766b2b66 100644
--- a/drivers/i2c/busses/i2c-aspeed.c
+++ b/drivers/i2c/busses/i2c-aspeed.c
@@ -135,7 +135,6 @@ enum aspeed_i2c_slave_state {
ASPEED_I2C_SLAVE_READ_PROCESSED,
ASPEED_I2C_SLAVE_WRITE_REQUESTED,
ASPEED_I2C_SLAVE_WRITE_RECEIVED,
- ASPEED_I2C_SLAVE_STOP,
};
struct aspeed_i2c_bus {
@@ -250,6 +249,14 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status)
command = readl(bus->base + ASPEED_I2C_CMD_REG);
+ /* handle a stop before starting any new events */
+ if (bus->slave_state != ASPEED_I2C_SLAVE_INACTIVE &&
+ irq_status & ASPEED_I2CD_INTR_NORMAL_STOP) {
+ irq_handled |= ASPEED_I2CD_INTR_NORMAL_STOP;
+ i2c_slave_event(slave, I2C_SLAVE_STOP, &value);
+ bus->slave_state = ASPEED_I2C_SLAVE_INACTIVE;
+ }
+
/* Slave was requested, restart state machine. */
if (irq_status & ASPEED_I2CD_INTR_SLAVE_MATCH) {
irq_handled |= ASPEED_I2CD_INTR_SLAVE_MATCH;
@@ -278,15 +285,11 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status)
irq_handled |= ASPEED_I2CD_INTR_RX_DONE;
}
- /* Slave was asked to stop. */
- if (irq_status & ASPEED_I2CD_INTR_NORMAL_STOP) {
- irq_handled |= ASPEED_I2CD_INTR_NORMAL_STOP;
- bus->slave_state = ASPEED_I2C_SLAVE_STOP;
- }
if (irq_status & ASPEED_I2CD_INTR_TX_NAK &&
bus->slave_state == ASPEED_I2C_SLAVE_READ_PROCESSED) {
irq_handled |= ASPEED_I2CD_INTR_TX_NAK;
- bus->slave_state = ASPEED_I2C_SLAVE_STOP;
+ i2c_slave_event(slave, I2C_SLAVE_STOP, &value);
+ bus->slave_state = ASPEED_I2C_SLAVE_INACTIVE;
}
switch (bus->slave_state) {
@@ -316,13 +319,11 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status)
case ASPEED_I2C_SLAVE_WRITE_RECEIVED:
i2c_slave_event(slave, I2C_SLAVE_WRITE_RECEIVED, &value);
break;
- case ASPEED_I2C_SLAVE_STOP:
- i2c_slave_event(slave, I2C_SLAVE_STOP, &value);
- bus->slave_state = ASPEED_I2C_SLAVE_INACTIVE;
- break;
case ASPEED_I2C_SLAVE_START:
/* Slave was just started. Waiting for the next event. */;
break;
+ case ASPEED_I2C_SLAVE_INACTIVE:
+ break;
default:
dev_err(bus->dev, "unknown slave_state: %d\n",
bus->slave_state);
--
2.35.1
next prev parent reply other threads:[~2022-11-18 6:17 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-16 8:43 [PATCH 0/3] hw/{i2c, nvme}: mctp endpoint, nvme management interface model Klaus Jensen
2022-11-16 8:43 ` [PATCH maybe-7.2 1/3] hw/i2c: only schedule pending master when bus is idle Klaus Jensen
2022-11-16 13:16 ` Peter Maydell
2022-11-16 13:43 ` Corey Minyard
2022-11-16 15:58 ` Cédric Le Goater
2022-11-17 6:40 ` Klaus Jensen
2022-11-17 6:56 ` Cédric Le Goater
2022-11-17 7:37 ` Klaus Jensen
2022-11-17 8:01 ` Cédric Le Goater
2022-11-17 11:58 ` Klaus Jensen
2022-11-17 13:40 ` Cédric Le Goater
2022-11-18 6:59 ` Klaus Jensen
2022-11-22 8:45 ` Klaus Jensen
2022-11-16 8:43 ` [PATCH RFC 2/3] hw/i2c: add mctp core Klaus Jensen
2022-11-16 14:27 ` Corey Minyard
2022-11-17 6:51 ` Klaus Jensen
2022-11-18 5:56 ` Jeremy Kerr
2022-11-18 6:15 ` Jeremy Kerr [this message]
2022-11-18 7:03 ` Klaus Jensen
2022-11-18 7:09 ` Jeremy Kerr
2022-11-18 7:01 ` Klaus Jensen
2022-11-21 8:04 ` Matt Johnston
2022-11-16 8:43 ` [PATCH RFC 3/3] hw/nvme: add nvme management interface model Klaus Jensen
2022-11-18 7:56 ` Philippe Mathieu-Daudé
2022-11-18 7:58 ` Klaus Jensen
2022-11-16 9:18 ` [PATCH 0/3] hw/{i2c,nvme}: mctp endpoint, " Jeremy Kerr
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=be1a8590ee2f06d159987c45f85b4552695f8ed1.camel@codeconstruct.com.au \
--to=jk@codeconstruct.com.au \
--cc=andrew@aj.id.au \
--cc=clg@kaod.org \
--cc=cminyard@mvista.com \
--cc=its@irrelevant.dk \
--cc=joel@jms.id.au \
--cc=k.jensen@samsung.com \
--cc=kbusch@kernel.org \
--cc=matt@codeconstruct.com.au \
--cc=peter.maydell@linaro.org \
--cc=peter@pjd.dev \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.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).