From patchwork Thu Jul 2 13:17:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 50580 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0B0BF214B3 for ; Thu, 2 Jul 2015 13:18:18 +0000 (UTC) Received: by wgjx7 with SMTP id x7sf21112739wgj.3 for ; Thu, 02 Jul 2015 06:18:16 -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=PCKtW6gBfILiENKuFnKLnBEHHUliHztrme0eolK3UFU=; b=h+zaak7WBfAFFDjpaGaSyIK33JCuhk6k8fK+XKu1Pe5lUfno8lO660Vne90sOUv1ni P+papuBF6cmAOaxzfimz6K81rrGtjXQN+wDUaoubvbCwC046i7qlt28HByIihj0NoI1J sI4/I5PEr0T2NerEafUzbnf/cP9f7hZcdT1T0ViPl8i1Xa+C8sd3XIATnDv4NdrvoQOb aYHHxjx1mFSnAJ+iKathfOHGshHXwKgep4hKd8KIaPcSjtiuFGt9cgwSNY4Sd/eKQ/Bp LnEOpS5fwwbtulTDSyucvef/79RE3dAMPbs4lrFvgdt0v2v8DCkA16BnrFutY/pVkyil dq/Q== X-Gm-Message-State: ALoCoQm7AX7nI7Ahiq1DIkAOayY/cC9n14WeKPkniJRCZTjC35i8tq59l3o060l5tex9Rk0b0fP7 X-Received: by 10.112.99.37 with SMTP id en5mr846467lbb.7.1435843095552; Thu, 02 Jul 2015 06:18:15 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.20.67 with SMTP id l3ls339638lae.73.gmail; Thu, 02 Jul 2015 06:18:15 -0700 (PDT) X-Received: by 10.152.204.7 with SMTP id ku7mr30415954lac.38.1435843095260; Thu, 02 Jul 2015 06:18:15 -0700 (PDT) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com. [209.85.217.172]) by mx.google.com with ESMTPS id ji5si4433773lbb.149.2015.07.02.06.18.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Jul 2015 06:18:15 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by lbcpe5 with SMTP id pe5so31788219lbc.2 for ; Thu, 02 Jul 2015 06:18:15 -0700 (PDT) X-Received: by 10.152.36.161 with SMTP id r1mr30465864laj.88.1435843095040; Thu, 02 Jul 2015 06:18:15 -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 hn6csp476206lbb; Thu, 2 Jul 2015 06:18:14 -0700 (PDT) X-Received: by 10.194.176.68 with SMTP id cg4mr10987218wjc.106.1435843087340; Thu, 02 Jul 2015 06:18:07 -0700 (PDT) Received: from mail-wg0-f53.google.com (mail-wg0-f53.google.com. [74.125.82.53]) by mx.google.com with ESMTPS id i2si8822825wjr.23.2015.07.02.06.18.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Jul 2015 06:18:07 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 74.125.82.53 as permitted sender) client-ip=74.125.82.53; Received: by wgjx7 with SMTP id x7so62918891wgj.2 for ; Thu, 02 Jul 2015 06:18:07 -0700 (PDT) X-Received: by 10.180.79.134 with SMTP id j6mr16506083wix.83.1435843087061; Thu, 02 Jul 2015 06:18:07 -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 tl3sm8157099wjc.20.2015.07.02.06.18.05 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Jul 2015 06:18:06 -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, pbonzini@redhat.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 Subject: [RFC 06/17] VFIO: add vfio_external_{mask|is_active|set_automasked} Date: Thu, 2 Jul 2015 15:17:16 +0200 Message-Id: <1435843047-6327-7-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1435843047-6327-1-git-send-email-eric.auger@linaro.org> References: <1435843047-6327-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.172 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: , Introduces 3 new external functions aimed at doing actions on VFIO devices: - mask VFIO IRQ - get the active status of VFIO IRQ (active at interrupt controller level or masked by the level-sensitive automasking). - change the automasked property and switch the IRQ handler (between automasked/ non automasked) Their implementation is based on bus specific callbacks. Note there is no way to discriminate between user-space masking and automasked handler masking. As a consequence, is_active will return true in case the IRQ was masked by the user-space. Signed-off-by: Eric Auger --- v5 -> v6: - implementation now uses external ops - prototype changed (index, start, count) and returns int V4: creation --- drivers/vfio/vfio.c | 39 +++++++++++++++++++++++++++++++++++++++ include/linux/vfio.h | 16 ++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 2fb29df..af6901e 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -1527,6 +1527,45 @@ long vfio_external_check_extension(struct vfio_group *group, unsigned long arg) } EXPORT_SYMBOL_GPL(vfio_external_check_extension); +int vfio_external_mask(struct vfio_device *vdev, unsigned index, + unsigned start, unsigned count) +{ + if (vdev->ops->external_ops && + vdev->ops->external_ops->mask) + return vdev->ops->external_ops->mask(vdev->device_data, + index, start, count); + else + return -ENXIO; +} +EXPORT_SYMBOL_GPL(vfio_external_mask); + +int vfio_external_is_active(struct vfio_device *vdev, unsigned index, + unsigned start, unsigned count) +{ + if (vdev->ops->external_ops && + vdev->ops->external_ops->is_active) + return vdev->ops->external_ops->is_active(vdev->device_data, + index, start, count); + else + return -ENXIO; +} +EXPORT_SYMBOL_GPL(vfio_external_is_active); + +int vfio_external_set_automasked(struct vfio_device *vdev, + unsigned index, unsigned start, + unsigned count, bool automasked) +{ + if (vdev->ops->external_ops && + vdev->ops->external_ops->set_automasked) + return vdev->ops->external_ops->set_automasked( + vdev->device_data, + index, start, + count, automasked); + else + return -ENXIO; +} +EXPORT_SYMBOL_GPL(vfio_external_set_automasked); + /** * Module/class support */ diff --git a/include/linux/vfio.h b/include/linux/vfio.h index d79e8a9..31d3c95 100644 --- a/include/linux/vfio.h +++ b/include/linux/vfio.h @@ -107,6 +107,22 @@ extern int vfio_external_user_iommu_id(struct vfio_group *group); extern long vfio_external_check_extension(struct vfio_group *group, unsigned long arg); +extern int vfio_external_mask(struct vfio_device *vdev, unsigned index, + unsigned start, unsigned count); +/* + * returns whether the VFIO IRQ is active: + * true if not yet deactivated at interrupt controller level or if + * automasked (level sensitive IRQ). Unfortunately there is no way to + * discriminate between handler auto-masking and user-space masking + */ +extern int vfio_external_is_active(struct vfio_device *vdev, + unsigned index, unsigned start, + unsigned count); + +extern int vfio_external_set_automasked(struct vfio_device *vdev, + unsigned index, unsigned start, + unsigned count, bool automasked); + struct pci_dev; #ifdef CONFIG_EEH extern void vfio_spapr_pci_eeh_open(struct pci_dev *pdev);