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: Eric Auger X-Patchwork-Id: 6709231 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8FDA59F380 for ; Thu, 2 Jul 2015 13:21:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8858A206F2 for ; Thu, 2 Jul 2015 13:21:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7F1062065A for ; Thu, 2 Jul 2015 13:21:24 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZAeOZ-0005Wt-7h; Thu, 02 Jul 2015 13:19:15 +0000 Received: from mail-wg0-f42.google.com ([74.125.82.42]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZAeNo-0004Hb-Nt for linux-arm-kernel@lists.infradead.org; Thu, 02 Jul 2015 13:18:29 +0000 Received: by wgjx7 with SMTP id x7so62918889wgj.2 for ; Thu, 02 Jul 2015 06:18: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:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PCKtW6gBfILiENKuFnKLnBEHHUliHztrme0eolK3UFU=; b=L7GvtVKQcYQayt2zj1DOUU+h8kw6tjbWDCQpD/tgnrrDsVkpBkveonu04aR5UwWpoL n73jVLcMnH6BQ5JWIvj1szwTM+oCC3TPpSnCuI+Wn6JYL2skRPJmypagWVURBq39Xu2z FaPP7OLmsg1Jj2N9nvqcEwbMxU5HEahNLOq1wQM5bYU/e8j1q+6/RlXveryWrD9z/FYT 07Tj6JdvggjiXrt8tT+L8Ryso0pagVHbMwHUjBr1HgxZY3e6RPN/FNeRib5gbaOq/kLS nEHO2wc7cbaXHHiV4VGbNa1pg00ZqUKm5qWnVFaaqpRk6TrF4t0J+qg7xI8qUIgauFt1 a0Hg== X-Gm-Message-State: ALoCoQl7WWsD6+mwq4TvWoyJUKHCnjaVCjepcXTb3av47sxMd0kWBLQSm88F7WrcrjlLMuPPYyPg 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 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150702_061828_965204_8EE2BA46 X-CRM114-Status: GOOD ( 12.48 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, patches@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);