Separate the IOVA library from the intel-iommu driver
Subsystems (4)
cover Separate the IOVA library from the intel-iommu driver
Hi folks,
This set separates the IOVA library from the intel-iommu driver, and makes it usable for other implementations (such as DMA mapping) as well.
The RFC set can be found here:
Since the RFC:
- Rebase on current iommu next branch.
- Don't export get_vm_area_caller(). __get_vm_area() which is already exported can be used instead.
Signature · 2 lines
Kind regards, Sakari
A message that is not in the archive (sent off-list or not yet received): 1436787091-11943-1-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/[email protected]
PATCH 1/4 iommu: iova: Move iova cache management to the iova library
This is necessary to separate intel-iommu from the iova library.
--- drivers/iommu/intel-iommu.c | 6 ++-- drivers/iommu/iova.c | 83 ++++++++++++++++++++++++++------------------- include/linux/iova.h | 4 +-- 3 files changed, 54 insertions(+), 39 deletions(-)
drivers/iommu/intel-iommu.c +3 -3
@@ -3741,7 +3741,7 @@ static inline int iommu_devinfo_cache_init(void)static int __init iommu_init_mempool (void ) {int ret; - ret =iommu_iova_cache_init (); + ret =iova_cache_get ();if (ret)return ret;
@@ -3755,7 +3755,7 @@ static int __init iommu_init_mempool(void)kmem_cache_destroy (iommu_domain_cache); domain_error: -iommu_iova_cache_destroy (); +iova_cache_put ();return -ENOMEM ; }
@@ -3764,7 +3764,7 @@ static void __init iommu_exit_mempool(void) {kmem_cache_destroy (iommu_devinfo_cache);kmem_cache_destroy (iommu_domain_cache); -iommu_iova_cache_destroy (); +iova_cache_put (); }static void quirk_ioat_snb_local_iommu (struct pci_dev *pdev)
drivers/iommu/iova.c +49 -34
95 lines not on this page · raw message
include/linux/iova.h +2 -2
@@ -68,8 +68,8 @@ static inline unsigned long iova_pfn(struct iova_domain *iovad, dma_addr_t iova)return iova >>iova_shift (iovad); } -int iommu_iova_cache_init (void ); -void iommu_iova_cache_destroy (void ); +int iova_cache_get (void ); +void iova_cache_put (void );struct iova *alloc_iova_mem (void );void free_iova_mem (struct iova *iova);
Signature · 1 line
2.1.0.231.g7484e3b
PATCH 2/4 iommu: iova: Export symbols
In reply to a message not in the archiveUse EXPORT_SYMBOL_GPL() to export the iova library symbols. The symbols include:
init_iova_domain(); iova_cache_get(); iova_cache_put(); iova_cache_init(); alloc_iova(); find_iova(); __free_iova(); free_iova(); put_iova_domain(); reserve_iova(); copy_reserved_iova();
--- drivers/iommu/iova.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/iommu/iova.c +10 -0
@@ -38,6 +38,7 @@ init_iova_domain(struct iova_domain *iovad, unsigned long granule, iovad->start_pfn = start_pfn; iovad->dma_32bit_pfn = pfn_32bit; } +EXPORT_SYMBOL_GPL (init_iova_domain);static struct rb_node *__get_cached_rbnode (struct iova_domain *iovad,unsigned long *limit_pfn)
@@ -243,6 +244,7 @@ int iova_cache_get(void)return 0 ; } +EXPORT_SYMBOL_GPL (iova_cache_get);void iova_cache_put (void ) {
@@ -256,6 +258,7 @@ void iova_cache_put(void)kmem_cache_destroy (iova_cache);mutex_unlock (&iova_cache_mutex); } +EXPORT_SYMBOL_GPL (iova_cache_put);/** * alloc_iova - allocates an iova
@@ -296,6 +299,7 @@ alloc_iova(struct iova_domain *iovad, unsigned long size,return new_iova; } +EXPORT_SYMBOL_GPL (alloc_iova);/** * find_iova - find's an iova for a given pfn
@@ -336,6 +340,7 @@ struct iova *find_iova(struct iova_domain *iovad, unsigned long pfn)spin_unlock_irqrestore (&iovad->iova_rbtree_lock, flags);return NULL ; } +EXPORT_SYMBOL_GPL (find_iova);/** * __free_iova - frees the given iova
@@ -354,6 +359,7 @@ __free_iova(struct iova_domain *iovad, struct iova *iova)spin_unlock_irqrestore (&iovad->iova_rbtree_lock, flags);free_iova_mem (iova); } +EXPORT_SYMBOL_GPL (__free_iova);/** * free_iova - finds and frees the iova for a given pfn
@@ -371,6 +377,7 @@ free_iova(struct iova_domain *iovad, unsigned long pfn)__free_iova (iovad, iova); } +EXPORT_SYMBOL_GPL (free_iova);/** * put_iova_domain - destroys the iova doamin
@@ -393,6 +400,7 @@ void put_iova_domain(struct iova_domain *iovad) }spin_unlock_irqrestore (&iovad->iova_rbtree_lock, flags); } +EXPORT_SYMBOL_GPL (put_iova_domain); static int __is_range_overlap(struct rb_node *node,
@@ -482,6 +490,7 @@ finish:spin_unlock_irqrestore (&iovad->iova_rbtree_lock, flags);return iova; } +EXPORT_SYMBOL_GPL (reserve_iova);/** * copy_reserved_iova - copies the reserved between domains
@@ -508,6 +517,7 @@ copy_reserved_iova(struct iova_domain *from, struct iova_domain *to) }spin_unlock_irqrestore (&from->iova_rbtree_lock, flags); } +EXPORT_SYMBOL_GPL (copy_reserved_iova);struct iova * split_and_remove_iova(struct iova_domain *iovad, struct iova *iova,
Signature · 1 line
2.1.0.231.g7484e3b
PATCH 3/4 iommu: Make the iova library a module
In reply to a message not in the archiveThe iova library has use outside the intel-iommu driver, thus make it a module.
--- drivers/iommu/Kconfig | 2 +- drivers/iommu/iova.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/iommu/Kconfig +1 -1
@@ -42,7 +42,7 @@ config IOMMU_IO_PGTABLE_LPAE_SELFTEST endmenu config IOMMU_IOVA - bool + tristate config OF_IOMMU def_bool y
drivers/iommu/iova.c +4 -0
@@ -18,6 +18,7 @@*/ #include <linux/iova.h> +#include <linux/module.h> #include <linux/slab.h> void
@@ -559,3 +560,6 @@ error:free_iova_mem (prev);return NULL ; } + +MODULE_AUTHOR ("Anil S Keshavamurthy <[email protected]>" ); +MODULE_LICENSE ("GPL" );
Signature · 1 line
2.1.0.231.g7484e3b
PATCH 4/4 mm: EXPORT_SYMBOL_GPL(find_vm_area);
In reply to a message not in the archivefind_vm_area() is needed in implementing the DMA mapping API as a module. Device specific IOMMUs with associated DMA mapping implementations should be buildable as modules.
--- mm/vmalloc.c | 1 + 1 file changed, 1 insertion(+)
mm/vmalloc.c +1 -0
@@ -1416,6 +1416,7 @@ struct vm_struct *find_vm_area(const void *addr)return NULL ; } +EXPORT_SYMBOL_GPL (find_vm_area);/** * remove_vm_area - find and remove a continuous kernel virtual area
Signature · 1 line
2.1.0.231.g7484e3b
Quoted 4 lines · Sakari Ailus
Hi folks,
This set separates the IOVA library from the intel-iommu driver, and makes it usable for other implementations (such as DMA mapping) as well.
Thanks. I've applied patches ##1-3 to my tree. The fourth patch ideally wants to go elsewhere.
Signature · 2 lines
David Woodhouse Open Source Technology Centre [email protected] Intel Corporation
A message that is not in the archive (sent off-list or not yet received): 1438089947.26913.155.camel-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org
Hi David,
Quoted 9 lines · David Woodhouse
Quoted 4 lines · Sakari Ailus
Hi folks,
This set separates the IOVA library from the intel-iommu driver, and makes it usable for other implementations (such as DMA mapping) as well.
Thanks. I've applied patches ##1-3 to my tree. The fourth patch ideally wants to go elsewhere.
This doesn't seem to have made 4.3-rc1, despite having been in -next for a while. Were you planning to push it for 4.3, or is it waiting on further development?
Thanks,
Robin.