Re: [PATCH v10] i2c: virtio: add a virtio i2c frontend driver

Jie Deng
2021-06-29T03:03:50Z

On 2021/6/28 17:01, Arnd Bergmann wrote:

> On Mon, Jun 28, 2021 at 10:39 AM Wolfram Sang <wsa@kernel.org> wrote:
>> sorry for the long delay. I am not familiar with VFIO, so I had to dive
>> into the topic a little first. I am still not seeing through it
>> completely, so I have very high-level questions first.
> You probably know this already, but just in case for clarification
> these are two different things:
>
> VFIO: kernel feature to make raw (usually PCI) devices available
> to user space drivers and virtual machines from a kernel
> running on bare metal.
>
> virtio: transport protocol for implementing arbitrary paravirtualized
> drivers in (usually) a virtual machine guest without giving the
> guest access to hardware registers.
>
Thanks Arnd for clarification.

Let me add some more:

The native model is as follows: a specific native I2C driver operates a
specific hardware.

A specific native I2C driver  <--> A specific hardware

The virtio paravirtualized model is something like:

virtio-i2c <--> virtio I2C interfaces <--> virtio-backend <--> Real hardware

virtio-i2c: is this driver, the frontend driver.

virtio I2C interfaces: which are described in the specification.

https://raw.githubusercontent.com/oasis-tcs/virtio-spec/master/virtio-i2c.tex.

I had tried to mirror Linux I2C interfaces (like "i2c_msg") into
virtio I2C interface directly. But

when I was doing upstream for this specification, I understood the
virtio TC had the design philosophy

"VIRTIO devices are not specific to Linux so the specs design
should avoid the limitations of the

current Linux driver behavior." So we redefined a minimum virtio
I2C interfaces to make a working POC.

and we may extend it in the future according to the need.

virtio-backend: the backend driver communicate with virtio-i2c by
following virtio I2C interfaces specs.

The are already two backend drivers developed by Viresh, one in
QEMU, another in rust-vmm.

1. vhost-user:
https://lore.kernel.org/qemu-devel/cover.1617278395.git.viresh.kumar@linaro.org/t/#m3b5044bad9769b170f505e63bd081eb27cef8db2

2. rust-vmm I2C backend:
https://github.com/rust-vmm/vhost-device/pull/1

Regards,

Jie