aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/staging/memrar/memrar.h7
-rw-r--r--drivers/staging/sep/TODO12
-rw-r--r--drivers/staging/sep/memrar_stub.h172
-rw-r--r--drivers/staging/sep/sep_dev.h12
-rw-r--r--drivers/staging/sep/sep_driver.c1257
-rw-r--r--drivers/staging/sep/sep_driver_api.h77
-rw-r--r--drivers/staging/sep/sep_driver_config.h29
7 files changed, 640 insertions, 926 deletions
diff --git a/drivers/staging/memrar/memrar.h b/drivers/staging/memrar/memrar.h
index 0b735b827c0..07e6c36a6ce 100644
--- a/drivers/staging/memrar/memrar.h
+++ b/drivers/staging/memrar/memrar.h
@@ -95,6 +95,8 @@ struct RAR_buffer {
dma_addr_t bus_address;
};
+#if defined(CONFIG_MRST_RAR_HANDLER) || defined(CONFIG_MRST_RAR_HANDLER_MODULE)
+
/**
* rar_reserve() - reserve RAR buffers
* @buffers: array of RAR_buffers where type and size of buffers to
@@ -149,6 +151,11 @@ extern size_t rar_release(struct RAR_buffer *buffers,
extern size_t rar_handle_to_bus(struct RAR_buffer *buffers,
size_t count);
+#else
+#define rar_reserve(a, b) ((size_t)NULL)
+#define rar_release(a, b) ((size_t)NULL)
+#define rar_handle_to_bus(a, b) ((size_t)NULL)
+#endif
#endif /* __KERNEL__ */
diff --git a/drivers/staging/sep/TODO b/drivers/staging/sep/TODO
index e622b493153..ea17f5015b8 100644
--- a/drivers/staging/sep/TODO
+++ b/drivers/staging/sep/TODO
@@ -1,2 +1,10 @@
-Todo's so far
-TBD
+Todo's so far (from Alan Cox)
+- Fix firmware loading - Done 09/10 M. Allyn
+- Get firmware into firmware git tree - Firmware is non open source
+- Review and tidy each algorithm function - Done 09/10 M. Allyn
+- Check whether it can be plugged into any of the kernel crypto API
+ interfaces - Crypto API 'glue' is still not ready to submit
+- Do something about the magic shared memory interface and replace it
+ with something saner (in Linux terms) - Done 09/10 M. Allyn
+- Clean up unused ioctls - Needs vendor help
+- Clean up unused fields in ioctl structures - Needs vendor help
diff --git a/drivers/staging/sep/memrar_stub.h b/drivers/staging/sep/memrar_stub.h
deleted file mode 100644
index 056bccefa9a..00000000000
--- a/drivers/staging/sep/memrar_stub.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * RAR Handler (/dev/memrar) internal driver API.
- * Copyright (C) 2010 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General
- * Public License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- * The full GNU General Public License is included in this
- * distribution in the file called COPYING.
- *
- * CONTACTS:
- *
- * Mark Allyn mark.a.allyn@intel.com
- *
- * Revisions:
- * 9/2010 - Initial publish (Mark Allyn)
- */
-
-#ifndef _MEMRAR_STUB_H
-#define _MEMRAR_STUB_H
-
-/* This stub header is for non Moorestown driver only */
-
-/*
- * Constants that specify different kinds of RAR regions that could be
- * set up.
- */
-static __u32 const RAR_TYPE_VIDEO; /* 0 */
-static __u32 const RAR_TYPE_AUDIO = 1;
-static __u32 const RAR_TYPE_IMAGE = 2;
-static __u32 const RAR_TYPE_DATA = 3;
-
-/*
- * @struct RAR_stat
- *
- * @brief This structure is used for @c RAR_HANDLER_STAT ioctl and for
- * @c RAR_get_stat() user space wrapper function.
- */
-struct RAR_stat {
- /* Type of RAR memory (e.g., audio vs. video) */
- __u32 type;
-
- /*
- * Total size of RAR memory region.
- */
- __u32 capacity;
-
- /* Size of the largest reservable block. */
- __u32 largest_block_size;
-};
-
-
-/*
- * @struct RAR_block_info
- *
- * @brief The argument for the @c RAR_HANDLER_RESERVE @c ioctl.
- *
- */
-struct RAR_block_info {
- /* Type of RAR memory (e.g., audio vs. video) */
- __u32 type;
-
- /* Requested size of a block to be reserved in RAR. */
- __u32 size;
-
- /* Handle that can be used to refer to reserved block. */
- __u32 handle;
-};
-
-/*
- * @struct RAR_buffer
- *
- * Structure that contains all information related to a given block of
- * memory in RAR. It is generally only used when retrieving bus
- * addresses.
- *
- * @note This structure is used only by RAR-enabled drivers, and is
- * not intended to be exposed to the user space.
- */
-struct RAR_buffer {
- /* Structure containing base RAR buffer information */
- struct RAR_block_info info;
-
- /* Buffer bus address */
- __u32 bus_address;
-};
-
-
-#define RAR_IOCTL_BASE 0xE0
-
-/* Reserve RAR block. */
-#define RAR_HANDLER_RESERVE _IOWR(RAR_IOCTL_BASE, 0x00, struct RAR_block_info)
-
-/* Release previously reserved RAR block. */
-#define RAR_HANDLER_RELEASE _IOW(RAR_IOCTL_BASE, 0x01, __u32)
-
-/* Get RAR stats. */
-#define RAR_HANDLER_STAT _IOWR(RAR_IOCTL_BASE, 0x02, struct RAR_stat)
-
-
-/* -------------------------------------------------------------- */
-/* Kernel Side RAR Handler Interface */
-/* -------------------------------------------------------------- */
-
-/*
- * @function rar_reserve
- *
- * @brief Reserve RAR buffers.
- *
- * This function will reserve buffers in the restricted access regions
- * of given types.
- *
- * @return Number of successfully reserved buffers.
- * Successful buffer reservations will have the corresponding
- * @c bus_address field set to a non-zero value in the
- * given @a buffers vector.
- */
-#define rar_reserve(a, b) ((size_t)NULL)
-
-/*
- * @function rar_release
- *
- * @brief Release RAR buffers retrieved through call to
- * @c rar_reserve() or @c rar_handle_to_bus().
- *
- * This function will release RAR buffers that were retrieved through
- * a call to @c rar_reserve() or @c rar_handle_to_bus() by
- * decrementing the reference count. The RAR buffer will be reclaimed
- * when the reference count drops to zero.
- *
- * @return Number of successfully released buffers.
- * Successful releases will have their handle field set to
- * zero in the given @a buffers vector.
- */
-#define rar_release(a, b) ((size_t)NULL)
-
-/*
- * @function rar_handle_to_bus
- *
- * @brief Convert a vector of RAR handles to bus addresses.
- *
- * This function will retrieve the RAR buffer bus addresses, type and
- * size corresponding to the RAR handles provided in the @a buffers
- * vector.
- *
- * @return Number of successfully converted buffers.
- * The bus address will be set to @c 0 for unrecognized
- * handles.
- *
- * @note The reference count for each corresponding buffer in RAR will
- * be incremented. Call @c rar_release() when done with the
- * buffers.
- */
-#define rar_handle_to_bus(a, b) ((size_t)NULL)
-
-#endif /* _MEMRAR_H */
-
-
-/*
- Local Variables:
- c-file-style: "linux"
- End:
-*/
diff --git a/drivers/staging/sep/sep_dev.h b/drivers/staging/sep/sep_dev.h
index f5ee28a1299..c12381cf97e 100644
--- a/drivers/staging/sep/sep_dev.h
+++ b/drivers/staging/sep/sep_dev.h
@@ -38,13 +38,19 @@ struct sep_device {
struct cdev sep_daemon_cdev;
struct cdev sep_singleton_cdev;
+ /* devices (using misc dev) */
+ struct miscdevice miscdev_sep;
+ struct miscdevice miscdev_singleton;
+ struct miscdevice miscdev_daemon;
+
/* major / minor numbers of device */
dev_t sep_devno;
dev_t sep_daemon_devno;
dev_t sep_singleton_devno;
- /* counter used to indicate how many have device open */
- unsigned long in_use;
+ struct mutex sep_mutex;
+ struct mutex ioctl_mutex;
+ spinlock_t snd_rply_lck;
/* flags to indicate use and lock status of sep */
u32 pid_doing_transaction;
@@ -114,7 +120,7 @@ struct sep_device {
unsigned long reply_ct;
/* counter for the number of bytes allocated in the pool for the
current transaction */
- unsigned long data_pool_bytes_allocated;
+ long data_pool_bytes_allocated;
u32 num_of_data_allocations;
diff --git a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c
index efa7c6b5c17..22cee0a7b1f 100644
--- a/drivers/staging/sep/sep_driver.c
+++ b/drivers/staging/sep/sep_driver.c
@@ -29,9 +29,9 @@
*
*/
-#define DEBUG
#include <linux/init.h>
#include <linux/module.h>
+#include <linux/miscdevice.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <linux/kdev_t.h>
@@ -57,13 +57,7 @@
#include <linux/connector.h>
#include <linux/cn_proc.h>
-
-/* Stub out memrar and rar_register if those drivers are not in config */
-#if defined(CONFIG_MRST_RAR_HANDLER)
#include "../memrar/memrar.h"
-#else
-#include "memrar_stub.h"
-#endif
#include <linux/rar_register.h>
@@ -84,18 +78,8 @@
/* Keep this a single static object for now to keep the conversion easy */
-static struct sep_device sep_instance;
static struct sep_device *sep_dev;
-/*
- mutex for the access to the internals of the sep driver
-*/
-static DEFINE_MUTEX(sep_mutex);
-static DEFINE_MUTEX(ioctl_mutex);
-static DEFINE_SPINLOCK(snd_rply_lck);
-static unsigned long snd_rply_lck_flag;
-
-
/**
* sep_load_firmware - copy firmware cache/resident
* @sep: device we are loading
@@ -131,8 +115,8 @@ static int sep_load_firmware(struct sep_device *sep)
dev_dbg(&sep->pdev->dev, "resident virtual is %p\n",
sep->resident_addr);
- dev_dbg(&sep->pdev->dev, "residnet bus is %08llx\n",
- (unsigned long long)sep->resident_bus);
+ dev_dbg(&sep->pdev->dev, "residnet bus is %lx\n",
+ (unsigned long)sep->resident_bus);
dev_dbg(&sep->pdev->dev, "resident size is %08x\n",
sep->resident_size);
@@ -165,8 +149,8 @@ static int sep_load_firmware(struct sep_device *sep)
dev_dbg(&sep->pdev->dev, "cache virtual is %p\n",
sep->cache_addr);
- dev_dbg(&sep->pdev->dev, "cache bus is %08llx\n",
- (unsigned long long)sep->cache_bus);
+ dev_dbg(&sep->pdev->dev, "cache bus is %08lx\n",
+ (unsigned long)sep->cache_bus);
dev_dbg(&sep->pdev->dev, "cache size is %08x\n",
sep->cache_size);
@@ -208,10 +192,11 @@ MODULE_FIRMWARE("sep/extapp.image.bin");
static void sep_dump_message(struct sep_device *sep)
{
int count;
+ u32 *p = sep->shared_addr;
for (count = 0; count < 12 * 4; count += 4)
dev_dbg(&sep->pdev->dev,
"Word %d of the message is %x\n",
- count, *((u32 *) (sep->shared_addr + count)));
+ count, *p++);
}
/**
@@ -271,28 +256,22 @@ static void *sep_shared_bus_to_virt(struct sep_device *sep,
return sep->shared_addr + (bus_address - sep->shared_bus);
}
-/*
- open function for the singleton driver
- @inode_ptr struct inode *
- @file_ptr struct file *
-*/
+/**
+ * open function for the singleton driver
+ * @inode_ptr struct inode *
+ * @file_ptr struct file *
+ */
+
static int sep_singleton_open(struct inode *inode_ptr, struct file *file_ptr)
{
- /*-----------------
- CODE
- ---------------------*/
-
int error = 0;
struct sep_device *sep;
- if (sep_dev == NULL)
- return -ENODEV;
-
/* get the sep device structure and use it for the
private_data field in filp for other methods */
- sep = container_of(inode_ptr->i_cdev, struct sep_device,
- sep_singleton_cdev);
+ sep = sep_dev;
+
file_ptr->private_data = sep;
dev_dbg(&sep->pdev->dev, "Singleton open for pid %d\n",
@@ -306,14 +285,6 @@ static int sep_singleton_open(struct inode *inode_ptr, struct file *file_ptr)
goto end_function;
}
- /* count up number of users opening device
- which prevents someone else from attempting
- to remove device (rmmod) */
- mutex_lock(&sep_mutex);
- sep->in_use += 1;
- mutex_unlock(&sep_mutex);
-
-
dev_dbg(&sep->pdev->dev,
"sep_singleton_open end\n");
end_function:
@@ -321,7 +292,6 @@ end_function:
return error;
}
-
/**
* sep_open - device open method
* @inode: inode of sep device
@@ -338,23 +308,13 @@ static int sep_open(struct inode *inode, struct file *filp)
{
struct sep_device *sep;
- if (sep_dev == NULL)
- return -ENODEV;
-
/* get the sep device structure and use it for the
private_data field in filp for other methods */
- sep = container_of(inode->i_cdev, struct sep_device, sep_cdev);
+ sep = sep_dev;
filp->private_data = sep;
dev_dbg(&sep->pdev->dev, "Open for pid %d\n", current->pid);
- /* count up number of users opening device
- which prevents someone else from attempting
- to remove device (rmmod) */
- mutex_lock(&sep_mutex);
- sep->in_use += 1;
- mutex_unlock(&sep_mutex);
-
/* Note that anyone is allowed to open device and
that blocking, if necessary, will take place
at transaction level (when the sep is actally
@@ -380,12 +340,6 @@ static int sep_singleton_release(struct inode *inode, struct file *filp)
dev_dbg(&sep->pdev->dev, "Singleton release for pid %d\n",
current->pid);
- /* decrement the number of processes having this device
- open */
- mutex_lock(&sep_mutex);
- sep->in_use -= 1;
- mutex_unlock(&sep_mutex);
-
clear_bit(0, &sep->singleton_access_flag);
return 0;
@@ -409,12 +363,9 @@ static int sep_request_daemon_open(struct inode *inode, struct file *filp)
int error = 0;
- if (sep_dev == NULL)
- return -ENODEV;
-
/* get the sep device structure and use it for the
private_data field in filp for other methods */
- sep = container_of(inode->i_cdev, struct sep_device, sep_daemon_cdev);
+ sep = sep_dev;
filp->private_data = sep;
dev_dbg(&sep->pdev->dev, "Request daemon open for pid %d\n",
@@ -429,19 +380,11 @@ static int sep_request_daemon_open(struct inode *inode, struct file *filp)
goto end_function;
}
- /* count up number of users opening device
- which prevents someone else from attempting
- to remove device (rmmod) */
- mutex_lock(&sep_mutex);
- sep->in_use += 1;
- mutex_unlock(&sep_mutex);
-
end_function:
return error;
}
-
/**
* sep_request_daemon_release - close a SEP daemon
* @inode: inode of SEP device
@@ -460,25 +403,20 @@ static int sep_request_daemon_release(struct inode *inode, struct file *filp)
/* clear the request_daemon_open flag */
clear_bit(0, &sep->request_daemon_open);
- /* decrement the number of processes having this device
- open */
- mutex_lock(&sep_mutex);
- sep->in_use -= 1;
- mutex_unlock(&sep_mutex);
-
return 0;
}
-/*
- This function raises interrupt to SEPm that signals that is has a
- new command from HOST
- @sep: struct sep_device *
-*/
+/**
+ * This function raises interrupt to SEPm that signals that is has a
+ * new command from HOST
+ * @sep: struct sep_device *
+ */
static int sep_req_daemon_send_reply_command_handler(struct sep_device *sep)
{
/* error */
int error = 0;
+ unsigned long lck_flags;
dev_dbg(&sep->pdev->dev,
"sep_req_daemon_send_reply_command_handler start\n");
@@ -489,7 +427,7 @@ static int sep_req_daemon_send_reply_command_handler(struct sep_device *sep)
/* update both counters counter */
/* logk while activity with counters */
- spin_lock_irqsave(&snd_rply_lck, snd_rply_lck_flag);
+ spin_lock_irqsave(&sep->snd_rply_lck, lck_flags);
sep->send_ct++;
sep->reply_ct++;
@@ -501,7 +439,7 @@ static int sep_req_daemon_send_reply_command_handler(struct sep_device *sep)
sep->send_ct++;
/* done with counters */
- spin_unlock_irqrestore(&snd_rply_lck, snd_rply_lck_flag);
+ spin_unlock_irqrestore(&sep->snd_rply_lck, lck_flags);
dev_dbg(&sep->pdev->dev,
"sep_req_daemon_send_reply send_ct %lx reply_ct %lx\n",
@@ -514,10 +452,10 @@ static int sep_req_daemon_send_reply_command_handler(struct sep_device *sep)
}
-/*
- this function handles the request for freeing dma table for synhronic actions
- @sep: pointere to struct sep_device
-*/
+/**
+ * this function handles the request for freeing dma table for synhronic actions
+ * @sep: pointere to struct sep_device
+ */
static int sep_free_dma_table_data_handler(struct sep_device *sep)
{
@@ -530,10 +468,6 @@ static int sep_free_dma_table_data_handler(struct sep_device *sep)
/* pointer to the current dma_resource struct */
struct sep_dma_resource *dma_resource;
- /*-------------------------
- CODE
- -----------------------------*/
-
dev_dbg(&sep->pdev->dev,
"sep_free_dma_table_data_handler start\n");
@@ -621,27 +555,12 @@ static int sep_free_dma_table_data_handler(struct sep_device *sep)
}
-/*
- This API handles the end transaction request
- @sep: struct sep_device * for sep
- @file_ptr: struct file * for file
-*/
-static int sep_req_daemon_end_transaction_handler(
- struct sep_device *sep, struct file *file_ptr)
-{
- /*----------------------------
- CODE
- -----------------------------*/
-
- dev_dbg(&sep->pdev->dev,
- "sep_req_daemon_end_transaction_handler start\n");
-
- dev_dbg(&sep->pdev->dev,
- "sep_req_daemon_end_transaction_handler end\n");
-
- return 0;
-}
-
+/**
+ * The request daemon mmap function maps the
+ * shared area to user space
+ * @filp: pointer to struct file
+ * @vma: pointer to vm_area_struct
+ */
static int sep_request_daemon_mmap(struct file *filp,
struct vm_area_struct *vma)
{
@@ -649,15 +568,11 @@ static int sep_request_daemon_mmap(struct file *filp,
struct sep_device *sep = filp->private_data;
/* physical addr */
- dma_addr_t phys_addr;
+ dma_addr_t bus_address;
/* error */
int error = 0;
- /*-----------------------
- CODE
- -------------------------*/
-
dev_dbg(&sep->pdev->dev, "daemon mmap start\n");
/* check that the size of the mapped range is as the size of the message
@@ -670,13 +585,13 @@ static int sep_request_daemon_mmap(struct file *filp,
}
/* get physical address */
- phys_addr = sep->shared_bus;
+ bus_address = sep->shared_bus;
dev_dbg(&sep->pdev->dev,
- "phys_addr is %08x\n",
- (u32)phys_addr);
+ "bus_address is %08lx\n",
+ (unsigned long)bus_address);
- if (remap_pfn_range(vma, vma->vm_start, phys_addr >> PAGE_SHIFT,
+ if (remap_pfn_range(vma, vma->vm_start, bus_address >> PAGE_SHIFT,
vma->vm_end - vma->vm_start, vma->vm_page_prot)) {
dev_warn(&sep->pdev->dev,
@@ -692,24 +607,24 @@ end_function:
return error;
}
-/* sep_request_daemon_poll
- @sep: struct sep_device * for current sep device
- @filp: struct file * for open file
- @wait: poll_table * for poll
-*/
+/**
+ * sep_request_daemon_poll
+ * @sep: struct sep_device * for current sep device
+ * @filp: struct file * for open file
+ * @wait: poll_table * for poll
+ */
static unsigned int sep_request_daemon_poll(struct file *filp,
poll_table *wait)
{
u32 mask = 0;
/* GPR2 register */
- u32 retVal2;
+ u32 retval2;
+
+ unsigned long lck_flags;
struct sep_device *sep = filp->private_data;
- /*----------------------------------------------
- CODE
- -------------------------------------------------*/
dev_dbg(&sep->pdev->dev,
"daemon poll: start\n");
@@ -723,16 +638,19 @@ static unsigned int sep_request_daemon_poll(struct file *filp,
"daemon poll: send_ct is %lx reply ct is %lx\n",
sep->send_ct, sep->reply_ct);
+ spin_lock_irqsave(&sep->snd_rply_lck, lck_flags);
/* check if the data is ready */
if (sep->send_ct == sep->reply_ct) {
- retVal2 = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR2_REG_ADDR);
+ spin_unlock_irqrestore(&sep->snd_rply_lck, lck_flags);
+
+ retval2 = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR2_REG_ADDR);
dev_dbg(&sep->pdev->dev,
- "daemon poll: data check (GPR2) is %x\n", retVal2);
+ "daemon poll: data check (GPR2) is %x\n", retval2);
/* check if PRINT request */
- if ((retVal2 >> 30) & 0x1) {
+ if ((retval2 >> 30) & 0x1) {
dev_dbg(&sep->pdev->dev,
"daemon poll: PRINTF request in\n");
@@ -741,7 +659,7 @@ static unsigned int sep_request_daemon_poll(struct file *filp,
}
/* check if NVS request */
- if (retVal2 >> 31) {
+ if (retval2 >> 31) {
dev_dbg(&sep->pdev->dev,
"daemon poll: NVS request in\n");
@@ -751,23 +669,13 @@ static unsigned int sep_request_daemon_poll(struct file *filp,
else {
+ spin_unlock_irqrestore(&sep->snd_rply_lck, lck_flags);
+
dev_dbg(&sep->pdev->dev,
"daemon poll: no reply received; returning 0\n");
mask = 0;
}
-#if SEP_DRIVER_POLLING_MODE
- /* in case not a request and we're running -goto sleep and wake up
- application process */
- if (sep->send_ct != sep->reply_ct) {
-
- dev_dbg(&sep->pdev->dev,
- "daemon poll: wake up task\n");
-
- wake_up(&sep->event);
- }
-#endif
-
end_function:
dev_dbg(&sep->pdev->dev,
@@ -789,12 +697,12 @@ static int sep_release(struct inode *inode, struct file *filp)
dev_dbg(&sep->pdev->dev, "Release for pid %d\n", current->pid);
- /* decrement the number of processes having this device
- open */
- mutex_lock(&sep_mutex);
- sep->in_use -= 1;
-
- /* is this the process that has a transaction open? */
+ mutex_lock(&sep->sep_mutex);
+ /* is this the process that has a transaction open?
+ * If so, lets reset pid_doing_transaction to 0 and
+ * clear the in use flags, and then wake up sep_event
+ * so that other processes can do transactions
+ */
dev_dbg(&sep->pdev->dev, "waking up event and mmap_event\n");
if (sep->pid_doing_transaction == current->pid) {
clear_bit(SEP_MMAP_LOCK_BIT, &sep->in_use_flags);
@@ -804,13 +712,15 @@ static int sep_release(struct inode *inode, struct file *filp)
sep->pid_doing_transaction = 0;
}
- mutex_unlock(&sep_mutex);
+ mutex_unlock(&sep->sep_mutex);
return 0;
}
-/*---------------------------------------------------------------
- map function - this functions maps the message shared area
------------------------------------------------------------------*/
+/**
+ * The mmap function maps the shared area to user space
+ * @filp: pointer to struct file
+ * @vma: pointer to vm_area_struct
+ */
static int sep_mmap(struct file *filp, struct vm_area_struct *vma)
{
dma_addr_t bus_addr;
@@ -831,7 +741,19 @@ static int sep_mmap(struct file *filp, struct vm_area_struct *vma)
error = -EINTR;
goto end_function_with_error;
}
+ /*
+ * The pid_doing_transaction indicates that this process
+ * now owns the facilities to performa a transaction with
+ * the sep. While this process is performing a transaction,
+ * no other process who has the sep device open can perform
+ * any transactions. This method allows more than one process
+ * to have the device open at any given time, which provides
+ * finer granularity for device utilization by multiple
+ * processes.
+ */
+ mutex_lock(&sep->sep_mutex);
sep->pid_doing_transaction = current->pid;
+ mutex_unlock(&sep->sep_mutex);
/* zero the pools and the number of data pool alocation pointers */
sep->data_pool_bytes_allocated = 0;
@@ -857,7 +779,7 @@ static int sep_mmap(struct file *filp, struct vm_area_struct *vma)
bus_addr = sep->shared_bus;
dev_dbg(&sep->pdev->dev,
- "phys_addr is %08llx\n", (unsigned long long)bus_addr);
+ "bus_address is %lx\n", (unsigned long)bus_addr);
if (remap_pfn_range(vma, vma->vm_start, bus_addr >> PAGE_SHIFT,
vma->vm_end - vma->vm_start, vma->vm_page_prot)) {
@@ -874,7 +796,9 @@ end_function_with_error:
/* clear the bit */
clear_bit(SEP_MMAP_LOCK_BIT, &sep->in_use_flags);
+ mutex_lock(&sep->sep_mutex);
sep->pid_doing_transaction = 0;
+ mutex_unlock(&sep->sep_mutex);
/* raise event for stuck contextes */
@@ -886,28 +810,34 @@ end_function:
return error;
}
-
-/*-----------------------------------------------
- poll function
-*----------------------------------------------*/
+/**
+ * poll function
+ * @filp: pointer to struct file
+ * @wait: pointer to poll_table
+ */
static unsigned int sep_poll(struct file *filp, poll_table *wait)
{
- u32 count = 0;
u32 mask = 0;
u32 retval = 0;
u32 retval2 = 0;
+ unsigned long lck_flags;
+
struct sep_device *sep = filp->private_data;
dev_dbg(&sep->pdev->dev, "poll: start\n");
/* am I the process that own the transaction? */
+ mutex_lock(&sep->sep_mutex);
if (current->pid != sep->pid_doing_transaction) {
dev_warn(&sep->pdev->dev, "poll; wrong pid\n");
mask = POLLERR;
+ mutex_unlock(&sep->sep_mutex);
goto end_function;
}
+ mutex_unlock(&sep->sep_mutex);
+
/* check if send command or send_reply were activated previously */
if (!test_bit(SEP_SEND_MSG_LOCK_BIT, &sep->in_use_flags)) {
dev_warn(&sep->pdev->dev, "poll; lock bit set\n");
@@ -915,23 +845,6 @@ static unsigned int sep_poll(struct file *filp, poll_table *wait)
goto end_function;
}
-#if SEP_DRIVER_POLLING_MODE
-
- dev_dbg(&sep->pdev->dev, "poll: waiting for send_ct and gpr2\n");
- while ((retval2 == 0x0) &&
- (sep->send_ct != (retVal & 0x3FFFFFFF))) {
-
- retval = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR2_REG_ADDR);
-
- retval2 = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR3_REG_ADDR);
- }
-
- spin_lock_irqsave(&snd_rply_lck, snd_rply_lck_flag);
- sep->reply_ct++;
- spin_unlock_irqrestore(&snd_rply_lck, snd_rply_lck_flag);
-
-#endif
-
/* add the event to the polling wait table */
dev_dbg(&sep->pdev->dev, "poll: calling wait sep_event\n");
@@ -953,8 +866,11 @@ static unsigned int sep_poll(struct file *filp, poll_table *wait)
goto end_function;
}
+ spin_lock_irqsave(&sep->snd_rply_lck, lck_flags);
+
if (sep->send_ct == sep->reply_ct) {
+ spin_unlock_irqrestore(&sep->snd_rply_lck, lck_flags);
retval = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR2_REG_ADDR);
dev_dbg(&sep->pdev->dev, "poll: data ready check (GPR2) %x\n",
retval);
@@ -985,23 +901,15 @@ static unsigned int sep_poll(struct file *filp, poll_table *wait)
sep_dump_message(sep);
- for (count = 0; count < 10 * 4; count += 4)
- dev_dbg(&sep->pdev->dev,
- "poll; debug word %d is %x\n",
- count,
- *((u32 *)(sep->shared_addr + count +
- 0x1800)));
-
dev_dbg(&sep->pdev->dev,
"poll; sep reply POLLIN | POLLRDNORM\n");
mask |= POLLIN | POLLRDNORM;
-
}
- }
+ } else {
- else {
+ spin_unlock_irqrestore(&sep->snd_rply_lck, lck_flags);
dev_dbg(&sep->pdev->dev,
"poll; no reply received; returning mask of 0\n");
@@ -1061,10 +969,10 @@ static unsigned long sep_set_time(struct sep_device *sep)
return time.tv_sec;
}
-/*
- initializes the caller id functionality
- @sep: sep device
-*/
+/**
+ * initializes the caller id functionality
+ * @sep: pointer to struct sep_device
+ */
static int sep_init_caller_id(struct sep_device *sep)
{
/* return value */
@@ -1075,11 +983,6 @@ static int sep_init_caller_id(struct sep_device *sep)
struct cb_id caller_id;
-
- /*----------------------------
- CODE
- ---------------------------------*/
-
dev_dbg(&sep->pdev->dev,
"sep_init_caller_id start\n");
@@ -1089,7 +992,11 @@ static int sep_init_caller_id(struct sep_device *sep)
caller_id.idx = CN_IDX_PROC;
caller_id.val = CN_VAL_PROC;
- /* init caller id table */
+ /**
+ * init caller id table
+ * note that locking is not needed here as this function is
+ * called prior to registering the device file
+ */
for (counter = 0; counter < SEP_CALLER_ID_TABLE_NUM_ENTRIES; counter++)
sep->caller_id_table[counter].pid = 0;
@@ -1114,11 +1021,12 @@ static int sep_init_caller_id(struct sep_device *sep)
return ret_val;
}
-/*
- inserts the data into the caller id table
- @sep: sep device
- @arg: pointer to struct sep_driver_set_caller_id_t
-*/
+/**
+ * inserts the data into the caller id table
+ * note that this function does fall under the ioctl lock
+ * @sep: sep device
+ * @arg: pointer to struct caller_id_stru
+ */
static int sep_set_caller_id_handler(struct sep_device *sep, u32 arg)
{
/* error */
@@ -1128,11 +1036,7 @@ static int sep_set_caller_id_handler(struct sep_device *sep, u32 arg)
int i;
/* command arguments */
- struct sep_driver_set_caller_id_t command_args;
-
- /*----------------------------
- CODE
- ------------------------------*/
+ struct caller_id_stru command_args;
dev_dbg(&sep->pdev->dev,
"sep_set_caller_id_handler start\n");
@@ -1157,7 +1061,7 @@ static int sep_set_caller_id_handler(struct sep_device *sep, u32 arg)
}
/* copy the data */
- if (copy_from_user(&command_args, (void *)arg,
+ if (copy_from_user(&command_args, (void __user *)arg,
sizeof(command_args))) {
dev_warn(&sep->pdev->dev,
"copy_from_user failed\n");
@@ -1203,10 +1107,11 @@ end_function:
return error;
}
-/*
- set the caller id (if exists) to the sep
- @sep: pointer to struct_sep
-*/
+/**
+ * set the caller id (if exists) to the sep
+ * note that this function does fall under the ioctl lock
+ * @sep: pointer to struct_sep
+ */
static int sep_set_current_caller_id(struct sep_device *sep)
{
int i;
@@ -1239,15 +1144,18 @@ static int sep_set_current_caller_id(struct sep_device *sep)
}
/**
- * sep_send_command_handler - kick off a command
- * @sep: sep being signalled
- *
+ * sep_send_command_handler - kick off a command
+ * note that this function does fall under the ioctl lock
* This function raises interrupt to SEP that signals that is has a new
* command from the host
+ * @sep: sep being signalled
*/
-static void sep_send_command_handler(struct sep_device *sep)
+static int sep_send_command_handler(struct sep_device *sep)
{
+ unsigned long lck_flags;
+ int error = 0;
+
dev_dbg(&sep->pdev->dev, "sep_send_command_handler start\n");
dev_dbg(&sep->pdev->dev, "calling test and set for "
@@ -1256,6 +1164,7 @@ static void sep_send_command_handler(struct sep_device *sep)
dev_warn(&sep->pdev->dev,
"cannot send msg while awaiting reply\n");
+ error = -EBUSY;
goto end_function;
}
@@ -1268,9 +1177,9 @@ static void sep_send_command_handler(struct sep_device *sep)
sep_dump_message(sep);
/* update counter */
- spin_lock_irqsave(&snd_rply_lck, snd_rply_lck_flag);
+ spin_lock_irqsave(&sep->snd_rply_lck, lck_flags);
sep->send_ct++;
- spin_unlock_irqrestore(&snd_rply_lck, snd_rply_lck_flag);
+ spin_unlock_irqrestore(&sep->snd_rply_lck, lck_flags);
dev_dbg(&sep->pdev->dev, "sep_send_command_handler"
"send_ct %lx reply_ct %lx\n", sep->send_ct, sep->reply_ct);
@@ -1282,23 +1191,23 @@ end_function:
dev_dbg(&sep->pdev->dev, "sep_send_command_handler end\n");
- return;
+ return error;
}
-/*
- This function handles the allocate data pool memory request
- This function returns calculates the bus address of the
- allocated memory, and the offset of this area from the mapped address.
- Therefore, the FVOs in user space can calculate the exact virtual
- address of this allocated memory
- @sep: pointer to struct_sep
- @arg: pointer to struct sep_driver_alloc_t
-*/
+/**
+ * This function handles the allocate data pool memory request
+ * This function returns calculates the bus address of the
+ * allocated memory, and the offset of this area from the mapped address.
+ * Therefore, the FVOs in user space can calculate the exact virtual
+ * address of this allocated memory
+ * @sep: pointer to struct_sep
+ * @arg: pointer to struct alloc_struct
+ */
static int sep_allocate_data_pool_memory_handler(struct sep_device *sep,
unsigned long arg)
{
int error = 0;
- struct sep_driver_alloc_t command_args;
+ struct alloc_struct command_args;
/* holds the allocated buffer address in the system memory pool */
u32 *token_addr;
@@ -1306,8 +1215,8 @@ 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 *)arg,
- sizeof(struct sep_driver_alloc_t));
+ 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");
@@ -1356,7 +1265,7 @@ static int sep_allocate_data_pool_memory_handler(struct sep_device *sep,
/* write the memory back to the user space */
error = copy_to_user((void *)arg, (void *)&command_args,
- sizeof(struct sep_driver_alloc_t));
+ sizeof(struct alloc_struct));
if (error) {
dev_warn(&sep->pdev->dev,
@@ -1380,15 +1289,20 @@ end_function:
return error;
}
-/*
- 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
-*/
+/**
+ * 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_t **lli_array_ptr,
+ struct sep_lli_entry **lli_array_ptr,
int in_out_flag)
{
@@ -1396,15 +1310,11 @@ static int sep_lock_kernel_pages(struct sep_device *sep,
int error = 0;
/* array of lli */
- struct sep_lli_entry_t *lli_array;
+ struct sep_lli_entry *lli_array;
/* map array */
struct sep_dma_map *map_array;
- /*------------------------
- CODE
- --------------------------*/
-
dev_dbg(&sep->pdev->dev,
"sep_lock_kernel_pages start\n");
@@ -1413,7 +1323,7 @@ static int sep_lock_kernel_pages(struct sep_device *sep,
dev_dbg(&sep->pdev->dev,
"data_size is %x\n", data_size);
- lli_array = kmalloc(sizeof(struct sep_lli_entry_t) * 1, GFP_ATOMIC);
+ lli_array = kmalloc(sizeof(struct sep_lli_entry), GFP_ATOMIC);
if (!lli_array) {
dev_warn(&sep->pdev->dev, "kmalloc for lli_array failed\n");
@@ -1421,7 +1331,7 @@ static int sep_lock_kernel_pages(struct sep_device *sep,
goto end_function;
}
- map_array = kmalloc(sizeof(struct sep_dma_map) * 1, GFP_ATOMIC);
+ 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;
@@ -1441,9 +1351,9 @@ static int sep_lock_kernel_pages(struct sep_device *sep,
/* debug print */
dev_dbg(&sep->pdev->dev,
- "lli_array[0].bus_address is %08x,"
+ "lli_array[0].bus_address is %08lx,"
" lli_array[0].block_size is %x\n",
- lli_array[0].bus_address,
+ (unsigned long)lli_array[0].bus_address,
lli_array[0].block_size);
/* set the output parameters */
@@ -1475,16 +1385,21 @@ end_function:
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
- data holds in this physical pages
-*/
+/**
+ * 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
+ * data holds in this physical pages
+ * @sep: pointer to struct sep_device
+ * @app_virt_addr: user memory data buffer
+ * @data_size: size of data buffer
+ * @lli_array_ptr: lli array
+ * @in_out_flag: input or output to device
+ */
static int sep_lock_user_pages(struct sep_device *sep,
u32 app_virt_addr,
u32 data_size,
- struct sep_lli_entry_t **lli_array_ptr,
+ struct sep_lli_entry **lli_array_ptr,
int in_out_flag)
{
@@ -1504,7 +1419,7 @@ static int sep_lock_user_pages(struct sep_device *sep,
struct page **page_array;
/* array of lli */
- struct sep_lli_entry_t *lli_array;
+ struct sep_lli_entry *lli_array;
/* map array */
struct sep_dma_map *map_array;
@@ -1518,10 +1433,6 @@ static int sep_lock_user_pages(struct sep_device *sep,
/* result */
int result;
- /*------------------------
- CODE
- --------------------------*/
-
dev_dbg(&sep->pdev->dev,
"sep_lock_user_pages start\n");
@@ -1533,7 +1444,7 @@ static int sep_lock_user_pages(struct sep_device *sep,
num_pages = end_page - start_page + 1;
dev_dbg(&sep->pdev->dev,
- "app_virt_addr is %08x\n", app_virt_addr);
+ "app_virt_addr is %x\n", app_virt_addr);
dev_dbg(&sep->pdev->dev,
"data_size is %x\n", data_size);
dev_dbg(&sep->pdev->dev,
@@ -1564,7 +1475,7 @@ static int sep_lock_user_pages(struct sep_device *sep,
goto end_function_with_error1;
}
- lli_array = kmalloc(sizeof(struct sep_lli_entry_t) * num_pages,
+ lli_array = kmalloc(sizeof(struct sep_lli_entry) * num_pages,
GFP_ATOMIC);
if (!lli_array) {
@@ -1606,7 +1517,7 @@ static int sep_lock_user_pages(struct sep_device *sep,
dir = DMA_FROM_DEVICE;
/* fill the array using page array data and map the pages - this action
- will also flush the cache as needed */
+ will also flush the cache as needed */
for (count = 0; count < num_pages; count++) {
/* fill the map array */
map_array[count].dma_addr =
@@ -1620,9 +1531,9 @@ static int sep_lock_user_pages(struct sep_device *sep,
lli_array[count].block_size = PAGE_SIZE;
dev_warn(&sep->pdev->dev,
- "lli_array[%x].bus_address is %08x, \
+ "lli_array[%x].bus_address is %08lx, \
lli_array[%x].block_size is %x\n",
- count, lli_array[count].bus_address,
+ count, (unsigned long)lli_array[count].bus_address,
count, lli_array[count].block_size);
}
@@ -1639,9 +1550,9 @@ static int sep_lock_user_pages(struct sep_device *sep,
PAGE_SIZE - (app_virt_addr & (~PAGE_MASK));
dev_dbg(&sep->pdev->dev,
- "lli_array[0].bus_address is %08x, \
+ "lli_array[0].bus_address is %08lx, \
lli_array[0].block_size is %x\n",
- lli_array[count].bus_address,
+ (unsigned long)lli_array[count].bus_address,
lli_array[count].block_size);
/* check the size of the last page */
@@ -1651,9 +1562,10 @@ static int sep_lock_user_pages(struct sep_device *sep,
(app_virt_addr + data_size) & (~PAGE_MASK);
dev_warn(&sep->pdev->dev,
- "lli_array[%x].bus_address is %08x, \
+ "lli_array[%x].bus_address is %08lx, \
lli_array[%x].block_size is %x\n",
- num_pages - 1, lli_array[count].bus_address,
+ num_pages - 1,
+ (unsigned long)lli_array[count].bus_address,
num_pages - 1,
lli_array[count].block_size);
}
@@ -1705,20 +1617,20 @@ end_function:
return error;
}
-/*
- this function calculates the size of data
- that can be inserted into the lli
- table from this array the condition is that
- either the table is full
- (all etnries are entered), or there are no more
- entries in the lli array
- @sep: pointer to struct sep_device
- @lli_in_array_ptr
- @num_array_entries
- @last_table_flag
-*/
+/**
+ * this function calculates the size of data
+ * that can be inserted into the lli
+ * table from this array the condition is that
+ * either the table is full
+ * (all etnries are entered), or there are no more
+ * entries in the lli array
+ * @sep: pointer to struct sep_device
+ * @lli_in_array_ptr
+ * @num_array_entries
+ * @last_table_flag
+ */
static u32 sep_calculate_lli_table_max_size(struct sep_device *sep,
- struct sep_lli_entry_t *lli_in_array_ptr,
+ struct sep_lli_entry *lli_in_array_ptr,
u32 num_array_entries,
u32 *last_table_flag)
{
@@ -1731,10 +1643,6 @@ static u32 sep_calculate_lli_table_max_size(struct sep_device *sep,
/* counter */
u32 counter;
- /*---------------------
- CODE
- ----------------------*/
-
table_data_size = 0;
*last_table_flag = 0;
@@ -1756,8 +1664,7 @@ static u32 sep_calculate_lli_table_max_size(struct sep_device *sep,
}
/* calculate the data size of the next table. Stop if no entries left or
- if data size is more the DMA restriction
- */
+ if data size is more the DMA restriction */
next_table_data_size = 0;
for (; counter < num_array_entries; counter++) {
@@ -1769,8 +1676,8 @@ static u32 sep_calculate_lli_table_max_size(struct sep_device *sep,
}
/* check if the next table data size is less then DMA rstriction.
- if it is - recalculate the current table size, so that the next
- table data size will be adaquete for DMA
+ if it is - recalculate the current table size, so that the next
+ table data size will be adaquete for DMA
*/
if (next_table_data_size &&
next_table_data_size < SEP_DRIVER_MIN_DATA_SIZE_PER_TABLE)
@@ -1786,19 +1693,19 @@ end_function:
return table_data_size;
}
-/*
- this functions builds ont lli table from the lli_array according to
- the given size of data
- @sep: pointer to struct sep_device
- @lli_array_ptr: pointer to lli array
- @lli_table_ptr: pointer to lli table
- @num_processed_entries_ptr: pointer to number of entries
- @num_table_entries_ptr: pointer to number of tables
- @table_data_size: total data size
-*/
+/**
+ * this functions builds ont lli table from the lli_array according to
+ * the given size of data
+ * @sep: pointer to struct sep_device
+ * @lli_array_ptr: pointer to lli array
+ * @lli_table_ptr: pointer to lli table
+ * @num_processed_entries_ptr: pointer to number of entries
+ * @num_table_entries_ptr: pointer to number of tables
+ * @table_data_size: total data size
+ */
static void sep_build_lli_table(struct sep_device *sep,
- struct sep_lli_entry_t *lli_array_ptr,
- struct sep_lli_entry_t *lli_table_ptr,
+ struct sep_lli_entry *lli_array_ptr,
+ struct sep_lli_entry *lli_table_ptr,
u32 *num_processed_entries_ptr,
u32 *num_table_entries_ptr,
u32 table_data_size)
@@ -1809,10 +1716,6 @@ static void sep_build_lli_table(struct sep_device *sep,
/* counter of lli array entry */
u32 array_counter;
- /*-----------------------
- CODE
- ---------------------------*/
-
dev_dbg(&sep->pdev->dev,
"sep_build_lli_table start\n");
@@ -1838,10 +1741,10 @@ static void sep_build_lli_table(struct sep_device *sep,
curr_table_data_size += lli_array_ptr[array_counter].block_size;
dev_dbg(&sep->pdev->dev,
- "lli_table_ptr is %08x\n", (u32)lli_table_ptr);
+ "lli_table_ptr is %p\n", lli_table_ptr);
dev_dbg(&sep->pdev->dev,
- "lli_table_ptr->bus_address is %08x\n",
- lli_table_ptr->bus_address);
+ "lli_table_ptr->bus_address is %08lx\n",
+ (unsigned long)lli_table_ptr->bus_address);
dev_dbg(&sep->pdev->dev,
"lli_table_ptr->block_size is %x\n",
lli_table_ptr->block_size);
@@ -1870,8 +1773,8 @@ static void sep_build_lli_table(struct sep_device *sep,
array_counter++;
dev_dbg(&sep->pdev->dev,
- "lli_table_ptr->bus_address is %08x\n",
- lli_table_ptr->bus_address);
+ "lli_table_ptr->bus_address is %08lx\n",
+ (unsigned long)lli_table_ptr->bus_address);
dev_dbg(&sep->pdev->dev,
"lli_table_ptr->block_size is %x\n",
lli_table_ptr->block_size);
@@ -1885,10 +1788,10 @@ static void sep_build_lli_table(struct sep_device *sep,
lli_table_ptr->block_size = 0;
dev_dbg(&sep->pdev->dev,
- "lli_table_ptr is %08x\n", (u32)lli_table_ptr);
+ "lli_table_ptr is %p\n", lli_table_ptr);
dev_dbg(&sep->pdev->dev,
- "lli_table_ptr->bus_address is %08x\n",
- lli_table_ptr->bus_address);
+ "lli_table_ptr->bus_address is %08lx\n",
+ (unsigned long)lli_table_ptr->bus_address);
dev_dbg(&sep->pdev->dev,
"lli_table_ptr->block_size is %x\n",
lli_table_ptr->block_size);
@@ -1906,12 +1809,14 @@ static void sep_build_lli_table(struct sep_device *sep,
return;
}
-/*
- This functions returns the physical address inside shared area according
- to the virtual address. It can be either on the externa RAM device
- (ioremapped), or on the system RAM
- This implementation is for the external RAM
-*/
+/**
+ * This functions returns the physical address inside shared area according
+ * to the virtual address. It can be either on the externa RAM device
+ * (ioremapped), or on the system RAM
+ * This implementation is for the external RAM
+ * @sep: pointer to struct sep_device
+ * @virt_address: virtual address to convert
+ */
static dma_addr_t sep_shared_area_virt_to_bus(struct sep_device *sep,
void *virt_address)
{
@@ -1927,12 +1832,14 @@ static dma_addr_t sep_shared_area_virt_to_bus(struct sep_device *sep,
+ (size_t)(virt_address - sep->shared_addr);
}
-/*
- This functions returns the virtual address inside shared area
- according to the physical address. It can be either on the
- externa RAM device (ioremapped), or on the system RAM This implementation
- is for the external RAM
-*/
+/**
+ * This functions returns the virtual address inside shared area
+ * according to the physical address. It can be either on the
+ * externa RAM device (ioremapped), or on the system RAM
+ * This implementation is for the external RAM
+ * @sep: pointer to struct sep_device
+ * @bus_address: bus address to convert
+ */
static void *sep_shared_area_bus_to_virt(struct sep_device *sep,
dma_addr_t bus_address)
@@ -1947,16 +1854,16 @@ static void *sep_shared_area_bus_to_virt(struct sep_device *sep,
+ (size_t)(bus_address - sep->shared_bus);
}
-/*
- this function goes over the list of the print created tables and
- prints all the data
- @sep: pointer to struct sep_device
- @lli_table_ptr: pointer to sep_lli_entry_t
- @num_table_entries: number of entries
- @table_data_size: total data size
-*/
+/**
+ * this function goes over the list of the print created tables and
+ * prints all the data
+ * @sep: pointer to struct sep_device
+ * @lli_table_ptr: pointer to sep_lli_entry
+ * @num_table_entries: number of entries
+ * @table_data_size: total data size
+ */
static void sep_debug_print_lli_tables(struct sep_device *sep,
- struct sep_lli_entry_t *lli_table_ptr,
+ struct sep_lli_entry *lli_table_ptr,
unsigned long num_table_entries,
unsigned long table_data_size)
{
@@ -2003,7 +1910,7 @@ static void sep_debug_print_lli_tables(struct sep_device *sep,
table_data_size = lli_table_ptr->block_size & 0xffffff;
num_table_entries = (lli_table_ptr->block_size >> 24) & 0xff;
- lli_table_ptr = (struct sep_lli_entry_t *)
+ lli_table_ptr = (struct sep_lli_entry *)
(lli_table_ptr->bus_address);
dev_dbg(&sep->pdev->dev,
@@ -2012,7 +1919,7 @@ static void sep_debug_print_lli_tables(struct sep_device *sep,
num_table_entries, (unsigned long)lli_table_ptr);
if ((unsigned long)lli_table_ptr != 0xffffffff)
- lli_table_ptr = (struct sep_lli_entry_t *)
+ lli_table_ptr = (struct sep_lli_entry *)
sep_shared_bus_to_virt(sep,
(unsigned long)lli_table_ptr);
@@ -2023,33 +1930,28 @@ static void sep_debug_print_lli_tables(struct sep_device *sep,
}
-/*
- This function creates empty lli tables when there is no data
- @sep: pointer to struct sep_device
- @lli_table_addr_ptr: pointer to lli table
- @num_entries_ptr: pointer to number of entries
- @table_data_size_ptr: point to table data size
-*/
+/**
+ * This function creates empty lli tables when there is no data
+ * @sep: pointer to struct sep_device
+ * @lli_table_addr_ptr: pointer to lli table
+ * @num_entries_ptr: pointer to number of entries
+ * @table_data_size_ptr: point to table data size
+ */
static void sep_prepare_empty_lli_table(struct sep_device *sep,
dma_addr_t *lli_table_addr_ptr,
u32 *num_entries_ptr,
u32 *table_data_size_ptr)
{
- /* lli table pointer */
- struct sep_lli_entry_t *lli_table_ptr;
-
- /*---------------------
- CODE
- ------------------------*/
+ struct sep_lli_entry *lli_table_ptr;
dev_dbg(&sep->pdev->dev, "sep_prepare_empty_lli_table start\n");
/* find the area for new table */
lli_table_ptr =
- (struct sep_lli_entry_t *)(sep->shared_addr +
+ (struct sep_lli_entry *)(sep->shared_addr +
SYNCHRONIC_DMA_TABLES_AREA_OFFSET_BYTES +
sep->num_lli_tables_created *
- sizeof(struct sep_lli_entry_t) *
+ sizeof(struct sep_lli_entry) *
SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP);
lli_table_ptr->bus_address = 0;
@@ -2063,7 +1965,7 @@ static void sep_prepare_empty_lli_table(struct sep_device *sep,
*lli_table_addr_ptr = sep->shared_bus +
SYNCHRONIC_DMA_TABLES_AREA_OFFSET_BYTES +
sep->num_lli_tables_created *
- sizeof(struct sep_lli_entry_t) *
+ sizeof(struct sep_lli_entry) *
SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP;
/* set the num of entries and table data size for empty table */
@@ -2077,10 +1979,19 @@ static void sep_prepare_empty_lli_table(struct sep_device *sep,
}
-/*
- This function prepares only input DMA table for synhronic symmetric
- operations (HASH)
-*/
+/**
+ * This function prepares only input DMA table for synhronic symmetric
+ * operations (HASH)
+ * Note that all bus addresses that are passed to the sep
+ * are in 32 bit format; the SEP is a 32 bit device
+ * @sep: pointer to struct sep_device
+ * @data_size:
+ * @block_size:
+ * @lli_table_ptr:
+ * @num_entries_ptr:
+ * @data_data_size_ptr:
+ * @is_kva:
+ */
static int sep_prepare_input_dma_table(struct sep_device *sep,
unsigned long app_virt_addr,
u32 data_size,
@@ -2088,14 +1999,14 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
dma_addr_t *lli_table_ptr,
u32 *num_entries_ptr,
u32 *table_data_size_ptr,
- bool isKernelVirtualAddress)
+ bool is_kva)
{
/* pointer to the info entry of the table - the last entry */
- struct sep_lli_entry_t *info_entry_ptr;
+ struct sep_lli_entry *info_entry_ptr;
/* array of pointers ot page */
- struct sep_lli_entry_t *lli_array_ptr;
+ struct sep_lli_entry *lli_array_ptr;
/* points to the first entry to be processed in the lli_in_array */
u32 current_entry = 0;
@@ -2104,7 +2015,7 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
u32 sep_lli_entries = 0;
/* lli table pointer */
- struct sep_lli_entry_t *in_lli_table_ptr;
+ struct sep_lli_entry *in_lli_table_ptr;
/* the total data in one table */
u32 table_data_size = 0;
@@ -2121,10 +2032,6 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
/* error */
int error = 0;
- /*------------------------
- CODE
- --------------------------*/
-
dev_dbg(&sep->pdev->dev,
"sep_prepare_input_dma_table start\n");
@@ -2141,7 +2048,7 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
lli_table_alloc_addr = (u32)(sep->shared_addr +
SYNCHRONIC_DMA_TABLES_AREA_OFFSET_BYTES +
sep->num_lli_tables_created *
- sizeof(struct sep_lli_entry_t) *
+ sizeof(struct sep_lli_entry) *
SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP);
if (data_size == 0) {
@@ -2155,7 +2062,7 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
}
/* check if the pages are in Kernel Virtual Address layout */
- if (isKernelVirtualAddress == true)
+ if (is_kva == true)
/* lock the pages of the kernel
buffer and translate them to pages */
@@ -2186,9 +2093,9 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
/* set the new input and output tables */
in_lli_table_ptr =
- (struct sep_lli_entry_t *)lli_table_alloc_addr;
+ (struct sep_lli_entry *)lli_table_alloc_addr;
- lli_table_alloc_addr += sizeof(struct sep_lli_entry_t) *
+ lli_table_alloc_addr += sizeof(struct sep_lli_entry) *
SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP;
if (lli_table_alloc_addr >
@@ -2234,8 +2141,8 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
*table_data_size_ptr = table_data_size;
dev_dbg(&sep->pdev->dev,
- "output lli_table_in_ptr is %08x\n",
- (u32)*lli_table_ptr);
+ "output lli_table_in_ptr is %08lx\n",
+ (unsigned long)*lli_table_ptr);
}
@@ -2256,7 +2163,7 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
}
/* print input tables */
- sep_debug_print_lli_tables(sep, (struct sep_lli_entry_t *)
+ sep_debug_print_lli_tables(sep, (struct sep_lli_entry *)
sep_shared_area_bus_to_virt(sep, *lli_table_ptr),
*num_entries_ptr,
*table_data_size_ptr);
@@ -2286,26 +2193,29 @@ end_function:
return error;
}
-/*
- This function creates the input and output dma tables for
- symmetric operations (AES/DES) according to the block size from LLI arays
- @sep: pointer to struct_sep
- @lli_in_array:
- @sep_in_lli_entries:
- @lli_out_array:
- @sep_out_lli_entries
- @block_size
- @lli_table_in_ptr
- @lli_table_out_ptr
- @in_num_entries_ptr
- @out_num_entries_ptr
- @table_data_size_ptr
-*/
+/**
+ * This function creates the input and output dma tables for
+ * symmetric operations (AES/DES) according to the block
+ * size from LLI arays
+ * Note that all bus addresses that are passed to the sep
+ * are in 32 bit format; the SEP is a 32 bit device
+ * @sep: pointer to struct_sep
+ * @lli_in_array:
+ * @sep_in_lli_entries:
+ * @lli_out_array:
+ * @sep_out_lli_entries
+ * @block_size
+ * @lli_table_in_ptr
+ * @lli_table_out_ptr
+ * @in_num_entries_ptr
+ * @out_num_entries_ptr
+ * @table_data_size_ptr
+ */
static int sep_construct_dma_tables_from_lli(
struct sep_device *sep,
- struct sep_lli_entry_t *lli_in_array,
+ struct sep_lli_entry *lli_in_array,
u32 sep_in_lli_entries,
- struct sep_lli_entry_t *lli_out_array,
+ struct sep_lli_entry *lli_out_array,
u32 sep_out_lli_entries,
u32 block_size,
dma_addr_t *lli_table_in_ptr,
@@ -2318,16 +2228,16 @@ static int sep_construct_dma_tables_from_lli(
u32 lli_table_alloc_addr = 0;
/* input lli table */
- struct sep_lli_entry_t *in_lli_table_ptr = 0;
+ struct sep_lli_entry *in_lli_table_ptr = 0;
/* output lli table */
- struct sep_lli_entry_t *out_lli_table_ptr = 0;
+ struct sep_lli_entry *out_lli_table_ptr = 0;
/* pointer to the info entry of the table - the last entry */
- struct sep_lli_entry_t *info_in_entry_ptr = 0;
+ struct sep_lli_entry *info_in_entry_ptr = 0;
/* pointer to the info entry of the table - the last entry */
- struct sep_lli_entry_t *info_out_entry_ptr = 0;
+ struct sep_lli_entry *info_out_entry_ptr = 0;
/* points to the first entry to be processed in the lli_in_array */
u32 current_in_entry = 0;
@@ -2353,10 +2263,6 @@ static int sep_construct_dma_tables_from_lli(
/* number of etnries in the output table */
u32 num_entries_out_table = 0;
- /*---------------------
- CODE
- ------------------------*/
-
dev_dbg(&sep->pdev->dev,
"sep_construct_dma_tables_from_lli start\n");
@@ -2364,7 +2270,7 @@ static int sep_construct_dma_tables_from_lli(
lli_table_alloc_addr = (u32)(sep->shared_addr +
SYNCHRONIC_DMA_TABLES_AREA_OFFSET_BYTES +
(sep->num_lli_tables_created *
- (sizeof(struct sep_lli_entry_t) *
+ (sizeof(struct sep_lli_entry) *
SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP)));
/* loop till all the entries in in array are not processed */
@@ -2372,17 +2278,17 @@ static int sep_construct_dma_tables_from_lli(
/* set the new input and output tables */
in_lli_table_ptr =
- (struct sep_lli_entry_t *)lli_table_alloc_addr;
+ (struct sep_lli_entry *)lli_table_alloc_addr;
- lli_table_alloc_addr += sizeof(struct sep_lli_entry_t) *
+ lli_table_alloc_addr += sizeof(struct sep_lli_entry) *
SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP;
/* set the first output tables */
out_lli_table_ptr =
- (struct sep_lli_entry_t *)lli_table_alloc_addr;
+ (struct sep_lli_entry *)lli_table_alloc_addr;
/* check if the DMA table area limit was overrun */
- if ((lli_table_alloc_addr + sizeof(struct sep_lli_entry_t) *
+ if ((lli_table_alloc_addr + sizeof(struct sep_lli_entry) *
SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP) >
((u32)sep->shared_addr +
SYNCHRONIC_DMA_TABLES_AREA_OFFSET_BYTES +
@@ -2396,7 +2302,7 @@ static int sep_construct_dma_tables_from_lli(
/* update the number of the lli tables created */
sep->num_lli_tables_created += 2;
- lli_table_alloc_addr += sizeof(struct sep_lli_entry_t) *
+ lli_table_alloc_addr += sizeof(struct sep_lli_entry) *
SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP;
/* calculate the maximum size of data for input table */
@@ -2469,11 +2375,11 @@ static int sep_construct_dma_tables_from_lli(
*table_data_size_ptr = table_data_size;
dev_dbg(&sep->pdev->dev,
- "output lli_table_in_ptr is %08x\n",
- (u32)*lli_table_in_ptr);
+ "output lli_table_in_ptr is %08lx\n",
+ (unsigned long)*lli_table_in_ptr);
dev_dbg(&sep->pdev->dev,
- "output lli_table_out_ptr is %08x\n",
- (u32)*lli_table_out_ptr);
+ "output lli_table_out_ptr is %08lx\n",
+ (unsigned long)*lli_table_out_ptr);
} else {
/* update the info entry of the previous in table */
info_in_entry_ptr->bus_address =
@@ -2494,13 +2400,13 @@ static int sep_construct_dma_tables_from_lli(
(table_data_size);
dev_dbg(&sep->pdev->dev,
- "output lli_table_in_ptr:%08x %08x\n",
- (u32)info_in_entry_ptr->bus_address,
+ "output lli_table_in_ptr:%08lx %08x\n",
+ (unsigned long)info_in_entry_ptr->bus_address,
info_in_entry_ptr->block_size);
dev_dbg(&sep->pdev->dev,
- "output lli_table_out_ptr:%08x %08x\n",
- (u32)info_out_entry_ptr->bus_address,
+ "output lli_table_out_ptr:%08lx %08x\n",
+ (unsigned long)info_out_entry_ptr->bus_address,
info_out_entry_ptr->block_size);
}
@@ -2514,23 +2420,23 @@ static int sep_construct_dma_tables_from_lli(
"output num_entries_out_table is %x\n",
(u32)num_entries_out_table);
dev_dbg(&sep->pdev->dev,
- "output info_in_entry_ptr is %x\n",
- (u32)info_in_entry_ptr);
+ "output info_in_entry_ptr is %lx\n",
+ (unsigned long)info_in_entry_ptr);
dev_dbg(&sep->pdev->dev,
- "output info_out_entry_ptr is %x\n",
- (u32)info_out_entry_ptr);
+ "output info_out_entry_ptr is %lx\n",
+ (unsigned long)info_out_entry_ptr);
}
/* print input tables */
sep_debug_print_lli_tables(sep,
- (struct sep_lli_entry_t *)
+ (struct sep_lli_entry *)
sep_shared_area_bus_to_virt(sep, *lli_table_in_ptr),
*in_num_entries_ptr,
*table_data_size_ptr);
/* print output tables */
sep_debug_print_lli_tables(sep,
- (struct sep_lli_entry_t *)
+ (struct sep_lli_entry *)
sep_shared_area_bus_to_virt(sep, *lli_table_out_ptr),
*out_num_entries_ptr,
*table_data_size_ptr);
@@ -2541,11 +2447,23 @@ static int sep_construct_dma_tables_from_lli(
return 0;
}
-/*
- This function builds input and output DMA tables for synhronic
- symmetric operations (AES, DES, HASH). It also checks that each table
- is of the modular block size
-*/
+/**
+ * This function builds input and output DMA tables for synhronic
+ * symmetric operations (AES, DES, HASH). It also checks that each table
+ * is of the modular block size
+ * Note that all bus addresses that are passed to the sep
+ * are in 32 bit format; the SEP is a 32 bit device
+ * @app_virt_in_addr:
+ * @app_virt_out_addr:
+ * @data_size:
+ * @block_size:
+ * @lli_table_in_ptr:
+ * @lli_table_out_ptr:
+ * @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,
unsigned long app_virt_out_addr,
@@ -2556,22 +2474,18 @@ static int sep_prepare_input_output_dma_table(struct sep_device *sep,
u32 *in_num_entries_ptr,
u32 *out_num_entries_ptr,
u32 *table_data_size_ptr,
- bool isKernelVirtualAddress)
+ bool is_kva)
{
/* array of pointers of page */
- struct sep_lli_entry_t *lli_in_array;
+ struct sep_lli_entry *lli_in_array;
/* array of pointers of page */
- struct sep_lli_entry_t *lli_out_array;
+ struct sep_lli_entry *lli_out_array;
/* error */
int error = 0;
- /*------------------------
- CODE
- --------------------------*/
-
dev_dbg(&sep->pdev->dev,
"sep_prepare_input_output_dma_table start\n");
@@ -2592,7 +2506,7 @@ static int sep_prepare_input_output_dma_table(struct sep_device *sep,
sep->dma_res_arr[sep->nr_dcb_creat].out_page_array = 0;
/* check if the pages are in Kernel Virtual Address layout */
- if (isKernelVirtualAddress == true) {
+ if (is_kva == true) {
/* lock the pages of the kernel buffer and
translate them to pages */
@@ -2623,7 +2537,7 @@ static int sep_prepare_input_output_dma_table(struct sep_device *sep,
}
}
- if (isKernelVirtualAddress == true) {
+ if (is_kva == true) {
error = sep_lock_kernel_pages(sep, app_virt_out_addr,
data_size, &lli_out_array, SEP_DRIVER_OUT_FLAG);
@@ -2714,17 +2628,19 @@ end_function:
}
-/*
- This function prepares the linked dma tables and puts the
- address for the linked list of tables inta a dcb (data control
- block) the address of which is known by the sep hardware
- @app_in_address: unsigned long; for data buffer in (user space)
- @app_out_address: unsigned long; for data buffer out (user space)
- @data_in_size: u32; for size of data
- @block_size: u32; for block size
- @tail_block_size: u32; for size of tail block
- @isApplet: bool; to indicate external app
- @isKernelVirtualAddress: bool; to indicate kernel space
+/**
+ * This function prepares the linked dma tables and puts the
+ * address for the linked list of tables inta a dcb (data control
+ * block) the address of which is known by the sep hardware
+ * Note that all bus addresses that are passed to the sep
+ * are in 32 bit format; the SEP is a 32 bit device
+ * @app_in_address: unsigned long; for data buffer in (user space)
+ * @app_out_address: unsigned long; for data buffer out (user space)
+ * @data_in_size: u32; for size of data
+ * @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,
@@ -2732,8 +2648,8 @@ 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 isKernelVirtualAddress)
+ bool isapplet,
+ bool is_kva)
{
/* error */
@@ -2743,7 +2659,7 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
u32 tail_size = 0;
/* address of the created dcb table */
- struct sep_dcb_t *dcb_table_ptr = 0;
+ struct sep_dcblock *dcb_table_ptr = 0;
/* the physical address of the first input DMA table */
dma_addr_t in_first_mlli_address = 0;
@@ -2772,9 +2688,9 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
}
/* allocate new DCB */
- dcb_table_ptr = (struct sep_dcb_t *)(sep->shared_addr +
+ dcb_table_ptr = (struct sep_dcblock *)(sep->shared_addr +
SEP_DRIVER_SYSTEM_DCB_MEMORY_OFFSET_IN_BYTES +
- (sep->nr_dcb_creat * sizeof(struct sep_dcb_t)));
+ (sep->nr_dcb_creat * sizeof(struct sep_dcblock)));
/* set the default values in the dcb */
dcb_table_ptr->input_mlli_address = 0;
@@ -2786,7 +2702,7 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
dcb_table_ptr->tail_data_size = 0;
dcb_table_ptr->out_vr_tail_pt = 0;
- if (isApplet == true) {
+ if (isapplet == true) {
tail_size = data_in_size % block_size;
if (tail_size) {
@@ -2810,7 +2726,7 @@ 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 (isKernelVirtualAddress == true) {
+ if (is_kva == true) {
memcpy(dcb_table_ptr->tail_data,
(void *)app_in_address, data_in_size);
}
@@ -2843,7 +2759,7 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
if (tail_size) {
- if (isKernelVirtualAddress == true) {
+ if (is_kva == true) {
memcpy(dcb_table_ptr->tail_data,
(void *)(app_in_address + data_in_size -
tail_size), tail_size);
@@ -2893,7 +2809,7 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
&in_first_num_entries,
&out_first_num_entries,
&first_data_size,
- isKernelVirtualAddress);
+ is_kva);
}
else {
@@ -2905,7 +2821,7 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
&in_first_mlli_address,
&in_first_num_entries,
&first_data_size,
- isKernelVirtualAddress);
+ is_kva);
}
if (error) {
@@ -2931,11 +2847,13 @@ end_function:
}
-/*
- this function handles tha request for creation of the DMA table
- for the synchronic symmetric operations (AES,DES)
- @sep: pointer to struct sep_device
- @arg: pointer to struct sep_driver_build_sync_table_t
+/**
+ * this function handles tha request for creation of the DMA table
+ * for the synchronic symmetric operations (AES,DES)
+ * Note that all bus addresses that are passed to the sep
+ * are in 32 bit format; the SEP is a 32 bit device
+ * @sep: pointer to struct sep_device
+ * @arg: pointer to struct bld_syn_tab_struc
*/
static int sep_create_sync_dma_tables_handler(struct sep_device *sep,
unsigned long arg)
@@ -2943,13 +2861,13 @@ static int sep_create_sync_dma_tables_handler(struct sep_device *sep,
int error = 0;
/* command arguments */
- struct sep_driver_build_sync_table_t command_args;
+ struct bld_syn_tab_struc command_args;
dev_dbg(&sep->pdev->dev,
"sep_create_sync_dma_tables_handler start\n");
- error = copy_from_user(&command_args, (void *)arg,
- sizeof(struct sep_driver_build_sync_table_t));
+ error = copy_from_user(&command_args, (void __user *)arg,
+ sizeof(struct bld_syn_tab_struc));
if (error) {
dev_warn(&sep->pdev->dev, "create dma tables;"
" copy_from_user fails\n");
@@ -2990,32 +2908,28 @@ end_function:
return error;
}
-/*
- This function frees the dma tables and dcb block
- @sep: pointer to struct sep_device
- @isApplet: indicates external application
- @isKernelVirtualAddress: indicates kernel addresses
-*/
-static int sep_free_dma_tables_and_dcb(struct sep_device *sep, bool isApplet,
- bool isKernelVirtualAddress)
+/**
+ * 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)
{
int i = 0;
int error = 0;
int error_temp = 0;
- struct sep_dcb_t *dcb_table_ptr;
-
- /*----------------
- CODE
- -----------------*/
+ struct sep_dcblock *dcb_table_ptr;
dev_dbg(&sep->pdev->dev, "sep_free_dma_tables_and_dcb start\n");
- if (isApplet == true) {
+ if (isapplet == true) {
/* set pointer to first dcb table */
- dcb_table_ptr = (struct sep_dcb_t *)
+ dcb_table_ptr = (struct sep_dcblock *)
(sep->shared_addr +
SEP_DRIVER_SYSTEM_DCB_MEMORY_OFFSET_IN_BYTES);
@@ -3024,7 +2938,7 @@ static int sep_free_dma_tables_and_dcb(struct sep_device *sep, bool isApplet,
if (dcb_table_ptr->out_vr_tail_pt) {
- if (isKernelVirtualAddress == true) {
+ if (is_kva == true) {
memcpy(dcb_table_ptr->out_vr_tail_pt,
dcb_table_ptr->tail_data,
dcb_table_ptr->tail_data_size);
@@ -3055,15 +2969,17 @@ static int sep_free_dma_tables_and_dcb(struct sep_device *sep, bool isApplet,
return error;
}
-/*
- this function sets the bus and virtual addresses of the static pool
- and returns the virtual address
-*/
+/**
+ * this function sets the bus and virtual addresses of the static pool
+ * and returns the virtual address
+ * @sep: pointer to struct sep_device
+ * @arg: parameters from user space application
+ */
static int sep_get_static_pool_addr_handler(struct sep_device *sep,
unsigned long arg)
{
int error = 0;
- struct sep_driver_static_pool_addr_t command_args;
+ struct stat_pool_addr_struc command_args;
u32 *static_pool_addr = 0;
@@ -3085,17 +3001,17 @@ static int sep_get_static_pool_addr_handler(struct sep_device *sep,
/* send the parameters to user application */
error = copy_to_user((void *) arg, &command_args,
- sizeof(struct sep_driver_static_pool_addr_t));
+ sizeof(struct stat_pool_addr_struc));
dev_dbg(&sep->pdev->dev, "sep_get_static_pool_addr_handler end\n");
return error;
}
-/*
- This function starts the sep device
- @sep: pointer to struct sep_device
-*/
+/**
+ * This function starts the sep device
+ * @sep: pointer to struct sep_device
+ */
static int sep_start_handler(struct sep_device *sep)
{
unsigned long reg_val;
@@ -3116,10 +3032,12 @@ static int sep_start_handler(struct sep_device *sep)
return error;
}
-/*
- This function performs a checsum for messages that are sent
- to the sep
-*/
+/**
+ * This function performs a checsum for messages that are sent
+ * to the sep
+ * @data:
+ * @length:
+ */
static u32 sep_check_sum_calc(u8 *data, u32 length)
{
u32 sum = 0;
@@ -3142,9 +3060,11 @@ static u32 sep_check_sum_calc(u8 *data, u32 length)
return ~sum & 0xFFFF;
}
-/*
- this function handles the request for SEP initialization
-*/
+/**
+ * this function handles the request for SEP initialization
+ * @sep: pointer to struct sep_device
+ * @arg: parameters from user space application
+ */
static int sep_init_handler(struct sep_device *sep, unsigned long arg)
{
u32 message_buff[14];
@@ -3152,7 +3072,7 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
int error = 0;
u32 reg_val;
dma_addr_t new_base_addr;
- struct sep_driver_init_t command_args;
+ struct init_stru command_args;
dev_dbg(&sep->pdev->dev, "sep_init_handler start\n");
error = 0;
@@ -3176,8 +3096,8 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
}
/* copy in the parameters */
- error = copy_from_user(&command_args, (void *) arg,
- sizeof(struct sep_driver_init_t));
+ error = copy_from_user(&command_args, (void __user *) arg,
+ sizeof(struct init_stru));
if (error) {
dev_warn(&sep->pdev->dev,
@@ -3301,16 +3221,12 @@ end_function:
return error;
}
-/*
- This API handles the end transaction request
- @sep: pointer to struct sep_device
-*/
+/**
+ * This API handles the end transaction request
+ * @sep: pointer to struct sep_device
+ */
static int sep_end_transaction_handler(struct sep_device *sep)
{
- /*----------------------------
- CODE
- -----------------------------*/
-
dev_dbg(&sep->pdev->dev, "sep_end_transaction_handler start\n");
/* clear the data pool pointers Token */
@@ -3323,7 +3239,14 @@ static int sep_end_transaction_handler(struct sep_device *sep)
clear_bit(SEP_MMAP_LOCK_BIT, &sep->in_use_flags);
+ /*
+ * we are now through with the transaction. Let's
+ * allow other processes who have the device open
+ * to perform transactions
+ */
+ mutex_lock(&sep->sep_mutex);
sep->pid_doing_transaction = 0;
+ mutex_unlock(&sep->sep_mutex);
/* raise event for stuck contextes */
wake_up(&sep->event);
@@ -3333,12 +3256,12 @@ static int sep_end_transaction_handler(struct sep_device *sep)
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
-*/
+/**
+ * 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)
{
@@ -3346,16 +3269,13 @@ static int sep_prepare_dcb_handler(struct sep_device *sep, unsigned long arg)
int error = 0;
/* command arguments */
- struct sep_driver_build_dcb_t command_args;
+ struct build_dcb_struc 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))) {
+ if (copy_from_user(&command_args, (void __user *)arg,
+ sizeof(struct build_dcb_struc))) {
dev_warn(&sep->pdev->dev,
"prepare dcb handler: copy_from_user failed\n");
@@ -3386,21 +3306,16 @@ end_function:
}
-/*
- this function frees the DCB resources
- and updates the needed user-space buffers
- @sep: pointer to struct sep_device
-*/
+/**
+ * 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);
@@ -3410,12 +3325,12 @@ static int sep_free_dcb_handler(struct sep_device *sep)
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
-*/
+/**
+ * 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)
@@ -3424,7 +3339,7 @@ static int sep_rar_prepare_output_msg_handler(struct sep_device *sep,
int error = 0;
/* command args */
- struct sep_driver_rar_handle_to_bus command_args;
+ struct rar_hndl_to_bus_stru command_args;
struct RAR_buffer rar_buf;
/* bus address */
@@ -3433,16 +3348,12 @@ static int sep_rar_prepare_output_msg_handler(struct sep_device *sep,
/* 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,
+ (void __user *)arg,
sizeof(command_args))) {
dev_warn(&sep->pdev->dev, "rar msg; copy from user error\n");
@@ -3486,22 +3397,23 @@ end_function:
return error;
}
-/*
- This function tells the sep where the extapp is located
- @sep: pointer to struct sep_device
- @arg: pointer to user parameters
-*/
+/**
+ * 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;
+ struct realloc_ext_struc 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))) {
+ 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");
@@ -3529,13 +3441,12 @@ end_function:
return error;
}
-
-/*
+/**
* Ioctl API
* @filp: pointer to struct file
* @cmd: command
* @arg: pointer to argument structure
-*/
+ */
static long sep_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
int error = 0;
@@ -3570,14 +3481,18 @@ static long sep_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
"SEP_IOCFREEDCB is %x\n", SEP_IOCFREEDCB);
/* make sure we own this device */
+ mutex_lock(&sep->sep_mutex);
if ((current->pid != sep->pid_doing_transaction) &&
(sep->pid_doing_transaction != 0)) {
dev_dbg(&sep->pdev->dev, "ioctl pid is not owner\n");
+ mutex_unlock(&sep->sep_mutex);
error = -EACCES;
goto end_function;
}
+ mutex_unlock(&sep->sep_mutex);
+
/* 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");
@@ -3587,12 +3502,12 @@ static long sep_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* lock access to ioctl because we don't
want the daemon to interfere with operation */
- mutex_lock(&ioctl_mutex);
+ mutex_lock(&sep->ioctl_mutex);
switch (cmd) {
case SEP_IOCSENDSEPCOMMAND:
/* send command to SEP */
- sep_send_command_handler(sep);
+ error = sep_send_command_handler(sep);
break;
case SEP_IOCALLOCDATAPOLL:
/* allocate data pool */
@@ -3641,7 +3556,7 @@ static long sep_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
break;
}
- mutex_unlock(&ioctl_mutex);
+ mutex_unlock(&sep->ioctl_mutex);
end_function:
@@ -3649,12 +3564,12 @@ end_function:
return error;
}
-/*
- singleton ioctl
+/**
+ * singleton ioctl
* @filp: pointer to struct file
* @cmd: command
* @arg: pointer to argument structure
-*/
+ */
static long sep_singleton_ioctl(struct file *filp, u32 cmd, unsigned long arg)
{
@@ -3662,9 +3577,6 @@ static long sep_singleton_ioctl(struct file *filp, u32 cmd, unsigned long arg)
long error;
struct sep_device *sep = filp->private_data;
- /*------------------------
- CODE
- ------------------------*/
error = 0;
dev_dbg(&sep->pdev->dev,
@@ -3681,21 +3593,25 @@ static long sep_singleton_ioctl(struct file *filp, u32 cmd, unsigned long arg)
}
/* make sure we own this device */
+ mutex_lock(&sep->sep_mutex);
if ((current->pid != sep->pid_doing_transaction) &&
(sep->pid_doing_transaction != 0)) {
dev_dbg(&sep->pdev->dev, "singleton ioctl pid is not owner\n");
+ mutex_unlock(&sep->sep_mutex);
error = -EACCES;
goto end_function;
}
+ mutex_unlock(&sep->sep_mutex);
+
switch (cmd) {
case SEP_IOCTLSETCALLERID:
- mutex_lock(&ioctl_mutex);
+ mutex_lock(&sep->ioctl_mutex);
error = sep_set_caller_id_handler(sep, arg);
- mutex_unlock(&ioctl_mutex);
+ mutex_unlock(&sep->ioctl_mutex);
break;
default:
@@ -3727,10 +3643,6 @@ static long sep_request_daemon_ioctl(struct file *filp, u32 cmd,
struct sep_device *sep = filp->private_data;
- /*------------------------
- CODE
- ------------------------*/
-
dev_dbg(&sep->pdev->dev,
"daemon ioctl: start\n");
@@ -3746,7 +3658,7 @@ static long sep_request_daemon_ioctl(struct file *filp, u32 cmd,
}
/* only one process can access ioctl at any given time */
- mutex_lock(&ioctl_mutex);
+ mutex_lock(&sep->ioctl_mutex);
switch (cmd) {
case SEP_IOCSENDSEPRPLYCOMMAND:
@@ -3757,8 +3669,12 @@ static long sep_request_daemon_ioctl(struct file *filp, u32 cmd,
case SEP_IOCENDTRANSACTION:
- /* end req daemon transaction, do nothing */
- error = sep_req_daemon_end_transaction_handler(sep, filp);
+ /*
+ * end req daemon transaction, do nothing
+ * will be removed upon update in middleware
+ * API library
+ */
+ error = 0;
break;
default:
@@ -3767,7 +3683,7 @@ static long sep_request_daemon_ioctl(struct file *filp, u32 cmd,
error = -ENOIOCTLCMD;
}
- mutex_unlock(&ioctl_mutex);
+ mutex_unlock(&sep->ioctl_mutex);
end_function:
@@ -3777,16 +3693,16 @@ end_function:
}
-#if !SEP_DRIVER_POLLING_MODE
-/*
- * Inerrupt Handler
+/**
+ * Interrupt Handler
* @irq: interrupt
* @dev_id: device id
-*/
+ */
static irqreturn_t sep_inthandler(int irq, void *dev_id)
{
irqreturn_t int_error = IRQ_HANDLED;
+ unsigned long lck_flags;
u32 reg_val, reg_val2 = 0;
struct sep_device *sep = dev_id;
@@ -3799,9 +3715,9 @@ static irqreturn_t sep_inthandler(int irq, void *dev_id)
/* update the counter of reply messages */
/* must be locked */
- spin_lock_irqsave(&snd_rply_lck, snd_rply_lck_flag);
+ spin_lock_irqsave(&sep->snd_rply_lck, lck_flags);
sep->reply_ct++;
- spin_unlock_irqrestore(&snd_rply_lck, snd_rply_lck_flag);
+ spin_unlock_irqrestore(&sep->snd_rply_lck, lck_flags);
dev_dbg(&sep->pdev->dev, "sep int: send_ct %lx reply_ct %lx\n",
sep->send_ct, sep->reply_ct);
@@ -3839,13 +3755,11 @@ static irqreturn_t sep_inthandler(int irq, void *dev_id)
return int_error;
}
-#endif
-
-/*
- Function that is called by rar_register when it is ready with
- a region (only for Moorestown)
- @sep_context_pointer: pointer to struct sep_device
-*/
+/**
+ * Function that is called by rar_register when it is ready with
+ * a region (only for Moorestown)
+ * @sep_context_pointer: pointer to struct sep_device
+ */
static int sep_callback(unsigned long sep_context_pointer)
{
int error = 0;
@@ -3894,9 +3808,11 @@ end_function:
return error;
}
-/*
- Function that is activated on the successful probe of the SEP device
-*/
+/**
+ * Function that is activated on the successful probe of the SEP device
+ * @pdev: pci_device
+ * @end: pci_device_id
+ */
static int __devinit sep_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
@@ -3916,12 +3832,24 @@ static int __devinit sep_probe(struct pci_dev *pdev,
goto end_function;
}
+ /* allocate the sep_device structure for this device */
+ sep_dev = kmalloc(sizeof(struct sep_device), GFP_ATOMIC);
+
+ if (sep_dev == NULL) {
+ dev_warn(&pdev->dev,
+ "can't kmalloc the sep_device structure\n");
+ return -ENOMEM;
+ }
+
/* zero out sep structure */
- memset((void *)&sep_instance, 0, sizeof(sep_instance));
+ memset((void *)sep_dev, 0, sizeof(struct sep_device));
- /* set the pci dev pointer */
- sep_dev = &sep_instance;
- sep = &sep_instance;
+ /* we're going to use another variable for actually
+ * working with the device; this way, if we have
+ * multiple devices in the future, it would be easier
+ * to make appropriate changes
+ */
+ sep = sep_dev;
sep->pdev = pdev;
@@ -3998,6 +3926,7 @@ 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) {
@@ -4005,8 +3934,11 @@ static int __devinit sep_probe(struct pci_dev *pdev,
"error register_rar\n");
goto end_function_deallocate_sep_shared_area;
}
- } else {
- sep->rar_size = FAKE_RAR_SIZE;
+ }
+
+ else {
+
+ sep->rar_size = FAKE_RAR_SIZE;
sep->rar_addr = dma_alloc_coherent(NULL,
sep->rar_size, &sep->rar_bus, GFP_KERNEL);
if (sep->rar_addr == NULL) {
@@ -4020,8 +3952,6 @@ static int __devinit sep_probe(struct pci_dev *pdev,
sep->probed = 1;
}
-#if !SEP_DRIVER_POLLING_MODE
-
dev_dbg(&sep->pdev->dev,
"about to write IMR and ICR REG_ADDR\n");
@@ -4040,16 +3970,13 @@ static int __devinit sep_probe(struct pci_dev *pdev,
if (error)
goto end_function_free_res;
- dev_dbg(&sep->pdev->dev,
- "about to write IMR REG_ADDR");
-
- /* set the IMR register - open only GPR 2 */
- sep_write_reg(sep, HW_HOST_IMR_REG_ADDR, (~(0x1 << 13)));
+ goto end_function;
end_function_free_res:
- dma_free_coherent(&sep->pdev->dev, 2 * SEP_RAR_IO_MEM_REGION_SIZE,
+
+ if (sep->rar_addr)
+ dma_free_coherent(&sep->pdev->dev, sep->rar_size,
sep->rar_addr, sep->rar_bus);
-#endif /* SEP_DRIVER_POLLING_MODE */
goto end_function;
@@ -4059,6 +3986,7 @@ end_function_deallocate_sep_shared_area:
end_function_error:
iounmap(sep->reg_addr);
+ kfree(sep_dev);
sep_dev = NULL;
end_function:
@@ -4111,108 +4039,64 @@ static const struct file_operations sep_file_operations = {
.mmap = sep_mmap,
};
-/*
- this function registers the driver to the file system
-*/
+/**
+ * This function registers the driver to the file system
+ * @sep: pointer to struct sep_device
+ */
static int sep_register_driver_to_fs(struct sep_device *sep)
{
- int ret_val;
- int major;
+ int ret_val = 0;
- if (sep->mrst)
- ret_val = alloc_chrdev_region(&sep->sep_devno,
- 0, 2, "sep_sec_driver");
- else
- ret_val = alloc_chrdev_region(&sep->sep_devno,
- 0, 3, "sep_sec_driver");
+ sep->miscdev_sep.minor = MISC_DYNAMIC_MINOR;
+ sep->miscdev_sep.name = SEP_DEV_NAME;
+ sep->miscdev_sep.fops = &sep_file_operations;
- if (ret_val) {
- dev_warn(&sep->pdev->dev,
- "sep - major number allocation failed, retval is %d\n",
- ret_val);
- return ret_val;
- }
+ sep->miscdev_singleton.minor = MISC_DYNAMIC_MINOR;
+ sep->miscdev_singleton.name = SEP_DEV_SINGLETON;
+ sep->miscdev_singleton.fops = &singleton_file_operations;
- major = MAJOR(sep->sep_devno);
+ sep->miscdev_daemon.minor = MISC_DYNAMIC_MINOR;
+ sep->miscdev_daemon.name = SEP_DEV_DAEMON;
+ sep->miscdev_daemon.fops = &daemon_file_operations;
- /* for the sep device itself */
- /* init cdev */
- cdev_init(&sep->sep_cdev, &sep_file_operations);
- sep->sep_cdev.owner = THIS_MODULE;
-
- /* register the driver with the kernel */
- ret_val = cdev_add(&sep->sep_cdev, sep->sep_devno, 1);
+ ret_val = misc_register(&sep->miscdev_sep);
if (ret_val) {
- dev_warn(&sep->pdev->dev,
- "sep - cdev_add failed, retval is %d\n", ret_val);
- /* unregister dev numbers */
- goto end_function_unregister_devnum;
+ dev_warn(&sep->pdev->dev, "misc reg fails for sep %x\n",
+ ret_val);
+ return ret_val;
}
- /* for the sep daemon port */
- major = MAJOR(sep->sep_devno);
- sep->sep_daemon_devno = MKDEV(major, 2);
- cdev_init(&sep->sep_daemon_cdev, &daemon_file_operations);
-
- sep->sep_daemon_cdev.owner = THIS_MODULE;
-
- ret_val = cdev_add(&sep->sep_daemon_cdev, sep->sep_daemon_devno, 1);
+ ret_val = misc_register(&sep->miscdev_singleton);
if (ret_val) {
- dev_warn(&sep->pdev->dev,
- "sep daemon - cdev_add failed, retval is %d\n",
+ dev_warn(&sep->pdev->dev, "misc reg fails for sing %x\n",
ret_val);
- /* unregister dev numbers */
- cdev_del(&sep->sep_cdev);
- goto end_function_unregister_devnum;
+ misc_deregister(&sep->miscdev_sep);
+ return ret_val;
}
- major = MAJOR(sep->sep_devno);
- sep->sep_singleton_devno = MKDEV(major, 1);
- cdev_init(&sep->sep_singleton_cdev, &singleton_file_operations);
-
- sep->sep_singleton_cdev.owner = THIS_MODULE;
-
- if (sep->mrst == 0) {
-
- ret_val = cdev_add(&sep->sep_singleton_cdev,
- sep->sep_singleton_devno, 1);
+ if (!sep->mrst) {
+ ret_val = misc_register(&sep->miscdev_daemon);
if (ret_val) {
dev_warn(&sep->pdev->dev,
- "sep singleton -"
- " cdev_add failed, retval is %d\n",
+ "misc reg fails for dmn %x\n",
ret_val);
- /* unregister dev numbers */
- cdev_del(&sep->sep_cdev);
- cdev_del(&sep->sep_daemon_cdev);
- goto end_function_unregister_devnum;
- }
+ misc_deregister(&sep->miscdev_sep);
+ misc_deregister(&sep->miscdev_singleton);
+ return ret_val;
+ }
}
- goto end_function;
-
-end_function_unregister_devnum:
-
- if (sep->mrst)
- unregister_chrdev_region(sep->sep_devno, 2);
- else
- unregister_chrdev_region(sep->sep_devno, 3);
-
-end_function:
-
return ret_val;
}
-
-/*--------------------------------------------------------------
- init function
-----------------------------------------------------------------*/
+/**
+ * init function
+ */
static int __init sep_init(void)
{
int ret_val = 0;
- struct sep_device *sep;
-
- sep = &sep_instance;
+ struct sep_device *sep = NULL;
pr_debug("Sep driver: Init start\n");
@@ -4223,8 +4107,13 @@ static int __init sep_init(void)
goto end_function;
}
+ sep = sep_dev;
+
init_waitqueue_head(&sep->event);
init_waitqueue_head(&sep->event_request_daemon);
+ spin_lock_init(&sep->snd_rply_lck);
+ mutex_init(&sep->sep_mutex);
+ mutex_init(&sep->ioctl_mutex);
if (sep->mrst == 0) {
ret_val = sep_init_caller_id(sep);
@@ -4255,14 +4144,14 @@ end_function:
}
-/*-------------------------------------------------------------
- exit function
---------------------------------------------------------------*/
+/**
+ * exit function
+ */
static void __exit sep_exit(void)
{
struct sep_device *sep;
- sep = &sep_instance;
+ sep = sep_dev;
pr_debug("Exit start\n");
/* unregister from fs */
diff --git a/drivers/staging/sep/sep_driver_api.h b/drivers/staging/sep/sep_driver_api.h
index cdebc217cc9..03986767033 100644
--- a/drivers/staging/sep/sep_driver_api.h
+++ b/drivers/staging/sep/sep_driver_api.h
@@ -42,41 +42,47 @@
----------------------------------------------*/
/*
+ * Note that several members of these structres are only here
+ * for campatability with the middleware; they are not used
+ * by this driver.
+ */
+
+/*
init command struct
*/
-struct sep_driver_init_t {
- /* start of the 1G of the host memory address that SEP can access */
+struct init_stru {
+ /* -not used- address that SEP can access */
u32 *message_addr;
- /* start address of resident */
+ /* -not used- start address of resident */
u32 message_size_in_words;
/* offset of the init message in the sep sram */
u32 sep_sram_addr;
- /* resident size in bytes*/
+ /* -not used- resident size in bytes*/
u32 resident_size_in_bytes;
- /* cache size in bytes*/
+ /* -not used- cache size in bytes*/
u32 cache_size_in_bytes;
- /* ext cache current address */
+ /* -not used- ext cache current address */
void *extcache_addr;
- /* ext cache size in bytes*/
+ /* -not used- ext cache size in bytes*/
u32 extcache_size_in_bytes;
};
-struct sep_driver_realloc_ext_cache_t {
- /* current external cache address */
+struct realloc_ext_struc {
+ /* -not used- current external cache address */
void *ext_cache_addr;
- /* external cache size in bytes*/
+ /* -not used- external cache size in bytes*/
u32 ext_cache_size_in_bytes;
};
-struct sep_driver_alloc_t {
- /* virtual address of allocated space */
+struct alloc_struct {
+ /* offset from start of shared pool area */
u32 offset;
/* number of bytes to allocate */
@@ -85,49 +91,40 @@ struct sep_driver_alloc_t {
/*
*/
-struct sep_driver_build_sync_table_t {
- /* address value of the data in */
+struct bld_syn_tab_struc {
+ /* address value of the data in (user space addr) */
unsigned long app_in_address;
/* size of data in */
u32 data_in_size;
- /* address of the data out */
+ /* 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;
- /* distinct user/kernel layout */
+ /* -not used- distinct user/kernel layout */
bool isKernelVirtualAddress;
};
/* command struct for static pool addresses */
-struct sep_driver_static_pool_addr_t {
+struct stat_pool_addr_struc {
/* virtual address of the static pool */
void *static_virt_address;
};
-/* command struct for getiing offset of the physical address from
- the start of the mapped area */
-struct sep_driver_get_mapped_offset_t {
- /* physical address of the static pool */
- unsigned long physical_address;
-
- /* virtual address of the static pool */
- u32 offset;
-};
/* command struct for getting time value and address */
-struct sep_driver_set_caller_id_t {
+struct caller_id_stru {
/* pid of the process */
u32 pid;
/* virtual address of the caller id hash */
- void *callerIdAddress;
+ void *callerIdAddress;
/* caller id hash size in bytes */
u32 callerIdSizeInBytes;
@@ -136,7 +133,7 @@ struct sep_driver_set_caller_id_t {
/*
structure that represents DCB
*/
-struct sep_dcb_t {
+struct sep_dcblock {
/* physical address of the first input mlli */
u32 input_mlli_address;
@@ -173,7 +170,7 @@ struct sep_caller_id_entry {
/*
command structure for building dcb block (currently for ext app only
*/
-struct sep_driver_build_dcb_t {
+struct build_dcb_struc {
/* address value of the data in */
unsigned long app_in_address;
@@ -240,7 +237,7 @@ struct sep_dma_resource {
/* command struct for translating rar handle to bus address
and setting it at predefined location */
-struct sep_driver_rar_handle_to_bus {
+struct rar_hndl_to_bus_stru {
/* rar handle */
void *rar_handle;
@@ -249,7 +246,7 @@ struct sep_driver_rar_handle_to_bus {
/*
structure that represent one entry in the DMA LLI table
*/
-struct sep_lli_entry_t {
+struct sep_lli_entry {
/* physical address */
u32 bus_address;
@@ -274,11 +271,11 @@ struct sep_lli_entry_t {
/* allocate memory in data pool */
#define SEP_IOCALLOCDATAPOLL \
- _IOW(SEP_IOC_MAGIC_NUMBER, 2, struct sep_driver_alloc_t)
+ _IOW(SEP_IOC_MAGIC_NUMBER, 2, struct alloc_struct)
/* create sym dma lli tables */
#define SEP_IOCCREATESYMDMATABLE \
- _IOW(SEP_IOC_MAGIC_NUMBER, 5, struct sep_driver_build_sync_table_t)
+ _IOW(SEP_IOC_MAGIC_NUMBER, 5, struct bld_syn_tab_struc)
/* free dynamic data aalocated during table creation */
#define SEP_IOCFREEDMATABLEDATA \
@@ -286,7 +283,7 @@ struct sep_lli_entry_t {
/* get the static pool area addersses (physical and virtual) */
#define SEP_IOCGETSTATICPOOLADDR \
- _IOR(SEP_IOC_MAGIC_NUMBER, 8, struct sep_driver_static_pool_addr_t)
+ _IOR(SEP_IOC_MAGIC_NUMBER, 8, struct stat_pool_addr_struc)
/* set flow id command */
#define SEP_IOCSETFLOWID \
@@ -306,7 +303,7 @@ struct sep_lli_entry_t {
/* init sep command */
#define SEP_IOCSEPINIT \
- _IOW(SEP_IOC_MAGIC_NUMBER, 13, struct sep_driver_init_t)
+ _IOW(SEP_IOC_MAGIC_NUMBER, 13, struct init_stru)
/* end transaction command */
#define SEP_IOCENDTRANSACTION \
@@ -314,10 +311,10 @@ struct sep_lli_entry_t {
/* reallocate external app */
#define SEP_IOCREALLOCEXTCACHE \
- _IOW(SEP_IOC_MAGIC_NUMBER, 18, struct sep_driver_realloc_ext_cache_t)
+ _IOW(SEP_IOC_MAGIC_NUMBER, 18, struct realloc_ext_struc)
#define SEP_IOCRARPREPAREMESSAGE \
- _IOW(SEP_IOC_MAGIC_NUMBER, 20, struct sep_driver_rar_handle_to_bus)
+ _IOW(SEP_IOC_MAGIC_NUMBER, 20, struct rar_hndl_to_bus_stru)
#define SEP_IOCTLSINGLETONLOCK \
_IO(SEP_IOC_MAGIC_NUMBER, 32)
@@ -326,10 +323,10 @@ struct sep_lli_entry_t {
_IO(SEP_IOC_MAGIC_NUMBER, 33)
#define SEP_IOCTLSETCALLERID \
- _IOW(SEP_IOC_MAGIC_NUMBER, 34, struct sep_driver_set_caller_id_t)
+ _IOW(SEP_IOC_MAGIC_NUMBER, 34, struct caller_id_stru)
#define SEP_IOCPREPAREDCB \
- _IOW(SEP_IOC_MAGIC_NUMBER, 35, struct sep_driver_build_dcb_t)
+ _IOW(SEP_IOC_MAGIC_NUMBER, 35, struct build_dcb_struc)
#define SEP_IOCFREEDCB \
_IO(SEP_IOC_MAGIC_NUMBER, 36)
diff --git a/drivers/staging/sep/sep_driver_config.h b/drivers/staging/sep/sep_driver_config.h
index 76edb3ae591..cf0095d1b4b 100644
--- a/drivers/staging/sep/sep_driver_config.h
+++ b/drivers/staging/sep/sep_driver_config.h
@@ -98,6 +98,9 @@ held by the proccess (struct file) */
TIME_MEMORY_AREA 8B
-----------------------------------------------------------*/
+#define SEP_DEV_NAME "sep_sec_driver"
+#define SEP_DEV_SINGLETON "sep_sec_singleton_driver"
+#define SEP_DEV_DAEMON "sep_req_daemon_driver"
/*
@@ -226,28 +229,4 @@ held by the proccess (struct file) */
/* the token that defines the data pool pointers address */
#define SEP_EXT_CACHE_ADDR_VAL_TOKEN 0xBABABABA
-/*
-#define SEP_DEBUG_LEVEL_BASIC 0x1
-
-#define SEP_DEBUG_LEVEL_EXTENDED 0x4
-
-*/
-
-/* Debug helpers */
-
-/*
-#define dbg(fmt, args...) \
-do {\
- if (debug & SEP_DEBUG_LEVEL_BASIC) \
- printk(KERN_DEBUG fmt, ##args); \
-} while(0);
-
-#define edbg(fmt, args...) \
-do { \
- if (debug & SEP_DEBUG_LEVEL_EXTENDED) \
- printk(KERN_DEBUG fmt, ##args); \
-} while(0);
-
-*/
-
-#endif
+#endif /* SEP DRIVER CONFIG */