From patchwork Mon Jul 6 13:24:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 50755 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6A75B229FC for ; Mon, 6 Jul 2015 13:25:18 +0000 (UTC) Received: by laer2 with SMTP id r2sf47205593lae.3 for ; Mon, 06 Jul 2015 06:25:17 -0700 (PDT) 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=Mg8xi7LWgONHt4LhyyvwTIj9X5Smfg5cXDmzu7Z8tcY=; b=XH1bfvg91kRcR+0bZ2E0QbvtMIjVqKTA30LUXOxrLeNejr1pPY8IWOtMITqQ9yki6S MKACQyXuXCYS+v6GBU0NNJjf5wM/sX2OGWQoGhehHxL1OjRtxI80iwPPOzhMaTYT1siI PkRuGsy+rMUCuZ4A5h/S9eeybNYqGW2xzv5zmQjklnYVqvGsVlZc/foBsk9Y6FhZL8dO VS/Zgs6wgXCK63Vo4X/CiOoSFvwkQonfpPlSKjwd3c8cDnQHnxcDmLWoagIgz8ln8OhJ YQvWBdtMBqsj48CqoQkDLgmN3bNW9i7W76tvg29JkuHYpj0j57vQhEPOmDrSoMlInOSU wLRw== X-Gm-Message-State: ALoCoQkQyQtQgdfXR1cY03/efScQKEH0r21TNdkMVawETZ4hd7jobcaKS/XGBO4XYVVRmYILlIiU X-Received: by 10.152.22.71 with SMTP id b7mr30494476laf.3.1436189117390; Mon, 06 Jul 2015 06:25:17 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.39 with SMTP id p7ls172108lap.104.gmail; Mon, 06 Jul 2015 06:25:17 -0700 (PDT) X-Received: by 10.112.89.201 with SMTP id bq9mr24328776lbb.39.1436189117208; Mon, 06 Jul 2015 06:25:17 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id v7si15284815lbj.27.2015.07.06.06.25.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jul 2015 06:25:17 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by lagx9 with SMTP id x9so154715811lag.1 for ; Mon, 06 Jul 2015 06:25:17 -0700 (PDT) X-Received: by 10.152.1.40 with SMTP id 8mr50028179laj.56.1436189116660; Mon, 06 Jul 2015 06:25:16 -0700 (PDT) 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.108.230 with SMTP id hn6csp1725175lbb; Mon, 6 Jul 2015 06:25:16 -0700 (PDT) X-Received: by 10.180.86.73 with SMTP id n9mr89608151wiz.78.1436189114096; Mon, 06 Jul 2015 06:25:14 -0700 (PDT) Received: from mail-wg0-f47.google.com (mail-wg0-f47.google.com. [74.125.82.47]) by mx.google.com with ESMTPS id bl7si30268663wjc.28.2015.07.06.06.25.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jul 2015 06:25:14 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 74.125.82.47 as permitted sender) client-ip=74.125.82.47; Received: by wgjx7 with SMTP id x7so140139233wgj.2 for ; Mon, 06 Jul 2015 06:25:13 -0700 (PDT) X-Received: by 10.194.243.230 with SMTP id xb6mr95924294wjc.13.1436189113732; Mon, 06 Jul 2015 06:25:13 -0700 (PDT) Received: from gnx2579.home (LCaen-156-56-7-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by mx.google.com with ESMTPSA id q4sm28148131wju.14.2015.07.06.06.25.11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jul 2015 06:25:12 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, christoffer.dall@linaro.org, marc.zyngier@arm.com, avi.kivity@gmail.com, mtosatti@redhat.com, feng.wu@intel.com, joro@8bytes.org, b.reynal@virtualopensystems.com Cc: linux-kernel@vger.kernel.org, patches@linaro.org, alex.williamson@redhat.com, pbonzini@redhat.com Subject: [RFC v2 3/9] VFIO: platform: single handler using function pointer Date: Mon, 6 Jul 2015 15:24:37 +0200 Message-Id: <1436189083-32527-4-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1436189083-32527-1-git-send-email-eric.auger@linaro.org> References: <1436189083-32527-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.43 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: , A single handler now is registered whatever the use case: automasked or not. A function pointer is set according to the wished behavior and the handler calls this function. The irq lock is taken/released in the root handler. eventfd_signal can be called in regions not allowed to sleep. Signed-off-by: Eric Auger --- v4: creation --- drivers/vfio/platform/vfio_platform_irq.c | 21 +++++++++++++++------ drivers/vfio/platform/vfio_platform_private.h | 1 + 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/vfio/platform/vfio_platform_irq.c b/drivers/vfio/platform/vfio_platform_irq.c index e39f795..7f8d27c 100644 --- a/drivers/vfio/platform/vfio_platform_irq.c +++ b/drivers/vfio/platform/vfio_platform_irq.c @@ -148,11 +148,8 @@ static int vfio_platform_set_irq_unmask(struct vfio_platform_device *vdev, static irqreturn_t vfio_automasked_irq_handler(int irq, void *dev_id) { struct vfio_platform_irq *irq_ctx = dev_id; - unsigned long flags; int ret = IRQ_NONE; - spin_lock_irqsave(&irq_ctx->lock, flags); - if (!irq_ctx->masked) { ret = IRQ_HANDLED; @@ -161,8 +158,6 @@ static irqreturn_t vfio_automasked_irq_handler(int irq, void *dev_id) irq_ctx->masked = true; } - spin_unlock_irqrestore(&irq_ctx->lock, flags); - if (ret == IRQ_HANDLED) eventfd_signal(irq_ctx->trigger, 1); @@ -178,6 +173,19 @@ static irqreturn_t vfio_irq_handler(int irq, void *dev_id) return IRQ_HANDLED; } +static irqreturn_t vfio_handler(int irq, void *dev_id) +{ + struct vfio_platform_irq *irq_ctx = dev_id; + unsigned long flags; + irqreturn_t ret; + + spin_lock_irqsave(&irq_ctx->lock, flags); + ret = irq_ctx->handler(irq, dev_id); + spin_unlock_irqrestore(&irq_ctx->lock, flags); + + return ret; +} + static void vfio_platform_irq_bypass_stop(struct irq_bypass_producer *prod) { } @@ -228,9 +236,10 @@ static int vfio_set_trigger(struct vfio_platform_device *vdev, int index, } irq->trigger = trigger; + irq->handler = handler; irq_set_status_flags(irq->hwirq, IRQ_NOAUTOEN); - ret = request_irq(irq->hwirq, handler, 0, irq->name, irq); + ret = request_irq(irq->hwirq, vfio_handler, 0, irq->name, irq); if (ret) { kfree(irq->name); eventfd_ctx_put(trigger); diff --git a/drivers/vfio/platform/vfio_platform_private.h b/drivers/vfio/platform/vfio_platform_private.h index 1d2d4d6..9737981 100644 --- a/drivers/vfio/platform/vfio_platform_private.h +++ b/drivers/vfio/platform/vfio_platform_private.h @@ -39,6 +39,7 @@ struct vfio_platform_irq { struct virqfd *unmask; struct virqfd *mask; struct irq_bypass_producer producer; + irqreturn_t (*handler)(int irq, void *dev_id); }; struct vfio_platform_region {