From patchwork Tue Nov 24 13:50:55 2015
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pavel Fedin
X-Patchwork-Id: 7691281
Return-Path:
X-Original-To: patchwork-kvm@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 38C649F2E9
for ;
Tue, 24 Nov 2015 13:51:20 +0000 (UTC)
Received: from mail.kernel.org (localhost [127.0.0.1])
by mail.kernel.org (Postfix) with ESMTP id 28CF0207E4
for ;
Tue, 24 Nov 2015 13:51:19 +0000 (UTC)
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
by mail.kernel.org (Postfix) with ESMTP id A4EE320843
for ;
Tue, 24 Nov 2015 13:51:17 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S1754239AbbKXNvI (ORCPT
);
Tue, 24 Nov 2015 08:51:08 -0500
Received: from mailout4.w1.samsung.com ([210.118.77.14]:10771 "EHLO
mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S1754253AbbKXNvE (ORCPT );
Tue, 24 Nov 2015 08:51:04 -0500
Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245])
by mailout4.w1.samsung.com
(Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5
2014)) with ESMTP id <0NYB00C5HNT1NC10@mailout4.w1.samsung.com> for
kvm@vger.kernel.org; Tue, 24 Nov 2015 13:51:01 +0000 (GMT)
X-AuditID: cbfec7f5-f79b16d000005389-55-56546b453b93
Received: from eusync3.samsung.com ( [203.254.199.213])
by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 64.5C.21385.54B64565;
Tue, 24 Nov 2015 13:51:01 +0000 (GMT)
Received: from fedinw7x64.rnd.samsung.ru ([106.109.131.169])
by eusync3.samsung.com
(Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5
2014)) with ESMTPA id <0NYB00IQYNSXM8B0@eusync3.samsung.com>; Tue,
24 Nov 2015 13:51:01 +0000 (GMT)
From: Pavel Fedin
To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu
Cc: Alex Williamson ,
Marc Zyngier ,
Thomas Gleixner ,
Jason Cooper ,
Manish Jaggi
Subject: [PATCH v2 2/3] gicv3, its: Introduce VFIO map and unmap operations
Date: Tue, 24 Nov 2015 16:50:55 +0300
Message-id:
<6b5aed2d9fd9b8678c07091e97a8d07f64cd584d.1448372839.git.p.fedin@samsung.com>
X-Mailer: git-send-email 2.4.4
In-reply-to:
References:
In-reply-to:
References:
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFtrGLMWRmVeSWpSXmKPExsVy+t/xq7qu2SFhBjsOqFp8+9/DZtG45DKL
xZyphRYfTx1nt/h75x+bxdemr2wWmzdNZXZg91gzbw2jx4YT/aweDQfOs3i8O3eO3eP8pjXM
Hu/3XWXz+LxJLoA9issmJTUnsyy1SN8ugSvj+pYuloKJMhU72maxNjBOEe9i5OSQEDCR6Gn5
xgxhi0lcuLeerYuRi0NIYCmjxLKPzxghnDYmiX9fXrCAVLEJqEuc/voBzBYRMJU4d7EdrIhZ
4ByjxP5Vm8FGCQt4S1ye9JkJxGYRUJU4uHoCWJxXIFpi8pNZTBDr5CSuXJ/OBmJzCphLnL/Q
xA5iCwmYSWxbOJcZl/gERv4FjAyrGEVTS5MLipPSc430ihNzi0vz0vWS83M3MUJC8+sOxqXH
rA4xCnAwKvHwfigJDhNiTSwrrsw9xCjBwawkwmutHxImxJuSWFmVWpQfX1Sak1p8iFGag0VJ
nHfmrvchQgLpiSWp2ampBalFMFkmDk6pBsbzF1cmGdWqxj1rmP/zkeWEfLMv5x7Y+ZvozmTg
k/j1+nef+pIPpfYxzjm+KvWrF9Qflbm+MluG0eXNrrUOW1+vX2x79Q7P8ZqFWubbFumdaopp
mzObccrMA1l8X389fLfCKbORlf3sKa2wHwFBCu9cd3G0VGzKfJ1wedWki6f6fX1tfs/f7/RD
iaU4I9FQi7moOBEA8AibN0kCAAA=
Sender: kvm-owner@vger.kernel.org
Precedence: bulk
List-ID:
X-Mailing-List: kvm@vger.kernel.org
X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI,
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
These new functions use the supplied IOMMU in order to map and unmap MSI
translation register(s).
Signed-off-by: Pavel Fedin
---
drivers/irqchip/irq-gic-v3-its.c | 31 +++++++++++++++++++++++++++++++
include/linux/irqchip/arm-gic-v3.h | 2 ++
include/linux/msi.h | 12 ++++++++++++
3 files changed, 45 insertions(+)
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index e23d1d1..b97dfd7 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -29,6 +29,7 @@
#include
#include
#include
+#include
#include
#include
@@ -1257,8 +1258,38 @@ out:
return 0;
}
+#if IS_ENABLED(CONFIG_VFIO)
+
+static int its_vfio_map(struct irq_domain *domain,
+ const struct vfio_iommu_driver_ops *ops,
+ void *iommu_data)
+{
+ struct msi_domain_info *msi_info = msi_get_domain_info(domain);
+ struct its_node *its = msi_info->data;
+ u64 addr = its->phys_base + GIC_V3_ITS_CONTROL_SIZE;
+
+ return ops->map(iommu_data, addr, addr, 1, IOMMU_READ|IOMMU_WRITE);
+}
+
+static void its_vfio_unmap(struct irq_domain *domain,
+ const struct vfio_iommu_driver_ops *ops,
+ void *iommu_data)
+{
+ struct msi_domain_info *msi_info = msi_get_domain_info(domain);
+ struct its_node *its = msi_info->data;
+ u64 addr = its->phys_base + GIC_V3_ITS_CONTROL_SIZE;
+
+ ops->unmap(iommu_data, addr, 1);
+}
+
+#endif
+
static struct msi_domain_ops its_msi_domain_ops = {
.msi_prepare = its_msi_prepare,
+#if IS_ENABLED(CONFIG_VFIO)
+ .vfio_map = its_vfio_map,
+ .vfio_unmap = its_vfio_unmap,
+#endif
};
static int its_irq_gic_domain_alloc(struct irq_domain *domain,
diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h
index bff3eee..dfd2bed 100644
--- a/include/linux/irqchip/arm-gic-v3.h
+++ b/include/linux/irqchip/arm-gic-v3.h
@@ -241,6 +241,8 @@
#define GITS_BASER_TYPE_RESERVED6 6
#define GITS_BASER_TYPE_RESERVED7 7
+#define GIC_V3_ITS_CONTROL_SIZE 0x10000
+
/*
* ITS commands
*/
diff --git a/include/linux/msi.h b/include/linux/msi.h
index f71a25e..48faea9 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -155,6 +155,8 @@ void arch_restore_msi_irqs(struct pci_dev *dev);
void default_teardown_msi_irqs(struct pci_dev *dev);
void default_restore_msi_irqs(struct pci_dev *dev);
+struct vfio_iommu_driver_ops;
+
struct msi_controller {
struct module *owner;
struct device *dev;
@@ -189,6 +191,8 @@ struct msi_domain_info;
* @msi_finish: Optional callbacl to finalize the allocation
* @set_desc: Set the msi descriptor for an interrupt
* @handle_error: Optional error handler if the allocation fails
+ * @vfio_map: Map the MSI hardware for VFIO
+ * @vfio_unmap: Unmap the MSI hardware for VFIO
*
* @get_hwirq, @msi_init and @msi_free are callbacks used by
* msi_create_irq_domain() and related interfaces
@@ -218,6 +222,14 @@ struct msi_domain_ops {
struct msi_desc *desc);
int (*handle_error)(struct irq_domain *domain,
struct msi_desc *desc, int error);
+#if IS_ENABLED(CONFIG_VFIO)
+ int (*vfio_map)(struct irq_domain *domain,
+ const struct vfio_iommu_driver_ops *ops,
+ void *iommu_data);
+ void (*vfio_unmap)(struct irq_domain *domain,
+ const struct vfio_iommu_driver_ops *ops,
+ void *iommu_data);
+#endif
};
/**