From patchwork Thu Aug 5 02:09:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 60919 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 37F421007D1 for ; Thu, 5 Aug 2010 12:12:14 +1000 (EST) Received: from localhost ([127.0.0.1]:43010 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OgpwI-0005hY-Py for incoming@patchwork.ozlabs.org; Wed, 04 Aug 2010 22:12:10 -0400 Received: from [140.186.70.92] (port=38861 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ogpnq-0001IG-2n for qemu-devel@nongnu.org; Wed, 04 Aug 2010 22:03:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ogpnn-0007MN-LK for qemu-devel@nongnu.org; Wed, 04 Aug 2010 22:03:25 -0400 Received: from mail.valinux.co.jp ([210.128.90.3]:38254) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ogpnn-0007Lq-5O for qemu-devel@nongnu.org; Wed, 04 Aug 2010 22:03:23 -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 EBA31107935; Thu, 5 Aug 2010 11:03:19 +0900 (JST) Received: (nullmailer pid 14303 invoked by uid 1000); Thu, 05 Aug 2010 02:09:05 -0000 From: Isaku Yamahata To: qemu-devel@nongnu.org Date: Thu, 5 Aug 2010 11:09:01 +0900 Message-Id: <2f375d90b4ba1b3da1b47d4ba302911d390d44e2.1280973617.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, kraxel@redhat.com, mst@redhat.com Subject: [Qemu-devel] [PATCH v2 4/8] pci: make pci_device_reset() aware of qdev. 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 Make pci_device_reset handle qdevfied device and non-converted device differently. Later they will be handled differently. Signed-off-by: Isaku Yamahata --- hw/pci.c | 35 +++++++++++++++++++++++++++++++++-- hw/pci.h | 1 + 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 6a614d1..c48bb3e 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -130,8 +130,7 @@ static void pci_update_irq_status(PCIDevice *dev) } } -/* Reset the device in response to RST# signal. */ -void pci_device_reset(PCIDevice *dev) +void pci_device_reset_default(PCIDevice *dev) { int r; @@ -159,6 +158,38 @@ void pci_device_reset(PCIDevice *dev) pci_update_mappings(dev); } +/* Reset the device in response to RST# signal. */ +void pci_device_reset(PCIDevice *dev) +{ + if (!dev->qdev.info || !dev->qdev.info->reset) { + /* for not qdevified device or reset isn't implemented property. + * So take care of them in PCI generic layer. + */ + pci_device_reset_default(dev); + return; + } + + /* + * 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. + * So move this part to each device specific callback. + */ + + /* For now qdev_reset() is called directly by qemu_system_reset() */ + /* qdev_reset(&dev->qdev); */ + + pci_device_reset_default(dev); +} + /* * Trigger pci bus reset under a given bus. * This functions emulates RST#. diff --git a/hw/pci.h b/hw/pci.h index be05662..ce1feb4 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -210,6 +210,7 @@ PCIBus *pci_bus_new(DeviceState *parent, const char *name, int devfn_min); void pci_bus_reset(PCIBus *bus); void pci_device_reset(PCIDevice *dev); +void pci_device_reset_default(PCIDevice *dev); void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, pci_map_irq_fn map_irq, void *irq_opaque, int nirq);