[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
- [PATCH 1/5] hw/virtio: add boilerplate for vhost-user-i2c device, (continued)
- [PATCH 1/5] hw/virtio: add boilerplate for vhost-user-i2c device, Viresh Kumar, 2021/03/24
- [PATCH 2/5] hw/virtio: add vhost-user-i2c-pci boilerplate, Viresh Kumar, 2021/03/24
- [PATCH 3/5] tools/vhost-user-i2c: Add backend driver, Viresh Kumar, 2021/03/24
- Re: [PATCH 3/5] tools/vhost-user-i2c: Add backend driver, Jie Deng, 2021/03/25
- Re: [PATCH 3/5] tools/vhost-user-i2c: Add backend driver, Arnd Bergmann, 2021/03/25
- Re: [PATCH 3/5] tools/vhost-user-i2c: Add backend driver, Viresh Kumar, 2021/03/26
- Re: [PATCH 3/5] tools/vhost-user-i2c: Add backend driver, Arnd Bergmann, 2021/03/26
[PATCH 4/5] docs: add a man page for vhost-user-i2c, Viresh Kumar, 2021/03/24
[PATCH 5/5] MAINTAINERS: Add entry for virtio-i2c, Viresh Kumar, 2021/03/24
Re: [PATCH 0/5] virtio: Implement generic vhost-user-i2c backend, no-reply, 2021/03/24