From patchwork Thu Dec 2 22:54:33 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 74037 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 AD1BBB6EE9 for ; Fri, 3 Dec 2010 09:59:38 +1100 (EST) Received: from localhost ([127.0.0.1]:52702 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1POI7i-0005Ir-8v for incoming@patchwork.ozlabs.org; Thu, 02 Dec 2010 17:59:34 -0500 Received: from [140.186.70.92] (port=38513 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1POI3B-0003vJ-0j for qemu-devel@nongnu.org; Thu, 02 Dec 2010 17:54:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1POI39-0001dN-95 for qemu-devel@nongnu.org; Thu, 02 Dec 2010 17:54:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:20791) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1POI38-0001dD-W8 for qemu-devel@nongnu.org; Thu, 02 Dec 2010 17:54:51 -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 oB2MsoZR004690 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 2 Dec 2010 17:54:50 -0500 Received: from redhat.com (vpn-200-18.tlv.redhat.com [10.35.200.18]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id oB2Mslcm001612; Thu, 2 Dec 2010 17:54:48 -0500 Date: Fri, 3 Dec 2010 00:54:33 +0200 From: "Michael S. Tsirkin" To: yamahata@valinux.co.jp, qemu-devel@nongnu.org Message-ID: <578a2c45b25f154965c6da15a703646b2d22f57b.1291330353.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mutt-Fcc: =sent User-Agent: Mutt/1.5.21 (2010-09-15) 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: Subject: [Qemu-devel] [PATCH 1/6] pci: untangle pci/msi dependency 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 msi depends on pci but pci should not depend on msi. The only dependency we have is a recent addition of pci_msi_ functions, IMO they add little enough to open-code in the small number of users. Follow-up patches add more cleanups. Signed-off-by: Michael S. Tsirkin --- hw/pci.c | 19 ------------------- hw/pci.h | 3 --- hw/pcie.c | 8 +++++--- hw/pcie_aer.c | 24 ++++++++++++++---------- 4 files changed, 19 insertions(+), 35 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index ca878e8..254647b 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -25,8 +25,6 @@ #include "pci.h" #include "pci_bridge.h" #include "pci_internals.h" -#include "msix.h" -#include "msi.h" #include "monitor.h" #include "net.h" #include "sysemu.h" @@ -1099,23 +1097,6 @@ static void pci_set_irq(void *opaque, int irq_num, int level) pci_change_irq_level(pci_dev, irq_num, change); } -bool pci_msi_enabled(PCIDevice *dev) -{ - return msix_enabled(dev) || msi_enabled(dev); -} - -void pci_msi_notify(PCIDevice *dev, unsigned int vector) -{ - if (msix_enabled(dev)) { - msix_notify(dev, vector); - } else if (msi_enabled(dev)) { - msi_notify(dev, vector); - } else { - /* MSI/MSI-X must be enabled */ - abort(); - } -} - /***********************************************************/ /* monitor info on PCI */ diff --git a/hw/pci.h b/hw/pci.h index 099c251..aa3afe9 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -261,9 +261,6 @@ void do_pci_info_print(Monitor *mon, const QObject *data); void do_pci_info(Monitor *mon, QObject **ret_data); void pci_bridge_update_mappings(PCIBus *b); -bool pci_msi_enabled(PCIDevice *dev); -void pci_msi_notify(PCIDevice *dev, unsigned int vector); - static inline void pci_set_byte(uint8_t *config, uint8_t val) { diff --git a/hw/pcie.c b/hw/pcie.c index f461c1c..d1f0086 100644 --- a/hw/pcie.c +++ b/hw/pcie.c @@ -167,10 +167,12 @@ static void hotplug_event_notify(PCIDevice *dev) * The Port may optionally send an MSI when there are hot-plug events that * occur while interrupt generation is disabled, and interrupt generation is * subsequently enabled. */ - if (!pci_msi_enabled(dev)) { + if (msix_enabled(dev)) { + msix_notify(dev, pcie_cap_flags_get_vector(dev)); + } else if (msi_enabled(dev)) { + msi_notify(dev, pcie_cap_flags_get_vector(dev)); + } else { qemu_set_irq(dev->irq[dev->exp.hpev_intx], dev->exp.hpev_notified); - } else if (dev->exp.hpev_notified) { - pci_msi_notify(dev, pcie_cap_flags_get_vector(dev)); } } diff --git a/hw/pcie_aer.c b/hw/pcie_aer.c index 235ac53..18bbd5a 100644 --- a/hw/pcie_aer.c +++ b/hw/pcie_aer.c @@ -339,10 +339,10 @@ static bool pcie_aer_msg_root_port(PCIDevice *dev, const PCIEAERMsg *msg) if (root_cmd & msg->severity) { /* 6.2.4.1.2 Interrupt Generation */ - if (pci_msi_enabled(dev)) { - if (msi_trigger) { - pci_msi_notify(dev, pcie_aer_root_get_vector(dev)); - } + if (msix_enabled(dev)) { + msix_notify(dev, pcie_aer_root_get_vector(dev)); + } else if (msi_enabled(dev)) { + msi_notify(dev, pcie_aer_root_get_vector(dev)); } else { qemu_set_irq(dev->irq[dev->exp.aer_intx], 1); } @@ -761,16 +761,20 @@ void pcie_aer_root_write_config(PCIDevice *dev, /* 6.2.4.1.2 Interrupt Generation */ /* 0 -> 1 */ - uint32_t root_cmd_set = (root_cmd_prev ^ root_cmd) & root_cmd; + uint32_t root_cmd_set = ~root_cmd_prev & root_cmd; uint32_t root_status = pci_get_long(aer_cap + PCI_ERR_ROOT_STATUS); + bool assert = pcie_aer_root_does_trigger(root_cmd_set, root_status); - if (pci_msi_enabled(dev)) { - if (pcie_aer_root_does_trigger(root_cmd_set, root_status)) { - pci_msi_notify(dev, pcie_aer_root_get_vector(dev)); + if (msix_enabled(dev)) { + if (assert) { + msix_notify(dev, pcie_aer_root_get_vector(dev)); + } + } else if (msi_enabled(dev)) { + if (assert) { + msi_notify(dev, pcie_aer_root_get_vector(dev)); } } else { - int int_level = pcie_aer_root_does_trigger(root_cmd, root_status); - qemu_set_irq(dev->irq[dev->exp.aer_intx], int_level); + qemu_set_irq(dev->irq[dev->exp.aer_intx], assert); } } }