From patchwork Wed Jun 23 07:15:28 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 56611 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 55510B6F14 for ; Wed, 23 Jun 2010 18:00:16 +1000 (EST) Received: from localhost ([127.0.0.1]:48839 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ORKSy-0008DX-Ay for incoming@patchwork.ozlabs.org; Wed, 23 Jun 2010 03:33:48 -0400 Received: from [140.186.70.92] (port=40757 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ORKF6-0003mV-TY for qemu-devel@nongnu.org; Wed, 23 Jun 2010 03:19:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1ORKF0-0004Ap-Uh for qemu-devel@nongnu.org; Wed, 23 Jun 2010 03:19:25 -0400 Received: from mail.valinux.co.jp ([210.128.90.3]:52211) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ORKF0-00049z-FN for qemu-devel@nongnu.org; Wed, 23 Jun 2010 03:19:22 -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 7C823107480; Wed, 23 Jun 2010 16:19:21 +0900 (JST) Received: (nullmailer pid 29743 invoked by uid 1000); Wed, 23 Jun 2010 07:15:33 -0000 From: Isaku Yamahata To: qemu-devel@nongnu.org Date: Wed, 23 Jun 2010 16:15:28 +0900 Message-Id: <57f14506e6788d65df4da5b4073e5e1c6ba54e04.1277277076.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: yu.liu@freescale.com, mst@redhat.com, blauwirbel@gmail.com, yamahata@valinux.co.jp, paul@codesourcery.com, aurelien@aurel32.net Subject: [Qemu-devel] [PATCH v5 4/9] pci: remove PCIDeviceInfo::header_type 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 replace PCIDeviceInfo::header_type with is_bridge as suggested by Michael S. Tsirkin Signed-off-by: Isaku Yamahata --- hw/apb_pci.c | 2 +- hw/dec_pci.c | 2 +- hw/pci.c | 15 ++++++++------- hw/pci.h | 8 ++++++-- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/hw/apb_pci.c b/hw/apb_pci.c index 6dd529f..69a774d 100644 --- a/hw/apb_pci.c +++ b/hw/apb_pci.c @@ -434,7 +434,7 @@ static PCIDeviceInfo pbm_pci_host_info = { .qdev.name = "pbm", .qdev.size = sizeof(PCIDevice), .init = pbm_pci_host_init, - .header_type = PCI_HEADER_TYPE_BRIDGE, + .is_bridge = 1, }; static SysBusDeviceInfo pbm_host_info = { diff --git a/hw/dec_pci.c b/hw/dec_pci.c index 024c67c..83ce4cd 100644 --- a/hw/dec_pci.c +++ b/hw/dec_pci.c @@ -90,7 +90,7 @@ static PCIDeviceInfo dec_21154_pci_host_info = { .qdev.name = "dec-21154", .qdev.size = sizeof(PCIDevice), .init = dec_21154_pci_host_init, - .header_type = PCI_HEADER_TYPE_BRIDGE, + .is_bridge = 1, }; static void dec_register_devices(void) diff --git a/hw/pci.c b/hw/pci.c index 1ba209f..a14b74d 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -598,7 +598,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, const char *name, int devfn, PCIConfigReadFunc *config_read, PCIConfigWriteFunc *config_write, - uint8_t header_type) + bool is_bridge) { if (devfn < 0) { for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices); @@ -620,13 +620,12 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, pci_dev->irq_state = 0; pci_config_alloc(pci_dev); - header_type &= ~PCI_HEADER_TYPE_MULTI_FUNCTION; - if (header_type == PCI_HEADER_TYPE_NORMAL) { + if (!is_bridge) { pci_set_default_subsystem_id(pci_dev); } pci_init_cmask(pci_dev); pci_init_wmask(pci_dev); - if (header_type == PCI_HEADER_TYPE_BRIDGE) { + if (is_bridge) { pci_init_wmask_bridge(pci_dev); } @@ -1555,7 +1554,9 @@ static int pci_bridge_initfn(PCIDevice *dev) pci_set_word(dev->config + PCI_STATUS, PCI_STATUS_66MHZ | PCI_STATUS_FAST_BACK); pci_config_set_class(dev->config, PCI_CLASS_BRIDGE_PCI); - dev->config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_BRIDGE; + dev->config[PCI_HEADER_TYPE] = + (dev->config[PCI_HEADER_TYPE] & PCI_HEADER_TYPE_MULTI_FUNCTION) | + PCI_HEADER_TYPE_BRIDGE; pci_set_word(dev->config + PCI_SEC_STATUS, PCI_STATUS_66MHZ | PCI_STATUS_FAST_BACK); return 0; @@ -1606,7 +1607,7 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) devfn = pci_dev->devfn; pci_dev = do_pci_register_device(pci_dev, bus, base->name, devfn, info->config_read, info->config_write, - info->header_type); + info->is_bridge); if (pci_dev == NULL) return -1; rc = info->init(pci_dev); @@ -1856,7 +1857,7 @@ static PCIDeviceInfo bridge_info = { .init = pci_bridge_initfn, .exit = pci_bridge_exitfn, .config_write = pci_bridge_write_config, - .header_type = PCI_HEADER_TYPE_BRIDGE, + .is_bridge = 1, .qdev.props = (Property[]) { DEFINE_PROP_HEX32("vendorid", PCIBridge, vid, 0), DEFINE_PROP_HEX32("deviceid", PCIBridge, did, 0), diff --git a/hw/pci.h b/hw/pci.h index 077387d..76adc66 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -326,8 +326,12 @@ typedef struct { PCIConfigReadFunc *config_read; PCIConfigWriteFunc *config_write; - /* pci config header type */ - uint8_t header_type; + /* + * pci-to-pci bridge or normal device. + * This doesn't mean pci host switch. + * When card bus bridge is supported, this would be enhanced. + */ + int is_bridge; /* pcie stuff */ int is_express; /* is this device pci express? */