summaryrefslogtreecommitdiff
path: root/security
diff options
context:
space:
mode:
authorChris Johnson <cwj@nvidia.com>2013-07-23 11:20:34 -0700
committerDan Willemsen <dwillemsen@nvidia.com>2013-09-14 13:34:25 -0700
commit4a4c2c0e76d273003c0f308664fc5b8689d078fc (patch)
treea7280bfa78ac3644ac3d6b76e406181d55601b43 /security
parentf66557b7567de9011bbe0416e6e7a9adf2dba0bf (diff)
tlk_driver: use dma_alloc_coherent for uncached mem
Instead of relying on change page attribute calls, instead use DMA routines to get uncached mem. This will go away in the near future when we can map these buffers directly in the kernel. Change-Id: I6a375f2b1b09f987deae8a61e0907209b90c870e Signed-off-by: Chris Johnson <cwj@nvidia.com> Reviewed-on: http://git-master/r/252523 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Aaron Gamble <jgamble@nvidia.com> Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com> Tested-by: Aaron Gamble <jgamble@nvidia.com>
Diffstat (limited to 'security')
-rw-r--r--security/tlk_driver/ote_device.c29
-rw-r--r--security/tlk_driver/ote_protocol.h7
2 files changed, 18 insertions, 18 deletions
diff --git a/security/tlk_driver/ote_device.c b/security/tlk_driver/ote_device.c
index 44d8a09971d0..5c5447b89a51 100644
--- a/security/tlk_driver/ote_device.c
+++ b/security/tlk_driver/ote_device.c
@@ -28,6 +28,7 @@
#include <asm/cacheflush.h>
#include <asm/outercache.h>
#include <linux/list.h>
+#include <linux/dma-mapping.h>
#include "ote_protocol.h"
@@ -55,22 +56,19 @@ u32 notrace tegra_read_cycle(void)
static int te_create_free_cmd_list(struct tlk_device *dev)
{
- struct page *te_cmd_pages;
- int cmd_desc_count = 0, ret = 0;
+ int cmd_desc_count, ret = 0;
struct te_cmd_req_desc *req_desc;
int bitmap_size;
- te_cmd_pages = alloc_pages(GFP_KERNEL, get_count_order(2));
- if (!te_cmd_pages) {
+ dev->req_addr = dma_alloc_coherent(NULL, PAGE_SIZE,
+ &dev->req_addr_phys, GFP_KERNEL);
+ dev->param_addr = dma_alloc_coherent(NULL, PAGE_SIZE,
+ &dev->param_addr_phys, GFP_KERNEL);
+ if ((dev->req_addr == NULL) || (dev->param_addr == NULL)) {
ret = -ENOMEM;
goto error;
}
- /* first 4KB page is request freelist, second is param freelist */
- dev->req_addr = (unsigned long) page_address(te_cmd_pages);
- dev->param_addr = (struct te_oper_param *)(dev->req_addr + PAGE_SIZE);
- set_memory_uc(dev->req_addr, 2);
-
/* alloc param bitmap allocator */
bitmap_size = BITS_TO_LONGS(TE_PARAM_MAX) * sizeof(long);
dev->param_bitmap = kzalloc(bitmap_size, GFP_KERNEL);
@@ -84,8 +82,7 @@ static int te_create_free_cmd_list(struct tlk_device *dev)
ret = -ENOMEM;
goto error;
}
- req_desc->req_addr = dev->req_addr +
- sizeof(struct te_request) * cmd_desc_count;
+ req_desc->req_addr = dev->req_addr + cmd_desc_count;
INIT_LIST_HEAD(&(req_desc->list));
/* Add the cmd param descriptor to free list */
@@ -162,7 +159,7 @@ static void __attribute__((unused)) te_print_cmd_list(
if (!(list_empty(&(dev->free_cmd_list)))) {
list_for_each_entry(param_desc, &(dev->free_cmd_list),
list)
- pr_info("Phys addr for cmd req desc (%lx)\n",
+ pr_info("Phys addr for cmd req desc (%p)\n",
param_desc->req_addr);
}
} else {
@@ -170,7 +167,7 @@ static void __attribute__((unused)) te_print_cmd_list(
if (!(list_empty(&(dev->used_cmd_list)))) {
list_for_each_entry(param_desc, &(dev->used_cmd_list),
list)
- pr_info("Phys addr for cmd req desc (%lx)\n",
+ pr_info("Phys addr for cmd req desc (%p)\n",
param_desc->req_addr);
}
}
@@ -301,7 +298,7 @@ static long te_handle_trustedapp_ioctl(struct file *file,
goto error;
}
- request = (struct te_request *)cmd_desc->req_addr;
+ request = cmd_desc->req_addr;
memset(request, 0, sizeof(struct te_request));
request->params = params;
@@ -330,7 +327,7 @@ static long te_handle_trustedapp_ioctl(struct file *file,
goto error;
}
- request = (struct te_request *)cmd_desc->req_addr;
+ request = cmd_desc->req_addr;
memset(request, 0, sizeof(struct te_request));
/* close session cannot fail */
@@ -352,7 +349,7 @@ static long te_handle_trustedapp_ioctl(struct file *file,
goto error;
}
- request = (struct te_request *)cmd_desc->req_addr;
+ request = cmd_desc->req_addr;
memset(request, 0, sizeof(struct te_request));
request->params = params;
diff --git a/security/tlk_driver/ote_protocol.h b/security/tlk_driver/ote_protocol.h
index 79224e1c3669..531406e8b3fb 100644
--- a/security/tlk_driver/ote_protocol.h
+++ b/security/tlk_driver/ote_protocol.h
@@ -45,8 +45,11 @@ extern uint32_t tlk_extended_smc(uint32_t *args);
extern void tlk_irq_handler(void);
struct tlk_device {
- unsigned long req_addr;
+ struct te_request *req_addr;
+ dma_addr_t req_addr_phys;
struct te_oper_param *param_addr;
+ dma_addr_t param_addr_phys;
+
unsigned long *param_bitmap;
struct list_head used_cmd_list;
@@ -54,7 +57,7 @@ struct tlk_device {
};
struct te_cmd_req_desc {
- unsigned long req_addr;
+ struct te_request *req_addr;
struct list_head list;
};