From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:52763) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkdVK-00006J-3m for qemu-devel@nongnu.org; Mon, 17 Dec 2012 11:25:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TkdVE-0008Ga-EX for qemu-devel@nongnu.org; Mon, 17 Dec 2012 11:25:21 -0500 Received: from mail-ia0-f173.google.com ([209.85.210.173]:58406) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkdVE-0008GN-7H for qemu-devel@nongnu.org; Mon, 17 Dec 2012 11:25:16 -0500 Received: by mail-ia0-f173.google.com with SMTP id w21so5709752iac.4 for ; Mon, 17 Dec 2012 08:25:15 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 17 Dec 2012 17:24:39 +0100 Message-Id: <1355761490-10073-5-git-send-email-pbonzini@redhat.com> In-Reply-To: <1355761490-10073-1-git-send-email-pbonzini@redhat.com> References: <1355761490-10073-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 04/15] virtio-pci: reset device before PCI layer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, mst@redhat.com At the end of this series, qdev will reset devices in post-order: first the children, then the parents. The ->vdev link is logically a child of the virtio-pci device and, even though it is not explicitly modeled like that, we want to use the same reset semantics as qdev. Signed-off-by: Paolo Bonzini --- hw/virtio-pci.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index 71f4fb5..a7c75fe 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -245,8 +245,8 @@ static void virtio_pci_stop_ioeventfd(VirtIOPCIProxy *proxy) void virtio_pci_reset(DeviceState *d) { VirtIOPCIProxy *proxy = container_of(d, VirtIOPCIProxy, pci_dev.qdev); - virtio_pci_stop_ioeventfd(proxy); virtio_reset(proxy->vdev); + virtio_pci_stop_ioeventfd(proxy); msix_unuse_all_vectors(&proxy->pci_dev); proxy->flags &= ~VIRTIO_PCI_FLAG_BUS_MASTER_BUG; } @@ -268,8 +268,8 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val) case VIRTIO_PCI_QUEUE_PFN: pa = (hwaddr)val << VIRTIO_PCI_QUEUE_ADDR_SHIFT; if (pa == 0) { - virtio_pci_stop_ioeventfd(proxy); virtio_reset(proxy->vdev); + virtio_pci_stop_ioeventfd(proxy); msix_unuse_all_vectors(&proxy->pci_dev); } else @@ -285,6 +285,10 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val) } break; case VIRTIO_PCI_STATUS: + if (vdev->status == 0) { + virtio_reset(proxy->vdev); + } + if (!(val & VIRTIO_CONFIG_S_DRIVER_OK)) { virtio_pci_stop_ioeventfd(proxy); } @@ -296,7 +300,6 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val) } if (vdev->status == 0) { - virtio_reset(proxy->vdev); msix_unuse_all_vectors(&proxy->pci_dev); } -- 1.8.0.2