This is an expected behavior. If timeout happens, we don't need to care about the requests whether+ virtqueue_kick(vq);
+
+ time_left = wait_for_completion_timeout(&vi->completion, adap->timeout);
+ if (!time_left) {
+ dev_err(&adap->dev, "virtio i2c backend timeout.\n");
+ ret = -ETIMEDOUT;
+ goto err_unlock_free;
So if the request is finished after the timerout, all the following request will fail, is this expected?
really completed by "HW" or not. Just return error and let the i2c core to decide whether to resend.
So you need at least reinit the completion at least?
The device can raise interrupt when some requests are still not completed though this is not a good operation.+ }
+
+ ret = virtio_i2c_complete_reqs(vq, reqs, msgs, nr);
So consider driver queue N requests, can device raise interrupt if it completes the first request? If yes, the code break, if not it need to be clarified in the spec.
Then you need forbid this in the spec.
In this case, the remaining requests in the vq will be ignored and the i2c_algorithm. master_xfer will return 1 for
your example. And let the i2c core to decide whether to resend.
This flag is introduced by Stefan. Please check following link for the details
Acaultly I remember there's no VIRTIO_I2C_FLAGS_FAIL_NEXT in previous versions, and after reading the spec I still don't get the motivation for that (it may complicates both driver and device actually).
https://lists.oasis-open.org/archives/virtio-comment/202012/msg00075.html.
> We just need to make sure that once the driver adds some requests to the
> virtqueue,
> it should complete them (either success or fail) before adding new requests.
> I think this
> is a behavior of physical I2C adapter drivers and we can follow.
Is this a driver requirement or device? If it's the driver, the code have already did something like this. E.g you wait for the completion of the request and forbid new request via i2c_lock.
Thanks