[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c8229883-3988-b9f4-189c-7b685bc462b3@intel.com>
Date: Thu, 15 Apr 2021 14:17:28 +0800
From: Jie Deng <jie.deng@...el.com>
To: Jason Wang <jasowang@...hat.com>, linux-i2c@...r.kernel.org,
virtualization@...ts.linux-foundation.org,
linux-kernel@...r.kernel.org
Cc: mst@...hat.com, wsa@...nel.org, wsa+renesas@...g-engineering.com,
andriy.shevchenko@...ux.intel.com, conghui.chen@...el.com,
arnd@...db.de, kblaiech@...lanox.com,
jarkko.nikula@...ux.intel.com, Sergey.Semin@...kalelectronics.ru,
rppt@...nel.org, loic.poulain@...aro.org, tali.perry1@...il.com,
u.kleine-koenig@...gutronix.de, bjorn.andersson@...aro.org,
yu1.wang@...el.com, shuo.a.liu@...el.com, viresh.kumar@...aro.org,
stefanha@...hat.com, pbonzini@...hat.com
Subject: Re: [PATCH v10] i2c: virtio: add a virtio i2c frontend driver
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.
Powered by blists - more mailing lists