From patchwork Mon Jul 6 13:24:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 50759 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7EB6F229FC for ; Mon, 6 Jul 2015 13:25:32 +0000 (UTC) Received: by wguu7 with SMTP id u7sf50147972wgu.0 for ; Mon, 06 Jul 2015 06:25:31 -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=E12vxHVlsd/I0qw/XZJnemnAfFAzSyX0cJKBvdla/NU=; b=kwRvxn1KQ5ySdv0rovRIxznGauemmLlh2HW9IoL02cZ/AkSlZjUYafUn67AKsj5goR 1eNXh07eGTZTBbYWZlrFXquJzQS9Q3d10IopoQqMeXzf5w/6NycuzyGb9dGkz9sA0B1b jVwlFEQAG9ll9EmID36MTwpzzZEKe2SqBus4yjdgIm4Od+ZMYu58HvlI8AKE5jaZC9wG hAI4c7nmTx/ER4JLAlASl71irkNMmYYAwwzsodwnGYQbIYTAkQKGkMWB+MNy715QHbyX DUrrIcNb/hqYIbpXIRuBE5JkkKbA0LMGRX7Yok0/wkLSwkttoNHIq5iS7/FC4Pb8txgE mh4g== X-Gm-Message-State: ALoCoQkVlvBR6Xi5D1KVpMXTpwFT5dhXnNBQISE/scC6fZVKqVFFnY846Zj8nCNrZ5JrI2jjmM/b X-Received: by 10.194.179.42 with SMTP id dd10mr30486328wjc.7.1436189131849; Mon, 06 Jul 2015 06:25:31 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.104 with SMTP id u8ls147619lae.31.gmail; Mon, 06 Jul 2015 06:25:31 -0700 (PDT) X-Received: by 10.152.22.129 with SMTP id d1mr49350257laf.13.1436189131546; Mon, 06 Jul 2015 06:25:31 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id t2si15247366lbj.163.2015.07.06.06.25.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jul 2015 06:25:31 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by lagx9 with SMTP id x9so154725328lag.1 for ; Mon, 06 Jul 2015 06:25:31 -0700 (PDT) X-Received: by 10.153.5.38 with SMTP id cj6mr48859197lad.36.1436189130841; Mon, 06 Jul 2015 06:25:30 -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 hn6csp1725312lbb; Mon, 6 Jul 2015 06:25:30 -0700 (PDT) X-Received: by 10.180.9.168 with SMTP id a8mr11980936wib.77.1436189122826; Mon, 06 Jul 2015 06:25:22 -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 h18si52156424wiw.84.2015.07.06.06.25.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jul 2015 06:25:22 -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 wiwl6 with SMTP id l6so284728870wiw.0 for ; Mon, 06 Jul 2015 06:25:22 -0700 (PDT) X-Received: by 10.180.77.233 with SMTP id v9mr53618479wiw.87.1436189122539; Mon, 06 Jul 2015 06:25:22 -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.20 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jul 2015 06:25:21 -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 7/9] VFIO: platform: add irq bypass producer management Date: Mon, 6 Jul 2015 15:24:41 +0200 Message-Id: <1436189083-32527-8-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.46 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/resume producer simply consist in disabling/enabling the host irq - add/del consumer: basically set the automasked flag to false/true - update remains void Signed-off-by: Eric Auger --- 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 | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/vfio/platform/vfio_platform_irq.c b/drivers/vfio/platform/vfio_platform_irq.c index d00ed24..7dc17a6 100644 --- a/drivers/vfio/platform/vfio_platform_irq.c +++ b/drivers/vfio/platform/vfio_platform_irq.c @@ -222,22 +222,49 @@ 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_resume(struct irq_bypass_producer *prod) { + enable_irq(prod->irq); } static void vfio_platform_irq_bypass_add_consumer( struct irq_bypass_producer *prod, struct irq_bypass_consumer *cons) { + int ret; + struct vfio_platform_irq *irq = + container_of(prod, struct vfio_platform_irq, producer); + + //TODO + /* + * 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. + */ + prod->active = vfio_platform_is_active(irq); + + ret = vfio_platform_set_automasked(irq, false); + WARN_ON(ret); } 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); + + if (prod->active) + vfio_platform_mask(irq); + + vfio_platform_set_automasked(irq, true); } static int vfio_set_trigger(struct vfio_platform_device *vdev, int index,