From: Jason Wang <jasowang@redhat.com>
To: Max Gurtovoy <mgurtovoy@nvidia.com>,
mst@redhat.com, kvm@vger.kernel.org,
virtualization@lists.linux-foundation.org
Cc: nitzanc@nvidia.com, oren@nvidia.com, cohuck@redhat.com
Subject: Re: [PATCH v2 2/3] virito_pci: add timeout to reset device operation
Date: Thu, 8 Apr 2021 21:18:26 +0800 [thread overview]
Message-ID: <2b4edcaf-779d-b197-0437-c6cb8e82e8e1@redhat.com> (raw)
In-Reply-To: <7ed9cafa-498e-156d-c667-6da3fa432b18@nvidia.com>
在 2021/4/8 下午8:57, Max Gurtovoy 写道:
>
> On 4/8/2021 3:45 PM, Jason Wang wrote:
>>
>> 在 2021/4/8 下午5:44, Max Gurtovoy 写道:
>>>
>>> On 4/8/2021 12:01 PM, Jason Wang wrote:
>>>>
>>>> 在 2021/4/8 下午4:11, Max Gurtovoy 写道:
>>>>> According to the spec after writing 0 to device_status, the driver
>>>>> MUST
>>>>> wait for a read of device_status to return 0 before reinitializing
>>>>> the
>>>>> device. In case we have a device that won't return 0, the reset
>>>>> operation will loop forever and cause the host/vm to stuck. Set
>>>>> timeout
>>>>> for 3 minutes before giving up on the device.
>>>>>
>>>>> Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com>
>>>>> ---
>>>>> drivers/virtio/virtio_pci_modern.c | 10 +++++++++-
>>>>> 1 file changed, 9 insertions(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/drivers/virtio/virtio_pci_modern.c
>>>>> b/drivers/virtio/virtio_pci_modern.c
>>>>> index cc3412a96a17..dcee616e8d21 100644
>>>>> --- a/drivers/virtio/virtio_pci_modern.c
>>>>> +++ b/drivers/virtio/virtio_pci_modern.c
>>>>> @@ -162,6 +162,7 @@ static int vp_reset(struct virtio_device *vdev)
>>>>> {
>>>>> struct virtio_pci_device *vp_dev = to_vp_device(vdev);
>>>>> struct virtio_pci_modern_device *mdev = &vp_dev->mdev;
>>>>> + unsigned long timeout = jiffies + msecs_to_jiffies(180000);
>>>>> /* 0 status means a reset. */
>>>>> vp_modern_set_status(mdev, 0);
>>>>> @@ -169,9 +170,16 @@ static int vp_reset(struct virtio_device *vdev)
>>>>> * device_status to return 0 before reinitializing the device.
>>>>> * This will flush out the status write, and flush in device
>>>>> writes,
>>>>> * including MSI-X interrupts, if any.
>>>>> + * Set a timeout before giving up on the device.
>>>>> */
>>>>> - while (vp_modern_get_status(mdev))
>>>>> + while (vp_modern_get_status(mdev)) {
>>>>> + if (time_after(jiffies, timeout)) {
>>>>
>>>>
>>>> What happens if the device finish the rest after the timeout?
>>>
>>>
>>> The driver will set VIRTIO_CONFIG_S_FAILED and one can re-probe it
>>> later on (e.g by re-scanning the pci bus).
>>
>>
>> Ok, so do we need the flush through vp_synchronize_vectors() here?
>
> If the device didn't write 0 to status I guess we don't need that.
>
> The device shouldn't raise any interrupt before negotiation finish
> successfully.
The reset could be triggered in other places like driver removing.
Thanks
>
> MST, is that correct ?
>
>>
>> Thanks
>>
>>
>>>
>>>
>>>>
>>>> Thanks
>>>>
>>>>
>>>>> + dev_err(&vdev->dev, "virtio: device not ready. "
>>>>> + "Aborting. Try again later\n");
>>>>> + return -EAGAIN;
>>>>> + }
>>>>> msleep(1);
>>>>> + }
>>>>> /* Flush pending VQ/configuration callbacks. */
>>>>> vp_synchronize_vectors(vdev);
>>>>> return 0;
>>>>
>>>
>>
>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next prev parent reply other threads:[~2021-04-08 13:18 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210408081109.56537-1-mgurtovoy@nvidia.com>
2021-04-08 8:58 ` [PATCH v2 1/3] virtio: update reset callback to return status Jason Wang
[not found] ` <1f134102-4ccb-57e3-858d-3922d851ce8a@nvidia.com>
2021-04-08 13:14 ` Jason Wang
[not found] ` <103ae6fe-1ffc-90a3-09cd-bcbbcbb8eee7@nvidia.com>
2021-04-09 5:22 ` Jason Wang
[not found] ` <96742dde-edba-0329-c9c2-b3ac3b28cf1d@nvidia.com>
2021-04-12 9:07 ` Michael S. Tsirkin
[not found] ` <e1e4a42c-2e87-adc1-9089-1c722f02b810@nvidia.com>
2021-04-12 21:29 ` Michael S. Tsirkin
2021-04-08 15:56 ` Michael S. Tsirkin
[not found] ` <31fa92ca-bce5-b71f-406d-8f3951b2143c@nvidia.com>
2021-04-12 12:04 ` Michael S. Tsirkin
[not found] ` <b99e324b-3a78-b3ed-98a8-a3b88a271338@nvidia.com>
2021-04-12 21:23 ` Michael S. Tsirkin
[not found] ` <10e099a9-2e3d-8c39-138a-17b2674b5389@nvidia.com>
2021-04-13 2:42 ` Jason Wang
2021-04-13 4:52 ` Michael S. Tsirkin
2021-04-13 4:42 ` Michael S. Tsirkin
[not found] ` <20210408081109.56537-2-mgurtovoy@nvidia.com>
2021-04-08 9:01 ` [PATCH v2 2/3] virito_pci: add timeout to reset device operation Jason Wang
[not found] ` <a00abefe-790d-8239-ac42-9f70daa7a25c@nvidia.com>
2021-04-08 12:45 ` Jason Wang
[not found] ` <7ed9cafa-498e-156d-c667-6da3fa432b18@nvidia.com>
2021-04-08 13:18 ` Jason Wang [this message]
2021-04-08 16:18 ` [PATCH v2 1/3] virtio: update reset callback to return status Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2b4edcaf-779d-b197-0437-c6cb8e82e8e1@redhat.com \
--to=jasowang@redhat.com \
--cc=cohuck@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mgurtovoy@nvidia.com \
--cc=mst@redhat.com \
--cc=nitzanc@nvidia.com \
--cc=oren@nvidia.com \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).