From patchwork Mon Dec 17 16:24:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 206938 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8D0132C007C for ; Tue, 18 Dec 2012 04:48:42 +1100 (EST) Received: from localhost ([::1]:46950 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkdVm-00019O-5k for incoming@patchwork.ozlabs.org; Mon, 17 Dec 2012 11:25:50 -0500 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=XjW8/Yn4kk5VOS/xkbgE7kNoQukqfBIn66YLt4tWQ0I=; b=JmgI441Err5OdW9cJQCipXw1UOamp9QKzx3o1mNcgjOdIqxASmZDGYWAIDgGVR+50/ Jvlw14qJ2ZcnAAs8UIC2YcZkSJGMrqF/g4EF1co7u3x9otyyJjFyMPDxBn4uSGdK/tfE c6cEb4xTYDFFetj7CH5Ou2VaVbBzFDZ5b3Ch5exWhgsQI7v99Xap9XrylwjcjTMIRmx2 ICX2SS2VH9XqHpW0Vjw46Pn8iZvnfM3AbZwFTp7/CfuEXFLL0lU1c7+S1DN4bqS4spHu MPKNHm8cZDgUkRs0LfxzrNgsw0GNrZlXCxueFZyefUrREZiNuX+PxoBfZx/kWao6569w LknQ== X-Received: by 10.50.150.175 with SMTP id uj15mr9525357igb.52.1355761515662; Mon, 17 Dec 2012 08:25:15 -0800 (PST) Received: from yakj.usersys.redhat.com (93-34-219-150.ip51.fastwebnet.it. [93.34.219.150]) by mx.google.com with ESMTPS id bh3sm5950327igc.0.2012.12.17.08.25.11 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Dec 2012 08:25:14 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 17 Dec 2012 17:24:39 +0100 Message-Id: <1355761490-10073-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.0.2 In-Reply-To: <1355761490-10073-1-git-send-email-pbonzini@redhat.com> References: <1355761490-10073-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.210.173 Cc: aliguori@us.ibm.com, mst@redhat.com Subject: [Qemu-devel] [PATCH 04/15] virtio-pci: reset device before PCI layer X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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); }