From patchwork Fri Nov 12 02:55:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 70913 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 1EF65B7147 for ; Fri, 12 Nov 2010 13:58:11 +1100 (EST) Received: from localhost ([127.0.0.1]:54906 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PGjpo-000273-Vz for incoming@patchwork.ozlabs.org; Thu, 11 Nov 2010 21:57:53 -0500 Received: from [140.186.70.92] (port=47947 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PGjoT-0001O0-Jq for qemu-devel@nongnu.org; Thu, 11 Nov 2010 21:56:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PGjnl-0000RU-JG for qemu-devel@nongnu.org; Thu, 11 Nov 2010 21:55:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34594) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PGjnl-0000RQ-Bo for qemu-devel@nongnu.org; Thu, 11 Nov 2010 21:55:45 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oAC2ti7N010526 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 11 Nov 2010 21:55:44 -0500 Received: from s20.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oAC2thNu011745; Thu, 11 Nov 2010 21:55:43 -0500 From: Alex Williamson To: kvm@vger.kernel.org Date: Thu, 11 Nov 2010 19:55:43 -0700 Message-ID: <20101112025535.31423.42693.stgit@s20.home> In-Reply-To: <20101112024710.31423.99667.stgit@s20.home> References: <20101112024710.31423.99667.stgit@s20.home> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: chrisw@redhat.com, alex.williamson@redhat.com, qemu-devel@nongnu.org, mst@redhat.com Subject: [Qemu-devel] [PATCH 4/8] pci: Replace used bitmap with capability byte map 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 Capabilities are allocated in bytes, so we can track both whether a byte is used and by what capability in the same structure. Remove pci_reserve_capability() as there are no users. Signed-off-by: Alex Williamson --- hw/pci.c | 16 +++++----------- hw/pci.h | 6 ++---- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 6b2b320..e1e8a77 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -730,7 +730,7 @@ static void pci_config_alloc(PCIDevice *pci_dev) pci_dev->config = qemu_mallocz(config_size); pci_dev->cmask = qemu_mallocz(config_size); pci_dev->wmask = qemu_mallocz(config_size); - pci_dev->used = qemu_mallocz(config_size); + pci_dev->cap_map = qemu_mallocz(config_size); } static void pci_config_free(PCIDevice *pci_dev) @@ -738,7 +738,7 @@ static void pci_config_free(PCIDevice *pci_dev) qemu_free(pci_dev->config); qemu_free(pci_dev->cmask); qemu_free(pci_dev->wmask); - qemu_free(pci_dev->used); + qemu_free(pci_dev->cap_map); } /* -1 for devfn means auto assign */ @@ -1928,7 +1928,7 @@ static int pci_find_space(PCIDevice *pdev, uint8_t size) int offset = PCI_CONFIG_HEADER_SIZE; int i; for (i = PCI_CONFIG_HEADER_SIZE; i < config_size; ++i) - if (pdev->used[i]) + if (pdev->cap_map[i]) offset = i + 1; else if (i - offset + 1 == size) return offset; @@ -2033,7 +2033,7 @@ int pci_add_capability_at_offset(PCIDevice *pdev, uint8_t cap_id, config[PCI_CAP_LIST_ID] = cap_id; config[PCI_CAP_LIST_NEXT] = pdev->config[PCI_CAPABILITY_LIST]; pdev->config[PCI_CAPABILITY_LIST] = offset; - memset(pdev->used + offset, 0xFF, size); + memset(pdev->cap_map + offset, cap_id, size); /* Make capability read-only by default */ memset(pdev->wmask + offset, 0, size); /* Check capability by default */ @@ -2068,7 +2068,7 @@ void pci_del_capability(PCIDevice *pdev, uint8_t cap_id, uint8_t size) memset(pdev->wmask + offset, 0xff, size); /* Clear cmask as device-specific registers can't be checked */ memset(pdev->cmask + offset, 0, size); - memset(pdev->used + offset, 0, size); + memset(pdev->cap_map + offset, 0, size); if (!pdev->config[PCI_CAPABILITY_LIST]) { pdev->config[PCI_STATUS] &= ~PCI_STATUS_CAP_LIST; @@ -2076,12 +2076,6 @@ void pci_del_capability(PCIDevice *pdev, uint8_t cap_id, uint8_t size) } } -/* Reserve space for capability at a known offset (to call after load). */ -void pci_reserve_capability(PCIDevice *pdev, uint8_t offset, uint8_t size) -{ - memset(pdev->used + offset, 0xff, size); -} - uint8_t pci_find_capability(PCIDevice *pdev, uint8_t cap_id) { return pci_find_capability_list(pdev, cap_id, NULL); diff --git a/hw/pci.h b/hw/pci.h index 0712e55..2265c70 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -151,8 +151,8 @@ struct PCIDevice { /* Used to implement R/W bytes */ uint8_t *wmask; - /* Used to allocate config space for capabilities. */ - uint8_t *used; + /* Used to allocate config space and track capabilities. */ + uint8_t *cap_map; /* the following fields are read only */ PCIBus *bus; @@ -239,8 +239,6 @@ int pci_add_capability_at_offset(PCIDevice *pci_dev, uint8_t cap_id, void pci_del_capability(PCIDevice *pci_dev, uint8_t cap_id, uint8_t cap_size); -void pci_reserve_capability(PCIDevice *pci_dev, uint8_t offset, uint8_t size); - uint8_t pci_find_capability(PCIDevice *pci_dev, uint8_t cap_id); uint32_t pci_default_read_config(PCIDevice *d,