From patchwork Tue Nov 2 05:37:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 69861 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 E8232B70E8 for ; Tue, 2 Nov 2010 16:39:43 +1100 (EST) Received: from localhost ([127.0.0.1]:58074 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PD9at-0008TJ-PP for incoming@patchwork.ozlabs.org; Tue, 02 Nov 2010 01:39:39 -0400 Received: from [140.186.70.92] (port=55144 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PD9ZE-0008S6-PC for qemu-devel@nongnu.org; Tue, 02 Nov 2010 01:37:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PD9ZD-0003Kp-6r for qemu-devel@nongnu.org; Tue, 02 Nov 2010 01:37:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46896) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PD9ZC-0003Kl-VR for qemu-devel@nongnu.org; Tue, 02 Nov 2010 01:37:55 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oA25bsR0003509 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 2 Nov 2010 01:37:54 -0400 Received: from s20.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oA25brM8020792; Tue, 2 Nov 2010 01:37:53 -0400 From: Alex Williamson To: mst@redhat.com, yamahata@valinux.co.jp Date: Mon, 01 Nov 2010 23:37:53 -0600 Message-ID: <20101102053751.10424.7525.stgit@s20.home> In-Reply-To: <20101102053544.10424.42769.stgit@s20.home> References: <20101102053544.10424.42769.stgit@s20.home> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: alex.williamson@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 3/3] msi: Store the capability size in PCIDevice 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 Avoid needing to get the MSI capability flags every time we need to check the capability length. This also makes it accessible outside of msi.c, making it easier for users to filter config space writes using msi_cap and msi_cap_size. Signed-off-by: Alex Williamson --- hw/msi.c | 9 ++++----- hw/pci.h | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/msi.c b/hw/msi.c index 110859b..12e125f 100644 --- a/hw/msi.c +++ b/hw/msi.c @@ -148,6 +148,7 @@ int msi_init(struct PCIDevice *dev, uint8_t offset, } dev->msi_cap = config_offset; + dev->msi_cap_size = cap_size; dev->cap_present |= QEMU_PCI_CAP_MSI; pci_set_word(dev->config + msi_flags_off(dev), flags); @@ -170,14 +171,12 @@ int msi_init(struct PCIDevice *dev, uint8_t offset, void msi_uninit(struct PCIDevice *dev) { - uint8_t cap_size; - if (!(dev->cap_present & QEMU_PCI_CAP_MSI)) return; - cap_size = msi_cap_sizeof(pci_get_word(dev->config + msi_flags_off(dev))); - pci_del_capability(dev, PCI_CAP_ID_MSIX, cap_size); + pci_del_capability(dev, PCI_CAP_ID_MSIX, dev->msi_cap_size); dev->msi_cap = 0; + dev->msi_cap_size = 0; dev->cap_present &= ~QEMU_PCI_CAP_MSI; MSI_DEV_PRINTF(dev, "uninit\n"); } @@ -269,7 +268,7 @@ void msi_write_config(PCIDevice *dev, uint32_t addr, uint32_t val, int len) uint32_t pending; int i; - if (!ranges_overlap(addr, len, dev->msi_cap, msi_cap_sizeof(flags))) { + if (!ranges_overlap(addr, len, dev->msi_cap, dev->msi_cap_size)) { return; } diff --git a/hw/pci.h b/hw/pci.h index a558803..d268806 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -176,8 +176,9 @@ struct PCIDevice { /* Version id needed for VMState */ int32_t version_id; - /* Offset of MSI capability in config space */ + /* Offset & size of MSI capability in config space */ uint8_t msi_cap; + uint8_t msi_cap_size; /* PCI Express */ PCIExpressDevice exp;