From: "Cédric Le Goater" <clg@kaod.org>
To: Klaus Jensen <its@irrelevant.dk>
Cc: <qemu-devel@nongnu.org>, 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>,
Jeremy Kerr <jk@codeconstruct.com.au>,
Joel Stanley <joel@jms.id.au>,
Klaus Jensen <k.jensen@samsung.com>
Subject: Re: [PATCH maybe-7.2 1/3] hw/i2c: only schedule pending master when bus is idle
Date: Thu, 17 Nov 2022 09:01:22 +0100 [thread overview]
Message-ID: <465b2d2e-5958-d63f-02dc-cf96dd1d459e@kaod.org> (raw)
In-Reply-To: <Y3Xktt8b85RvJ89A@cormorant.local>
On 11/17/22 08:37, Klaus Jensen wrote:
> On Nov 17 07:56, Cédric Le Goater wrote:
>> On 11/17/22 07:40, Klaus Jensen wrote:
>>> On Nov 16 16:58, Cédric Le Goater wrote:
>>>> On 11/16/22 09:43, Klaus Jensen wrote:
>>>>> From: Klaus Jensen <k.jensen@samsung.com>
>>>>>
>>>>> It is not given that the current master will release the bus after a
>>>>> transfer ends. Only schedule a pending master if the bus is idle.
>>>>>
>>>>> Fixes: 37fa5ca42623 ("hw/i2c: support multiple masters")
>>>>> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
>>>>> ---
>>>>> hw/i2c/aspeed_i2c.c | 2 ++
>>>>> hw/i2c/core.c | 37 ++++++++++++++++++++++---------------
>>>>> include/hw/i2c/i2c.h | 2 ++
>>>>> 3 files changed, 26 insertions(+), 15 deletions(-)
>>>>>
>>>>> diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c
>>>>> index c166fd20fa11..1f071a3811f7 100644
>>>>> --- a/hw/i2c/aspeed_i2c.c
>>>>> +++ b/hw/i2c/aspeed_i2c.c
>>>>> @@ -550,6 +550,8 @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value)
>>>>> }
>>>>> SHARED_ARRAY_FIELD_DP32(bus->regs, reg_cmd, M_STOP_CMD, 0);
>>>>> aspeed_i2c_set_state(bus, I2CD_IDLE);
>>>>> +
>>>>> + i2c_schedule_pending_master(bus->bus);
>>>>
>>>> Shouldn't it be i2c_bus_release() ?
>>>>
>>>
>>> The reason for having both i2c_bus_release() and
>>> i2c_schedule_pending_master() is that i2c_bus_release() sort of pairs
>>> with i2c_bus_master(). They either set or clear the bus->bh member.
>>>
>>> In the current design, the controller (in this case the Aspeed I2C) is
>>> an "implicit" master (it does not have a bottom half driving it), so
>>> there is no bus->bh to clear.
>>>
>>> I should (and will) write some documentation on the asynchronous API.
>>
>> I found the routine names confusing. Thanks for the clarification.
>>
>> Maybe we could do this rename :
>>
>> i2c_bus_release() -> i2c_bus_release_and_clear()
>> i2c_schedule_pending_master() -> i2c_bus_release()
>>
>> and keep i2c_schedule_pending_master() internal the I2C core subsystem.
>>
>
> How about renaming i2c_bus_master to i2c_bus_acquire() such that it
> pairs with i2c_bus_release().
Looks good to me.
> And then add an i2c_bus_yield() to be used by the controller? I think we
> should be able to assert in i2c_bus_yield() that bus->bh is NULL. But
> I'll take a closer look at that.
I am using your i2c-echo slave device to track regressions in the Aspeed
machines. May be we could merge it for tests ?
Thanks,
C.
next prev parent reply other threads:[~2022-11-17 8:02 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 [this message]
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
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=465b2d2e-5958-d63f-02dc-cf96dd1d459e@kaod.org \
--to=clg@kaod.org \
--cc=andrew@aj.id.au \
--cc=cminyard@mvista.com \
--cc=its@irrelevant.dk \
--cc=jk@codeconstruct.com.au \
--cc=joel@jms.id.au \
--cc=k.jensen@samsung.com \
--cc=kbusch@kernel.org \
--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).