lkml.org 
[lkml]   [2021]   [Apr]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v10] i2c: virtio: add a virtio i2c frontend driver
From
Date

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.


\
 
 \ /
  Last update: 2021-04-15 08:17    [W:0.279 / U:0.556 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site