From patchwork Thu Jun 17 06:15:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 55972 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 76FC21007D2 for ; Thu, 17 Jun 2010 16:37:00 +1000 (EST) Received: from localhost ([127.0.0.1]:34049 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OP8if-00078q-9r for incoming@patchwork.ozlabs.org; Thu, 17 Jun 2010 02:36:57 -0400 Received: from [140.186.70.92] (port=38434 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OP8S0-0008Ah-KG for qemu-devel@nongnu.org; Thu, 17 Jun 2010 02:19:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OP8Rx-0002kl-Mk for qemu-devel@nongnu.org; Thu, 17 Jun 2010 02:19:44 -0400 Received: from mail.valinux.co.jp ([210.128.90.3]:36647) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OP8Rx-0002jY-4x for qemu-devel@nongnu.org; Thu, 17 Jun 2010 02:19:41 -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 209481072C2; Thu, 17 Jun 2010 15:19:39 +0900 (JST) Received: (nullmailer pid 29417 invoked by uid 1000); Thu, 17 Jun 2010 06:15:52 -0000 From: Isaku Yamahata To: qemu-devel@nongnu.org Date: Thu, 17 Jun 2010 15:15:48 +0900 Message-Id: <5ab7e569a178e6bd8247718c5b2435058d75fc7a.1276755023.git.yamahata@valinux.co.jp> X-Mailer: git-send-email 1.6.6.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: jan.kiszka@siemens.com, mst@redhat.com, allen.m.kay@intel.com, blauwirbel@gmail.com, yamahata@valinux.co.jp, kraxel@redhat.com, stefano.stabellini@eu.citrix.com, jean.guyader@gmail.com Subject: [Qemu-devel] [PATCH 06/10] pci: eliminate work around in pci_device_reset(). 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 Eliminate work around in pci_device_reset() by making each pci reset function to call pci_device_reset_default(). If a driver reset function isn't specified, set it to pci default reset function. Signed-off-by: Isaku Yamahata --- hw/e1000.c | 1 + hw/lsi53c895a.c | 2 ++ hw/pci.c | 12 ++++++++---- hw/pcnet.c | 1 + hw/rtl8139.c | 2 ++ hw/virtio-pci.c | 1 + 6 files changed, 15 insertions(+), 4 deletions(-) diff --git a/hw/e1000.c b/hw/e1000.c index 0da65f9..448a743 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -1069,6 +1069,7 @@ static void e1000_reset(void *opaque) memmove(d->mac_reg, mac_reg_init, sizeof mac_reg_init); d->rxbuf_min_shift = 1; memset(&d->tx, 0, sizeof d->tx); + pci_device_reset_default(&d->dev); } static NetClientInfo net_e1000_info = { diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c index f5a91ba..68723e3 100644 --- a/hw/lsi53c895a.c +++ b/hw/lsi53c895a.c @@ -358,6 +358,8 @@ static void lsi_soft_reset(LSIState *s) qemu_free(s->current); s->current = NULL; } + + pci_device_reset_default(&s->dev); } static int lsi_dma_40bit(LSIState *s) diff --git a/hw/pci.c b/hw/pci.c index 87f5e6c..5dee102 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -171,6 +171,11 @@ void pci_device_reset_default(PCIDevice *dev) pci_update_mappings(dev); } +static void pci_device_reset_default_fn(DeviceState *qdev) +{ + pci_device_reset_default(DO_UPCAST(PCIDevice, qdev, qdev)); +} + void pci_device_reset(PCIDevice *dev) { if (!dev->qdev.info) { @@ -180,10 +185,6 @@ void pci_device_reset(PCIDevice *dev) } qdev_reset(&dev->qdev); - - /* TODO: make DeviceInfo::reset call - pci_device_reset_default() itself. */ - pci_device_reset_default(dev); } void pci_bus_reset(PCIBus *bus) @@ -1614,6 +1615,9 @@ void pci_qdev_register(PCIDeviceInfo *info) info->qdev.unplug = pci_unplug_device; info->qdev.exit = pci_unregister_device; info->qdev.bus_info = &pci_bus_info; + if (!info->qdev.reset) { + info->qdev.reset = pci_device_reset_default_fn; + } qdev_register(&info->qdev); } diff --git a/hw/pcnet.c b/hw/pcnet.c index 5e63eb5..c894d13 100644 --- a/hw/pcnet.c +++ b/hw/pcnet.c @@ -2036,6 +2036,7 @@ static void pci_reset(DeviceState *dev) PCIPCNetState *d = DO_UPCAST(PCIPCNetState, pci_dev.qdev, dev); pcnet_h_reset(&d->state); + pci_device_reset_default(&d->pci_dev); } static PCIDeviceInfo pcnet_info = { diff --git a/hw/rtl8139.c b/hw/rtl8139.c index 72e2242..bfa7cde 100644 --- a/hw/rtl8139.c +++ b/hw/rtl8139.c @@ -1260,6 +1260,8 @@ static void rtl8139_reset(DeviceState *d) /* reset tally counters */ RTL8139TallyCounters_clear(&s->tally_counters); + + pci_device_reset_default(&s->dev); } static void RTL8139TallyCounters_clear(RTL8139TallyCounters* counters) diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index e101fa0..ea8ea6a 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -184,6 +184,7 @@ static void virtio_pci_reset(DeviceState *d) virtio_reset(proxy->vdev); msix_reset(&proxy->pci_dev); proxy->bugs = 0; + pci_device_reset_default(&proxy->pci_dev); } static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)