From patchwork Sun Nov 30 18:35:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 41737 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C487F24001 for ; Sun, 30 Nov 2014 18:36:05 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id ge10sf2197008lab.4 for ; Sun, 30 Nov 2014 10:36:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=atKWCzrZiruMwHnTN4BvhQYQKzyJOFIX1DneCpFC7E0=; b=bf/CTPbMo0/bzlUoMDJGaNz3H2vAunk0J9vADjlwNaApVmQxP6H9cAhm1XFqy8FAqn qRxujAVpmf735xeb1JuFvkq9X/dXgF/mKZsfdr/mLwCF+7XnH3JVWVUhrLjpMo8FJxcT uNS19SYqtlwt9U4T7awSF6MGQ8KOUGIqDkif0O/gU/RMgNqxNMvxtLTtIG6Bvo2UVyl1 49MjX2MNF0VzcjV6yG2CUSaqMxu0oK6T5DZM3mnOmPGhFemeTBMAU+soivAQJnrwnz2Z pQzYepB0/XAWeFCp38dackST3NUOSqgpimD6ZD12SGHA3N+ZM8q4Og+Jdn1ByG/qkVvr ghjQ== X-Gm-Message-State: ALoCoQlPwaexGh0m9E0aUlySEpLi9fEnrx6hCrAEqqH8GDrhMTXUV0D/xKK+0n73d1ubTKmalhVG X-Received: by 10.152.10.233 with SMTP id l9mr14774017lab.0.1417372564772; Sun, 30 Nov 2014 10:36:04 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.193 with SMTP id d1ls1039127lah.85.gmail; Sun, 30 Nov 2014 10:36:04 -0800 (PST) X-Received: by 10.152.36.232 with SMTP id t8mr48039356laj.6.1417372564329; Sun, 30 Nov 2014 10:36:04 -0800 (PST) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id g8si15664312lae.48.2014.11.30.10.36.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 30 Nov 2014 10:36:03 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by mail-la0-f44.google.com with SMTP id ge10so7738962lab.3 for ; Sun, 30 Nov 2014 10:36:03 -0800 (PST) X-Received: by 10.112.189.10 with SMTP id ge10mr52520376lbc.23.1417372563917; Sun, 30 Nov 2014 10:36:03 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp172720lbc; Sun, 30 Nov 2014 10:36:03 -0800 (PST) X-Received: by 10.194.58.180 with SMTP id s20mr87812520wjq.28.1417372563215; Sun, 30 Nov 2014 10:36:03 -0800 (PST) Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com. [74.125.82.50]) by mx.google.com with ESMTPS id eh5si48770287wic.3.2014.11.30.10.36.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 30 Nov 2014 10:36:03 -0800 (PST) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 74.125.82.50 as permitted sender) client-ip=74.125.82.50; Received: by mail-wg0-f50.google.com with SMTP id k14so12291540wgh.23 for ; Sun, 30 Nov 2014 10:36:03 -0800 (PST) X-Received: by 10.194.200.1 with SMTP id jo1mr70601199wjc.64.1417372563001; Sun, 30 Nov 2014 10:36:03 -0800 (PST) Received: from midway01-04-00.lavalab ([81.128.185.50]) by mx.google.com with ESMTPSA id z7sm38794058wia.22.2014.11.30.10.36.01 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 30 Nov 2014 10:36:02 -0800 (PST) From: Eric Auger To: eric.auger@st.com, christoffer.dall@linaro.org, qemu-devel@nongnu.org, agraf@suse.de, pbonzini@redhat.com, kim.phillips@freescale.com, a.rigo@virtualopensystems.com, manish.jaggi@caviumnetworks.com, joel.schopp@amd.com, zhaoshenglong@huawei.com, ard.biesheuvel@linaro.org Cc: eric.auger@linaro.org, kvmarm@lists.cs.columbia.edu, patches@linaro.org, alex.williamson@redhat.com, peter.maydell@linaro.org, will.deacon@arm.com, Bharat.Bhushan@freescale.com, stuart.yoder@freescale.com, a.motakis@virtualopensystems.com Subject: [PATCH v8 14/19] hw/arm/virt: add support for VFIO devices Date: Sun, 30 Nov 2014 18:35:19 +0000 Message-Id: <1417372524-12936-15-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1417372524-12936-1-git-send-email-eric.auger@linaro.org> References: <1417372524-12936-1-git-send-email-eric.auger@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: eric.auger@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , VFIO devices are dynamic sysbus devices. They could already be instantiated. However for them to be functional, IRQ injection must be programmed and started. This programming must happen after the sysbus devices are attached to the platform bus and IRQ are bound. Only at that time the GSI they are connected to are identified and irqfd can be programmed. Binding happens in a machine init done notifier registered by the platform bus init. The IRQ start is done in a reset notifier. This patchs adds the registration of the IRQ start notifier in machvirt. Signed-off-by: Eric Auger --- v7 -> v8: - vfio_kick_irqs replaces older vfio_register_irq_starter. The new function registers a reset notifier while the older registered a machine init done notifier. - Given the fact platform_bus_first_irq has become part of a const struct its handle cannot be passed as a void* to the reset notifier. We now pass the interrupt DeviceState*. - create_gic now returns the DeviceState handle of the gic so that it can be passed to the reset notifier registration --- hw/arm/virt.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 37326a9..346b04a 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -44,6 +44,7 @@ #include "qemu/error-report.h" #include "hw/arm/sysbus-fdt.h" #include "hw/platform-bus.h" +#include "hw/vfio/vfio-platform.h" #define NUM_VIRTIO_TRANSPORTS 32 @@ -330,7 +331,7 @@ static void fdt_add_gic_node(const VirtBoardInfo *vbi) qemu_fdt_setprop_cell(vbi->fdt, "/intc", "phandle", gic_phandle); } -static void create_gic(const VirtBoardInfo *vbi, qemu_irq *pic) +static DeviceState *create_gic(const VirtBoardInfo *vbi, qemu_irq *pic) { /* We create a standalone GIC v2 */ DeviceState *gicdev; @@ -378,6 +379,7 @@ static void create_gic(const VirtBoardInfo *vbi, qemu_irq *pic) } fdt_add_gic_node(vbi); + return gicdev; } static void create_uart(const VirtBoardInfo *vbi, qemu_irq *pic) @@ -537,7 +539,8 @@ static void create_flash(const VirtBoardInfo *vbi) } static void create_platform_bus(VirtBoardInfo *vbi, qemu_irq *pic, - const ARMPlatformBusSystemParams *system_params) + const ARMPlatformBusSystemParams *system_params, + DeviceState *gic) { DeviceState *dev; SysBusDevice *s; @@ -571,6 +574,9 @@ static void create_platform_bus(VirtBoardInfo *vbi, qemu_irq *pic, memory_region_add_subregion(sysmem, system_params->platform_bus_base, sysbus_mmio_get_region(s, 0)); + + /* setup VFIO signaling/IRQFD for all VFIO platform sysbus devices */ + qemu_register_reset(vfio_kick_irqs, gic); } static void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size) @@ -589,6 +595,7 @@ static void machvirt_init(MachineState *machine) MemoryRegion *ram = g_new(MemoryRegion, 1); const char *cpu_model = machine->cpu_model; VirtBoardInfo *vbi; + DeviceState *gic; if (!cpu_model) { cpu_model = "cortex-a15"; @@ -646,7 +653,7 @@ static void machvirt_init(MachineState *machine) create_flash(vbi); - create_gic(vbi, pic); + gic = create_gic(vbi, pic); create_uart(vbi, pic); @@ -658,7 +665,7 @@ static void machvirt_init(MachineState *machine) */ create_virtio_devices(vbi, pic); - create_platform_bus(vbi, pic, &platform_bus_params); + create_platform_bus(vbi, pic, &platform_bus_params, gic); vbi->bootinfo.ram_size = machine->ram_size; vbi->bootinfo.kernel_filename = machine->kernel_filename;