{"push_id":1137583194,"size":1,"distinct_size":1,"ref":"refs/heads/real","head":"cc5166fb556fd2e2778cf5432a7a3606fa91c952","before":"92ee3e60a9fc3a2ea885b6fc22d66e3d33186406","commits":[{"sha":"cc5166fb556fd2e2778cf5432a7a3606fa91c952","author":{"name":"robcore","email":"a3b05a675e90e628f2d9df6520db16da9bff1bff@gmail.com"},"message":"From 4acacb6d852c3659dd12f329aaf2b588744f9bc4 Mon Sep 17 00:00:00 2001\nFrom: Rohit Vaswani <rvaswani@codeaurora.org>\nDate: Fri, 18 Jan 2013 19:11:43 -0800\nSubject: [PATCH 0659/6902] ARM: Drop VCM framework\n\nThis framework wasn't accepted upstream and is not used. Drop it.\n\nChange-Id: Ieb381a679873cbfb4baf245a5bcb8df1c730d964\nSigned-off-by: Rohit Vaswani <rvaswani@codeaurora.org>\nSigned-off-by: Stephen Boyd <sboyd@codeaurora.org>\n---\n arch/arm/mm/Kconfig       |   15 -\n arch/arm/mm/Makefile      |    2 -\n arch/arm/mm/vcm.c         | 1830 ---------------------------------------------\n arch/arm/mm/vcm_alloc.c   |  557 --------------\n arch/arm/mm/vcm_mm.c      |  253 -------\n include/linux/vcm.h       |  652 ----------------\n include/linux/vcm_alloc.h |   63 --\n include/linux/vcm_mm.h    |  105 ---\n include/linux/vcm_types.h |  355 ---------\n 9 files changed, 3832 deletions(-)\n delete mode 100644 arch/arm/mm/vcm.c\n delete mode 100644 arch/arm/mm/vcm_alloc.c\n delete mode 100644 arch/arm/mm/vcm_mm.c\n delete mode 100644 include/linux/vcm.h\n delete mode 100644 include/linux/vcm_alloc.h\n delete mode 100644 include/linux/vcm_mm.h\n delete mode 100644 include/linux/vcm_types.h\n\ndiff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig\nindex dcb400a..409e548 100644\n--- a/arch/arm/mm/Kconfig\n+++ b/arch/arm/mm/Kconfig\n@@ -932,21 +932,6 @@ config ARCH_HAS_BARRIERS\n \t  This option allows the use of custom mandatory barriers\n \t  included via the mach/barriers.h file.\n\n-config VCM_MM\n-\tbool\n-\n-config VCM\n-\tbool \"Virtual Contiguous Memory (VCM) Layer\"\n-\tdepends on MMU\n-\tselect GENERIC_ALLOCATOR\n-\tselect VCM_MM\n-\tdefault n\n-\thelp\n-\t  Virtual Contiguous Memory layer. This is the layer that is intended to\n-\t  replace PMEM.\n-\n-\t  If you don't know what this is, say N here.\n-\n config STRICT_MEMORY_RWX\n \tbool \"restrict kernel memory permissions as much as possible\"\n \tdefault n\ndiff --git a/arch/arm/mm/Makefile b/arch/arm/mm/Makefile\nindex a67022d..bca7e61 100644\n--- a/arch/arm/mm/Makefile\n+++ b/arch/arm/mm/Makefile\n@@ -100,5 +100,3 @@ obj-$(CONFIG_CACHE_FEROCEON_L2)\t+= cache-feroceon-l2.o\n obj-$(CONFIG_CACHE_L2X0)\t+= cache-l2x0.o\n obj-$(CONFIG_CACHE_XSC3L2)\t+= cache-xsc3l2.o\n obj-$(CONFIG_CACHE_TAUROS2)\t+= cache-tauros2.o\n-obj-$(CONFIG_VCM)\t\t+= vcm.o vcm_alloc.o\n-obj-$(CONFIG_VCM_MM)\t\t+= vcm_mm.o\ndiff --git a/arch/arm/mm/vcm.c b/arch/arm/mm/vcm.c\ndeleted file mode 100644\nindex c4dc1db..0000000\n--- a/arch/arm/mm/vcm.c\n+++ /dev/null\n@@ -1,1830 +0,0 @@\n-/* Copyright (c) 2010, The Linux Foundation. All rights reserved.\n- *\n- * This program is free software; you can redistribute it and/or modify\n- * it under the terms of the GNU General Public License version 2 and\n- * only version 2 as published by the Free Software Foundation.\n- *\n- * This program is distributed in the hope that it will be useful,\n- * but WITHOUT ANY WARRANTY; without even the implied warranty of\n- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n- * GNU General Public License for more details.\n- */\n-\n-#include <linux/module.h>\n-#include <linux/kernel.h>\n-#include <linux/slab.h>\n-#include <linux/vcm_mm.h>\n-#include <linux/vcm.h>\n-#include <linux/vcm_alloc.h>\n-#include <linux/vcm_types.h>\n-#include <linux/errno.h>\n-#include <linux/spinlock.h>\n-\n-#include <asm/page.h>\n-#include <asm/sizes.h>\n-\n-#include <linux/iommu.h>\n-\n-/* alloc_vm_area */\n-#include <linux/pfn.h>\n-#include <linux/mm.h>\n-#include <linux/vmalloc.h>\n-\n-#include <asm/cacheflush.h>\n-#include <asm/mach/map.h>\n-\n-#define ONE_TO_ONE_CHK 1\n-\n-#define vcm_err(a, ...)\t\t\t\t\t\t\t\\\n-\tpr_err(\"ERROR %s %i \" a, __func__, __LINE__, ##__VA_ARGS__)\n-\n-static unsigned int smmu_map_sizes[4] = {SZ_16M, SZ_1M, SZ_64K, SZ_4K};\n-\n-static phys_addr_t *bootmem_cont;\n-static int cont_sz;\n-static struct vcm *cont_vcm_id;\n-static struct phys_chunk *cont_phys_chunk;\n-\n-DEFINE_SPINLOCK(vcmlock);\n-\n-/* Leaving this in for now to keep compatibility of the API. */\n-/* This will disappear. */\n-phys_addr_t vcm_get_dev_addr(struct res *res)\n-{\n-\tif (!res) {\n-\t\tvcm_err(\"NULL RES\");\n-\t\treturn -EINVAL;\n-\t}\n-\treturn res->dev_addr;\n-}\n-\n-static int vcm_no_res(struct vcm *vcm)\n-{\n-\tif (!vcm) {\n-\t\tvcm_err(\"NULL vcm\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\treturn list_empty(&vcm->res_head);\n-fail:\n-\treturn -EINVAL;\n-}\n-\n-static int vcm_no_assoc(struct vcm *vcm)\n-{\n-\tif (!vcm) {\n-\t\tvcm_err(\"NULL vcm\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\treturn list_empty(&vcm->assoc_head);\n-fail:\n-\treturn -EINVAL;\n-}\n-\n-static int vcm_all_activated(struct vcm *vcm)\n-{\n-\tstruct avcm *avcm;\n-\n-\tif (!vcm) {\n-\t\tvcm_err(\"NULL vcm\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tlist_for_each_entry(avcm, &vcm->assoc_head, assoc_elm)\n-\t\tif (!avcm->is_active)\n-\t\t\treturn 0;\n-\n-\treturn 1;\n-fail:\n-\treturn -EINVAL;\n-}\n-\n-static void vcm_destroy_common(struct vcm *vcm)\n-{\n-\tif (!vcm) {\n-\t\tvcm_err(\"NULL vcm\\n\");\n-\t\treturn;\n-\t}\n-\n-\tmemset(vcm, 0, sizeof(*vcm));\n-\tkfree(vcm);\n-}\n-\n-static struct vcm *vcm_create_common(void)\n-{\n-\tstruct vcm *vcm = 0;\n-\n-\tvcm = kzalloc(sizeof(*vcm), GFP_KERNEL);\n-\tif (!vcm) {\n-\t\tvcm_err(\"kzalloc(%i, GFP_KERNEL) ret 0\\n\",\n-\t\t\tsizeof(*vcm));\n-\t\tgoto fail;\n-\t}\n-\n-\tINIT_LIST_HEAD(&vcm->res_head);\n-\tINIT_LIST_HEAD(&vcm->assoc_head);\n-\n-\treturn vcm;\n-\n-fail:\n-\treturn NULL;\n-}\n-\n-\n-static int vcm_create_pool(struct vcm *vcm, unsigned long start_addr,\n-\t\t\t   size_t len)\n-{\n-\tint ret = 0;\n-\n-\tif (!vcm) {\n-\t\tvcm_err(\"NULL vcm\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tvcm->start_addr = start_addr;\n-\tvcm->len = len;\n-\n-\tvcm->pool = gen_pool_create(PAGE_SHIFT, -1);\n-\tif (!vcm->pool) {\n-\t\tvcm_err(\"gen_pool_create(%x, -1) ret 0\\n\", PAGE_SHIFT);\n-\t\tret = -EINVAL;\n-\t\tgoto fail;\n-\t}\n-\n-\tret = gen_pool_add(vcm->pool, start_addr, len, -1);\n-\tif (ret) {\n-\t\tvcm_err(\"gen_pool_add(%p, %p, %i, -1) ret %i\\n\", vcm->pool,\n-\t\t\t(void *) start_addr, len, ret);\n-\t\tgoto fail;\n-\t}\n-\n-\tvcm->domain = iommu_domain_alloc();\n-\tif (!vcm->domain) {\n-\t\tvcm_err(\"Could not allocate domain\\n\");\n-\t\tret = -ENOMEM;\n-\t\tgoto fail;\n-\t}\n-\n-fail:\n-\tif (ret && vcm->pool)\n-\t\tgen_pool_destroy(vcm->pool);\n-\n-\treturn ret;\n-}\n-\n-\n-static struct vcm *vcm_create_flagged(int flag, unsigned long start_addr,\n-\t\t\t\t      size_t len)\n-{\n-\tint ret = 0;\n-\tstruct vcm *vcm = 0;\n-\n-\tvcm = vcm_create_common();\n-\tif (!vcm) {\n-\t\tvcm_err(\"NULL vcm\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\t/* special one-to-one mapping case */\n-\tif ((flag & ONE_TO_ONE_CHK) &&\n-\t    bootmem_cont &&\n-\t    start_addr == (size_t) bootmem_cont &&\n-\t    len == cont_sz) {\n-\t\tvcm->type = VCM_ONE_TO_ONE;\n-\t} else {\n-\t\tret = vcm_create_pool(vcm, start_addr, len);\n-\t\tvcm->type = VCM_DEVICE;\n-\t}\n-\n-\tif (ret) {\n-\t\tvcm_err(\"vcm_create_pool(%p, %p, %i) ret %i\\n\", vcm,\n-\t\t\t(void *) start_addr, len, ret);\n-\t\tgoto fail2;\n-\t}\n-\n-\treturn vcm;\n-\n-fail2:\n-\tvcm_destroy_common(vcm);\n-fail:\n-\treturn NULL;\n-}\n-\n-struct vcm *vcm_create(unsigned long start_addr, size_t len)\n-{\n-\tunsigned long flags;\n-\tstruct vcm *vcm;\n-\n-\tspin_lock_irqsave(&vcmlock, flags);\n-\tvcm = vcm_create_flagged(ONE_TO_ONE_CHK, start_addr, len);\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn vcm;\n-}\n-\n-\n-static int ext_vcm_id_valid(size_t ext_vcm_id)\n-{\n-\treturn ((ext_vcm_id == VCM_PREBUILT_KERNEL) ||\n-\t\t(ext_vcm_id == VCM_PREBUILT_USER));\n-}\n-\n-\n-struct vcm *vcm_create_from_prebuilt(size_t ext_vcm_id)\n-{\n-\tunsigned long flags;\n-\tstruct vcm *vcm = 0;\n-\n-\tspin_lock_irqsave(&vcmlock, flags);\n-\n-\tif (!ext_vcm_id_valid(ext_vcm_id)) {\n-\t\tvcm_err(\"ext_vcm_id_valid(%i) ret 0\\n\", ext_vcm_id);\n-\t\tgoto fail;\n-\t}\n-\n-\tvcm = vcm_create_common();\n-\tif (!vcm) {\n-\t\tvcm_err(\"NULL vcm\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (ext_vcm_id == VCM_PREBUILT_KERNEL)\n-\t\tvcm->type = VCM_EXT_KERNEL;\n-\telse if (ext_vcm_id == VCM_PREBUILT_USER)\n-\t\tvcm->type = VCM_EXT_USER;\n-\telse {\n-\t\tvcm_err(\"UNREACHABLE ext_vcm_id is illegal\\n\");\n-\t\tgoto fail_free;\n-\t}\n-\n-\t/* TODO: set kernel and userspace start_addr and len, if this\n-\t * makes sense */\n-\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn vcm;\n-\n-fail_free:\n-\tvcm_destroy_common(vcm);\n-fail:\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn NULL;\n-}\n-\n-\n-struct vcm *vcm_clone(struct vcm *vcm)\n-{\n-\treturn 0;\n-}\n-\n-\n-/* No lock needed, vcm->start_addr is never updated after creation */\n-size_t vcm_get_start_addr(struct vcm *vcm)\n-{\n-\tif (!vcm) {\n-\t\tvcm_err(\"NULL vcm\\n\");\n-\t\treturn 1;\n-\t}\n-\n-\treturn vcm->start_addr;\n-}\n-\n-\n-/* No lock needed, vcm->len is never updated after creation */\n-size_t vcm_get_len(struct vcm *vcm)\n-{\n-\tif (!vcm) {\n-\t\tvcm_err(\"NULL vcm\\n\");\n-\t\treturn 0;\n-\t}\n-\n-\treturn vcm->len;\n-}\n-\n-\n-static int vcm_free_common_rule(struct vcm *vcm)\n-{\n-\tint ret;\n-\n-\tif (!vcm) {\n-\t\tvcm_err(\"NULL vcm\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tret = vcm_no_res(vcm);\n-\tif (!ret) {\n-\t\tvcm_err(\"vcm_no_res(%p) ret 0\\n\", vcm);\n-\t\tgoto fail_busy;\n-\t}\n-\n-\tif (ret == -EINVAL) {\n-\t\tvcm_err(\"vcm_no_res(%p) ret -EINVAL\\n\", vcm);\n-\t\tgoto fail;\n-\t}\n-\n-\tret = vcm_no_assoc(vcm);\n-\tif (!ret) {\n-\t\tvcm_err(\"vcm_no_assoc(%p) ret 0\\n\", vcm);\n-\t\tgoto fail_busy;\n-\t}\n-\n-\tif (ret == -EINVAL) {\n-\t\tvcm_err(\"vcm_no_assoc(%p) ret -EINVAL\\n\", vcm);\n-\t\tgoto fail;\n-\t}\n-\n-\treturn 0;\n-\n-fail_busy:\n-\treturn -EBUSY;\n-fail:\n-\treturn -EINVAL;\n-}\n-\n-\n-static int vcm_free_pool_rule(struct vcm *vcm)\n-{\n-\tif (!vcm) {\n-\t\tvcm_err(\"NULL vcm\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\t/* A vcm always has a valid pool, don't free the vcm because\n-\t   what we got is probably invalid.\n-\t*/\n-\tif (!vcm->pool) {\n-\t\tvcm_err(\"NULL vcm->pool\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\treturn 0;\n-\n-fail:\n-\treturn -EINVAL;\n-}\n-\n-\n-static void vcm_free_common(struct vcm *vcm)\n-{\n-\tmemset(vcm, 0, sizeof(*vcm));\n-\n-\tkfree(vcm);\n-}\n-\n-\n-static int vcm_free_pool(struct vcm *vcm)\n-{\n-\tif (!vcm) {\n-\t\tvcm_err(\"NULL vcm\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tgen_pool_destroy(vcm->pool);\n-\n-\treturn 0;\n-\n-fail:\n-\treturn -EINVAL;\n-}\n-\n-\n-static int __vcm_free(struct vcm *vcm)\n-{\n-\tint ret;\n-\n-\tif (!vcm) {\n-\t\tvcm_err(\"NULL vcm\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tret = vcm_free_common_rule(vcm);\n-\tif (ret != 0) {\n-\t\tvcm_err(\"vcm_free_common_rule(%p) ret %i\\n\", vcm, ret);\n-\t\tgoto fail;\n-\t}\n-\n-\tif (vcm->type == VCM_DEVICE) {\n-\t\tret = vcm_free_pool_rule(vcm);\n-\t\tif (ret != 0) {\n-\t\t\tvcm_err(\"vcm_free_pool_rule(%p) ret %i\\n\",\n-\t\t\t\t(void *) vcm, ret);\n-\t\t\tgoto fail;\n-\t\t}\n-\t\tif (vcm->domain)\n-\t\t\tiommu_domain_free(vcm->domain);\n-\n-\t\tvcm->domain = NULL;\n-\t\tret = vcm_free_pool(vcm);\n-\t\tif (ret != 0) {\n-\t\t\tvcm_err(\"vcm_free_pool(%p) ret %i\", (void *) vcm, ret);\n-\t\t\tgoto fail;\n-\t\t}\n-\t}\n-\n-\tvcm_free_common(vcm);\n-\n-\treturn 0;\n-\n-fail:\n-\treturn -EINVAL;\n-}\n-\n-int vcm_free(struct vcm *vcm)\n-{\n-\tunsigned long flags;\n-\tint ret;\n-\n-\tspin_lock_irqsave(&vcmlock, flags);\n-\tret = __vcm_free(vcm);\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\n-\treturn ret;\n-}\n-\n-\n-static struct res *__vcm_reserve(struct vcm *vcm, size_t len, u32 attr)\n-{\n-\tstruct res *res = NULL;\n-\tint align_attr = 0, i = 0;\n-\n-\tif (!vcm) {\n-\t\tvcm_err(\"NULL vcm\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (len == 0) {\n-\t\tvcm_err(\"len is 0\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tres = kzalloc(sizeof(*res), GFP_KERNEL);\n-\tif (!res) {\n-\t\tvcm_err(\"kzalloc(%i, GFP_KERNEL) ret 0\", sizeof(*res));\n-\t\tgoto fail;\n-\t}\n-\n-\talign_attr = (attr >> VCM_ALIGN_SHIFT) & VCM_ALIGN_MASK;\n-\n-\tif (align_attr >= 32) {\n-\t\tvcm_err(\"Invalid alignment attribute: %d\\n\", align_attr);\n-\t\tgoto fail2;\n-\t}\n-\n-\tINIT_LIST_HEAD(&res->res_elm);\n-\tres->vcm = vcm;\n-\tres->len = len;\n-\tres->attr = attr;\n-\tres->alignment_req = smmu_map_sizes[ARRAY_SIZE(smmu_map_sizes) - 1];\n-\n-\tif (align_attr == 0) {\n-\t\tfor (i = 0; i < ARRAY_SIZE(smmu_map_sizes); i++)\n-\t\t\tif (len / smmu_map_sizes[i]) {\n-\t\t\t\tres->alignment_req = smmu_map_sizes[i];\n-\t\t\t\tbreak;\n-\t\t\t}\n-\t} else\n-\t\tres->alignment_req = 1 << align_attr;\n-\n-\tres->aligned_len = res->alignment_req + len;\n-\n-\tswitch (vcm->type) {\n-\tcase VCM_DEVICE:\n-\t\t/* should always be not zero */\n-\t\tif (!vcm->pool) {\n-\t\t\tvcm_err(\"NULL vcm->pool\\n\");\n-\t\t\tgoto fail2;\n-\t\t}\n-\n-\t\tres->ptr = gen_pool_alloc(vcm->pool, res->aligned_len);\n-\t\tif (!res->ptr) {\n-\t\t\tvcm_err(\"gen_pool_alloc(%p, %i) ret 0\\n\",\n-\t\t\t\tvcm->pool, res->aligned_len);\n-\t\t\tgoto fail2;\n-\t\t}\n-\n-\t\t/* Calculate alignment... this will all change anyway */\n-\t\tres->dev_addr = res->ptr +\n-\t\t\t(res->alignment_req -\n-\t\t\t (res->ptr & (res->alignment_req - 1)));\n-\n-\t\tbreak;\n-\tcase VCM_EXT_KERNEL:\n-\t\tres->vm_area = alloc_vm_area(res->aligned_len);\n-\t\tres->mapped = 0; /* be explicit */\n-\t\tif (!res->vm_area) {\n-\t\t\tvcm_err(\"NULL res->vm_area\\n\");\n-\t\t\tgoto fail2;\n-\t\t}\n-\n-\t\tres->dev_addr = (size_t) res->vm_area->addr +\n-\t\t\t(res->alignment_req -\n-\t\t\t ((size_t) res->vm_area->addr &\n-\t\t\t  (res->alignment_req - 1)));\n-\n-\t\tbreak;\n-\tcase VCM_ONE_TO_ONE:\n-\t\tbreak;\n-\tdefault:\n-\t\tvcm_err(\"%i is an invalid vcm->type\\n\", vcm->type);\n-\t\tgoto fail2;\n-\t}\n-\n-\tlist_add_tail(&res->res_elm, &vcm->res_head);\n-\n-\treturn res;\n-\n-fail2:\n-\tkfree(res);\n-fail:\n-\treturn 0;\n-}\n-\n-\n-struct res *vcm_reserve(struct vcm *vcm, size_t len, u32 attr)\n-{\n-\tunsigned long flags;\n-\tstruct res *res;\n-\n-\tspin_lock_irqsave(&vcmlock, flags);\n-\tres = __vcm_reserve(vcm, len, attr);\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\n-\treturn res;\n-}\n-\n-\n-struct res *vcm_reserve_at(enum memtarget_t memtarget, struct vcm *vcm,\n-\t\t\t   size_t len, u32 attr)\n-{\n-\treturn 0;\n-}\n-\n-\n-static int __vcm_unreserve(struct res *res)\n-{\n-\tstruct vcm *vcm;\n-\n-\tif (!res) {\n-\t\tvcm_err(\"NULL res\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (!res->vcm) {\n-\t\tvcm_err(\"NULL res->vcm\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tvcm = res->vcm;\n-\tif (!vcm) {\n-\t\tvcm_err(\"NULL vcm\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tswitch (vcm->type) {\n-\tcase VCM_DEVICE:\n-\t\tif (!res->vcm->pool) {\n-\t\t\tvcm_err(\"NULL (res->vcm))->pool\\n\");\n-\t\t\tgoto fail;\n-\t\t}\n-\n-\t\t/* res->ptr could be zero, this isn't an error */\n-\t\tgen_pool_free(res->vcm->pool, res->ptr,\n-\t\t\t      res->aligned_len);\n-\t\tbreak;\n-\tcase VCM_EXT_KERNEL:\n-\t\tif (res->mapped) {\n-\t\t\tvcm_err(\"res->mapped is true\\n\");\n-\t\t\tgoto fail;\n-\t\t}\n-\n-\t\t/* This may take a little explaining.\n-\t\t * In the kernel vunmap will free res->vm_area\n-\t\t * so if we've called it then we shouldn't call\n-\t\t * free_vm_area(). If we've called it we set\n-\t\t * res->vm_area to 0.\n-\t\t */\n-\t\tif (res->vm_area) {\n-\t\t\tfree_vm_area(res->vm_area);\n-\t\t\tres->vm_area = 0;\n-\t\t}\n-\n-\t\tbreak;\n-\tcase VCM_ONE_TO_ONE:\n-\t\tbreak;\n-\tdefault:\n-\t\tvcm_err(\"%i is an invalid vcm->type\\n\", vcm->type);\n-\t\tgoto fail;\n-\t}\n-\n-\tlist_del(&res->res_elm);\n-\n-\t/* be extra careful by clearing the memory before freeing it */\n-\tmemset(res, 0, sizeof(*res));\n-\n-\tkfree(res);\n-\n-\treturn 0;\n-\n-fail:\n-\treturn -EINVAL;\n-}\n-\n-\n-int vcm_unreserve(struct res *res)\n-{\n-\tunsigned long flags;\n-\tint ret;\n-\n-\tspin_lock_irqsave(&vcmlock, flags);\n-\tret = __vcm_unreserve(res);\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\n-\treturn ret;\n-}\n-\n-\n-/* No lock needed, res->len is never updated after creation */\n-size_t vcm_get_res_len(struct res *res)\n-{\n-\tif (!res) {\n-\t\tvcm_err(\"res is 0\\n\");\n-\t\treturn 0;\n-\t}\n-\n-\treturn res->len;\n-}\n-\n-\n-int vcm_set_res_attr(struct res *res, u32 attr)\n-{\n-\treturn 0;\n-}\n-\n-\n-u32 vcm_get_res_attr(struct res *res)\n-{\n-\treturn 0;\n-}\n-\n-\n-size_t vcm_get_num_res(struct vcm *vcm)\n-{\n-\treturn 0;\n-}\n-\n-\n-struct res *vcm_get_next_res(struct vcm *vcm, struct res *res)\n-{\n-\treturn 0;\n-}\n-\n-\n-size_t vcm_res_copy(struct res *to, size_t to_off, struct res *from, size_t\n-\t\t    from_off, size_t len)\n-{\n-\treturn 0;\n-}\n-\n-\n-size_t vcm_get_min_page_size(void)\n-{\n-\treturn PAGE_SIZE;\n-}\n-\n-\n-static int vcm_to_smmu_attr(u32 attr)\n-{\n-\tint smmu_attr = 0;\n-\n-\tswitch (attr & VCM_CACHE_POLICY) {\n-\tcase VCM_NOTCACHED:\n-\t\tsmmu_attr = VCM_DEV_ATTR_NONCACHED;\n-\t\tbreak;\n-\tcase VCM_WB_WA:\n-\t\tsmmu_attr = VCM_DEV_ATTR_CACHED_WB_WA;\n-\t\tsmmu_attr |= VCM_DEV_ATTR_SH;\n-\t\tbreak;\n-\tcase VCM_WB_NWA:\n-\t\tsmmu_attr = VCM_DEV_ATTR_CACHED_WB_NWA;\n-\t\tsmmu_attr |= VCM_DEV_ATTR_SH;\n-\t\tbreak;\n-\tcase VCM_WT:\n-\t\tsmmu_attr = VCM_DEV_ATTR_CACHED_WT;\n-\t\tsmmu_attr |= VCM_DEV_ATTR_SH;\n-\t\tbreak;\n-\tdefault:\n-\t\treturn -EINVAL;\n-\t}\n-\n-\treturn smmu_attr;\n-}\n-\n-\n-static int vcm_process_chunk(struct iommu_domain *domain, phys_addr_t pa,\n-\t\t\t     unsigned long va, size_t len, u32 attr, int map)\n-{\n-\tint ret, i, map_order;\n-\tunsigned long map_len = smmu_map_sizes[ARRAY_SIZE(smmu_map_sizes) - 1];\n-\n-\tfor (i = 0; i < ARRAY_SIZE(smmu_map_sizes); i++) {\n-\t\tif (IS_ALIGNED(va, smmu_map_sizes[i]) && len >=\n-\t\t\t\t\t\t\tsmmu_map_sizes[i]) {\n-\t\t\tmap_len = smmu_map_sizes[i];\n-\t\t\tbreak;\n-\t\t}\n-\t}\n-\n-#ifdef VCM_PERF_DEBUG\n-\tif (va & (len - 1))\n-\t\tpr_warning(\"Warning! Suboptimal VCM mapping alignment \"\n-\t\t\t   \"va = %p, len = %p. Expect TLB performance \"\n-\t\t\t   \"degradation.\\n\", (void *) va, (void *) len);\n-#endif\n-\n-\tmap_order = get_order(map_len);\n-\n-\twhile (len) {\n-\t\tif (va & (SZ_4K - 1)) {\n-\t\t\tvcm_err(\"Tried to map w/ align < 4k! va = %08lx\\n\", va);\n-\t\t\tgoto fail;\n-\t\t}\n-\n-\t\tif (map_len > len) {\n-\t\t\tvcm_err(\"map_len = %lu, len = %d, trying to overmap\\n\",\n-\t\t\t\t map_len, len);\n-\t\t\tgoto fail;\n-\t\t}\n-\n-\t\tif (map)\n-\t\t\tret = iommu_map(domain, va, pa, map_len, attr);\n-\t\telse\n-\t\t\tret = iommu_unmap(domain, va, map_len);\n-\n-\t\tif (ret) {\n-\t\t\tvcm_err(\"iommu_map/unmap(%p, %p, %p, 0x%x, 0x%x) ret %i\"\n-\t\t\t\t\"map = %d\", (void *) domain, (void *) pa,\n-\t\t\t\t(void *) va, (int) map_len, attr, ret, map);\n-\t\t\tgoto fail;\n-\t\t}\n-\n-\t\tva += map_len;\n-\t\tpa += map_len;\n-\t\tlen -= map_len;\n-\t}\n-\n-\treturn 0;\n-fail:\n-\treturn -EINVAL;\n-}\n-\n-/* TBD if you vcm_back again what happens? */\n-int vcm_back(struct res *res, struct physmem *physmem)\n-{\n-\tunsigned long flags;\n-\tstruct vcm *vcm;\n-\tstruct phys_chunk *chunk;\n-\tsize_t va = 0;\n-\tint ret;\n-\tint attr;\n-\n-\tspin_lock_irqsave(&vcmlock, flags);\n-\n-\tif (!res) {\n-\t\tvcm_err(\"NULL res\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tvcm = res->vcm;\n-\tif (!vcm) {\n-\t\tvcm_err(\"NULL vcm\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tswitch (vcm->type) {\n-\tcase VCM_DEVICE:\n-\tcase VCM_EXT_KERNEL: /* hack part 1 */\n-\t\tattr = vcm_to_smmu_attr(res->attr);\n-\t\tif (attr == -1) {\n-\t\t\tvcm_err(\"Bad SMMU attr\\n\");\n-\t\t\tgoto fail;\n-\t\t}\n-\t\tbreak;\n-\tdefault:\n-\t\tattr = 0;\n-\t\tbreak;\n-\t}\n-\n-\tif (!physmem) {\n-\t\tvcm_err(\"NULL physmem\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (res->len == 0) {\n-\t\tvcm_err(\"res->len is 0\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (physmem->len == 0) {\n-\t\tvcm_err(\"physmem->len is 0\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (res->len != physmem->len) {\n-\t\tvcm_err(\"res->len (%i) != physmem->len (%i)\\n\",\n-\t\t\tres->len, physmem->len);\n-\t\tgoto fail;\n-\t}\n-\n-\tif (physmem->is_cont) {\n-\t\tif (physmem->res == 0) {\n-\t\t\tvcm_err(\"cont physmem->res is 0\");\n-\t\t\tgoto fail;\n-\t\t}\n-\t} else {\n-\t\t/* fail if no physmem */\n-\t\tif (list_empty(&physmem->alloc_head.allocated)) {\n-\t\t\tvcm_err(\"no allocated phys memory\");\n-\t\t\tgoto fail;\n-\t\t}\n-\t}\n-\n-\tret = vcm_no_assoc(res->vcm);\n-\tif (ret == 1) {\n-\t\tvcm_err(\"can't back un associated VCM\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (ret == -1) {\n-\t\tvcm_err(\"vcm_no_assoc() ret -1\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tret = vcm_all_activated(res->vcm);\n-\tif (ret == 0) {\n-\t\tvcm_err(\"can't back, not all associations are activated\\n\");\n-\t\tgoto fail_eagain;\n-\t}\n-\n-\tif (ret == -1) {\n-\t\tvcm_err(\"vcm_all_activated() ret -1\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tva = res->dev_addr;\n-\n-\tlist_for_each_entry(chunk, &physmem->alloc_head.allocated,\n-\t\t\t    allocated) {\n-\t\tstruct vcm *vcm = res->vcm;\n-\t\tsize_t chunk_size = chunk->size;\n-\n-\t\tif (chunk_size <= 0) {\n-\t\t\tvcm_err(\"Bad chunk size: %d\\n\", chunk_size);\n-\t\t\tgoto fail;\n-\t\t}\n-\n-\t\tswitch (vcm->type) {\n-\t\tcase VCM_DEVICE:\n-\t\t{\n-\t\t\t/* map all */\n-\t\t\tret = vcm_process_chunk(vcm->domain, chunk->pa,\n-\t\t\t\t\t\tva, chunk_size, attr, 1);\n-\t\t\tif (ret != 0) {\n-\t\t\t\tvcm_err(\"vcm_process_chunk(%p, %p, %p,\"\n-\t\t\t\t\t\" 0x%x, 0x%x)\"\n-\t\t\t\t\t\" ret %i\",\n-\t\t\t\t\tvcm->domain,\n-\t\t\t\t\t(void *) chunk->pa,\n-\t\t\t\t\t(void *) va,\n-\t\t\t\t\t(int) chunk_size, attr, ret);\n-\t\t\t\tgoto fail;\n-\t\t\t}\n-\t\t\tbreak;\n-\t\t}\n-\n-\t\tcase VCM_EXT_KERNEL:\n-\t\t{\n-\t\t\tunsigned int pages_in_chunk = chunk_size / PAGE_SIZE;\n-\t\t\tunsigned long loc_va = va;\n-\t\t\tunsigned long loc_pa = chunk->pa;\n-\n-\t\t\tconst struct mem_type *mtype;\n-\n-\t\t\t/* TODO: get this based on MEMTYPE */\n-\t\t\tmtype = get_mem_type(MT_DEVICE);\n-\t\t\tif (!mtype) {\n-\t\t\t\tvcm_err(\"mtype is 0\\n\");\n-\t\t\t\tgoto fail;\n-\t\t\t}\n-\n-\t\t\t/* TODO: Map with the same chunk size */\n-\t\t\twhile (pages_in_chunk--) {\n-\t\t\t\tret = ioremap_page(loc_va,\n-\t\t\t\t\t\t   loc_pa,\n-\t\t\t\t\t\t   mtype);\n-\t\t\t\tif (ret != 0) {\n-\t\t\t\t\tvcm_err(\"ioremap_page(%p, %p, %p) ret\"\n-\t\t\t\t\t\t\" %i\", (void *) loc_va,\n-\t\t\t\t\t\t(void *) loc_pa,\n-\t\t\t\t\t\t(void *) mtype, ret);\n-\t\t\t\t\tgoto fail;\n-\t\t\t\t\t/* TODO handle weird\n-\t\t\t\t\t   inter-map case */\n-\t\t\t\t}\n-\n-\t\t\t\t/* hack part 2 */\n-\t\t\t\t/* we're changing the PT entry behind\n-\t\t\t\t * linux's back\n-\t\t\t\t */\n-\t\t\t\tret = cpu_set_attr(loc_va, PAGE_SIZE, attr);\n-\t\t\t\tif (ret != 0) {\n-\t\t\t\t\tvcm_err(\"cpu_set_attr(%p, %lu, %x)\"\n-\t\t\t\t\t\t\"ret %i\\n\",\n-\t\t\t\t\t\t(void *) loc_va, PAGE_SIZE,\n-\t\t\t\t\t\tattr, ret);\n-\t\t\t\t\tgoto fail;\n-\t\t\t\t\t/* TODO handle weird\n-\t\t\t\t\t   inter-map case */\n-\t\t\t\t}\n-\n-\t\t\t\tres->mapped = 1;\n-\n-\t\t\t\tloc_va += PAGE_SIZE;\n-\t\t\t\tloc_pa += PAGE_SIZE;\n-\t\t\t}\n-\n-\t\t\tflush_cache_vmap(va, loc_va);\n-\t\t\tbreak;\n-\t\t}\n-\t\tcase VCM_ONE_TO_ONE:\n-\t\t\tva = chunk->pa;\n-\t\t\tbreak;\n-\t\tdefault:\n-\t\t\t/* this should never happen */\n-\t\t\tgoto fail;\n-\t\t}\n-\n-\t\tva += chunk_size;\n-\t\t/* also add res to the allocated chunk list of refs */\n-\t}\n-\n-\t/* note the reservation */\n-\tres->physmem = physmem;\n-\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn 0;\n-fail_eagain:\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn -EAGAIN;\n-fail:\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn -EINVAL;\n-}\n-\n-\n-int vcm_unback(struct res *res)\n-{\n-\tunsigned long flags;\n-\tstruct vcm *vcm;\n-\tstruct physmem *physmem;\n-\tint ret;\n-\n-\tspin_lock_irqsave(&vcmlock, flags);\n-\n-\tif (!res)\n-\t\tgoto fail;\n-\n-\tvcm = res->vcm;\n-\tif (!vcm) {\n-\t\tvcm_err(\"NULL vcm\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (!res->physmem) {\n-\t\tvcm_err(\"can't unback a non-backed reservation\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tphysmem = res->physmem;\n-\tif (!physmem) {\n-\t\tvcm_err(\"physmem is NULL\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (list_empty(&physmem->alloc_head.allocated)) {\n-\t\tvcm_err(\"physmem allocation is empty\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tret = vcm_no_assoc(res->vcm);\n-\tif (ret == 1) {\n-\t\tvcm_err(\"can't unback a unassociated reservation\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (ret == -1) {\n-\t\tvcm_err(\"vcm_no_assoc(%p) ret -1\\n\", (void *) res->vcm);\n-\t\tgoto fail;\n-\t}\n-\n-\tret = vcm_all_activated(res->vcm);\n-\tif (ret == 0) {\n-\t\tvcm_err(\"can't unback, not all associations are active\\n\");\n-\t\tgoto fail_eagain;\n-\t}\n-\n-\tif (ret == -1) {\n-\t\tvcm_err(\"vcm_all_activated(%p) ret -1\\n\", (void *) res->vcm);\n-\t\tgoto fail;\n-\t}\n-\n-\n-\tswitch (vcm->type) {\n-\tcase VCM_EXT_KERNEL:\n-\t\tif (!res->mapped) {\n-\t\t\tvcm_err(\"can't unback an unmapped VCM_EXT_KERNEL\"\n-\t\t\t\t\" VCM\\n\");\n-\t\t\tgoto fail;\n-\t\t}\n-\n-\t\t/* vunmap free's vm_area */\n-\t\tvunmap(res->vm_area->addr);\n-\t\tres->vm_area = 0;\n-\n-\t\tres->mapped = 0;\n-\t\tbreak;\n-\n-\tcase VCM_DEVICE:\n-\t{\n-\t\tstruct phys_chunk *chunk;\n-\t\tsize_t va = res->dev_addr;\n-\n-\t\tlist_for_each_entry(chunk, &physmem->alloc_head.allocated,\n-\t\t\t\t    allocated) {\n-\t\t\tstruct vcm *vcm = res->vcm;\n-\t\t\tsize_t chunk_size = chunk->size;\n-\n-\t\t\tret = vcm_process_chunk(vcm->domain, 0, va,\n-\t\t\t\t\t\tchunk_size, 0, 0);\n-\t\t\tif (ret != 0) {\n-\t\t\t\tvcm_err(\"vcm_unback_chunk(%p, %p, 0x%x)\"\n-\t\t\t\t\t\" ret %i\",\n-\t\t\t\t\t(void *) vcm->domain,\n-\t\t\t\t\t(void *) va,\n-\t\t\t\t\t(int) chunk_size, ret);\n-\t\t\t\tgoto fail;\n-\t\t\t\t/* TODO handle weird inter-unmap state*/\n-\t\t\t}\n-\n-\t\t\tva += chunk_size;\n-\t\t\t/* may to a light unback, depending on the requested\n-\t\t\t* functionality\n-\t\t\t */\n-\t\t}\n-\t\tbreak;\n-\t}\n-\n-\tcase VCM_ONE_TO_ONE:\n-\t\tbreak;\n-\tdefault:\n-\t\t/* this should never happen */\n-\t\tgoto fail;\n-\t}\n-\n-\t/* clear the reservation */\n-\tres->physmem = 0;\n-\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn 0;\n-fail_eagain:\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn -EAGAIN;\n-fail:\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn -EINVAL;\n-}\n-\n-\n-enum memtarget_t vcm_get_memtype_of_res(struct res *res)\n-{\n-\treturn VCM_INVALID;\n-}\n-\n-static int vcm_free_max_munch_cont(struct phys_chunk *head)\n-{\n-\tstruct phys_chunk *chunk, *tmp;\n-\n-\tif (!head)\n-\t\treturn -EINVAL;\n-\n-\tlist_for_each_entry_safe(chunk, tmp, &head->allocated,\n-\t\t\t\t allocated) {\n-\t\tlist_del_init(&chunk->allocated);\n-\t}\n-\n-\treturn 0;\n-}\n-\n-static int vcm_alloc_max_munch_cont(size_t start_addr, size_t len,\n-\t\t\t\t    struct phys_chunk *head)\n-{\n-\t/* this function should always succeed, since it\n-\t   parallels a VCM */\n-\n-\tint i, j;\n-\n-\tif (!head) {\n-\t\tvcm_err(\"head is NULL in continuous map.\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (start_addr < (int) bootmem_cont) {\n-\t\tvcm_err(\"phys start addr (%p) < base (%p)\\n\",\n-\t\t\t(void *) start_addr, (void *) bootmem_cont);\n-\t\tgoto fail;\n-\t}\n-\n-\tif ((start_addr + len) >= ((size_t) bootmem_cont + cont_sz)) {\n-\t\tvcm_err(\"requested region (%p + %i) > \"\n-\t\t\t\" available region (%p + %i)\",\n-\t\t\t(void *) start_addr, (int) len,\n-\t\t\t(void *) bootmem_cont, cont_sz);\n-\t\tgoto fail;\n-\t}\n-\n-\ti = (start_addr - (size_t) bootmem_cont)/SZ_4K;\n-\n-\tfor (j = 0; j < ARRAY_SIZE(smmu_map_sizes); ++j) {\n-\t\twhile (len/smmu_map_sizes[j]) {\n-\t\t\tif (!list_empty(&cont_phys_chunk[i].allocated)) {\n-\t\t\t\tvcm_err(\"chunk %i ( addr %p) already mapped\\n\",\n-\t\t\t\t\ti, (void *) (start_addr +\n-\t\t\t\t\t\t     (i*smmu_map_sizes[j])));\n-\t\t\t\tgoto fail_free;\n-\t\t\t}\n-\t\t\tlist_add_tail(&cont_phys_chunk[i].allocated,\n-\t\t\t\t      &head->allocated);\n-\t\t\tcont_phys_chunk[i].size = smmu_map_sizes[j];\n-\n-\t\t\tlen -= smmu_map_sizes[j];\n-\t\t\ti += smmu_map_sizes[j]/SZ_4K;\n-\t\t}\n-\t}\n-\n-\tif (len % SZ_4K) {\n-\t\tif (!list_empty(&cont_phys_chunk[i].allocated)) {\n-\t\t\tvcm_err(\"chunk %i (addr %p) already mapped\\n\",\n-\t\t\t\ti, (void *) (start_addr + (i*SZ_4K)));\n-\t\t\tgoto fail_free;\n-\t\t}\n-\t\tlen -= SZ_4K;\n-\t\tlist_add_tail(&cont_phys_chunk[i].allocated,\n-\t\t\t      &head->allocated);\n-\n-\t\ti++;\n-\t}\n-\n-\treturn i;\n-\n-fail_free:\n-\t{\n-\t\tstruct phys_chunk *chunk, *tmp;\n-\t\t/* just remove from list, if we're double alloc'ing\n-\t\t   we don't want to stamp on the other guy */\n-\t\tlist_for_each_entry_safe(chunk, tmp, &head->allocated,\n-\t\t\t\t\t allocated) {\n-\t\t\tlist_del(&chunk->allocated);\n-\t\t}\n-\t}\n-fail:\n-\treturn 0;\n-}\n-\n-struct physmem *vcm_phys_alloc(enum memtype_t memtype, size_t len, u32 attr)\n-{\n-\tunsigned long flags;\n-\tint ret;\n-\tstruct physmem *physmem = NULL;\n-\tint blocks_allocated;\n-\n-\tspin_lock_irqsave(&vcmlock, flags);\n-\n-\tphysmem = kzalloc(sizeof(*physmem), GFP_KERNEL);\n-\tif (!physmem) {\n-\t\tvcm_err(\"physmem is NULL\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tphysmem->memtype = memtype;\n-\tphysmem->len = len;\n-\tphysmem->attr = attr;\n-\n-\tINIT_LIST_HEAD(&physmem->alloc_head.allocated);\n-\n-\tif (attr & VCM_PHYS_CONT) {\n-\t\tif (!cont_vcm_id) {\n-\t\t\tvcm_err(\"cont_vcm_id is NULL\\n\");\n-\t\t\tgoto fail2;\n-\t\t}\n-\n-\t\tphysmem->is_cont = 1;\n-\n-\t\t/* TODO: get attributes */\n-\t\tphysmem->res = __vcm_reserve(cont_vcm_id, len, 0);\n-\t\tif (physmem->res == 0) {\n-\t\t\tvcm_err(\"contiguous space allocation failed\\n\");\n-\t\t\tgoto fail2;\n-\t\t}\n-\n-\t\t/* if we're here we know we have memory, create\n-\t\t   the shadow physmem links*/\n-\t\tblocks_allocated =\n-\t\t\tvcm_alloc_max_munch_cont(\n-\t\t\t\tphysmem->res->dev_addr,\n-\t\t\t\tlen,\n-\t\t\t\t&physmem->alloc_head);\n-\n-\t\tif (blocks_allocated == 0) {\n-\t\t\tvcm_err(\"shadow physmem allocation failed\\n\");\n-\t\t\tgoto fail3;\n-\t\t}\n-\t} else {\n-\t\tblocks_allocated = vcm_alloc_max_munch(len, memtype,\n-\t\t\t\t\t\t       &physmem->alloc_head);\n-\t\tif (blocks_allocated == 0) {\n-\t\t\tvcm_err(\"physical allocation failed:\"\n-\t\t\t\t\" vcm_alloc_max_munch(%i, %p) ret 0\\n\",\n-\t\t\t\tlen, &physmem->alloc_head);\n-\t\t\tgoto fail2;\n-\t\t}\n-\t}\n-\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn physmem;\n-\n-fail3:\n-\tret = __vcm_unreserve(physmem->res);\n-\tif (ret != 0) {\n-\t\tvcm_err(\"vcm_unreserve(%p) ret %i during cleanup\",\n-\t\t\t(void *) physmem->res, ret);\n-\t\tspin_unlock_irqrestore(&vcmlock, flags);\n-\t\treturn 0;\n-\t}\n-fail2:\n-\tkfree(physmem);\n-fail:\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn 0;\n-}\n-\n-\n-int vcm_phys_free(struct physmem *physmem)\n-{\n-\tunsigned long flags;\n-\tint ret;\n-\n-\tspin_lock_irqsave(&vcmlock, flags);\n-\n-\tif (!physmem) {\n-\t\tvcm_err(\"physmem is NULL\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (physmem->is_cont) {\n-\t\tif (physmem->res == 0) {\n-\t\t\tvcm_err(\"contiguous reservation is NULL\\n\");\n-\t\t\tgoto fail;\n-\t\t}\n-\n-\t\tret = vcm_free_max_munch_cont(&physmem->alloc_head);\n-\t\tif (ret != 0) {\n-\t\t\tvcm_err(\"failed to free physical blocks:\"\n-\t\t\t\t\" vcm_free_max_munch_cont(%p) ret %i\\n\",\n-\t\t\t\t(void *) &physmem->alloc_head, ret);\n-\t\t\tgoto fail;\n-\t\t}\n-\n-\t\tret = __vcm_unreserve(physmem->res);\n-\t\tif (ret != 0) {\n-\t\t\tvcm_err(\"failed to free virtual blocks:\"\n-\t\t\t\t\" vcm_unreserve(%p) ret %i\\n\",\n-\t\t\t\t(void *) physmem->res, ret);\n-\t\t\tgoto fail;\n-\t\t}\n-\n-\t} else {\n-\n-\t\tret = vcm_alloc_free_blocks(physmem->memtype,\n-\t\t\t\t\t    &physmem->alloc_head);\n-\t\tif (ret != 0) {\n-\t\t\tvcm_err(\"failed to free physical blocks:\"\n-\t\t\t\t\" vcm_alloc_free_blocks(%p) ret %i\\n\",\n-\t\t\t\t(void *) &physmem->alloc_head, ret);\n-\t\t\tgoto fail;\n-\t\t}\n-\t}\n-\n-\tmemset(physmem, 0, sizeof(*physmem));\n-\n-\tkfree(physmem);\n-\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn 0;\n-\n-fail:\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn -EINVAL;\n-}\n-\n-\n-struct avcm *vcm_assoc(struct vcm *vcm, struct device *dev, u32 attr)\n-{\n-\tunsigned long flags;\n-\tstruct avcm *avcm = NULL;\n-\n-\tspin_lock_irqsave(&vcmlock, flags);\n-\n-\tif (!vcm) {\n-\t\tvcm_err(\"vcm is NULL\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (!dev) {\n-\t\tvcm_err(\"dev_id is NULL\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (vcm->type == VCM_EXT_KERNEL && !list_empty(&vcm->assoc_head)) {\n-\t\tvcm_err(\"only one device may be assocoated with a\"\n-\t\t\t\" VCM_EXT_KERNEL\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tavcm = kzalloc(sizeof(*avcm), GFP_KERNEL);\n-\tif (!avcm) {\n-\t\tvcm_err(\"kzalloc(%i, GFP_KERNEL) ret NULL\\n\", sizeof(*avcm));\n-\t\tgoto fail;\n-\t}\n-\n-\tavcm->dev = dev;\n-\n-\tavcm->vcm = vcm;\n-\tavcm->attr = attr;\n-\tavcm->is_active = 0;\n-\n-\tINIT_LIST_HEAD(&avcm->assoc_elm);\n-\tlist_add(&avcm->assoc_elm, &vcm->assoc_head);\n-\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn avcm;\n-\n-fail:\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn 0;\n-}\n-\n-\n-int vcm_deassoc(struct avcm *avcm)\n-{\n-\tunsigned long flags;\n-\n-\tspin_lock_irqsave(&vcmlock, flags);\n-\n-\tif (!avcm) {\n-\t\tvcm_err(\"avcm is NULL\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (list_empty(&avcm->assoc_elm)) {\n-\t\tvcm_err(\"nothing to deassociate\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (avcm->is_active) {\n-\t\tvcm_err(\"association still activated\\n\");\n-\t\tgoto fail_busy;\n-\t}\n-\n-\tlist_del(&avcm->assoc_elm);\n-\n-\tmemset(avcm, 0, sizeof(*avcm));\n-\n-\tkfree(avcm);\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn 0;\n-fail_busy:\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn -EBUSY;\n-fail:\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn -EINVAL;\n-}\n-\n-\n-int vcm_set_assoc_attr(struct avcm *avcm, u32 attr)\n-{\n-\treturn 0;\n-}\n-\n-\n-u32 vcm_get_assoc_attr(struct avcm *avcm)\n-{\n-\treturn 0;\n-}\n-\n-\n-int vcm_activate(struct avcm *avcm)\n-{\n-\tunsigned long flags;\n-\tstruct vcm *vcm;\n-\n-\tspin_lock_irqsave(&vcmlock, flags);\n-\n-\tif (!avcm) {\n-\t\tvcm_err(\"avcm is NULL\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tvcm = avcm->vcm;\n-\tif (!vcm) {\n-\t\tvcm_err(\"NULL vcm\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (!avcm->dev) {\n-\t\tvcm_err(\"cannot activate without a device\\n\");\n-\t\tgoto fail_nodev;\n-\t}\n-\n-\tif (avcm->is_active) {\n-\t\tvcm_err(\"double activate\\n\");\n-\t\tgoto fail_busy;\n-\t}\n-\n-\tif (vcm->type == VCM_DEVICE) {\n-#ifdef CONFIG_SMMU\n-\t\tint ret;\n-\t\tret = iommu_attach_device(vcm->domain, avcm->dev);\n-\t\tif (ret != 0) {\n-\t\t\tdev_err(avcm->dev, \"failed to attach to domain\\n\");\n-\t\t\tgoto fail_dev;\n-\t\t}\n-#else\n-\t\tvcm_err(\"No SMMU support - cannot activate/deactivate\\n\");\n-\t\tgoto fail_nodev;\n-#endif\n-\t}\n-\n-\tavcm->is_active = 1;\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn 0;\n-\n-#ifdef CONFIG_SMMU\n-fail_dev:\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn -ENODEV;\n-#endif\n-fail_busy:\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn -EBUSY;\n-fail_nodev:\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn -ENODEV;\n-fail:\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn -EINVAL;\n-}\n-\n-\n-int vcm_deactivate(struct avcm *avcm)\n-{\n-\tunsigned long flags;\n-\tstruct vcm *vcm;\n-\n-\tspin_lock_irqsave(&vcmlock, flags);\n-\n-\tif (!avcm)\n-\t\tgoto fail;\n-\n-\tvcm = avcm->vcm;\n-\tif (!vcm) {\n-\t\tvcm_err(\"NULL vcm\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (!avcm->dev) {\n-\t\tvcm_err(\"cannot deactivate without a device\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (!avcm->is_active) {\n-\t\tvcm_err(\"double deactivate\\n\");\n-\t\tgoto fail_nobusy;\n-\t}\n-\n-\tif (vcm->type == VCM_DEVICE) {\n-#ifdef CONFIG_SMMU\n-\t\t/* TODO, pmem check */\n-\t\tiommu_detach_device(vcm->domain, avcm->dev);\n-#else\n-\t\tvcm_err(\"No SMMU support - cannot activate/deactivate\\n\");\n-\t\tgoto fail;\n-#endif\n-\t}\n-\n-\tavcm->is_active = 0;\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn 0;\n-fail_nobusy:\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn -ENOENT;\n-fail:\n-\tspin_unlock_irqrestore(&vcmlock, flags);\n-\treturn -EINVAL;\n-}\n-\n-struct bound *vcm_create_bound(struct vcm *vcm, size_t len)\n-{\n-\treturn 0;\n-}\n-\n-\n-int vcm_free_bound(struct bound *bound)\n-{\n-\treturn -EINVAL;\n-}\n-\n-\n-struct res *vcm_reserve_from_bound(struct bound *bound, size_t len,\n-\t\t\t\t   u32 attr)\n-{\n-\treturn 0;\n-}\n-\n-\n-size_t vcm_get_bound_start_addr(struct bound *bound)\n-{\n-\treturn 0;\n-}\n-\n-\n-size_t vcm_get_bound_len(struct bound *bound)\n-{\n-\treturn 0;\n-}\n-\n-\n-struct physmem *vcm_map_phys_addr(phys_addr_t phys, size_t len)\n-{\n-\treturn 0;\n-}\n-\n-\n-size_t vcm_get_next_phys_addr(struct physmem *physmem, phys_addr_t phys,\n-\t\t\t      size_t *len)\n-{\n-\treturn 0;\n-}\n-\n-\n-struct res *vcm_get_res(unsigned long dev_addr, struct vcm *vcm)\n-{\n-\treturn 0;\n-}\n-\n-\n-size_t vcm_translate(struct device *src_dev, struct vcm *src_vcm,\n-\t\t     struct vcm *dst_vcm)\n-{\n-\treturn 0;\n-}\n-\n-\n-size_t vcm_get_phys_num_res(phys_addr_t phys)\n-{\n-\treturn 0;\n-}\n-\n-\n-struct res *vcm_get_next_phys_res(phys_addr_t phys, struct res *res,\n-\t\t\t\t  size_t *len)\n-{\n-\treturn 0;\n-}\n-\n-\n-phys_addr_t vcm_get_pgtbl_pa(struct vcm *vcm)\n-{\n-\treturn 0;\n-}\n-\n-\n-/* No lock needed, smmu_translate has its own lock */\n-phys_addr_t vcm_dev_addr_to_phys_addr(struct vcm *vcm, unsigned long dev_addr)\n-{\n-\tif (!vcm)\n-\t\treturn -EINVAL;\n-#ifdef CONFIG_SMMU\n-\treturn iommu_iova_to_phys(vcm->domain, dev_addr);\n-#else\n-\tvcm_err(\"No support for SMMU - manual translation not supported\\n\");\n-\treturn -ENODEV;\n-#endif\n-}\n-\n-\n-/* No lock needed, bootmem_cont never changes after  */\n-phys_addr_t vcm_get_cont_memtype_pa(enum memtype_t memtype)\n-{\n-\tif (memtype != VCM_MEMTYPE_0) {\n-\t\tvcm_err(\"memtype != VCM_MEMTYPE_0\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (!bootmem_cont) {\n-\t\tvcm_err(\"bootmem_cont 0\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\treturn (size_t) bootmem_cont;\n-fail:\n-\treturn 0;\n-}\n-\n-\n-/* No lock needed, constant */\n-size_t vcm_get_cont_memtype_len(enum memtype_t memtype)\n-{\n-\tif (memtype != VCM_MEMTYPE_0) {\n-\t\tvcm_err(\"memtype != VCM_MEMTYPE_0\\n\");\n-\t\treturn 0;\n-\t}\n-\n-\treturn cont_sz;\n-}\n-\n-int vcm_hook(struct device *dev, vcm_handler handler, void *data)\n-{\n-#ifdef CONFIG_SMMU\n-\tvcm_err(\"No interrupts in IOMMU API\\n\");\n-\treturn -ENODEV;\n-#else\n-\tvcm_err(\"No support for SMMU - interrupts not supported\\n\");\n-\treturn -ENODEV;\n-#endif\n-}\n-\n-\n-size_t vcm_hw_ver(size_t dev)\n-{\n-\treturn 0;\n-}\n-\n-\n-static int vcm_cont_phys_chunk_init(void)\n-{\n-\tint i;\n-\tint cont_pa;\n-\n-\tif (!cont_phys_chunk) {\n-\t\tvcm_err(\"cont_phys_chunk 0\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (!bootmem_cont) {\n-\t\tvcm_err(\"bootmem_cont 0\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tcont_pa = (size_t) bootmem_cont;\n-\n-\tfor (i = 0; i < cont_sz/PAGE_SIZE; ++i) {\n-\t\tcont_phys_chunk[i].pa = cont_pa; cont_pa += PAGE_SIZE;\n-\t\tcont_phys_chunk[i].size = SZ_4K;\n-\t\t/* Not part of an allocator-managed pool */\n-\t\tcont_phys_chunk[i].pool_idx = -1;\n-\t\tINIT_LIST_HEAD(&cont_phys_chunk[i].allocated);\n-\t}\n-\n-\treturn 0;\n-\n-fail:\n-\treturn -EINVAL;\n-}\n-\n-int vcm_sys_init(struct physmem_region *mem, int n_regions,\n-\t\t struct vcm_memtype_map *mt_map, int n_mt,\n-\t\t void *cont_pa, unsigned int cont_len)\n-{\n-\tint ret;\n-\tprintk(KERN_INFO \"VCM Initialization\\n\");\n-\tbootmem_cont = cont_pa;\n-\tcont_sz = cont_len;\n-\n-\tif (!bootmem_cont) {\n-\t\tvcm_err(\"bootmem_cont is 0\\n\");\n-\t\tret = -1;\n-\t\tgoto fail;\n-\t}\n-\n-\tret = vcm_setup_tex_classes();\n-\tif (ret != 0) {\n-\t\tprintk(KERN_INFO \"Could not determine TEX attribute mapping\\n\");\n-\t\tret = -1;\n-\t\tgoto fail;\n-\t}\n-\n-\n-\tret = vcm_alloc_init(mem, n_regions, mt_map, n_mt);\n-\n-\tif (ret != 0) {\n-\t\tvcm_err(\"vcm_alloc_init() ret %i\\n\", ret);\n-\t\tret = -1;\n-\t\tgoto fail;\n-\t}\n-\n-\tcont_phys_chunk = kzalloc(sizeof(*cont_phys_chunk)*(cont_sz/PAGE_SIZE),\n-\t\t\t\t  GFP_KERNEL);\n-\tif (!cont_phys_chunk) {\n-\t\tvcm_err(\"kzalloc(%lu, GFP_KERNEL) ret 0\",\n-\t\t\tsizeof(*cont_phys_chunk)*(cont_sz/PAGE_SIZE));\n-\t\tgoto fail_free;\n-\t}\n-\n-\t/* the address and size will hit our special case unless we\n-\t   pass an override */\n-\tcont_vcm_id = vcm_create_flagged(0, (size_t)bootmem_cont, cont_sz);\n-\tif (cont_vcm_id == 0) {\n-\t\tvcm_err(\"vcm_create_flagged(0, %p, %i) ret 0\\n\",\n-\t\t\tbootmem_cont, cont_sz);\n-\t\tret = -1;\n-\t\tgoto fail_free2;\n-\t}\n-\n-\tret = vcm_cont_phys_chunk_init();\n-\tif (ret != 0) {\n-\t\tvcm_err(\"vcm_cont_phys_chunk_init() ret %i\\n\", ret);\n-\t\tgoto fail_free3;\n-\t}\n-\n-\tprintk(KERN_INFO \"VCM Initialization OK\\n\");\n-\treturn 0;\n-\n-fail_free3:\n-\tret = __vcm_free(cont_vcm_id);\n-\tif (ret != 0) {\n-\t\tvcm_err(\"vcm_free(%p) ret %i during failure path\\n\",\n-\t\t\t(void *) cont_vcm_id, ret);\n-\t\treturn ret;\n-\t}\n-\n-fail_free2:\n-\tkfree(cont_phys_chunk);\n-\tcont_phys_chunk = 0;\n-\n-fail_free:\n-\tret = vcm_alloc_destroy();\n-\tif (ret != 0)\n-\t\tvcm_err(\"vcm_alloc_destroy() ret %i during failure path\\n\",\n-\t\t\tret);\n-\n-\tret = -EINVAL;\n-fail:\n-\treturn ret;\n-}\n-\n-\n-int vcm_sys_destroy(void)\n-{\n-\tint ret = 0;\n-\n-\tif (!cont_phys_chunk) {\n-\t\tvcm_err(\"cont_phys_chunk is 0\\n\");\n-\t\treturn -ENODEV;\n-\t}\n-\n-\tif (!cont_vcm_id) {\n-\t\tvcm_err(\"cont_vcm_id is 0\\n\");\n-\t\treturn -ENODEV;\n-\t}\n-\n-\tret = __vcm_free(cont_vcm_id);\n-\tif (ret != 0) {\n-\t\tvcm_err(\"vcm_free(%p) ret %i\\n\", (void *) cont_vcm_id, ret);\n-\t\treturn -ENODEV;\n-\t}\n-\n-\tcont_vcm_id = 0;\n-\n-\tkfree(cont_phys_chunk);\n-\tcont_phys_chunk = 0;\n-\n-\tret = vcm_alloc_destroy();\n-\tif (ret != 0) {\n-\t\tvcm_err(\"vcm_alloc_destroy() ret %i\\n\", ret);\n-\t\treturn ret;\n-\t}\n-\n-\treturn ret;\n-}\n-\n-MODULE_LICENSE(\"GPL v2\");\n-MODULE_AUTHOR(\"Zach Pfeffer <zpfeffer@codeaurora.org>\");\ndiff --git a/arch/arm/mm/vcm_alloc.c b/arch/arm/mm/vcm_alloc.c\ndeleted file mode 100644\nindex 2106ebb..0000000\n--- a/arch/arm/mm/vcm_alloc.c\n+++ /dev/null\n@@ -1,557 +0,0 @@\n-/* Copyright (c) 2010, The Linux Foundation. All rights reserved.\n- *\n- * This program is free software; you can redistribute it and/or modify\n- * it under the terms of the GNU General Public License version 2 and\n- * only version 2 as published by the Free Software Foundation.\n- *\n- * This program is distributed in the hope that it will be useful,\n- * but WITHOUT ANY WARRANTY; without even the implied warranty of\n- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n- * GNU General Public License for more details.\n- */\n-\n-#include <linux/kernel.h>\n-#include <linux/slab.h>\n-#include <linux/module.h>\n-#include <linux/vcm.h>\n-#include <linux/vcm_alloc.h>\n-#include <linux/string.h>\n-#include <asm/sizes.h>\n-\n-int basicalloc_init;\n-\n-#define vcm_alloc_err(a, ...)\t\t\t\t\t\t\\\n-\tpr_err(\"ERROR %s %i \" a, __func__, __LINE__, ##__VA_ARGS__)\n-\n-struct phys_chunk_head {\n-\tstruct list_head head;\n-\tint num;\n-};\n-\n-struct phys_pool {\n-\tint size;\n-\tint chunk_size;\n-\tstruct phys_chunk_head head;\n-};\n-\n-static int vcm_num_phys_pools;\n-static int vcm_num_memtypes;\n-static struct phys_pool *vcm_phys_pool;\n-static struct vcm_memtype_map *memtype_map;\n-\n-static int num_pools(enum memtype_t memtype)\n-{\n-\tif (memtype >= vcm_num_memtypes) {\n-\t\tvcm_alloc_err(\"Bad memtype: %d\\n\", memtype);\n-\t\treturn -EINVAL;\n-\t}\n-\treturn memtype_map[memtype].num_pools;\n-}\n-\n-static int pool_chunk_size(enum memtype_t memtype, int prio_idx)\n-{\n-\tint pool_idx;\n-\tif (memtype >= vcm_num_memtypes) {\n-\t\tvcm_alloc_err(\"Bad memtype: %d\\n\", memtype);\n-\t\treturn -EINVAL;\n-\t}\n-\n-\tif (prio_idx >= num_pools(memtype)) {\n-\t\tvcm_alloc_err(\"Bad prio index: %d, max=%d, mt=%d\\n\", prio_idx,\n-\t\t\t      num_pools(memtype), memtype);\n-\t\treturn -EINVAL;\n-\t}\n-\n-\tpool_idx = memtype_map[memtype].pool_id[prio_idx];\n-\treturn vcm_phys_pool[pool_idx].chunk_size;\n-}\n-\n-int vcm_alloc_pool_idx_to_size(int pool_idx)\n-{\n-\tif (pool_idx >= vcm_num_phys_pools) {\n-\t\tvcm_alloc_err(\"Bad pool index: %d\\n, max=%d\\n\", pool_idx,\n-\t\t\t      vcm_num_phys_pools);\n-\t\treturn -EINVAL;\n-\t}\n-\treturn vcm_phys_pool[pool_idx].chunk_size;\n-}\n-\n-static struct phys_chunk_head *get_chunk_list(enum memtype_t memtype,\n-\t\t\t\t\t      int prio_idx)\n-{\n-\tunsigned int pool_idx;\n-\n-\tif (memtype >= vcm_num_memtypes) {\n-\t\tvcm_alloc_err(\"Bad memtype: %d\\n\", memtype);\n-\t\treturn NULL;\n-\t}\n-\n-\tif (prio_idx >= num_pools(memtype)) {\n-\t\tvcm_alloc_err(\"bad chunk size: mt=%d, prioidx=%d, np=%d\\n\",\n-\t\t\t      memtype, prio_idx, num_pools(memtype));\n-\t\tBUG();\n-\t\treturn NULL;\n-\t}\n-\n-\tif (!vcm_phys_pool) {\n-\t\tvcm_alloc_err(\"phys_pool is null\\n\");\n-\t\treturn NULL;\n-\t}\n-\n-\t/* We don't have a \"pool count\" anywhere but this is coming\n-\t * strictly from data in a board file\n-\t */\n-\tpool_idx = memtype_map[memtype].pool_id[prio_idx];\n-\n-\treturn &vcm_phys_pool[pool_idx].head;\n-}\n-\n-static int is_allocated(struct list_head *allocated)\n-{\n-\t/* This should not happen under normal conditions */\n-\tif (!allocated) {\n-\t\tvcm_alloc_err(\"no allocated\\n\");\n-\t\treturn 0;\n-\t}\n-\n-\tif (!basicalloc_init) {\n-\t\tvcm_alloc_err(\"no basicalloc_init\\n\");\n-\t\treturn 0;\n-\t}\n-\treturn !list_empty(allocated);\n-}\n-\n-static int count_allocated_size(enum memtype_t memtype, int idx)\n-{\n-\tint cnt = 0;\n-\tstruct phys_chunk *chunk, *tmp;\n-\tstruct phys_chunk_head *pch;\n-\n-\tif (!basicalloc_init) {\n-\t\tvcm_alloc_err(\"no basicalloc_init\\n\");\n-\t\treturn 0;\n-\t}\n-\n-\tpch = get_chunk_list(memtype, idx);\n-\tif (!pch) {\n-\t\tvcm_alloc_err(\"null pch\\n\");\n-\t\treturn -EINVAL;\n-\t}\n-\n-\tlist_for_each_entry_safe(chunk, tmp, &pch->head, list) {\n-\t\tif (is_allocated(&chunk->allocated))\n-\t\t\tcnt++;\n-\t}\n-\n-\treturn cnt;\n-}\n-\n-\n-int vcm_alloc_get_mem_size(void)\n-{\n-\tif (!vcm_phys_pool) {\n-\t\tvcm_alloc_err(\"No physical pool set up!\\n\");\n-\t\treturn -ENODEV;\n-\t}\n-\treturn vcm_phys_pool[0].size;\n-}\n-EXPORT_SYMBOL(vcm_alloc_get_mem_size);\n-\n-void vcm_alloc_print_list(enum memtype_t memtype, int just_allocated)\n-{\n-\tint i;\n-\tstruct phys_chunk *chunk, *tmp;\n-\tstruct phys_chunk_head *pch;\n-\n-\tif (!basicalloc_init) {\n-\t\tvcm_alloc_err(\"no basicalloc_init\\n\");\n-\t\treturn;\n-\t}\n-\n-\tfor (i = 0; i < num_pools(memtype); ++i) {\n-\t\tpch = get_chunk_list(memtype, i);\n-\n-\t\tif (!pch) {\n-\t\t\tvcm_alloc_err(\"pch is null\\n\");\n-\t\t\treturn;\n-\t\t}\n-\n-\t\tif (list_empty(&pch->head))\n-\t\t\tcontinue;\n-\n-\t\tlist_for_each_entry_safe(chunk, tmp, &pch->head, list) {\n-\t\t\tif (just_allocated && !is_allocated(&chunk->allocated))\n-\t\t\t\tcontinue;\n-\n-\t\t\tprintk(KERN_INFO \"pa = %#x, size = %#x\\n\",\n-\t\t\tchunk->pa, vcm_phys_pool[chunk->pool_idx].chunk_size);\n-\t\t}\n-\t}\n-}\n-EXPORT_SYMBOL(vcm_alloc_print_list);\n-\n-int vcm_alloc_blocks_avail(enum memtype_t memtype, int idx)\n-{\n-\tstruct phys_chunk_head *pch;\n-\tif (!basicalloc_init) {\n-\t\tvcm_alloc_err(\"no basicalloc_init\\n\");\n-\t\treturn 0;\n-\t}\n-\tpch = get_chunk_list(memtype, idx);\n-\n-\tif (!pch) {\n-\t\tvcm_alloc_err(\"pch is null\\n\");\n-\t\treturn 0;\n-\t}\n-\treturn pch->num;\n-}\n-EXPORT_SYMBOL(vcm_alloc_blocks_avail);\n-\n-\n-int vcm_alloc_get_num_chunks(enum memtype_t memtype)\n-{\n-\treturn num_pools(memtype);\n-}\n-EXPORT_SYMBOL(vcm_alloc_get_num_chunks);\n-\n-\n-int vcm_alloc_all_blocks_avail(enum memtarget_t memtype)\n-{\n-\tint i;\n-\tint cnt = 0;\n-\n-\tif (!basicalloc_init) {\n-\t\tvcm_alloc_err(\"no basicalloc_init\\n\");\n-\t\treturn 0;\n-\t}\n-\n-\tfor (i = 0; i < num_pools(memtype); ++i)\n-\t\tcnt += vcm_alloc_blocks_avail(memtype, i);\n-\treturn cnt;\n-}\n-EXPORT_SYMBOL(vcm_alloc_all_blocks_avail);\n-\n-\n-int vcm_alloc_count_allocated(enum memtype_t memtype)\n-{\n-\tint i;\n-\tint cnt = 0;\n-\n-\tif (!basicalloc_init) {\n-\t\tvcm_alloc_err(\"no basicalloc_init\\n\");\n-\t\treturn 0;\n-\t}\n-\n-\tfor (i = 0; i < num_pools(memtype); ++i)\n-\t\tcnt += count_allocated_size(memtype, i);\n-\treturn cnt;\n-}\n-EXPORT_SYMBOL(vcm_alloc_count_allocated);\n-\n-int vcm_alloc_destroy(void)\n-{\n-\tint i, mt;\n-\tstruct phys_chunk *chunk, *tmp;\n-\n-\tif (!basicalloc_init) {\n-\t\tvcm_alloc_err(\"no basicalloc_init\\n\");\n-\t\treturn -ENODEV;\n-\t}\n-\n-\t/* can't destroy a space that has allocations */\n-\tfor (mt = 0; mt < vcm_num_memtypes; mt++)\n-\t\tif (vcm_alloc_count_allocated(mt)) {\n-\t\t\tvcm_alloc_err(\"allocations still present\\n\");\n-\t\t\treturn -EBUSY;\n-\t\t}\n-\n-\tfor (i = 0; i < vcm_num_phys_pools; i++) {\n-\t\tstruct phys_chunk_head *pch = &vcm_phys_pool[i].head;\n-\n-\t\tif (list_empty(&pch->head))\n-\t\t\tcontinue;\n-\t\tlist_for_each_entry_safe(chunk, tmp, &pch->head, list) {\n-\t\t\tlist_del(&chunk->list);\n-\t\t\tmemset(chunk, 0, sizeof(*chunk));\n-\t\t\tkfree(chunk);\n-\t\t}\n-\t\tvcm_phys_pool[i].head.num = 0;\n-\t}\n-\n-\tkfree(vcm_phys_pool);\n-\tkfree(memtype_map);\n-\n-\tvcm_phys_pool = NULL;\n-\tmemtype_map = NULL;\n-\tbasicalloc_init = 0;\n-\tvcm_num_phys_pools = 0;\n-\treturn 0;\n-}\n-EXPORT_SYMBOL(vcm_alloc_destroy);\n-\n-\n-int vcm_alloc_init(struct physmem_region *mem, int n_regions,\n-\t\t   struct vcm_memtype_map *mt_map, int n_mt)\n-{\n-\tint i = 0, j = 0, r = 0, num_chunks;\n-\tstruct phys_chunk *chunk;\n-\tstruct phys_chunk_head *pch = NULL;\n-\tunsigned long pa;\n-\n-\t/* no double inits */\n-\tif (basicalloc_init) {\n-\t\tvcm_alloc_err(\"double basicalloc_init\\n\");\n-\t\tBUG();\n-\t\tgoto fail;\n-\t}\n-\tmemtype_map = kzalloc(sizeof(*mt_map) * n_mt, GFP_KERNEL);\n-\tif (!memtype_map) {\n-\t\tvcm_alloc_err(\"Could not copy memtype map\\n\");\n-\t\tgoto fail;\n-\t}\n-\tmemcpy(memtype_map, mt_map, sizeof(*mt_map) * n_mt);\n-\n-\tvcm_phys_pool = kzalloc(sizeof(*vcm_phys_pool) * n_regions, GFP_KERNEL);\n-\tvcm_num_phys_pools = n_regions;\n-\tvcm_num_memtypes = n_mt;\n-\n-\tif (!vcm_phys_pool) {\n-\t\tvcm_alloc_err(\"Could not allocate physical pool structure\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\t/* separate out to ensure good cleanup */\n-\tfor (i = 0; i < n_regions; i++) {\n-\t\tpch = &vcm_phys_pool[i].head;\n-\t\tINIT_LIST_HEAD(&pch->head);\n-\t\tpch->num = 0;\n-\t}\n-\n-\tfor (r = 0; r < n_regions; r++) {\n-\t\tpa = mem[r].addr;\n-\t\tvcm_phys_pool[r].size = mem[r].size;\n-\t\tvcm_phys_pool[r].chunk_size = mem[r].chunk_size;\n-\t\tpch = &vcm_phys_pool[r].head;\n-\n-\t\tnum_chunks = mem[r].size / mem[r].chunk_size;\n-\n-\t\tprintk(KERN_INFO \"VCM Init: region %d, chunk size=%d, \"\n-\t\t       \"num=%d, pa=%p\\n\", r, mem[r].chunk_size, num_chunks,\n-\t\t       (void *)pa);\n-\n-\t\tfor (j = 0; j < num_chunks; ++j) {\n-\t\t\tchunk = kzalloc(sizeof(*chunk), GFP_KERNEL);\n-\t\t\tif (!chunk) {\n-\t\t\t\tvcm_alloc_err(\"null chunk\\n\");\n-\t\t\t\tgoto fail;\n-\t\t\t}\n-\t\t\tchunk->pa = pa;\n-\t\t\tchunk->size = mem[r].chunk_size;\n-\t\t\tpa += mem[r].chunk_size;\n-\t\t\tchunk->pool_idx = r;\n-\t\t\tINIT_LIST_HEAD(&chunk->allocated);\n-\t\t\tlist_add_tail(&chunk->list, &pch->head);\n-\t\t\tpch->num++;\n-\t\t}\n-\t}\n-\n-\tbasicalloc_init = 1;\n-\treturn 0;\n-fail:\n-\tvcm_alloc_destroy();\n-\treturn -EINVAL;\n-}\n-EXPORT_SYMBOL(vcm_alloc_init);\n-\n-\n-int vcm_alloc_free_blocks(enum memtype_t memtype, struct phys_chunk *alloc_head)\n-{\n-\tstruct phys_chunk *chunk, *tmp;\n-\tstruct phys_chunk_head *pch = NULL;\n-\n-\tif (!basicalloc_init) {\n-\t\tvcm_alloc_err(\"no basicalloc_init\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (!alloc_head) {\n-\t\tvcm_alloc_err(\"no alloc_head\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tlist_for_each_entry_safe(chunk, tmp, &alloc_head->allocated,\n-\t\t\t\t allocated) {\n-\t\tlist_del_init(&chunk->allocated);\n-\t\tpch = &vcm_phys_pool[chunk->pool_idx].head;\n-\n-\t\tif (!pch) {\n-\t\t\tvcm_alloc_err(\"null pch\\n\");\n-\t\t\tgoto fail;\n-\t\t}\n-\t\tpch->num++;\n-\t}\n-\n-\treturn 0;\n-fail:\n-\treturn -ENODEV;\n-}\n-EXPORT_SYMBOL(vcm_alloc_free_blocks);\n-\n-\n-int vcm_alloc_num_blocks(int num, enum memtype_t memtype, int idx,\n-\t\t\t struct phys_chunk *alloc_head)\n-{\n-\tstruct phys_chunk *chunk;\n-\tstruct phys_chunk_head *pch = NULL;\n-\tint num_allocated = 0;\n-\n-\tif (!basicalloc_init) {\n-\t\tvcm_alloc_err(\"no basicalloc_init\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (!alloc_head) {\n-\t\tvcm_alloc_err(\"no alloc_head\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tpch = get_chunk_list(memtype, idx);\n-\n-\tif (!pch) {\n-\t\tvcm_alloc_err(\"null pch\\n\");\n-\t\tgoto fail;\n-\t}\n-\tif (list_empty(&pch->head)) {\n-\t\tvcm_alloc_err(\"list is empty\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (vcm_alloc_blocks_avail(memtype, idx) < num) {\n-\t\tvcm_alloc_err(\"not enough blocks? num=%d\\n\", num);\n-\t\tgoto fail;\n-\t}\n-\n-\tlist_for_each_entry(chunk, &pch->head, list) {\n-\t\tif (num_allocated == num)\n-\t\t\tbreak;\n-\t\tif (is_allocated(&chunk->allocated))\n-\t\t\tcontinue;\n-\n-\t\tlist_add_tail(&chunk->allocated, &alloc_head->allocated);\n-\t\tpch->num--;\n-\t\tnum_allocated++;\n-\t}\n-\treturn num_allocated;\n-fail:\n-\treturn 0;\n-}\n-EXPORT_SYMBOL(vcm_alloc_num_blocks);\n-\n-\n-int vcm_alloc_max_munch(int len, enum memtype_t memtype,\n-\t\t\tstruct phys_chunk *alloc_head)\n-{\n-\tint i;\n-\n-\tint blocks_req = 0;\n-\tint block_residual = 0;\n-\tint blocks_allocated = 0;\n-\tint cur_chunk_size = 0;\n-\tint ba = 0;\n-\n-\tif (!basicalloc_init) {\n-\t\tvcm_alloc_err(\"basicalloc_init is 0\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (!alloc_head) {\n-\t\tvcm_alloc_err(\"alloc_head is NULL\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tif (num_pools(memtype) <= 0) {\n-\t\tvcm_alloc_err(\"Memtype %d has improper mempool configuration\\n\",\n-\t\t\t      memtype);\n-\t\tgoto fail;\n-\t}\n-\n-\tfor (i = 0; i < num_pools(memtype); ++i) {\n-\t\tcur_chunk_size = pool_chunk_size(memtype, i);\n-\t\tif (cur_chunk_size <= 0) {\n-\t\t\tvcm_alloc_err(\"Bad chunk size: %d\\n\", cur_chunk_size);\n-\t\t\tgoto fail;\n-\t\t}\n-\n-\t\tblocks_req = len / cur_chunk_size;\n-\t\tblock_residual = len % cur_chunk_size;\n-\n-\t\tlen = block_residual; /* len left */\n-\t\tif (blocks_req) {\n-\t\t\tint blocks_available = 0;\n-\t\t\tint blocks_diff = 0;\n-\t\t\tint bytes_diff = 0;\n-\n-\t\t\tblocks_available = vcm_alloc_blocks_avail(memtype, i);\n-\t\t\tif (blocks_available < blocks_req) {\n-\t\t\t\tblocks_diff =\n-\t\t\t\t\t(blocks_req - blocks_available);\n-\t\t\t\tbytes_diff =\n-\t\t\t\t\tblocks_diff * cur_chunk_size;\n-\n-\t\t\t\t/* add back in the rest */\n-\t\t\t\tlen += bytes_diff;\n-\t\t\t} else {\n-\t\t\t\t/* got all the blocks I need */\n-\t\t\t\tblocks_available =\n-\t\t\t\t\t(blocks_available > blocks_req)\n-\t\t\t\t\t? blocks_req : blocks_available;\n-\t\t\t}\n-\n-\t\t\tba = vcm_alloc_num_blocks(blocks_available, memtype, i,\n-\t\t\t\t\t\t  alloc_head);\n-\n-\t\t\tif (ba != blocks_available) {\n-\t\t\t\tvcm_alloc_err(\"blocks allocated (%i) !=\"\n-\t\t\t\t\t      \" blocks_available (%i):\"\n-\t\t\t\t\t      \" chunk size = %#x,\"\n-\t\t\t\t\t      \" alloc_head = %p\\n\",\n-\t\t\t\t\t      ba, blocks_available,\n-\t\t\t\t\t      i, (void *) alloc_head);\n-\t\t\t\tgoto fail;\n-\t\t\t}\n-\t\t\tblocks_allocated += blocks_available;\n-\t\t}\n-\t}\n-\n-\tif (len) {\n-\t\tint blocks_available = 0;\n-\t\tint last_sz = num_pools(memtype) - 1;\n-\t\tblocks_available = vcm_alloc_blocks_avail(memtype, last_sz);\n-\n-\t\tif (blocks_available > 0) {\n-\t\t\tba = vcm_alloc_num_blocks(1, memtype, last_sz,\n-\t\t\t\t\t\t  alloc_head);\n-\t\t\tif (ba != 1) {\n-\t\t\t\tvcm_alloc_err(\"blocks allocated (%i) !=\"\n-\t\t\t\t\t      \" blocks_available (%i):\"\n-\t\t\t\t\t      \" chunk size = %#x,\"\n-\t\t\t\t\t      \" alloc_head = %p\\n\",\n-\t\t\t\t\t      ba, 1,\n-\t\t\t\t\t      last_sz,\n-\t\t\t\t\t      (void *) alloc_head);\n-\t\t\t\tgoto fail;\n-\t\t\t}\n-\t\t\tblocks_allocated += 1;\n-\t\t} else {\n-\t\t\tvcm_alloc_err(\"blocks_available (%#x) <= 1\\n\",\n-\t\t\t\t      blocks_available);\n-\t\t\tgoto fail;\n-\t\t}\n-\t}\n-\n-\treturn blocks_allocated;\n-fail:\n-\tvcm_alloc_free_blocks(memtype, alloc_head);\n-\treturn 0;\n-}\n-EXPORT_SYMBOL(vcm_alloc_max_munch);\ndiff --git a/arch/arm/mm/vcm_mm.c b/arch/arm/mm/vcm_mm.c\ndeleted file mode 100644\nindex 2642390..0000000\n--- a/arch/arm/mm/vcm_mm.c\n+++ /dev/null\n@@ -1,253 +0,0 @@\n-/* Copyright (c) 2010, The Linux Foundation. All rights reserved.\n- *\n- * This program is free software; you can redistribute it and/or modify\n- * it under the terms of the GNU General Public License version 2 and\n- * only version 2 as published by the Free Software Foundation.\n- *\n- * This program is distributed in the hope that it will be useful,\n- * but WITHOUT ANY WARRANTY; without even the implied warranty of\n- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n- * GNU General Public License for more details.\n- */\n-\n-/* Architecture-specific VCM functions */\n-\n-#include <linux/kernel.h>\n-#include <linux/vcm_mm.h>\n-\n-#include <asm/pgtable-hwdef.h>\n-#include <asm/tlbflush.h>\n-\n-#define MRC(reg, processor, op1, crn, crm, op2)\t\t\t\t\\\n-__asm__ __volatile__ (\t\t\t\t\t\t\t\\\n-\"   mrc   \"   #processor \",\" #op1 \", %0,\"  #crn \",\" #crm \",\" #op2 \" \\n\" \\\n-: \"=r\" (reg))\n-\n-#define RCP15_PRRR(reg)\t\tMRC(reg, p15, 0, c10, c2, 0)\n-#define RCP15_NMRR(reg) \tMRC(reg, p15, 0, c10, c2, 1)\n-\n-\n-/* Local type attributes (not the same as VCM) */\n-#define ARM_MT_NORMAL\t\t2\n-#define ARM_MT_STRONGLYORDERED\t0\n-#define ARM_MT_DEVICE\t\t1\n-\n-#define ARM_CP_NONCACHED\t0\n-#define ARM_CP_WB_WA\t\t1\n-#define ARM_CP_WB_NWA\t\t3\n-#define ARM_CP_WT_NWA\t\t2\n-\n-#define smmu_err(a, ...)\t\t\t\t\t\t\\\n-\tpr_err(\"ERROR %s %i \" a, __func__, __LINE__, ##__VA_ARGS__)\n-\n-#define FL_OFFSET(va)\t(((va) & 0xFFF00000) >> 20)\n-#define SL_OFFSET(va)\t(((va) & 0xFF000) >> 12)\n-\n-int vcm_driver_tex_class[4];\n-\n-static int find_tex_class(int icp, int ocp, int mt, int nos)\n-{\n-\tint i = 0;\n-\tunsigned int prrr = 0;\n-\tunsigned int nmrr = 0;\n-\tint c_icp, c_ocp, c_mt, c_nos;\n-\n-\tRCP15_PRRR(prrr);\n-\tRCP15_NMRR(nmrr);\n-\n-\t/* There are only 8 classes on this architecture */\n-\t/* If they add more classes, registers will VASTLY change */\n-\tfor (i = 0; i < 8; i++)\t{\n-\t\tc_nos = prrr & (1 << (i + 24)) ? 1 : 0;\n-\t\tc_mt = (prrr & (3 << (i * 2))) >> (i * 2);\n-\t\tc_icp = (nmrr & (3 << (i * 2))) >> (i * 2);\n-\t\tc_ocp = (nmrr & (3 << (i * 2 + 16))) >> (i * 2 + 16);\n-\n-\t\tif (icp == c_icp && ocp == c_ocp && c_mt == mt && c_nos == nos)\n-\t\t\treturn i;\n-\t}\n-\tsmmu_err(\"Could not find TEX class for ICP=%d, OCP=%d, MT=%d, NOS=%d\\n\",\n-\t\t icp, ocp, mt, nos);\n-\n-\t/* In reality, we may want to remove this panic. Some classes just */\n-\t/* will not be available, and will fail in smmu_set_attr */\n-\tpanic(\"SMMU: Could not determine TEX attribute mapping.\\n\");\n-\treturn -1;\n-}\n-\n-\n-int vcm_setup_tex_classes(void)\n-{\n-\tunsigned int cpu_prrr;\n-\tunsigned int cpu_nmrr;\n-\n-\tif (!(get_cr() & CR_TRE))\t/* No TRE? */\n-\t\tpanic(\"TEX remap not enabled, but the SMMU driver needs it!\\n\");\n-\n-\tRCP15_PRRR(cpu_prrr);\n-\tRCP15_NMRR(cpu_nmrr);\n-\n-\tvcm_driver_tex_class[VCM_DEV_ATTR_NONCACHED] =\n-\t\tfind_tex_class(ARM_CP_NONCACHED, ARM_CP_NONCACHED,\n-\t\t\t       ARM_MT_NORMAL, 1);\n-\n-\tvcm_driver_tex_class[VCM_DEV_ATTR_CACHED_WB_WA] =\n-\t\tfind_tex_class(ARM_CP_WB_WA, ARM_CP_WB_WA,\n-\t\t\t       ARM_MT_NORMAL, 1);\n-\n-\tvcm_driver_tex_class[VCM_DEV_ATTR_CACHED_WB_NWA] =\n-\t\tfind_tex_class(ARM_CP_WB_NWA, ARM_CP_WB_NWA,\n-\t\t\t       ARM_MT_NORMAL, 1);\n-\n-\tvcm_driver_tex_class[VCM_DEV_ATTR_CACHED_WT] =\n-\t\tfind_tex_class(ARM_CP_WT_NWA, ARM_CP_WT_NWA,\n-\t\t\t       ARM_MT_NORMAL, 1);\n-#ifdef DEBUG_TEX\n-\tprintk(KERN_INFO \"VCM driver debug: Using TEX classes: %d %d %d %d\\n\",\n-\t       vcm_driver_tex_class[VCM_DEV_ATTR_NONCACHED],\n-\t       vcm_driver_tex_class[VCM_DEV_ATTR_CACHED_WB_WA],\n-\t       vcm_driver_tex_class[VCM_DEV_ATTR_CACHED_WB_NWA],\n-\t       vcm_driver_tex_class[VCM_DEV_ATTR_CACHED_WT]);\n-#endif\n-\treturn 0;\n-}\n-\n-\n-int set_arm7_pte_attr(unsigned long pt_base, unsigned long va,\n-\t\t\t\t\tunsigned long len, unsigned int attr)\n-{\n-\tunsigned long *fl_table = NULL;\n-\tunsigned long *fl_pte = NULL;\n-\tunsigned long fl_offset = 0;\n-\tunsigned long *sl_table = NULL;\n-\tunsigned long *sl_pte = NULL;\n-\tunsigned long sl_offset = 0;\n-\tint i;\n-\tint sh = 0;\n-\tint class = 0;\n-\n-\t/* Alignment */\n-\tif (va & (len-1)) {\n-\t\tsmmu_err(\"misaligned va: %p\\n\", (void *) va);\n-\t\tgoto fail;\n-\t}\n-\tif (attr > 7) {\n-\t\tsmmu_err(\"bad attribute: %d\\n\", attr);\n-\t\tgoto fail;\n-\t}\n-\n-\tsh = (attr & VCM_DEV_ATTR_SH) ? 1 : 0;\n-\tclass = vcm_driver_tex_class[attr & 0x03];\n-\n-\tif (class > 7 || class < 0) {\t/* Bad class */\n-\t\tsmmu_err(\"bad tex class: %d\\n\", class);\n-\t\tgoto fail;\n-\t}\n-\n-\tif (len != SZ_16M && len != SZ_1M &&\n-\t    len != SZ_64K && len != SZ_4K) {\n-\t\tsmmu_err(\"bad size: %lu\\n\", len);\n-\t\tgoto fail;\n-\t}\n-\n-\tfl_table = (unsigned long *) pt_base;\n-\n-\tif (!fl_table) {\n-\t\tsmmu_err(\"null page table\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tfl_offset = FL_OFFSET(va);\t/* Upper 12 bits */\n-\tfl_pte = fl_table + fl_offset;\t/* int pointers, 4 bytes */\n-\n-\tif (*fl_pte == 0) {\t/* Nothing there! */\n-\t\tsmmu_err(\"first level pte is 0\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\t/* Supersection attributes */\n-\tif (len == SZ_16M) {\n-\t\tfor (i = 0; i < 16; i++) {\n-\t\t\t/* Clear the old bits */\n-\t\t\t*(fl_pte+i) &= ~(PMD_SECT_S | PMD_SECT_CACHEABLE |\n-\t\t\t\t\t PMD_SECT_BUFFERABLE | PMD_SECT_TEX(1));\n-\n-\t\t\t/* Assign new class and S bit */\n-\t\t\t*(fl_pte+i) |= sh ? PMD_SECT_S : 0;\n-\t\t\t*(fl_pte+i) |= class & 0x01 ? PMD_SECT_BUFFERABLE : 0;\n-\t\t\t*(fl_pte+i) |= class & 0x02 ? PMD_SECT_CACHEABLE : 0;\n-\t\t\t*(fl_pte+i) |= class & 0x04 ? PMD_SECT_TEX(1) : 0;\n-\t\t}\n-\t} else\tif (len == SZ_1M) {\n-\n-\t\t/* Clear the old bits */\n-\t\t*(fl_pte) &= ~(PMD_SECT_S | PMD_SECT_CACHEABLE |\n-\t\t\t       PMD_SECT_BUFFERABLE | PMD_SECT_TEX(1));\n-\n-\t\t/* Assign new class and S bit */\n-\t\t*(fl_pte) |= sh ? PMD_SECT_S : 0;\n-\t\t*(fl_pte) |= class & 0x01 ? PMD_SECT_BUFFERABLE : 0;\n-\t\t*(fl_pte) |= class & 0x02 ? PMD_SECT_CACHEABLE : 0;\n-\t\t*(fl_pte) |= class & 0x04 ? PMD_SECT_TEX(1) : 0;\n-\t}\n-\n-\tsl_table = (unsigned long *) __va(((*fl_pte) & 0xFFFFFC00));\n-\tsl_offset = SL_OFFSET(va);\n-\tsl_pte = sl_table + sl_offset;\n-\n-\tif (len == SZ_64K) {\n-\t\tfor (i = 0; i < 16; i++) {\n-\t\t\t/* Clear the old bits */\n-\t\t\t*(sl_pte+i) &= ~(PTE_EXT_SHARED | PTE_CACHEABLE |\n-\t\t\t\t\t PTE_BUFFERABLE | PTE_EXT_TEX(1));\n-\n-\t\t\t/* Assign new class and S bit */\n-\t\t\t*(sl_pte+i) |= sh ? PTE_EXT_SHARED : 0;\n-\t\t\t*(sl_pte+i) |= class & 0x01 ? PTE_BUFFERABLE : 0;\n-\t\t\t*(sl_pte+i) |= class & 0x02 ? PTE_CACHEABLE : 0;\n-\t\t\t*(sl_pte+i) |= class & 0x04 ? PTE_EXT_TEX(1) : 0;\n-\t\t}\n-\t} else \tif (len == SZ_4K) {\n-\t\t/* Clear the old bits */\n-\t\t*(sl_pte) &= ~(PTE_EXT_SHARED | PTE_CACHEABLE |\n-\t\t\t       PTE_BUFFERABLE | PTE_EXT_TEX(1));\n-\n-\t\t/* Assign new class and S bit */\n-\t\t*(sl_pte) |= sh ? PTE_EXT_SHARED : 0;\n-\t\t*(sl_pte) |= class & 0x01 ? PTE_BUFFERABLE : 0;\n-\t\t*(sl_pte) |= class & 0x02 ? PTE_CACHEABLE : 0;\n-\t\t*(sl_pte) |= class & 0x04 ? PTE_EXT_TEX(1) : 0;\n-\t}\n-\n-\n-\tmb();\n-\treturn 0;\n-fail:\n-\treturn 1;\n-}\n-\n-\n-int cpu_set_attr(unsigned long va, unsigned long len, unsigned int attr)\n-{\n-\tint ret;\n-\tpgd_t *pgd = init_mm.pgd;\n-\n-\tif (!pgd) {\n-\t\tsmmu_err(\"null pgd\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tret = set_arm7_pte_attr((unsigned long)pgd, va, len, attr);\n-\n-\tif (ret != 0) {\n-\t\tsmmu_err(\"could not set attribute: \\\n-\t\t\t\t\tpgd=%p, va=%p, len=%lu, attr=%d\\n\",\n-\t\t\t (void *) pgd, (void *) va, len, attr);\n-\t\tgoto fail;\n-\t}\n-\tdmb();\n-\tflush_tlb_all();\n-\treturn 0;\n-fail:\n-\treturn -1;\n-}\ndiff --git a/include/linux/vcm.h b/include/linux/vcm.h\ndeleted file mode 100644\nindex 3ea8c88..0000000\n--- a/include/linux/vcm.h\n+++ /dev/null\n@@ -1,652 +0,0 @@\n-/* Copyright (c) 2010, The Linux Foundation. All rights reserved.\n- *\n- * This program is free software; you can redistribute it and/or modify\n- * it under the terms of the GNU General Public License version 2 and\n- * only version 2 as published by the Free Software Foundation.\n- *\n- * This program is distributed in the hope that it will be useful,\n- * but WITHOUT ANY WARRANTY; without even the implied warranty of\n- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n- * GNU General Public License for more details.\n- *\n- */\n-\n-#ifndef _VCM_H_\n-#define _VCM_H_\n-\n-/* All undefined types must be defined using platform specific headers */\n-\n-#include <linux/vcm_types.h>\n-\n-/*\n- * Virtual contiguous memory (VCM) region primitives.\n- *\n- * Current memory mapping software uses a CPU centric management\n- * model. This makes sense in general, average hardware only contains an\n- * CPU MMU and possibly a graphics MMU. If every device in the system\n- * has one or more MMUs a CPU centric MM programming model breaks down.\n- *\n- * Looking at mapping from a system-wide perspective reveals a general\n- * graph problem. Each node that talks to memory, either through an MMU\n- * or directly (via physical memory) can be thought of as the device end\n- * of a mapping edge. The other edge is the physical memory that is\n- * mapped.\n- *\n- * In the direct mapped case, it is useful to give the device an\n- * MMU. This one-to-one MMU allows direct mapped devices to\n- * participate in graph management, they simply see memory through a\n- * one-to-one mapping.\n- *\n- * The CPU nodes can also be brought under the same mapping\n- * abstraction with the use of a light overlay on the existing\n- * VMM. This light overlay brings the VMM's page table abstraction for\n- * each process and the kernel into the graph management API.\n- *\n- * Taken together this system wide approach provides a capability that\n- * is greater than the sum of its parts by allowing users to reason\n- * about system wide mapping issues without getting bogged down in CPU\n- * centric device page table management issues.\n- */\n-\n-\n-/*\n- * Creating, freeing and managing VCMs.\n- *\n- * A VCM region is a virtual space that can be reserved from and\n- * associated with one or more devices. At creation the user can\n- * specify an offset to start addresses and a length of the entire VCM\n- * region. Reservations out of a VCM region are always contiguous.\n- */\n-\n-/**\n- * vcm_create() - Create a VCM region\n- * @start_addr:\t\tThe starting address of the VCM region.\n- * @len:\t\tThe len of the VCM region. This must be at least\n- *\t\t\tvcm_get_min_page_size() bytes.\n- *\n- * A VCM typically abstracts a page table.\n- *\n- * All functions in this API are passed and return opaque things\n- * because the underlying implementations will vary. The goal\n- * is really graph management. vcm_create() creates the \"device end\"\n- * of an edge in the mapping graph.\n- *\n- * The return value is non-zero if a VCM has successfully been\n- * created. It will return zero if a VCM region cannot be created or\n- * len is invalid.\n- */\n-struct vcm *vcm_create(unsigned long start_addr, size_t len);\n-\n-\n-/**\n- * vcm_create_from_prebuilt() - Create a VCM region from an existing region\n- * @ext_vcm_id:\t\tAn external opaque value that allows the\n- *\t\t\timplementation to reference an already built table.\n- *\n- * The ext_vcm_id will probably reference a page table that's been built\n- * by the VM.\n- *\n- * The platform specific implementation will provide this.\n- *\n- * The return value is non-zero if a VCM has successfully been created.\n- */\n-struct vcm *vcm_create_from_prebuilt(size_t ext_vcm_id);\n-\n-\n-/**\n- * vcm_clone() - Clone a VCM\n- * @vcm:\t\tA VCM to clone from.\n- *\n- * Perform a VCM \"deep copy.\" The resulting VCM will match the original at\n- * the point of cloning. Subsequent updates to either VCM will only be\n- * seen by that VCM.\n- *\n- * The return value is non-zero if a VCM has been successfully cloned.\n- */\n-struct vcm *vcm_clone(struct vcm *vcm);\n-\n-\n-/**\n- * vcm_get_start_addr() - Get the starting address of the VCM region.\n- * @vcm:\t\tThe VCM we're interested in getting the starting\n- *\t\t\taddress of.\n- *\n- * The return value will be 1 if an error has occurred.\n- */\n-size_t vcm_get_start_addr(struct vcm *vcm);\n-\n-\n-/**\n- * vcm_get_len() - Get the length of the VCM region.\n- * @vcm:\t\tThe VCM we're interested in reading the length from.\n- *\n- * The return value will be non-zero for a valid VCM. VCM regions\n- * cannot have 0 len.\n- */\n-size_t vcm_get_len(struct vcm *vcm);\n-\n-\n-/**\n- * vcm_free() - Free a VCM.\n- * @vcm:\t\tThe VCM we're interested in freeing.\n- *\n- * The return value is 0 if the VCM has been freed or:\n- * -EBUSY\t\tThe VCM region contains reservations or has been\n- *\t\t\tassociated (active or not) and cannot be freed.\n- * -EINVAL\t\tThe vcm argument is invalid.\n- */\n-int vcm_free(struct vcm *vcm);\n-\n-\n-/*\n- * Creating, freeing and managing reservations out of a VCM.\n- *\n- */\n-\n-/**\n- * vcm_reserve() - Create a reservation from a VCM region.\n- * @vcm:\t\tThe VCM region to reserve from.\n- * @len:\t\tThe length of the reservation. Must be at least\n- *\t\t\tvcm_get_min_page_size() bytes.\n- * @attr:\t\tSee 'Reservation Attributes'.\n- *\n- * A reservation, res_t, is a contiguous range from a VCM region.\n- *\n- * The return value is non-zero if a reservation has been successfully\n- * created. It is 0 if any of the parameters are invalid.\n- */\n-struct res *vcm_reserve(struct vcm *vcm, size_t len, u32 attr);\n-\n-\n-/**\n- * vcm_reserve_at() - Make a reservation at a given logical location.\n- * @memtarget:\t\tA logical location to start the reservation from.\n- * @vcm:\t\tThe VCM region to start the reservation from.\n- * @len:\t\tThe length of the reservation.\n- * @attr:\t\tSee 'Reservation Attributes'.\n- *\n- * The return value is non-zero if a reservation has been successfully\n- * created.\n- */\n-struct res *vcm_reserve_at(enum memtarget_t memtarget, struct vcm *vcm,\n-\t\t\t   size_t len, u32 attr);\n-\n-\n-/**\n- * vcm_get_vcm_from_res() - Return the VCM region of a reservation.\n- * @res:\t\tThe reservation to return the VCM region of.\n- *\n- * Te return value will be non-zero if the reservation is valid. A valid\n- * reservation is always associated with a VCM region; there is no such\n- * thing as an orphan reservation.\n- */\n-struct vcm *vcm_get_vcm_from_res(struct res *res);\n-\n-\n-/**\n- * vcm_unreserve() - Unreserve the reservation.\n- * @res:\t\tThe reservation to unreserve.\n- *\n- * The return value will be 0 if the reservation was successfully\n- * unreserved and:\n- * -EBUSY\t\tThe reservation is still backed,\n- * -EINVAL\t\tThe vcm argument is invalid.\n- */\n-int vcm_unreserve(struct res *res);\n-\n-\n-/**\n- * vcm_set_res_attr() - Set attributes of an existing reservation.\n- * @res:\t\tAn existing reservation of interest.\n- * @attr:\t\tSee 'Reservation Attributes'.\n- *\n- * This function can only be used on an existing reservation; there\n- * are no orphan reservations. All attributes can be set on a existing\n- * reservation.\n- *\n- * The return value will be 0 for a success, otherwise it will be:\n- * -EINVAL\t\tres or attr are invalid.\n- */\n-int vcm_set_res_attr(struct res *res, u32 attr);\n-\n-\n-/**\n- * vcm_get_num_res() - Return the number of reservations in a VCM region.\n- * @vcm:\t\tThe VCM region of interest.\n- */\n-size_t vcm_get_num_res(struct vcm *vcm);\n-\n-\n-/**\n- * vcm_get_next_res() - Read each reservation one at a time.\n- * @vcm:\t\tThe VCM region of interest.\n- * @res:\t\tContains the last reservation.…","distinct":true,"url":"https://api.github.com/repos/robcore/Hulk-Kernel-V2/commits/cc5166fb556fd2e2778cf5432a7a3606fa91c952"}]}
{"actor":{"display_login":"robcore"}}