From patchwork Mon Aug 10 13:20:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 52237 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 patches.linaro.org (Postfix) with ESMTPS id 0E2BB22919 for ; Mon, 10 Aug 2015 13:22:01 +0000 (UTC) Received: by labia3 with SMTP id ia3sf39648111lab.1 for ; Mon, 10 Aug 2015 06:22:00 -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=tyKvBCvy0IzzEnkus/pMAYL3inZuMuSbASKxoxNl3BE=; b=FfI6pZBKnlYuCgZ46jK//BsBi9X/yv4MrquinAmf2uJ4SB2IL7WmVg7kHYGy98qt4c xf567qt3ThnjP44s6q+lcE7DkgfHnxXTQ2b28Y720jSQzLFyLv6AbE0Nd7bfODFqQlo4 CO4sKNDFryqzMqv55sHF4jr5qqfG34ndgHG6wCSy1S0tziboza9qYu2EX7UFEZS/qRRR rzKNk+qTrtzsNUtanO4P/x/Hg5ywJvUSW1xAeYWpjJ+Ib+7ftV77DSRxtDGLpsJO4gyT NLy0SV5fUvVEdSzYAc3l5ovm6Bpgjhyp4ZYYHWp5nNmigK4MjEboEtENrd/5sMtF/6yn V1oQ== X-Gm-Message-State: ALoCoQmg8R6wtdUAUXgM3kpWk0bViqrby6D7msKs9LsnAQA2HFj43Kutxf20q9vAHdhoE45b/Lgi X-Received: by 10.180.81.70 with SMTP id y6mr2879424wix.2.1439212920020; Mon, 10 Aug 2015 06:22:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.7 with SMTP id a7ls89748lae.68.gmail; Mon, 10 Aug 2015 06:21:59 -0700 (PDT) X-Received: by 10.112.12.233 with SMTP id b9mr19632592lbc.91.1439212919862; Mon, 10 Aug 2015 06:21:59 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id o6si5298879lag.87.2015.08.10.06.21.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Aug 2015 06:21:59 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by lagz9 with SMTP id z9so53399808lag.3 for ; Mon, 10 Aug 2015 06:21:59 -0700 (PDT) X-Received: by 10.112.166.2 with SMTP id zc2mr19881624lbb.29.1439212919568; Mon, 10 Aug 2015 06:21:59 -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.7.198 with SMTP id l6csp1931706lba; Mon, 10 Aug 2015 06:21:58 -0700 (PDT) X-Received: by 10.181.12.20 with SMTP id em20mr25099316wid.28.1439212916955; Mon, 10 Aug 2015 06:21:56 -0700 (PDT) Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com. [209.85.212.181]) by mx.google.com with ESMTPS id i1si16038248wij.108.2015.08.10.06.21.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Aug 2015 06:21:56 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.181 as permitted sender) client-ip=209.85.212.181; Received: by wicne3 with SMTP id ne3so21955859wic.0 for ; Mon, 10 Aug 2015 06:21:56 -0700 (PDT) X-Received: by 10.194.63.20 with SMTP id c20mr48509959wjs.134.1439212916550; Mon, 10 Aug 2015 06:21:56 -0700 (PDT) Received: from gnx2579.home (LCaen-156-56-7-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id fq15sm29517024wjc.12.2015.08.10.06.21.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Aug 2015 06:21:55 -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, alex.williamson@redhat.com, feng.wu@intel.com Cc: linux-kernel@vger.kernel.org, patches@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 03/10] VFIO: platform: single handler using function pointer Date: Mon, 10 Aug 2015 15:20:57 +0200 Message-Id: <1439212864-12954-4-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1439212864-12954-1-git-send-email-eric.auger@linaro.org> References: <1439212864-12954-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.52 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 40f057a..b31b1f0 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) { } @@ -229,9 +237,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 8b4f814..f848a6b 100644 --- a/drivers/vfio/platform/vfio_platform_private.h +++ b/drivers/vfio/platform/vfio_platform_private.h @@ -40,6 +40,7 @@ struct vfio_platform_irq { struct virqfd *mask; struct irq_bypass_producer producer; bool forwarded; + irqreturn_t (*handler)(int irq, void *dev_id); }; struct vfio_platform_region {