From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422860AbcBZRgR (ORCPT ); Fri, 26 Feb 2016 12:36:17 -0500 Received: from mail-wm0-f50.google.com ([74.125.82.50]:38319 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030316AbcBZRgM (ORCPT ); Fri, 26 Feb 2016 12:36:12 -0500 From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, robin.murphy@arm.com, alex.williamson@redhat.com, will.deacon@arm.com, joro@8bytes.org, tglx@linutronix.de, jason@lakedaemon.net, marc.zyngier@arm.com, christoffer.dall@linaro.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Cc: suravee.suthikulpanit@amd.com, patches@linaro.org, linux-kernel@vger.kernel.org, Manish.Jaggi@caviumnetworks.com, Bharat.Bhushan@freescale.com, pranav.sawargaonkar@gmail.com, p.fedin@samsung.com, iommu@lists.linux-foundation.org Subject: [RFC v4 03/14] dma-reserved-iommu: alloc/free_reserved_iova_domain Date: Fri, 26 Feb 2016 17:35:43 +0000 Message-Id: <1456508154-2253-4-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1456508154-2253-1-git-send-email-eric.auger@linaro.org> References: <1456508154-2253-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 Introduce alloc/free_reserved_iova_domain in the IOMMU API. alloc_reserved_iova_domain initializes an iova domain at a given iova base address and with a given size. This iova domain will be used to allocate iova within that window. Those IOVAs will be reserved for special purpose, typically MSI frame binding. Allocation function within the reserved iova domain will be introduced in subsequent patches. Those functions are implemented and exposed if CONFIG_IOMMU_DMA_RESERVED is seta. Signed-off-by: Eric Auger --- v3 -> v4: - formerly in "iommu/arm-smmu: implement alloc/free_reserved_iova_domain" & "iommu: add alloc/free_reserved_iova_domain" v2 -> v3: - remove iommu_alloc_reserved_iova_domain & iommu_free_reserved_iova_domain static implementation in case CONFIG_IOMMU_API is not set v1 -> v2: - moved from vfio API to IOMMU API --- drivers/iommu/Kconfig | 8 +++++ drivers/iommu/Makefile | 1 + drivers/iommu/dma-reserved-iommu.c | 74 ++++++++++++++++++++++++++++++++++++++ include/linux/dma-reserved-iommu.h | 45 +++++++++++++++++++++++ 4 files changed, 128 insertions(+) create mode 100644 drivers/iommu/dma-reserved-iommu.c create mode 100644 include/linux/dma-reserved-iommu.h diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index a1e75cb..0775143 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -55,6 +55,12 @@ config IOMMU_DMA select IOMMU_API select IOMMU_IOVA +# IOMMU reserved IOVA mapping (MSI doorbell) +config IOMMU_DMA_RESERVED + bool + select IOMMU_API + select IOMMU_IOVA + config FSL_PAMU bool "Freescale IOMMU support" depends on PPC32 @@ -288,6 +294,7 @@ config SPAPR_TCE_IOMMU config ARM_SMMU bool "ARM Ltd. System MMU (SMMU) Support" depends on (ARM64 || ARM) && MMU + select IOMMU_DMA_RESERVED select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU if ARM @@ -301,6 +308,7 @@ config ARM_SMMU config ARM_SMMU_V3 bool "ARM Ltd. System MMU Version 3 (SMMUv3) Support" depends on ARM64 && PCI + select IOMMU_DMA_RESERVED select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select GENERIC_MSI_IRQ_DOMAIN diff --git a/drivers/iommu/Makefile b/drivers/iommu/Makefile index 42fc0c2..ea68d23 100644 --- a/drivers/iommu/Makefile +++ b/drivers/iommu/Makefile @@ -2,6 +2,7 @@ obj-$(CONFIG_IOMMU_API) += iommu.o obj-$(CONFIG_IOMMU_API) += iommu-traces.o obj-$(CONFIG_IOMMU_API) += iommu-sysfs.o obj-$(CONFIG_IOMMU_DMA) += dma-iommu.o +obj-$(CONFIG_IOMMU_DMA_RESERVED) += dma-reserved-iommu.o obj-$(CONFIG_IOMMU_IO_PGTABLE) += io-pgtable.o obj-$(CONFIG_IOMMU_IO_PGTABLE_LPAE) += io-pgtable-arm.o obj-$(CONFIG_IOMMU_IOVA) += iova.o diff --git a/drivers/iommu/dma-reserved-iommu.c b/drivers/iommu/dma-reserved-iommu.c new file mode 100644 index 0000000..41a1add --- /dev/null +++ b/drivers/iommu/dma-reserved-iommu.c @@ -0,0 +1,74 @@ +/* + * Reserved IOVA Management + * + * Copyright (c) 2015 Linaro Ltd. + * www.linaro.org + * + * Copyright (C) 2000-2004 Russell King + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include +#include + +int iommu_alloc_reserved_iova_domain(struct iommu_domain *domain, + dma_addr_t iova, size_t size, + unsigned long order) +{ + unsigned long granule, mask; + struct iova_domain *iovad; + int ret = 0; + + granule = 1UL << order; + mask = granule - 1; + if (iova & mask || (!size) || (size & mask)) + return -EINVAL; + + mutex_lock(&domain->reserved_mutex); + + if (domain->reserved_iova_cookie) { + ret = -EEXIST; + goto unlock; + } + + iovad = kzalloc(sizeof(struct iova_domain), GFP_KERNEL); + if (!iovad) { + ret = -ENOMEM; + goto unlock; + } + + init_iova_domain(iovad, granule, + iova >> order, (iova + size - 1) >> order); + domain->reserved_iova_cookie = iovad; + +unlock: + mutex_unlock(&domain->reserved_mutex); + return ret; +} +EXPORT_SYMBOL_GPL(iommu_alloc_reserved_iova_domain); + +void iommu_free_reserved_iova_domain(struct iommu_domain *domain) +{ + struct iova_domain *iovad = + (struct iova_domain *)domain->reserved_iova_cookie; + + if (!iovad) + return; + + mutex_lock(&domain->reserved_mutex); + + put_iova_domain(iovad); + kfree(iovad); + + mutex_unlock(&domain->reserved_mutex); +} +EXPORT_SYMBOL_GPL(iommu_free_reserved_iova_domain); diff --git a/include/linux/dma-reserved-iommu.h b/include/linux/dma-reserved-iommu.h new file mode 100644 index 0000000..5bf863b --- /dev/null +++ b/include/linux/dma-reserved-iommu.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015 Linaro Ltd. + * www.linaro.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ +#ifndef __DMA_RESERVED_IOMMU_H +#define __DMA_RESERVED_IOMMU_H + +#ifdef __KERNEL__ +#include + +#ifdef CONFIG_IOMMU_DMA_RESERVED +#include + +/** + * iommu_alloc_reserved_iova_domain: allocate the reserved iova domain + * + * @domain: iommu domain handle + * @iova: base iova address + * @size: iova window size + * @order: page order + */ +int iommu_alloc_reserved_iova_domain(struct iommu_domain *domain, + dma_addr_t iova, size_t size, + unsigned long order); + +/** + * iommu_free_reserved_iova_domain: free the reserved iova domain + * + * @domain: iommu domain handle + */ +void iommu_free_reserved_iova_domain(struct iommu_domain *domain); + +#endif /* CONFIG_IOMMU_DMA_RESERVED */ +#endif /* __KERNEL__ */ +#endif /* __DMA_RESERVED_IOMMU_H */ -- 1.9.1 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Auger Subject: [RFC v4 03/14] dma-reserved-iommu: alloc/free_reserved_iova_domain Date: Fri, 26 Feb 2016 17:35:43 +0000 Message-ID: <1456508154-2253-4-git-send-email-eric.auger@linaro.org> References: <1456508154-2253-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, Manish.Jaggi@caviumnetworks.com, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org To: eric.auger@st.com, eric.auger@linaro.org, robin.murphy@arm.com, alex.williamson@redhat.com, will.deacon@arm.com, joro@8bytes.org, tglx@linutronix.de, jason@lakedaemon.net, marc.zyngier@arm.com, christoffer.dall@linaro.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Return-path: In-Reply-To: <1456508154-2253-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 Introduce alloc/free_reserved_iova_domain in the IOMMU API. alloc_reserved_iova_domain initializes an iova domain at a given iova base address and with a given size. This iova domain will be used to allocate iova within that window. Those IOVAs will be reserved for special purpose, typically MSI frame binding. Allocation function within the reserved iova domain will be introduced in subsequent patches. Those functions are implemented and exposed if CONFIG_IOMMU_DMA_RESERVED is seta. Signed-off-by: Eric Auger --- v3 -> v4: - formerly in "iommu/arm-smmu: implement alloc/free_reserved_iova_domain" & "iommu: add alloc/free_reserved_iova_domain" v2 -> v3: - remove iommu_alloc_reserved_iova_domain & iommu_free_reserved_iova_domain static implementation in case CONFIG_IOMMU_API is not set v1 -> v2: - moved from vfio API to IOMMU API --- drivers/iommu/Kconfig | 8 +++++ drivers/iommu/Makefile | 1 + drivers/iommu/dma-reserved-iommu.c | 74 ++++++++++++++++++++++++++++++++++++++ include/linux/dma-reserved-iommu.h | 45 +++++++++++++++++++++++ 4 files changed, 128 insertions(+) create mode 100644 drivers/iommu/dma-reserved-iommu.c create mode 100644 include/linux/dma-reserved-iommu.h diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index a1e75cb..0775143 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -55,6 +55,12 @@ config IOMMU_DMA select IOMMU_API select IOMMU_IOVA +# IOMMU reserved IOVA mapping (MSI doorbell) +config IOMMU_DMA_RESERVED + bool + select IOMMU_API + select IOMMU_IOVA + config FSL_PAMU bool "Freescale IOMMU support" depends on PPC32 @@ -288,6 +294,7 @@ config SPAPR_TCE_IOMMU config ARM_SMMU bool "ARM Ltd. System MMU (SMMU) Support" depends on (ARM64 || ARM) && MMU + select IOMMU_DMA_RESERVED select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU if ARM @@ -301,6 +308,7 @@ config ARM_SMMU config ARM_SMMU_V3 bool "ARM Ltd. System MMU Version 3 (SMMUv3) Support" depends on ARM64 && PCI + select IOMMU_DMA_RESERVED select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select GENERIC_MSI_IRQ_DOMAIN diff --git a/drivers/iommu/Makefile b/drivers/iommu/Makefile index 42fc0c2..ea68d23 100644 --- a/drivers/iommu/Makefile +++ b/drivers/iommu/Makefile @@ -2,6 +2,7 @@ obj-$(CONFIG_IOMMU_API) += iommu.o obj-$(CONFIG_IOMMU_API) += iommu-traces.o obj-$(CONFIG_IOMMU_API) += iommu-sysfs.o obj-$(CONFIG_IOMMU_DMA) += dma-iommu.o +obj-$(CONFIG_IOMMU_DMA_RESERVED) += dma-reserved-iommu.o obj-$(CONFIG_IOMMU_IO_PGTABLE) += io-pgtable.o obj-$(CONFIG_IOMMU_IO_PGTABLE_LPAE) += io-pgtable-arm.o obj-$(CONFIG_IOMMU_IOVA) += iova.o diff --git a/drivers/iommu/dma-reserved-iommu.c b/drivers/iommu/dma-reserved-iommu.c new file mode 100644 index 0000000..41a1add --- /dev/null +++ b/drivers/iommu/dma-reserved-iommu.c @@ -0,0 +1,74 @@ +/* + * Reserved IOVA Management + * + * Copyright (c) 2015 Linaro Ltd. + * www.linaro.org + * + * Copyright (C) 2000-2004 Russell King + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include +#include + +int iommu_alloc_reserved_iova_domain(struct iommu_domain *domain, + dma_addr_t iova, size_t size, + unsigned long order) +{ + unsigned long granule, mask; + struct iova_domain *iovad; + int ret = 0; + + granule = 1UL << order; + mask = granule - 1; + if (iova & mask || (!size) || (size & mask)) + return -EINVAL; + + mutex_lock(&domain->reserved_mutex); + + if (domain->reserved_iova_cookie) { + ret = -EEXIST; + goto unlock; + } + + iovad = kzalloc(sizeof(struct iova_domain), GFP_KERNEL); + if (!iovad) { + ret = -ENOMEM; + goto unlock; + } + + init_iova_domain(iovad, granule, + iova >> order, (iova + size - 1) >> order); + domain->reserved_iova_cookie = iovad; + +unlock: + mutex_unlock(&domain->reserved_mutex); + return ret; +} +EXPORT_SYMBOL_GPL(iommu_alloc_reserved_iova_domain); + +void iommu_free_reserved_iova_domain(struct iommu_domain *domain) +{ + struct iova_domain *iovad = + (struct iova_domain *)domain->reserved_iova_cookie; + + if (!iovad) + return; + + mutex_lock(&domain->reserved_mutex); + + put_iova_domain(iovad); + kfree(iovad); + + mutex_unlock(&domain->reserved_mutex); +} +EXPORT_SYMBOL_GPL(iommu_free_reserved_iova_domain); diff --git a/include/linux/dma-reserved-iommu.h b/include/linux/dma-reserved-iommu.h new file mode 100644 index 0000000..5bf863b --- /dev/null +++ b/include/linux/dma-reserved-iommu.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015 Linaro Ltd. + * www.linaro.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ +#ifndef __DMA_RESERVED_IOMMU_H +#define __DMA_RESERVED_IOMMU_H + +#ifdef __KERNEL__ +#include + +#ifdef CONFIG_IOMMU_DMA_RESERVED +#include + +/** + * iommu_alloc_reserved_iova_domain: allocate the reserved iova domain + * + * @domain: iommu domain handle + * @iova: base iova address + * @size: iova window size + * @order: page order + */ +int iommu_alloc_reserved_iova_domain(struct iommu_domain *domain, + dma_addr_t iova, size_t size, + unsigned long order); + +/** + * iommu_free_reserved_iova_domain: free the reserved iova domain + * + * @domain: iommu domain handle + */ +void iommu_free_reserved_iova_domain(struct iommu_domain *domain); + +#endif /* CONFIG_IOMMU_DMA_RESERVED */ +#endif /* __KERNEL__ */ +#endif /* __DMA_RESERVED_IOMMU_H */ -- 1.9.1 From mboxrd@z Thu Jan 1 00:00:00 1970 From: eric.auger@linaro.org (Eric Auger) Date: Fri, 26 Feb 2016 17:35:43 +0000 Subject: [RFC v4 03/14] dma-reserved-iommu: alloc/free_reserved_iova_domain In-Reply-To: <1456508154-2253-1-git-send-email-eric.auger@linaro.org> References: <1456508154-2253-1-git-send-email-eric.auger@linaro.org> Message-ID: <1456508154-2253-4-git-send-email-eric.auger@linaro.org> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Introduce alloc/free_reserved_iova_domain in the IOMMU API. alloc_reserved_iova_domain initializes an iova domain at a given iova base address and with a given size. This iova domain will be used to allocate iova within that window. Those IOVAs will be reserved for special purpose, typically MSI frame binding. Allocation function within the reserved iova domain will be introduced in subsequent patches. Those functions are implemented and exposed if CONFIG_IOMMU_DMA_RESERVED is seta. Signed-off-by: Eric Auger --- v3 -> v4: - formerly in "iommu/arm-smmu: implement alloc/free_reserved_iova_domain" & "iommu: add alloc/free_reserved_iova_domain" v2 -> v3: - remove iommu_alloc_reserved_iova_domain & iommu_free_reserved_iova_domain static implementation in case CONFIG_IOMMU_API is not set v1 -> v2: - moved from vfio API to IOMMU API --- drivers/iommu/Kconfig | 8 +++++ drivers/iommu/Makefile | 1 + drivers/iommu/dma-reserved-iommu.c | 74 ++++++++++++++++++++++++++++++++++++++ include/linux/dma-reserved-iommu.h | 45 +++++++++++++++++++++++ 4 files changed, 128 insertions(+) create mode 100644 drivers/iommu/dma-reserved-iommu.c create mode 100644 include/linux/dma-reserved-iommu.h diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index a1e75cb..0775143 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -55,6 +55,12 @@ config IOMMU_DMA select IOMMU_API select IOMMU_IOVA +# IOMMU reserved IOVA mapping (MSI doorbell) +config IOMMU_DMA_RESERVED + bool + select IOMMU_API + select IOMMU_IOVA + config FSL_PAMU bool "Freescale IOMMU support" depends on PPC32 @@ -288,6 +294,7 @@ config SPAPR_TCE_IOMMU config ARM_SMMU bool "ARM Ltd. System MMU (SMMU) Support" depends on (ARM64 || ARM) && MMU + select IOMMU_DMA_RESERVED select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU if ARM @@ -301,6 +308,7 @@ config ARM_SMMU config ARM_SMMU_V3 bool "ARM Ltd. System MMU Version 3 (SMMUv3) Support" depends on ARM64 && PCI + select IOMMU_DMA_RESERVED select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select GENERIC_MSI_IRQ_DOMAIN diff --git a/drivers/iommu/Makefile b/drivers/iommu/Makefile index 42fc0c2..ea68d23 100644 --- a/drivers/iommu/Makefile +++ b/drivers/iommu/Makefile @@ -2,6 +2,7 @@ obj-$(CONFIG_IOMMU_API) += iommu.o obj-$(CONFIG_IOMMU_API) += iommu-traces.o obj-$(CONFIG_IOMMU_API) += iommu-sysfs.o obj-$(CONFIG_IOMMU_DMA) += dma-iommu.o +obj-$(CONFIG_IOMMU_DMA_RESERVED) += dma-reserved-iommu.o obj-$(CONFIG_IOMMU_IO_PGTABLE) += io-pgtable.o obj-$(CONFIG_IOMMU_IO_PGTABLE_LPAE) += io-pgtable-arm.o obj-$(CONFIG_IOMMU_IOVA) += iova.o diff --git a/drivers/iommu/dma-reserved-iommu.c b/drivers/iommu/dma-reserved-iommu.c new file mode 100644 index 0000000..41a1add --- /dev/null +++ b/drivers/iommu/dma-reserved-iommu.c @@ -0,0 +1,74 @@ +/* + * Reserved IOVA Management + * + * Copyright (c) 2015 Linaro Ltd. + * www.linaro.org + * + * Copyright (C) 2000-2004 Russell King + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include +#include + +int iommu_alloc_reserved_iova_domain(struct iommu_domain *domain, + dma_addr_t iova, size_t size, + unsigned long order) +{ + unsigned long granule, mask; + struct iova_domain *iovad; + int ret = 0; + + granule = 1UL << order; + mask = granule - 1; + if (iova & mask || (!size) || (size & mask)) + return -EINVAL; + + mutex_lock(&domain->reserved_mutex); + + if (domain->reserved_iova_cookie) { + ret = -EEXIST; + goto unlock; + } + + iovad = kzalloc(sizeof(struct iova_domain), GFP_KERNEL); + if (!iovad) { + ret = -ENOMEM; + goto unlock; + } + + init_iova_domain(iovad, granule, + iova >> order, (iova + size - 1) >> order); + domain->reserved_iova_cookie = iovad; + +unlock: + mutex_unlock(&domain->reserved_mutex); + return ret; +} +EXPORT_SYMBOL_GPL(iommu_alloc_reserved_iova_domain); + +void iommu_free_reserved_iova_domain(struct iommu_domain *domain) +{ + struct iova_domain *iovad = + (struct iova_domain *)domain->reserved_iova_cookie; + + if (!iovad) + return; + + mutex_lock(&domain->reserved_mutex); + + put_iova_domain(iovad); + kfree(iovad); + + mutex_unlock(&domain->reserved_mutex); +} +EXPORT_SYMBOL_GPL(iommu_free_reserved_iova_domain); diff --git a/include/linux/dma-reserved-iommu.h b/include/linux/dma-reserved-iommu.h new file mode 100644 index 0000000..5bf863b --- /dev/null +++ b/include/linux/dma-reserved-iommu.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015 Linaro Ltd. + * www.linaro.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ +#ifndef __DMA_RESERVED_IOMMU_H +#define __DMA_RESERVED_IOMMU_H + +#ifdef __KERNEL__ +#include + +#ifdef CONFIG_IOMMU_DMA_RESERVED +#include + +/** + * iommu_alloc_reserved_iova_domain: allocate the reserved iova domain + * + * @domain: iommu domain handle + * @iova: base iova address + * @size: iova window size + * @order: page order + */ +int iommu_alloc_reserved_iova_domain(struct iommu_domain *domain, + dma_addr_t iova, size_t size, + unsigned long order); + +/** + * iommu_free_reserved_iova_domain: free the reserved iova domain + * + * @domain: iommu domain handle + */ +void iommu_free_reserved_iova_domain(struct iommu_domain *domain); + +#endif /* CONFIG_IOMMU_DMA_RESERVED */ +#endif /* __KERNEL__ */ +#endif /* __DMA_RESERVED_IOMMU_H */ -- 1.9.1