Re: [PATCH 2/2] i2c: virtio: fix completion handling

From: Jie Deng
Date: Thu Oct 21 2021 - 01:55:43 EST



On 2021/10/19 15:46, Vincent Whitchurch wrote:
The driver currently assumes that the notify callback is only received
when the device is done with all the queued buffers.

However, this is not true, since the notify callback could be called
without any of the queued buffers being completed (for example, with
virtio-pci and shared interrupts) or with only some of the buffers being
completed (since the driver makes them available to the device in
multiple separate virtqueue_add_sgs() calls).


Can the backend driver control the time point of interrupt injection ? I can't think of

why the backend has to send an early interrupt. This operation should be avoided

in the backend driver if possible. However, this change make sense if early interrupt

can't be avoid.



This can lead to incorrect data on the I2C bus or memory corruption in
the guest if the device operates on buffers which are have been freed by
the driver. (The WARN_ON in the driver is also triggered.)