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

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

 




On 2021/4/15 11:51, Jason Wang wrote:

+    for (i = 0; i < nr; i++) {
+        /* Detach the ith request from the vq */
+        req = virtqueue_get_buf(vq, &len);
+
+        /*
+         * Condition (req && req == &reqs[i]) should always meet since
+         * we have total nr requests in the vq.


So this assumes the requests are completed in order. Is this mandated in the spec?



This is a mandatory device requirements in spec.


+         */
+        if (!failed && (WARN_ON(!(req && req == &reqs[i])) ||
+            (req->in_hdr.status != VIRTIO_I2C_MSG_OK)))
+            failed = true;
+
+        i2c_put_dma_safe_msg_buf(reqs[i].buf, &msgs[i], !failed);
+        if (!failed)
+            ++j;
+    }
+
+    return (timeout ? -ETIMEDOUT : j);


Checking timeout is fragile, what happens if the request are completed after wait_for_completion() but before virtio_i2c_complete_reqs()?

We have discussed this before in v6. https://lists.linuxfoundation.org/pipermail/virtualization/2021-March/053093.html.

If timeout happens, we don't need to care about the requests whether really completed by "HW" or not.

Just return error and let the i2c core to decide whether to resend. And currently, the timeout is statically configured in driver.

We may extend a device timeout value configuration in spec for driver to use if there is actual need in the future.


_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization




[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux