From patchwork Wed Jun 10 14:25:08 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 29302 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n5AET3Hr005564 for ; Wed, 10 Jun 2009 14:29:03 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756923AbZFJO2M (ORCPT ); Wed, 10 Jun 2009 10:28:12 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758239AbZFJO2M (ORCPT ); Wed, 10 Jun 2009 10:28:12 -0400 Received: from mx2.redhat.com ([66.187.237.31]:59648 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755802AbZFJO2L (ORCPT ); Wed, 10 Jun 2009 10:28:11 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n5AEQ4oA001694; Wed, 10 Jun 2009 10:26:04 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n5AEQ32x021466; Wed, 10 Jun 2009 10:26:03 -0400 Received: from redhat.com (vpn-6-37.tlv.redhat.com [10.35.6.37]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n5AEPxFb005666; Wed, 10 Jun 2009 10:26:00 -0400 Date: Wed, 10 Jun 2009 17:25:08 +0300 From: "Michael S. Tsirkin" To: Paul Brook Cc: qemu-devel@nongnu.org, Avi Kivity , Carsten Otte , kvm@vger.kernel.org, Rusty Russell , virtualization@lists.linux-foundation.org, Christian Borntraeger , Blue Swirl Subject: Re: [Qemu-devel] [PATCH 05/11] qemu: MSI-X support functions Message-ID: <20090610142508.GA28409@redhat.com> References: <200906100019.59981.paul@codesourcery.com> <20090610094604.GD6844@redhat.com> <200906101507.39823.paul@codesourcery.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <200906101507.39823.paul@codesourcery.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Wed, Jun 10, 2009 at 03:07:34PM +0100, Paul Brook wrote: > > > > Note that platform must set a flag to declare MSI supported. > > > > For PC this will be set by APIC. > > > > > > This sounds wrong. The device shouldn't know or care whether the system > > > has a MSI capable interrupt controller. That's for the guest OS to figure > > > out. > > > > You are right of course. In theory there's nothing that breaks if I > > set this flag to on, on all platforms. OTOH if qemu emulates some > > controller incorrectly, guest might misdetect MSI support in the > > controller, and things will break horribly. > > > > It seems safer to have a flag that can be enabled by people > > that know about a specific platform. > > No. The solution is to fix whatever is broken. That's easy enough then. Patch below. > > If we really need to avoid MSI-X capable devices then that should be done > explicity per-device. i.e. you have a different virtio-net device that does > not use MSI-X. > > Paul Why should it be done per-device? ---> Don't add an option for platforms to disable MSI-X in all devices. Paul Brook will find and fix all platforms that have broken MSI-X emulation. Signed-off-by: Michael S. Tsirkin diff --git a/hw/apic.c b/hw/apic.c index ed03a36..9d44061 100644 --- a/hw/apic.c +++ b/hw/apic.c @@ -945,7 +945,6 @@ int apic_init(CPUState *env) s->cpu_env = env; apic_reset(s); - msix_supported = 1; /* XXX: mapping more APICs at the same memory location */ if (apic_io_memory == 0) { diff --git a/hw/msix.c b/hw/msix.c index ce4e6ba..16efb27 100644 --- a/hw/msix.c +++ b/hw/msix.c @@ -62,9 +62,6 @@ /* Flag to globally disable MSI-X support */ int msix_disable; -/* 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. @@ -232,10 +229,7 @@ void msix_mmio_map(PCIDevice *d, int region_num, int msix_init(struct PCIDevice *dev, unsigned short nentries, unsigned bar_nr, unsigned bar_size) { - int ret = -ENOMEM; - /* Nothing to do if MSI is not supported by interrupt controller */ - if (!msix_supported) - return -ENOTTY; + int ret; if (nentries > MSIX_MAX_ENTRIES) return -EINVAL; diff --git a/hw/msix.h b/hw/msix.h index 79e84a3..2fcadd3 100644 --- a/hw/msix.h +++ b/hw/msix.h @@ -30,6 +30,5 @@ void msix_notify(PCIDevice *dev, unsigned vector); void msix_reset(PCIDevice *dev); extern int msix_disable; -extern int msix_supported; #endif