aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu
diff options
context:
space:
mode:
authorRobin Murphy <robin.murphy@arm.com>2015-01-12 12:51:14 -0500
committerJoerg Roedel <jroedel@suse.de>2015-01-19 08:55:22 -0500
commit85b4545629663486b7f71047ce3b54fa0ad3eb28 (patch)
tree00c5840d2ca44a0e5c75aa54e05e866d1f28d612 /drivers/iommu
parent114150d8f4fc9e7a003be2bdb0efd31796d241ff (diff)
iommu: Consolidate IOVA allocator code
In order to share the IOVA allocator with other architectures, break the unnecssary dependency on the Intel IOMMU driver and move the remaining IOVA internals to iova.c Signed-off-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu')
-rw-r--r--drivers/iommu/intel-iommu.c33
-rw-r--r--drivers/iommu/iova.c35
2 files changed, 37 insertions, 31 deletions
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 40dfbc0444c0..e758d8ed8fb5 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -485,7 +485,6 @@ __setup("intel_iommu=", intel_iommu_setup);
485 485
486static struct kmem_cache *iommu_domain_cache; 486static struct kmem_cache *iommu_domain_cache;
487static struct kmem_cache *iommu_devinfo_cache; 487static struct kmem_cache *iommu_devinfo_cache;
488static struct kmem_cache *iommu_iova_cache;
489 488
490static inline void *alloc_pgtable_page(int node) 489static inline void *alloc_pgtable_page(int node)
491{ 490{
@@ -523,16 +522,6 @@ static inline void free_devinfo_mem(void *vaddr)
523 kmem_cache_free(iommu_devinfo_cache, vaddr); 522 kmem_cache_free(iommu_devinfo_cache, vaddr);
524} 523}
525 524
526struct iova *alloc_iova_mem(void)
527{
528 return kmem_cache_alloc(iommu_iova_cache, GFP_ATOMIC);
529}
530
531void free_iova_mem(struct iova *iova)
532{
533 kmem_cache_free(iommu_iova_cache, iova);
534}
535
536static inline int domain_type_is_vm(struct dmar_domain *domain) 525static inline int domain_type_is_vm(struct dmar_domain *domain)
537{ 526{
538 return domain->flags & DOMAIN_FLAG_VIRTUAL_MACHINE; 527 return domain->flags & DOMAIN_FLAG_VIRTUAL_MACHINE;
@@ -3427,23 +3416,6 @@ static inline int iommu_devinfo_cache_init(void)
3427 return ret; 3416 return ret;
3428} 3417}
3429 3418
3430static inline int iommu_iova_cache_init(void)
3431{
3432 int ret = 0;
3433
3434 iommu_iova_cache = kmem_cache_create("iommu_iova",
3435 sizeof(struct iova),
3436 0,
3437 SLAB_HWCACHE_ALIGN,
3438 NULL);
3439 if (!iommu_iova_cache) {
3440 printk(KERN_ERR "Couldn't create iova cache\n");
3441 ret = -ENOMEM;
3442 }
3443
3444 return ret;
3445}
3446
3447static int __init iommu_init_mempool(void) 3419static int __init iommu_init_mempool(void)
3448{ 3420{
3449 int ret; 3421 int ret;
@@ -3461,7 +3433,7 @@ static int __init iommu_init_mempool(void)
3461 3433
3462 kmem_cache_destroy(iommu_domain_cache); 3434 kmem_cache_destroy(iommu_domain_cache);
3463domain_error: 3435domain_error:
3464 kmem_cache_destroy(iommu_iova_cache); 3436 iommu_iova_cache_destroy();
3465 3437
3466 return -ENOMEM; 3438 return -ENOMEM;
3467} 3439}
@@ -3470,8 +3442,7 @@ static void __init iommu_exit_mempool(void)
3470{ 3442{
3471 kmem_cache_destroy(iommu_devinfo_cache); 3443 kmem_cache_destroy(iommu_devinfo_cache);
3472 kmem_cache_destroy(iommu_domain_cache); 3444 kmem_cache_destroy(iommu_domain_cache);
3473 kmem_cache_destroy(iommu_iova_cache); 3445 iommu_iova_cache_destroy();
3474
3475} 3446}
3476 3447
3477static void quirk_ioat_snb_local_iommu(struct pci_dev *pdev) 3448static void quirk_ioat_snb_local_iommu(struct pci_dev *pdev)
diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
index f6b17e6af2fb..520b8c8ae0c4 100644
--- a/drivers/iommu/iova.c
+++ b/drivers/iommu/iova.c
@@ -18,6 +18,41 @@
18 */ 18 */
19 19
20#include <linux/iova.h> 20#include <linux/iova.h>
21#include <linux/slab.h>
22
23static struct kmem_cache *iommu_iova_cache;
24
25int iommu_iova_cache_init(void)
26{
27 int ret = 0;
28
29 iommu_iova_cache = kmem_cache_create("iommu_iova",
30 sizeof(struct iova),
31 0,
32 SLAB_HWCACHE_ALIGN,
33 NULL);
34 if (!iommu_iova_cache) {
35 pr_err("Couldn't create iova cache\n");
36 ret = -ENOMEM;
37 }
38
39 return ret;
40}
41
42void iommu_iova_cache_destroy(void)
43{
44 kmem_cache_destroy(iommu_iova_cache);
45}
46
47struct iova *alloc_iova_mem(void)
48{
49 return kmem_cache_alloc(iommu_iova_cache, GFP_ATOMIC);
50}
51
52void free_iova_mem(struct iova *iova)
53{
54 kmem_cache_free(iommu_iova_cache, iova);
55}
21 56
22void 57void
23init_iova_domain(struct iova_domain *iovad, unsigned long pfn_32bit) 58init_iova_domain(struct iova_domain *iovad, unsigned long pfn_32bit)