From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37258) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wzuk4-0000mA-Ux for qemu-devel@nongnu.org; Wed, 25 Jun 2014 17:28:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wzujz-00064u-25 for qemu-devel@nongnu.org; Wed, 25 Jun 2014 17:28:32 -0400 Received: from cantor2.suse.de ([195.135.220.15]:57165 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wzujy-00064o-RM for qemu-devel@nongnu.org; Wed, 25 Jun 2014 17:28:26 -0400 Message-ID: <53AB3EF8.7040401@suse.de> Date: Wed, 25 Jun 2014 23:28:24 +0200 From: Alexander Graf MIME-Version: 1.0 References: <1401695374-4287-1-git-send-email-eric.auger@linaro.org> <1401695374-4287-6-git-send-email-eric.auger@linaro.org> In-Reply-To: <1401695374-4287-6-git-send-email-eric.auger@linaro.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed 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: Eric Auger , eric.auger@st.com, christoffer.dall@linaro.org, qemu-devel@nongnu.org, kim.phillips@freescale.com, a.rigo@virtualopensystems.com Cc: peter.maydell@linaro.org, patches@linaro.org, stuart.yoder@freescale.com, alex.williamson@redhat.com, christophe.barnichon@st.com, a.motakis@virtualopensystems.com, kvmarm@lists.cs.columbia.edu 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. Alex > > A single IRQ can be forwarded to the guest at a time, ie. before a > new virtual IRQ to be injected, the previous active one must have > completed. > > When no IRQ is pending anymore, fast path can be restored. This is > done on mmap_timer scheduling. > > irqfd support will be added in a subsequent patch. irqfd brings a > framework where the eventfd is handled on kernel side instead of in > user-side as currently done, hence improving the performance. > > Although the code is prepared to support multiple IRQs, this is not > tested at that stage. > > Tested on Calxeda Midway xgmac which can be directly assigned to one > guest (unfortunately only the main IRQ is exercised). A KVM patch is > required to invalidate stage2 entries on RAM memory region destruction > (https://patches.linaro.org/27691/). Without that patch, slow/fast path > switch cannot work. > > change v2 -> v3: > > - Move mmap_timer and mmap_timeout in new VFIODevice struct as > PCI/platform factorization. > - multiple IRQ handling (a pending IRQ queue is added) - not tested - > - create vfio_mmap_set_enabled as in PCI code > - name of irq changed in virt > > Signed-off-by: Eric Auger