Received: from eggs.gnu.org ([2001:4830:134:3::10]:40529) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzuwE-0005c7-Nd for qemu-devel@nongnu.org; Wed, 25 Jun 2014 17:41:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wzuw8-0001pE-IA for qemu-devel@nongnu.org; Wed, 25 Jun 2014 17:41:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57251) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wzuw8-0001p9-9I for qemu-devel@nongnu.org; Wed, 25 Jun 2014 17:41:00 -0400 Message-ID: <1403732452.31091.45.camel@ul30vt.home> From: Alex Williamson Date: Wed, 25 Jun 2014 15:40:52 -0600 In-Reply-To: <53AB3EF8.7040401@suse.de> References: <1401695374-4287-1-git-send-email-eric.auger@linaro.org> <1401695374-4287-6-git-send-email-eric.auger@linaro.org> <53AB3EF8.7040401@suse.de> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC v3 05/10] vfio: Add initial IRQ support in platform device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: peter.maydell@linaro.org, kim.phillips@freescale.com, eric.auger@st.com, Eric Auger , patches@linaro.org, a.rigo@virtualopensystems.com, qemu-devel@nongnu.org, stuart.yoder@freescale.com, christophe.barnichon@st.com, a.motakis@virtualopensystems.com, kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org On Wed, 2014-06-25 at 23:28 +0200, Alexander Graf wrote: > On 02.06.14 09:49, Eric Auger wrote: > > This patch brings a first support for device IRQ assignment to a > > KVM guest. Code is inspired of PCI INTx code. > > > > General principle of IRQ handling: > > > > when a physical IRQ occurs, VFIO driver signals an eventfd that was > > registered by the QEMU VFIO platform device. The eventfd handler > > (vfio_intp_interrupt) injects the IRQ through QEMU/KVM and also > > disables MMIO region fast path (where MMIO regions are mapped as > > RAM). The purpose is to trap the IRQ status register guest reset. > > The physical interrupt is unmasked on the first read/write in any > > MMIO region. It was masked in the VFIO driver at the instant it > > signaled the eventfd. > > This doesn't sound like a very promising generic scheme to me. I can > easily see devices requiring 2 or 3 or more accesses until they're > pulling down the IRQ line. During that time interrupts will keep firing, > queue up in the irqfd and get at us as spurious interrupts. > > Can't we handle it like PCI where we require devices to not share an > interrupt line? Then we can just wait until the EOI in the interrupt > controller. QEMU's interrupt abstraction makes this really difficult and something that's not generally necessary outside of device assignment. I spent a long time trying to figure out how we'd do it for PCI before I came up with this super generic hack that works surprisingly well. Yes, we may get additional spurious interrupts, but from a host perspective they're rate limited by the guest poking hardware, so there's a feedback loop. Also note that assuming this is the same approach we take for PCI, this mode is only used for the non-KVM accelerated path. When we have a KVM irqchip that supports a resampling irqfd then we can get an eventfd signal back at the point when we should unmask the interrupt on the host. Creating a cross-architecture QEMU interface to give you a callback when the architecture's notion of a resampling event occurs is not a trivial undertaking. Thanks, Alex