From patchwork Thu Jan 15 13:18:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 43178 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C0F0920D60 for ; Thu, 15 Jan 2015 13:18:54 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id p9sf7938112lbv.1 for ; Thu, 15 Jan 2015 05:18:53 -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=VvLDTz8Ktlptkr6121EoYwnNq3hEO8oiKOlHf8BuPKE=; b=VYRKcmMEdivoBwTvzLf6+gtpyRzFvMcY2qHlYvVWh9Ww7EXQdZnb6KEtQkUI+c0TGE kSHYXv7IGocSLl7MzwfHcb8XwuBy46HWcR5If+vwkI6ad7cT2vNmeZbP48Qs+Ouf/XfI U/tj5y92DlBZ8zoOtLN32B14eUpcFjYTJqAjgo6DLctUVyP6/xGCvRCWBkfOzdAutwRb XNTTwQDbxgSeVAOEHQEkEyntMUcOOaOa8pVQog4DrdEH8hOzjiXPqAH7TcCbqPALmjDf NgHShPHMvYe/xIjT9kEN07Yjc9mlxaOxfOZr7+eI4+40fl+DzYdWu0XtnL5ho6+11nqi EHWQ== X-Gm-Message-State: ALoCoQlO+CkqciPLDjQUWAVU/EsNR5zZRZgKCasUBQqgxVhbLmfq4qRv/bTTk7pfrXHfTbFcO6ID X-Received: by 10.152.2.40 with SMTP id 8mr270473lar.7.1421327933102; Thu, 15 Jan 2015 05:18:53 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.3.170 with SMTP id d10ls206666lad.37.gmail; Thu, 15 Jan 2015 05:18:52 -0800 (PST) X-Received: by 10.112.119.201 with SMTP id kw9mr9504299lbb.99.1421327932961; Thu, 15 Jan 2015 05:18:52 -0800 (PST) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id at8si20697lbc.56.2015.01.15.05.18.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 Jan 2015 05:18:52 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id z11so13175993lbi.10 for ; Thu, 15 Jan 2015 05:18:52 -0800 (PST) X-Received: by 10.112.14.6 with SMTP id l6mr9694838lbc.91.1421327932876; Thu, 15 Jan 2015 05:18:52 -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.9.200 with SMTP id c8csp2030729lbb; Thu, 15 Jan 2015 05:18:52 -0800 (PST) X-Received: by 10.194.48.109 with SMTP id k13mr18467281wjn.7.1421327928555; Thu, 15 Jan 2015 05:18:48 -0800 (PST) Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com. [209.85.212.177]) by mx.google.com with ESMTPS id wj6si2559965wjc.175.2015.01.15.05.18.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 Jan 2015 05:18:48 -0800 (PST) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.177 as permitted sender) client-ip=209.85.212.177; Received: by mail-wi0-f177.google.com with SMTP id l15so17745895wiw.4 for ; Thu, 15 Jan 2015 05:18:48 -0800 (PST) X-Received: by 10.180.7.201 with SMTP id l9mr24225411wia.80.1421327928197; Thu, 15 Jan 2015 05:18:48 -0800 (PST) Received: from midway01-04-00.lavalab ([81.128.185.50]) by mx.google.com with ESMTPSA id o2sm7456332wiy.11.2015.01.15.05.18.47 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 Jan 2015 05:18:47 -0800 (PST) From: Eric Auger To: eric.auger@st.com, christoffer.dall@linaro.org, qemu-devel@nongnu.org, kim.phillips@freescale.com, alex.williamson@redhat.com, agraf@suse.de, peter.maydell@linaro.org Cc: eric.auger@linaro.org, kvmarm@lists.cs.columbia.edu, patches@linaro.org, Bharat.Bhushan@freescale.com, b.reynal@virtualopensystems.com, a.rigo@virtualopensystems.com, a.motakis@virtualopensystems.com, pbonzini@redhat.com, afaerber@suse.de Subject: [PATCH v9 4/7] hw/vfio/platform: add capability to start IRQ propagation Date: Thu, 15 Jan 2015 13:18:14 +0000 Message-Id: <1421327897-1698-5-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1421327897-1698-1-git-send-email-eric.auger@linaro.org> References: <1421327897-1698-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.217.179 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: , Add a reset notify function that enables to start the propagation of interrupts to the guest. Signed-off-by: Eric Auger --- v8 -> v9: - handle failure in vfio_irq_starter --- hw/vfio/platform.c | 52 +++++++++++++++++++++++++++++++++++++++++ include/hw/vfio/vfio-platform.h | 8 +++++++ 2 files changed, 60 insertions(+) diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index b85ad6c..30798d8 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -553,6 +553,58 @@ static void vfio_platform_realize(DeviceState *dev, Error **errp) } } +/* + * Binding to the platform bus IRQ happens on a machine init done + * notifier registered by the platform bus. Only at that time the + * absolute virtual IRQ = GSI is known and allows to setup IRQFD. + * vfio_kick_irqs can typically be used as a reset notifier function. + */ + +/* Start injection of IRQ for a specific VFIO device */ +static int vfio_irq_starter(SysBusDevice *sbdev, void *opaque) +{ + DeviceState *intc = (DeviceState *)opaque; + VFIOPlatformDevice *vdev; + VFIOINTp *intp; + qemu_irq irq; + int gsi, ret; + + if (object_dynamic_cast(OBJECT(sbdev), TYPE_VFIO_PLATFORM)) { + vdev = VFIO_PLATFORM_DEVICE(sbdev); + + QLIST_FOREACH(intp, &vdev->intp_list, next) { + gsi = 0; + while (1) { + irq = qdev_get_gpio_in(intc, gsi); + if (irq == intp->qemuirq) { + break; + } + gsi++; + } + intp->virtualID = gsi; + ret = vdev->start_irq_fn(intp); + if (ret) { + error_report("%s unable to start propagation of IRQ index %d", + vdev->vbasedev.name, intp->pin); + exit(1); + } + } + } + return 0; +} + +/* loop on all VFIO platform devices and start their IRQ injection */ +void vfio_kick_irqs(void *data) +{ + DeviceState *intc = (DeviceState *)data; + DeviceState *dev = + qdev_find_recursive(sysbus_get_default(), TYPE_PLATFORM_BUS_DEVICE); + PlatformBusDevice *pbus = PLATFORM_BUS_DEVICE(dev); + + assert(pbus->done_gathering); + foreach_dynamic_sysbus_device(vfio_irq_starter, intc); +} + static const VMStateDescription vfio_platform_vmstate = { .name = TYPE_VFIO_PLATFORM, .unmigratable = 1, diff --git a/include/hw/vfio/vfio-platform.h b/include/hw/vfio/vfio-platform.h index e55b711..bd1206e 100644 --- a/include/hw/vfio/vfio-platform.h +++ b/include/hw/vfio/vfio-platform.h @@ -74,4 +74,12 @@ typedef struct VFIOPlatformDeviceClass { #define VFIO_PLATFORM_DEVICE_GET_CLASS(obj) \ OBJECT_GET_CLASS(VFIOPlatformDeviceClass, (obj), TYPE_VFIO_PLATFORM) +/** + * vfio_kick_irqs - reset notifier that starts IRQ injection + * for all VFIO dynamic sysbus devices attached to the platform bus. + * + * @opaque: handle to the interrupt controller DeviceState* + */ +void vfio_kick_irqs(void *opaque); + #endif /*HW_VFIO_VFIO_PLATFORM_H*/