From patchwork Fri Jul 30 10:04:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 60346 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D08F51007D3 for ; Fri, 30 Jul 2010 20:02:05 +1000 (EST) Received: from localhost ([127.0.0.1]:58390 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OemPi-0004eR-2s for incoming@patchwork.ozlabs.org; Fri, 30 Jul 2010 06:02:02 -0400 Received: from [140.186.70.92] (port=36404 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OemNY-0004bV-4L for qemu-devel@nongnu.org; Fri, 30 Jul 2010 05:59:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OemNV-0002yn-0M for qemu-devel@nongnu.org; Fri, 30 Jul 2010 05:59:47 -0400 Received: from mail.valinux.co.jp ([210.128.90.3]:49727) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OemNU-0002y2-Ib for qemu-devel@nongnu.org; Fri, 30 Jul 2010 05:59:44 -0400 Received: from ps.local.valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by mail.valinux.co.jp (Postfix) with SMTP id 1C9AA18806; Fri, 30 Jul 2010 18:59:40 +0900 (JST) Received: (nullmailer pid 16564 invoked by uid 1000); Fri, 30 Jul 2010 10:04:02 -0000 From: Isaku Yamahata To: qemu-devel@nongnu.org Date: Fri, 30 Jul 2010 19:04:00 +0900 Message-Id: <22042d5b97c049d47159c6784449ccedcabe98d6.1280484023.git.yamahata@valinux.co.jp> X-Mailer: git-send-email 1.7.1.1 In-Reply-To: References: In-Reply-To: References: X-Virus-Scanned: clamav-milter 0.95.2 at va-mail.local.valinux.co.jp X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: blauwirbel@gmail.com, yamahata@valinux.co.jp, mst@redhat.com Subject: [Qemu-devel] [PATCH 6/8] pci: use qbus bus reset callback. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org use qbus bus reset callback. Signed-off-by: Isaku Yamahata --- hw/apb_pci.c | 2 ++ hw/pci.c | 23 ++++++----------------- hw/pci_bridge.c | 2 ++ 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/hw/apb_pci.c b/hw/apb_pci.c index c619112..775063a 100644 --- a/hw/apb_pci.c +++ b/hw/apb_pci.c @@ -384,6 +384,8 @@ static void pci_pbm_reset(DeviceState *d) unsigned int i; APBState *s = container_of(d, APBState, busdev.qdev); + qdev_reset_default(d); + for (i = 0; i < 8; i++) { s->pci_irq_map[i] &= PBM_PCI_IMR_MASK; } diff --git a/hw/pci.c b/hw/pci.c index c48bb3e..731d367 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -40,12 +40,14 @@ static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent); static char *pcibus_get_dev_path(DeviceState *dev); +static void pci_bus_reset_fn(BusState *qbus); struct BusInfo pci_bus_info = { .name = "PCI", .size = sizeof(PCIBus), .print_dev = pcibus_dev_print, .get_dev_path = pcibus_get_dev_path, + .reset = pci_bus_reset_fn, .props = (Property[]) { DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1), DEFINE_PROP_STRING("romfile", PCIDevice, romfile), @@ -170,23 +172,11 @@ void pci_device_reset(PCIDevice *dev) } /* - * There are two paths to reset pci device. Each resets does partially. - * qemu_system_reset() - * -> pci_device_reset() with bus - * -> pci_device_reset_default() which resets pci common part. - * -> DeviceState::reset: each device specific reset hanlder - * which resets device specific part. - * * TODO: - * It requires two execution paths to reset the device fully. - * It is confusing and prone to error. Each device should know all - * its states. + * Each device should know all its states. * So move this part to each device specific callback. */ - - /* For now qdev_reset() is called directly by qemu_system_reset() */ - /* qdev_reset(&dev->qdev); */ - + qdev_reset(&dev->qdev); pci_device_reset_default(dev); } @@ -208,9 +198,9 @@ void pci_bus_reset(PCIBus *bus) } } -static void pci_bus_reset_fn(void *opaque) +static void pci_bus_reset_fn(BusState *qbus) { - pci_bus_reset(opaque); + pci_bus_reset(DO_UPCAST(PCIBus, qbus, qbus)); } static void pci_host_bus_register(int domain, PCIBus *bus) @@ -267,7 +257,6 @@ void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent, pci_host_bus_register(0, bus); /* for now only pci domain 0 is supported */ vmstate_register(NULL, -1, &vmstate_pcibus, bus); - qemu_register_reset(pci_bus_reset_fn, bus); } PCIBus *pci_bus_new(DeviceState *parent, const char *name, int devfn_min) diff --git a/hw/pci_bridge.c b/hw/pci_bridge.c index 198c3c7..ab7ed6e 100644 --- a/hw/pci_bridge.c +++ b/hw/pci_bridge.c @@ -158,6 +158,8 @@ void pci_bridge_reset_reg(PCIDevice *dev) void pci_bridge_reset(DeviceState *qdev) { PCIDevice *dev = DO_UPCAST(PCIDevice, qdev, qdev); + PCIBridge *br = DO_UPCAST(PCIBridge, dev, dev); + pci_bus_reset(&br->sec_bus); pci_bridge_reset_reg(dev); }