From patchwork Fri Jan 20 17:26:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 137077 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6870F1007D3 for ; Sat, 21 Jan 2012 05:38:47 +1100 (EST) Received: from localhost ([::1]:57576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RoIJV-0006pl-28 for incoming@patchwork.ozlabs.org; Fri, 20 Jan 2012 12:31:45 -0500 Received: from eggs.gnu.org ([140.186.70.92]:34672) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RoIIM-0004to-Nj for qemu-devel@nongnu.org; Fri, 20 Jan 2012 12:30:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RoII7-0006Bq-Dc for qemu-devel@nongnu.org; Fri, 20 Jan 2012 12:30:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54107) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RoII7-0006BZ-4x for qemu-devel@nongnu.org; Fri, 20 Jan 2012 12:30:19 -0500 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.14.4/8.14.4) with ESMTP id q0KHUIlI014738 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 20 Jan 2012 12:30:18 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q0KHUIfP008514; Fri, 20 Jan 2012 12:30:18 -0500 Received: from amt.cnet (vpn1-5-58.ams2.redhat.com [10.36.5.58]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id q0KHUEPb011519; Fri, 20 Jan 2012 12:30:16 -0500 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id BC1586523B4; Fri, 20 Jan 2012 15:26:58 -0200 (BRST) Received: (from marcelo@localhost) by amt.cnet (8.14.5/8.14.5/Submit) id q0KHQuoc007241; Fri, 20 Jan 2012 15:26:56 -0200 From: Marcelo Tosatti To: Anthony Liguori Date: Fri, 20 Jan 2012 15:26:29 -0200 Message-Id: <60ba3cc231d6bc7b802ad4fe6b6fc159ecb112e2.1327080406.git.mtosatti@redhat.com> In-Reply-To: References: 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. X-Received-From: 209.132.183.28 Cc: Jan Kiszka , qemu-devel@nongnu.org, kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH 03/20] msi: Generalize msix_supported to msi_supported X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jan Kiszka Rename msix_supported to msi_supported and control MSI and MSI-X activation this way. That was likely to original intention for this flag, but MSI support came after MSI-X. Signed-off-by: Jan Kiszka --- hw/msi.c | 8 ++++++++ hw/msi.h | 2 ++ hw/msix.c | 9 ++++----- hw/msix.h | 2 -- hw/pc.c | 4 ++-- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/hw/msi.c b/hw/msi.c index f214fcf..5d6ceb6 100644 --- a/hw/msi.c +++ b/hw/msi.c @@ -36,6 +36,9 @@ #define PCI_MSI_VECTORS_MAX 32 +/* Flag for interrupt controller to declare MSI/MSI-X support */ +bool msi_supported; + /* If we get rid of cap allocator, we won't need this. */ static inline uint8_t msi_cap_sizeof(uint16_t flags) { @@ -116,6 +119,11 @@ int msi_init(struct PCIDevice *dev, uint8_t offset, uint16_t flags; uint8_t cap_size; int config_offset; + + if (!msi_supported) { + return -ENOTSUP; + } + MSI_DEV_PRINTF(dev, "init offset: 0x%"PRIx8" vector: %"PRId8 " 64bit %d mask %d\n", diff --git a/hw/msi.h b/hw/msi.h index 5766018..3040bb0 100644 --- a/hw/msi.h +++ b/hw/msi.h @@ -24,6 +24,8 @@ #include "qemu-common.h" #include "pci.h" +extern bool msi_supported; + bool msi_enabled(const PCIDevice *dev); int msi_init(struct PCIDevice *dev, uint8_t offset, unsigned int nr_vectors, bool msi64bit, bool msi_per_vector_mask); diff --git a/hw/msix.c b/hw/msix.c index f47d26b..3835eaa 100644 --- a/hw/msix.c +++ b/hw/msix.c @@ -15,6 +15,7 @@ */ #include "hw.h" +#include "msi.h" #include "msix.h" #include "pci.h" #include "range.h" @@ -35,9 +36,6 @@ #define MSIX_MAX_ENTRIES 32 -/* Flag for interrupt controller to declare MSI-X support */ -int msix_supported; - /* Add MSI-X capability to the config space for the device. */ /* Given a bar and its size, add MSI-X table on top of it * and fill MSI-X capability in the config space. @@ -238,10 +236,11 @@ int msix_init(struct PCIDevice *dev, unsigned short nentries, unsigned bar_nr, unsigned bar_size) { int ret; + /* Nothing to do if MSI is not supported by interrupt controller */ - if (!msix_supported) + if (!msi_supported) { return -ENOTSUP; - + } if (nentries > MSIX_MAX_ENTRIES) return -EINVAL; diff --git a/hw/msix.h b/hw/msix.h index 7e04336..5aba22b 100644 --- a/hw/msix.h +++ b/hw/msix.h @@ -29,6 +29,4 @@ void msix_notify(PCIDevice *dev, unsigned vector); void msix_reset(PCIDevice *dev); -extern int msix_supported; - #endif diff --git a/hw/pc.c b/hw/pc.c index 85304cf..04304e0 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -36,7 +36,7 @@ #include "elf.h" #include "multiboot.h" #include "mc146818rtc.h" -#include "msix.h" +#include "msi.h" #include "sysbus.h" #include "sysemu.h" #include "blockdev.h" @@ -896,7 +896,7 @@ static DeviceState *apic_init(void *env, uint8_t apic_id) apic_mapped = 1; } - msix_supported = 1; + msi_supported = true; return dev; }