From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756502AbcDECyA (ORCPT ); Mon, 4 Apr 2016 22:54:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42387 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752085AbcDECx7 (ORCPT ); Mon, 4 Apr 2016 22:53:59 -0400 Subject: Re: [PATCH] virtio: virtio 1.0 cs04 spec compliance for reset To: "Michael S. Tsirkin" , linux-kernel@vger.kernel.org References: <1459686336-29527-1-git-send-email-mst@redhat.com> Cc: stable@vger.kernel.org, virtualization@lists.linux-foundation.org, Bandan Das From: Jason Wang Message-ID: <570328C1.9010709@redhat.com> Date: Tue, 5 Apr 2016 10:53:53 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <1459686336-29527-1-git-send-email-mst@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/03/2016 08:26 PM, Michael S. Tsirkin wrote: > The spec says: after writing 0 to device_status, the driver MUST wait > for a read of device_status to return 0 before reinitializing the > device. > > Cc: stable@vger.kernel.org > Signed-off-by: Michael S. Tsirkin > --- > drivers/virtio/virtio_pci_modern.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c > index f6f28cc..e76bd91 100644 > --- a/drivers/virtio/virtio_pci_modern.c > +++ b/drivers/virtio/virtio_pci_modern.c > @@ -17,6 +17,7 @@ > * > */ > > +#include > #define VIRTIO_PCI_NO_LEGACY > #include "virtio_pci_common.h" > > @@ -271,9 +272,13 @@ static void vp_reset(struct virtio_device *vdev) > struct virtio_pci_device *vp_dev = to_vp_device(vdev); > /* 0 status means a reset. */ > vp_iowrite8(0, &vp_dev->common->device_status); > - /* Flush out the status write, and flush in device writes, > - * including MSI-X interrupts, if any. */ > - vp_ioread8(&vp_dev->common->device_status); > + /* After writing 0 to device_status, the driver MUST wait for a read of > + * 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. > + */ > + while (vp_ioread8(&vp_dev->common->device_status)) > + msleep(1); > /* Flush pending VQ/configuration callbacks. */ > vp_synchronize_vectors(vdev); > } Acked-by: Jason Wang