aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2010-12-08 10:57:26 +0000
committerAlan Cox <alan@linux.intel.com>2010-12-08 10:57:26 +0000
commitb48177cb523020f3263fac07cf1998e09eafc8b0 (patch)
tree7a93b200bcef44c4b1d5cc15ff68cde3b523a859
parent70b449357c5e7211d3c5b7a37f6d64c8992f2162 (diff)
downloadmrst-s0i3-test-b48177cb523020f3263fac07cf1998e09eafc8b0.tar.gz
mrst-s0i3-test-b48177cb523020f3263fac07cf1998e09eafc8b0.tar.xz
mrst-s0i3-test-b48177cb523020f3263fac07cf1998e09eafc8b0.zip
dcb's are device control blocks to point to dma tables
Signed-off-by: Mark A. Allyn <mark.a.allyn@intel.com>
-rw-r--r--drivers/staging/sep/sep_driver.c229
1 files changed, 217 insertions, 12 deletions
diff --git a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c
index 839fa360702..5f230dc5b49 100644
--- a/drivers/staging/sep/sep_driver.c
+++ b/drivers/staging/sep/sep_driver.c
@@ -3306,28 +3306,233 @@ end_function:
}
/*
- This API handles the end transaction request
+ This API handles the end transaction request
+ @sep: pointer to struct sep_device
*/
-static int sep_end_transaction_handler(struct sep_device *sep, unsigned long arg)
+static int sep_end_transaction_handler(struct sep_device *sep)
{
- dbg("SEP Driver:--------> sep_end_transaction_handler start\n");
+ /*----------------------------
+ CODE
+ -----------------------------*/
-#if 0 /*!SEP_DRIVER_POLLING_MODE */
- /* close IMR */
- sep_write_reg(sep, HW_HOST_IMR_REG_ADDR, 0x7FFF);
+ dev_dbg(&sep->pdev->dev, "sep_end_transaction_handler start\n");
- /* release IRQ line */
- free_irq(SEP_DIRVER_IRQ_NUM, sep);
+ /* clear the data pool pointers Token */
+ memset((void *)(sep->shared_addr +
+ SEP_DRIVER_DATA_POOL_ALLOCATION_OFFSET_IN_BYTES),
+ 0, sep->num_of_data_allocations*2*sizeof(u32));
- /* lock the sep mutex */
- mutex_unlock(&sep_mutex);
-#endif
+ /* check that all the dma resources were freed */
+ sep_free_dma_table_data_handler(sep);
- dbg("SEP Driver:<-------- sep_end_transaction_handler end\n");
+ clear_bit(SEP_MMAP_LOCK_BIT, &sep->in_use_flags);
+
+ sep->pid_doing_transaction = 0;
+ /* raise event for stuck contextes */
+ wake_up(&sep->event);
+
+ dev_dbg(&sep->pdev->dev, "waking up event\n");
+ dev_dbg(&sep->pdev->dev, "sep_end_transaction_handler end\n");
return 0;
}
+/*
+ This function will retrieve the RAR buffer physical addresses, type
+ & size corresponding to the RAR handles provided in the buffers vector.
+ @sep: pointer to struct sep_device
+ @arg: pointer to user parameters
+*/
+
+static int sep_prepare_dcb_handler(struct sep_device *sep, unsigned long arg)
+{
+ /* error */
+ int error = 0;
+
+ /* command arguments */
+ struct sep_driver_build_dcb_t command_args;
+
+ /*--------------
+ CODE
+ -----------------*/
+ dev_dbg(&sep->pdev->dev, "sep_prepare_dcb_handler start\n");
+
+ /* get the command arguments */
+ if (copy_from_user(&command_args, (void *)arg,
+ sizeof(struct sep_driver_build_dcb_t))) {
+
+ 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);
+ dev_dbg(&sep->pdev->dev,
+ "app_out_address is %08lx\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,
+ "block_size is %x\n", command_args.block_size);
+ dev_dbg(&sep->pdev->dev,
+ "tail block_size is %x\n", command_args.tail_block_size);
+
+ 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);
+
+end_function:
+
+ dev_dbg(&sep->pdev->dev, "sep_prepare_dcb_handler end\n");
+ return error;
+
+}
+
+/*
+ this function frees the DCB resources
+ and updates the needed user-space buffers
+ @sep: pointer to struct sep_device
+*/
+static int sep_free_dcb_handler(struct sep_device *sep)
+{
+
+ int error = 0;
+
+
+ /*----------------
+ CODE
+ -----------------*/
+
+ 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);
+
+ dev_dbg(&sep->pdev->dev, "sep_free_dcb_handler end\n");
+ return error;
+}
+
+/*
+ This function will retrieve the RAR buffer physical addresses, type
+ & size corresponding to the RAR handles provided in the buffers vector.
+ @sep: pointer to struct sep_device
+ @arg: pointer to user parameters
+*/
+
+static int sep_rar_prepare_output_msg_handler(struct sep_device *sep,
+ unsigned long arg)
+{
+ /* error return code */
+ int error = 0;
+
+ /* command args */
+ struct sep_driver_rar_handle_to_bus command_args;
+ struct RAR_buffer rar_buf;
+
+ /* bus address */
+ dma_addr_t rar_bus = 0;
+
+ /* holds the RAR address in the system memory offset */
+ u32 *rar_addr;
+
+ /*------------------
+ CODE
+ ---------------------*/
+
+ dev_dbg(&sep->pdev->dev,
+ "sep_rar_prepare_output_msg_handler start\n");
+
+ /* copy the data */
+ if (copy_from_user(&command_args,
+ (void *)arg,
+ sizeof(command_args))) {
+
+ dev_warn(&sep->pdev->dev, "rar msg; copy from user error\n");
+ error = -EFAULT;
+ goto end_function;
+ }
+
+ /* call to translation function only if user handle is not NULL */
+ if (command_args.rar_handle) {
+
+ memset(&rar_buf, 0, sizeof(rar_buf));
+ rar_buf.info.handle = (u32)command_args.rar_handle;
+
+ if (rar_handle_to_bus(&rar_buf, 1) != 1) {
+ dev_dbg(&sep->pdev->dev,
+ "rar_handle_to_bus failure\n");
+ error = -EFAULT;
+ goto end_function;
+ }
+
+ rar_bus = rar_buf.bus_address;
+ }
+
+ dev_dbg(&sep->pdev->dev, "rar msg; rar_addr_bus = %x\n",
+ (u32)rar_bus);
+
+ /* set value in the SYSTEM MEMORY offset */
+ rar_addr = (u32 *)(sep->shared_addr +
+ SEP_DRIVER_SYSTEM_RAR_MEMORY_OFFSET_IN_BYTES);
+
+ /* copy the physical address to the System Area.
+ The SEP will follow this address */
+ rar_addr[0] = SEP_RAR_VAL_TOKEN;
+ rar_addr[1] = rar_bus;
+
+end_function:
+
+ dev_dbg(&sep->pdev->dev,
+ "sep_rar_prepare_output_msg_handler start\n");
+
+ return error;
+}
+
+/*
+ This function tells the sep where the extapp is located
+ @sep: pointer to struct sep_device
+ @arg: pointer to user parameters
+*/
+static int sep_realloc_ext_cache_handler(struct sep_device *sep,
+ unsigned long arg)
+{
+
+ int error = 0;
+ struct sep_driver_realloc_ext_cache_t command_args;
+
+ /* holds the new ext cache address in the system memory offset */
+ u32 *system_addr;
+
+ if (copy_from_user(&command_args, (void *)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);
+
+ /* copy the physical address to the System Area.
+ which is used directly by the sep */
+
+ system_addr[0] = SEP_EXT_CACHE_ADDR_VAL_TOKEN;
+ dev_dbg(&sep->pdev->dev,
+ "ext cache init; system addr 0 is %x\n", system_addr[0]);
+ system_addr[1] = sep->extapp_bus;
+ dev_dbg(&sep->pdev->dev,
+ "ext cache init; system addr 1 is %x\n", system_addr[1]);
+
+end_function:
+
+ return error;
+}
+
static long sep_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
int error = 0;