From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:53042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFl1w-0001K1-GM for qemu-devel@nongnu.org; Mon, 17 Oct 2011 07:06:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RFl1q-0007H5-P1 for qemu-devel@nongnu.org; Mon, 17 Oct 2011 07:06:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28295) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFl1q-0007Gz-Dq for qemu-devel@nongnu.org; Mon, 17 Oct 2011 07:06:46 -0400 Message-ID: <4E9C0C42.60201@redhat.com> Date: Mon, 17 Oct 2011 13:06:42 +0200 From: Avi Kivity MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC][PATCH 12/45] msi: Introduce MSIRoutingCache List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka Cc: Alex Williamson , Marcelo Tosatti , qemu-devel@nongnu.org, kvm@vger.kernel.org, "Michael S. Tsirkin" On 10/17/2011 11:27 AM, Jan Kiszka wrote: > This cache will help us implementing KVM in-kernel irqchip support > without spreading hooks all over the place. > > KVM requires us to register it first and then deliver it by raising a > pseudo IRQ line returned on registration. While this could be changed > for QEMU-originated MSI messages by adding direct MSI injection, we will > still need this translation for irqfd-originated messages. The > MSIRoutingCache will allow to track those registrations and update them > lazily before the actual delivery. This avoid having to track MSI > vectors at device level (like qemu-kvm currently does). > > > +typedef enum { > + MSI_ROUTE_NONE = 0, > + MSI_ROUTE_STATIC, > +} MSIRouteType; > + > +struct MSIRoutingCache { > + MSIMessage msg; > + MSIRouteType type; > + int kvm_gsi; > + int kvm_irqfd; > +}; > + > diff --git a/hw/pci.h b/hw/pci.h > index 329ab32..5b5d2fd 100644 > --- a/hw/pci.h > +++ b/hw/pci.h > @@ -197,6 +197,10 @@ struct PCIDevice { > MemoryRegion rom; > uint32_t rom_bar; > > + /* MSI routing chaches */ > + MSIRoutingCache *msi_cache; > + MSIRoutingCache *msix_cache; > + > /* MSI entries */ > int msi_entries_nr; > struct KVMMsiMessage *msi_irq_entries; IMO this needlessly leaks kvm information into core qemu. The cache should be completely hidden in kvm code. I think msi_deliver() can hide the use of the cache completely. For pre-registered events like kvm's irqfd, you can use something like qemu_irq qemu_msi_irq(MSIMessage msg) for non-kvm, it simply returns a qemu_irq that triggers a stl_phys(); for kvm, it allocates an irqfd and a permanent entry in the cache and returns a qemu_irq that triggers the irqfd. -- error compiling committee.c: too many arguments to function