From: Corey Minyard <cminyard@mvista.com>
To: Shengtan Mao <stmao@google.com>
Cc: venture@google.com, qemu-devel@nongnu.org, wuhaotsh@google.com,
qemu-arm@nongnu.org, maoshengtan2011@gmail.com,
crauer@google.com
Subject: Re: [PATCH v4 0/2] Add remote I2C device to support external I2C device
Date: Fri, 6 Aug 2021 20:55:07 -0500 [thread overview]
Message-ID: <20210807015507.GE3431@minyard.net> (raw)
In-Reply-To: <20210806234918.122457-1-stmao@google.com>
On Fri, Aug 06, 2021 at 11:49:16PM +0000, Shengtan Mao wrote:
> This patch implements the remote I2C device. The remote I2C device allows an
> external I2C device to communicate with the I2C controller in QEMU through the
> remote I2C protocol. Users no longer have to directly modify QEMU to add new
> I2C devices and can instead implement the emulated device externally and
> connect it to the remote I2C device.
I got to spend some time on this today, and I like the concept, but
there is one major issue. When you do a read, you are blocking the
entire qemu I/O system until the read returns, which may result in
issues. At least that's may understanding of how the qemu I/O system
works, which may be dated or wrong.
If you look at the IPMI code, it as an external BMC that can handle
async I/O from the chardev. But the IPMI subsystem is designed to
handle this sort of thing.
Unfortunately, the I2C code really isn't set up to handle async
operations. I'm not sure how hard it would be to modify the I2C core to
handle this, but it doesn't look trivial. Well, the changes to the core
wouldn't be terrible, but all the host devices are set up for
synchronous operation. You could add a separate asynchronous interface,
and only host devices that were modified could use it, and your device
would only work on those host devices.
Another issue is that you aren't handling errors from the chr read/write
calls. If the remote connection dies, this isn't going to be good. You
have to do error handling.
There is also no way for the remote end to return a NACK. That's pretty
important, I think. It will, unfortunately, complicate your nice simple
protocol.
Sorry to be the bearer of bad news. Maybe I'm wrong about the blocking
thing, I'd be happy to be wrong.
-corey
>
> Previous work by Wolfram Sang
> (https://git.kernel.org/pub/scm/virt/qemu/wsa/qemu.git/commit/?h=i2c-passthrough)
> was referenced. It shares the similar idea of redirecting the actual I2C device
> functionalities, but Sang focuses on physical devices, and we focus on emulated devices.
> The work by Sang mainly utilizes file descriptors while ours utilizes character
> devices, which offers better support for emulated devices. The work by Sang is
> not meant to offer full I2C device support; it only implements the receive
> functionality. Our work implements full support for I2C devices: send, recv,
> and event (match_and_add is not applicable for external devices).
>
> v1 -> v2
> fixed terminology errors in the description comments.
> v2 -> v3
> corrected patch set emailing errors.
> v3 -> v4
> added remote I2C protocol description in docs/specs
>
> Shengtan Mao (2):
> hw/i2c: add remote I2C device
> docs/specs: add remote i2c docs
>
> docs/specs/index.rst | 1 +
> docs/specs/remote-i2c.rst | 51 ++++++++
> hw/arm/Kconfig | 1 +
> hw/i2c/Kconfig | 4 +
> hw/i2c/meson.build | 1 +
> hw/i2c/remote-i2c.c | 117 ++++++++++++++++++
> tests/qtest/meson.build | 1 +
> tests/qtest/remote-i2c-test.c | 216 ++++++++++++++++++++++++++++++++++
> 8 files changed, 392 insertions(+)
> create mode 100644 docs/specs/remote-i2c.rst
> create mode 100644 hw/i2c/remote-i2c.c
> create mode 100644 tests/qtest/remote-i2c-test.c
>
> --
> 2.32.0.605.g8dce9f2422-goog
>
next prev parent reply other threads:[~2021-08-07 1:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-06 23:49 [PATCH v4 0/2] Add remote I2C device to support external I2C device Shengtan Mao
2021-08-06 23:49 ` [PATCH v4 1/2] hw/i2c: add remote " Shengtan Mao
2021-08-06 23:49 ` [PATCH v4 2/2] docs/specs: add remote i2c docs Shengtan Mao
2021-08-07 1:55 ` Corey Minyard [this message]
2021-08-13 14:37 ` [PATCH v4 0/2] Add remote I2C device to support external I2C device Shengtan Mao
2021-08-13 15:48 ` Corey Minyard
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=20210807015507.GE3431@minyard.net \
--to=cminyard@mvista.com \
--cc=crauer@google.com \
--cc=maoshengtan2011@gmail.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stmao@google.com \
--cc=venture@google.com \
--cc=wuhaotsh@google.com \
/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).