Commit d19cf32f authored by Alan Cox's avatar Alan Cox Committed by Greg Kroah-Hartman

Staging: sep: indent pass

Ok time to indent and get the code in vague shape. No other changes in this
patch.
Signed-off-by: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 46eb5a13
...@@ -121,9 +121,8 @@ static inline void sep_wait_sram_write(struct sep_device *dev) ...@@ -121,9 +121,8 @@ static inline void sep_wait_sram_write(struct sep_device *dev)
u32 reg_val; u32 reg_val;
do do
reg_val = sep_read_reg(dev, HW_SRAM_DATA_READY_REG_ADDR); reg_val = sep_read_reg(dev, HW_SRAM_DATA_READY_REG_ADDR);
while(!(reg_val & 1)); while (!(reg_val & 1));
} }
#endif #endif
...@@ -125,13 +125,13 @@ struct sep_driver_realloc_cache_resident_t { ...@@ -125,13 +125,13 @@ struct sep_driver_realloc_cache_resident_t {
/* current cache address */ /* current cache address */
unsigned long cache_addr; unsigned long cache_addr;
/* cache size in bytes*/ /* cache size in bytes */
unsigned long cache_size_in_bytes; unsigned long cache_size_in_bytes;
/* current resident address */ /* current resident address */
unsigned long resident_addr; unsigned long resident_addr;
/* resident size in bytes*/ /* resident size in bytes */
unsigned long resident_size_in_bytes; unsigned long resident_size_in_bytes;
/* new cache address */ /* new cache address */
...@@ -374,7 +374,7 @@ struct sep_lli_prepare_table_data_t { ...@@ -374,7 +374,7 @@ struct sep_lli_prepare_table_data_t {
*/ */
struct sep_lli_table_t { struct sep_lli_table_t {
/* number of pages mapped in this tables. If 0 - means that the table /* number of pages mapped in this tables. If 0 - means that the table
is not defined (used as a valid flag)*/ is not defined (used as a valid flag) */
unsigned long num_pages; unsigned long num_pages;
/* /*
pointer to array of page pointers that represent the mapping of the pointer to array of page pointers that represent the mapping of the
...@@ -478,26 +478,18 @@ void sep_send_msg_rdy_cmd(void); ...@@ -478,26 +478,18 @@ void sep_send_msg_rdy_cmd(void);
This function releases all the application virtual This function releases all the application virtual
buffer physical pages, that were previously locked buffer physical pages, that were previously locked
*/ */
int sep_free_dma_pages(struct page **page_array_ptr, int sep_free_dma_pages(struct page **page_array_ptr, unsigned long num_pages, unsigned long dirtyFlag);
unsigned long num_pages,
unsigned long dirtyFlag);
/* /*
This function creates the input and output dma tables for This function creates the input and output dma tables for
symmetric operations (AES/DES) according to the block size symmetric operations (AES/DES) according to the block size
from LLI arays from LLI arays
*/ */
int sep_construct_dma_tables_from_lli( int sep_construct_dma_tables_from_lli(struct sep_lli_entry_t *lli_in_array,
struct sep_lli_entry_t *lli_in_array,
unsigned long sep_in_lli_entries, unsigned long sep_in_lli_entries,
struct sep_lli_entry_t *lli_out_array, struct sep_lli_entry_t *lli_out_array,
unsigned long sep_out_lli_entries, unsigned long sep_out_lli_entries,
unsigned long block_size, unsigned long block_size, unsigned long *lli_table_in_ptr, unsigned long *lli_table_out_ptr, unsigned long *in_num_entries_ptr, unsigned long *out_num_entries_ptr, unsigned long *table_data_size_ptr);
unsigned long *lli_table_in_ptr,
unsigned long *lli_table_out_ptr,
unsigned long *in_num_entries_ptr,
unsigned long *out_num_entries_ptr,
unsigned long *table_data_size_ptr);
/* /*
This function builds input and output DMA tables for synhronic symmetric This function builds input and output DMA tables for synhronic symmetric
...@@ -508,24 +500,13 @@ int sep_prepare_input_output_dma_table(unsigned long app_virt_in_addr, ...@@ -508,24 +500,13 @@ int sep_prepare_input_output_dma_table(unsigned long app_virt_in_addr,
unsigned long app_virt_out_addr, unsigned long app_virt_out_addr,
unsigned long data_size, unsigned long data_size,
unsigned long block_size, unsigned long block_size,
unsigned long *lli_table_in_ptr, unsigned long *lli_table_in_ptr, unsigned long *lli_table_out_ptr, unsigned long *in_num_entries_ptr, unsigned long *out_num_entries_ptr, unsigned long *table_data_size_ptr, bool isKernelVirtualAddress);
unsigned long *lli_table_out_ptr,
unsigned long *in_num_entries_ptr,
unsigned long *out_num_entries_ptr,
unsigned long *table_data_size_ptr,
bool isKernelVirtualAddress);
/* /*
This function prepares only input DMA table for synhronic symmetric This function prepares only input DMA table for synhronic symmetric
operations (HASH) operations (HASH)
*/ */
int sep_prepare_input_dma_table(unsigned long app_virt_addr, int sep_prepare_input_dma_table(unsigned long app_virt_addr, unsigned long data_size, unsigned long block_size, unsigned long *lli_table_ptr, unsigned long *num_entries_ptr, unsigned long *table_data_size_ptr, bool isKernelVirtualAddress);
unsigned long data_size,
unsigned long block_size,
unsigned long *lli_table_ptr,
unsigned long *num_entries_ptr,
unsigned long *table_data_size_ptr,
bool isKernelVirtualAddress);
/* this functions frees all the resources that were allocated for the building /* this functions frees all the resources that were allocated for the building
of the LLI DMA tables */ of the LLI DMA tables */
......
...@@ -51,12 +51,7 @@ This functions copies the cache and resident from their source location into ...@@ -51,12 +51,7 @@ This functions copies the cache and resident from their source location into
destination memory, which is external to Linux VM and is given as physical destination memory, which is external to Linux VM and is given as physical
address address
*/ */
int sep_copy_cache_resident_to_area(unsigned long src_cache_addr, int sep_copy_cache_resident_to_area(unsigned long src_cache_addr, unsigned long cache_size_in_bytes, unsigned long src_resident_addr, unsigned long resident_size_in_bytes, unsigned long *dst_new_cache_addr_ptr, unsigned long *dst_new_resident_addr_ptr);
unsigned long cache_size_in_bytes,
unsigned long src_resident_addr,
unsigned long resident_size_in_bytes,
unsigned long *dst_new_cache_addr_ptr,
unsigned long *dst_new_resident_addr_ptr);
/* /*
This functions maps and allocates the shared area on the external This functions maps and allocates the shared area on the external
...@@ -65,9 +60,7 @@ to allocate. The outputs are kernel_shared_area_addr_ptr - the kerenl ...@@ -65,9 +60,7 @@ to allocate. The outputs are kernel_shared_area_addr_ptr - the kerenl
address of the mapped and allocated shared area, and address of the mapped and allocated shared area, and
phys_shared_area_addr_ptr - the physical address of the shared area phys_shared_area_addr_ptr - the physical address of the shared area
*/ */
int sep_map_and_alloc_shared_area(unsigned long shared_area_size, int sep_map_and_alloc_shared_area(unsigned long shared_area_size, unsigned long *kernel_shared_area_addr_ptr, unsigned long *phys_shared_area_addr_ptr);
unsigned long *kernel_shared_area_addr_ptr,
unsigned long *phys_shared_area_addr_ptr);
/* /*
This functions unmaps and deallocates the shared area on the external This functions unmaps and deallocates the shared area on the external
...@@ -76,9 +69,7 @@ deallocate,kernel_shared_area_addr_ptr - the kernel address of the ...@@ -76,9 +69,7 @@ deallocate,kernel_shared_area_addr_ptr - the kernel address of the
mapped and allocated shared area,phys_shared_area_addr_ptr - the physical mapped and allocated shared area,phys_shared_area_addr_ptr - the physical
address of the shared area address of the shared area
*/ */
void sep_unmap_and_free_shared_area(unsigned long shared_area_size, void sep_unmap_and_free_shared_area(unsigned long shared_area_size, unsigned long kernel_shared_area_addr, unsigned long phys_shared_area_addr);
unsigned long kernel_shared_area_addr,
unsigned long phys_shared_area_addr);
/* /*
......
...@@ -90,7 +90,7 @@ static unsigned long CRYS_SEP_ROM[] = { ...@@ -90,7 +90,7 @@ static unsigned long CRYS_SEP_ROM[] = {
#define BASE_ADDRESS_FOR_SYSTEM 0xfffc0000 #define BASE_ADDRESS_FOR_SYSTEM 0xfffc0000
#define SEP_RAR_IO_MEM_REGION_SIZE 0x40000 #define SEP_RAR_IO_MEM_REGION_SIZE 0x40000
irqreturn_t sep_inthandler(int irq , void* dev_id); irqreturn_t sep_inthandler(int irq, void *dev_id);
/* Keep this a single static object for now to keep the conversion easy */ /* Keep this a single static object for now to keep the conversion easy */
...@@ -107,12 +107,11 @@ unsigned long jiffies_future; ...@@ -107,12 +107,11 @@ unsigned long jiffies_future;
/* /*
function that is activated on the succesfull probe of the SEP device function that is activated on the succesfull probe of the SEP device
*/ */
static int __devinit sep_probe(struct pci_dev *pdev, static int __devinit sep_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
const struct pci_device_id *ent);
static struct pci_device_id sep_pci_id_tbl[] = { static struct pci_device_id sep_pci_id_tbl[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x080c) }, {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x080c)},
{ 0 } {0}
}; };
MODULE_DEVICE_TABLE(pci, sep_pci_id_tbl); MODULE_DEVICE_TABLE(pci, sep_pci_id_tbl);
...@@ -141,12 +140,7 @@ void sep_lock_cache_resident_area(void) ...@@ -141,12 +140,7 @@ void sep_lock_cache_resident_area(void)
destination memory, which is external to Linux VM and is given as destination memory, which is external to Linux VM and is given as
physical address physical address
*/ */
int sep_copy_cache_resident_to_area(unsigned long src_cache_addr, int sep_copy_cache_resident_to_area(unsigned long src_cache_addr, unsigned long cache_size_in_bytes, unsigned long src_resident_addr, unsigned long resident_size_in_bytes, unsigned long *dst_new_cache_addr_ptr, unsigned long *dst_new_resident_addr_ptr)
unsigned long cache_size_in_bytes,
unsigned long src_resident_addr,
unsigned long resident_size_in_bytes,
unsigned long *dst_new_cache_addr_ptr,
unsigned long *dst_new_resident_addr_ptr)
{ {
/* resident address in user space */ /* resident address in user space */
unsigned long resident_addr; unsigned long resident_addr;
...@@ -167,14 +161,10 @@ int sep_copy_cache_resident_to_area(unsigned long src_cache_addr, ...@@ -167,14 +161,10 @@ int sep_copy_cache_resident_to_area(unsigned long src_cache_addr,
-------------------------------------*/ -------------------------------------*/
error = 0; error = 0;
edbg( edbg("SEP Driver:rar_virtual is %p\n", sep_dev->rar_virtual_address);
"SEP Driver:rar_virtual is %p\n", edbg("SEP Driver:rar_physical is %08lx\n", sep_dev->rar_physical_address);
sep_dev->rar_virtual_address);
edbg(
"SEP Driver:rar_physical is %08lx\n",
sep_dev->rar_physical_address);
sep_dev->rar_region_addr = (unsigned long)sep_dev->rar_virtual_address; sep_dev->rar_region_addr = (unsigned long) sep_dev->rar_virtual_address;
sep_dev->cache_physical_address = sep_dev->rar_physical_address; sep_dev->cache_physical_address = sep_dev->rar_physical_address;
sep_dev->cache_virtual_address = sep_dev->rar_virtual_address; sep_dev->cache_virtual_address = sep_dev->rar_virtual_address;
...@@ -182,72 +172,50 @@ int sep_copy_cache_resident_to_area(unsigned long src_cache_addr, ...@@ -182,72 +172,50 @@ int sep_copy_cache_resident_to_area(unsigned long src_cache_addr,
/* load cache */ /* load cache */
error = request_firmware(&fw, cache_name, &sep_dev->sep_pci_dev_ptr->dev); error = request_firmware(&fw, cache_name, &sep_dev->sep_pci_dev_ptr->dev);
if (error) { if (error) {
edbg( edbg("SEP Driver:cant request cache fw\n");
"SEP Driver:cant request cache fw\n");
goto end_function; goto end_function;
} }
edbg( edbg("SEP Driver:cache data loc is %p\n", (void *) fw->data);
"SEP Driver:cache data loc is %p\n", edbg("SEP Driver:cache data size is %08Zx\n", fw->size);
(void *)fw->data);
edbg(
"SEP Driver:cache data size is %08Zx\n",
fw->size);
memcpy((void *)sep_dev->cache_virtual_address, (void *)fw->data, fw->size); memcpy((void *) sep_dev->cache_virtual_address, (void *) fw->data, fw->size);
sep_dev->cache_size = fw->size; sep_dev->cache_size = fw->size;
cache_addr = (unsigned long)sep_dev->cache_virtual_address; cache_addr = (unsigned long) sep_dev->cache_virtual_address;
release_firmware(fw); release_firmware(fw);
sep_dev->resident_physical_address = sep_dev->cache_physical_address sep_dev->resident_physical_address = sep_dev->cache_physical_address + sep_dev->cache_size;
+ sep_dev->cache_size; sep_dev->resident_virtual_address = sep_dev->cache_virtual_address + sep_dev->cache_size;
sep_dev->resident_virtual_address = sep_dev->cache_virtual_address
+ sep_dev->cache_size;
/* load resident */ /* load resident */
error = request_firmware(&fw, res_name, &sep_dev->sep_pci_dev_ptr->dev); error = request_firmware(&fw, res_name, &sep_dev->sep_pci_dev_ptr->dev);
if (error) { if (error) {
edbg( edbg("SEP Driver:cant request res fw\n");
"SEP Driver:cant request res fw\n");
goto end_function; goto end_function;
} }
edbg( edbg("SEP Driver:res data loc is %p\n", (void *) fw->data);
"SEP Driver:res data loc is %p\n", edbg("SEP Driver:res data size is %08Zx\n", fw->size);
(void *)fw->data);
edbg(
"SEP Driver:res data size is %08Zx\n",
fw->size);
memcpy((void *)sep_dev->resident_virtual_address, (void *)fw->data, fw->size); memcpy((void *) sep_dev->resident_virtual_address, (void *) fw->data, fw->size);
sep_dev->resident_size = fw->size; sep_dev->resident_size = fw->size;
release_firmware(fw); release_firmware(fw);
resident_addr = (unsigned long)sep_dev->resident_virtual_address; resident_addr = (unsigned long) sep_dev->resident_virtual_address;
edbg( edbg("SEP Driver:resident_addr (physical )is %08lx\n", sep_dev->resident_physical_address);
"SEP Driver:resident_addr (physical )is %08lx\n", edbg("SEP Driver:cache_addr (physical) is %08lx\n", sep_dev->cache_physical_address);
sep_dev->resident_physical_address);
edbg(
"SEP Driver:cache_addr (physical) is %08lx\n",
sep_dev->cache_physical_address);
edbg( edbg("SEP Driver:resident_addr (logical )is %08lx\n", resident_addr);
"SEP Driver:resident_addr (logical )is %08lx\n", edbg("SEP Driver:cache_addr (logical) is %08lx\n", cache_addr);
resident_addr);
edbg(
"SEP Driver:cache_addr (logical) is %08lx\n",
cache_addr);
edbg( edbg("SEP Driver:resident_size is %08lx\n", sep_dev->resident_size);
"SEP Driver:resident_size is %08lx\n", sep_dev->resident_size); edbg("SEP Driver:cache_size is %08lx\n", sep_dev->cache_size);
edbg(
"SEP Driver:cache_size is %08lx\n", sep_dev->cache_size);
...@@ -255,7 +223,7 @@ int sep_copy_cache_resident_to_area(unsigned long src_cache_addr, ...@@ -255,7 +223,7 @@ int sep_copy_cache_resident_to_area(unsigned long src_cache_addr,
*dst_new_cache_addr_ptr = sep_dev->cache_physical_address; *dst_new_cache_addr_ptr = sep_dev->cache_physical_address;
*dst_new_resident_addr_ptr = sep_dev->resident_physical_address; *dst_new_resident_addr_ptr = sep_dev->resident_physical_address;
end_function: end_function:
return error; return error;
} }
...@@ -270,15 +238,12 @@ int sep_copy_cache_resident_to_area(unsigned long src_cache_addr, ...@@ -270,15 +238,12 @@ int sep_copy_cache_resident_to_area(unsigned long src_cache_addr,
shared area, and phys_shared_area_addr_ptr shared area, and phys_shared_area_addr_ptr
- the physical address of the shared area - the physical address of the shared area
*/ */
int sep_map_and_alloc_shared_area(unsigned long shared_area_size, int sep_map_and_alloc_shared_area(unsigned long shared_area_size, unsigned long *kernel_shared_area_addr_ptr, unsigned long *phys_shared_area_addr_ptr)
unsigned long *kernel_shared_area_addr_ptr,
unsigned long *phys_shared_area_addr_ptr)
{ {
// shared_virtual_address = ioremap_nocache(0xda00000,shared_area_size); // shared_virtual_address = ioremap_nocache(0xda00000,shared_area_size);
sep_dev->shared_virtual_address = kmalloc(shared_area_size, GFP_KERNEL); sep_dev->shared_virtual_address = kmalloc(shared_area_size, GFP_KERNEL);
if (!sep_dev->shared_virtual_address) { if (!sep_dev->shared_virtual_address) {
edbg( edbg("sep_driver:shared memory kmalloc failed\n");
"sep_driver:shared memory kmalloc failed\n");
return -1; return -1;
} }
...@@ -286,19 +251,13 @@ int sep_map_and_alloc_shared_area(unsigned long shared_area_size, ...@@ -286,19 +251,13 @@ int sep_map_and_alloc_shared_area(unsigned long shared_area_size,
sep_dev->shared_physical_address = __pa(sep_dev->shared_virtual_address); sep_dev->shared_physical_address = __pa(sep_dev->shared_virtual_address);
// shared_physical_address = 0xda00000; // shared_physical_address = 0xda00000;
*kernel_shared_area_addr_ptr = (unsigned long)sep_dev->shared_virtual_address; *kernel_shared_area_addr_ptr = (unsigned long) sep_dev->shared_virtual_address;
/* set the physical address of the shared area */ /* set the physical address of the shared area */
*phys_shared_area_addr_ptr = sep_dev->shared_physical_address; *phys_shared_area_addr_ptr = sep_dev->shared_physical_address;
edbg( edbg("SEP Driver:shared_virtual_address is %p\n", sep_dev->shared_virtual_address);
"SEP Driver:shared_virtual_address is %p\n", edbg("SEP Driver:shared_region_size is %08lx\n", shared_area_size);
sep_dev->shared_virtual_address); edbg("SEP Driver:shared_physical_addr is %08lx\n", *phys_shared_area_addr_ptr);
edbg(
"SEP Driver:shared_region_size is %08lx\n",
shared_area_size);
edbg(
"SEP Driver:shared_physical_addr is %08lx\n",
*phys_shared_area_addr_ptr);
return 0; return 0;
} }
...@@ -311,11 +270,9 @@ int sep_map_and_alloc_shared_area(unsigned long shared_area_size, ...@@ -311,11 +270,9 @@ int sep_map_and_alloc_shared_area(unsigned long shared_area_size,
shared area,phys_shared_area_addr_ptr - the physical address of shared area,phys_shared_area_addr_ptr - the physical address of
the shared area the shared area
*/ */
void sep_unmap_and_free_shared_area(unsigned long shared_area_size, void sep_unmap_and_free_shared_area(unsigned long shared_area_size, unsigned long kernel_shared_area_addr, unsigned long phys_shared_area_addr)
unsigned long kernel_shared_area_addr,
unsigned long phys_shared_area_addr)
{ {
kfree((void *)kernel_shared_area_addr); kfree((void *) kernel_shared_area_addr);
return; return;
} }
...@@ -327,16 +284,10 @@ void sep_unmap_and_free_shared_area(unsigned long shared_area_size, ...@@ -327,16 +284,10 @@ void sep_unmap_and_free_shared_area(unsigned long shared_area_size,
*/ */
unsigned long sep_shared_area_virt_to_phys(unsigned long virt_address) unsigned long sep_shared_area_virt_to_phys(unsigned long virt_address)
{ {
edbg( edbg("SEP Driver:sh virt to phys v %08lx\n", virt_address);
"SEP Driver:sh virt to phys v %08lx\n", edbg("SEP Driver:sh virt to phys p %08lx\n", sep_dev->shared_physical_address + (virt_address - (unsigned long) sep_dev->shared_virtual_address));
virt_address);
edbg( return (unsigned long) sep_dev->shared_physical_address + (virt_address - (unsigned long) sep_dev->shared_virtual_address);
"SEP Driver:sh virt to phys p %08lx\n",
sep_dev->shared_physical_address
+ (virt_address - (unsigned long)sep_dev->shared_virtual_address));
return (unsigned long)sep_dev->shared_physical_address +
(virt_address - (unsigned long)sep_dev->shared_virtual_address);
} }
/* /*
...@@ -347,16 +298,14 @@ unsigned long sep_shared_area_virt_to_phys(unsigned long virt_address) ...@@ -347,16 +298,14 @@ unsigned long sep_shared_area_virt_to_phys(unsigned long virt_address)
*/ */
unsigned long sep_shared_area_phys_to_virt(unsigned long phys_address) unsigned long sep_shared_area_phys_to_virt(unsigned long phys_address)
{ {
return (unsigned long)sep_dev->shared_virtual_address return (unsigned long) sep_dev->shared_virtual_address + (phys_address - sep_dev->shared_physical_address);
+ (phys_address - sep_dev->shared_physical_address);
} }
/* /*
function that is activaed on the succesfull probe of the SEP device function that is activaed on the succesfull probe of the SEP device
*/ */
static int __devinit sep_probe(struct pci_dev *pdev, static int __devinit sep_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
const struct pci_device_id *ent)
{ {
/* error */ /* error */
int error; int error;
...@@ -365,15 +314,13 @@ static int __devinit sep_probe(struct pci_dev *pdev, ...@@ -365,15 +314,13 @@ static int __devinit sep_probe(struct pci_dev *pdev,
CODE CODE
---------------------------*/ ---------------------------*/
edbg( edbg("Sep pci probe starting\n");
"Sep pci probe starting\n");
error = 0; error = 0;
/* enable the device */ /* enable the device */
error = pci_enable_device(pdev); error = pci_enable_device(pdev);
if (error) { if (error) {
edbg( edbg("error enabling pci device\n");
"error enabling pci device\n");
goto end_function; goto end_function;
} }
...@@ -383,111 +330,83 @@ static int __devinit sep_probe(struct pci_dev *pdev, ...@@ -383,111 +330,83 @@ static int __devinit sep_probe(struct pci_dev *pdev,
/* get the io memory start address */ /* get the io memory start address */
sep_dev->io_memory_start_physical_address = pci_resource_start(pdev, 0); sep_dev->io_memory_start_physical_address = pci_resource_start(pdev, 0);
if (!sep_dev->io_memory_start_physical_address) { if (!sep_dev->io_memory_start_physical_address) {
edbg( edbg("SEP Driver error pci resource start\n");
"SEP Driver error pci resource start\n");
goto end_function; goto end_function;
} }
/* get the io memory end address */ /* get the io memory end address */
sep_dev->io_memory_end_physical_address = pci_resource_end(pdev, 0); sep_dev->io_memory_end_physical_address = pci_resource_end(pdev, 0);
if (!sep_dev->io_memory_end_physical_address) { if (!sep_dev->io_memory_end_physical_address) {
edbg( edbg("SEP Driver error pci resource end\n");
"SEP Driver error pci resource end\n");
goto end_function; goto end_function;
} }
sep_dev->io_memory_size = sep_dev->io_memory_end_physical_address - sep_dev->io_memory_size = sep_dev->io_memory_end_physical_address - sep_dev->io_memory_start_physical_address + 1;
sep_dev->io_memory_start_physical_address + 1;
edbg( edbg("SEP Driver:io_memory_start_physical_address is %08lx\n", sep_dev->io_memory_start_physical_address);
"SEP Driver:io_memory_start_physical_address is %08lx\n",
sep_dev->io_memory_start_physical_address);
edbg( edbg("SEP Driver:io_memory_end_phyaical_address is %08lx\n", sep_dev->io_memory_end_physical_address);
"SEP Driver:io_memory_end_phyaical_address is %08lx\n",
sep_dev->io_memory_end_physical_address);
edbg( edbg("SEP Driver:io_memory_size is %08lx\n", sep_dev->io_memory_size);
"SEP Driver:io_memory_size is %08lx\n",
sep_dev->io_memory_size);
sep_dev->io_memory_start_virtual_address = sep_dev->io_memory_start_virtual_address = ioremap_nocache(sep_dev->io_memory_start_physical_address, sep_dev->io_memory_size);
ioremap_nocache(sep_dev->io_memory_start_physical_address,
sep_dev->io_memory_size);
if (!sep_dev->io_memory_start_virtual_address) { if (!sep_dev->io_memory_start_virtual_address) {
edbg( edbg("SEP Driver error ioremap of io memory\n");
"SEP Driver error ioremap of io memory\n");
goto end_function; goto end_function;
} }
edbg( edbg("SEP Driver:io_memory_start_virtual_address is %p\n", sep_dev->io_memory_start_virtual_address);
"SEP Driver:io_memory_start_virtual_address is %p\n",
sep_dev->io_memory_start_virtual_address);
sep_dev->reg_base_address = (void __iomem *)sep_dev->io_memory_start_virtual_address; sep_dev->reg_base_address = (void __iomem *) sep_dev->io_memory_start_virtual_address;
/* set up system base address and shared memory location */ /* set up system base address and shared memory location */
sep_dev->rar_virtual_address = kmalloc(2 * SEP_RAR_IO_MEM_REGION_SIZE, sep_dev->rar_virtual_address = kmalloc(2 * SEP_RAR_IO_MEM_REGION_SIZE, GFP_KERNEL);
GFP_KERNEL);
if (!sep_dev->rar_virtual_address) { if (!sep_dev->rar_virtual_address) {
edbg( edbg("SEP Driver:cant kmalloc rar\n");
"SEP Driver:cant kmalloc rar\n");
goto end_function; goto end_function;
} }
/* FIXME */ /* FIXME */
sep_dev->rar_physical_address = __pa(sep_dev->rar_virtual_address); sep_dev->rar_physical_address = __pa(sep_dev->rar_virtual_address);
edbg( edbg("SEP Driver:rar_physical is %08lx\n", sep_dev->rar_physical_address);
"SEP Driver:rar_physical is %08lx\n",
sep_dev->rar_physical_address);
edbg( edbg("SEP Driver:rar_virtual is %p\n", sep_dev->rar_virtual_address);
"SEP Driver:rar_virtual is %p\n",
sep_dev->rar_virtual_address);
#if !SEP_DRIVER_POLLING_MODE #if !SEP_DRIVER_POLLING_MODE
edbg( edbg("SEP Driver: about to write IMR and ICR REG_ADDR\n");
"SEP Driver: about to write IMR and ICR REG_ADDR\n");
/* clear ICR register */ /* clear ICR register */
sep_write_reg(sep_dev, HW_HOST_ICR_REG_ADDR, sep_write_reg(sep_dev, HW_HOST_ICR_REG_ADDR, 0xFFFFFFFF);
0xFFFFFFFF);
/* set the IMR register - open only GPR 2 */ /* set the IMR register - open only GPR 2 */
sep_write_reg(sep_dev, HW_HOST_IMR_REG_ADDR, sep_write_reg(sep_dev, HW_HOST_IMR_REG_ADDR, (~(0x1 << 13)));
(~(0x1 << 13)));
/* figure out our irq */ /* figure out our irq */
/* FIXME: */ /* FIXME: */
error = pci_read_config_byte(pdev, PCI_INTERRUPT_LINE, (u8 *)&sep_dev->sep_irq); error = pci_read_config_byte(pdev, PCI_INTERRUPT_LINE, (u8 *) & sep_dev->sep_irq);
edbg( edbg("SEP Driver: my irq is %d\n", sep_irq);
"SEP Driver: my irq is %d\n", sep_irq);
edbg( edbg("SEP Driver: about to call request_irq\n");
"SEP Driver: about to call request_irq\n");
/* get the interrupt line */ /* get the interrupt line */
error = request_irq(sep_irq, sep_inthandler, IRQF_SHARED, error = request_irq(sep_irq, sep_inthandler, IRQF_SHARED, "sep_driver", &sep_dev->reg_base_address);
"sep_driver", &sep_dev->reg_base_address);
if (error) if (error)
goto end_function; goto end_function;
goto end_function; goto end_function;
edbg( edbg("SEP Driver: about to write IMR REG_ADDR");
"SEP Driver: about to write IMR REG_ADDR");
/* set the IMR register - open only GPR 2 */ /* set the IMR register - open only GPR 2 */
sep_write_reg(sep_dev, HW_HOST_IMR_REG_ADDR, sep_write_reg(sep_dev, HW_HOST_IMR_REG_ADDR, (~(0x1 << 13)));
(~(0x1 << 13)));
#endif /* SEP_DRIVER_POLLING_MODE */ #endif /* SEP_DRIVER_POLLING_MODE */
end_function: end_function:
return error; return error;
} }
...@@ -515,26 +434,18 @@ void sep_load_rom_code(void) ...@@ -515,26 +434,18 @@ void sep_load_rom_code(void)
/* Loading ROM from SEP_ROM_image.h file */ /* Loading ROM from SEP_ROM_image.h file */
k = sizeof(CRYS_SEP_ROM); k = sizeof(CRYS_SEP_ROM);
edbg( edbg("SEP Driver: DX_CC_TST_SepRomLoader start\n");
"SEP Driver: DX_CC_TST_SepRomLoader start\n");
edbg( edbg("SEP Driver: k is %lu\n", k);
"SEP Driver: k is %lu\n", k); edbg("SEP Driver: sep_dev->reg_base_address is %p\n", sep_dev->reg_base_address);
edbg( edbg("SEP Driver: CRYS_SEP_ROM_start_address_offset is %p\n", CRYS_SEP_ROM_start_address_offset);
"SEP Driver: sep_dev->reg_base_address is %p\n",
sep_dev->reg_base_address);
edbg(
"SEP Driver: CRYS_SEP_ROM_start_address_offset is %p\n",
CRYS_SEP_ROM_start_address_offset);
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
/* write bank */ /* write bank */
sep_write_reg(sep_dev, SEP_ROM_BANK_register_offset, i); sep_write_reg(sep_dev, SEP_ROM_BANK_register_offset, i);
for (j = 0; j < CRYS_SEP_ROM_length / 4; j++) { for (j = 0; j < CRYS_SEP_ROM_length / 4; j++) {
sep_write_reg(sep_dev, sep_write_reg(sep_dev, CRYS_SEP_ROM_start_address_offset + 4 * j, CRYS_SEP_ROM[i * 0x1000 + j]);
CRYS_SEP_ROM_start_address_offset + 4*j,
CRYS_SEP_ROM[i * 0x1000 + j]);
k = k - 4; k = k - 4;
...@@ -545,7 +456,7 @@ void sep_load_rom_code(void) ...@@ -545,7 +456,7 @@ void sep_load_rom_code(void)
} }
} }
/* reset the SEP*/ /* reset the SEP */
sep_write_reg(sep_dev, HW_HOST_SEP_SW_RST_REG_ADDR, 0x1); sep_write_reg(sep_dev, HW_HOST_SEP_SW_RST_REG_ADDR, 0x1);
/* poll for SEP ROM boot finish */ /* poll for SEP ROM boot finish */
...@@ -553,49 +464,41 @@ void sep_load_rom_code(void) ...@@ -553,49 +464,41 @@ void sep_load_rom_code(void)
retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR3_REG_ADDR); retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR3_REG_ADDR);
} while (!regVal); } while (!regVal);
edbg( edbg("SEP Driver: ROM polling ended\n");
"SEP Driver: ROM polling ended\n");
switch (regVal) { switch (regVal) {
case 0x1: case 0x1:
/* fatal error - read erro status from GPRO */ /* fatal error - read erro status from GPRO */
Error = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR); Error = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR);
edbg( edbg("SEP Driver: ROM polling case 1\n");
"SEP Driver: ROM polling case 1\n");
break; break;
case 0x2: case 0x2:
/* Boot First Phase ended */ /* Boot First Phase ended */
warning = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR); warning = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR);
edbg( edbg("SEP Driver: ROM polling case 2\n");
"SEP Driver: ROM polling case 2\n");
break; break;
case 0x4: case 0x4:
/* Cold boot ended successfully */ /* Cold boot ended successfully */
warning = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR); warning = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR);
edbg( edbg("SEP Driver: ROM polling case 4\n");
"SEP Driver: ROM polling case 4\n");
Error = 0; Error = 0;
break; break;
case 0x8: case 0x8:
/* Warmboot ended successfully */ /* Warmboot ended successfully */
warning = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR); warning = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR);
edbg( edbg("SEP Driver: ROM polling case 8\n");
"SEP Driver: ROM polling case 8\n");
Error = 0; Error = 0;
break; break;
case 0x10: case 0x10:
/* ColdWarm boot ended successfully */ /* ColdWarm boot ended successfully */
warning = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR); warning = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR);
edbg( edbg("SEP Driver: ROM polling case 16\n");
"SEP Driver: ROM polling case 16\n");
Error = 0; Error = 0;
break; break;
case 0x20: case 0x20:
edbg( edbg("SEP Driver: ROM polling case 32\n");
"SEP Driver: ROM polling case 32\n");
break; break;
} }
#endif #endif
} }
...@@ -115,26 +115,18 @@ static void sep_unregister_driver_from_fs(void); ...@@ -115,26 +115,18 @@ static void sep_unregister_driver_from_fs(void);
table from this array the condition is that either the table is full 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 (all etnries are entered), or there are no more entries in the lli array
*/ */
static unsigned long sep_calculate_lli_table_max_size( static unsigned long sep_calculate_lli_table_max_size(struct sep_lli_entry_t *lli_in_array_ptr, unsigned long num_array_entries);
struct sep_lli_entry_t *lli_in_array_ptr,
unsigned long num_array_entries);
/* /*
this functions builds ont lli table from the lli_array according to the this functions builds ont lli table from the lli_array according to the
given size of data given size of data
*/ */
static void sep_build_lli_table(struct sep_lli_entry_t *lli_array_ptr, static void sep_build_lli_table(struct sep_lli_entry_t *lli_array_ptr, struct sep_lli_entry_t *lli_table_ptr, unsigned long *num_processed_entries_ptr, unsigned long *num_table_entries_ptr, unsigned long table_data_size);
struct sep_lli_entry_t *lli_table_ptr,
unsigned long *num_processed_entries_ptr,
unsigned long *num_table_entries_ptr,
unsigned long table_data_size);
/* /*
this function goes over the list of the print created tables and prints this function goes over the list of the print created tables and prints
all the data all the data
*/ */
static void sep_debug_print_lli_tables(struct sep_lli_entry_t *lli_table_ptr, static void sep_debug_print_lli_tables(struct sep_lli_entry_t *lli_table_ptr, unsigned long num_table_entries, unsigned long table_data_size);
unsigned long num_table_entries,
unsigned long table_data_size);
...@@ -226,46 +218,31 @@ static void sep_flow_done_handler(struct work_struct *work); ...@@ -226,46 +218,31 @@ static void sep_flow_done_handler(struct work_struct *work);
and construct a basic lli array, where each entry holds the physical 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 page address and the size that application data holds in this physical pages
*/ */
static int sep_lock_kernel_pages(unsigned long kernel_virt_addr, static int sep_lock_kernel_pages(unsigned long kernel_virt_addr, unsigned long data_size, unsigned long *num_pages_ptr, struct sep_lli_entry_t **lli_array_ptr, struct page ***page_array_ptr);
unsigned long data_size,
unsigned long *num_pages_ptr,
struct sep_lli_entry_t **lli_array_ptr,
struct page ***page_array_ptr);
/* /*
This function creates one DMA table for flow and returns its data, This function creates one DMA table for flow and returns its data,
and pointer to its info entry and pointer to its info entry
*/ */
static int sep_prepare_one_flow_dma_table(unsigned long virt_buff_addr, static int sep_prepare_one_flow_dma_table(unsigned long virt_buff_addr, unsigned long virt_buff_size, struct sep_lli_entry_t *table_data, struct sep_lli_entry_t **info_entry_ptr, struct sep_flow_context_t *flow_data_ptr, bool isKernelVirtualAddress);
unsigned long virt_buff_size,
struct sep_lli_entry_t *table_data,
struct sep_lli_entry_t **info_entry_ptr,
struct sep_flow_context_t *flow_data_ptr,
bool isKernelVirtualAddress);
/* /*
This function creates a list of tables for flow and returns the data for the This function creates a list of tables for flow and returns the data for the
first and last tables of the list first and last tables of the list
*/ */
static int sep_prepare_flow_dma_tables(unsigned long num_virtual_buffers, static int sep_prepare_flow_dma_tables(unsigned long num_virtual_buffers,
unsigned long first_buff_addr, unsigned long first_buff_addr, struct sep_flow_context_t *flow_data_ptr, struct sep_lli_entry_t *first_table_data_ptr, struct sep_lli_entry_t *last_table_data_ptr, bool isKernelVirtualAddress);
struct sep_flow_context_t *flow_data_ptr,
struct sep_lli_entry_t *first_table_data_ptr,
struct sep_lli_entry_t *last_table_data_ptr,
bool isKernelVirtualAddress);
/* /*
this function find a space for the new flow dma table this function find a space for the new flow dma table
*/ */
static int sep_find_free_flow_dma_table_space( static int sep_find_free_flow_dma_table_space(unsigned long **table_address_ptr);
unsigned long **table_address_ptr);
/* /*
this function goes over all the flow tables connected to the given table and this function goes over all the flow tables connected to the given table and
deallocate them deallocate them
*/ */
static void sep_deallocated_flow_tables( static void sep_deallocated_flow_tables(struct sep_lli_entry_t *first_table_ptr);
struct sep_lli_entry_t *first_table_ptr);
/* /*
This function handler the set flow id command This function handler the set flow id command
...@@ -276,8 +253,7 @@ static int sep_set_flow_id_handler(unsigned long arg); ...@@ -276,8 +253,7 @@ static int sep_set_flow_id_handler(unsigned long arg);
This function returns pointer to the flow data structure This function returns pointer to the flow data structure
that conatins the given id that conatins the given id
*/ */
static int sep_find_flow_context(unsigned long flow_id, static int sep_find_flow_context(unsigned long flow_id, struct sep_flow_context_t **flow_data_ptr);
struct sep_flow_context_t **flow_data_ptr);
/* /*
...@@ -300,8 +276,7 @@ static int sep_get_time_handler(unsigned long arg); ...@@ -300,8 +276,7 @@ static int sep_get_time_handler(unsigned long arg);
/* /*
calculates time and sets it at the predefined address calculates time and sets it at the predefined address
*/ */
static int sep_set_time(unsigned long *address_ptr, static int sep_set_time(unsigned long *address_ptr, unsigned long *time_in_sec_ptr);
unsigned long *time_in_sec_ptr);
/* /*
PATCH for configuring the DMA to single burst instead of multi-burst PATCH for configuring the DMA to single burst instead of multi-burst
...@@ -314,11 +289,7 @@ static void sep_configure_dma_burst(void); ...@@ -314,11 +289,7 @@ static void sep_configure_dma_burst(void);
array, where each entry holds the physical page address array, where each entry holds the physical page address
and the size that application data holds in this physical pages and the size that application data holds in this physical pages
*/ */
static int sep_lock_user_pages(unsigned long app_virt_addr, static int sep_lock_user_pages(unsigned long app_virt_addr, unsigned long data_size, unsigned long *num_pages_ptr, struct sep_lli_entry_t **lli_array_ptr, struct page ***page_array_ptr);
unsigned long data_size,
unsigned long *num_pages_ptr,
struct sep_lli_entry_t **lli_array_ptr,
struct page ***page_array_ptr);
/*--------------------------------------------- /*---------------------------------------------
FUNCTIONS FUNCTIONS
...@@ -379,8 +350,7 @@ void sep_driver_poll() ...@@ -379,8 +350,7 @@ void sep_driver_poll()
sep_dev->sep_to_host_reply_counter++; sep_dev->sep_to_host_reply_counter++;
#else #else
/* poll, until reply from sep */ /* poll, until reply from sep */
wait_event(g_sep_event, wait_event(g_sep_event, (sep_dev->host_to_sep_send_counter == sep_dev->sep_to_host_reply_counter));
(sep_dev->host_to_sep_send_counter == sep_dev->sep_to_host_reply_counter));
#endif #endif
} }
...@@ -411,8 +381,7 @@ static int sep_open(struct inode *inode_ptr, struct file *file_ptr) ...@@ -411,8 +381,7 @@ static int sep_open(struct inode *inode_ptr, struct file *file_ptr)
/* check the error */ /* check the error */
if (error) { if (error) {
edbg( edbg("SEP Driver: down_interruptible failed\n");
"SEP Driver: down_interruptible failed\n");
goto end_function; goto end_function;
} }
...@@ -420,7 +389,7 @@ static int sep_open(struct inode *inode_ptr, struct file *file_ptr) ...@@ -420,7 +389,7 @@ static int sep_open(struct inode *inode_ptr, struct file *file_ptr)
/* release data pool allocations */ /* release data pool allocations */
sep_dev->data_pool_bytes_allocated = 0; sep_dev->data_pool_bytes_allocated = 0;
end_function: end_function:
dbg("SEP Driver:<-------- open end\n"); dbg("SEP Driver:<-------- open end\n");
...@@ -441,7 +410,7 @@ static int sep_release(struct inode *inode_ptr, struct file *file_ptr) ...@@ -441,7 +410,7 @@ static int sep_release(struct inode *inode_ptr, struct file *file_ptr)
dbg("----------->SEP Driver: sep_release start\n"); dbg("----------->SEP Driver: sep_release start\n");
#if 0/*!SEP_DRIVER_POLLING_MODE*/ #if 0 /*!SEP_DRIVER_POLLING_MODE */
/* close IMR */ /* close IMR */
sep_write_reg(sep_dev, HW_HOST_IMR_REG_ADDR, 0x7FFF); sep_write_reg(sep_dev, HW_HOST_IMR_REG_ADDR, 0x7FFF);
...@@ -478,34 +447,23 @@ static int sep_mmap(struct file *filp, struct vm_area_struct *vma) ...@@ -478,34 +447,23 @@ static int sep_mmap(struct file *filp, struct vm_area_struct *vma)
/* check that the size of the mapped range is as the size of the message /* check that the size of the mapped range is as the size of the message
shared area */ shared area */
if ((vma->vm_end - vma->vm_start) > SEP_DRIVER_MMMAP_AREA_SIZE) { if ((vma->vm_end - vma->vm_start) > SEP_DRIVER_MMMAP_AREA_SIZE) {
edbg( edbg("SEP Driver mmap requested size is more than allowed\n");
"SEP Driver mmap requested size is more than allowed\n");
printk(KERN_WARNING "SEP Driver mmap requested size is more \ printk(KERN_WARNING "SEP Driver mmap requested size is more \
than allowed\n"); than allowed\n");
printk(KERN_WARNING "SEP Driver vma->vm_end is %08lx\n", printk(KERN_WARNING "SEP Driver vma->vm_end is %08lx\n", vma->vm_end);
vma->vm_end); printk(KERN_WARNING "SEP Driver vma->vm_end is %08lx\n", vma->vm_start);
printk(KERN_WARNING "SEP Driver vma->vm_end is %08lx\n",
vma->vm_start);
return -EAGAIN; return -EAGAIN;
} }
edbg( edbg("SEP Driver:g_message_shared_area_addr is %08lx\n", sep_dev->message_shared_area_addr);
"SEP Driver:g_message_shared_area_addr is %08lx\n",
sep_dev->message_shared_area_addr);
/* get physical address */ /* get physical address */
phys_addr = sep_dev->phys_shared_area_addr; phys_addr = sep_dev->phys_shared_area_addr;
edbg( "SEP Driver: phys_addr is %08lx\n", edbg("SEP Driver: phys_addr is %08lx\n", phys_addr);
phys_addr);
if (remap_pfn_range(vma, if (remap_pfn_range(vma, vma->vm_start, phys_addr >> PAGE_SHIFT, vma->vm_end - vma->vm_start, vma->vm_page_prot)) {
vma->vm_start, edbg("SEP Driver remap_page_range failed\n");
phys_addr >> PAGE_SHIFT,
vma->vm_end - vma->vm_start,
vma->vm_page_prot)) {
edbg(
"SEP Driver remap_page_range failed\n");
printk(KERN_WARNING "SEP Driver remap_page_range failed\n"); printk(KERN_WARNING "SEP Driver remap_page_range failed\n");
return -EAGAIN; return -EAGAIN;
} }
...@@ -519,7 +477,7 @@ phys_addr); ...@@ -519,7 +477,7 @@ phys_addr);
/*----------------------------------------------- /*-----------------------------------------------
poll function poll function
*----------------------------------------------*/ *----------------------------------------------*/
static unsigned int sep_poll(struct file *filp, poll_table *wait) static unsigned int sep_poll(struct file *filp, poll_table * wait)
{ {
unsigned long count; unsigned long count;
...@@ -541,9 +499,7 @@ static unsigned int sep_poll(struct file *filp, poll_table *wait) ...@@ -541,9 +499,7 @@ static unsigned int sep_poll(struct file *filp, poll_table *wait)
retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR2_REG_ADDR); retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR2_REG_ADDR);
for (count = 0; count < 10 * 4; count += 4) for (count = 0; count < 10 * 4; count += 4)
edbg("Poll Debug Word %lu of the message is %lu\n", count, edbg("Poll Debug Word %lu of the message is %lu\n", count, *((unsigned long *) (sep_dev->shared_area_addr + SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES + count)));
*((unsigned long *)(sep_dev->shared_area_addr +
SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES + count)));
} }
sep_dev->sep_to_host_reply_counter++; sep_dev->sep_to_host_reply_counter++;
...@@ -553,33 +509,26 @@ static unsigned int sep_poll(struct file *filp, poll_table *wait) ...@@ -553,33 +509,26 @@ static unsigned int sep_poll(struct file *filp, poll_table *wait)
#endif #endif
edbg( edbg("sep_dev->host_to_sep_send_counter is %lu\n", sep_dev->host_to_sep_send_counter);
"sep_dev->host_to_sep_send_counter is %lu\n", edbg("sep_dev->sep_to_host_reply_counter is %lu\n", sep_dev->sep_to_host_reply_counter);
sep_dev->host_to_sep_send_counter);
edbg(
"sep_dev->sep_to_host_reply_counter is %lu\n",
sep_dev->sep_to_host_reply_counter);
/* check if the data is ready */ /* check if the data is ready */
if (sep_dev->host_to_sep_send_counter == sep_dev->sep_to_host_reply_counter) { if (sep_dev->host_to_sep_send_counter == sep_dev->sep_to_host_reply_counter) {
for (count = 0; count < 12 * 4; count += 4) for (count = 0; count < 12 * 4; count += 4)
edbg("Sep Mesg Word %lu of the message is %lu\n", count, edbg("Sep Mesg Word %lu of the message is %lu\n", count, *((unsigned long *) (sep_dev->shared_area_addr + count)));
*((unsigned long *)(sep_dev->shared_area_addr + count)));
for (count = 0; count < 10 * 4; count += 4) for (count = 0; count < 10 * 4; count += 4)
edbg("Debug Data Word %lu of the message is %lu\n", count, edbg("Debug Data Word %lu of the message is %lu\n", count, *((unsigned long *) (sep_dev->shared_area_addr + 0x1800 + count)));
*((unsigned long *)(sep_dev->shared_area_addr + 0x1800 + count)));
retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR2_REG_ADDR); retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR2_REG_ADDR);
edbg( "retVal is %lu\n", retVal); edbg("retVal is %lu\n", retVal);
/* check if the this is sep reply or request */ /* check if the this is sep reply or request */
if (retVal >> 31) { if (retVal >> 31) {
edbg( edbg("SEP Driver: sep request in\n");
"SEP Driver: sep request in\n");
/* request */ /* request */
mask |= POLLOUT | POLLWRNORM; mask |= POLLOUT | POLLWRNORM;
} else { } else {
edbg( "SEP Driver: sep reply in\n"); edbg("SEP Driver: sep reply in\n");
mask |= POLLIN | POLLRDNORM; mask |= POLLIN | POLLRDNORM;
} }
} }
...@@ -589,10 +538,7 @@ static unsigned int sep_poll(struct file *filp, poll_table *wait) ...@@ -589,10 +538,7 @@ static unsigned int sep_poll(struct file *filp, poll_table *wait)
} }
static int sep_ioctl(struct inode *inode, static int sep_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg)
struct file *filp,
unsigned int cmd,
unsigned long arg)
{ {
/* error */ /* error */
...@@ -617,8 +563,7 @@ static int sep_ioctl(struct inode *inode, ...@@ -617,8 +563,7 @@ static int sep_ioctl(struct inode *inode,
/* send command to SEP */ /* send command to SEP */
sep_send_command_handler(); sep_send_command_handler();
edbg( edbg("SEP Driver: after sep_send_command_handler\n");
"SEP Driver: after sep_send_command_handler\n");
break; break;
...@@ -766,8 +711,7 @@ static int sep_register_driver_to_fs(void) ...@@ -766,8 +711,7 @@ static int sep_register_driver_to_fs(void)
ret_val = alloc_chrdev_region(&g_sep_device_number, 0, 1, "sep_sec_driver"); ret_val = alloc_chrdev_region(&g_sep_device_number, 0, 1, "sep_sec_driver");
if (ret_val) { if (ret_val) {
edbg( edbg("sep_driver:major number allocation failed, retval is %d\n", ret_val);
"sep_driver:major number allocation failed, retval is %d\n", ret_val);
goto end_function; goto end_function;
} }
...@@ -787,20 +731,18 @@ static int sep_register_driver_to_fs(void) ...@@ -787,20 +731,18 @@ static int sep_register_driver_to_fs(void)
ret_val = cdev_add(&g_sep_cdev, g_sep_device_number, 1); ret_val = cdev_add(&g_sep_cdev, g_sep_device_number, 1);
if (ret_val) { if (ret_val) {
edbg( edbg("sep_driver:cdev_add failed, retval is %d\n", ret_val);
"sep_driver:cdev_add failed, retval is %d\n",
ret_val);
goto end_function_unregister_devnum; goto end_function_unregister_devnum;
} }
goto end_function; goto end_function;
end_function_unregister_devnum: end_function_unregister_devnum:
/* unregister dev numbers */ /* unregister dev numbers */
unregister_chrdev_region(g_sep_device_number, 1); unregister_chrdev_region(g_sep_device_number, 1);
end_function: end_function:
return ret_val; return ret_val;
} }
...@@ -839,8 +781,7 @@ static int __init sep_init(void) ...@@ -839,8 +781,7 @@ static int __init sep_init(void)
------------------------*/ ------------------------*/
dbg("SEP Driver:-------->Init start\n"); dbg("SEP Driver:-------->Init start\n");
edbg("sep->shared_area_addr = %lx\n", edbg("sep->shared_area_addr = %lx\n", (unsigned long) &sep_dev->shared_area_addr);
(unsigned long)&sep_dev->shared_area_addr);
ret_val = 0; ret_val = 0;
...@@ -861,26 +802,18 @@ for the current transaction */ ...@@ -861,26 +802,18 @@ for the current transaction */
ret_val = sep_register_driver_to_device(); ret_val = sep_register_driver_to_device();
if (ret_val) { if (ret_val) {
edbg( edbg("sep_driver:sep_driver_to_device failed, ret_val is %d\n", ret_val);
"sep_driver:sep_driver_to_device failed, ret_val is %d\n",
ret_val);
goto end_function_unregister_from_fs; goto end_function_unregister_from_fs;
} }
/* calculate the total size for allocation */ /* calculate the total size for allocation */
size = SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES + size = SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES +
SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_SIZE_IN_BYTES + SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_SIZE_IN_BYTES + SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES + SEP_DRIVER_FLOW_DMA_TABLES_AREA_SIZE_IN_BYTES + SEP_DRIVER_STATIC_AREA_SIZE_IN_BYTES + SEP_DRIVER_SYSTEM_DATA_MEMORY_SIZE_IN_BYTES;
SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES +
SEP_DRIVER_FLOW_DMA_TABLES_AREA_SIZE_IN_BYTES +
SEP_DRIVER_STATIC_AREA_SIZE_IN_BYTES +
SEP_DRIVER_SYSTEM_DATA_MEMORY_SIZE_IN_BYTES;
/* allocate the shared area */ /* allocate the shared area */
if (sep_map_and_alloc_shared_area(size, if (sep_map_and_alloc_shared_area(size, &sep_dev->shared_area_addr, &sep_dev->phys_shared_area_addr)) {
&sep_dev->shared_area_addr,
&sep_dev->phys_shared_area_addr)) {
ret_val = -ENOMEM; ret_val = -ENOMEM;
/* allocation failed */ /* allocation failed */
goto end_function_unmap_io_memory; goto end_function_unmap_io_memory;
...@@ -889,15 +822,12 @@ for the current transaction */ ...@@ -889,15 +822,12 @@ for the current transaction */
/* now set the memory regions */ /* now set the memory regions */
sep_dev->message_shared_area_addr = sep_dev->shared_area_addr; sep_dev->message_shared_area_addr = sep_dev->shared_area_addr;
edbg( edbg("SEP Driver: g_message_shared_area_addr is %08lx\n", sep_dev->message_shared_area_addr);
"SEP Driver: g_message_shared_area_addr is %08lx\n",
sep_dev->message_shared_area_addr);
#if (SEP_DRIVER_RECONFIG_MESSAGE_AREA == 1) #if (SEP_DRIVER_RECONFIG_MESSAGE_AREA == 1)
/* send the new SHARED MESSAGE AREA to the SEP */ /* send the new SHARED MESSAGE AREA to the SEP */
sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR1_REG_ADDR, sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR1_REG_ADDR, sep_dev->phys_shared_area_addr);
sep_dev->phys_shared_area_addr);
/* poll for SEP response */ /* poll for SEP response */
retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR1_REG_ADDR); retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR1_REG_ADDR);
...@@ -909,7 +839,6 @@ for the current transaction */ ...@@ -909,7 +839,6 @@ for the current transaction */
ret_val = -ENOMEM; ret_val = -ENOMEM;
goto end_function_deallocate_message_area; goto end_function_deallocate_message_area;
} }
#endif #endif
/* init the flow contextes */ /* init the flow contextes */
...@@ -919,13 +848,11 @@ for the current transaction */ ...@@ -919,13 +848,11 @@ for the current transaction */
sep_dev->flow_wq_ptr = create_singlethread_workqueue("sepflowwq"); sep_dev->flow_wq_ptr = create_singlethread_workqueue("sepflowwq");
if (sep_dev->flow_wq_ptr == 0) { if (sep_dev->flow_wq_ptr == 0) {
ret_val = -ENOMEM; ret_val = -ENOMEM;
edbg( edbg("sep_driver:flow queue creation failed\n");
"sep_driver:flow queue creation failed\n");
goto end_function_deallocate_sep_shared_area; goto end_function_deallocate_sep_shared_area;
} }
edbg( edbg("SEP Driver: create flow workqueue \n");
"SEP Driver: create flow workqueue \n");
/* register driver to fs */ /* register driver to fs */
ret_val = sep_register_driver_to_fs(); ret_val = sep_register_driver_to_fs();
...@@ -937,26 +864,24 @@ for the current transaction */ ...@@ -937,26 +864,24 @@ for the current transaction */
goto end_function; goto end_function;
end_function_unregister_from_fs: end_function_unregister_from_fs:
/* unregister from fs */ /* unregister from fs */
sep_unregister_driver_from_fs(); sep_unregister_driver_from_fs();
end_function_deallocate_sep_shared_area: end_function_deallocate_sep_shared_area:
/* de-allocate shared area */ /* de-allocate shared area */
sep_unmap_and_free_shared_area(size, sep_unmap_and_free_shared_area(size, sep_dev->shared_area_addr, sep_dev->phys_shared_area_addr);
sep_dev->shared_area_addr,
sep_dev->phys_shared_area_addr);
end_function_unmap_io_memory: end_function_unmap_io_memory:
iounmap((void *)sep_dev->reg_base_address); iounmap((void *) sep_dev->reg_base_address);
/* release io memory region */ /* release io memory region */
release_mem_region(SEP_IO_MEM_REGION_START_ADDRESS, SEP_IO_MEM_REGION_SIZE); release_mem_region(SEP_IO_MEM_REGION_START_ADDRESS, SEP_IO_MEM_REGION_SIZE);
end_function: end_function:
dbg("SEP Driver:<-------- Init end\n"); dbg("SEP Driver:<-------- Init end\n");
...@@ -985,29 +910,22 @@ static void __exit sep_exit(void) ...@@ -985,29 +910,22 @@ static void __exit sep_exit(void)
/* calculate the total size for de-allocation */ /* calculate the total size for de-allocation */
size = SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES + size = SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES +
SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_SIZE_IN_BYTES + SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_SIZE_IN_BYTES + SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES + SEP_DRIVER_FLOW_DMA_TABLES_AREA_SIZE_IN_BYTES + SEP_DRIVER_STATIC_AREA_SIZE_IN_BYTES + SEP_DRIVER_SYSTEM_DATA_MEMORY_SIZE_IN_BYTES;
SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES +
SEP_DRIVER_FLOW_DMA_TABLES_AREA_SIZE_IN_BYTES +
SEP_DRIVER_STATIC_AREA_SIZE_IN_BYTES +
SEP_DRIVER_SYSTEM_DATA_MEMORY_SIZE_IN_BYTES;
/* free shared area */ /* free shared area */
sep_unmap_and_free_shared_area(size, sep_unmap_and_free_shared_area(size, sep_dev->shared_area_addr, sep_dev->phys_shared_area_addr);
sep_dev->shared_area_addr,
sep_dev->phys_shared_area_addr);
edbg( edbg("SEP Driver: free pages SEP SHARED AREA \n");
"SEP Driver: free pages SEP SHARED AREA \n");
iounmap((void *)sep_dev->reg_base_address); iounmap((void *) sep_dev->reg_base_address);
edbg( "SEP Driver: iounmap \n"); edbg("SEP Driver: iounmap \n");
/* release io memory region */ /* release io memory region */
release_mem_region(SEP_IO_MEM_REGION_START_ADDRESS, SEP_IO_MEM_REGION_SIZE); release_mem_region(SEP_IO_MEM_REGION_START_ADDRESS, SEP_IO_MEM_REGION_SIZE);
edbg( "SEP Driver: release_mem_region \n"); edbg("SEP Driver: release_mem_region \n");
dbg("SEP Driver:<-------- Exit end\n"); dbg("SEP Driver:<-------- Exit end\n");
} }
...@@ -1041,11 +959,10 @@ irqreturn_t sep_inthandler(int irq, void *dev_id) ...@@ -1041,11 +959,10 @@ irqreturn_t sep_inthandler(int irq, void *dev_id)
/* read the IRR register to check if this is SEP interrupt */ /* read the IRR register to check if this is SEP interrupt */
reg_val = sep_read_reg(sep_dev, HW_HOST_IRR_REG_ADDR); reg_val = sep_read_reg(sep_dev, HW_HOST_IRR_REG_ADDR);
edbg( "SEP Interrupt - reg is %08lx\n", edbg("SEP Interrupt - reg is %08lx\n", reg_val);
reg_val);
/* check if this is the flow interrupt */ /* check if this is the flow interrupt */
if (0/*reg_val & (0x1 << 11)*/) { if (0 /*reg_val & (0x1 << 11) */ ) {
/* read GPRO to find out the which flow is done */ /* read GPRO to find out the which flow is done */
flow_id = sep_read_reg(sep_dev, HW_HOST_IRR_REG_ADDR); flow_id = sep_read_reg(sep_dev, HW_HOST_IRR_REG_ADDR);
...@@ -1073,12 +990,12 @@ irqreturn_t sep_inthandler(int irq, void *dev_id) ...@@ -1073,12 +990,12 @@ irqreturn_t sep_inthandler(int irq, void *dev_id)
} }
} }
end_function_with_error: end_function_with_error:
/* clear the interrupt */ /* clear the interrupt */
sep_write_reg(sep_dev, HW_HOST_ICR_REG_ADDR, reg_val); sep_write_reg(sep_dev, HW_HOST_ICR_REG_ADDR, reg_val);
end_function: end_function:
return int_error; return int_error;
} }
...@@ -1088,14 +1005,7 @@ irqreturn_t sep_inthandler(int irq, void *dev_id) ...@@ -1088,14 +1005,7 @@ irqreturn_t sep_inthandler(int irq, void *dev_id)
This function prepares only input DMA table for synhronic symmetric This function prepares only input DMA table for synhronic symmetric
operations (HASH) operations (HASH)
*/ */
int sep_prepare_input_dma_table(unsigned long app_virt_addr, int sep_prepare_input_dma_table(unsigned long app_virt_addr, unsigned long data_size, unsigned long block_size, unsigned long *lli_table_ptr, unsigned long *num_entries_ptr, unsigned long *table_data_size_ptr, bool isKernelVirtualAddress)
unsigned long data_size,
unsigned long block_size,
unsigned long *lli_table_ptr,
unsigned long *num_entries_ptr,
unsigned long *table_data_size_ptr,
bool isKernelVirtualAddress)
{ {
/* pointer to the info entry of the table - the last entry */ /* pointer to the info entry of the table - the last entry */
struct sep_lli_entry_t *info_entry_ptr; struct sep_lli_entry_t *info_entry_ptr;
...@@ -1130,8 +1040,8 @@ int sep_prepare_input_dma_table(unsigned long app_virt_addr, ...@@ -1130,8 +1040,8 @@ int sep_prepare_input_dma_table(unsigned long app_virt_addr,
dbg("SEP Driver:--------> sep_prepare_input_dma_table start\n"); dbg("SEP Driver:--------> sep_prepare_input_dma_table start\n");
edbg( "SEP Driver:data_size is %lu\n", data_size); edbg("SEP Driver:data_size is %lu\n", data_size);
edbg( "SEP Driver:block_size is %lu\n", block_size); edbg("SEP Driver:block_size is %lu\n", block_size);
/* initialize the pages pointers */ /* initialize the pages pointers */
sep_dev->in_page_array = 0; sep_dev->in_page_array = 0;
...@@ -1139,18 +1049,15 @@ int sep_prepare_input_dma_table(unsigned long app_virt_addr, ...@@ -1139,18 +1049,15 @@ int sep_prepare_input_dma_table(unsigned long app_virt_addr,
if (data_size == 0) { if (data_size == 0) {
/* special case - created 2 entries table with zero data */ /* special case - created 2 entries table with zero data */
in_lli_table_ptr = (struct sep_lli_entry_t *)(sep_dev->shared_area_addr + in_lli_table_ptr = (struct sep_lli_entry_t *) (sep_dev->shared_area_addr + SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES);
SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES); in_lli_table_ptr->physical_address = sep_dev->shared_area_addr + SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES;
in_lli_table_ptr->physical_address = sep_dev->shared_area_addr +
SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES;
in_lli_table_ptr->block_size = 0; in_lli_table_ptr->block_size = 0;
in_lli_table_ptr++; in_lli_table_ptr++;
in_lli_table_ptr->physical_address = 0xFFFFFFFF; in_lli_table_ptr->physical_address = 0xFFFFFFFF;
in_lli_table_ptr->block_size = 0; in_lli_table_ptr->block_size = 0;
*lli_table_ptr = sep_dev->phys_shared_area_addr + *lli_table_ptr = sep_dev->phys_shared_area_addr + SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES;
SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES;
*num_entries_ptr = 2; *num_entries_ptr = 2;
*table_data_size_ptr = 0; *table_data_size_ptr = 0;
...@@ -1160,77 +1067,52 @@ int sep_prepare_input_dma_table(unsigned long app_virt_addr, ...@@ -1160,77 +1067,52 @@ int sep_prepare_input_dma_table(unsigned long app_virt_addr,
/* check if the pages are in Kernel Virtual Address layout */ /* check if the pages are in Kernel Virtual Address layout */
if (isKernelVirtualAddress == true) if (isKernelVirtualAddress == true)
/* lock the pages of the kernel buffer and translate them to pages */ /* lock the pages of the kernel buffer and translate them to pages */
result = sep_lock_kernel_pages(app_virt_addr, result = sep_lock_kernel_pages(app_virt_addr, data_size, &sep_dev->in_num_pages, &lli_array_ptr, &sep_dev->in_page_array);
data_size,
&sep_dev->in_num_pages,
&lli_array_ptr,
&sep_dev->in_page_array);
else else
/* lock the pages of the user buffer and translate them to pages */ /* lock the pages of the user buffer and translate them to pages */
result = sep_lock_user_pages(app_virt_addr, result = sep_lock_user_pages(app_virt_addr, data_size, &sep_dev->in_num_pages, &lli_array_ptr, &sep_dev->in_page_array);
data_size,
&sep_dev->in_num_pages,
&lli_array_ptr,
&sep_dev->in_page_array);
if (result) if (result)
return result; return result;
edbg( edbg("SEP Driver:output sep_dev->in_num_pages is %lu\n", sep_dev->in_num_pages);
"SEP Driver:output sep_dev->in_num_pages is %lu\n",
sep_dev->in_num_pages);
current_entry = 0; current_entry = 0;
info_entry_ptr = 0; info_entry_ptr = 0;
sep_lli_entries = sep_dev->in_num_pages; sep_lli_entries = sep_dev->in_num_pages;
/* initiate to point after the message area */ /* initiate to point after the message area */
lli_table_alloc_addr = sep_dev->shared_area_addr + lli_table_alloc_addr = sep_dev->shared_area_addr + SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES;
SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES;
/* loop till all the entries in in array are not processed */ /* loop till all the entries in in array are not processed */
while (current_entry < sep_lli_entries) { while (current_entry < sep_lli_entries) {
/* set the new input and output tables */ /* set the new input and output tables */
in_lli_table_ptr = (struct sep_lli_entry_t *)lli_table_alloc_addr; in_lli_table_ptr = (struct sep_lli_entry_t *) lli_table_alloc_addr;
lli_table_alloc_addr += sizeof(struct sep_lli_entry_t) * lli_table_alloc_addr += sizeof(struct sep_lli_entry_t) * SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP;
SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP;
/* calculate the maximum size of data for input table */ /* calculate the maximum size of data for input table */
table_data_size = sep_calculate_lli_table_max_size( table_data_size = sep_calculate_lli_table_max_size(&lli_array_ptr[current_entry], (sep_lli_entries - current_entry));
&lli_array_ptr[current_entry],
(sep_lli_entries - current_entry));
/* now calculate the table size so that it will be module block size */ /* now calculate the table size so that it will be module block size */
table_data_size = (table_data_size / block_size) * block_size; table_data_size = (table_data_size / block_size) * block_size;
edbg( edbg("SEP Driver:output table_data_size is %lu\n", table_data_size);
"SEP Driver:output table_data_size is %lu\n",
table_data_size);
/* construct input lli table */ /* construct input lli table */
sep_build_lli_table(&lli_array_ptr[current_entry], sep_build_lli_table(&lli_array_ptr[current_entry], in_lli_table_ptr, &current_entry, &num_entries_in_table, table_data_size);
in_lli_table_ptr,
&current_entry,
&num_entries_in_table,
table_data_size);
if (info_entry_ptr == 0) { if (info_entry_ptr == 0) {
/* set the output parameters to physical addresses */ /* set the output parameters to physical addresses */
*lli_table_ptr = sep_shared_area_virt_to_phys( *lli_table_ptr = sep_shared_area_virt_to_phys((unsigned long) in_lli_table_ptr);
(unsigned long)in_lli_table_ptr);
*num_entries_ptr = num_entries_in_table; *num_entries_ptr = num_entries_in_table;
*table_data_size_ptr = table_data_size; *table_data_size_ptr = table_data_size;
edbg( edbg("SEP Driver:output lli_table_in_ptr is %08lx\n", *lli_table_ptr);
"SEP Driver:output lli_table_in_ptr is %08lx\n",
*lli_table_ptr);
} else { } else {
/* update the info entry of the previous in table */ /* update the info entry of the previous in table */
info_entry_ptr->physical_address = sep_shared_area_virt_to_phys( info_entry_ptr->physical_address = sep_shared_area_virt_to_phys((unsigned long) in_lli_table_ptr);
(unsigned long)in_lli_table_ptr); info_entry_ptr->block_size = ((num_entries_in_table) << 24) | (table_data_size);
info_entry_ptr->block_size = ((num_entries_in_table) << 24) |
(table_data_size);
} }
/* save the pointer to the info entry of the current tables */ /* save the pointer to the info entry of the current tables */
...@@ -1239,14 +1121,12 @@ int sep_prepare_input_dma_table(unsigned long app_virt_addr, ...@@ -1239,14 +1121,12 @@ int sep_prepare_input_dma_table(unsigned long app_virt_addr,
/* print input tables */ /* print input tables */
sep_debug_print_lli_tables((struct sep_lli_entry_t *) sep_debug_print_lli_tables((struct sep_lli_entry_t *)
sep_shared_area_phys_to_virt(*lli_table_ptr), sep_shared_area_phys_to_virt(*lli_table_ptr), *num_entries_ptr, *table_data_size_ptr);
*num_entries_ptr,
*table_data_size_ptr);
/* the array of the pages */ /* the array of the pages */
kfree(lli_array_ptr); kfree(lli_array_ptr);
end_function: end_function:
dbg("SEP Driver:<-------- sep_prepare_input_dma_table end\n"); dbg("SEP Driver:<-------- sep_prepare_input_dma_table end\n");
...@@ -1263,13 +1143,7 @@ int sep_prepare_input_output_dma_table(unsigned long app_virt_in_addr, ...@@ -1263,13 +1143,7 @@ int sep_prepare_input_output_dma_table(unsigned long app_virt_in_addr,
unsigned long app_virt_out_addr, unsigned long app_virt_out_addr,
unsigned long data_size, unsigned long data_size,
unsigned long block_size, unsigned long block_size,
unsigned long *lli_table_in_ptr, unsigned long *lli_table_in_ptr, unsigned long *lli_table_out_ptr, unsigned long *in_num_entries_ptr, unsigned long *out_num_entries_ptr, unsigned long *table_data_size_ptr, bool isKernelVirtualAddress)
unsigned long *lli_table_out_ptr,
unsigned long *in_num_entries_ptr,
unsigned long *out_num_entries_ptr,
unsigned long *table_data_size_ptr,
bool isKernelVirtualAddress)
{ {
/* array of pointers of page */ /* array of pointers of page */
struct sep_lli_entry_t *lli_in_array; struct sep_lli_entry_t *lli_in_array;
...@@ -1296,102 +1170,65 @@ int sep_prepare_input_output_dma_table(unsigned long app_virt_in_addr, ...@@ -1296,102 +1170,65 @@ int sep_prepare_input_output_dma_table(unsigned long app_virt_in_addr,
/* check if the pages are in Kernel Virtual Address layout */ /* check if the pages are in Kernel Virtual Address layout */
if (isKernelVirtualAddress == true) { if (isKernelVirtualAddress == true) {
/* lock the pages of the kernel buffer and translate them to pages */ /* lock the pages of the kernel buffer and translate them to pages */
result = sep_lock_kernel_pages(app_virt_in_addr, result = sep_lock_kernel_pages(app_virt_in_addr, data_size, &sep_dev->in_num_pages, &lli_in_array, &sep_dev->in_page_array);
data_size,
&sep_dev->in_num_pages,
&lli_in_array,
&sep_dev->in_page_array);
if (result) { if (result) {
edbg( edbg("SEP Driver: sep_lock_kernel_pages for input virtual buffer failed\n");
"SEP Driver: sep_lock_kernel_pages for input virtual buffer failed\n");
goto end_function; goto end_function;
} }
} else { } else {
/* lock the pages of the user buffer and translate them to pages */ /* lock the pages of the user buffer and translate them to pages */
result = sep_lock_user_pages(app_virt_in_addr, result = sep_lock_user_pages(app_virt_in_addr, data_size, &sep_dev->in_num_pages, &lli_in_array, &sep_dev->in_page_array);
data_size,
&sep_dev->in_num_pages,
&lli_in_array,
&sep_dev->in_page_array);
if (result) { if (result) {
edbg( edbg("SEP Driver: sep_lock_user_pages for input virtual buffer failed\n");
"SEP Driver: sep_lock_user_pages for input virtual buffer failed\n");
goto end_function; goto end_function;
} }
} }
if (isKernelVirtualAddress == true) { if (isKernelVirtualAddress == true) {
result = sep_lock_kernel_pages(app_virt_out_addr, result = sep_lock_kernel_pages(app_virt_out_addr, data_size, &sep_dev->out_num_pages, &lli_out_array, &sep_dev->out_page_array);
data_size,
&sep_dev->out_num_pages,
&lli_out_array,
&sep_dev->out_page_array);
if (result) { if (result) {
edbg( edbg("SEP Driver: sep_lock_kernel_pages for output virtual buffer failed\n");
"SEP Driver: sep_lock_kernel_pages for output virtual buffer failed\n");
goto end_function_with_error1; goto end_function_with_error1;
} }
} else { } else {
result = sep_lock_user_pages(app_virt_out_addr, result = sep_lock_user_pages(app_virt_out_addr, data_size, &sep_dev->out_num_pages, &lli_out_array, &sep_dev->out_page_array);
data_size,
&sep_dev->out_num_pages,
&lli_out_array,
&sep_dev->out_page_array);
if (result) { if (result) {
edbg( edbg("SEP Driver: sep_lock_user_pages for output virtual buffer failed\n");
"SEP Driver: sep_lock_user_pages for output virtual buffer failed\n");
goto end_function_with_error1; goto end_function_with_error1;
} }
} }
edbg( edbg("sep_dev->in_num_pages is %lu\n", sep_dev->in_num_pages);
"sep_dev->in_num_pages is %lu\n", sep_dev->in_num_pages); edbg("sep_dev->out_num_pages is %lu\n", sep_dev->out_num_pages);
edbg( edbg("SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP is %x\n", SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP);
"sep_dev->out_num_pages is %lu\n", sep_dev->out_num_pages);
edbg(
"SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP is %x\n",
SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP);
/* call the fucntion that creates table from the lli arrays */ /* call the fucntion that creates table from the lli arrays */
result = sep_construct_dma_tables_from_lli(lli_in_array, result = sep_construct_dma_tables_from_lli(lli_in_array, sep_dev->in_num_pages, lli_out_array, sep_dev->out_num_pages, block_size, lli_table_in_ptr, lli_table_out_ptr, in_num_entries_ptr, out_num_entries_ptr, table_data_size_ptr);
sep_dev->in_num_pages,
lli_out_array,
sep_dev->out_num_pages,
block_size,
lli_table_in_ptr,
lli_table_out_ptr,
in_num_entries_ptr,
out_num_entries_ptr,
table_data_size_ptr);
if (result) { if (result) {
edbg( edbg("SEP Driver: sep_construct_dma_tables_from_lli failed\n");
"SEP Driver: sep_construct_dma_tables_from_lli failed\n");
goto end_function_with_error2; goto end_function_with_error2;
} }
/* fall through - free the lli entry arrays */ /* fall through - free the lli entry arrays */
dbg("in_num_entries_ptr is %08lx\n", dbg("in_num_entries_ptr is %08lx\n", *in_num_entries_ptr);
*in_num_entries_ptr); dbg("out_num_entries_ptr is %08lx\n", *out_num_entries_ptr);
dbg("out_num_entries_ptr is %08lx\n", dbg("table_data_size_ptr is %08lx\n", *table_data_size_ptr);
*out_num_entries_ptr);
dbg("table_data_size_ptr is %08lx\n",
*table_data_size_ptr);
end_function_with_error2: end_function_with_error2:
kfree(lli_out_array); kfree(lli_out_array);
end_function_with_error1: end_function_with_error1:
kfree(lli_in_array); kfree(lli_in_array);
end_function: end_function:
dbg("SEP Driver:<-------- sep_prepare_input_output_dma_table end result = %d\n", (int)result); dbg("SEP Driver:<-------- sep_prepare_input_output_dma_table end result = %d\n", (int) result);
return result; return result;
...@@ -1406,12 +1243,7 @@ int sep_construct_dma_tables_from_lli(struct sep_lli_entry_t *lli_in_array, ...@@ -1406,12 +1243,7 @@ int sep_construct_dma_tables_from_lli(struct sep_lli_entry_t *lli_in_array,
unsigned long sep_in_lli_entries, unsigned long sep_in_lli_entries,
struct sep_lli_entry_t *lli_out_array, struct sep_lli_entry_t *lli_out_array,
unsigned long sep_out_lli_entries, unsigned long sep_out_lli_entries,
unsigned long block_size, unsigned long block_size, unsigned long *lli_table_in_ptr, unsigned long *lli_table_out_ptr, unsigned long *in_num_entries_ptr, unsigned long *out_num_entries_ptr, unsigned long *table_data_size_ptr)
unsigned long *lli_table_in_ptr,
unsigned long *lli_table_out_ptr,
unsigned long *in_num_entries_ptr,
unsigned long *out_num_entries_ptr,
unsigned long *table_data_size_ptr)
{ {
/* points to the area where next lli table can be allocated */ /* points to the area where next lli table can be allocated */
unsigned long lli_table_alloc_addr; unsigned long lli_table_alloc_addr;
...@@ -1459,8 +1291,7 @@ int sep_construct_dma_tables_from_lli(struct sep_lli_entry_t *lli_in_array, ...@@ -1459,8 +1291,7 @@ int sep_construct_dma_tables_from_lli(struct sep_lli_entry_t *lli_in_array,
dbg("SEP Driver:--------> sep_construct_dma_tables_from_lli start\n"); dbg("SEP Driver:--------> sep_construct_dma_tables_from_lli start\n");
/* initiate to pint after the message area */ /* initiate to pint after the message area */
lli_table_alloc_addr = sep_dev->shared_area_addr + lli_table_alloc_addr = sep_dev->shared_area_addr + SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES;
SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES;
current_in_entry = 0; current_in_entry = 0;
current_out_entry = 0; current_out_entry = 0;
...@@ -1471,33 +1302,23 @@ int sep_construct_dma_tables_from_lli(struct sep_lli_entry_t *lli_in_array, ...@@ -1471,33 +1302,23 @@ int sep_construct_dma_tables_from_lli(struct sep_lli_entry_t *lli_in_array,
/* loop till all the entries in in array are not processed */ /* loop till all the entries in in array are not processed */
while (current_in_entry < sep_in_lli_entries) { while (current_in_entry < sep_in_lli_entries) {
/* set the new input and output tables */ /* set the new input and output tables */
in_lli_table_ptr = (struct sep_lli_entry_t *)lli_table_alloc_addr; in_lli_table_ptr = (struct sep_lli_entry_t *) lli_table_alloc_addr;
lli_table_alloc_addr += sizeof(struct sep_lli_entry_t) * lli_table_alloc_addr += sizeof(struct sep_lli_entry_t) * SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP;
SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP;
/* set the first output tables */ /* set the first output tables */
out_lli_table_ptr = (struct sep_lli_entry_t *)lli_table_alloc_addr; out_lli_table_ptr = (struct sep_lli_entry_t *) lli_table_alloc_addr;
lli_table_alloc_addr += sizeof(struct sep_lli_entry_t) * lli_table_alloc_addr += sizeof(struct sep_lli_entry_t) * SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP;
SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP;
/* calculate the maximum size of data for input table */ /* calculate the maximum size of data for input table */
in_table_data_size = in_table_data_size = sep_calculate_lli_table_max_size(&lli_in_array[current_in_entry], (sep_in_lli_entries - current_in_entry));
sep_calculate_lli_table_max_size(
&lli_in_array[current_in_entry],
(sep_in_lli_entries - current_in_entry));
/* calculate the maximum size of data for output table */ /* calculate the maximum size of data for output table */
out_table_data_size = out_table_data_size = sep_calculate_lli_table_max_size(&lli_out_array[current_out_entry], (sep_out_lli_entries - current_out_entry));
sep_calculate_lli_table_max_size(
&lli_out_array[current_out_entry],
(sep_out_lli_entries - current_out_entry));
edbg( edbg("SEP Driver:in_table_data_size is %lu\n", in_table_data_size);
"SEP Driver:in_table_data_size is %lu\n", in_table_data_size); edbg("SEP Driver:out_table_data_size is %lu\n", out_table_data_size);
edbg(
"SEP Driver:out_table_data_size is %lu\n", out_table_data_size);
/* check where the data is smallest */ /* check where the data is smallest */
table_data_size = in_table_data_size; table_data_size = in_table_data_size;
...@@ -1510,76 +1331,48 @@ int sep_construct_dma_tables_from_lli(struct sep_lli_entry_t *lli_in_array, ...@@ -1510,76 +1331,48 @@ int sep_construct_dma_tables_from_lli(struct sep_lli_entry_t *lli_in_array,
dbg("SEP Driver:table_data_size is %lu\n", table_data_size); dbg("SEP Driver:table_data_size is %lu\n", table_data_size);
/* construct input lli table */ /* construct input lli table */
sep_build_lli_table(&lli_in_array[current_in_entry], sep_build_lli_table(&lli_in_array[current_in_entry], in_lli_table_ptr, &current_in_entry, &num_entries_in_table, table_data_size);
in_lli_table_ptr,
&current_in_entry,
&num_entries_in_table,
table_data_size);
/* construct output lli table */ /* construct output lli table */
sep_build_lli_table(&lli_out_array[current_out_entry], sep_build_lli_table(&lli_out_array[current_out_entry], out_lli_table_ptr, &current_out_entry, &num_entries_out_table, table_data_size);
out_lli_table_ptr,
&current_out_entry,
&num_entries_out_table,
table_data_size);
/* if info entry is null - this is the first table built */ /* if info entry is null - this is the first table built */
if (info_in_entry_ptr == 0) { if (info_in_entry_ptr == 0) {
/* set the output parameters to physical addresses */ /* set the output parameters to physical addresses */
*lli_table_in_ptr = *lli_table_in_ptr = sep_shared_area_virt_to_phys((unsigned long) in_lli_table_ptr);
sep_shared_area_virt_to_phys((unsigned long)in_lli_table_ptr);
*in_num_entries_ptr = num_entries_in_table; *in_num_entries_ptr = num_entries_in_table;
*lli_table_out_ptr = *lli_table_out_ptr = sep_shared_area_virt_to_phys((unsigned long) out_lli_table_ptr);
sep_shared_area_virt_to_phys((unsigned long)out_lli_table_ptr);
*out_num_entries_ptr = num_entries_out_table; *out_num_entries_ptr = num_entries_out_table;
*table_data_size_ptr = table_data_size; *table_data_size_ptr = table_data_size;
edbg( edbg("SEP Driver:output lli_table_in_ptr is %08lx\n", *lli_table_in_ptr);
"SEP Driver:output lli_table_in_ptr is %08lx\n", *lli_table_in_ptr); edbg("SEP Driver:output lli_table_out_ptr is %08lx\n", *lli_table_out_ptr);
edbg(
"SEP Driver:output lli_table_out_ptr is %08lx\n", *lli_table_out_ptr);
} else { } else {
/* update the info entry of the previous in table */ /* update the info entry of the previous in table */
info_in_entry_ptr->physical_address = info_in_entry_ptr->physical_address = sep_shared_area_virt_to_phys((unsigned long) in_lli_table_ptr);
sep_shared_area_virt_to_phys((unsigned long)in_lli_table_ptr); info_in_entry_ptr->block_size = ((num_entries_in_table) << 24) | (table_data_size);
info_in_entry_ptr->block_size =
((num_entries_in_table) << 24) | (table_data_size);
/* update the info entry of the previous in table */ /* update the info entry of the previous in table */
info_out_entry_ptr->physical_address = info_out_entry_ptr->physical_address = sep_shared_area_virt_to_phys((unsigned long) out_lli_table_ptr);
sep_shared_area_virt_to_phys((unsigned long)out_lli_table_ptr); info_out_entry_ptr->block_size = ((num_entries_out_table) << 24) | (table_data_size);
info_out_entry_ptr->block_size =
((num_entries_out_table) << 24) | (table_data_size);
} }
/* save the pointer to the info entry of the current tables */ /* save the pointer to the info entry of the current tables */
info_in_entry_ptr = in_lli_table_ptr + num_entries_in_table - 1; info_in_entry_ptr = in_lli_table_ptr + num_entries_in_table - 1;
info_out_entry_ptr = out_lli_table_ptr + num_entries_out_table - 1; info_out_entry_ptr = out_lli_table_ptr + num_entries_out_table - 1;
edbg( edbg("SEP Driver:output num_entries_out_table is %lu\n", (unsigned long) num_entries_out_table);
"SEP Driver:output num_entries_out_table is %lu\n", edbg("SEP Driver:output info_in_entry_ptr is %lu\n", (unsigned long) info_in_entry_ptr);
(unsigned long)num_entries_out_table); edbg("SEP Driver:output info_out_entry_ptr is %lu\n", (unsigned long) info_out_entry_ptr);
edbg(
"SEP Driver:output info_in_entry_ptr is %lu\n",
(unsigned long)info_in_entry_ptr);
edbg(
"SEP Driver:output info_out_entry_ptr is %lu\n",
(unsigned long)info_out_entry_ptr);
} }
/* print input tables */ /* print input tables */
sep_debug_print_lli_tables( sep_debug_print_lli_tables((struct sep_lli_entry_t *)
(struct sep_lli_entry_t *) sep_shared_area_phys_to_virt(*lli_table_in_ptr), *in_num_entries_ptr, *table_data_size_ptr);
sep_shared_area_phys_to_virt(*lli_table_in_ptr),
*in_num_entries_ptr,
*table_data_size_ptr);
/* print output tables */ /* print output tables */
sep_debug_print_lli_tables( sep_debug_print_lli_tables((struct sep_lli_entry_t *)
(struct sep_lli_entry_t *) sep_shared_area_phys_to_virt(*lli_table_out_ptr), *out_num_entries_ptr, *table_data_size_ptr);
sep_shared_area_phys_to_virt(*lli_table_out_ptr),
*out_num_entries_ptr,
*table_data_size_ptr);
dbg("SEP Driver:<-------- sep_construct_dma_tables_from_lli end\n"); dbg("SEP Driver:<-------- sep_construct_dma_tables_from_lli end\n");
...@@ -1591,9 +1384,7 @@ int sep_construct_dma_tables_from_lli(struct sep_lli_entry_t *lli_in_array, ...@@ -1591,9 +1384,7 @@ int sep_construct_dma_tables_from_lli(struct sep_lli_entry_t *lli_in_array,
table from this array the condition is that either the table is full 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 (all etnries are entered), or there are no more entries in the lli array
*/ */
unsigned long sep_calculate_lli_table_max_size( unsigned long sep_calculate_lli_table_max_size(struct sep_lli_entry_t *lli_in_array_ptr, unsigned long num_array_entries)
struct sep_lli_entry_t *lli_in_array_ptr,
unsigned long num_array_entries)
{ {
/* table data size */ /* table data size */
unsigned long table_data_size; unsigned long table_data_size;
...@@ -1609,9 +1400,7 @@ unsigned long sep_calculate_lli_table_max_size( ...@@ -1609,9 +1400,7 @@ unsigned long sep_calculate_lli_table_max_size(
/* calculate the data in the out lli table if till we fill the whole /* calculate the data in the out lli table if till we fill the whole
table or till the data has ended */ table or till the data has ended */
for (counter = 0; for (counter = 0; (counter < (SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP - 1)) && (counter < num_array_entries); counter++)
(counter < (SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP - 1)) &&
(counter < num_array_entries); counter++)
table_data_size += lli_in_array_ptr[counter].block_size; table_data_size += lli_in_array_ptr[counter].block_size;
return table_data_size; return table_data_size;
...@@ -1621,11 +1410,7 @@ unsigned long sep_calculate_lli_table_max_size( ...@@ -1621,11 +1410,7 @@ unsigned long sep_calculate_lli_table_max_size(
this functions builds ont lli table from the lli_array according to this functions builds ont lli table from the lli_array according to
the given size of data the given size of data
*/ */
static void sep_build_lli_table(struct sep_lli_entry_t *lli_array_ptr, static void sep_build_lli_table(struct sep_lli_entry_t *lli_array_ptr, struct sep_lli_entry_t *lli_table_ptr, unsigned long *num_processed_entries_ptr, unsigned long *num_table_entries_ptr, unsigned long table_data_size)
struct sep_lli_entry_t *lli_table_ptr,
unsigned long *num_processed_entries_ptr,
unsigned long *num_table_entries_ptr,
unsigned long table_data_size)
{ {
/* current table data size */ /* current table data size */
unsigned long curr_table_data_size; unsigned long curr_table_data_size;
...@@ -1644,55 +1429,39 @@ static void sep_build_lli_table(struct sep_lli_entry_t *lli_array_ptr, ...@@ -1644,55 +1429,39 @@ static void sep_build_lli_table(struct sep_lli_entry_t *lli_array_ptr,
array_counter = 0; array_counter = 0;
*num_table_entries_ptr = 1; *num_table_entries_ptr = 1;
edbg( edbg("SEP Driver:table_data_size is %lu\n", table_data_size);
"SEP Driver:table_data_size is %lu\n",
table_data_size);
/* fill the table till table size reaches the needed amount */ /* fill the table till table size reaches the needed amount */
while (curr_table_data_size < table_data_size) { while (curr_table_data_size < table_data_size) {
/* update the number of entries in table */ /* update the number of entries in table */
(*num_table_entries_ptr)++; (*num_table_entries_ptr)++;
lli_table_ptr->physical_address = lli_table_ptr->physical_address = lli_array_ptr[array_counter].physical_address;
lli_array_ptr[array_counter].physical_address;
lli_table_ptr->block_size = lli_array_ptr[array_counter].block_size; lli_table_ptr->block_size = lli_array_ptr[array_counter].block_size;
curr_table_data_size += lli_table_ptr->block_size; curr_table_data_size += lli_table_ptr->block_size;
edbg( edbg("SEP Driver:lli_table_ptr is %08lx\n", (unsigned long) lli_table_ptr);
"SEP Driver:lli_table_ptr is %08lx\n", edbg("SEP Driver:lli_table_ptr->physical_address is %08lx\n", lli_table_ptr->physical_address);
(unsigned long)lli_table_ptr); edbg("SEP Driver:lli_table_ptr->block_size is %lu\n", lli_table_ptr->block_size);
edbg(
"SEP Driver:lli_table_ptr->physical_address is %08lx\n",
lli_table_ptr->physical_address);
edbg(
"SEP Driver:lli_table_ptr->block_size is %lu\n",
lli_table_ptr->block_size);
/* check for overflow of the table data */ /* check for overflow of the table data */
if (curr_table_data_size > table_data_size) { if (curr_table_data_size > table_data_size) {
edbg( edbg("SEP Driver:curr_table_data_size > table_data_size\n");
"SEP Driver:curr_table_data_size > table_data_size\n");
/* update the size of block in the table */ /* update the size of block in the table */
lli_table_ptr->block_size -= (curr_table_data_size - table_data_size); lli_table_ptr->block_size -= (curr_table_data_size - table_data_size);
/* update the physical address in the lli array */ /* update the physical address in the lli array */
lli_array_ptr[array_counter].physical_address += lli_array_ptr[array_counter].physical_address += lli_table_ptr->block_size;
lli_table_ptr->block_size;
/* update the block size left in the lli array */ /* update the block size left in the lli array */
lli_array_ptr[array_counter].block_size = lli_array_ptr[array_counter].block_size = (curr_table_data_size - table_data_size);
(curr_table_data_size - table_data_size);
} else } else
/* advance to the next entry in the lli_array */ /* advance to the next entry in the lli_array */
array_counter++; array_counter++;
edbg( edbg("SEP Driver:lli_table_ptr->physical_address is %08lx\n", lli_table_ptr->physical_address);
"SEP Driver:lli_table_ptr->physical_address is %08lx\n", edbg("SEP Driver:lli_table_ptr->block_size is %lu\n", lli_table_ptr->block_size);
lli_table_ptr->physical_address);
edbg(
"SEP Driver:lli_table_ptr->block_size is %lu\n",
lli_table_ptr->block_size);
/* move to the next entry in table */ /* move to the next entry in table */
lli_table_ptr++; lli_table_ptr++;
...@@ -1702,23 +1471,15 @@ static void sep_build_lli_table(struct sep_lli_entry_t *lli_array_ptr, ...@@ -1702,23 +1471,15 @@ static void sep_build_lli_table(struct sep_lli_entry_t *lli_array_ptr,
lli_table_ptr->physical_address = 0xffffffff; lli_table_ptr->physical_address = 0xffffffff;
lli_table_ptr->block_size = 0; lli_table_ptr->block_size = 0;
edbg( edbg("SEP Driver:lli_table_ptr is %08lx\n", (unsigned long) lli_table_ptr);
"SEP Driver:lli_table_ptr is %08lx\n", edbg("SEP Driver:lli_table_ptr->physical_address is %08lx\n", lli_table_ptr->physical_address);
(unsigned long)lli_table_ptr); edbg("SEP Driver:lli_table_ptr->block_size is %lu\n", lli_table_ptr->block_size);
edbg(
"SEP Driver:lli_table_ptr->physical_address is %08lx\n",
lli_table_ptr->physical_address);
edbg(
"SEP Driver:lli_table_ptr->block_size is %lu\n",
lli_table_ptr->block_size);
/* set the output parameter */ /* set the output parameter */
*num_processed_entries_ptr += array_counter; *num_processed_entries_ptr += array_counter;
edbg( edbg("SEP Driver:*num_processed_entries_ptr is %lu\n", *num_processed_entries_ptr);
"SEP Driver:*num_processed_entries_ptr is %lu\n",
*num_processed_entries_ptr);
dbg("SEP Driver:<-------- sep_build_lli_table end\n"); dbg("SEP Driver:<-------- sep_build_lli_table end\n");
...@@ -1730,9 +1491,7 @@ static void sep_build_lli_table(struct sep_lli_entry_t *lli_array_ptr, ...@@ -1730,9 +1491,7 @@ static void sep_build_lli_table(struct sep_lli_entry_t *lli_array_ptr,
this function goes over the list of the print created tables and this function goes over the list of the print created tables and
prints all the data prints all the data
*/ */
static void sep_debug_print_lli_tables(struct sep_lli_entry_t *lli_table_ptr, static void sep_debug_print_lli_tables(struct sep_lli_entry_t *lli_table_ptr, unsigned long num_table_entries, unsigned long table_data_size)
unsigned long num_table_entries,
unsigned long table_data_size)
{ {
unsigned long table_count; unsigned long table_count;
...@@ -1744,30 +1503,21 @@ static void sep_debug_print_lli_tables(struct sep_lli_entry_t *lli_table_ptr, ...@@ -1744,30 +1503,21 @@ static void sep_debug_print_lli_tables(struct sep_lli_entry_t *lli_table_ptr,
dbg("SEP Driver:--------> sep_debug_print_lli_tables start\n"); dbg("SEP Driver:--------> sep_debug_print_lli_tables start\n");
table_count = 1; table_count = 1;
while ((unsigned long)lli_table_ptr != 0xffffffff) { while ((unsigned long) lli_table_ptr != 0xffffffff) {
edbg("SEP Driver: lli table %08lx, table_data_size is %lu\n", edbg("SEP Driver: lli table %08lx, table_data_size is %lu\n", table_count, table_data_size);
table_count, table_data_size);
edbg("SEP Driver: num_table_entries is %lu\n", num_table_entries); edbg("SEP Driver: num_table_entries is %lu\n", num_table_entries);
/* print entries of the table (without info entry) */ /* print entries of the table (without info entry) */
for (entries_count = 0; for (entries_count = 0; entries_count < num_table_entries; entries_count++, lli_table_ptr++) {
entries_count < num_table_entries; edbg("SEP Driver:lli_table_ptr address is %08lx\n", (unsigned long) lli_table_ptr);
entries_count++, lli_table_ptr++) { edbg("SEP Driver:phys address is %08lx block size is %lu\n", lli_table_ptr->physical_address, lli_table_ptr->block_size);
edbg("SEP Driver:lli_table_ptr address is %08lx\n",
(unsigned long)lli_table_ptr);
edbg("SEP Driver:phys address is %08lx block size is %lu\n",
lli_table_ptr->physical_address, lli_table_ptr->block_size);
} }
/* point to the info entry */ /* point to the info entry */
lli_table_ptr--; lli_table_ptr--;
edbg( edbg("SEP Driver:phys lli_table_ptr->block_size is %lu\n", lli_table_ptr->block_size);
"SEP Driver:phys lli_table_ptr->block_size is %lu\n", edbg("SEP Driver:phys lli_table_ptr->physical_address is %08lx\n", lli_table_ptr->physical_address);
lli_table_ptr->block_size);
edbg(
"SEP Driver:phys lli_table_ptr->physical_address is %08lx\n",
lli_table_ptr->physical_address);
table_data_size = lli_table_ptr->block_size & 0xffffff; table_data_size = lli_table_ptr->block_size & 0xffffff;
...@@ -1775,12 +1525,10 @@ static void sep_debug_print_lli_tables(struct sep_lli_entry_t *lli_table_ptr, ...@@ -1775,12 +1525,10 @@ static void sep_debug_print_lli_tables(struct sep_lli_entry_t *lli_table_ptr,
lli_table_ptr = (struct sep_lli_entry_t *) lli_table_ptr = (struct sep_lli_entry_t *)
(lli_table_ptr->physical_address); (lli_table_ptr->physical_address);
edbg("SEP Driver:phys table_data_size is %lu num_table_entries is %lu lli_table_ptr is%lu\n", edbg("SEP Driver:phys table_data_size is %lu num_table_entries is %lu lli_table_ptr is%lu\n", table_data_size, num_table_entries, (unsigned long) lli_table_ptr);
table_data_size, num_table_entries, (unsigned long)lli_table_ptr);
if ((unsigned long)lli_table_ptr != 0xffffffff) if ((unsigned long) lli_table_ptr != 0xffffffff)
lli_table_ptr = (struct sep_lli_entry_t *)sep_shared_area_phys_to_virt( lli_table_ptr = (struct sep_lli_entry_t *) sep_shared_area_phys_to_virt((unsigned long) lli_table_ptr);
(unsigned long)lli_table_ptr);
table_count++; table_count++;
} }
...@@ -1794,12 +1542,7 @@ static void sep_debug_print_lli_tables(struct sep_lli_entry_t *lli_table_ptr, ...@@ -1794,12 +1542,7 @@ static void sep_debug_print_lli_tables(struct sep_lli_entry_t *lli_table_ptr,
and construct a basic lli array, where each entry holds the physical page 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 address and the size that application data holds in this physical pages
*/ */
int sep_lock_user_pages(unsigned long app_virt_addr, int sep_lock_user_pages(unsigned long app_virt_addr, unsigned long data_size, unsigned long *num_pages_ptr, struct sep_lli_entry_t **lli_array_ptr, struct page ***page_array_ptr)
unsigned long data_size,
unsigned long *num_pages_ptr,
struct sep_lli_entry_t **lli_array_ptr,
struct page ***page_array_ptr)
{ {
/* error */ /* error */
int error; int error;
...@@ -1838,27 +1581,16 @@ int sep_lock_user_pages(unsigned long app_virt_addr, ...@@ -1838,27 +1581,16 @@ int sep_lock_user_pages(unsigned long app_virt_addr,
start_page = app_virt_addr >> PAGE_SHIFT; start_page = app_virt_addr >> PAGE_SHIFT;
num_pages = end_page - start_page + 1; num_pages = end_page - start_page + 1;
edbg( edbg("SEP Driver: app_virt_addr is %08lx\n", app_virt_addr);
"SEP Driver: app_virt_addr is %08lx\n", edbg("SEP Driver: data_size is %lu\n", data_size);
app_virt_addr); edbg("SEP Driver: start_page is %lu\n", start_page);
edbg( edbg("SEP Driver: end_page is %lu\n", end_page);
"SEP Driver: data_size is %lu\n", edbg("SEP Driver: num_pages is %lu\n", num_pages);
data_size);
edbg(
"SEP Driver: start_page is %lu\n",
start_page);
edbg(
"SEP Driver: end_page is %lu\n",
end_page);
edbg(
"SEP Driver: num_pages is %lu\n",
num_pages);
/* allocate array of pages structure pointers */ /* allocate array of pages structure pointers */
page_array = kmalloc(sizeof(struct page *) * num_pages, GFP_ATOMIC); page_array = kmalloc(sizeof(struct page *) * num_pages, GFP_ATOMIC);
if (!page_array) { if (!page_array) {
edbg( edbg("SEP Driver: kmalloc for page_array failed\n");
"SEP Driver: kmalloc for page_array failed\n");
error = -ENOMEM; error = -ENOMEM;
goto end_function; goto end_function;
...@@ -1866,8 +1598,7 @@ int sep_lock_user_pages(unsigned long app_virt_addr, ...@@ -1866,8 +1598,7 @@ int sep_lock_user_pages(unsigned long app_virt_addr,
lli_array = kmalloc(sizeof(struct sep_lli_entry_t) * num_pages, GFP_ATOMIC); lli_array = kmalloc(sizeof(struct sep_lli_entry_t) * num_pages, GFP_ATOMIC);
if (!lli_array) { if (!lli_array) {
edbg( edbg("SEP Driver: kmalloc for lli_array failed\n");
"SEP Driver: kmalloc for lli_array failed\n");
error = -ENOMEM; error = -ENOMEM;
goto end_function_with_error1; goto end_function_with_error1;
...@@ -1875,9 +1606,7 @@ int sep_lock_user_pages(unsigned long app_virt_addr, ...@@ -1875,9 +1606,7 @@ int sep_lock_user_pages(unsigned long app_virt_addr,
/* convert the application virtual address into a set of physical */ /* convert the application virtual address into a set of physical */
down_read(&current->mm->mmap_sem); down_read(&current->mm->mmap_sem);
result = get_user_pages(current, current->mm, app_virt_addr, num_pages, 1, 0, result = get_user_pages(current, current->mm, app_virt_addr, num_pages, 1, 0, page_array, 0);
page_array,
0);
up_read(&current->mm->mmap_sem); up_read(&current->mm->mmap_sem);
/* check the number of pages locked - if not all then exit with error */ /* check the number of pages locked - if not all then exit with error */
...@@ -1894,9 +1623,7 @@ int sep_lock_user_pages(unsigned long app_virt_addr, ...@@ -1894,9 +1623,7 @@ int sep_lock_user_pages(unsigned long app_virt_addr,
/* set the start address of the first page - app data may start not at /* set the start address of the first page - app data may start not at
the beginning of the page */ the beginning of the page */
lli_array[0].physical_address = ( lli_array[0].physical_address = ((unsigned long) page_to_phys(page_array[0])) + (app_virt_addr & (~PAGE_MASK));
(unsigned long)page_to_phys(page_array[0])) +
(app_virt_addr & (~PAGE_MASK)) ;
/* check that not all the data is in the first page only */ /* check that not all the data is in the first page only */
if ((PAGE_SIZE - (app_virt_addr & (~PAGE_MASK))) >= data_size) if ((PAGE_SIZE - (app_virt_addr & (~PAGE_MASK))) >= data_size)
...@@ -1905,45 +1632,32 @@ int sep_lock_user_pages(unsigned long app_virt_addr, ...@@ -1905,45 +1632,32 @@ int sep_lock_user_pages(unsigned long app_virt_addr,
lli_array[0].block_size = PAGE_SIZE - (app_virt_addr & (~PAGE_MASK)); lli_array[0].block_size = PAGE_SIZE - (app_virt_addr & (~PAGE_MASK));
/* debug print */ /* debug print */
dbg("lli_array[0].physical_address is %08lx, lli_array[0].block_size is %lu\n", dbg("lli_array[0].physical_address is %08lx, lli_array[0].block_size is %lu\n", lli_array[0].physical_address, lli_array[0].block_size);
lli_array[0].physical_address,
lli_array[0].block_size);
/* go from the second page to the prev before last */ /* go from the second page to the prev before last */
for (count = 1; count < (num_pages - 1); count++) { for (count = 1; count < (num_pages - 1); count++) {
lli_array[count].physical_address = lli_array[count].physical_address = (unsigned long) page_to_phys(page_array[count]);
(unsigned long)page_to_phys(page_array[count]);
lli_array[count].block_size = PAGE_SIZE; lli_array[count].block_size = PAGE_SIZE;
edbg( edbg("lli_array[%lu].physical_address is %08lx, \
"lli_array[%lu].physical_address is %08lx, \ lli_array[%lu].block_size is %lu\n", count, lli_array[count].physical_address, count, lli_array[count].block_size);
lli_array[%lu].block_size is %lu\n",
count, lli_array[count].physical_address,
count,
lli_array[count].block_size);
} }
/* if more then 1 pages locked - then update for the last page size needed */ /* if more then 1 pages locked - then update for the last page size needed */
if (num_pages > 1) { if (num_pages > 1) {
/* update the address of the last page */ /* update the address of the last page */
lli_array[count].physical_address = lli_array[count].physical_address = (unsigned long) page_to_phys(page_array[count]);
(unsigned long)page_to_phys(page_array[count]);
/* set the size of the last page */ /* set the size of the last page */
lli_array[count].block_size = (app_virt_addr + data_size) & lli_array[count].block_size = (app_virt_addr + data_size) & (~PAGE_MASK);
(~PAGE_MASK);
if (lli_array[count].block_size == 0) { if (lli_array[count].block_size == 0) {
dbg("app_virt_addr is %08lx\n", app_virt_addr); dbg("app_virt_addr is %08lx\n", app_virt_addr);
dbg("data_size is %lu\n", data_size); dbg("data_size is %lu\n", data_size);
while (1); while (1);
} }
edbg( edbg("lli_array[%lu].physical_address is %08lx, \
"lli_array[%lu].physical_address is %08lx, \ lli_array[%lu].block_size is %lu\n", count, lli_array[count].physical_address, count, lli_array[count].block_size);
lli_array[%lu].block_size is %lu\n",
count, lli_array[count].physical_address,
count,
lli_array[count].block_size);
} }
/* set output params */ /* set output params */
...@@ -1953,7 +1667,7 @@ int sep_lock_user_pages(unsigned long app_virt_addr, ...@@ -1953,7 +1667,7 @@ int sep_lock_user_pages(unsigned long app_virt_addr,
goto end_function; goto end_function;
end_function_with_error2: end_function_with_error2:
/* release the cache */ /* release the cache */
for (count = 0; count < num_pages; count++) for (count = 0; count < num_pages; count++)
...@@ -1962,12 +1676,12 @@ int sep_lock_user_pages(unsigned long app_virt_addr, ...@@ -1962,12 +1676,12 @@ int sep_lock_user_pages(unsigned long app_virt_addr,
/* free lli array */ /* free lli array */
kfree(lli_array); kfree(lli_array);
end_function_with_error1: end_function_with_error1:
/* free page array */ /* free page array */
kfree(page_array); kfree(page_array);
end_function: end_function:
dbg("SEP Driver:<-------- sep_lock_user_pages end\n"); dbg("SEP Driver:<-------- sep_lock_user_pages end\n");
...@@ -1979,12 +1693,7 @@ int sep_lock_user_pages(unsigned long app_virt_addr, ...@@ -1979,12 +1693,7 @@ int sep_lock_user_pages(unsigned long app_virt_addr,
and construct a basic lli array, where each entry holds the physical 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 page address and the size that application data holds in this physical pages
*/ */
int sep_lock_kernel_pages(unsigned long kernel_virt_addr, int sep_lock_kernel_pages(unsigned long kernel_virt_addr, unsigned long data_size, unsigned long *num_pages_ptr, struct sep_lli_entry_t **lli_array_ptr, struct page ***page_array_ptr)
unsigned long data_size,
unsigned long *num_pages_ptr,
struct sep_lli_entry_t **lli_array_ptr,
struct page ***page_array_ptr)
{ {
/* error */ /* error */
int error; int error;
...@@ -2021,26 +1730,15 @@ int sep_lock_kernel_pages(unsigned long kernel_virt_addr, ...@@ -2021,26 +1730,15 @@ int sep_lock_kernel_pages(unsigned long kernel_virt_addr,
start_page = kernel_virt_addr >> PAGE_SHIFT; start_page = kernel_virt_addr >> PAGE_SHIFT;
num_pages = end_page - start_page + 1; num_pages = end_page - start_page + 1;
edbg( edbg("SEP Driver: kernel_virt_addr is %08lx\n", kernel_virt_addr);
"SEP Driver: kernel_virt_addr is %08lx\n", edbg("SEP Driver: data_size is %lu\n", data_size);
kernel_virt_addr); edbg("SEP Driver: start_page is %lx\n", start_page);
edbg( edbg("SEP Driver: end_page is %lx\n", end_page);
"SEP Driver: data_size is %lu\n", edbg("SEP Driver: num_pages is %lu\n", num_pages);
data_size);
edbg(
"SEP Driver: start_page is %lx\n",
start_page);
edbg(
"SEP Driver: end_page is %lx\n",
end_page);
edbg(
"SEP Driver: num_pages is %lu\n",
num_pages);
lli_array = kmalloc(sizeof(struct sep_lli_entry_t) * num_pages, GFP_ATOMIC); lli_array = kmalloc(sizeof(struct sep_lli_entry_t) * num_pages, GFP_ATOMIC);
if (!lli_array) { if (!lli_array) {
edbg( edbg("SEP Driver: kmalloc for lli_array failed\n");
"SEP Driver: kmalloc for lli_array failed\n");
error = -ENOMEM; error = -ENOMEM;
goto end_function; goto end_function;
...@@ -2048,35 +1746,27 @@ int sep_lock_kernel_pages(unsigned long kernel_virt_addr, ...@@ -2048,35 +1746,27 @@ int sep_lock_kernel_pages(unsigned long kernel_virt_addr,
/* set the start address of the first page - app data may start not at /* set the start address of the first page - app data may start not at
the beginning of the page */ the beginning of the page */
lli_array[0].physical_address = lli_array[0].physical_address = (unsigned long) virt_to_phys((unsigned long *) kernel_virt_addr);
(unsigned long)virt_to_phys((unsigned long *)kernel_virt_addr);
/* check that not all the data is in the first page only */ /* check that not all the data is in the first page only */
if ((PAGE_SIZE - (kernel_virt_addr & (~PAGE_MASK))) >= data_size) if ((PAGE_SIZE - (kernel_virt_addr & (~PAGE_MASK))) >= data_size)
lli_array[0].block_size = data_size; lli_array[0].block_size = data_size;
else else
lli_array[0].block_size = lli_array[0].block_size = PAGE_SIZE - (kernel_virt_addr & (~PAGE_MASK));
PAGE_SIZE - (kernel_virt_addr & (~PAGE_MASK));
/* debug print */ /* debug print */
dbg("lli_array[0].physical_address is %08lx, lli_array[0].block_size is %lu\n", dbg("lli_array[0].physical_address is %08lx, lli_array[0].block_size is %lu\n", lli_array[0].physical_address, lli_array[0].block_size);
lli_array[0].physical_address,
lli_array[0].block_size);
/* advance the address to the start of the next page */ /* advance the address to the start of the next page */
next_kernel_address = (kernel_virt_addr & PAGE_MASK) + PAGE_SIZE; next_kernel_address = (kernel_virt_addr & PAGE_MASK) + PAGE_SIZE;
/* go from the second page to the prev before last */ /* go from the second page to the prev before last */
for (count = 1; count < (num_pages - 1); count++) { for (count = 1; count < (num_pages - 1); count++) {
lli_array[count].physical_address = lli_array[count].physical_address = (unsigned long) virt_to_phys((unsigned long *) next_kernel_address);
(unsigned long)virt_to_phys((unsigned long *)next_kernel_address);
lli_array[count].block_size = PAGE_SIZE; lli_array[count].block_size = PAGE_SIZE;
edbg( edbg("lli_array[%lu].physical_address is %08lx, \
"lli_array[%lu].physical_address is %08lx, \ lli_array[%lu].block_size is %lu\n", count, lli_array[count].physical_address, count, lli_array[count].block_size);
lli_array[%lu].block_size is %lu\n",
count, lli_array[count].physical_address, count,
lli_array[count].block_size);
next_kernel_address += PAGE_SIZE; next_kernel_address += PAGE_SIZE;
} }
...@@ -2084,26 +1774,19 @@ int sep_lock_kernel_pages(unsigned long kernel_virt_addr, ...@@ -2084,26 +1774,19 @@ int sep_lock_kernel_pages(unsigned long kernel_virt_addr,
/* if more then 1 pages locked - then update for the last page size needed */ /* if more then 1 pages locked - then update for the last page size needed */
if (num_pages > 1) { if (num_pages > 1) {
/* update the address of the last page */ /* update the address of the last page */
lli_array[count].physical_address = lli_array[count].physical_address = (unsigned long) virt_to_phys((unsigned long *) next_kernel_address);
(unsigned long)virt_to_phys((unsigned long *)next_kernel_address);
/* set the size of the last page */ /* set the size of the last page */
lli_array[count].block_size = lli_array[count].block_size = (kernel_virt_addr + data_size) & (~PAGE_MASK);
(kernel_virt_addr + data_size) & (~PAGE_MASK);
if (lli_array[count].block_size == 0) { if (lli_array[count].block_size == 0) {
dbg("app_virt_addr is %08lx\n", dbg("app_virt_addr is %08lx\n", kernel_virt_addr);
kernel_virt_addr);
dbg("data_size is %lu\n", data_size); dbg("data_size is %lu\n", data_size);
while (1); while (1);
} }
edbg( edbg("lli_array[%lu].physical_address is %08lx, \
"lli_array[%lu].physical_address is %08lx, \ lli_array[%lu].block_size is %lu\n", count, lli_array[count].physical_address, count, lli_array[count].block_size);
lli_array[%lu].block_size is %lu\n",
count, lli_array[count].physical_address,
count,
lli_array[count].block_size);
} }
/* set output params */ /* set output params */
...@@ -2112,7 +1795,7 @@ int sep_lock_kernel_pages(unsigned long kernel_virt_addr, ...@@ -2112,7 +1795,7 @@ int sep_lock_kernel_pages(unsigned long kernel_virt_addr,
*page_array_ptr = 0; *page_array_ptr = 0;
end_function: end_function:
dbg("SEP Driver:<-------- sep_lock_kernel_pages end\n"); dbg("SEP Driver:<-------- sep_lock_kernel_pages end\n");
...@@ -2123,9 +1806,7 @@ int sep_lock_kernel_pages(unsigned long kernel_virt_addr, ...@@ -2123,9 +1806,7 @@ int sep_lock_kernel_pages(unsigned long kernel_virt_addr,
This function releases all the application virtual buffer physical pages, This function releases all the application virtual buffer physical pages,
that were previously locked that were previously locked
*/ */
int sep_free_dma_pages(struct page **page_array_ptr, int sep_free_dma_pages(struct page **page_array_ptr, unsigned long num_pages, unsigned long dirtyFlag)
unsigned long num_pages,
unsigned long dirtyFlag)
{ {
/* count */ /* count */
unsigned long count; unsigned long count;
...@@ -2172,8 +1853,7 @@ static void sep_send_command_handler() ...@@ -2172,8 +1853,7 @@ static void sep_send_command_handler()
flush_cache_all(); flush_cache_all();
for (count = 0; count < 12 * 4; count += 4) for (count = 0; count < 12 * 4; count += 4)
edbg("Word %lu of the message is %lu\n", count, edbg("Word %lu of the message is %lu\n", count, *((unsigned long *) (sep_dev->shared_area_addr + count)));
*((unsigned long *)(sep_dev->shared_area_addr + count)));
/* update counter */ /* update counter */
sep_dev->host_to_sep_send_counter++; sep_dev->host_to_sep_send_counter++;
...@@ -2200,16 +1880,14 @@ static void sep_send_reply_command_handler() ...@@ -2200,16 +1880,14 @@ static void sep_send_reply_command_handler()
flush_cache_all(); flush_cache_all();
for (count = 0; count < 12 * 4; count += 4) for (count = 0; count < 12 * 4; count += 4)
edbg("Word %lu of the message is %lu\n", count, edbg("Word %lu of the message is %lu\n", count, *((unsigned long *) (sep_dev->shared_area_addr + count)));
*((unsigned long *)(sep_dev->shared_area_addr + count)));
/* update counter */ /* update counter */
sep_dev->host_to_sep_send_counter++; sep_dev->host_to_sep_send_counter++;
/* send the interrupt to SEP */ /* send the interrupt to SEP */
sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR2_REG_ADDR, sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR2_REG_ADDR, sep_dev->host_to_sep_send_counter);
sep_dev->host_to_sep_send_counter);
/* update both counters */ /* update both counters */
sep_dev->host_to_sep_send_counter++; sep_dev->host_to_sep_send_counter++;
...@@ -2245,38 +1923,29 @@ static int sep_allocate_data_pool_memory_handler(unsigned long arg) ...@@ -2245,38 +1923,29 @@ static int sep_allocate_data_pool_memory_handler(unsigned long arg)
dbg("SEP Driver:--------> sep_allocate_data_pool_memory_handler start\n"); dbg("SEP Driver:--------> sep_allocate_data_pool_memory_handler start\n");
error = copy_from_user(&command_args, error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_alloc_t));
(void *)arg,
sizeof(struct sep_driver_alloc_t));
if (error) if (error)
goto end_function; goto end_function;
/* allocate memory */ /* allocate memory */
if ( if ((sep_dev->data_pool_bytes_allocated + command_args.num_bytes) > SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES) {
(sep_dev->data_pool_bytes_allocated + command_args.num_bytes) >
SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES) {
error = -ENOTTY; error = -ENOTTY;
goto end_function; goto end_function;
} }
/* set the virtual and physical address */ /* set the virtual and physical address */
command_args.offset = SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES + command_args.offset = SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES + sep_dev->data_pool_bytes_allocated;
sep_dev->data_pool_bytes_allocated; command_args.phys_address = sep_dev->phys_shared_area_addr + SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES + sep_dev->data_pool_bytes_allocated;
command_args.phys_address = sep_dev->phys_shared_area_addr +
SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES +
sep_dev->data_pool_bytes_allocated;
/* write the memory back to the user space */ /* write the memory back to the user space */
error = copy_to_user((void *)arg, error = copy_to_user((void *) arg, (void *) &command_args, sizeof(struct sep_driver_alloc_t));
(void *)&command_args,
sizeof(struct sep_driver_alloc_t));
if (error) if (error)
goto end_function; goto end_function;
/* set the allocation */ /* set the allocation */
sep_dev->data_pool_bytes_allocated += command_args.num_bytes; sep_dev->data_pool_bytes_allocated += command_args.num_bytes;
end_function: end_function:
dbg("SEP Driver:<-------- sep_allocate_data_pool_memory_handler end\n"); dbg("SEP Driver:<-------- sep_allocate_data_pool_memory_handler end\n");
...@@ -2310,41 +1979,34 @@ static int sep_write_into_data_pool_handler(unsigned long arg) ...@@ -2310,41 +1979,34 @@ static int sep_write_into_data_pool_handler(unsigned long arg)
dbg("SEP Driver:--------> sep_write_into_data_pool_handler start\n"); dbg("SEP Driver:--------> sep_write_into_data_pool_handler start\n");
/* get the application address */ /* get the application address */
error = get_user(app_in_address, error = get_user(app_in_address, &(((struct sep_driver_write_t *) arg)->app_address));
&(((struct sep_driver_write_t *)arg)->app_address));
if (error) if (error)
goto end_function; goto end_function;
/* get the virtual kernel address address */ /* get the virtual kernel address address */
error = get_user(virt_address, error = get_user(virt_address, &(((struct sep_driver_write_t *) arg)->datapool_address));
&(((struct sep_driver_write_t *)arg)->datapool_address));
if (error) if (error)
goto end_function; goto end_function;
/* get the number of bytes */ /* get the number of bytes */
error = get_user(num_bytes, &(((struct sep_driver_write_t *)arg)->num_bytes)); error = get_user(num_bytes, &(((struct sep_driver_write_t *) arg)->num_bytes));
if (error) if (error)
goto end_function; goto end_function;
/* calculate the start of the data pool */ /* calculate the start of the data pool */
data_pool_area_addr = sep_dev->shared_area_addr + data_pool_area_addr = sep_dev->shared_area_addr + SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES;
SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES;
/* check that the range of the virtual kernel address is correct */ /* check that the range of the virtual kernel address is correct */
if ((virt_address < data_pool_area_addr) || if ((virt_address < data_pool_area_addr) || (virt_address > (data_pool_area_addr + SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES))) {
(virt_address > (data_pool_area_addr +
SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES))) {
error = -ENOTTY; error = -ENOTTY;
goto end_function; goto end_function;
} }
/* copy the application data */ /* copy the application data */
error = copy_from_user((void *)virt_address, error = copy_from_user((void *) virt_address, (void *) app_in_address, num_bytes);
(void *)app_in_address,
num_bytes);
end_function: end_function:
dbg("SEP Driver:<-------- sep_write_into_data_pool_handler end\n"); dbg("SEP Driver:<-------- sep_write_into_data_pool_handler end\n");
...@@ -2378,39 +2040,33 @@ static int sep_read_from_data_pool_handler(unsigned long arg) ...@@ -2378,39 +2040,33 @@ static int sep_read_from_data_pool_handler(unsigned long arg)
dbg("SEP Driver:--------> sep_read_from_data_pool_handler start\n"); dbg("SEP Driver:--------> sep_read_from_data_pool_handler start\n");
/* get the application address */ /* get the application address */
error = get_user(app_out_address, error = get_user(app_out_address, &(((struct sep_driver_write_t *) arg)->app_address));
&(((struct sep_driver_write_t *)arg)->app_address));
if (error) if (error)
goto end_function; goto end_function;
/* get the virtual kernel address address */ /* get the virtual kernel address address */
error = get_user(virt_address, error = get_user(virt_address, &(((struct sep_driver_write_t *) arg)->datapool_address));
&(((struct sep_driver_write_t *)arg)->datapool_address));
if (error) if (error)
goto end_function; goto end_function;
/* get the number of bytes */ /* get the number of bytes */
error = get_user(num_bytes, &(((struct sep_driver_write_t *)arg)->num_bytes)); error = get_user(num_bytes, &(((struct sep_driver_write_t *) arg)->num_bytes));
if (error) if (error)
goto end_function; goto end_function;
/* calculate the start of the data pool */ /* calculate the start of the data pool */
data_pool_area_addr = sep_dev->shared_area_addr + data_pool_area_addr = sep_dev->shared_area_addr + SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES;
SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES;
/* check that the range of the virtual kernel address is correct */ /* check that the range of the virtual kernel address is correct */
if ((virt_address < data_pool_area_addr) || if ((virt_address < data_pool_area_addr) || (virt_address > (data_pool_area_addr + SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES))) {
(virt_address > (data_pool_area_addr +
SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES))) {
error = -ENOTTY; error = -ENOTTY;
goto end_function; goto end_function;
} }
/* copy the application data */ /* copy the application data */
error = copy_to_user((void *)app_out_address, (void *)virt_address, error = copy_to_user((void *) app_out_address, (void *) virt_address, num_bytes);
num_bytes);
end_function: end_function:
dbg("SEP Driver:<-------- sep_read_from_data_pool_handler end\n"); dbg("SEP Driver:<-------- sep_read_from_data_pool_handler end\n");
...@@ -2436,24 +2092,14 @@ static int sep_create_sync_dma_tables_handler(unsigned long arg) ...@@ -2436,24 +2092,14 @@ static int sep_create_sync_dma_tables_handler(unsigned long arg)
dbg("SEP Driver:--------> sep_create_sync_dma_tables_handler start\n"); dbg("SEP Driver:--------> sep_create_sync_dma_tables_handler start\n");
error = copy_from_user(&command_args, error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_build_sync_table_t));
(void *)arg,
sizeof(struct sep_driver_build_sync_table_t));
if (error) if (error)
goto end_function; goto end_function;
edbg( edbg("app_in_address is %08lx\n", command_args.app_in_address);
"app_in_address is %08lx\n", edbg("app_out_address is %08lx\n", command_args.app_out_address);
command_args.app_in_address); edbg("data_size is %lu\n", command_args.data_in_size);
edbg( edbg("block_size is %lu\n", command_args.block_size);
"app_out_address is %08lx\n",
command_args.app_out_address);
edbg(
"data_size is %lu\n",
command_args.data_in_size);
edbg(
"block_size is %lu\n",
command_args.block_size);
/* check if we need to build only input table or input/output */ /* check if we need to build only input table or input/output */
...@@ -2464,30 +2110,19 @@ static int sep_create_sync_dma_tables_handler(unsigned long arg) ...@@ -2464,30 +2110,19 @@ static int sep_create_sync_dma_tables_handler(unsigned long arg)
command_args.data_in_size, command_args.data_in_size,
command_args.block_size, command_args.block_size,
&command_args.in_table_address, &command_args.in_table_address,
&command_args.out_table_address, &command_args.out_table_address, &command_args.in_table_num_entries, &command_args.out_table_num_entries, &command_args.table_data_size, command_args.isKernelVirtualAddress);
&command_args.in_table_num_entries,
&command_args.out_table_num_entries,
&command_args.table_data_size,
command_args.isKernelVirtualAddress);
else else
/* prepare input tables */ /* prepare input tables */
error = sep_prepare_input_dma_table(command_args.app_in_address, error = sep_prepare_input_dma_table(command_args.app_in_address,
command_args.data_in_size, command_args.data_in_size, command_args.block_size, &command_args.in_table_address, &command_args.in_table_num_entries, &command_args.table_data_size, command_args.isKernelVirtualAddress);
command_args.block_size,
&command_args.in_table_address,
&command_args.in_table_num_entries,
&command_args.table_data_size,
command_args.isKernelVirtualAddress);
if (error) if (error)
goto end_function; goto end_function;
/* copy to user */ /* copy to user */
error = copy_to_user((void *)arg, error = copy_to_user((void *) arg, (void *) &command_args, sizeof(struct sep_driver_build_sync_table_t));
(void *)&command_args,
sizeof(struct sep_driver_build_sync_table_t));
end_function: end_function:
dbg("SEP Driver:<-------- sep_create_sync_dma_tables_handler end\n"); dbg("SEP Driver:<-------- sep_create_sync_dma_tables_handler end\n");
...@@ -2506,15 +2141,11 @@ int sep_free_dma_table_data_handler() ...@@ -2506,15 +2141,11 @@ int sep_free_dma_table_data_handler()
dbg("SEP Driver:--------> sep_free_dma_table_data_handler start\n"); dbg("SEP Driver:--------> sep_free_dma_table_data_handler start\n");
/* free input pages array */ /* free input pages array */
sep_free_dma_pages(sep_dev->in_page_array, sep_free_dma_pages(sep_dev->in_page_array, sep_dev->in_num_pages, 0);
sep_dev->in_num_pages,
0);
/* free output pages array if needed */ /* free output pages array if needed */
if (sep_dev->out_page_array) if (sep_dev->out_page_array)
sep_free_dma_pages(sep_dev->out_page_array, sep_free_dma_pages(sep_dev->out_page_array, sep_dev->out_num_pages, 1);
sep_dev->out_num_pages,
1);
/* reset all the values */ /* reset all the values */
sep_dev->in_page_array = 0; sep_dev->in_page_array = 0;
...@@ -2566,19 +2197,12 @@ static int sep_create_flow_dma_tables_handler(unsigned long arg) ...@@ -2566,19 +2197,12 @@ static int sep_create_flow_dma_tables_handler(unsigned long arg)
if (error) if (error)
goto end_function; goto end_function;
error = copy_from_user(&command_args, error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_build_flow_table_t));
(void *)arg,
sizeof(struct sep_driver_build_flow_table_t));
if (error) if (error)
goto end_function; goto end_function;
/* create flow tables */ /* create flow tables */
error = sep_prepare_flow_dma_tables(command_args.num_virtual_buffers, error = sep_prepare_flow_dma_tables(command_args.num_virtual_buffers, command_args.virt_buff_data_addr, flow_context_ptr, &first_table_data, &last_table_data, command_args.isKernelVirtualAddress);
command_args.virt_buff_data_addr,
flow_context_ptr,
&first_table_data,
&last_table_data,
command_args.isKernelVirtualAddress);
if (error) if (error)
goto end_function_with_error; goto end_function_with_error;
...@@ -2589,16 +2213,11 @@ static int sep_create_flow_dma_tables_handler(unsigned long arg) ...@@ -2589,16 +2213,11 @@ static int sep_create_flow_dma_tables_handler(unsigned long arg)
/* set output params */ /* set output params */
command_args.first_table_addr = first_table_data.physical_address; command_args.first_table_addr = first_table_data.physical_address;
command_args.first_table_num_entries = command_args.first_table_num_entries = ((first_table_data.block_size >> SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK);
((first_table_data.block_size >> SEP_NUM_ENTRIES_OFFSET_IN_BITS) & command_args.first_table_data_size = (first_table_data.block_size & SEP_TABLE_DATA_SIZE_MASK);
SEP_NUM_ENTRIES_MASK);
command_args.first_table_data_size =
(first_table_data.block_size & SEP_TABLE_DATA_SIZE_MASK);
/* send the parameters to user application */ /* send the parameters to user application */
error = copy_to_user((void *)arg, error = copy_to_user((void *) arg, &command_args, sizeof(struct sep_driver_build_flow_table_t));
&command_args,
sizeof(struct sep_driver_build_flow_table_t));
if (error) if (error)
goto end_function_with_error; goto end_function_with_error;
...@@ -2613,12 +2232,12 @@ static int sep_create_flow_dma_tables_handler(unsigned long arg) ...@@ -2613,12 +2232,12 @@ static int sep_create_flow_dma_tables_handler(unsigned long arg)
goto end_function; goto end_function;
end_function_with_error: end_function_with_error:
/* free the allocated tables */ /* free the allocated tables */
sep_deallocated_flow_tables(&first_table_data); sep_deallocated_flow_tables(&first_table_data);
end_function: end_function:
dbg("SEP Driver:<-------- sep_create_flow_dma_tables_handler end\n"); dbg("SEP Driver:<-------- sep_create_flow_dma_tables_handler end\n");
...@@ -2659,9 +2278,7 @@ static int sep_add_flow_tables_handler(unsigned long arg) ...@@ -2659,9 +2278,7 @@ static int sep_add_flow_tables_handler(unsigned long arg)
dbg("SEP Driver:--------> sep_add_flow_tables_handler start\n"); dbg("SEP Driver:--------> sep_add_flow_tables_handler start\n");
/* get input parameters */ /* get input parameters */
error = copy_from_user(&command_args, error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_add_flow_table_t));
(void *)arg,
sizeof(struct sep_driver_add_flow_table_t));
if (error) if (error)
goto end_function; goto end_function;
...@@ -2671,12 +2288,7 @@ static int sep_add_flow_tables_handler(unsigned long arg) ...@@ -2671,12 +2288,7 @@ static int sep_add_flow_tables_handler(unsigned long arg)
goto end_function; goto end_function;
/* prepare the flow dma tables */ /* prepare the flow dma tables */
error = sep_prepare_flow_dma_tables(command_args.num_virtual_buffers, error = sep_prepare_flow_dma_tables(command_args.num_virtual_buffers, command_args.virt_buff_data_addr, flow_context_ptr, &first_table_data, &last_table_data, command_args.isKernelVirtualAddress);
command_args.virt_buff_data_addr,
flow_context_ptr,
&first_table_data,
&last_table_data,
command_args.isKernelVirtualAddress);
if (error) if (error)
goto end_function_with_error; goto end_function_with_error;
...@@ -2686,13 +2298,10 @@ static int sep_add_flow_tables_handler(unsigned long arg) ...@@ -2686,13 +2298,10 @@ static int sep_add_flow_tables_handler(unsigned long arg)
if (flow_context_ptr->input_tables_flag) { if (flow_context_ptr->input_tables_flag) {
/* add table already exists - add the new tables to the end /* add table already exists - add the new tables to the end
of the previous */ of the previous */
num_entries = (flow_context_ptr->last_input_table.block_size >> num_entries = (flow_context_ptr->last_input_table.block_size >> SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK;
SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK;
info_entry_ptr = info_entry_ptr = (struct sep_lli_entry_t *)
(struct sep_lli_entry_t *) (flow_context_ptr->last_input_table.physical_address + (sizeof(struct sep_lli_entry_t) * (num_entries - 1)));
(flow_context_ptr->last_input_table.physical_address +
(sizeof(struct sep_lli_entry_t) * (num_entries - 1)));
/* connect to list of tables */ /* connect to list of tables */
*info_entry_ptr = first_table_data; *info_entry_ptr = first_table_data;
...@@ -2708,18 +2317,16 @@ static int sep_add_flow_tables_handler(unsigned long arg) ...@@ -2708,18 +2317,16 @@ static int sep_add_flow_tables_handler(unsigned long arg)
} }
/* set the last table data */ /* set the last table data */
flow_context_ptr->last_input_table = last_table_data; flow_context_ptr->last_input_table = last_table_data;
} else /* this is output tables */ { } else { /* this is output tables */
/* this buffer was for input buffers */ /* this buffer was for input buffers */
if (flow_context_ptr->output_tables_flag) { if (flow_context_ptr->output_tables_flag) {
/* add table already exists - add the new tables to /* add table already exists - add the new tables to
the end of the previous */ the end of the previous */
num_entries = (flow_context_ptr->last_output_table.block_size >> num_entries = (flow_context_ptr->last_output_table.block_size >> SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK;
SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK;
info_entry_ptr = info_entry_ptr = (struct sep_lli_entry_t *)
(struct sep_lli_entry_t *) (flow_context_ptr->last_output_table.physical_address + (sizeof(struct sep_lli_entry_t) * (num_entries - 1)));
(flow_context_ptr->last_output_table.physical_address +
(sizeof(struct sep_lli_entry_t) * (num_entries - 1)));
/* connect to list of tables */ /* connect to list of tables */
*info_entry_ptr = first_table_data; *info_entry_ptr = first_table_data;
...@@ -2739,24 +2346,20 @@ static int sep_add_flow_tables_handler(unsigned long arg) ...@@ -2739,24 +2346,20 @@ static int sep_add_flow_tables_handler(unsigned long arg)
/* set output params */ /* set output params */
command_args.first_table_addr = first_table_data.physical_address; command_args.first_table_addr = first_table_data.physical_address;
command_args.first_table_num_entries = ((first_table_data.block_size >> command_args.first_table_num_entries = ((first_table_data.block_size >> SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK);
SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK); command_args.first_table_data_size = (first_table_data.block_size & SEP_TABLE_DATA_SIZE_MASK);
command_args.first_table_data_size =
(first_table_data.block_size & SEP_TABLE_DATA_SIZE_MASK);
/* send the parameters to user application */ /* send the parameters to user application */
error = copy_to_user((void *)arg, error = copy_to_user((void *) arg, &command_args, sizeof(struct sep_driver_add_flow_table_t));
&command_args,
sizeof(struct sep_driver_add_flow_table_t));
if (error) if (error)
goto end_function_with_error; goto end_function_with_error;
end_function_with_error: end_function_with_error:
/* free the allocated tables */ /* free the allocated tables */
sep_deallocated_flow_tables(&first_table_data); sep_deallocated_flow_tables(&first_table_data);
end_function: end_function:
dbg("SEP Driver:<-------- sep_add_flow_tables_handler end\n"); dbg("SEP Driver:<-------- sep_add_flow_tables_handler end\n");
...@@ -2783,15 +2386,12 @@ static int sep_add_flow_tables_message_handler(unsigned long arg) ...@@ -2783,15 +2386,12 @@ static int sep_add_flow_tables_message_handler(unsigned long arg)
dbg("SEP Driver:--------> sep_add_flow_tables_message_handler start\n"); dbg("SEP Driver:--------> sep_add_flow_tables_message_handler start\n");
error = copy_from_user(&command_args, error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_add_message_t));
(void *)arg,
sizeof(struct sep_driver_add_message_t));
if (error) if (error)
goto end_function; goto end_function;
/* check input */ /* check input */
if (command_args.message_size_in_bytes > if (command_args.message_size_in_bytes > SEP_MAX_ADD_MESSAGE_LENGTH_IN_BYTES) {
SEP_MAX_ADD_MESSAGE_LENGTH_IN_BYTES) {
error = -ENOMEM; error = -ENOMEM;
goto end_function; goto end_function;
} }
...@@ -2804,12 +2404,10 @@ static int sep_add_flow_tables_message_handler(unsigned long arg) ...@@ -2804,12 +2404,10 @@ static int sep_add_flow_tables_message_handler(unsigned long arg)
/* copy the message into context */ /* copy the message into context */
flow_context_ptr->message_size_in_bytes = command_args.message_size_in_bytes; flow_context_ptr->message_size_in_bytes = command_args.message_size_in_bytes;
error = copy_from_user(flow_context_ptr->message, error = copy_from_user(flow_context_ptr->message, (void *) command_args.message_address, command_args.message_size_in_bytes);
(void *)command_args.message_address,
command_args.message_size_in_bytes);
end_function: end_function:
dbg("SEP Driver:<-------- sep_add_flow_tables_message_handler end\n"); dbg("SEP Driver:<-------- sep_add_flow_tables_message_handler end\n");
...@@ -2835,23 +2433,17 @@ static int sep_get_static_pool_addr_handler(unsigned long arg) ...@@ -2835,23 +2433,17 @@ static int sep_get_static_pool_addr_handler(unsigned long arg)
dbg("SEP Driver:--------> sep_get_static_pool_addr_handler start\n"); dbg("SEP Driver:--------> sep_get_static_pool_addr_handler start\n");
/*prepare the output parameters in the struct */ /*prepare the output parameters in the struct */
command_args.physical_static_address = sep_dev->phys_shared_area_addr + command_args.physical_static_address = sep_dev->phys_shared_area_addr + SEP_DRIVER_STATIC_AREA_OFFSET_IN_BYTES;
SEP_DRIVER_STATIC_AREA_OFFSET_IN_BYTES; command_args.virtual_static_address = sep_dev->shared_area_addr + SEP_DRIVER_STATIC_AREA_OFFSET_IN_BYTES;
command_args.virtual_static_address = sep_dev->shared_area_addr +
SEP_DRIVER_STATIC_AREA_OFFSET_IN_BYTES;
edbg("SEP Driver:physical_static_address is %08lx, virtual_static_address %08lx\n", edbg("SEP Driver:physical_static_address is %08lx, virtual_static_address %08lx\n", command_args.physical_static_address, command_args.virtual_static_address);
command_args.physical_static_address,
command_args.virtual_static_address);
/* send the parameters to user application */ /* send the parameters to user application */
error = copy_to_user((void *)arg, error = copy_to_user((void *) arg, &command_args, sizeof(struct sep_driver_static_pool_addr_t));
&command_args,
sizeof(struct sep_driver_static_pool_addr_t));
if (error) if (error)
goto end_function; goto end_function;
end_function: end_function:
dbg("SEP Driver:<-------- sep_get_static_pool_addr_handler end\n"); dbg("SEP Driver:<-------- sep_get_static_pool_addr_handler end\n");
...@@ -2876,9 +2468,7 @@ static int sep_get_physical_mapped_offset_handler(unsigned long arg) ...@@ -2876,9 +2468,7 @@ static int sep_get_physical_mapped_offset_handler(unsigned long arg)
dbg("SEP Driver:--------> sep_get_physical_mapped_offset_handler start\n"); dbg("SEP Driver:--------> sep_get_physical_mapped_offset_handler start\n");
error = copy_from_user(&command_args, error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_get_mapped_offset_t));
(void *)arg,
sizeof(struct sep_driver_get_mapped_offset_t));
if (error) if (error)
goto end_function; goto end_function;
...@@ -2888,21 +2478,16 @@ static int sep_get_physical_mapped_offset_handler(unsigned long arg) ...@@ -2888,21 +2478,16 @@ static int sep_get_physical_mapped_offset_handler(unsigned long arg)
} }
/*prepare the output parameters in the struct */ /*prepare the output parameters in the struct */
command_args.offset = command_args.physical_address - command_args.offset = command_args.physical_address - sep_dev->phys_shared_area_addr;
sep_dev->phys_shared_area_addr;
edbg("SEP Driver:physical_address is %08lx, offset is %lu\n", edbg("SEP Driver:physical_address is %08lx, offset is %lu\n", command_args.physical_address, command_args.offset);
command_args.physical_address,
command_args.offset);
/* send the parameters to user application */ /* send the parameters to user application */
error = copy_to_user((void *)arg, error = copy_to_user((void *) arg, &command_args, sizeof(struct sep_driver_get_mapped_offset_t));
&command_args,
sizeof(struct sep_driver_get_mapped_offset_t));
if (error) if (error)
goto end_function; goto end_function;
end_function: end_function:
dbg("SEP Driver:<-------- sep_get_physical_mapped_offset_handler end\n"); dbg("SEP Driver:<-------- sep_get_physical_mapped_offset_handler end\n");
...@@ -2941,7 +2526,7 @@ static int sep_start_handler(void) ...@@ -2941,7 +2526,7 @@ static int sep_start_handler(void)
goto end_function; goto end_function;
} }
end_function: end_function:
dbg("SEP Driver:<-------- sep_start_handler end\n"); dbg("SEP Driver:<-------- sep_start_handler end\n");
...@@ -2979,8 +2564,7 @@ static int sep_init_handler(unsigned long arg) ...@@ -2979,8 +2564,7 @@ static int sep_init_handler(unsigned long arg)
error = 0; error = 0;
error = copy_from_user(&command_args, (void *)arg, error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_init_t));
sizeof(struct sep_driver_init_t));
dbg("SEP Driver:--------> sep_init_handler - finished copy_from_user \n"); dbg("SEP Driver:--------> sep_init_handler - finished copy_from_user \n");
...@@ -2988,27 +2572,22 @@ static int sep_init_handler(unsigned long arg) ...@@ -2988,27 +2572,22 @@ static int sep_init_handler(unsigned long arg)
goto end_function; goto end_function;
/* PATCH - configure the DMA to single -burst instead of multi-burst */ /* PATCH - configure the DMA to single -burst instead of multi-burst */
/*sep_configure_dma_burst();*/ /*sep_configure_dma_burst(); */
dbg("SEP Driver:--------> sep_init_handler - finished sep_configure_dma_burst \n"); dbg("SEP Driver:--------> sep_init_handler - finished sep_configure_dma_burst \n");
message_ptr = (unsigned long *)command_args.message_addr; message_ptr = (unsigned long *) command_args.message_addr;
/* set the base address of the SRAM */ /* set the base address of the SRAM */
sep_write_reg(sep_dev, HW_SRAM_ADDR_REG_ADDR, HW_CC_SRAM_BASE_ADDRESS); sep_write_reg(sep_dev, HW_SRAM_ADDR_REG_ADDR, HW_CC_SRAM_BASE_ADDRESS);
for (counter = 0 ; for (counter = 0; counter < command_args.message_size_in_words; counter++, message_ptr++) {
counter < command_args.message_size_in_words;
counter++, message_ptr++) {
get_user(message_word, message_ptr); get_user(message_word, message_ptr);
/* write data to SRAM */ /* write data to SRAM */
sep_write_reg(sep_dev, HW_SRAM_DATA_REG_ADDR, sep_write_reg(sep_dev, HW_SRAM_DATA_REG_ADDR, message_word);
message_word);
edbg( edbg("SEP Driver:message_word is %lu\n", message_word);
"SEP Driver:message_word is %lu\n",
message_word);
/* wait for write complete */ /* wait for write complete */
sep_wait_sram_write(sep_dev); sep_wait_sram_write(sep_dev);
...@@ -3017,8 +2596,7 @@ static int sep_init_handler(unsigned long arg) ...@@ -3017,8 +2596,7 @@ static int sep_init_handler(unsigned long arg)
dbg("SEP Driver:--------> sep_init_handler - finished getting messages from user space\n"); dbg("SEP Driver:--------> sep_init_handler - finished getting messages from user space\n");
/* signal SEP */ /* signal SEP */
sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR0_REG_ADDR, sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR0_REG_ADDR, 0x1);
0x1);
do { do {
reg_val = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR3_REG_ADDR); reg_val = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR3_REG_ADDR);
...@@ -3028,22 +2606,18 @@ static int sep_init_handler(unsigned long arg) ...@@ -3028,22 +2606,18 @@ static int sep_init_handler(unsigned long arg)
/* check the value */ /* check the value */
if (reg_val == 0x1) { if (reg_val == 0x1) {
edbg( edbg("SEP Driver:init failed\n");
"SEP Driver:init failed\n");
error = sep_read_reg(sep_dev, 0x8060); error = sep_read_reg(sep_dev, 0x8060);
edbg( edbg("SEP Driver:sw monitor is %lu\n", error);
"SEP Driver:sw monitor is %lu\n",
error);
/* fatal error - read erro status from GPRO */ /* fatal error - read erro status from GPRO */
error = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR); error = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR);
edbg( edbg("SEP Driver:error is %lu\n", error);
"SEP Driver:error is %lu\n", error);
goto end_function; goto end_function;
} }
end_function: end_function:
dbg("SEP Driver:<-------- sep_init_handler end\n"); dbg("SEP Driver:<-------- sep_init_handler end\n");
...@@ -3073,19 +2647,12 @@ static int sep_realloc_cache_resident_handler(unsigned long arg) ...@@ -3073,19 +2647,12 @@ static int sep_realloc_cache_resident_handler(unsigned long arg)
---------------------*/ ---------------------*/
/* copy the data */ /* copy the data */
error = copy_from_user(&command_args, error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_realloc_cache_resident_t));
(void *)arg,
sizeof(struct sep_driver_realloc_cache_resident_t));
if (error) if (error)
goto end_function; goto end_function;
/* copy cache and resident to the their intended locations */ /* copy cache and resident to the their intended locations */
error = sep_copy_cache_resident_to_area(command_args.cache_addr, error = sep_copy_cache_resident_to_area(command_args.cache_addr, command_args.cache_size_in_bytes, command_args.resident_addr, command_args.resident_size_in_bytes, &phys_cache_address, &phys_resident_address);
command_args.cache_size_in_bytes,
command_args.resident_addr,
command_args.resident_size_in_bytes,
&phys_cache_address,
&phys_resident_address);
if (error) if (error)
goto end_function; goto end_function;
...@@ -3109,25 +2676,15 @@ static int sep_realloc_cache_resident_handler(unsigned long arg) ...@@ -3109,25 +2676,15 @@ static int sep_realloc_cache_resident_handler(unsigned long arg)
/* set the new shared area */ /* set the new shared area */
command_args.new_shared_area_addr = sep_dev->phys_shared_area_addr; command_args.new_shared_area_addr = sep_dev->phys_shared_area_addr;
edbg( edbg("SEP Driver:command_args.new_shared_area_addr is %08lx\n", command_args.new_shared_area_addr);
"SEP Driver:command_args.new_shared_area_addr is %08lx\n", edbg("SEP Driver:command_args.new_base_addr is %08lx\n", command_args.new_base_addr);
command_args.new_shared_area_addr); edbg("SEP Driver:command_args.new_resident_addr is %08lx\n", command_args.new_resident_addr);
edbg( edbg("SEP Driver:command_args.new_cache_addr is %08lx\n", command_args.new_cache_addr);
"SEP Driver:command_args.new_base_addr is %08lx\n",
command_args.new_base_addr);
edbg(
"SEP Driver:command_args.new_resident_addr is %08lx\n",
command_args.new_resident_addr);
edbg(
"SEP Driver:command_args.new_cache_addr is %08lx\n",
command_args.new_cache_addr);
/* return to user */ /* return to user */
error = copy_to_user((void *)arg, error = copy_to_user((void *) arg, (void *) &command_args, sizeof(struct sep_driver_realloc_cache_resident_t));
(void *)&command_args,
sizeof(struct sep_driver_realloc_cache_resident_t));
end_function: end_function:
return error; return error;
} }
...@@ -3147,13 +2704,10 @@ static int sep_get_time_handler(unsigned long arg) ...@@ -3147,13 +2704,10 @@ static int sep_get_time_handler(unsigned long arg)
CODE CODE
--------------------------*/ --------------------------*/
error = sep_set_time(&command_args.time_physical_address, error = sep_set_time(&command_args.time_physical_address, &command_args.time_value);
&command_args.time_value);
/* return to user */ /* return to user */
error = copy_to_user((void *)arg, error = copy_to_user((void *) arg, (void *) &command_args, sizeof(struct sep_driver_get_time_t));
(void *)&command_args,
sizeof(struct sep_driver_get_time_t));
return error; return error;
...@@ -3176,8 +2730,7 @@ static int sep_set_api_mode_handler(unsigned long arg) ...@@ -3176,8 +2730,7 @@ static int sep_set_api_mode_handler(unsigned long arg)
dbg("SEP Driver:--------> sep_set_api_mode_handler start\n"); dbg("SEP Driver:--------> sep_set_api_mode_handler start\n");
error = get_user( error = get_user(mode_flag, &(((struct sep_driver_set_api_mode_t *) arg)->mode));
mode_flag, &(((struct sep_driver_set_api_mode_t *)arg)->mode));
if (error) if (error)
goto end_function; goto end_function;
...@@ -3185,7 +2738,7 @@ static int sep_set_api_mode_handler(unsigned long arg) ...@@ -3185,7 +2738,7 @@ static int sep_set_api_mode_handler(unsigned long arg)
sep_dev->block_mode_flag = mode_flag; sep_dev->block_mode_flag = mode_flag;
end_function: end_function:
dbg("SEP Driver:<-------- sep_set_api_mode_handler end\n"); dbg("SEP Driver:<-------- sep_set_api_mode_handler end\n");
...@@ -3203,7 +2756,7 @@ static int sep_end_transaction_handler(unsigned long arg) ...@@ -3203,7 +2756,7 @@ static int sep_end_transaction_handler(unsigned long arg)
dbg("SEP Driver:--------> sep_end_transaction_handler start\n"); dbg("SEP Driver:--------> sep_end_transaction_handler start\n");
#if 0/*!SEP_DRIVER_POLLING_MODE*/ #if 0 /*!SEP_DRIVER_POLLING_MODE */
/* close IMR */ /* close IMR */
sep_write_reg(sep_dev, HW_HOST_IMR_REG_ADDR, 0x7FFF); sep_write_reg(sep_dev, HW_HOST_IMR_REG_ADDR, 0x7FFF);
...@@ -3232,7 +2785,7 @@ static void sep_flow_done_handler(struct work_struct *work) ...@@ -3232,7 +2785,7 @@ static void sep_flow_done_handler(struct work_struct *work)
mutex_lock(&sep_mutex); mutex_lock(&sep_mutex);
/* get the pointer to context */ /* get the pointer to context */
flow_data_ptr = (struct sep_flow_context_t *)work; flow_data_ptr = (struct sep_flow_context_t *) work;
/* free all the current input tables in sep */ /* free all the current input tables in sep */
sep_deallocated_flow_tables(&flow_data_ptr->input_tables_in_process); sep_deallocated_flow_tables(&flow_data_ptr->input_tables_in_process);
...@@ -3245,9 +2798,7 @@ static void sep_flow_done_handler(struct work_struct *work) ...@@ -3245,9 +2798,7 @@ static void sep_flow_done_handler(struct work_struct *work)
flag may be checked */ flag may be checked */
if (flow_data_ptr->input_tables_flag) { if (flow_data_ptr->input_tables_flag) {
/* copy the message to the shared RAM and signal SEP */ /* copy the message to the shared RAM and signal SEP */
memcpy((void *)flow_data_ptr->message, memcpy((void *) flow_data_ptr->message, (void *) sep_dev->shared_area_addr, flow_data_ptr->message_size_in_bytes);
(void *)sep_dev->shared_area_addr,
flow_data_ptr->message_size_in_bytes);
sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR2_REG_ADDR, 0x2); sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR2_REG_ADDR, 0x2);
} }
...@@ -3260,11 +2811,7 @@ static void sep_flow_done_handler(struct work_struct *work) ...@@ -3260,11 +2811,7 @@ static void sep_flow_done_handler(struct work_struct *work)
the first and last tables of the list the first and last tables of the list
*/ */
static int sep_prepare_flow_dma_tables(unsigned long num_virtual_buffers, static int sep_prepare_flow_dma_tables(unsigned long num_virtual_buffers,
unsigned long first_buff_addr, unsigned long first_buff_addr, struct sep_flow_context_t *flow_data_ptr, struct sep_lli_entry_t *first_table_data_ptr, struct sep_lli_entry_t *last_table_data_ptr, bool isKernelVirtualAddress)
struct sep_flow_context_t *flow_data_ptr,
struct sep_lli_entry_t *first_table_data_ptr,
struct sep_lli_entry_t *last_table_data_ptr,
bool isKernelVirtualAddress)
{ {
/* error */ /* error */
int error; int error;
...@@ -3316,12 +2863,7 @@ static int sep_prepare_flow_dma_tables(unsigned long num_virtual_buffers, ...@@ -3316,12 +2863,7 @@ static int sep_prepare_flow_dma_tables(unsigned long num_virtual_buffers,
first_buff_addr++; first_buff_addr++;
/* now prepare the one flow LLI table from the data */ /* now prepare the one flow LLI table from the data */
error = sep_prepare_one_flow_dma_table(virt_buff_addr, error = sep_prepare_one_flow_dma_table(virt_buff_addr, virt_buff_size, &table_data, &info_entry_ptr, flow_data_ptr, isKernelVirtualAddress);
virt_buff_size,
&table_data,
&info_entry_ptr,
flow_data_ptr,
isKernelVirtualAddress);
if (error) if (error)
goto end_function; goto end_function;
...@@ -3335,9 +2877,7 @@ static int sep_prepare_flow_dma_tables(unsigned long num_virtual_buffers, ...@@ -3335,9 +2877,7 @@ static int sep_prepare_flow_dma_tables(unsigned long num_virtual_buffers,
} else { } else {
/* not first table - the previous table info entry should /* not first table - the previous table info entry should
be updated */ be updated */
prev_info_entry_ptr->block_size = prev_info_entry_ptr->block_size = (0x1 << SEP_INT_FLAG_OFFSET_IN_BITS) | (table_data.block_size);
(0x1 << SEP_INT_FLAG_OFFSET_IN_BITS) |
(table_data.block_size);
/* set the pointer to info entry */ /* set the pointer to info entry */
prev_info_entry_ptr = info_entry_ptr; prev_info_entry_ptr = info_entry_ptr;
...@@ -3347,7 +2887,7 @@ static int sep_prepare_flow_dma_tables(unsigned long num_virtual_buffers, ...@@ -3347,7 +2887,7 @@ static int sep_prepare_flow_dma_tables(unsigned long num_virtual_buffers,
/* set the last table data */ /* set the last table data */
*last_table_data_ptr = table_data; *last_table_data_ptr = table_data;
end_function: end_function:
return error; return error;
} }
...@@ -3357,13 +2897,7 @@ static int sep_prepare_flow_dma_tables(unsigned long num_virtual_buffers, ...@@ -3357,13 +2897,7 @@ static int sep_prepare_flow_dma_tables(unsigned long num_virtual_buffers,
This function creates one DMA table for flow and returns its data, This function creates one DMA table for flow and returns its data,
and pointer to its info entry and pointer to its info entry
*/ */
static int sep_prepare_one_flow_dma_table( static int sep_prepare_one_flow_dma_table(unsigned long virt_buff_addr, unsigned long virt_buff_size, struct sep_lli_entry_t *table_data, struct sep_lli_entry_t **info_entry_ptr, struct sep_flow_context_t *flow_data_ptr, bool isKernelVirtualAddress)
unsigned long virt_buff_addr,
unsigned long virt_buff_size,
struct sep_lli_entry_t *table_data,
struct sep_lli_entry_t **info_entry_ptr,
struct sep_flow_context_t *flow_data_ptr,
bool isKernelVirtualAddress)
{ {
/* error */ /* error */
int error; int error;
...@@ -3401,18 +2935,10 @@ static int sep_prepare_one_flow_dma_table( ...@@ -3401,18 +2935,10 @@ static int sep_prepare_one_flow_dma_table(
/* check if the pages are in Kernel Virtual Address layout */ /* check if the pages are in Kernel Virtual Address layout */
if (isKernelVirtualAddress == true) if (isKernelVirtualAddress == true)
/* lock kernel buffer in the memory */ /* lock kernel buffer in the memory */
error = sep_lock_kernel_pages(virt_buff_addr, error = sep_lock_kernel_pages(virt_buff_addr, virt_buff_size, &lli_array_size, &lli_array, &page_array_ptr);
virt_buff_size,
&lli_array_size,
&lli_array,
&page_array_ptr);
else else
/* lock user buffer in the memory */ /* lock user buffer in the memory */
error = sep_lock_user_pages(virt_buff_addr, error = sep_lock_user_pages(virt_buff_addr, virt_buff_size, &lli_array_size, &lli_array, &page_array_ptr);
virt_buff_size,
&lli_array_size,
&lli_array,
&page_array_ptr);
if (error) if (error)
goto end_function; goto end_function;
...@@ -3425,20 +2951,16 @@ static int sep_prepare_one_flow_dma_table( ...@@ -3425,20 +2951,16 @@ static int sep_prepare_one_flow_dma_table(
start_dma_table_ptr++; start_dma_table_ptr++;
/* set the pages pointer */ /* set the pages pointer */
*start_dma_table_ptr = (unsigned long)page_array_ptr; *start_dma_table_ptr = (unsigned long) page_array_ptr;
/* set the pointer to the first entry */ /* set the pointer to the first entry */
flow_dma_table_entry_ptr = (struct sep_lli_entry_t *)(++start_dma_table_ptr); flow_dma_table_entry_ptr = (struct sep_lli_entry_t *) (++start_dma_table_ptr);
/* now create the entries for table */ /* now create the entries for table */
for (dma_table_data_count = entry_count = 0; for (dma_table_data_count = entry_count = 0; entry_count < lli_array_size; entry_count++) {
entry_count < lli_array_size; flow_dma_table_entry_ptr->physical_address = lli_array[entry_count].physical_address;
entry_count++) {
flow_dma_table_entry_ptr->physical_address =
lli_array[entry_count].physical_address;
flow_dma_table_entry_ptr->block_size = flow_dma_table_entry_ptr->block_size = lli_array[entry_count].block_size;
lli_array[entry_count].block_size;
/* set the total data of a table */ /* set the total data of a table */
dma_table_data_count += lli_array[entry_count].block_size; dma_table_data_count += lli_array[entry_count].block_size;
...@@ -3450,9 +2972,7 @@ static int sep_prepare_one_flow_dma_table( ...@@ -3450,9 +2972,7 @@ static int sep_prepare_one_flow_dma_table(
table_data->physical_address = virt_to_phys(start_dma_table_ptr); table_data->physical_address = virt_to_phys(start_dma_table_ptr);
/* set the num_entries and total data size */ /* set the num_entries and total data size */
table_data->block_size = ((lli_array_size + 1) << table_data->block_size = ((lli_array_size + 1) << SEP_NUM_ENTRIES_OFFSET_IN_BITS) | (dma_table_data_count);
SEP_NUM_ENTRIES_OFFSET_IN_BITS) |
(dma_table_data_count);
/* set the info entry */ /* set the info entry */
flow_dma_table_entry_ptr->physical_address = 0xffffffff; flow_dma_table_entry_ptr->physical_address = 0xffffffff;
...@@ -3464,7 +2984,7 @@ static int sep_prepare_one_flow_dma_table( ...@@ -3464,7 +2984,7 @@ static int sep_prepare_one_flow_dma_table(
/* the array of the lli entries */ /* the array of the lli entries */
kfree(lli_array); kfree(lli_array);
end_function: end_function:
return error; return error;
} }
...@@ -3474,9 +2994,7 @@ static int sep_prepare_one_flow_dma_table( ...@@ -3474,9 +2994,7 @@ static int sep_prepare_one_flow_dma_table(
This function returns pointer to the flow data structure This function returns pointer to the flow data structure
that conatins the given id that conatins the given id
*/ */
static int sep_find_flow_context( static int sep_find_flow_context(unsigned long flow_id, struct sep_flow_context_t **flow_data_ptr)
unsigned long flow_id,
struct sep_flow_context_t **flow_data_ptr)
{ {
/* count */ /* count */
unsigned long count; unsigned long count;
...@@ -3512,8 +3030,7 @@ static int sep_find_flow_context( ...@@ -3512,8 +3030,7 @@ static int sep_find_flow_context(
/* /*
this function find a space for the new flow dma table this function find a space for the new flow dma table
*/ */
static int sep_find_free_flow_dma_table_space( static int sep_find_free_flow_dma_table_space(unsigned long **table_address_ptr)
unsigned long **table_address_ptr)
{ {
/* error */ /* error */
int error; int error;
...@@ -3537,28 +3054,23 @@ static int sep_find_free_flow_dma_table_space( ...@@ -3537,28 +3054,23 @@ static int sep_find_free_flow_dma_table_space(
error = 0; error = 0;
/* find the start address of the flow DMA table area */ /* find the start address of the flow DMA table area */
flow_dma_area_start_addr = sep_dev->shared_area_addr + flow_dma_area_start_addr = sep_dev->shared_area_addr + SEP_DRIVER_FLOW_DMA_TABLES_AREA_OFFSET_IN_BYTES;
SEP_DRIVER_FLOW_DMA_TABLES_AREA_OFFSET_IN_BYTES;
/* set end address of the flow table area */ /* set end address of the flow table area */
flow_dma_area_end_addr = flow_dma_area_start_addr + flow_dma_area_end_addr = flow_dma_area_start_addr + SEP_DRIVER_FLOW_DMA_TABLES_AREA_SIZE_IN_BYTES;
SEP_DRIVER_FLOW_DMA_TABLES_AREA_SIZE_IN_BYTES;
/* set table size in words */ /* set table size in words */
table_size_in_words = SEP_DRIVER_MAX_FLOW_NUM_ENTRIES_IN_TABLE * table_size_in_words = SEP_DRIVER_MAX_FLOW_NUM_ENTRIES_IN_TABLE * (sizeof(struct sep_lli_entry_t) / sizeof(long)) + 2;
(sizeof(struct sep_lli_entry_t) / sizeof(long)) + 2;
/* set the pointer to the start address of DMA area */ /* set the pointer to the start address of DMA area */
start_table_ptr = (unsigned long *)flow_dma_area_start_addr; start_table_ptr = (unsigned long *) flow_dma_area_start_addr;
/* find the space for the next table */ /* find the space for the next table */
while (((*start_table_ptr & 0x7FFFFFFF) != 0) && while (((*start_table_ptr & 0x7FFFFFFF) != 0) && ((unsigned long) start_table_ptr < flow_dma_area_end_addr))
((unsigned long)start_table_ptr <
flow_dma_area_end_addr))
start_table_ptr += table_size_in_words; start_table_ptr += table_size_in_words;
/* check if we reached the end of floa tables area */ /* check if we reached the end of floa tables area */
if ((unsigned long)start_table_ptr >= flow_dma_area_end_addr) if ((unsigned long) start_table_ptr >= flow_dma_area_end_addr)
error = -1; error = -1;
else else
*table_address_ptr = start_table_ptr; *table_address_ptr = start_table_ptr;
...@@ -3591,7 +3103,7 @@ static void sep_deallocated_flow_tables(struct sep_lli_entry_t *first_table_ptr) ...@@ -3591,7 +3103,7 @@ static void sep_deallocated_flow_tables(struct sep_lli_entry_t *first_table_ptr)
---------------------------------*/ ---------------------------------*/
/* set the pointer to the first table */ /* set the pointer to the first table */
table_ptr = (unsigned long *)first_table_ptr->physical_address; table_ptr = (unsigned long *) first_table_ptr->physical_address;
/* set the num of entries */ /* set the num of entries */
num_entries = (first_table_ptr->block_size >> SEP_NUM_ENTRIES_OFFSET_IN_BITS) num_entries = (first_table_ptr->block_size >> SEP_NUM_ENTRIES_OFFSET_IN_BITS)
...@@ -3603,18 +3115,16 @@ static void sep_deallocated_flow_tables(struct sep_lli_entry_t *first_table_ptr) ...@@ -3603,18 +3115,16 @@ static void sep_deallocated_flow_tables(struct sep_lli_entry_t *first_table_ptr)
num_pages = *(table_ptr - 2); num_pages = *(table_ptr - 2);
/* get the pointer to the pages */ /* get the pointer to the pages */
pages_ptr = (struct page **)(*(table_ptr - 1)); pages_ptr = (struct page **) (*(table_ptr - 1));
/* free the pages */ /* free the pages */
sep_free_dma_pages(pages_ptr, num_pages, 1); sep_free_dma_pages(pages_ptr, num_pages, 1);
/* goto to the info entry */ /* goto to the info entry */
info_entry_ptr = ((struct sep_lli_entry_t *)table_ptr) + info_entry_ptr = ((struct sep_lli_entry_t *) table_ptr) + (num_entries - 1);
(num_entries - 1);
table_ptr = (unsigned long *)info_entry_ptr->physical_address; table_ptr = (unsigned long *) info_entry_ptr->physical_address;
num_entries = (info_entry_ptr->block_size >> num_entries = (info_entry_ptr->block_size >> SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK;
SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK;
} }
return; return;
...@@ -3640,8 +3150,7 @@ static int sep_set_flow_id_handler(unsigned long arg) ...@@ -3640,8 +3150,7 @@ static int sep_set_flow_id_handler(unsigned long arg)
dbg("------------>SEP Driver: sep_set_flow_id_handler start\n"); dbg("------------>SEP Driver: sep_set_flow_id_handler start\n");
error = get_user(flow_id, error = get_user(flow_id, &(((struct sep_driver_set_flow_id_t *) arg)->flow_id));
&(((struct sep_driver_set_flow_id_t *)arg)->flow_id));
if (error) if (error)
goto end_function; goto end_function;
...@@ -3654,7 +3163,7 @@ static int sep_set_flow_id_handler(unsigned long arg) ...@@ -3654,7 +3163,7 @@ static int sep_set_flow_id_handler(unsigned long arg)
/* set flow id */ /* set flow id */
flow_data_ptr->flow_id = flow_id; flow_data_ptr->flow_id = flow_id;
end_function: end_function:
dbg("SEP Driver:<-------- sep_set_flow_id_handler end\n"); dbg("SEP Driver:<-------- sep_set_flow_id_handler end\n");
...@@ -3666,8 +3175,7 @@ static int sep_set_flow_id_handler(unsigned long arg) ...@@ -3666,8 +3175,7 @@ static int sep_set_flow_id_handler(unsigned long arg)
/* /*
calculates time and sets it at the predefined address calculates time and sets it at the predefined address
*/ */
static int sep_set_time(unsigned long *address_ptr, static int sep_set_time(unsigned long *address_ptr, unsigned long *time_in_sec_ptr)
unsigned long *time_in_sec_ptr)
{ {
/* time struct */ /* time struct */
struct timeval time; struct timeval time;
...@@ -3686,21 +3194,14 @@ static int sep_set_time(unsigned long *address_ptr, ...@@ -3686,21 +3194,14 @@ static int sep_set_time(unsigned long *address_ptr,
do_gettimeofday(&time); do_gettimeofday(&time);
/* set value in the SYSTEM MEMORY offset */ /* set value in the SYSTEM MEMORY offset */
time_addr = sep_dev->message_shared_area_addr + time_addr = sep_dev->message_shared_area_addr + SEP_DRIVER_SYSTEM_TIME_MEMORY_OFFSET_IN_BYTES;
SEP_DRIVER_SYSTEM_TIME_MEMORY_OFFSET_IN_BYTES;
*(unsigned long *) time_addr = SEP_TIME_VAL_TOKEN;
*(unsigned long *)time_addr = SEP_TIME_VAL_TOKEN; *(unsigned long *) (time_addr + 4) = time.tv_sec;
*(unsigned long *)(time_addr + 4) = time.tv_sec;
edbg("SEP Driver:time.tv_sec is %lu\n", time.tv_sec);
edbg( edbg("SEP Driver:time_addr is %lu\n", time_addr);
"SEP Driver:time.tv_sec is %lu\n", edbg("SEP Driver:g_message_shared_area_addr is %lu\n", sep_dev->message_shared_area_addr);
time.tv_sec);
edbg(
"SEP Driver:time_addr is %lu\n",
time_addr);
edbg(
"SEP Driver:g_message_shared_area_addr is %lu\n",
sep_dev->message_shared_area_addr);
/* set the output parameters if needed */ /* set the output parameters if needed */
if (address_ptr) if (address_ptr)
...@@ -3742,7 +3243,7 @@ static void sep_configure_dma_burst(void) ...@@ -3742,7 +3243,7 @@ static void sep_configure_dma_burst(void)
dbg("SEP Driver:<-------- sep_configure_dma_burst finished request access to registers from SEP (while(revVal) wait loop) \n"); dbg("SEP Driver:<-------- sep_configure_dma_burst finished request access to registers from SEP (while(revVal) wait loop) \n");
/* set the DMA burst register to single burst*/ /* set the DMA burst register to single burst */
sep_write_reg(sep_dev, HW_AHB_RD_WR_BURSTS_REG_ADDR, 0x0UL); sep_write_reg(sep_dev, HW_AHB_RD_WR_BURSTS_REG_ADDR, 0x0UL);
/* release the sep busy */ /* release the sep busy */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment