qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 3/5] tools/vhost-user-i2c: Add backend driver


From: Arnd Bergmann
Subject: Re: [PATCH 3/5] tools/vhost-user-i2c: Add backend driver
Date: Fri, 26 Mar 2021 09:33:56 +0100

On Fri, Mar 26, 2021 at 7:01 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
> On 25-03-21, 17:16, Arnd Bergmann wrote:
> > On Wed, Mar 24, 2021 at 8:33 AM Viresh Kumar <viresh.kumar@linaro.org> 
> > wrote:
> >
> > > +static uint8_t vi2c_xfer(VuDev *dev, struct i2c_msg *msg)
> > > +{
> > > +    VuI2c *i2c = container_of(dev, VuI2c, dev.parent);
> > > +    struct i2c_rdwr_ioctl_data data;
> > > +    VI2cAdapter *adapter;
> > > +
> > > +    adapter = vi2c_find_adapter(i2c, msg->addr);
> > > +    if (!adapter) {
> > > +        g_printerr("Failed to find adapter for address: %x\n", 
> > > msg->addr);
> > > +        return VIRTIO_I2C_MSG_ERR;
> > > +    }
> > > +
> > > +    data.nmsgs = 1;
> > > +    data.msgs = msg;
> > > +
> > > +    if (ioctl(adapter->fd, I2C_RDWR, &data) < 0) {
> > > +        g_printerr("Failed to transfer data to address %x : %d\n", 
> > > msg->addr, errno);
> > > +        return VIRTIO_I2C_MSG_ERR;
> > > +    }
> >
> > As you found during testing, this doesn't work for host kernels
> > that only implement the SMBUS protocol. Since most i2c clients
> > only need simple register read/write operations, I think you should
> > at least handle the common ones (and one two byte read/write)
> > here to make it more useful.
>
> I am thinking if that is what we really want to support, then
> shouldn't the i2c virtio spec be updated first to support SMBUS type
> transfers as well?

As far as I can tell, all the simple devices should just work, with
I2C_FUNC_SMBUS_READ_BLOCK_DATA being the main exception,
but it seems that has practically no users.

       Arnd



reply via email to

[Prev in Thread] Current Thread [Next in Thread]