aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2010-12-08 10:57:30 +0000
committerAlan Cox <alan@linux.intel.com>2010-12-08 10:57:30 +0000
commit2b14a66cc1559e49b6f968a19c0ece579a07107a (patch)
treebe3fd1d34f937ef82a7f43db3cc28e635c72fee1
parent554dcfc13529cafedfb1adb1e99892ae2da4c6ce (diff)
downloadmrst-s0i3-test-2b14a66cc1559e49b6f968a19c0ece579a07107a.tar.gz
mrst-s0i3-test-2b14a66cc1559e49b6f968a19c0ece579a07107a.tar.xz
mrst-s0i3-test-2b14a66cc1559e49b6f968a19c0ece579a07107a.zip
sep: second ioctl pass
We can now kill off the various unused ioctls and make the ones we have left 32/64bit size safe. Most of this is just some types and then doing re-ordering of fields to pack better. For the init message I've moved the 14 words of message into the struct which makes the code far simpler. The big chunks of code changes are from removing is_kva, this is now always true which in turn means lots of code becomes unreachable and shakes out. Signed-off-by: Alan Cox <alan@linux.intel.com>
-rw-r--r--drivers/staging/sep/sep_driver.c554
-rw-r--r--drivers/staging/sep/sep_driver_api.h93
2 files changed, 121 insertions, 526 deletions
diff --git a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c
index 01fea026908..15b3837ec0e 100644
--- a/drivers/staging/sep/sep_driver.c
+++ b/drivers/staging/sep/sep_driver.c
@@ -279,8 +279,6 @@ static int sep_singleton_open(struct inode *inode_ptr, struct file *file_ptr)
dev_dbg(&sep->pdev->dev, "calling test and set for singleton 0\n");
if (test_and_set_bit(0, &sep->singleton_access_flag)) {
- dev_warn(&sep->pdev->dev,
- "sep singleton is not available for open; busy\n");
error = -EBUSY;
goto end_function;
}
@@ -374,8 +372,6 @@ static int sep_request_daemon_open(struct inode *inode, struct file *filp)
/* There is supposed to be only one request daemon */
dev_dbg(&sep->pdev->dev, "calling test and set for req_dmon open 0\n");
if (test_and_set_bit(0, &sep->request_daemon_open)) {
- dev_warn(&sep->pdev->dev,
- "request daemon is not available for open; busy\n");
error = -EBUSY;
goto end_function;
}
@@ -578,9 +574,7 @@ static int sep_request_daemon_mmap(struct file *filp,
/* check that the size of the mapped range is as the size of the message
shared area */
if ((vma->vm_end - vma->vm_start) > SEP_DRIVER_MMMAP_AREA_SIZE) {
- dev_warn(&sep->pdev->dev,
- "mmap requested more than allowed\n");
- error = -EAGAIN;
+ error = -EINVAL;
goto end_function;
}
@@ -762,13 +756,7 @@ static int sep_mmap(struct file *filp, struct vm_area_struct *vma)
/* check that the size of the mapped range is as the size of the message
shared area */
if ((vma->vm_end - vma->vm_start) > SEP_DRIVER_MMMAP_AREA_SIZE) {
- dev_warn(&sep->pdev->dev,
- "mmap requested size is more than allowed\n");
- dev_warn(&sep->pdev->dev,
- "vma->vm_end is %08lx\n", vma->vm_end);
- dev_warn(&sep->pdev->dev,
- "vma->vm_end is %08lx\n", vma->vm_start);
- error = -EAGAIN;
+ error = -EINVAL;
goto end_function_with_error;
}
@@ -784,7 +772,7 @@ static int sep_mmap(struct file *filp, struct vm_area_struct *vma)
if (remap_pfn_range(vma, vma->vm_start, bus_addr >> PAGE_SHIFT,
vma->vm_end - vma->vm_start, vma->vm_page_prot)) {
dev_warn(&sep->pdev->dev,
- "SEP Driver remap_page_range failed\n");
+ "remap_page_range failed\n");
error = -EAGAIN;
goto end_function_with_error;
}
@@ -1029,13 +1017,9 @@ static int sep_init_caller_id(struct sep_device *sep)
*/
static int sep_set_caller_id_handler(struct sep_device *sep, u32 arg)
{
- /* error */
+ void __user *hash;
int error;
-
- /* counter */
int i;
-
- /* command arguments */
struct caller_id_struct command_args;
dev_dbg(&sep->pdev->dev,
@@ -1049,61 +1033,48 @@ static int sep_set_caller_id_handler(struct sep_device *sep, u32 arg)
}
if (i == SEP_CALLER_ID_TABLE_NUM_ENTRIES) {
-
dev_warn(&sep->pdev->dev,
"no more caller id entries left\n");
dev_warn(&sep->pdev->dev,
"maximum number is %d\n",
SEP_CALLER_ID_TABLE_NUM_ENTRIES);
- error = -ENOMEM;
+ error = -EUSERS;
goto end_function;
}
/* copy the data */
if (copy_from_user(&command_args, (void __user *)arg,
sizeof(command_args))) {
- dev_warn(&sep->pdev->dev,
- "copy_from_user failed\n");
error = -EFAULT;
goto end_function;
}
- if (!command_args.pid || !command_args.callerIdAddress ||
- !command_args.callerIdSizeInBytes) {
- dev_warn(&sep->pdev->dev,
- "params validation error\n");
+ hash = (void __user *)(unsigned long)command_args.callerIdAddress;
+
+ if (!command_args.pid || !command_args.callerIdSizeInBytes) {
error = -EINVAL;
goto end_function;
}
- dev_dbg(&sep->pdev->dev,
- "pid is %x\n", command_args.pid);
- dev_dbg(&sep->pdev->dev,
- "callerIdSizeInBytes is %x\n",
+ dev_dbg(&sep->pdev->dev, "pid is %x\n", command_args.pid);
+ dev_dbg(&sep->pdev->dev, "callerIdSizeInBytes is %x\n",
command_args.callerIdSizeInBytes);
if (command_args.callerIdSizeInBytes >
- SEP_CALLER_ID_HASH_SIZE_IN_BYTES) {
- dev_warn(&sep->pdev->dev,
- "callerIdSizeInBytes too big\n");
- error = -EINVAL;
+ SEP_CALLER_ID_HASH_SIZE_IN_BYTES) {
+ error = -EMSGSIZE;
goto end_function;
}
sep->caller_id_table[i].pid = command_args.pid;
if (copy_from_user(sep->caller_id_table[i].callerIdHash,
- command_args.callerIdAddress, command_args.callerIdSizeInBytes))
- dev_warn(&sep->pdev->dev,
- "copy_from_user for callerIdAddress failed\n");
+ hash, command_args.callerIdSizeInBytes))
error = -EFAULT;
-
end_function:
-
dev_dbg(&sep->pdev->dev,
"sep_set_caller_id_handler end\n");
-
return error;
}
@@ -1161,10 +1132,7 @@ static int sep_send_command_handler(struct sep_device *sep)
dev_dbg(&sep->pdev->dev, "calling test and set for "
" in_use_flags SEP_SEND_MSG_LOCK_BIT 0\n");
if (test_and_set_bit(SEP_SEND_MSG_LOCK_BIT, &sep->in_use_flags)) {
-
- dev_warn(&sep->pdev->dev,
- "cannot send msg while awaiting reply\n");
- error = -EBUSY;
+ error = -EPROTO;
goto end_function;
}
@@ -1188,9 +1156,7 @@ static int sep_send_command_handler(struct sep_device *sep)
sep_write_reg(sep, HW_HOST_HOST_SEP_GPR0_REG_ADDR, 0x2);
end_function:
-
dev_dbg(&sep->pdev->dev, "sep_send_command_handler end\n");
-
return error;
}
@@ -1215,20 +1181,15 @@ static int sep_allocate_data_pool_memory_handler(struct sep_device *sep,
dev_dbg(&sep->pdev->dev,
"sep_allocate_data_pool_memory_handler start\n");
- error = copy_from_user(&command_args, (void __user *)arg,
- sizeof(struct alloc_struct));
- if (error) {
- dev_warn(&sep->pdev->dev,
- "allocate data pool copy from user error\n");
+ if (copy_from_user(&command_args, (void __user *)arg,
+ sizeof(struct alloc_struct))) {
+ error = -EFAULT;
goto end_function;
}
/* allocate memory */
if ((sep->data_pool_bytes_allocated + command_args.num_bytes) >
SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES) {
-
- dev_warn(&sep->pdev->dev,
- "no more data pool bytes available\n");
error = -ENOMEM;
goto end_function;
}
@@ -1290,102 +1251,6 @@ end_function:
}
/**
- * This function locks all the physical pages of the kernel virtual buffer
- * and construct a basic lli array, where each entry holds the physical
- * page address and the size that application data holds in this page
- * @sep: pointer to struct sep_device
- * @kernel_virt_addr: address of data buffer in kernel
- * @data_size: size of data
- * @lli_array_ptr: lli array
- * @in_out_flag: input into device or output from device
- */
-static int sep_lock_kernel_pages(struct sep_device *sep,
- u32 kernel_virt_addr,
- u32 data_size,
- struct sep_lli_entry **lli_array_ptr,
- int in_out_flag)
-
-{
- /* error */
- int error = 0;
-
- /* array of lli */
- struct sep_lli_entry *lli_array;
-
- /* map array */
- struct sep_dma_map *map_array;
-
- dev_dbg(&sep->pdev->dev,
- "sep_lock_kernel_pages start\n");
-
- dev_dbg(&sep->pdev->dev,
- "kernel_virt_addr is %08x\n", kernel_virt_addr);
- dev_dbg(&sep->pdev->dev,
- "data_size is %x\n", data_size);
-
- lli_array = kmalloc(sizeof(struct sep_lli_entry), GFP_ATOMIC);
- if (!lli_array) {
-
- dev_warn(&sep->pdev->dev, "kmalloc for lli_array failed\n");
- error = -ENOMEM;
- goto end_function;
- }
-
- map_array = kmalloc(sizeof(struct sep_dma_map), GFP_ATOMIC);
- if (!map_array) {
- dev_warn(&sep->pdev->dev, "kmalloc for map_array failed\n");
- error = -ENOMEM;
- goto end_function_with_error;
- }
-
- map_array[0].dma_addr =
- dma_map_single(&sep->pdev->dev, (void *)kernel_virt_addr,
- data_size, DMA_BIDIRECTIONAL);
- map_array[0].size = data_size;
-
-
- /* set the start address of the first page - app data may start not at
- the beginning of the page */
- lli_array[0].bus_address = (u32)map_array[0].dma_addr;
- lli_array[0].block_size = map_array[0].size;
-
- /* debug print */
- dev_dbg(&sep->pdev->dev,
- "lli_array[0].bus_address is %08lx,"
- " lli_array[0].block_size is %x\n",
- (unsigned long)lli_array[0].bus_address,
- lli_array[0].block_size);
-
- /* set the output parameters */
- if (in_out_flag == SEP_DRIVER_IN_FLAG) {
- *lli_array_ptr = lli_array;
- sep->dma_res_arr[sep->nr_dcb_creat].in_num_pages = 1;
- sep->dma_res_arr[sep->nr_dcb_creat].in_page_array = 0;
- sep->dma_res_arr[sep->nr_dcb_creat].in_map_array = map_array;
- sep->dma_res_arr[sep->nr_dcb_creat].in_map_num_entries = 1;
- } else {
- *lli_array_ptr = lli_array;
- sep->dma_res_arr[sep->nr_dcb_creat].out_num_pages = 1;
- sep->dma_res_arr[sep->nr_dcb_creat].out_page_array = 0;
- sep->dma_res_arr[sep->nr_dcb_creat].out_map_array = map_array;
- sep->dma_res_arr[sep->nr_dcb_creat].out_map_num_entries = 1;
- }
-
- goto end_function;
-
-end_function_with_error:
-
- kfree(lli_array);
-
-end_function:
-
- dev_dbg(&sep->pdev->dev,
- "sep_lock_kernel_pages end\n");
-
- return error;
-}
-
-/**
* This function locks all the physical pages of the application
* virtual buffer and construct a basic lli array, where each entry
* holds the physical page address and the size that application
@@ -1460,9 +1325,6 @@ static int sep_lock_user_pages(struct sep_device *sep,
/* allocate array of pages structure pointers */
page_array = kmalloc(sizeof(struct page *) * num_pages, GFP_ATOMIC);
if (!page_array) {
- dev_warn(&sep->pdev->dev,
- "kmalloc for page_array failed\n");
-
error = -ENOMEM;
goto end_function;
}
@@ -1989,8 +1851,7 @@ static void sep_prepare_empty_lli_table(struct sep_device *sep,
* @block_size:
* @lli_table_ptr:
* @num_entries_ptr:
- * @data_data_size_ptr:
- * @is_kva:
+ * @table_data_size_ptr:
*/
static int sep_prepare_input_dma_table(struct sep_device *sep,
unsigned long app_virt_addr,
@@ -1998,9 +1859,7 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
u32 block_size,
dma_addr_t *lli_table_ptr,
u32 *num_entries_ptr,
- u32 *table_data_size_ptr,
- bool is_kva)
-
+ u32 *table_data_size_ptr)
{
/* pointer to the info entry of the table - the last entry */
struct sep_lli_entry *info_entry_ptr;
@@ -2061,18 +1920,9 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
goto update_dcb_counter;
}
- /* check if the pages are in Kernel Virtual Address layout */
- if (is_kva == true)
-
- /* lock the pages of the kernel
- buffer and translate them to pages */
- error = sep_lock_kernel_pages(sep, app_virt_addr,
- data_size, &lli_array_ptr, SEP_DRIVER_IN_FLAG);
- else
-
- /* lock the pages of the user buffer
- and translate them to pages */
- error = sep_lock_user_pages(sep, app_virt_addr,
+ /* lock the pages of the user buffer
+ and translate them to pages */
+ error = sep_lock_user_pages(sep, app_virt_addr,
data_size, &lli_array_ptr, SEP_DRIVER_IN_FLAG);
if (error)
@@ -2462,7 +2312,6 @@ static int sep_construct_dma_tables_from_lli(
* @in_num_entries_ptr:
* @out_num_entries_ptr:
* @table_data_size_ptr:
- * @is_kva:
*/
static int sep_prepare_input_output_dma_table(struct sep_device *sep,
unsigned long app_virt_in_addr,
@@ -2473,8 +2322,7 @@ static int sep_prepare_input_output_dma_table(struct sep_device *sep,
dma_addr_t *lli_table_out_ptr,
u32 *in_num_entries_ptr,
u32 *out_num_entries_ptr,
- u32 *table_data_size_ptr,
- bool is_kva)
+ u32 *table_data_size_ptr)
{
/* array of pointers of page */
@@ -2505,61 +2353,23 @@ static int sep_prepare_input_output_dma_table(struct sep_device *sep,
sep->dma_res_arr[sep->nr_dcb_creat].in_page_array = 0;
sep->dma_res_arr[sep->nr_dcb_creat].out_page_array = 0;
- /* check if the pages are in Kernel Virtual Address layout */
- if (is_kva == true) {
-
- /* lock the pages of the kernel buffer and
- translate them to pages */
- error = sep_lock_kernel_pages(sep, app_virt_in_addr,
- data_size, &lli_in_array, SEP_DRIVER_IN_FLAG);
-
- if (error) {
-
- dev_warn(&sep->pdev->dev,
- "sep_lock_kernel_pages for input"
- " virtual buffer failed\n");
- goto end_function;
-
- }
- }
-
- else {
-
- /* lock the pages of the user buffer and
- translate them to pages */
- error = sep_lock_user_pages(sep, app_virt_in_addr,
- data_size, &lli_in_array, SEP_DRIVER_IN_FLAG);
- if (error) {
- dev_warn(&sep->pdev->dev,
- "sep_lock_user_pages for input virtual"
- " buffer failed\n");
- goto end_function;
- }
- }
-
- if (is_kva == true) {
- error = sep_lock_kernel_pages(sep, app_virt_out_addr,
- data_size, &lli_out_array, SEP_DRIVER_OUT_FLAG);
-
- if (error) {
- dev_warn(&sep->pdev->dev,
- "sep_lock_kernel_pages \
- for output virtual buffer failed\n");
- goto end_function_free_lli_in;
- }
-
+ /* lock the pages of the user buffer and
+ translate them to pages */
+ error = sep_lock_user_pages(sep, app_virt_in_addr,
+ data_size, &lli_in_array, SEP_DRIVER_IN_FLAG);
+ if (error) {
+ dev_warn(&sep->pdev->dev,
+ "sep_lock_user_pages for input virtual buffer failed\n");
+ goto end_function;
}
- else {
- error = sep_lock_user_pages(sep, app_virt_out_addr,
- data_size, &lli_out_array, SEP_DRIVER_OUT_FLAG);
+ error = sep_lock_user_pages(sep, app_virt_out_addr,
+ data_size, &lli_out_array, SEP_DRIVER_OUT_FLAG);
- if (error) {
- dev_warn(&sep->pdev->dev,
- "sep_lock_user_pages \
- for output virtual buffer failed\n");
- goto end_function_free_lli_in;
- }
+ if (error) {
+ dev_warn(&sep->pdev->dev,
+ "sep_lock_user_pages for output virtual buffer failed\n");
+ goto end_function_free_lli_in;
}
dev_dbg(&sep->pdev->dev,
@@ -2572,7 +2382,6 @@ static int sep_prepare_input_output_dma_table(struct sep_device *sep,
"SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP is %x\n",
SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP);
-
/* call the fucntion that creates table from the lli arrays */
error = sep_construct_dma_tables_from_lli(sep, lli_in_array,
sep->dma_res_arr[sep->nr_dcb_creat].in_num_pages,
@@ -2640,7 +2449,6 @@ end_function:
* @block_size: u32; for block size
* @tail_block_size: u32; for size of tail block
* @isapplet: bool; to indicate external app
- * @is_kva: bool; to indicate kernel space
*/
static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
unsigned long app_in_address,
@@ -2648,9 +2456,7 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
u32 data_in_size,
u32 block_size,
u32 tail_block_size,
- bool isapplet,
- bool is_kva)
-
+ bool isapplet)
{
/* error */
int error = 0;
@@ -2680,10 +2486,9 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
"prepare_input_output_dma_table_in_dcb start\n");
if (sep->nr_dcb_creat == SEP_MAX_NUM_SYNC_DMA_OPS) {
-
/*No more DCBS to allocate*/
dev_warn(&sep->pdev->dev, "no more dcb's available\n");
- error = -EFAULT;
+ error = -ENOSPC;
goto end_function;
}
@@ -2711,7 +2516,7 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
dev_warn(&sep->pdev->dev,
"data in size smaller than tail"
" block size\n");
- error = -EFAULT;
+ error = -ENOSPC;
goto end_function;
}
@@ -2725,30 +2530,17 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
/* check if there is enough data for dma operation */
if (data_in_size < SEP_DRIVER_MIN_DATA_SIZE_PER_TABLE) {
-
- if (is_kva == true) {
- memcpy(dcb_table_ptr->tail_data,
- (void *)app_in_address, data_in_size);
- }
-
- else {
- if (copy_from_user(dcb_table_ptr->tail_data,
- (void *)app_in_address,
- data_in_size)) {
-
- dev_warn(&sep->pdev->dev,
- "failed to copy tail\n");
- error = -EFAULT;
- goto end_function;
- }
+ if (copy_from_user(dcb_table_ptr->tail_data,
+ (void __user *)app_in_address, data_in_size)) {
+ error = -EFAULT;
+ goto end_function;
}
dcb_table_ptr->tail_data_size = data_in_size;
/* set the output user-space address for mem2mem op */
if (app_out_address)
- dcb_table_ptr->out_vr_tail_pt =
- (void *)app_out_address;
+ dcb_table_ptr->out_vr_tail_pt = app_out_address;
/*Update both data length parameters in order to avoid
second data copy and allow building of empty mlli
@@ -2758,34 +2550,18 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
}
if (tail_size) {
-
- if (is_kva == true) {
- memcpy(dcb_table_ptr->tail_data,
- (void *)(app_in_address + data_in_size -
- tail_size), tail_size);
- }
-
- else {
- /* we have tail data - copy it to dcb */
- if (copy_from_user(dcb_table_ptr->tail_data,
- (void *)(app_in_address +
- data_in_size - tail_size),
- tail_size)) {
-
-
- dev_warn(&sep->pdev->dev,
- "failed to copy tail\n");
- error = -EFAULT;
- goto end_function;
- }
+ /* we have tail data - copy it to dcb */
+ if (copy_from_user(dcb_table_ptr->tail_data,
+ (void *)(app_in_address +
+ data_in_size - tail_size), tail_size)) {
+ error = -EFAULT;
+ goto end_function;
}
-
if (app_out_address)
/*Caclulate the output address
according to tail data size.*/
dcb_table_ptr->out_vr_tail_pt =
- (void *)(app_out_address +
- data_in_size - tail_size);
+ app_out_address + data_in_size - tail_size;
/*save the real tail data size*/
dcb_table_ptr->tail_data_size = tail_size;
@@ -2808,8 +2584,7 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
&out_first_mlli_address,
&in_first_num_entries,
&out_first_num_entries,
- &first_data_size,
- is_kva);
+ &first_data_size);
}
else {
@@ -2820,8 +2595,7 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
block_size,
&in_first_mlli_address,
&in_first_num_entries,
- &first_data_size,
- is_kva);
+ &first_data_size);
}
if (error) {
@@ -2866,18 +2640,18 @@ static int sep_create_sync_dma_tables_handler(struct sep_device *sep,
dev_dbg(&sep->pdev->dev,
"sep_create_sync_dma_tables_handler start\n");
- error = copy_from_user(&command_args, (void __user *)arg,
- sizeof(struct bld_syn_tab_struct));
- if (error) {
+ if (copy_from_user(&command_args, (void __user *)arg,
+ sizeof(struct bld_syn_tab_struct))) {
+ error = -EFAULT;
dev_warn(&sep->pdev->dev, "create dma tables;"
" copy_from_user fails\n");
goto end_function;
}
dev_dbg(&sep->pdev->dev,
- "app_in_address is %08lx\n", command_args.app_in_address);
+ "app_in_address is %08llx\n", command_args.app_in_address);
dev_dbg(&sep->pdev->dev,
- "app_out_address is %08lx\n", command_args.app_out_address);
+ "app_out_address is %08llx\n", command_args.app_out_address);
dev_dbg(&sep->pdev->dev,
"data_size is %u\n", command_args.data_in_size);
dev_dbg(&sep->pdev->dev,
@@ -2899,7 +2673,6 @@ static int sep_create_sync_dma_tables_handler(struct sep_device *sep,
command_args.data_in_size,
command_args.block_size,
0x0,
- false,
false);
end_function:
@@ -2911,62 +2684,16 @@ end_function:
/**
* This function frees the dma tables and dcb block
* @sep: pointer to struct sep_device
- * @isapplet: indicates external application
- * @is_kva: indicates kernel addresses
*/
-static int sep_free_dma_tables_and_dcb(struct sep_device *sep, bool isapplet,
- bool is_kva)
+static int sep_free_dma_tables_and_dcb(struct sep_device *sep)
{
-
- int i = 0;
- int error = 0;
- int error_temp = 0;
-
- struct sep_dcblock *dcb_table_ptr;
-
dev_dbg(&sep->pdev->dev, "sep_free_dma_tables_and_dcb start\n");
- if (isapplet == true) {
-
- /* set pointer to first dcb table */
- dcb_table_ptr = (struct sep_dcblock *)
- (sep->shared_addr +
- SEP_DRIVER_SYSTEM_DCB_MEMORY_OFFSET_IN_BYTES);
-
- /* go over each dcb and see if tail pointer must be updated */
- for (i = 0; i < sep->nr_dcb_creat; i++, dcb_table_ptr++) {
-
- if (dcb_table_ptr->out_vr_tail_pt) {
-
- if (is_kva == true) {
- memcpy(dcb_table_ptr->out_vr_tail_pt,
- dcb_table_ptr->tail_data,
- dcb_table_ptr->tail_data_size);
- }
-
- else {
- error_temp = copy_to_user(
- dcb_table_ptr->out_vr_tail_pt,
- dcb_table_ptr->tail_data,
- dcb_table_ptr->tail_data_size);
- }
-
- if (error_temp) {
- /* we do not exist right away,
- since we need to release
- the dma resource */
-
- error = error_temp;
- }
- }
- }
- }
-
/* free the output pages, if any */
sep_free_dma_table_data_handler(sep);
dev_dbg(&sep->pdev->dev, "sep_free_dma_tables_and_dcb end\n");
- return error;
+ return 0;
}
/**
@@ -2978,7 +2705,6 @@ static int sep_free_dma_tables_and_dcb(struct sep_device *sep, bool isapplet,
static int sep_get_static_pool_addr_handler(struct sep_device *sep,
unsigned long arg)
{
- int error = 0;
struct stat_pool_addr_struct command_args;
u32 *static_pool_addr = 0;
@@ -2992,20 +2718,21 @@ static int sep_get_static_pool_addr_handler(struct sep_device *sep,
static_pool_addr[1] = sep->shared_bus +
SEP_DRIVER_STATIC_AREA_OFFSET_IN_BYTES;
- command_args.static_virt_address = sep->shared_addr +
- SEP_DRIVER_STATIC_AREA_OFFSET_IN_BYTES;
+ command_args.static_virt_address = (u64)(unsigned long)
+ (sep->shared_addr + SEP_DRIVER_STATIC_AREA_OFFSET_IN_BYTES);
dev_dbg(&sep->pdev->dev, "static pool: physical %x virtual %x\n",
(u32)static_pool_addr[1],
(u32)command_args.static_virt_address);
/* send the parameters to user application */
- error = copy_to_user((void *) arg, &command_args,
- sizeof(struct stat_pool_addr_struct));
+ if (copy_to_user((void __user *) arg, &command_args,
+ sizeof(struct stat_pool_addr_struct)))
+ return -EFAULT;
dev_dbg(&sep->pdev->dev, "sep_get_static_pool_addr_handler end\n");
- return error;
+ return 0;
}
/**
@@ -3067,75 +2794,49 @@ static u32 sep_check_sum_calc(u8 *data, u32 length)
*/
static int sep_init_handler(struct sep_device *sep, unsigned long arg)
{
- u32 message_buff[14];
u32 counter;
- int error = 0;
+ int error;
u32 reg_val;
dma_addr_t new_base_addr;
struct init_struct command_args;
+ u32 *buf;
+ u32 size;
dev_dbg(&sep->pdev->dev, "sep_init_handler start\n");
- error = 0;
/* make sure that we have not initialized already */
reg_val = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR3_REG_ADDR);
if (reg_val != 0x2) {
- error = SEP_ALREADY_INITIALIZED_ERR;
- dev_warn(&sep->pdev->dev,
- "init; device already initialized\n");
+ error = -EALREADY;
goto end_function;
}
/* only root can initialize */
if (!capable(CAP_SYS_ADMIN)) {
- dev_warn(&sep->pdev->dev,
- "init; only root can init\n");
- error = -EACCES;
+ error = -EPERM;
goto end_function;
}
/* copy in the parameters */
- error = copy_from_user(&command_args, (void __user *) arg,
- sizeof(struct init_struct));
-
- if (error) {
- dev_warn(&sep->pdev->dev,
- "init; copy_from_user failed %x\n", error);
+ if (copy_from_user(&command_args, (void __user *) arg,
+ sizeof(struct init_struct))) {
+ error = -EFAULT;
goto end_function;
}
+
+ size = command_args.message_size_in_words;
/* validate parameters */
- if (!command_args.message_addr || !command_args.sep_sram_addr ||
- command_args.message_size_in_words > 14) {
-
- dev_warn(&sep->pdev->dev,
- "init; parameter error\n");
+ if (!command_args.sep_sram_addr || size > 14) {
error = -EINVAL;
goto end_function;
}
- /* copy in the sep init message */
- error = copy_from_user(message_buff,
- command_args.message_addr,
- command_args.message_size_in_words*sizeof(u32));
-
- if (error) {
-
- dev_warn(&sep->pdev->dev,
- "init; copy sep init message failed %x\n", error);
- goto end_function;
- }
-
/* load resident, cache, and extapp firmware */
error = sep_load_firmware(sep);
-
- if (error) {
-
- dev_warn(&sep->pdev->dev,
- "init; copy sep init message failed %x\n", error);
+ if (error)
goto end_function;
- }
/* compute the base address */
new_base_addr = sep->shared_bus;
@@ -3149,36 +2850,29 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
if (sep->dcache_bus < new_base_addr)
new_base_addr = sep->dcache_bus;
- /* put physical addresses in sep message */
- message_buff[3] = (u32)new_base_addr;
- message_buff[4] = (u32)sep->shared_bus;
- message_buff[6] = (u32)sep->resident_bus;
- message_buff[7] = (u32)sep->cache_bus;
- message_buff[8] = (u32)sep->dcache_bus;
+ /* put bus addresses in sep message */
+ buf = command_args.message_buf;
+ buf[3] = (u32)new_base_addr;
+ buf[4] = (u32)sep->shared_bus;
+ buf[6] = (u32)sep->resident_bus;
+ buf[7] = (u32)sep->cache_bus;
+ buf[8] = (u32)sep->dcache_bus;
- message_buff[command_args.message_size_in_words - 1] = 0x0;
- message_buff[command_args.message_size_in_words - 1] =
- sep_check_sum_calc((u8 *)message_buff,
- command_args.message_size_in_words*sizeof(u32));
+ buf[size - 1] = 0x0;
+ buf[size - 1] = sep_check_sum_calc((u8 *)buf, size*sizeof(u32));
/* debug print of message */
- for (counter = 0; counter < command_args.message_size_in_words;
- counter++)
-
+ for (counter = 0; counter < size; counter++)
dev_dbg(&sep->pdev->dev,
"init; sep message word %d is %x\n",
- counter, message_buff[counter]);
+ counter, buf[counter]);
/* tell the sep the sram address */
sep_write_reg(sep, HW_SRAM_ADDR_REG_ADDR, command_args.sep_sram_addr);
/* push the message to the sep */
- for (counter = 0; counter < command_args.message_size_in_words;
- counter++) {
-
- sep_write_reg(sep, HW_SRAM_DATA_REG_ADDR,
- message_buff[counter]);
-
+ for (counter = 0; counter < size; counter++) {
+ sep_write_reg(sep, HW_SRAM_DATA_REG_ADDR, buf[counter]);
sep_wait_sram_write(sep);
}
@@ -3193,7 +2887,6 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
while (!(reg_val & 0xFFFFFFFD));
if (reg_val == 0x1) {
-
dev_warn(&sep->pdev->dev, "init; device int failed\n");
error = sep_read_reg(sep, 0x8060);
dev_warn(&sep->pdev->dev, "init; sw monitor is %x\n", error);
@@ -3202,8 +2895,7 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
goto end_function;
}
- dev_dbg(&sep->pdev->dev, "init; end CC INIT, reg_val is %x\n",
- reg_val);
+ dev_dbg(&sep->pdev->dev, "init; end CC INIT reg_val is %x\n", reg_val);
/* signal sep to zero the GPR3 */
sep_write_reg(sep, HW_HOST_HOST_SEP_GPR0_REG_ADDR, 0x10);
@@ -3276,17 +2968,14 @@ static int sep_prepare_dcb_handler(struct sep_device *sep, unsigned long arg)
/* get the command arguments */
if (copy_from_user(&command_args, (void __user *)arg,
sizeof(struct build_dcb_struct))) {
-
- dev_warn(&sep->pdev->dev,
- "prepare dcb handler: copy_from_user failed\n");
error = -EFAULT;
goto end_function;
}
dev_dbg(&sep->pdev->dev,
- "app_in_address is %08lx\n", command_args.app_in_address);
+ "app_in_address is %08llx\n", command_args.app_in_address);
dev_dbg(&sep->pdev->dev,
- "app_out_address is %08lx\n", command_args.app_out_address);
+ "app_out_address is %08llx\n", command_args.app_out_address);
dev_dbg(&sep->pdev->dev,
"data_size is %x\n", command_args.data_in_size);
dev_dbg(&sep->pdev->dev,
@@ -3297,7 +2986,7 @@ static int sep_prepare_dcb_handler(struct sep_device *sep, unsigned long arg)
error = sep_prepare_input_output_dma_table_in_dcb(sep,
command_args.app_in_address, command_args.app_out_address,
command_args.data_in_size, command_args.block_size,
- command_args.tail_block_size, true, false);
+ command_args.tail_block_size, true);
end_function:
@@ -3313,13 +3002,12 @@ end_function:
*/
static int sep_free_dcb_handler(struct sep_device *sep)
{
-
- int error = 0;
+ int error ;
dev_dbg(&sep->pdev->dev, "sep_prepare_dcb_handler start\n");
dev_dbg(&sep->pdev->dev, "num of DCBs %x\n", sep->nr_dcb_creat);
- error = sep_free_dma_tables_and_dcb(sep, false, false);
+ error = sep_free_dma_tables_and_dcb(sep);
dev_dbg(&sep->pdev->dev, "sep_free_dcb_handler end\n");
return error;
@@ -3355,8 +3043,6 @@ static int sep_rar_prepare_output_msg_handler(struct sep_device *sep,
if (copy_from_user(&command_args,
(void __user *)arg,
sizeof(command_args))) {
-
- dev_warn(&sep->pdev->dev, "rar msg; copy from user error\n");
error = -EFAULT;
goto end_function;
}
@@ -3405,23 +3091,9 @@ end_function:
static int sep_realloc_ext_cache_handler(struct sep_device *sep,
unsigned long arg)
{
-
- int error = 0;
- struct realloc_ext_struct command_args;
-
/* holds the new ext cache address in the system memory offset */
u32 *system_addr;
- if (copy_from_user(&command_args,
- (void __user *)arg, sizeof(command_args))) {
-
- dev_warn(&sep->pdev->dev,
- "ext cache init: copy from user error\n");
- error = -EFAULT;
- goto end_function;
-
- }
-
/* set value in the SYSTEM MEMORY offset */
system_addr = (u32 *)(sep->shared_addr +
SEP_DRIVER_SYSTEM_EXT_CACHE_ADDR_OFFSET_IN_BYTES);
@@ -3436,9 +3108,7 @@ static int sep_realloc_ext_cache_handler(struct sep_device *sep,
dev_dbg(&sep->pdev->dev,
"ext cache init; system addr 1 is %x\n", system_addr[1]);
-end_function:
-
- return error;
+ return 0;
}
/**
@@ -3495,8 +3165,7 @@ static long sep_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* check that the command is for sep device */
if (_IOC_TYPE(cmd) != SEP_IOC_MAGIC_NUMBER) {
- dev_dbg(&sep->pdev->dev, "ioctl incorrect magic nbr\n");
- error = -EFAULT;
+ error = -ENOTTY;
goto end_function;
}
@@ -3587,7 +3256,6 @@ static long sep_singleton_ioctl(struct file *filp, u32 cmd, unsigned long arg)
/* check that the command is for sep device */
if (_IOC_TYPE(cmd) != SEP_IOC_MAGIC_NUMBER) {
- dev_warn(&sep->pdev->dev, "singleton ictl wrong magic\n");
error = -ENOTTY;
goto end_function;
}
@@ -3608,14 +3276,12 @@ static long sep_singleton_ioctl(struct file *filp, u32 cmd, unsigned long arg)
switch (cmd) {
case SEP_IOCTLSETCALLERID:
-
mutex_lock(&sep->ioctl_mutex);
error = sep_set_caller_id_handler(sep, arg);
mutex_unlock(&sep->ioctl_mutex);
break;
default:
-
error = sep_ioctl(filp, cmd, arg);
break;
@@ -3639,7 +3305,7 @@ static long sep_request_daemon_ioctl(struct file *filp, u32 cmd,
unsigned long arg)
{
- long error = 0;
+ long error;
struct sep_device *sep = filp->private_data;
@@ -3651,9 +3317,7 @@ static long sep_request_daemon_ioctl(struct file *filp, u32 cmd,
/* check that the command is for sep device */
if (_IOC_TYPE(cmd) != SEP_IOC_MAGIC_NUMBER) {
- dev_warn(&sep->pdev->dev,
- "daemon ioctl: wrong magic number\n");
- error = -EFAULT;
+ error = -ENOTTY;
goto end_function;
}
@@ -3680,7 +3344,7 @@ static long sep_request_daemon_ioctl(struct file *filp, u32 cmd,
default:
dev_dbg(&sep->pdev->dev,
"daemon ioctl: no such IOCTL\n");
- error = -ENOIOCTLCMD;
+ error = -ENOTTY;
}
mutex_unlock(&sep->ioctl_mutex);
@@ -3867,7 +3531,7 @@ static int __devinit sep_probe(struct pci_dev *pdev,
dev_warn(&sep->pdev->dev,
"Please configure the rar register and\n");
dev_warn(&sep->pdev->dev,
- "ar handler and then recompile this kernel\n");
+ "rar handler and then recompile this kernel\n");
sep->probed = 0;
return -ENODEV;
}
@@ -3926,7 +3590,6 @@ static int __devinit sep_probe(struct pci_dev *pdev,
/* the next section depends on type of unit */
if (sep->mrst) {
-
error = register_rar(RAR_TYPE_IMAGE, &sep_callback,
(unsigned long)sep);
if (error) {
@@ -3934,9 +3597,7 @@ static int __devinit sep_probe(struct pci_dev *pdev,
"error register_rar\n");
goto end_function_deallocate_sep_shared_area;
}
- }
-
- else {
+ } else {
sep->rar_size = FAKE_RAR_SIZE;
sep->rar_addr = dma_alloc_coherent(NULL,
@@ -3973,12 +3634,10 @@ static int __devinit sep_probe(struct pci_dev *pdev,
goto end_function;
end_function_free_res:
-
if (sep->rar_addr)
dma_free_coherent(&sep->pdev->dev, sep->rar_size,
sep->rar_addr, sep->rar_bus);
-
-goto end_function;
+ goto end_function;
end_function_deallocate_sep_shared_area:
/* de-allocate shared area */
@@ -4155,6 +3814,7 @@ static void __exit sep_exit(void)
pr_debug("Exit start\n");
/* unregister from fs */
+ /* FIXME: this needs to deal with the misc devices instead */
cdev_del(&sep->sep_cdev);
cdev_del(&sep->sep_singleton_cdev);
cdev_del(&sep->sep_daemon_cdev);
diff --git a/drivers/staging/sep/sep_driver_api.h b/drivers/staging/sep/sep_driver_api.h
index f518b15935d..aa0f19a9c98 100644
--- a/drivers/staging/sep/sep_driver_api.h
+++ b/drivers/staging/sep/sep_driver_api.h
@@ -51,40 +51,17 @@
init command struct
*/
struct init_struct {
- /* address that SEP can access */
- u32 *message_addr;
-
/* start address of resident */
u32 message_size_in_words;
-
/* offset of the init message in the sep sram */
u32 sep_sram_addr;
-
- /* -not used- resident size in bytes*/
- u32 unused_resident_size_in_bytes;
-
- /* -not used- cache size in bytes*/
- u32 unused_cache_size_in_bytes;
-
- /* -not used- ext cache current address */
- void *unused_extcache_addr;
-
- /* -not used- ext cache size in bytes*/
- u32 unused_extcache_size_in_bytes;
-};
-
-struct realloc_ext_struct {
- /* -not used- current external cache address */
- void *unused_ext_cache_addr;
-
- /* -not used- external cache size in bytes*/
- u32 unused_ext_cache_size_in_bytes;
+ /* message buffer to pass - up to 14 dwords */
+ u32 message_buf[14];
};
struct alloc_struct {
/* offset from start of shared pool area */
u32 offset;
-
/* number of bytes to allocate */
u32 num_bytes;
};
@@ -93,41 +70,31 @@ struct alloc_struct {
*/
struct bld_syn_tab_struct {
/* address value of the data in (user space addr) */
- unsigned long app_in_address;
-
+ u64 app_in_address;
+ /* address of the data out (user space addr) */
+ u64 app_out_address;
/* size of data in */
u32 data_in_size;
-
- /* address of the data out (user space addr) */
- unsigned long app_out_address;
-
/* the size of the block of the operation - if needed,
every table will be modulo this parameter */
u32 block_size;
-
- /* -not used- distinct user/kernel layout */
- bool unused_isKernelVirtualAddress;
-
};
/* command struct for static pool addresses */
struct stat_pool_addr_struct {
-
/* virtual address of the static pool */
- void *static_virt_address;
+ u64 static_virt_address;
};
/* command struct for getting time value and address */
struct caller_id_struct {
/* pid of the process */
- u32 pid;
-
+ u32 pid;
/* virtual address of the caller id hash */
- void *callerIdAddress;
-
+ u64 callerIdAddress;
/* caller id hash size in bytes */
- u32 callerIdSizeInBytes;
+ u32 callerIdSizeInBytes;
};
/*
@@ -136,28 +103,20 @@ struct caller_id_struct {
struct sep_dcblock {
/* physical address of the first input mlli */
u32 input_mlli_address;
-
/* num of entries in the first input mlli */
u32 input_mlli_num_entries;
-
/* size of data in the first input mlli */
u32 input_mlli_data_size;
-
/* physical address of the first output mlli */
u32 output_mlli_address;
-
/* num of entries in the first output mlli */
u32 output_mlli_num_entries;
-
/* size of data in the first output mlli */
u32 output_mlli_data_size;
-
/* pointer to the output virtual tail */
- void *out_vr_tail_pt;
-
+ u64 out_vr_tail_pt;
/* size of tail data */
u32 tail_data_size;
-
/* input tail data array */
u8 tail_data[64];
};
@@ -172,18 +131,14 @@ struct sep_caller_id_entry {
*/
struct build_dcb_struct {
/* address value of the data in */
- unsigned long app_in_address;
-
+ u64 app_in_address;
+ /* address of the data out */
+ u64 app_out_address;
/* size of data in */
u32 data_in_size;
-
- /* address of the data out */
- unsigned long app_out_address;
-
/* the size of the block of the operation - if needed,
every table will be modulo this parameter */
u32 block_size;
-
/* the size of the block of the operation - if needed,
every table will be modulo this parameter */
u32 tail_block_size;
@@ -198,10 +153,8 @@ struct build_dcb_struct {
*
*/
struct sep_dma_map {
-
/* mapped dma address */
dma_addr_t dma_addr;
-
/* size of the mapped data */
size_t size;
};
@@ -285,18 +238,6 @@ struct sep_lli_entry {
#define SEP_IOCGETSTATICPOOLADDR \
_IOR(SEP_IOC_MAGIC_NUMBER, 8, struct stat_pool_addr_struct)
-/* set flow id command */
-#define SEP_IOCSETFLOWID \
- _IO(SEP_IOC_MAGIC_NUMBER, 9)
-
-/* add tables to the dynamic flow */
-#define SEP_IOCADDFLOWTABLE \
- _IO(SEP_IOC_MAGIC_NUMBER, 10)
-
-/* add flow add tables message */
-#define SEP_IOCADDFLOWMESSAGE \
- _IO(SEP_IOC_MAGIC_NUMBER, 11)
-
/* start sep command */
#define SEP_IOCSEPSTART \
_IO(SEP_IOC_MAGIC_NUMBER, 12)
@@ -311,17 +252,11 @@ struct sep_lli_entry {
/* reallocate external app */
#define SEP_IOCREALLOCEXTCACHE \
- _IOW(SEP_IOC_MAGIC_NUMBER, 18, struct realloc_ext_struct)
+ _IO(SEP_IOC_MAGIC_NUMBER, 18)
#define SEP_IOCRARPREPAREMESSAGE \
_IOW(SEP_IOC_MAGIC_NUMBER, 20, struct rar_hndl_to_bus_struct)
-#define SEP_IOCTLSINGLETONLOCK \
- _IO(SEP_IOC_MAGIC_NUMBER, 32)
-
-#define SEP_IOCTLSINGLETONUNLOCK \
- _IO(SEP_IOC_MAGIC_NUMBER, 33)
-
#define SEP_IOCTLSETCALLERID \
_IOW(SEP_IOC_MAGIC_NUMBER, 34, struct caller_id_struct)