From patchwork Mon Aug 10 13:21:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 52240 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id 9C4B222919 for ; Mon, 10 Aug 2015 13:22:07 +0000 (UTC) Received: by wijp15 with SMTP id p15sf38831666wij.3 for ; Mon, 10 Aug 2015 06:22:07 -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=TKGUGD35L1d0Vch/7RVi3N4NVmxwIjq7wMSA9TfzKPo=; b=UTVzws7yrD5BlxMqMyd3VrlXfs75qD8B1sa3XyNUFUS7PbyTSJRY6zx9VUzeIQJ9Uv z+b87hG66sWhkJeJ1J2fDpsMwqSvgTyZ1EHBPLGsPR70XLv0CujbooYgXAncdC+wDzL5 1dO4lPMdubifxsM66xLl5/Zx9G92iXfEpM+oivb1/2iOGk0dU1mJ/nzAj+psjbcJ9HLC SQ7xCy6hwhQox5cuwAaAJMATesEX+WH2v5ntH/qNN5o9WwQmVJAH1xCl41+4ar38mqIQ gLXXPyI1w9yrnDpI2x1r3Tyu24vLWvtG94iax4RDJKrF5RYxNSRQz9dQvpEWEjql8DFX t+rQ== X-Gm-Message-State: ALoCoQmSmpGSTF3ITAVPPNQFYSm+XbxPNqIcMWKMEqT4EKqbF9E2Hl+SwMpMGu3DAuPdVDvegXRg X-Received: by 10.112.16.200 with SMTP id i8mr6369240lbd.20.1439212926933; Mon, 10 Aug 2015 06:22:06 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.20.69 with SMTP id l5ls730689lae.73.gmail; Mon, 10 Aug 2015 06:22:06 -0700 (PDT) X-Received: by 10.152.8.234 with SMTP id u10mr19983095laa.8.1439212926632; Mon, 10 Aug 2015 06:22:06 -0700 (PDT) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id m18si13976890lbg.157.2015.08.10.06.22.06 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Aug 2015 06:22:06 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by lbbsx3 with SMTP id sx3so11261918lbb.0 for ; Mon, 10 Aug 2015 06:22:06 -0700 (PDT) X-Received: by 10.152.170.230 with SMTP id ap6mr3473523lac.73.1439212926526; Mon, 10 Aug 2015 06:22:06 -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 l6csp1931763lba; Mon, 10 Aug 2015 06:22:05 -0700 (PDT) X-Received: by 10.180.95.35 with SMTP id dh3mr24600626wib.30.1439212921309; Mon, 10 Aug 2015 06:22:01 -0700 (PDT) Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com. [209.85.212.179]) by mx.google.com with ESMTPS id u10si16037140wiv.111.2015.08.10.06.22.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Aug 2015 06:22:01 -0700 (PDT) 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 wicne3 with SMTP id ne3so135770424wic.1 for ; Mon, 10 Aug 2015 06:22:01 -0700 (PDT) X-Received: by 10.194.97.196 with SMTP id ec4mr44099951wjb.3.1439212920984; Mon, 10 Aug 2015 06:22:00 -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.59 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Aug 2015 06:22:00 -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 06/10] VFIO: platform: add irq bypass producer management Date: Mon, 10 Aug 2015 15:21:00 +0200 Message-Id: <1439212864-12954-7-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.217.173 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: , This patch populates the IRQ bypass callacks: - stop/start producer simply consist in disabling/enabling the host irq - add/del consumer: basically set the automasked flag to false/true Signed-off-by: Eric Auger --- v2 -> v3: - vfio_platform_irq_bypass_add_consumer now returns an error in case the IRQ is recognized as active - active boolean not set anymore - do not VFIO mask the IRQ anymore on unforward v1 -> v2: - device handle caching in vfio_platform_device is introduced in a separate patch - use container_of --- drivers/vfio/platform/vfio_platform_irq.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/vfio/platform/vfio_platform_irq.c b/drivers/vfio/platform/vfio_platform_irq.c index efaee58..400a188 100644 --- a/drivers/vfio/platform/vfio_platform_irq.c +++ b/drivers/vfio/platform/vfio_platform_irq.c @@ -224,23 +224,44 @@ static int vfio_platform_is_active(struct vfio_platform_irq *irq) static void vfio_platform_irq_bypass_stop(struct irq_bypass_producer *prod) { + disable_irq(prod->irq); } static void vfio_platform_irq_bypass_start(struct irq_bypass_producer *prod) { + enable_irq(prod->irq); } static int vfio_platform_irq_bypass_add_consumer( struct irq_bypass_producer *prod, struct irq_bypass_consumer *cons) { - return 0; + struct vfio_platform_irq *irq = + container_of(prod, struct vfio_platform_irq, producer); + + /* + * if the IRQ is active at irqchip level or VFIO (auto)masked + * this means the host IRQ is already under injection in the + * guest and this not safe to change the forwarding state at + * that stage. + * It is not possible to differentiate user-space masking + * from auto-masking, leading to possible false detection of + * active state. + */ + if (vfio_platform_is_active(irq)) + return -EAGAIN; + + return vfio_platform_set_automasked(irq, false); } static void vfio_platform_irq_bypass_del_consumer( struct irq_bypass_producer *prod, struct irq_bypass_consumer *cons) { + struct vfio_platform_irq *irq = + container_of(prod, struct vfio_platform_irq, producer); + + vfio_platform_set_automasked(irq, true); } static int vfio_set_trigger(struct vfio_platform_device *vdev, int index,