From patchwork Fri Feb 13 03:47:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 44649 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BC9EE21527 for ; Fri, 13 Feb 2015 03:47:33 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id h11sf5059886wiw.1 for ; Thu, 12 Feb 2015 19:47:33 -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=NxMvxOKGuUApxryCYm+i41hbUH3VRY1xycH//Q1Mkdi//68tWRewtctlyMsmhznSqG aYJysGJRv6F88noOtUFpd1RL1WDHSglSUQ7URXZTv6REse1TpkwJwiGtNrc6zEloW/SM 8d0Xgx8vkut8P+iGWiJV+pT+VxtAMnWxvcV2r4xIaKmY0yYI6LE/Vlxf3hANCKUiqirR bvPwElOMcMVBxdbioDOA+Ei/2UeUnL9z1z7gVq3teQOjN1rSKzkTFFeHwp16zk9VJ0cm Dq3qGY5XacRHOO8+2MyTwjmD/54HgFYt21kxPkLg2ajqJoYI/gxBwULrqKU1DV/B/4aC xxBw== X-Gm-Message-State: ALoCoQkps+mJnE21mdW6vzDWaOtLgapoGySz5cOYELw6+c5KgWgTQ6x4Nr05IyDAuDtJLEeBZI2q X-Received: by 10.112.131.106 with SMTP id ol10mr1040494lbb.20.1423799252986; Thu, 12 Feb 2015 19:47:32 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.73 with SMTP id c9ls270845lae.74.gmail; Thu, 12 Feb 2015 19:47:32 -0800 (PST) X-Received: by 10.112.155.168 with SMTP id vx8mr6081231lbb.110.1423799252831; Thu, 12 Feb 2015 19:47:32 -0800 (PST) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id s1si627070lbf.154.2015.02.12.19.47.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Feb 2015 19:47:32 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by mail-lb0-f180.google.com with SMTP id z12so13278313lbi.11 for ; Thu, 12 Feb 2015 19:47:32 -0800 (PST) X-Received: by 10.112.162.167 with SMTP id yb7mr5956763lbb.76.1423799252568; Thu, 12 Feb 2015 19:47:32 -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.35.133 with SMTP id h5csp824241lbj; Thu, 12 Feb 2015 19:47:32 -0800 (PST) X-Received: by 10.194.6.70 with SMTP id y6mr13578998wjy.97.1423799246916; Thu, 12 Feb 2015 19:47:26 -0800 (PST) Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com. [209.85.212.179]) by mx.google.com with ESMTPS id j2si1606994wjx.184.2015.02.12.19.47.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Feb 2015 19:47:26 -0800 (PST) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.179 as permitted sender) client-ip=209.85.212.179; Received: by mail-wi0-f179.google.com with SMTP id hi2so9129500wib.0 for ; Thu, 12 Feb 2015 19:47:26 -0800 (PST) X-Received: by 10.180.189.67 with SMTP id gg3mr12057006wic.4.1423799246590; Thu, 12 Feb 2015 19:47:26 -0800 (PST) Received: from midway01-04-00.lavalab ([81.128.185.50]) by mx.google.com with ESMTPSA id fw5sm8222550wjb.14.2015.02.12.19.47.25 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 12 Feb 2015 19:47:26 -0800 (PST) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, christoffer.dall@linaro.org, qemu-devel@nongnu.org, alex.williamson@redhat.com, peter.maydell@linaro.org, agraf@suse.de, b.reynal@virtualopensystems.com, feng.wu@intel.com Cc: kvmarm@lists.cs.columbia.edu, patches@linaro.org, pbonzini@redhat.com, afaerber@suse.de, kim.phillips@freescale.com, Bharat.Bhushan@freescale.com, a.rigo@virtualopensystems.com, a.motakis@virtualopensystems.com Subject: [PATCH v10 4/7] hw/vfio/platform: add capability to start IRQ propagation Date: Fri, 13 Feb 2015 03:47:09 +0000 Message-Id: <1423799232-10816-5-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1423799232-10816-1-git-send-email-eric.auger@linaro.org> References: <1423799232-10816-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.180 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*/