From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965604AbcAZNOg (ORCPT ); Tue, 26 Jan 2016 08:14:36 -0500 Received: from mail-wm0-f47.google.com ([74.125.82.47]:37868 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965919AbcAZNNn (ORCPT ); Tue, 26 Jan 2016 08:13:43 -0500 From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, alex.williamson@redhat.com, will.deacon@arm.com, christoffer.dall@linaro.org, marc.zyngier@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Cc: Bharat.Bhushan@freescale.com, pranav.sawargaonkar@gmail.com, p.fedin@samsung.com, suravee.suthikulpanit@amd.com, linux-kernel@vger.kernel.org, patches@linaro.org, iommu@lists.linux-foundation.org Subject: [PATCH 08/10] vfio: introduce vfio_group_require_msi_mapping Date: Tue, 26 Jan 2016 13:12:46 +0000 Message-Id: <1453813968-2024-9-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1453813968-2024-1-git-send-email-eric.auger@linaro.org> References: <1453813968-2024-1-git-send-email-eric.auger@linaro.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This new function enables to know whether msi write transaction addresses must be mapped. Signed-off-by: Eric Auger --- drivers/vfio/vfio.c | 22 ++++++++++++++++++++++ drivers/vfio/vfio_iommu_type1.c | 8 ++++++++ include/linux/vfio.h | 2 ++ 3 files changed, 32 insertions(+) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 2760d4c..f3df5a10 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -793,6 +793,28 @@ static int vfio_iommu_group_notifier(struct notifier_block *nb, return NOTIFY_OK; } +bool vfio_group_require_msi_mapping(struct vfio_group *group) +{ + struct vfio_container *container = group->container; + struct vfio_iommu_driver *driver; + bool ret; + + down_read(&container->group_lock); + + driver = container->iommu_driver; + if (!driver || !driver->ops || !driver->ops->require_msi_mapping) { + ret = -EINVAL; + goto up; + } + + ret = driver->ops->require_msi_mapping(container->iommu_data); + +up: + up_read(&container->group_lock); + return ret; +} +EXPORT_SYMBOL_GPL(vfio_group_require_msi_mapping); + /** * VFIO driver API */ diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index a79e2a8..2f085d3 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -1179,6 +1179,13 @@ unlock: return ret; } +static bool vfio_iommu_type1_require_msi_mapping(void *iommu_data) +{ + struct vfio_iommu *iommu = iommu_data; + + return vfio_domains_require_msi_mapping(iommu); +} + static void *vfio_iommu_type1_open(unsigned long arg) { struct vfio_iommu *iommu; @@ -1336,6 +1343,7 @@ static const struct vfio_iommu_driver_ops vfio_iommu_driver_ops_type1 = { vfio_iommu_type1_alloc_map_reserved_iova, .unmap_free_reserved_iova = vfio_iommu_type1_unmap_free_reserved_iova, + .require_msi_mapping = vfio_iommu_type1_require_msi_mapping, }; static int __init vfio_iommu_type1_init(void) diff --git a/include/linux/vfio.h b/include/linux/vfio.h index f7eaf30..3e6cbeb 100644 --- a/include/linux/vfio.h +++ b/include/linux/vfio.h @@ -58,6 +58,7 @@ extern void *vfio_del_group_dev(struct device *dev); extern struct vfio_device *vfio_device_get_from_dev(struct device *dev); extern void vfio_device_put(struct vfio_device *device); extern void *vfio_device_data(struct vfio_device *device); +extern bool vfio_group_require_msi_mapping(struct vfio_group *group); /** * struct vfio_iommu_driver_ops - VFIO IOMMU driver callbacks @@ -85,6 +86,7 @@ struct vfio_iommu_driver_ops { int (*unmap_free_reserved_iova)(void *iommu_data, struct iommu_group *group, dma_addr_t iova); + bool (*require_msi_mapping)(void *iommu_data); }; extern int vfio_register_iommu_driver(const struct vfio_iommu_driver_ops *ops); -- 1.9.1 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Auger Subject: [PATCH 08/10] vfio: introduce vfio_group_require_msi_mapping Date: Tue, 26 Jan 2016 13:12:46 +0000 Message-ID: <1453813968-2024-9-git-send-email-eric.auger@linaro.org> References: <1453813968-2024-1-git-send-email-eric.auger@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: patches@linaro.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org To: eric.auger@st.com, eric.auger@linaro.org, alex.williamson@redhat.com, will.deacon@arm.com, christoffer.dall@linaro.org, marc.zyngier@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Return-path: In-Reply-To: <1453813968-2024-1-git-send-email-eric.auger@linaro.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu List-Id: kvm.vger.kernel.org This new function enables to know whether msi write transaction addresses must be mapped. Signed-off-by: Eric Auger --- drivers/vfio/vfio.c | 22 ++++++++++++++++++++++ drivers/vfio/vfio_iommu_type1.c | 8 ++++++++ include/linux/vfio.h | 2 ++ 3 files changed, 32 insertions(+) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 2760d4c..f3df5a10 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -793,6 +793,28 @@ static int vfio_iommu_group_notifier(struct notifier_block *nb, return NOTIFY_OK; } +bool vfio_group_require_msi_mapping(struct vfio_group *group) +{ + struct vfio_container *container = group->container; + struct vfio_iommu_driver *driver; + bool ret; + + down_read(&container->group_lock); + + driver = container->iommu_driver; + if (!driver || !driver->ops || !driver->ops->require_msi_mapping) { + ret = -EINVAL; + goto up; + } + + ret = driver->ops->require_msi_mapping(container->iommu_data); + +up: + up_read(&container->group_lock); + return ret; +} +EXPORT_SYMBOL_GPL(vfio_group_require_msi_mapping); + /** * VFIO driver API */ diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index a79e2a8..2f085d3 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -1179,6 +1179,13 @@ unlock: return ret; } +static bool vfio_iommu_type1_require_msi_mapping(void *iommu_data) +{ + struct vfio_iommu *iommu = iommu_data; + + return vfio_domains_require_msi_mapping(iommu); +} + static void *vfio_iommu_type1_open(unsigned long arg) { struct vfio_iommu *iommu; @@ -1336,6 +1343,7 @@ static const struct vfio_iommu_driver_ops vfio_iommu_driver_ops_type1 = { vfio_iommu_type1_alloc_map_reserved_iova, .unmap_free_reserved_iova = vfio_iommu_type1_unmap_free_reserved_iova, + .require_msi_mapping = vfio_iommu_type1_require_msi_mapping, }; static int __init vfio_iommu_type1_init(void) diff --git a/include/linux/vfio.h b/include/linux/vfio.h index f7eaf30..3e6cbeb 100644 --- a/include/linux/vfio.h +++ b/include/linux/vfio.h @@ -58,6 +58,7 @@ extern void *vfio_del_group_dev(struct device *dev); extern struct vfio_device *vfio_device_get_from_dev(struct device *dev); extern void vfio_device_put(struct vfio_device *device); extern void *vfio_device_data(struct vfio_device *device); +extern bool vfio_group_require_msi_mapping(struct vfio_group *group); /** * struct vfio_iommu_driver_ops - VFIO IOMMU driver callbacks @@ -85,6 +86,7 @@ struct vfio_iommu_driver_ops { int (*unmap_free_reserved_iova)(void *iommu_data, struct iommu_group *group, dma_addr_t iova); + bool (*require_msi_mapping)(void *iommu_data); }; extern int vfio_register_iommu_driver(const struct vfio_iommu_driver_ops *ops); -- 1.9.1 From mboxrd@z Thu Jan 1 00:00:00 1970 From: eric.auger@linaro.org (Eric Auger) Date: Tue, 26 Jan 2016 13:12:46 +0000 Subject: [PATCH 08/10] vfio: introduce vfio_group_require_msi_mapping In-Reply-To: <1453813968-2024-1-git-send-email-eric.auger@linaro.org> References: <1453813968-2024-1-git-send-email-eric.auger@linaro.org> Message-ID: <1453813968-2024-9-git-send-email-eric.auger@linaro.org> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org This new function enables to know whether msi write transaction addresses must be mapped. Signed-off-by: Eric Auger --- drivers/vfio/vfio.c | 22 ++++++++++++++++++++++ drivers/vfio/vfio_iommu_type1.c | 8 ++++++++ include/linux/vfio.h | 2 ++ 3 files changed, 32 insertions(+) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 2760d4c..f3df5a10 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -793,6 +793,28 @@ static int vfio_iommu_group_notifier(struct notifier_block *nb, return NOTIFY_OK; } +bool vfio_group_require_msi_mapping(struct vfio_group *group) +{ + struct vfio_container *container = group->container; + struct vfio_iommu_driver *driver; + bool ret; + + down_read(&container->group_lock); + + driver = container->iommu_driver; + if (!driver || !driver->ops || !driver->ops->require_msi_mapping) { + ret = -EINVAL; + goto up; + } + + ret = driver->ops->require_msi_mapping(container->iommu_data); + +up: + up_read(&container->group_lock); + return ret; +} +EXPORT_SYMBOL_GPL(vfio_group_require_msi_mapping); + /** * VFIO driver API */ diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index a79e2a8..2f085d3 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -1179,6 +1179,13 @@ unlock: return ret; } +static bool vfio_iommu_type1_require_msi_mapping(void *iommu_data) +{ + struct vfio_iommu *iommu = iommu_data; + + return vfio_domains_require_msi_mapping(iommu); +} + static void *vfio_iommu_type1_open(unsigned long arg) { struct vfio_iommu *iommu; @@ -1336,6 +1343,7 @@ static const struct vfio_iommu_driver_ops vfio_iommu_driver_ops_type1 = { vfio_iommu_type1_alloc_map_reserved_iova, .unmap_free_reserved_iova = vfio_iommu_type1_unmap_free_reserved_iova, + .require_msi_mapping = vfio_iommu_type1_require_msi_mapping, }; static int __init vfio_iommu_type1_init(void) diff --git a/include/linux/vfio.h b/include/linux/vfio.h index f7eaf30..3e6cbeb 100644 --- a/include/linux/vfio.h +++ b/include/linux/vfio.h @@ -58,6 +58,7 @@ extern void *vfio_del_group_dev(struct device *dev); extern struct vfio_device *vfio_device_get_from_dev(struct device *dev); extern void vfio_device_put(struct vfio_device *device); extern void *vfio_device_data(struct vfio_device *device); +extern bool vfio_group_require_msi_mapping(struct vfio_group *group); /** * struct vfio_iommu_driver_ops - VFIO IOMMU driver callbacks @@ -85,6 +86,7 @@ struct vfio_iommu_driver_ops { int (*unmap_free_reserved_iova)(void *iommu_data, struct iommu_group *group, dma_addr_t iova); + bool (*require_msi_mapping)(void *iommu_data); }; extern int vfio_register_iommu_driver(const struct vfio_iommu_driver_ops *ops); -- 1.9.1