From patchwork Mon Jul 23 05:32:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 172544 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D9C332C0335 for ; Mon, 23 Jul 2012 15:55:22 +1000 (EST) Received: from localhost ([::1]:58303 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StBH0-0004y5-Jp for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2012 01:33:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40762) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StBGa-0003rF-OY for qemu-devel@nongnu.org; Mon, 23 Jul 2012 01:33:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1StBGY-0004DR-77 for qemu-devel@nongnu.org; Mon, 23 Jul 2012 01:33:12 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:36637) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StBGY-0004Bt-0g for qemu-devel@nongnu.org; Mon, 23 Jul 2012 01:33:10 -0400 Received: by mail-pb0-f45.google.com with SMTP id ro12so10176751pbb.4 for ; Sun, 22 Jul 2012 22:33:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=zBdEnZssSbA2q+gFzjOBpwzNVSAYE+gmH1dWQ4Sv8EA=; b=msCjlBDtOn3nuZT5TNhwWEfkeMhfsiFn5LETmcLLcNPkf2INRjAi6SgtB62aVUIgyf cgs5tfg87oMQhHfHKyOaixML0a3CSAOOXgVbFqvhn+yeIBXK3HE7c98R03WJUJfY7zO0 N9FNZw6281/NoCZnL2RPyj8Mxcu/211lwfyGj2/Rv4l1Btlf/xk1gNJoXn4ZcaZx5N4k aE/Zak07NOmeVGW4+4C4qbHEGFvAsQg5m7RkIkwK4srr5lQqZZNUp/g1ZFg/mg0oMC0g NKLdTIqbT+60fkLRvxhoeJjkPqSbfpp+bdijPHpIqybpYg1TZuJPxr2BprolbhPToMf+ uv3w== Received: by 10.68.240.69 with SMTP id vy5mr32058682pbc.156.1343021589457; Sun, 22 Jul 2012 22:33:09 -0700 (PDT) Received: from ka1.ozlabs.ibm.com (ibmaus65.lnk.telstra.net. [165.228.126.9]) by mx.google.com with ESMTPS id wf7sm9238869pbc.34.2012.07.22.22.33.06 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 22 Jul 2012 22:33:08 -0700 (PDT) From: Alexey Kardashevskiy To: Alex Williamson Date: Mon, 23 Jul 2012 15:32:47 +1000 Message-Id: <1343021567-3701-4-git-send-email-aik@ozlabs.ru> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1343021567-3701-1-git-send-email-aik@ozlabs.ru> References: <1342070995.2229.88.camel@bling.home> <1343021567-3701-1-git-send-email-aik@ozlabs.ru> X-Gm-Message-State: ALoCoQlaS9JuMAiW34F7Nc4GJkK/DR403kiu46z72KvjsVVDku7kFnKn7jTnWQV7zwQXT8w63DQH X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: Alexey Kardashevskiy , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson Subject: [Qemu-devel] [PATCH 3/3] vfio-pci: rework of EOI 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 Originally VFIO is coded to support IOAPIC only (i.e. x86). The patch adds XICS (POWERPC interrupt controller) and replaces ioapic_add_gsi_eoi_notifier with unified macro to have as little #ifdef TARGET_PPC64 as possible. Still needs some rework to get rid of #ifdef TARGET_PPC64. Signed-off-by: Alexey Kardashevskiy --- hw/vfio_pci.c | 24 ++++++++++++++++-------- hw/vfio_pci.h | 1 - 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/hw/vfio_pci.c b/hw/vfio_pci.c index fd65731..cd68fe0 100644 --- a/hw/vfio_pci.c +++ b/hw/vfio_pci.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -44,6 +43,15 @@ #include "range.h" #include "vfio_pci.h" +#ifndef TARGET_PPC64 +#include +#include "ioapic.h" +#define vfio_irq_add_eoi_notifier ioapic_add_gsi_eoi_notifier +#else +#include "xics.h" +#define vfio_irq_add_eoi_notifier xics_add_eoi_notifier +#endif + //#define DEBUG_VFIO #ifdef DEBUG_VFIO #define DPRINTF(fmt, ...) \ @@ -258,7 +266,7 @@ static void vfio_enable_intx_kvm(VFIODevice *vdev) irqfd.fd = event_notifier_get_fd(&vdev->intx.interrupt); qemu_set_fd_handler(irqfd.fd, NULL, NULL, vdev); - ioapic_remove_gsi_eoi_notifier(&vdev->intx.eoi, vdev->intx.irq); + notifier_remove(&vdev->intx.eoi); vfio_mask_intx(vdev); vdev->intx.pending = false; qemu_set_irq(vdev->pdev.irq[vdev->intx.pin], 0); @@ -294,7 +302,7 @@ static void vfio_enable_intx_kvm(VFIODevice *vdev) return; fail: - ioapic_add_gsi_eoi_notifier(&vdev->intx.eoi, vdev->intx.irq); + vfio_irq_add_eoi_notifier(&vdev->intx.eoi, vdev->intx.irq); qemu_set_fd_handler(irqfd.fd, vfio_intx_interrupt, NULL, vdev); vfio_unmask_intx(vdev); #endif @@ -341,7 +349,7 @@ static void vfio_disable_intx_kvm(VFIODevice *vdev) event_notifier_cleanup(&vdev->intx.unmask); - ioapic_add_gsi_eoi_notifier(&vdev->intx.eoi, vdev->intx.irq); + vfio_irq_add_eoi_notifier(&vdev->intx.eoi, vdev->intx.irq); qemu_set_fd_handler(irqfd.fd, vfio_intx_interrupt, NULL, vdev); vfio_unmask_intx(vdev); @@ -366,7 +374,7 @@ static void vfio_update_irq(Notifier *notify, void *data) vdev->host.func, vdev->intx.irq, irq); vfio_disable_intx_kvm(vdev); - ioapic_remove_gsi_eoi_notifier(&vdev->intx.eoi, vdev->intx.irq); + notifier_remove(&vdev->intx.eoi); vdev->intx.irq = irq; @@ -375,7 +383,7 @@ static void vfio_update_irq(Notifier *notify, void *data) return; } - ioapic_add_gsi_eoi_notifier(&vdev->intx.eoi, vdev->intx.irq); + vfio_irq_add_eoi_notifier(&vdev->intx.eoi, vdev->intx.irq); vfio_enable_intx_kvm(vdev); /* Re-enable the interrupt in cased we missed an EOI */ @@ -404,7 +412,7 @@ static int vfio_enable_intx(VFIODevice *vdev) vdev->intx.pin = pin - 1; /* Pin A (1) -> irq[0] */ vdev->intx.irq = pci_get_irq(&vdev->pdev, vdev->intx.pin); vdev->intx.eoi.notify = vfio_eoi; - ioapic_add_gsi_eoi_notifier(&vdev->intx.eoi, vdev->intx.irq); + vfio_irq_add_eoi_notifier(&vdev->intx.eoi, vdev->intx.irq); vdev->intx.update_irq.notify = vfio_update_irq; pci_add_irq_update_notifier(&vdev->pdev, &vdev->intx.update_irq); @@ -441,7 +449,7 @@ static void vfio_disable_intx(VFIODevice *vdev) vfio_disable_irqindex(vdev, VFIO_PCI_INTX_IRQ_INDEX); pci_remove_irq_update_notifier(&vdev->intx.update_irq); - ioapic_remove_gsi_eoi_notifier(&vdev->intx.eoi, vdev->intx.irq); + notifier_remove(&vdev->intx.eoi); fd = event_notifier_get_fd(&vdev->intx.interrupt); qemu_set_fd_handler(fd, NULL, NULL, vdev); diff --git a/hw/vfio_pci.h b/hw/vfio_pci.h index 00bb3dd..d1a7434 100644 --- a/hw/vfio_pci.h +++ b/hw/vfio_pci.h @@ -4,7 +4,6 @@ #include "qemu-common.h" #include "qemu-queue.h" #include "pci.h" -#include "ioapic.h" #include "event_notifier.h" typedef struct VFIOPCIHostDevice {