Re: [PATCH v10] i2c: virtio: add a virtio i2c frontend driver
From: Arnd Bergmann
Date: Mon Jun 28 2021 - 07:53:32 EST
On Mon, Jun 28, 2021 at 12:13 PM Wolfram Sang <wsa@xxxxxxxxxx> wrote:
>
>
> > Ok, that's what I thought. There is one corner case that I've struggled
> > with though: Suppose the host has an SMBus-only driver, and the
> > proposed driver exposes this as an I2C device to the guest, which
> > makes it available to guest user space (or a guest kernel driver)
> > using the emulated smbus command set. Is it always possible for
> > the host user space to turn the I2C transaction back into the
> > expected SMBus transaction on the host?
>
> If an SMBus commands gets converted to I2C messages, it can be converted
> back to an SMBus command. I don't see anything preventing that right
> now. However, the mapping-back code does look a bit clumsy, now that I
> envision it. Maybe it is better, after all, to support I2C_SMBUS
> directly and pass SMBus transactions as is. It should be a tad more
> effiecient, too.
You can fine Viresh's vhost-user implementation at
https://lore.kernel.org/qemu-devel/cover.1617278395.git.viresh.kumar@xxxxxxxxxx/t/#m3b5044bad9769b170f505e63bd081eb27cef8db2
As you say, it does get a bit clumsy, but I think there is also a good argument
to be made that the clumsiness is based on the host Linux user interface
more than the on the requirements of the physical interface,
and that should not have to be reflected in the virtio specification.
> Speaking of it, I recall another gory detail: SMBus has transfers named
> "read block data" and "block process call". These also need special
> support from I2C host controllers before they can be emulated because
> the length of the read needs to be adjusted in flight. These commands
> are rare and not hard to implement. However, it makes exposing what is
> supported a little more difficult.
Right, this one has come up before as well: the preliminary result
was to assume that this probably won't be needed, but would be easy
enough to add later if necessary.
Arnd