···6666 /* counter for the messages from sep */6767 unsigned long sep_to_host_reply_counter;6868 /* counter for the number of bytes allocated in the pool for the current6969- transaction */6969+ transaction */7070 unsigned long data_pool_bytes_allocated;71717272 /* array of pointers to the pages that represent input data for the synchronic7373- DMA action */7373+ DMA action */7474 struct page **in_page_array;75757676 /* array of pointers to the pages that represent out data for the synchronic7777- DMA action */7777+ DMA action */7878 struct page **out_page_array;79798080 /* number of pages in the sep_in_page_array */···121121 u32 reg_val;122122 do123123 reg_val = sep_read_reg(dev, HW_SRAM_DATA_READY_REG_ADDR);124124- while(!(reg_val & 1));124124+ while (!(reg_val & 1));125125}126126127127128128#endif129129-
+191-210
drivers/staging/sep/sep_driver_api.h
···106106 init command struct107107*/108108struct sep_driver_init_t {109109- /* start of the 1G of the host memory address that SEP can access */110110- unsigned long message_addr;109109+ /* start of the 1G of the host memory address that SEP can access */110110+ unsigned long message_addr;111111112112- /* start address of resident */113113- unsigned long message_size_in_words;112112+ /* start address of resident */113113+ unsigned long message_size_in_words;114114115115};116116···119119 realloc cache resident command120120*/121121struct sep_driver_realloc_cache_resident_t {122122- /* base address */123123- unsigned long base_addr;122122+ /* base address */123123+ unsigned long base_addr;124124125125- /* current cache address */126126- unsigned long cache_addr;125125+ /* current cache address */126126+ unsigned long cache_addr;127127128128- /* cache size in bytes*/129129- unsigned long cache_size_in_bytes;128128+ /* cache size in bytes */129129+ unsigned long cache_size_in_bytes;130130131131- /* current resident address */132132- unsigned long resident_addr;131131+ /* current resident address */132132+ unsigned long resident_addr;133133134134- /* resident size in bytes*/135135- unsigned long resident_size_in_bytes;134134+ /* resident size in bytes */135135+ unsigned long resident_size_in_bytes;136136137137- /* new cache address */138138- unsigned long new_cache_addr;137137+ /* new cache address */138138+ unsigned long new_cache_addr;139139140140- /* new resident address */141141- unsigned long new_resident_addr;140140+ /* new resident address */141141+ unsigned long new_resident_addr;142142143143- /* new resident address */144144- unsigned long new_shared_area_addr;143143+ /* new resident address */144144+ unsigned long new_shared_area_addr;145145146146- /* new base address */147147- unsigned long new_base_addr;146146+ /* new base address */147147+ unsigned long new_base_addr;148148};149149150150/*151151 set api mode command struct152152*/153153struct sep_driver_set_api_mode_t {154154- /* mode to set - 1 - blocking, 0 - non-blocking */155155- unsigned long mode;154154+ /* mode to set - 1 - blocking, 0 - non-blocking */155155+ unsigned long mode;156156};157157158158struct sep_driver_alloc_t {159159- /* virtual address of allocated space */160160- unsigned long offset;159159+ /* virtual address of allocated space */160160+ unsigned long offset;161161162162- /* physical address of allocated space */163163- unsigned long phys_address;162162+ /* physical address of allocated space */163163+ unsigned long phys_address;164164165165- /* number of bytes to allocate */166166- unsigned long num_bytes;165165+ /* number of bytes to allocate */166166+ unsigned long num_bytes;167167};168168169169/*170170 */171171struct sep_driver_write_t {172172- /* application space address */173173- unsigned long app_address;172172+ /* application space address */173173+ unsigned long app_address;174174175175- /* address of the data pool */176176- unsigned long datapool_address;175175+ /* address of the data pool */176176+ unsigned long datapool_address;177177178178- /* number of bytes to write */179179- unsigned long num_bytes;178178+ /* number of bytes to write */179179+ unsigned long num_bytes;180180};181181182182/*183183 */184184struct sep_driver_read_t {185185- /* application space address */186186- unsigned long app_address;185185+ /* application space address */186186+ unsigned long app_address;187187188188- /* address of the data pool */189189- unsigned long datapool_address;188188+ /* address of the data pool */189189+ unsigned long datapool_address;190190191191- /* number of bytes to read */192192- unsigned long num_bytes;191191+ /* number of bytes to read */192192+ unsigned long num_bytes;193193};194194195195/*196196*/197197struct sep_driver_build_sync_table_t {198198- /* address value of the data in */199199- unsigned long app_in_address;198198+ /* address value of the data in */199199+ unsigned long app_in_address;200200201201- /* size of data in */202202- unsigned long data_in_size;201201+ /* size of data in */202202+ unsigned long data_in_size;203203204204- /* address of the data out */205205- unsigned long app_out_address;204204+ /* address of the data out */205205+ unsigned long app_out_address;206206207207- /* the size of the block of the operation - if needed,208208- every table will be modulo this parameter */209209- unsigned long block_size;207207+ /* the size of the block of the operation - if needed,208208+ every table will be modulo this parameter */209209+ unsigned long block_size;210210211211- /* the physical address of the first input DMA table */212212- unsigned long in_table_address;211211+ /* the physical address of the first input DMA table */212212+ unsigned long in_table_address;213213214214- /* number of entries in the first input DMA table */215215- unsigned long in_table_num_entries;214214+ /* number of entries in the first input DMA table */215215+ unsigned long in_table_num_entries;216216217217- /* the physical address of the first output DMA table */218218- unsigned long out_table_address;217217+ /* the physical address of the first output DMA table */218218+ unsigned long out_table_address;219219220220- /* number of entries in the first output DMA table */221221- unsigned long out_table_num_entries;220220+ /* number of entries in the first output DMA table */221221+ unsigned long out_table_num_entries;222222223223- /* data in the first input table */224224- unsigned long table_data_size;223223+ /* data in the first input table */224224+ unsigned long table_data_size;225225226226- /* distinct user/kernel layout */227227- bool isKernelVirtualAddress;226226+ /* distinct user/kernel layout */227227+ bool isKernelVirtualAddress;228228229229};230230231231/*232232*/233233struct sep_driver_build_flow_table_t {234234- /* flow type */235235- unsigned long flow_type;234234+ /* flow type */235235+ unsigned long flow_type;236236237237- /* flag for input output */238238- unsigned long input_output_flag;237237+ /* flag for input output */238238+ unsigned long input_output_flag;239239240240- /* address value of the data in */241241- unsigned long virt_buff_data_addr;240240+ /* address value of the data in */241241+ unsigned long virt_buff_data_addr;242242243243- /* size of data in */244244- unsigned long num_virtual_buffers;243243+ /* size of data in */244244+ unsigned long num_virtual_buffers;245245246246- /* the physical address of the first input DMA table */247247- unsigned long first_table_addr;246246+ /* the physical address of the first input DMA table */247247+ unsigned long first_table_addr;248248249249- /* number of entries in the first input DMA table */250250- unsigned long first_table_num_entries;249249+ /* number of entries in the first input DMA table */250250+ unsigned long first_table_num_entries;251251252252- /* data in the first input table */253253- unsigned long first_table_data_size;252252+ /* data in the first input table */253253+ unsigned long first_table_data_size;254254255255- /* distinct user/kernel layout */256256- bool isKernelVirtualAddress;255255+ /* distinct user/kernel layout */256256+ bool isKernelVirtualAddress;257257};258258259259260260struct sep_driver_add_flow_table_t {261261- /* flow id */262262- unsigned long flow_id;261261+ /* flow id */262262+ unsigned long flow_id;263263264264- /* flag for input output */265265- unsigned long inputOutputFlag;264264+ /* flag for input output */265265+ unsigned long inputOutputFlag;266266267267- /* address value of the data in */268268- unsigned long virt_buff_data_addr;267267+ /* address value of the data in */268268+ unsigned long virt_buff_data_addr;269269270270- /* size of data in */271271- unsigned long num_virtual_buffers;270270+ /* size of data in */271271+ unsigned long num_virtual_buffers;272272273273- /* address of the first table */274274- unsigned long first_table_addr;273273+ /* address of the first table */274274+ unsigned long first_table_addr;275275276276- /* number of entries in the first table */277277- unsigned long first_table_num_entries;276276+ /* number of entries in the first table */277277+ unsigned long first_table_num_entries;278278279279- /* data size of the first table */280280- unsigned long first_table_data_size;279279+ /* data size of the first table */280280+ unsigned long first_table_data_size;281281282282- /* distinct user/kernel layout */283283- bool isKernelVirtualAddress;282282+ /* distinct user/kernel layout */283283+ bool isKernelVirtualAddress;284284285285};286286···288288 command struct for set flow id289289*/290290struct sep_driver_set_flow_id_t {291291- /* flow id to set */292292- unsigned long flow_id;291291+ /* flow id to set */292292+ unsigned long flow_id;293293};294294295295296296/* command struct for add tables message */297297struct sep_driver_add_message_t {298298- /* flow id to set */299299- unsigned long flow_id;298298+ /* flow id to set */299299+ unsigned long flow_id;300300301301- /* message size in bytes */302302- unsigned long message_size_in_bytes;301301+ /* message size in bytes */302302+ unsigned long message_size_in_bytes;303303304304- /* address of the message */305305- unsigned long message_address;304304+ /* address of the message */305305+ unsigned long message_address;306306};307307308308/* command struct for static pool addresses */309309struct sep_driver_static_pool_addr_t {310310- /* physical address of the static pool */311311- unsigned long physical_static_address;310310+ /* physical address of the static pool */311311+ unsigned long physical_static_address;312312313313- /* virtual address of the static pool */314314- unsigned long virtual_static_address;313313+ /* virtual address of the static pool */314314+ unsigned long virtual_static_address;315315};316316317317/* command struct for getiing offset of the physical address from318318 the start of the mapped area */319319struct sep_driver_get_mapped_offset_t {320320- /* physical address of the static pool */321321- unsigned long physical_address;320320+ /* physical address of the static pool */321321+ unsigned long physical_address;322322323323- /* virtual address of the static pool */324324- unsigned long offset;323323+ /* virtual address of the static pool */324324+ unsigned long offset;325325};326326327327/* command struct for getting time value and address */328328struct sep_driver_get_time_t {329329- /* physical address of stored time */330330- unsigned long time_physical_address;329329+ /* physical address of stored time */330330+ unsigned long time_physical_address;331331332332- /* value of the stored time */333333- unsigned long time_value;332332+ /* value of the stored time */333333+ unsigned long time_value;334334};335335336336···338338 structure that represent one entry in the DMA LLI table339339*/340340struct sep_lli_entry_t {341341- /* physical address */342342- unsigned long physical_address;341341+ /* physical address */342342+ unsigned long physical_address;343343344344- /* block size */345345- unsigned long block_size;344344+ /* block size */345345+ unsigned long block_size;346346};347347348348/*349349 structure that reperesents data needed for lli table construction350350*/351351struct sep_lli_prepare_table_data_t {352352- /* pointer to the memory where the first lli entry to be built */353353- struct sep_lli_entry_t *lli_entry_ptr;352352+ /* pointer to the memory where the first lli entry to be built */353353+ struct sep_lli_entry_t *lli_entry_ptr;354354355355- /* pointer to the array of lli entries from which the table is to be built */356356- struct sep_lli_entry_t *lli_array_ptr;355355+ /* pointer to the array of lli entries from which the table is to be built */356356+ struct sep_lli_entry_t *lli_array_ptr;357357358358- /* number of elements in lli array */359359- int lli_array_size;358358+ /* number of elements in lli array */359359+ int lli_array_size;360360361361- /* number of entries in the created table */362362- int num_table_entries;361361+ /* number of entries in the created table */362362+ int num_table_entries;363363364364- /* number of array entries processed during table creation */365365- int num_array_entries_processed;364364+ /* number of array entries processed during table creation */365365+ int num_array_entries_processed;366366367367- /* the totatl data size in the created table */368368- int lli_table_total_data_size;367367+ /* the totatl data size in the created table */368368+ int lli_table_total_data_size;369369};370370371371/*···373373 to show what table looks like374374*/375375struct sep_lli_table_t {376376- /* number of pages mapped in this tables. If 0 - means that the table377377- is not defined (used as a valid flag)*/378378- unsigned long num_pages;379379- /*380380- pointer to array of page pointers that represent the mapping of the381381- virtual buffer defined by the table to the physical memory. If this382382- pointer is NULL, it means that the table is not defined383383- (used as a valid flag)384384- */385385- struct page **table_page_array_ptr;376376+ /* number of pages mapped in this tables. If 0 - means that the table377377+ is not defined (used as a valid flag) */378378+ unsigned long num_pages;379379+ /*380380+ pointer to array of page pointers that represent the mapping of the381381+ virtual buffer defined by the table to the physical memory. If this382382+ pointer is NULL, it means that the table is not defined383383+ (used as a valid flag)384384+ */385385+ struct page **table_page_array_ptr;386386387387- /* maximum flow entries in table */388388- struct sep_lli_entry_t lli_entries[SEP_DRIVER_MAX_FLOW_NUM_ENTRIES_IN_TABLE];387387+ /* maximum flow entries in table */388388+ struct sep_lli_entry_t lli_entries[SEP_DRIVER_MAX_FLOW_NUM_ENTRIES_IN_TABLE];389389};390390391391···393393 structure for keeping the mapping of the virtual buffer into physical pages394394*/395395struct sep_flow_buffer_data {396396- /* pointer to the array of page structs pointers to the pages of the397397- virtual buffer */398398- struct page **page_array_ptr;396396+ /* pointer to the array of page structs pointers to the pages of the397397+ virtual buffer */398398+ struct page **page_array_ptr;399399400400- /* number of pages taken by the virtual buffer */401401- unsigned long num_pages;400400+ /* number of pages taken by the virtual buffer */401401+ unsigned long num_pages;402402403403- /* this flag signals if this page_array is the last one among many that were404404- sent in one setting to SEP */405405- unsigned long last_page_array_flag;403403+ /* this flag signals if this page_array is the last one among many that were404404+ sent in one setting to SEP */405405+ unsigned long last_page_array_flag;406406};407407408408/*409409 struct that keeps all the data for one flow410410*/411411struct sep_flow_context_t {412412- /*413413- work struct for handling the flow done interrupt in the workqueue414414- this structure must be in the first place, since it will be used415415- forcasting to the containing flow context416416- */417417- struct work_struct flow_wq;412412+ /*413413+ work struct for handling the flow done interrupt in the workqueue414414+ this structure must be in the first place, since it will be used415415+ forcasting to the containing flow context416416+ */417417+ struct work_struct flow_wq;418418419419- /* flow id */420420- unsigned long flow_id;419419+ /* flow id */420420+ unsigned long flow_id;421421422422- /* additional input tables exists */423423- unsigned long input_tables_flag;422422+ /* additional input tables exists */423423+ unsigned long input_tables_flag;424424425425- /* additional output tables exists */426426- unsigned long output_tables_flag;425425+ /* additional output tables exists */426426+ unsigned long output_tables_flag;427427428428- /* data of the first input file */429429- struct sep_lli_entry_t first_input_table;428428+ /* data of the first input file */429429+ struct sep_lli_entry_t first_input_table;430430431431- /* data of the first output table */432432- struct sep_lli_entry_t first_output_table;431431+ /* data of the first output table */432432+ struct sep_lli_entry_t first_output_table;433433434434- /* last input table data */435435- struct sep_lli_entry_t last_input_table;434434+ /* last input table data */435435+ struct sep_lli_entry_t last_input_table;436436437437- /* last output table data */438438- struct sep_lli_entry_t last_output_table;437437+ /* last output table data */438438+ struct sep_lli_entry_t last_output_table;439439440440- /* first list of table */441441- struct sep_lli_entry_t input_tables_in_process;440440+ /* first list of table */441441+ struct sep_lli_entry_t input_tables_in_process;442442443443- /* output table in process (in sep) */444444- struct sep_lli_entry_t output_tables_in_process;443443+ /* output table in process (in sep) */444444+ struct sep_lli_entry_t output_tables_in_process;445445446446- /* size of messages in bytes */447447- unsigned long message_size_in_bytes;446446+ /* size of messages in bytes */447447+ unsigned long message_size_in_bytes;448448449449- /* message */450450- unsigned char message[SEP_MAX_ADD_MESSAGE_LENGTH_IN_BYTES];449449+ /* message */450450+ unsigned char message[SEP_MAX_ADD_MESSAGE_LENGTH_IN_BYTES];451451};452452453453···478478 This function releases all the application virtual479479 buffer physical pages, that were previously locked480480*/481481-int sep_free_dma_pages(struct page **page_array_ptr,482482- unsigned long num_pages,483483- unsigned long dirtyFlag);481481+int sep_free_dma_pages(struct page **page_array_ptr, unsigned long num_pages, unsigned long dirtyFlag);484482485483/*486484 This function creates the input and output dma tables for487485 symmetric operations (AES/DES) according to the block size488486 from LLI arays489487*/490490-int sep_construct_dma_tables_from_lli(491491- struct sep_lli_entry_t *lli_in_array,492492- unsigned long sep_in_lli_entries,493493- struct sep_lli_entry_t *lli_out_array,494494- unsigned long sep_out_lli_entries,495495- unsigned long block_size,496496- unsigned long *lli_table_in_ptr,497497- unsigned long *lli_table_out_ptr,498498- unsigned long *in_num_entries_ptr,499499- unsigned long *out_num_entries_ptr,500500- unsigned long *table_data_size_ptr);488488+int sep_construct_dma_tables_from_lli(struct sep_lli_entry_t *lli_in_array,489489+ unsigned long sep_in_lli_entries,490490+ struct sep_lli_entry_t *lli_out_array,491491+ unsigned long sep_out_lli_entries,492492+ 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);501493502494/*503495 This function builds input and output DMA tables for synhronic symmetric504496 operations (AES, DES) It also checks that each table is of the modular505497 block size506498*/507507-int sep_prepare_input_output_dma_table(unsigned long app_virt_in_addr,508508- unsigned long app_virt_out_addr,509509- unsigned long data_size,510510- unsigned long block_size,511511- unsigned long *lli_table_in_ptr,512512- unsigned long *lli_table_out_ptr,513513- unsigned long *in_num_entries_ptr,514514- unsigned long *out_num_entries_ptr,515515- unsigned long *table_data_size_ptr,516516- bool isKernelVirtualAddress);499499+int sep_prepare_input_output_dma_table(unsigned long app_virt_in_addr,500500+ unsigned long app_virt_out_addr,501501+ unsigned long data_size,502502+ unsigned long block_size,503503+ 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);517504518505/*519506 This function prepares only input DMA table for synhronic symmetric520507 operations (HASH)521508*/522522-int sep_prepare_input_dma_table(unsigned long app_virt_addr,523523- unsigned long data_size,524524- unsigned long block_size,525525- unsigned long *lli_table_ptr,526526- unsigned long *num_entries_ptr,527527- unsigned long *table_data_size_ptr,528528- bool isKernelVirtualAddress);509509+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);529510530511/* this functions frees all the resources that were allocated for the building531512 of the LLI DMA tables */
+3-12
drivers/staging/sep/sep_driver_ext_api.h
···5151destination memory, which is external to Linux VM and is given as physical5252address5353*/5454-int sep_copy_cache_resident_to_area(unsigned long src_cache_addr,5555- unsigned long cache_size_in_bytes,5656- unsigned long src_resident_addr,5757- unsigned long resident_size_in_bytes,5858- unsigned long *dst_new_cache_addr_ptr,5959- unsigned long *dst_new_resident_addr_ptr);5454+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);60556156/*6257This functions maps and allocates the shared area on the external···6065address of the mapped and allocated shared area, and6166phys_shared_area_addr_ptr - the physical address of the shared area6267*/6363-int sep_map_and_alloc_shared_area(unsigned long shared_area_size,6464- unsigned long *kernel_shared_area_addr_ptr,6565- unsigned long *phys_shared_area_addr_ptr);6868+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);66696770/*6871This functions unmaps and deallocates the shared area on the external···6976mapped and allocated shared area,phys_shared_area_addr_ptr - the physical7077address of the shared area7178*/7272-void sep_unmap_and_free_shared_area(unsigned long shared_area_size,7373- unsigned long kernel_shared_area_addr,7474- unsigned long phys_shared_area_addr);7979+void sep_unmap_and_free_shared_area(unsigned long shared_area_size, unsigned long kernel_shared_area_addr, unsigned long phys_shared_area_addr);758076817782/*
···85858686/* 2M size */87878888-#endif /* SEP_DRIVER_ARM_DEBUG_MODE */8888+#endif /* SEP_DRIVER_ARM_DEBUG_MODE */89899090#define BASE_ADDRESS_FOR_SYSTEM 0xfffc00009191#define SEP_RAR_IO_MEM_REGION_SIZE 0x4000092929393-irqreturn_t sep_inthandler(int irq , void* dev_id);9393+irqreturn_t sep_inthandler(int irq, void *dev_id);94949595/* Keep this a single static object for now to keep the conversion easy */9696···107107/*108108 function that is activated on the succesfull probe of the SEP device109109*/110110-static int __devinit sep_probe(struct pci_dev *pdev,111111- const struct pci_device_id *ent);110110+static int __devinit sep_probe(struct pci_dev *pdev, const struct pci_device_id *ent);112111113112static struct pci_device_id sep_pci_id_tbl[] = {114114- { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x080c) },115115- { 0 }113113+ {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x080c)},114114+ {0}116115};117116118117MODULE_DEVICE_TABLE(pci, sep_pci_id_tbl);···140141 destination memory, which is external to Linux VM and is given as141142 physical address142143*/143143-int sep_copy_cache_resident_to_area(unsigned long src_cache_addr,144144- unsigned long cache_size_in_bytes,145145- unsigned long src_resident_addr,146146- unsigned long resident_size_in_bytes,147147- unsigned long *dst_new_cache_addr_ptr,148148- unsigned long *dst_new_resident_addr_ptr)144144+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)149145{150146 /* resident address in user space */151147 unsigned long resident_addr;···151157 const struct firmware *fw;152158153159 char *cache_name = "cache.image.bin";154154- char *res_name = "resident.image.bin";160160+ char *res_name = "resident.image.bin";155161156162 /* error */157163 int error;···161167 -------------------------------------*/162168 error = 0;163169164164- edbg(165165- "SEP Driver:rar_virtual is %p\n",166166- sep_dev->rar_virtual_address);167167- edbg(168168- "SEP Driver:rar_physical is %08lx\n",169169- sep_dev->rar_physical_address);170170+ edbg("SEP Driver:rar_virtual is %p\n", sep_dev->rar_virtual_address);171171+ edbg("SEP Driver:rar_physical is %08lx\n", sep_dev->rar_physical_address);170172171171- sep_dev->rar_region_addr = (unsigned long)sep_dev->rar_virtual_address;173173+ sep_dev->rar_region_addr = (unsigned long) sep_dev->rar_virtual_address;172174173175 sep_dev->cache_physical_address = sep_dev->rar_physical_address;174176 sep_dev->cache_virtual_address = sep_dev->rar_virtual_address;···172182 /* load cache */173183 error = request_firmware(&fw, cache_name, &sep_dev->sep_pci_dev_ptr->dev);174184 if (error) {175175- edbg(176176- "SEP Driver:cant request cache fw\n");185185+ edbg("SEP Driver:cant request cache fw\n");177186 goto end_function;178187 }179188180180- edbg(181181- "SEP Driver:cache data loc is %p\n",182182- (void *)fw->data);183183- edbg(184184- "SEP Driver:cache data size is %08Zx\n",185185- fw->size);189189+ edbg("SEP Driver:cache data loc is %p\n", (void *) fw->data);190190+ edbg("SEP Driver:cache data size is %08Zx\n", fw->size);186191187187- memcpy((void *)sep_dev->cache_virtual_address, (void *)fw->data, fw->size);192192+ memcpy((void *) sep_dev->cache_virtual_address, (void *) fw->data, fw->size);188193189194 sep_dev->cache_size = fw->size;190195191191- cache_addr = (unsigned long)sep_dev->cache_virtual_address;196196+ cache_addr = (unsigned long) sep_dev->cache_virtual_address;192197193198 release_firmware(fw);194199195195- sep_dev->resident_physical_address = sep_dev->cache_physical_address196196- + sep_dev->cache_size;197197- sep_dev->resident_virtual_address = sep_dev->cache_virtual_address198198- + sep_dev->cache_size;200200+ sep_dev->resident_physical_address = sep_dev->cache_physical_address + sep_dev->cache_size;201201+ sep_dev->resident_virtual_address = sep_dev->cache_virtual_address + sep_dev->cache_size;199202200203 /* load resident */201204 error = request_firmware(&fw, res_name, &sep_dev->sep_pci_dev_ptr->dev);202205 if (error) {203203- edbg(204204- "SEP Driver:cant request res fw\n");206206+ edbg("SEP Driver:cant request res fw\n");205207 goto end_function;206208 }207209208208- edbg(209209- "SEP Driver:res data loc is %p\n",210210- (void *)fw->data);211211- edbg(212212- "SEP Driver:res data size is %08Zx\n",213213- fw->size);210210+ edbg("SEP Driver:res data loc is %p\n", (void *) fw->data);211211+ edbg("SEP Driver:res data size is %08Zx\n", fw->size);214212215215- memcpy((void *)sep_dev->resident_virtual_address, (void *)fw->data, fw->size);213213+ memcpy((void *) sep_dev->resident_virtual_address, (void *) fw->data, fw->size);216214217215 sep_dev->resident_size = fw->size;218216219217 release_firmware(fw);220218221221- resident_addr = (unsigned long)sep_dev->resident_virtual_address;219219+ resident_addr = (unsigned long) sep_dev->resident_virtual_address;222220223223- edbg(224224- "SEP Driver:resident_addr (physical )is %08lx\n",225225- sep_dev->resident_physical_address);226226- edbg(227227- "SEP Driver:cache_addr (physical) is %08lx\n",228228- sep_dev->cache_physical_address);221221+ edbg("SEP Driver:resident_addr (physical )is %08lx\n", sep_dev->resident_physical_address);222222+ edbg("SEP Driver:cache_addr (physical) is %08lx\n", sep_dev->cache_physical_address);229223230230- edbg(231231- "SEP Driver:resident_addr (logical )is %08lx\n",232232- resident_addr);233233- edbg(234234- "SEP Driver:cache_addr (logical) is %08lx\n",235235- cache_addr);224224+ edbg("SEP Driver:resident_addr (logical )is %08lx\n", resident_addr);225225+ edbg("SEP Driver:cache_addr (logical) is %08lx\n", cache_addr);236226237237- edbg(238238- "SEP Driver:resident_size is %08lx\n", sep_dev->resident_size);239239- edbg(240240- "SEP Driver:cache_size is %08lx\n", sep_dev->cache_size);227227+ edbg("SEP Driver:resident_size is %08lx\n", sep_dev->resident_size);228228+ edbg("SEP Driver:cache_size is %08lx\n", sep_dev->cache_size);241229242230243231···223255 *dst_new_cache_addr_ptr = sep_dev->cache_physical_address;224256 *dst_new_resident_addr_ptr = sep_dev->resident_physical_address;225257226226-end_function:258258+ end_function:227259228260 return error;229261}···238270 shared area, and phys_shared_area_addr_ptr239271 - the physical address of the shared area240272*/241241-int sep_map_and_alloc_shared_area(unsigned long shared_area_size,242242- unsigned long *kernel_shared_area_addr_ptr,243243- unsigned long *phys_shared_area_addr_ptr)273273+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)244274{245275 // shared_virtual_address = ioremap_nocache(0xda00000,shared_area_size);246276 sep_dev->shared_virtual_address = kmalloc(shared_area_size, GFP_KERNEL);247277 if (!sep_dev->shared_virtual_address) {248248- edbg(249249- "sep_driver:shared memory kmalloc failed\n");278278+ edbg("sep_driver:shared memory kmalloc failed\n");250279 return -1;251280 }252281···251286 sep_dev->shared_physical_address = __pa(sep_dev->shared_virtual_address);252287 // shared_physical_address = 0xda00000;253288254254- *kernel_shared_area_addr_ptr = (unsigned long)sep_dev->shared_virtual_address;289289+ *kernel_shared_area_addr_ptr = (unsigned long) sep_dev->shared_virtual_address;255290 /* set the physical address of the shared area */256291 *phys_shared_area_addr_ptr = sep_dev->shared_physical_address;257292258258- edbg(259259- "SEP Driver:shared_virtual_address is %p\n",260260- sep_dev->shared_virtual_address);261261- edbg(262262- "SEP Driver:shared_region_size is %08lx\n",263263- shared_area_size);264264- edbg(265265- "SEP Driver:shared_physical_addr is %08lx\n",266266- *phys_shared_area_addr_ptr);293293+ edbg("SEP Driver:shared_virtual_address is %p\n", sep_dev->shared_virtual_address);294294+ edbg("SEP Driver:shared_region_size is %08lx\n", shared_area_size);295295+ edbg("SEP Driver:shared_physical_addr is %08lx\n", *phys_shared_area_addr_ptr);267296268297 return 0;269298}···270311 shared area,phys_shared_area_addr_ptr - the physical address of271312 the shared area272313*/273273-void sep_unmap_and_free_shared_area(unsigned long shared_area_size,274274- unsigned long kernel_shared_area_addr,275275- unsigned long phys_shared_area_addr)314314+void sep_unmap_and_free_shared_area(unsigned long shared_area_size, unsigned long kernel_shared_area_addr, unsigned long phys_shared_area_addr)276315{277277- kfree((void *)kernel_shared_area_addr);316316+ kfree((void *) kernel_shared_area_addr);278317 return;279318}280319···284327*/285328unsigned long sep_shared_area_virt_to_phys(unsigned long virt_address)286329{287287- edbg(288288- "SEP Driver:sh virt to phys v %08lx\n",289289- virt_address);290290- edbg(291291- "SEP Driver:sh virt to phys p %08lx\n",292292- sep_dev->shared_physical_address293293- + (virt_address - (unsigned long)sep_dev->shared_virtual_address));330330+ edbg("SEP Driver:sh virt to phys v %08lx\n", virt_address);331331+ edbg("SEP Driver:sh virt to phys p %08lx\n", sep_dev->shared_physical_address + (virt_address - (unsigned long) sep_dev->shared_virtual_address));294332295295- return (unsigned long)sep_dev->shared_physical_address +296296- (virt_address - (unsigned long)sep_dev->shared_virtual_address);333333+ return (unsigned long) sep_dev->shared_physical_address + (virt_address - (unsigned long) sep_dev->shared_virtual_address);297334}298335299336/*···298347*/299348unsigned long sep_shared_area_phys_to_virt(unsigned long phys_address)300349{301301- return (unsigned long)sep_dev->shared_virtual_address302302- + (phys_address - sep_dev->shared_physical_address);350350+ return (unsigned long) sep_dev->shared_virtual_address + (phys_address - sep_dev->shared_physical_address);303351}304352305353306354/*307355 function that is activaed on the succesfull probe of the SEP device308356*/309309-static int __devinit sep_probe(struct pci_dev *pdev,310310- const struct pci_device_id *ent)357357+static int __devinit sep_probe(struct pci_dev *pdev, const struct pci_device_id *ent)311358{312359 /* error */313360 int error;···314365 CODE315366 ---------------------------*/316367317317- edbg(318318- "Sep pci probe starting\n");368368+ edbg("Sep pci probe starting\n");319369 error = 0;320370321371 /* enable the device */322372 error = pci_enable_device(pdev);323373 if (error) {324324- edbg(325325- "error enabling pci device\n");374374+ edbg("error enabling pci device\n");326375 goto end_function;327376 }328377···330383 /* get the io memory start address */331384 sep_dev->io_memory_start_physical_address = pci_resource_start(pdev, 0);332385 if (!sep_dev->io_memory_start_physical_address) {333333- edbg(334334- "SEP Driver error pci resource start\n");386386+ edbg("SEP Driver error pci resource start\n");335387 goto end_function;336388 }337389338390 /* get the io memory end address */339391 sep_dev->io_memory_end_physical_address = pci_resource_end(pdev, 0);340392 if (!sep_dev->io_memory_end_physical_address) {341341- edbg(342342- "SEP Driver error pci resource end\n");393393+ edbg("SEP Driver error pci resource end\n");343394 goto end_function;344395 }345396346346- sep_dev->io_memory_size = sep_dev->io_memory_end_physical_address -347347- sep_dev->io_memory_start_physical_address + 1;397397+ sep_dev->io_memory_size = sep_dev->io_memory_end_physical_address - sep_dev->io_memory_start_physical_address + 1;348398349349- edbg(350350- "SEP Driver:io_memory_start_physical_address is %08lx\n",351351- sep_dev->io_memory_start_physical_address);399399+ edbg("SEP Driver:io_memory_start_physical_address is %08lx\n", sep_dev->io_memory_start_physical_address);352400353353- edbg(354354- "SEP Driver:io_memory_end_phyaical_address is %08lx\n",355355- sep_dev->io_memory_end_physical_address);401401+ edbg("SEP Driver:io_memory_end_phyaical_address is %08lx\n", sep_dev->io_memory_end_physical_address);356402357357- edbg(358358- "SEP Driver:io_memory_size is %08lx\n",359359- sep_dev->io_memory_size);403403+ edbg("SEP Driver:io_memory_size is %08lx\n", sep_dev->io_memory_size);360404361361- sep_dev->io_memory_start_virtual_address =362362- ioremap_nocache(sep_dev->io_memory_start_physical_address,363363- sep_dev->io_memory_size);405405+ sep_dev->io_memory_start_virtual_address = ioremap_nocache(sep_dev->io_memory_start_physical_address, sep_dev->io_memory_size);364406 if (!sep_dev->io_memory_start_virtual_address) {365365- edbg(366366- "SEP Driver error ioremap of io memory\n");407407+ edbg("SEP Driver error ioremap of io memory\n");367408 goto end_function;368409 }369410370370- edbg(371371- "SEP Driver:io_memory_start_virtual_address is %p\n",372372- sep_dev->io_memory_start_virtual_address);411411+ edbg("SEP Driver:io_memory_start_virtual_address is %p\n", sep_dev->io_memory_start_virtual_address);373412374374- sep_dev->reg_base_address = (void __iomem *)sep_dev->io_memory_start_virtual_address;413413+ sep_dev->reg_base_address = (void __iomem *) sep_dev->io_memory_start_virtual_address;375414376415377416 /* set up system base address and shared memory location */378417379379- sep_dev->rar_virtual_address = kmalloc(2 * SEP_RAR_IO_MEM_REGION_SIZE,380380- GFP_KERNEL);418418+ sep_dev->rar_virtual_address = kmalloc(2 * SEP_RAR_IO_MEM_REGION_SIZE, GFP_KERNEL);381419382420 if (!sep_dev->rar_virtual_address) {383383- edbg(384384- "SEP Driver:cant kmalloc rar\n");421421+ edbg("SEP Driver:cant kmalloc rar\n");385422 goto end_function;386386- }423423+ }387424 /* FIXME */388425 sep_dev->rar_physical_address = __pa(sep_dev->rar_virtual_address);389426390390- edbg(391391- "SEP Driver:rar_physical is %08lx\n",392392- sep_dev->rar_physical_address);427427+ edbg("SEP Driver:rar_physical is %08lx\n", sep_dev->rar_physical_address);393428394394- edbg(395395- "SEP Driver:rar_virtual is %p\n",396396- sep_dev->rar_virtual_address);429429+ edbg("SEP Driver:rar_virtual is %p\n", sep_dev->rar_virtual_address);397430398431399432#if !SEP_DRIVER_POLLING_MODE400433401401- edbg(402402- "SEP Driver: about to write IMR and ICR REG_ADDR\n");434434+ edbg("SEP Driver: about to write IMR and ICR REG_ADDR\n");403435404436 /* clear ICR register */405405- sep_write_reg(sep_dev, HW_HOST_ICR_REG_ADDR,406406- 0xFFFFFFFF);437437+ sep_write_reg(sep_dev, HW_HOST_ICR_REG_ADDR, 0xFFFFFFFF);407438408439 /* set the IMR register - open only GPR 2 */409409- sep_write_reg(sep_dev, HW_HOST_IMR_REG_ADDR,410410- (~(0x1 << 13)));440440+ sep_write_reg(sep_dev, HW_HOST_IMR_REG_ADDR, (~(0x1 << 13)));411441412442 /* figure out our irq */413443 /* FIXME: */414414- error = pci_read_config_byte(pdev, PCI_INTERRUPT_LINE, (u8 *)&sep_dev->sep_irq);444444+ error = pci_read_config_byte(pdev, PCI_INTERRUPT_LINE, (u8 *) & sep_dev->sep_irq);415445416416- edbg(417417- "SEP Driver: my irq is %d\n", sep_irq);446446+ edbg("SEP Driver: my irq is %d\n", sep_irq);418447419419- edbg(420420- "SEP Driver: about to call request_irq\n");448448+ edbg("SEP Driver: about to call request_irq\n");421449 /* get the interrupt line */422422- error = request_irq(sep_irq, sep_inthandler, IRQF_SHARED,423423- "sep_driver", &sep_dev->reg_base_address);450450+ error = request_irq(sep_irq, sep_inthandler, IRQF_SHARED, "sep_driver", &sep_dev->reg_base_address);424451 if (error)425452 goto end_function;426453427454 goto end_function;428428- edbg(429429- "SEP Driver: about to write IMR REG_ADDR");455455+ edbg("SEP Driver: about to write IMR REG_ADDR");430456431457 /* set the IMR register - open only GPR 2 */432432- sep_write_reg(sep_dev, HW_HOST_IMR_REG_ADDR,433433- (~(0x1 << 13)));458458+ sep_write_reg(sep_dev, HW_HOST_IMR_REG_ADDR, (~(0x1 << 13)));434459435435-#endif /* SEP_DRIVER_POLLING_MODE */460460+#endif /* SEP_DRIVER_POLLING_MODE */436461437437-end_function:462462+ end_function:438463439464 return error;440465}···434515 /* Loading ROM from SEP_ROM_image.h file */435516 k = sizeof(CRYS_SEP_ROM);436517437437- edbg(438438- "SEP Driver: DX_CC_TST_SepRomLoader start\n");518518+ edbg("SEP Driver: DX_CC_TST_SepRomLoader start\n");439519440440- edbg(441441- "SEP Driver: k is %lu\n", k);442442- edbg(443443- "SEP Driver: sep_dev->reg_base_address is %p\n",444444- sep_dev->reg_base_address);445445- edbg(446446- "SEP Driver: CRYS_SEP_ROM_start_address_offset is %p\n",447447- CRYS_SEP_ROM_start_address_offset);520520+ edbg("SEP Driver: k is %lu\n", k);521521+ edbg("SEP Driver: sep_dev->reg_base_address is %p\n", sep_dev->reg_base_address);522522+ edbg("SEP Driver: CRYS_SEP_ROM_start_address_offset is %p\n", CRYS_SEP_ROM_start_address_offset);448523449524 for (i = 0; i < 4; i++) {450525 /* write bank */451526 sep_write_reg(sep_dev, SEP_ROM_BANK_register_offset, i);452527453528 for (j = 0; j < CRYS_SEP_ROM_length / 4; j++) {454454- sep_write_reg(sep_dev,455455- CRYS_SEP_ROM_start_address_offset + 4*j,456456- CRYS_SEP_ROM[i * 0x1000 + j]);529529+ sep_write_reg(sep_dev, CRYS_SEP_ROM_start_address_offset + 4 * j, CRYS_SEP_ROM[i * 0x1000 + j]);457530458531 k = k - 4;459532···456545 }457546 }458547459459- /* reset the SEP*/548548+ /* reset the SEP */460549 sep_write_reg(sep_dev, HW_HOST_SEP_SW_RST_REG_ADDR, 0x1);461550462551 /* poll for SEP ROM boot finish */···464553 retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR3_REG_ADDR);465554 } while (!regVal);466555467467- edbg(468468- "SEP Driver: ROM polling ended\n");556556+ edbg("SEP Driver: ROM polling ended\n");469557470558 switch (regVal) {471559 case 0x1:472560 /* fatal error - read erro status from GPRO */473561 Error = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR);474474- edbg(475475- "SEP Driver: ROM polling case 1\n");562562+ edbg("SEP Driver: ROM polling case 1\n");476563 break;477564 case 0x2:478565 /* Boot First Phase ended */479566 warning = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR);480480- edbg(481481- "SEP Driver: ROM polling case 2\n");567567+ edbg("SEP Driver: ROM polling case 2\n");482568 break;483569 case 0x4:484570 /* Cold boot ended successfully */485571 warning = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR);486486- edbg(487487- "SEP Driver: ROM polling case 4\n");572572+ edbg("SEP Driver: ROM polling case 4\n");488573 Error = 0;489574 break;490575 case 0x8:491576 /* Warmboot ended successfully */492577 warning = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR);493493- edbg(494494- "SEP Driver: ROM polling case 8\n");578578+ edbg("SEP Driver: ROM polling case 8\n");495579 Error = 0;496580 break;497581 case 0x10:498582 /* ColdWarm boot ended successfully */499583 warning = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR);500500- edbg(501501- "SEP Driver: ROM polling case 16\n");584584+ edbg("SEP Driver: ROM polling case 16\n");502585 Error = 0;503586 break;504587 case 0x20:505505- edbg(506506- "SEP Driver: ROM polling case 32\n");588588+ edbg("SEP Driver: ROM polling case 32\n");507589 break;508590 }509591510592#endif511593}512512-
+1705-2204
drivers/staging/sep/sep_main_mod.c
···7272MODULE_PARM_DESC(sepDebug, "Flag to enable SEP debug messages");73737474/* major and minor device numbers */7575-static dev_t g_sep_device_number;7575+static dev_t g_sep_device_number;76767777/* the files operations structure of the driver */7878-static struct file_operations g_sep_fops;7878+static struct file_operations g_sep_fops;79798080/* cdev struct of the driver */8181-static struct cdev g_sep_cdev;8181+static struct cdev g_sep_cdev;82828383/*8484 mutex for the access to the internals of the sep driver···103103/*104104 this function registers the driver to the file system105105*/106106-static int sep_register_driver_to_fs(void);106106+static int sep_register_driver_to_fs(void);107107108108/*109109 this function unregisters driver from fs···115115 table from this array the condition is that either the table is full116116 (all etnries are entered), or there are no more entries in the lli array117117*/118118-static unsigned long sep_calculate_lli_table_max_size(119119- struct sep_lli_entry_t *lli_in_array_ptr,120120- unsigned long num_array_entries);118118+static unsigned long sep_calculate_lli_table_max_size(struct sep_lli_entry_t *lli_in_array_ptr, unsigned long num_array_entries);121119/*122120 this functions builds ont lli table from the lli_array according to the123121 given size of data124122*/125125-static void sep_build_lli_table(struct sep_lli_entry_t *lli_array_ptr,126126- struct sep_lli_entry_t *lli_table_ptr,127127- unsigned long *num_processed_entries_ptr,128128- unsigned long *num_table_entries_ptr,129129- unsigned long table_data_size);123123+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);130124131125/*132126 this function goes over the list of the print created tables and prints133127 all the data134128*/135135-static void sep_debug_print_lli_tables(struct sep_lli_entry_t *lli_table_ptr,136136- unsigned long num_table_entries,137137- unsigned long table_data_size);129129+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);138130139131140132···211219static int sep_set_api_mode_handler(unsigned long arg);212220213221/* handler for flow done interrupt */214214-static void sep_flow_done_handler(struct work_struct *work);222222+static void sep_flow_done_handler(struct work_struct *work);215223216224/*217225 This function locks all the physical pages of the kernel virtual buffer218226 and construct a basic lli array, where each entry holds the physical219227 page address and the size that application data holds in this physical pages220228*/221221-static int sep_lock_kernel_pages(unsigned long kernel_virt_addr,222222- unsigned long data_size,223223- unsigned long *num_pages_ptr,224224- struct sep_lli_entry_t **lli_array_ptr,225225- struct page ***page_array_ptr);229229+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);226230227231/*228232 This function creates one DMA table for flow and returns its data,229233 and pointer to its info entry230234*/231231-static int sep_prepare_one_flow_dma_table(unsigned long virt_buff_addr,232232- unsigned long virt_buff_size,233233- struct sep_lli_entry_t *table_data,234234- struct sep_lli_entry_t **info_entry_ptr,235235- struct sep_flow_context_t *flow_data_ptr,236236- bool isKernelVirtualAddress);235235+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);237236238237/*239238 This function creates a list of tables for flow and returns the data for the240239 first and last tables of the list241240*/242242-static int sep_prepare_flow_dma_tables(unsigned long num_virtual_buffers,243243- unsigned long first_buff_addr,244244- struct sep_flow_context_t *flow_data_ptr,245245- struct sep_lli_entry_t *first_table_data_ptr,246246- struct sep_lli_entry_t *last_table_data_ptr,247247- bool isKernelVirtualAddress);241241+static int sep_prepare_flow_dma_tables(unsigned long num_virtual_buffers,242242+ 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);248243249244/*250245 this function find a space for the new flow dma table251246*/252252-static int sep_find_free_flow_dma_table_space(253253- unsigned long **table_address_ptr);247247+static int sep_find_free_flow_dma_table_space(unsigned long **table_address_ptr);254248255249/*256250 this function goes over all the flow tables connected to the given table and257251 deallocate them258252*/259259-static void sep_deallocated_flow_tables(260260- struct sep_lli_entry_t *first_table_ptr);253253+static void sep_deallocated_flow_tables(struct sep_lli_entry_t *first_table_ptr);261254262255/*263256 This function handler the set flow id command···253276 This function returns pointer to the flow data structure254277 that conatins the given id255278*/256256-static int sep_find_flow_context(unsigned long flow_id,257257- struct sep_flow_context_t **flow_data_ptr);279279+static int sep_find_flow_context(unsigned long flow_id, struct sep_flow_context_t **flow_data_ptr);258280259281260282/*···276300/*277301 calculates time and sets it at the predefined address278302*/279279-static int sep_set_time(unsigned long *address_ptr,280280- unsigned long *time_in_sec_ptr);303303+static int sep_set_time(unsigned long *address_ptr, unsigned long *time_in_sec_ptr);281304282305/*283306 PATCH for configuring the DMA to single burst instead of multi-burst···289314 array, where each entry holds the physical page address290315 and the size that application data holds in this physical pages291316*/292292-static int sep_lock_user_pages(unsigned long app_virt_addr,293293- unsigned long data_size,294294- unsigned long *num_pages_ptr,295295- struct sep_lli_entry_t **lli_array_ptr,296296- struct page ***page_array_ptr);317317+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);297318298319/*---------------------------------------------299320 FUNCTIONS···300329*/301330int sep_lock()302331{303303- mutex_lock(&sep_mutex);332332+ mutex_lock(&sep_mutex);304333305305- return 0;334334+ return 0;306335}307336308337/*···310339*/311340void sep_unlock()312341{313313- /* release mutex */314314- mutex_unlock(&sep_mutex);342342+ /* release mutex */343343+ mutex_unlock(&sep_mutex);315344}316345317346/*318347 this function returns the address of the message shared area319348*/320320-void sep_map_shared_area(unsigned long *mappedAddr_ptr)349349+void sep_map_shared_area(unsigned long *mappedAddr_ptr)321350{322322- *mappedAddr_ptr = sep_dev->shared_area_addr;351351+ *mappedAddr_ptr = sep_dev->shared_area_addr;323352}324353325354/*···327356*/328357void sep_send_msg_rdy_cmd()329358{330330- sep_send_command_handler();359359+ sep_send_command_handler();331360}332361333362/* this functions frees all the resources that were allocated for the building334363of the LLI DMA tables */335364void sep_free_dma_resources()336365{337337- sep_free_dma_table_data_handler();366366+ sep_free_dma_table_data_handler();338367}339368340369/* poll(suspend), until reply from sep */341370void sep_driver_poll()342371{343343- unsigned long retVal = 0;372372+ unsigned long retVal = 0;344373345374#ifdef SEP_DRIVER_POLLING_MODE346375347347- while (sep_dev->host_to_sep_send_counter != (retVal & 0x7FFFFFFF))348348- retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR2_REG_ADDR);376376+ while (sep_dev->host_to_sep_send_counter != (retVal & 0x7FFFFFFF))377377+ retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR2_REG_ADDR);349378350350- sep_dev->sep_to_host_reply_counter++;379379+ sep_dev->sep_to_host_reply_counter++;351380#else352352- /* poll, until reply from sep */353353- wait_event(g_sep_event,354354- (sep_dev->host_to_sep_send_counter == sep_dev->sep_to_host_reply_counter));381381+ /* poll, until reply from sep */382382+ wait_event(g_sep_event, (sep_dev->host_to_sep_send_counter == sep_dev->sep_to_host_reply_counter));355383356384#endif357385}···361391------------------------------------------------------------------------*/362392static int sep_open(struct inode *inode_ptr, struct file *file_ptr)363393{364364- /* return value */365365- int error;394394+ /* return value */395395+ int error;366396367397 /*-----------------368398 CODE369399 ---------------------*/370400371371- dbg("SEP Driver:--------> open start\n");401401+ dbg("SEP Driver:--------> open start\n");372402373373- error = 0;403403+ error = 0;374404375375- /* check the blocking mode */376376- if (sep_dev->block_mode_flag)377377- /* lock mutex */378378- mutex_lock(&sep_mutex);379379- else380380- error = mutex_trylock(&sep_mutex);405405+ /* check the blocking mode */406406+ if (sep_dev->block_mode_flag)407407+ /* lock mutex */408408+ mutex_lock(&sep_mutex);409409+ else410410+ error = mutex_trylock(&sep_mutex);381411382382- /* check the error */383383- if (error) {384384- edbg(385385- "SEP Driver: down_interruptible failed\n");412412+ /* check the error */413413+ if (error) {414414+ edbg("SEP Driver: down_interruptible failed\n");386415387387- goto end_function;388388- }416416+ goto end_function;417417+ }389418390390- /* release data pool allocations */391391- sep_dev->data_pool_bytes_allocated = 0;419419+ /* release data pool allocations */420420+ sep_dev->data_pool_bytes_allocated = 0;392421393393-end_function:422422+ end_function:394423395395- dbg("SEP Driver:<-------- open end\n");424424+ dbg("SEP Driver:<-------- open end\n");396425397397- return error;426426+ return error;398427}399428400429···408439 CODE409440 ---------------------*/410441411411- dbg("----------->SEP Driver: sep_release start\n");442442+ dbg("----------->SEP Driver: sep_release start\n");412443413413-#if 0/*!SEP_DRIVER_POLLING_MODE*/414414- /* close IMR */415415- sep_write_reg(sep_dev, HW_HOST_IMR_REG_ADDR, 0x7FFF);444444+#if 0 /*!SEP_DRIVER_POLLING_MODE */445445+ /* close IMR */446446+ sep_write_reg(sep_dev, HW_HOST_IMR_REG_ADDR, 0x7FFF);416447417417- /* release IRQ line */418418- free_irq(SEP_DIRVER_IRQ_NUM, &sep_dev->reg_base_address);448448+ /* release IRQ line */449449+ free_irq(SEP_DIRVER_IRQ_NUM, &sep_dev->reg_base_address);419450420451#endif421452422422- /* unlock the sep mutex */423423- mutex_unlock(&sep_mutex);453453+ /* unlock the sep mutex */454454+ mutex_unlock(&sep_mutex);424455425425- dbg("SEP Driver:<-------- sep_release end\n");456456+ dbg("SEP Driver:<-------- sep_release end\n");426457427427- return 0;458458+ return 0;428459}429460430461···433464/*---------------------------------------------------------------434465 map function - this functions maps the message shared area435466-----------------------------------------------------------------*/436436-static int sep_mmap(struct file *filp, struct vm_area_struct *vma)467467+static int sep_mmap(struct file *filp, struct vm_area_struct *vma)437468{438438- /* physical addr */439439- unsigned long phys_addr;469469+ /* physical addr */470470+ unsigned long phys_addr;440471441472 /*-----------------------442473 CODE443474 -------------------------*/444475445445- dbg("-------->SEP Driver: mmap start\n");476476+ dbg("-------->SEP Driver: mmap start\n");446477447447- /* check that the size of the mapped range is as the size of the message448448- shared area */449449- if ((vma->vm_end - vma->vm_start) > SEP_DRIVER_MMMAP_AREA_SIZE) {450450- edbg(451451- "SEP Driver mmap requested size is more than allowed\n");452452- printk(KERN_WARNING "SEP Driver mmap requested size is more \478478+ /* check that the size of the mapped range is as the size of the message479479+ shared area */480480+ if ((vma->vm_end - vma->vm_start) > SEP_DRIVER_MMMAP_AREA_SIZE) {481481+ edbg("SEP Driver mmap requested size is more than allowed\n");482482+ printk(KERN_WARNING "SEP Driver mmap requested size is more \453483 than allowed\n");454454- printk(KERN_WARNING "SEP Driver vma->vm_end is %08lx\n",455455- vma->vm_end);456456- printk(KERN_WARNING "SEP Driver vma->vm_end is %08lx\n",457457- vma->vm_start);458458- return -EAGAIN;459459- }484484+ printk(KERN_WARNING "SEP Driver vma->vm_end is %08lx\n", vma->vm_end);485485+ printk(KERN_WARNING "SEP Driver vma->vm_end is %08lx\n", vma->vm_start);486486+ return -EAGAIN;487487+ }460488461461- edbg(462462- "SEP Driver:g_message_shared_area_addr is %08lx\n",463463- sep_dev->message_shared_area_addr);489489+ edbg("SEP Driver:g_message_shared_area_addr is %08lx\n", sep_dev->message_shared_area_addr);464490465465- /* get physical address */466466- phys_addr = sep_dev->phys_shared_area_addr;491491+ /* get physical address */492492+ phys_addr = sep_dev->phys_shared_area_addr;467493468468- edbg( "SEP Driver: phys_addr is %08lx\n",469469-phys_addr);494494+ edbg("SEP Driver: phys_addr is %08lx\n", phys_addr);470495471471- if (remap_pfn_range(vma,472472- vma->vm_start,473473- phys_addr >> PAGE_SHIFT,474474- vma->vm_end - vma->vm_start,475475- vma->vm_page_prot)) {476476- edbg(477477- "SEP Driver remap_page_range failed\n");478478- printk(KERN_WARNING "SEP Driver remap_page_range failed\n");479479- return -EAGAIN;480480- }496496+ if (remap_pfn_range(vma, vma->vm_start, phys_addr >> PAGE_SHIFT, vma->vm_end - vma->vm_start, vma->vm_page_prot)) {497497+ edbg("SEP Driver remap_page_range failed\n");498498+ printk(KERN_WARNING "SEP Driver remap_page_range failed\n");499499+ return -EAGAIN;500500+ }481501482482- dbg("SEP Driver:<-------- mmap end\n");502502+ dbg("SEP Driver:<-------- mmap end\n");483503484484- return 0;504504+ return 0;485505}486506487507488508/*-----------------------------------------------489509 poll function490510*----------------------------------------------*/491491-static unsigned int sep_poll(struct file *filp, poll_table *wait)511511+static unsigned int sep_poll(struct file *filp, poll_table * wait)492512{493493- unsigned long count;513513+ unsigned long count;494514495495- unsigned int mask = 0;515515+ unsigned int mask = 0;496516497497- /* flow id */498498- unsigned long retVal = 0;517517+ /* flow id */518518+ unsigned long retVal = 0;499519500520 /*----------------------------------------------501521 CODE502522 -------------------------------------------------*/503523504504- dbg("---------->SEP Driver poll: start\n");524524+ dbg("---------->SEP Driver poll: start\n");505525506526507527#if SEP_DRIVER_POLLING_MODE508528509509- while (sep_dev->host_to_sep_send_counter != (retVal & 0x7FFFFFFF)) {510510- retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR2_REG_ADDR);529529+ while (sep_dev->host_to_sep_send_counter != (retVal & 0x7FFFFFFF)) {530530+ retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR2_REG_ADDR);511531512512- for (count = 0; count < 10 * 4; count += 4)513513- edbg("Poll Debug Word %lu of the message is %lu\n", count,514514- *((unsigned long *)(sep_dev->shared_area_addr +515515- SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES + count)));516516- }532532+ for (count = 0; count < 10 * 4; count += 4)533533+ 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)));534534+ }517535518518- sep_dev->sep_to_host_reply_counter++;536536+ sep_dev->sep_to_host_reply_counter++;519537#else520520- /* add the event to the polling wait table */521521- poll_wait(filp, &g_sep_event, wait);538538+ /* add the event to the polling wait table */539539+ poll_wait(filp, &g_sep_event, wait);522540523541#endif524542525525- edbg(526526- "sep_dev->host_to_sep_send_counter is %lu\n",527527- sep_dev->host_to_sep_send_counter);528528- edbg(529529- "sep_dev->sep_to_host_reply_counter is %lu\n",530530- sep_dev->sep_to_host_reply_counter);543543+ edbg("sep_dev->host_to_sep_send_counter is %lu\n", sep_dev->host_to_sep_send_counter);544544+ edbg("sep_dev->sep_to_host_reply_counter is %lu\n", sep_dev->sep_to_host_reply_counter);531545532532- /* check if the data is ready */533533- if (sep_dev->host_to_sep_send_counter == sep_dev->sep_to_host_reply_counter) {534534- for (count = 0; count < 12 * 4; count += 4)535535- edbg("Sep Mesg Word %lu of the message is %lu\n", count,536536- *((unsigned long *)(sep_dev->shared_area_addr + count)));546546+ /* check if the data is ready */547547+ if (sep_dev->host_to_sep_send_counter == sep_dev->sep_to_host_reply_counter) {548548+ for (count = 0; count < 12 * 4; count += 4)549549+ edbg("Sep Mesg Word %lu of the message is %lu\n", count, *((unsigned long *) (sep_dev->shared_area_addr + count)));537550538538- for (count = 0; count < 10 * 4; count += 4)539539- edbg("Debug Data Word %lu of the message is %lu\n", count,540540- *((unsigned long *)(sep_dev->shared_area_addr + 0x1800 + count)));551551+ for (count = 0; count < 10 * 4; count += 4)552552+ edbg("Debug Data Word %lu of the message is %lu\n", count, *((unsigned long *) (sep_dev->shared_area_addr + 0x1800 + count)));541553542542- retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR2_REG_ADDR);543543- edbg( "retVal is %lu\n", retVal);544544- /* check if the this is sep reply or request */545545- if (retVal >> 31) {546546- edbg(547547- "SEP Driver: sep request in\n");548548- /* request */549549- mask |= POLLOUT | POLLWRNORM;550550- } else {551551- edbg( "SEP Driver: sep reply in\n");552552- mask |= POLLIN | POLLRDNORM;554554+ retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR2_REG_ADDR);555555+ edbg("retVal is %lu\n", retVal);556556+ /* check if the this is sep reply or request */557557+ if (retVal >> 31) {558558+ edbg("SEP Driver: sep request in\n");559559+ /* request */560560+ mask |= POLLOUT | POLLWRNORM;561561+ } else {562562+ edbg("SEP Driver: sep reply in\n");563563+ mask |= POLLIN | POLLRDNORM;564564+ }553565 }554554- }555566556556- dbg("SEP Driver:<-------- poll exit\n");557557- return mask;567567+ dbg("SEP Driver:<-------- poll exit\n");568568+ return mask;558569}559570560571561561-static int sep_ioctl(struct inode *inode,562562- struct file *filp,563563- unsigned int cmd,564564- unsigned long arg)572572+static int sep_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg)565573{566574567567- /* error */568568- int error;575575+ /* error */576576+ int error;569577570578 /*------------------------571579 CODE572580 ------------------------*/573573- error = 0;581581+ error = 0;574582575575- dbg("------------>SEP Driver: ioctl start\n");583583+ dbg("------------>SEP Driver: ioctl start\n");576584577577- edbg("SEP Driver: cmd is %x\n", cmd);585585+ edbg("SEP Driver: cmd is %x\n", cmd);578586579579- /* check that the command is for sep device */580580- if (_IOC_TYPE(cmd) != SEP_IOC_MAGIC_NUMBER)581581- error = -ENOTTY;587587+ /* check that the command is for sep device */588588+ if (_IOC_TYPE(cmd) != SEP_IOC_MAGIC_NUMBER)589589+ error = -ENOTTY;582590583591 switch (cmd) {584592 case SEP_IOCSENDSEPCOMMAND:585593586586- /* send command to SEP */587587- sep_send_command_handler();594594+ /* send command to SEP */595595+ sep_send_command_handler();588596589589- edbg(590590- "SEP Driver: after sep_send_command_handler\n");597597+ edbg("SEP Driver: after sep_send_command_handler\n");591598592592- break;599599+ break;593600594601 case SEP_IOCSENDSEPRPLYCOMMAND:595602596596- /* send reply command to SEP */597597- sep_send_reply_command_handler();603603+ /* send reply command to SEP */604604+ sep_send_reply_command_handler();598605599599- break;606606+ break;600607601608 case SEP_IOCALLOCDATAPOLL:602609603603- /* allocate data pool */604604- error = sep_allocate_data_pool_memory_handler(arg);610610+ /* allocate data pool */611611+ error = sep_allocate_data_pool_memory_handler(arg);605612606606- break;613613+ break;607614608615 case SEP_IOCWRITEDATAPOLL:609616610610- /* write data into memory pool */611611- error = sep_write_into_data_pool_handler(arg);617617+ /* write data into memory pool */618618+ error = sep_write_into_data_pool_handler(arg);612619613613- break;620620+ break;614621615622 case SEP_IOCREADDATAPOLL:616623617617- /* read data from data pool into application memory */618618- error = sep_read_from_data_pool_handler(arg);624624+ /* read data from data pool into application memory */625625+ error = sep_read_from_data_pool_handler(arg);619626620620- break;627627+ break;621628622629 case SEP_IOCCREATESYMDMATABLE:623630624624- /* create dma table for synhronic operation */625625- error = sep_create_sync_dma_tables_handler(arg);631631+ /* create dma table for synhronic operation */632632+ error = sep_create_sync_dma_tables_handler(arg);626633627627- break;634634+ break;628635629636 case SEP_IOCCREATEFLOWDMATABLE:630637631631- /* create flow dma tables */632632- error = sep_create_flow_dma_tables_handler(arg);638638+ /* create flow dma tables */639639+ error = sep_create_flow_dma_tables_handler(arg);633640634634- break;641641+ break;635642636643 case SEP_IOCFREEDMATABLEDATA:637644638638- /* free the pages */639639- error = sep_free_dma_table_data_handler();645645+ /* free the pages */646646+ error = sep_free_dma_table_data_handler();640647641641- break;648648+ break;642649643650 case SEP_IOCSETFLOWID:644651645645- /* set flow id */646646- error = sep_set_flow_id_handler(arg);652652+ /* set flow id */653653+ error = sep_set_flow_id_handler(arg);647654648648- break;655655+ break;649656650657 case SEP_IOCADDFLOWTABLE:651658652652- /* add tables to the dynamic flow */653653- error = sep_add_flow_tables_handler(arg);659659+ /* add tables to the dynamic flow */660660+ error = sep_add_flow_tables_handler(arg);654661655655- break;662662+ break;656663657664 case SEP_IOCADDFLOWMESSAGE:658665659659- /* add message of add tables to flow */660660- error = sep_add_flow_tables_message_handler(arg);666666+ /* add message of add tables to flow */667667+ error = sep_add_flow_tables_message_handler(arg);661668662662- break;669669+ break;663670664671 case SEP_IOCSEPSTART:665672666666- /* start command to sep */667667- error = sep_start_handler();668668- break;673673+ /* start command to sep */674674+ error = sep_start_handler();675675+ break;669676670677 case SEP_IOCSEPINIT:671678672672- /* init command to sep */673673- error = sep_init_handler(arg);674674- break;679679+ /* init command to sep */680680+ error = sep_init_handler(arg);681681+ break;675682676683 case SEP_IOCSETAPIMODE:677684678678- /* set non- blocking mode */679679- error = sep_set_api_mode_handler(arg);685685+ /* set non- blocking mode */686686+ error = sep_set_api_mode_handler(arg);680687681681- break;688688+ break;682689683690 case SEP_IOCGETSTATICPOOLADDR:684691···665720666721 case SEP_IOCENDTRANSACTION:667722668668- error = sep_end_transaction_handler(arg);723723+ error = sep_end_transaction_handler(arg);669724670725 break;671726672727 case SEP_IOCREALLOCCACHERES:673728674674- error = sep_realloc_cache_resident_handler(arg);729729+ error = sep_realloc_cache_resident_handler(arg);675730676676- break;731731+ break;677732678733 case SEP_IOCGETMAPPEDADDROFFSET:679734680680- error = sep_get_physical_mapped_offset_handler(arg);735735+ error = sep_get_physical_mapped_offset_handler(arg);681736682682- break;737737+ break;683738 case SEP_IOCGETIME:684739685685- error = sep_get_time_handler(arg);740740+ error = sep_get_time_handler(arg);686741687687- break;742742+ break;688743689744 default:690690- error = -ENOTTY;691691- break;692692- }745745+ error = -ENOTTY;746746+ break;747747+ }693748694694- dbg("SEP Driver:<-------- ioctl end\n");749749+ dbg("SEP Driver:<-------- ioctl end\n");695750696696- return error;751751+ return error;697752}698753699754700755/*701756 this function registers the driver to the file system702757*/703703-static int sep_register_driver_to_fs(void)758758+static int sep_register_driver_to_fs(void)704759{705705- /* return value */706706- int ret_val;760760+ /* return value */761761+ int ret_val;707762708763 /*---------------------709764 CODE710765 -----------------------*/711766712712- ret_val = alloc_chrdev_region(&g_sep_device_number, 0, 1, "sep_sec_driver");713713- if (ret_val) {714714- edbg(715715- "sep_driver:major number allocation failed, retval is %d\n", ret_val);767767+ ret_val = alloc_chrdev_region(&g_sep_device_number, 0, 1, "sep_sec_driver");768768+ if (ret_val) {769769+ edbg("sep_driver:major number allocation failed, retval is %d\n", ret_val);770770+ goto end_function;771771+ }772772+773773+ /* set the files operations structure */774774+ g_sep_fops.owner = THIS_MODULE;775775+ g_sep_fops.ioctl = sep_ioctl;776776+ g_sep_fops.poll = sep_poll;777777+ g_sep_fops.open = sep_open;778778+ g_sep_fops.release = sep_release;779779+ g_sep_fops.mmap = sep_mmap;780780+781781+ /* init cdev */782782+ cdev_init(&g_sep_cdev, &g_sep_fops);783783+ g_sep_cdev.owner = THIS_MODULE;784784+785785+ /* register the driver with the kernel */786786+ ret_val = cdev_add(&g_sep_cdev, g_sep_device_number, 1);787787+788788+ if (ret_val) {789789+ edbg("sep_driver:cdev_add failed, retval is %d\n", ret_val);790790+ goto end_function_unregister_devnum;791791+ }792792+716793 goto end_function;717717- }718794719719- /* set the files operations structure */720720- g_sep_fops.owner = THIS_MODULE;721721- g_sep_fops.ioctl = sep_ioctl;722722- g_sep_fops.poll = sep_poll;723723- g_sep_fops.open = sep_open;724724- g_sep_fops.release = sep_release;725725- g_sep_fops.mmap = sep_mmap;795795+ end_function_unregister_devnum:726796727727- /* init cdev */728728- cdev_init(&g_sep_cdev, &g_sep_fops);729729- g_sep_cdev.owner = THIS_MODULE;797797+ /* unregister dev numbers */798798+ unregister_chrdev_region(g_sep_device_number, 1);730799731731- /* register the driver with the kernel */732732- ret_val = cdev_add(&g_sep_cdev, g_sep_device_number, 1);800800+ end_function:733801734734- if (ret_val) {735735- edbg(736736- "sep_driver:cdev_add failed, retval is %d\n",737737- ret_val);738738- goto end_function_unregister_devnum;739739- }740740-741741- goto end_function;742742-743743-end_function_unregister_devnum:744744-745745- /* unregister dev numbers */746746- unregister_chrdev_region(g_sep_device_number, 1);747747-748748-end_function:749749-750750- return ret_val;802802+ return ret_val;751803}752804753805/*···756814 CODE757815 ---------------------*/758816759759- cdev_del(&g_sep_cdev);817817+ cdev_del(&g_sep_cdev);760818761761- /* unregister dev numbers */762762- unregister_chrdev_region(g_sep_device_number, 1);819819+ /* unregister dev numbers */820820+ unregister_chrdev_region(g_sep_device_number, 1);763821}764822765823/*--------------------------------------------------------------···767825----------------------------------------------------------------*/768826static int __init sep_init(void)769827{770770- /* return value */771771- int ret_val;828828+ /* return value */829829+ int ret_val;772830773773- /* counter */774774- int counter;831831+ /* counter */832832+ int counter;775833776776- /* size to of memory for allocation */777777- int size;834834+ /* size to of memory for allocation */835835+ int size;778836779837 /*------------------------780838 CODE781839 ------------------------*/782840783783- dbg("SEP Driver:-------->Init start\n");784784- edbg("sep->shared_area_addr = %lx\n",785785- (unsigned long)&sep_dev->shared_area_addr);841841+ dbg("SEP Driver:-------->Init start\n");842842+ edbg("sep->shared_area_addr = %lx\n", (unsigned long) &sep_dev->shared_area_addr);786843787787- ret_val = 0;844844+ ret_val = 0;788845789846/* transaction counter that coordinates the transactions between SEP790847 and HOST */791791- sep_dev->host_to_sep_send_counter = 0;848848+ sep_dev->host_to_sep_send_counter = 0;792849793850/* counter for the messages from sep */794794- sep_dev->sep_to_host_reply_counter = 0;851851+ sep_dev->sep_to_host_reply_counter = 0;795852796853/* counter for the number of bytes allocated in the pool797854for the current transaction */798798- sep_dev->data_pool_bytes_allocated = 0;855855+ sep_dev->data_pool_bytes_allocated = 0;799856800800- /* set the starting mode to blocking */801801- sep_dev->block_mode_flag = 1;857857+ /* set the starting mode to blocking */858858+ sep_dev->block_mode_flag = 1;802859803860804804- ret_val = sep_register_driver_to_device();805805- if (ret_val) {806806- edbg(807807- "sep_driver:sep_driver_to_device failed, ret_val is %d\n",808808- ret_val);809809- goto end_function_unregister_from_fs;810810- }861861+ ret_val = sep_register_driver_to_device();862862+ if (ret_val) {863863+ edbg("sep_driver:sep_driver_to_device failed, ret_val is %d\n", ret_val);864864+ goto end_function_unregister_from_fs;865865+ }811866812812- /* calculate the total size for allocation */813813- size = SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES +814814- SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_SIZE_IN_BYTES +815815- SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES +816816- SEP_DRIVER_FLOW_DMA_TABLES_AREA_SIZE_IN_BYTES +817817- SEP_DRIVER_STATIC_AREA_SIZE_IN_BYTES +818818- SEP_DRIVER_SYSTEM_DATA_MEMORY_SIZE_IN_BYTES;867867+ /* calculate the total size for allocation */868868+ size = SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES +869869+ 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;819870820871821872822822- /* allocate the shared area */823823- if (sep_map_and_alloc_shared_area(size,824824- &sep_dev->shared_area_addr,825825- &sep_dev->phys_shared_area_addr)) {826826- ret_val = -ENOMEM;827827- /* allocation failed */828828- goto end_function_unmap_io_memory;829829- }873873+ /* allocate the shared area */874874+ if (sep_map_and_alloc_shared_area(size, &sep_dev->shared_area_addr, &sep_dev->phys_shared_area_addr)) {875875+ ret_val = -ENOMEM;876876+ /* allocation failed */877877+ goto end_function_unmap_io_memory;878878+ }830879831831- /* now set the memory regions */832832- sep_dev->message_shared_area_addr = sep_dev->shared_area_addr;880880+ /* now set the memory regions */881881+ sep_dev->message_shared_area_addr = sep_dev->shared_area_addr;833882834834- edbg(835835- "SEP Driver: g_message_shared_area_addr is %08lx\n",836836- sep_dev->message_shared_area_addr);883883+ edbg("SEP Driver: g_message_shared_area_addr is %08lx\n", sep_dev->message_shared_area_addr);837884838885#if (SEP_DRIVER_RECONFIG_MESSAGE_AREA == 1)839886840840- /* send the new SHARED MESSAGE AREA to the SEP */841841- sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR1_REG_ADDR,842842- sep_dev->phys_shared_area_addr);887887+ /* send the new SHARED MESSAGE AREA to the SEP */888888+ sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR1_REG_ADDR, sep_dev->phys_shared_area_addr);843889844844- /* poll for SEP response */845845- retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR1_REG_ADDR);846846- while (retVal != 0xffffffff && retVal != sep_dev->phys_shared_area_addr)890890+ /* poll for SEP response */847891 retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR1_REG_ADDR);892892+ while (retVal != 0xffffffff && retVal != sep_dev->phys_shared_area_addr)893893+ retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR1_REG_ADDR);848894849849- /* check the return value (register) */850850- if (retVal != sep_dev->phys_shared_area_addr) {851851- ret_val = -ENOMEM;852852- goto end_function_deallocate_message_area;853853- }854854-895895+ /* check the return value (register) */896896+ if (retVal != sep_dev->phys_shared_area_addr) {897897+ ret_val = -ENOMEM;898898+ goto end_function_deallocate_message_area;899899+ }855900#endif856901857857- /* init the flow contextes */858858- for (counter = 0; counter < SEP_DRIVER_NUM_FLOWS; counter++)859859- sep_dev->flows_data_array[counter].flow_id = SEP_FREE_FLOW_ID;902902+ /* init the flow contextes */903903+ for (counter = 0; counter < SEP_DRIVER_NUM_FLOWS; counter++)904904+ sep_dev->flows_data_array[counter].flow_id = SEP_FREE_FLOW_ID;860905861861- sep_dev->flow_wq_ptr = create_singlethread_workqueue("sepflowwq");862862- if (sep_dev->flow_wq_ptr == 0) {863863- ret_val = -ENOMEM;864864- edbg(865865- "sep_driver:flow queue creation failed\n");866866- goto end_function_deallocate_sep_shared_area;867867- }906906+ sep_dev->flow_wq_ptr = create_singlethread_workqueue("sepflowwq");907907+ if (sep_dev->flow_wq_ptr == 0) {908908+ ret_val = -ENOMEM;909909+ edbg("sep_driver:flow queue creation failed\n");910910+ goto end_function_deallocate_sep_shared_area;911911+ }868912869869- edbg(870870- "SEP Driver: create flow workqueue \n");913913+ edbg("SEP Driver: create flow workqueue \n");871914872872- /* register driver to fs */873873- ret_val = sep_register_driver_to_fs();874874- if (ret_val)875875- goto end_function_deallocate_sep_shared_area;915915+ /* register driver to fs */916916+ ret_val = sep_register_driver_to_fs();917917+ if (ret_val)918918+ goto end_function_deallocate_sep_shared_area;876919877877- /* load the rom code */878878- sep_load_rom_code();920920+ /* load the rom code */921921+ sep_load_rom_code();879922880880- goto end_function;923923+ goto end_function;881924882882-end_function_unregister_from_fs:925925+ end_function_unregister_from_fs:883926884884- /* unregister from fs */885885- sep_unregister_driver_from_fs();927927+ /* unregister from fs */928928+ sep_unregister_driver_from_fs();886929887887-end_function_deallocate_sep_shared_area:930930+ end_function_deallocate_sep_shared_area:888931889889- /* de-allocate shared area */890890- sep_unmap_and_free_shared_area(size,891891- sep_dev->shared_area_addr,892892- sep_dev->phys_shared_area_addr);932932+ /* de-allocate shared area */933933+ sep_unmap_and_free_shared_area(size, sep_dev->shared_area_addr, sep_dev->phys_shared_area_addr);893934894894-end_function_unmap_io_memory:935935+ end_function_unmap_io_memory:895936896896- iounmap((void *)sep_dev->reg_base_address);937937+ iounmap((void *) sep_dev->reg_base_address);897938898898- /* release io memory region */899899- release_mem_region(SEP_IO_MEM_REGION_START_ADDRESS, SEP_IO_MEM_REGION_SIZE);939939+ /* release io memory region */940940+ release_mem_region(SEP_IO_MEM_REGION_START_ADDRESS, SEP_IO_MEM_REGION_SIZE);900941901901-end_function:942942+ end_function:902943903903- dbg("SEP Driver:<-------- Init end\n");944944+ dbg("SEP Driver:<-------- Init end\n");904945905905- return ret_val;946946+ return ret_val;906947}907948908949···896971--------------------------------------------------------------*/897972static void __exit sep_exit(void)898973{899899- /* size */900900- int size;974974+ /* size */975975+ int size;901976902977 /*-----------------------------903978 CODE904979 --------------------------------*/905980906906- dbg("SEP Driver:--------> Exit start\n");981981+ dbg("SEP Driver:--------> Exit start\n");907982908908- /* unregister from fs */909909- sep_unregister_driver_from_fs();983983+ /* unregister from fs */984984+ sep_unregister_driver_from_fs();910985911911- /* calculate the total size for de-allocation */912912- size = SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES +913913- SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_SIZE_IN_BYTES +914914- SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES +915915- SEP_DRIVER_FLOW_DMA_TABLES_AREA_SIZE_IN_BYTES +916916- SEP_DRIVER_STATIC_AREA_SIZE_IN_BYTES +917917- SEP_DRIVER_SYSTEM_DATA_MEMORY_SIZE_IN_BYTES;986986+ /* calculate the total size for de-allocation */987987+ size = SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES +988988+ 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;918989919990920920- /* free shared area */921921- sep_unmap_and_free_shared_area(size,922922- sep_dev->shared_area_addr,923923- sep_dev->phys_shared_area_addr);991991+ /* free shared area */992992+ sep_unmap_and_free_shared_area(size, sep_dev->shared_area_addr, sep_dev->phys_shared_area_addr);924993925925- edbg(926926- "SEP Driver: free pages SEP SHARED AREA \n");994994+ edbg("SEP Driver: free pages SEP SHARED AREA \n");927995928928- iounmap((void *)sep_dev->reg_base_address);996996+ iounmap((void *) sep_dev->reg_base_address);929997930930- edbg( "SEP Driver: iounmap \n");998998+ edbg("SEP Driver: iounmap \n");931999932932- /* release io memory region */933933- release_mem_region(SEP_IO_MEM_REGION_START_ADDRESS, SEP_IO_MEM_REGION_SIZE);10001000+ /* release io memory region */10011001+ release_mem_region(SEP_IO_MEM_REGION_START_ADDRESS, SEP_IO_MEM_REGION_SIZE);9341002935935- edbg( "SEP Driver: release_mem_region \n");10031003+ edbg("SEP Driver: release_mem_region \n");9361004937937- dbg("SEP Driver:<-------- Exit end\n");10051005+ dbg("SEP Driver:<-------- Exit end\n");9381006}93910079401008···9361018*/9371019irqreturn_t sep_inthandler(int irq, void *dev_id)9381020{939939- /* int error */940940- irqreturn_t int_error;10211021+ /* int error */10221022+ irqreturn_t int_error;9411023942942- /* error */943943- unsigned long error;10241024+ /* error */10251025+ unsigned long error;9441026945945- /* reg value */946946- unsigned long reg_val;10271027+ /* reg value */10281028+ unsigned long reg_val;9471029948948- /* flow id */949949- unsigned long flow_id;10301030+ /* flow id */10311031+ unsigned long flow_id;9501032951951- /* flow context */952952- struct sep_flow_context_t *flow_context_ptr;10331033+ /* flow context */10341034+ struct sep_flow_context_t *flow_context_ptr;95310359541036 /*-----------------------------9551037 CODE9561038 -----------------------------*/9571039958958- int_error = IRQ_HANDLED;10401040+ int_error = IRQ_HANDLED;9591041960960- /* read the IRR register to check if this is SEP interrupt */961961- reg_val = sep_read_reg(sep_dev, HW_HOST_IRR_REG_ADDR);962962- edbg( "SEP Interrupt - reg is %08lx\n",963963- reg_val);10421042+ /* read the IRR register to check if this is SEP interrupt */10431043+ reg_val = sep_read_reg(sep_dev, HW_HOST_IRR_REG_ADDR);10441044+ edbg("SEP Interrupt - reg is %08lx\n", reg_val);9641045965965- /* check if this is the flow interrupt */966966- if (0/*reg_val & (0x1 << 11)*/) {967967- /* read GPRO to find out the which flow is done */968968- flow_id = sep_read_reg(sep_dev, HW_HOST_IRR_REG_ADDR);10461046+ /* check if this is the flow interrupt */10471047+ if (0 /*reg_val & (0x1 << 11) */ ) {10481048+ /* read GPRO to find out the which flow is done */10491049+ flow_id = sep_read_reg(sep_dev, HW_HOST_IRR_REG_ADDR);9691050970970- /* find the contex of the flow */971971- error = sep_find_flow_context(flow_id >> 28, &flow_context_ptr);972972- if (error)973973- goto end_function_with_error;10511051+ /* find the contex of the flow */10521052+ error = sep_find_flow_context(flow_id >> 28, &flow_context_ptr);10531053+ if (error)10541054+ goto end_function_with_error;9741055975975- INIT_WORK(&flow_context_ptr->flow_wq, sep_flow_done_handler);10561056+ INIT_WORK(&flow_context_ptr->flow_wq, sep_flow_done_handler);9761057977977- /* queue the work */978978- queue_work(sep_dev->flow_wq_ptr, &flow_context_ptr->flow_wq);10581058+ /* queue the work */10591059+ queue_work(sep_dev->flow_wq_ptr, &flow_context_ptr->flow_wq);9791060980980- } else {981981- /* check if this is reply interrupt from SEP */982982- if (reg_val & (0x1 << 13)) {983983- /* update the counter of reply messages */984984- sep_dev->sep_to_host_reply_counter++;985985-986986- /* wake up the waiting process */987987- wake_up(&g_sep_event);9881061 } else {989989- int_error = IRQ_NONE;990990- goto end_function;10621062+ /* check if this is reply interrupt from SEP */10631063+ if (reg_val & (0x1 << 13)) {10641064+ /* update the counter of reply messages */10651065+ sep_dev->sep_to_host_reply_counter++;10661066+10671067+ /* wake up the waiting process */10681068+ wake_up(&g_sep_event);10691069+ } else {10701070+ int_error = IRQ_NONE;10711071+ goto end_function;10721072+ }9911073 }992992- }9931074994994-end_function_with_error:10751075+ end_function_with_error:9951076996996- /* clear the interrupt */997997- sep_write_reg(sep_dev, HW_HOST_ICR_REG_ADDR, reg_val);10771077+ /* clear the interrupt */10781078+ sep_write_reg(sep_dev, HW_HOST_ICR_REG_ADDR, reg_val);9981079999999-end_function:10801080+ end_function:1000108110011001- return int_error;10821082+ return int_error;10021083}1003108410041085···10051088 This function prepares only input DMA table for synhronic symmetric10061089 operations (HASH)10071090*/10081008-int sep_prepare_input_dma_table(unsigned long app_virt_addr,10091009- unsigned long data_size,10101010- unsigned long block_size,10111011- unsigned long *lli_table_ptr,10121012- unsigned long *num_entries_ptr,10131013- unsigned long *table_data_size_ptr,10141014- bool isKernelVirtualAddress)10151015-10911091+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)10161092{10171017- /* pointer to the info entry of the table - the last entry */10181018- struct sep_lli_entry_t *info_entry_ptr;10931093+ /* pointer to the info entry of the table - the last entry */10941094+ struct sep_lli_entry_t *info_entry_ptr;1019109510201020- /* array of pointers ot page */10211021- struct sep_lli_entry_t *lli_array_ptr;10961096+ /* array of pointers ot page */10971097+ struct sep_lli_entry_t *lli_array_ptr;1022109810231023- /* points to the first entry to be processed in the lli_in_array */10241024- unsigned long current_entry;10991099+ /* points to the first entry to be processed in the lli_in_array */11001100+ unsigned long current_entry;1025110110261026- /* num entries in the virtual buffer */10271027- unsigned long sep_lli_entries;11021102+ /* num entries in the virtual buffer */11031103+ unsigned long sep_lli_entries;1028110410291029- /* lli table pointer */10301030- struct sep_lli_entry_t *in_lli_table_ptr;11051105+ /* lli table pointer */11061106+ struct sep_lli_entry_t *in_lli_table_ptr;1031110710321032- /* the total data in one table */10331033- unsigned long table_data_size;11081108+ /* the total data in one table */11091109+ unsigned long table_data_size;1034111010351035- /* number of entries in lli table */10361036- unsigned long num_entries_in_table;11111111+ /* number of entries in lli table */11121112+ unsigned long num_entries_in_table;1037111310381038- /* next table address */10391039- unsigned long lli_table_alloc_addr;11141114+ /* next table address */11151115+ unsigned long lli_table_alloc_addr;1040111610411041- /* result */10421042- unsigned long result;11171117+ /* result */11181118+ unsigned long result;1043111910441120 /*------------------------10451121 CODE10461122 --------------------------*/1047112310481048- dbg("SEP Driver:--------> sep_prepare_input_dma_table start\n");11241124+ dbg("SEP Driver:--------> sep_prepare_input_dma_table start\n");1049112510501050- edbg( "SEP Driver:data_size is %lu\n", data_size);10511051- edbg( "SEP Driver:block_size is %lu\n", block_size);11261126+ edbg("SEP Driver:data_size is %lu\n", data_size);11271127+ edbg("SEP Driver:block_size is %lu\n", block_size);1052112810531053- /* initialize the pages pointers */10541054- sep_dev->in_page_array = 0;10551055- sep_dev->in_num_pages = 0;11291129+ /* initialize the pages pointers */11301130+ sep_dev->in_page_array = 0;11311131+ sep_dev->in_num_pages = 0;1056113210571057- if (data_size == 0) {10581058- /* special case - created 2 entries table with zero data */10591059- in_lli_table_ptr = (struct sep_lli_entry_t *)(sep_dev->shared_area_addr +10601060- SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES);10611061- in_lli_table_ptr->physical_address = sep_dev->shared_area_addr +10621062- SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES;10631063- in_lli_table_ptr->block_size = 0;11331133+ if (data_size == 0) {11341134+ /* special case - created 2 entries table with zero data */11351135+ in_lli_table_ptr = (struct sep_lli_entry_t *) (sep_dev->shared_area_addr + SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES);11361136+ in_lli_table_ptr->physical_address = sep_dev->shared_area_addr + SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES;11371137+ in_lli_table_ptr->block_size = 0;1064113810651065- in_lli_table_ptr++;10661066- in_lli_table_ptr->physical_address = 0xFFFFFFFF;10671067- in_lli_table_ptr->block_size = 0;11391139+ in_lli_table_ptr++;11401140+ in_lli_table_ptr->physical_address = 0xFFFFFFFF;11411141+ in_lli_table_ptr->block_size = 0;1068114210691069- *lli_table_ptr = sep_dev->phys_shared_area_addr +10701070- SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES;10711071- *num_entries_ptr = 2;10721072- *table_data_size_ptr = 0;11431143+ *lli_table_ptr = sep_dev->phys_shared_area_addr + SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES;11441144+ *num_entries_ptr = 2;11451145+ *table_data_size_ptr = 0;1073114610741074- goto end_function;10751075- }10761076-10771077- /* check if the pages are in Kernel Virtual Address layout */10781078- if (isKernelVirtualAddress == true)10791079- /* lock the pages of the kernel buffer and translate them to pages */10801080- result = sep_lock_kernel_pages(app_virt_addr,10811081- data_size,10821082- &sep_dev->in_num_pages,10831083- &lli_array_ptr,10841084- &sep_dev->in_page_array);10851085- else10861086- /* lock the pages of the user buffer and translate them to pages */10871087- result = sep_lock_user_pages(app_virt_addr,10881088- data_size,10891089- &sep_dev->in_num_pages,10901090- &lli_array_ptr,10911091- &sep_dev->in_page_array);10921092-10931093- if (result)10941094- return result;10951095-10961096- edbg(10971097- "SEP Driver:output sep_dev->in_num_pages is %lu\n",10981098- sep_dev->in_num_pages);10991099-11001100- current_entry = 0;11011101- info_entry_ptr = 0;11021102- sep_lli_entries = sep_dev->in_num_pages;11031103-11041104- /* initiate to point after the message area */11051105- lli_table_alloc_addr = sep_dev->shared_area_addr +11061106- SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES;11071107-11081108- /* loop till all the entries in in array are not processed */11091109- while (current_entry < sep_lli_entries) {11101110- /* set the new input and output tables */11111111- in_lli_table_ptr = (struct sep_lli_entry_t *)lli_table_alloc_addr;11121112-11131113- lli_table_alloc_addr += sizeof(struct sep_lli_entry_t) *11141114- SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP;11151115-11161116- /* calculate the maximum size of data for input table */11171117- table_data_size = sep_calculate_lli_table_max_size(11181118- &lli_array_ptr[current_entry],11191119- (sep_lli_entries - current_entry));11201120-11211121- /* now calculate the table size so that it will be module block size */11221122- table_data_size = (table_data_size / block_size) * block_size;11231123-11241124- edbg(11251125- "SEP Driver:output table_data_size is %lu\n",11261126- table_data_size);11271127-11281128- /* construct input lli table */11291129- sep_build_lli_table(&lli_array_ptr[current_entry],11301130- in_lli_table_ptr,11311131- ¤t_entry,11321132- &num_entries_in_table,11331133- table_data_size);11341134-11351135- if (info_entry_ptr == 0) {11361136- /* set the output parameters to physical addresses */11371137- *lli_table_ptr = sep_shared_area_virt_to_phys(11381138- (unsigned long)in_lli_table_ptr);11391139- *num_entries_ptr = num_entries_in_table;11401140- *table_data_size_ptr = table_data_size;11411141-11421142- edbg(11431143- "SEP Driver:output lli_table_in_ptr is %08lx\n",11441144- *lli_table_ptr);11451145- } else {11461146- /* update the info entry of the previous in table */11471147- info_entry_ptr->physical_address = sep_shared_area_virt_to_phys(11481148- (unsigned long)in_lli_table_ptr);11491149- info_entry_ptr->block_size = ((num_entries_in_table) << 24) |11501150- (table_data_size);11471147+ goto end_function;11511148 }1152114911531153- /* save the pointer to the info entry of the current tables */11541154- info_entry_ptr = in_lli_table_ptr + num_entries_in_table - 1;11551155- }11501150+ /* check if the pages are in Kernel Virtual Address layout */11511151+ if (isKernelVirtualAddress == true)11521152+ /* lock the pages of the kernel buffer and translate them to pages */11531153+ result = sep_lock_kernel_pages(app_virt_addr, data_size, &sep_dev->in_num_pages, &lli_array_ptr, &sep_dev->in_page_array);11541154+ else11551155+ /* lock the pages of the user buffer and translate them to pages */11561156+ result = sep_lock_user_pages(app_virt_addr, data_size, &sep_dev->in_num_pages, &lli_array_ptr, &sep_dev->in_page_array);1156115711571157- /* print input tables */11581158- sep_debug_print_lli_tables((struct sep_lli_entry_t *)11591159- sep_shared_area_phys_to_virt(*lli_table_ptr),11601160- *num_entries_ptr,11611161- *table_data_size_ptr);11581158+ if (result)11591159+ return result;1162116011631163- /* the array of the pages */11641164- kfree(lli_array_ptr);11611161+ edbg("SEP Driver:output sep_dev->in_num_pages is %lu\n", sep_dev->in_num_pages);1165116211661166-end_function:11631163+ current_entry = 0;11641164+ info_entry_ptr = 0;11651165+ sep_lli_entries = sep_dev->in_num_pages;1167116611681168- dbg("SEP Driver:<-------- sep_prepare_input_dma_table end\n");11671167+ /* initiate to point after the message area */11681168+ lli_table_alloc_addr = sep_dev->shared_area_addr + SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES;1169116911701170- return 0;11701170+ /* loop till all the entries in in array are not processed */11711171+ while (current_entry < sep_lli_entries) {11721172+ /* set the new input and output tables */11731173+ in_lli_table_ptr = (struct sep_lli_entry_t *) lli_table_alloc_addr;11741174+11751175+ lli_table_alloc_addr += sizeof(struct sep_lli_entry_t) * SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP;11761176+11771177+ /* calculate the maximum size of data for input table */11781178+ table_data_size = sep_calculate_lli_table_max_size(&lli_array_ptr[current_entry], (sep_lli_entries - current_entry));11791179+11801180+ /* now calculate the table size so that it will be module block size */11811181+ table_data_size = (table_data_size / block_size) * block_size;11821182+11831183+ edbg("SEP Driver:output table_data_size is %lu\n", table_data_size);11841184+11851185+ /* construct input lli table */11861186+ sep_build_lli_table(&lli_array_ptr[current_entry], in_lli_table_ptr, ¤t_entry, &num_entries_in_table, table_data_size);11871187+11881188+ if (info_entry_ptr == 0) {11891189+ /* set the output parameters to physical addresses */11901190+ *lli_table_ptr = sep_shared_area_virt_to_phys((unsigned long) in_lli_table_ptr);11911191+ *num_entries_ptr = num_entries_in_table;11921192+ *table_data_size_ptr = table_data_size;11931193+11941194+ edbg("SEP Driver:output lli_table_in_ptr is %08lx\n", *lli_table_ptr);11951195+ } else {11961196+ /* update the info entry of the previous in table */11971197+ info_entry_ptr->physical_address = sep_shared_area_virt_to_phys((unsigned long) in_lli_table_ptr);11981198+ info_entry_ptr->block_size = ((num_entries_in_table) << 24) | (table_data_size);11991199+ }12001200+12011201+ /* save the pointer to the info entry of the current tables */12021202+ info_entry_ptr = in_lli_table_ptr + num_entries_in_table - 1;12031203+ }12041204+12051205+ /* print input tables */12061206+ sep_debug_print_lli_tables((struct sep_lli_entry_t *)12071207+ sep_shared_area_phys_to_virt(*lli_table_ptr), *num_entries_ptr, *table_data_size_ptr);12081208+12091209+ /* the array of the pages */12101210+ kfree(lli_array_ptr);12111211+12121212+ end_function:12131213+12141214+ dbg("SEP Driver:<-------- sep_prepare_input_dma_table end\n");12151215+12161216+ return 0;1171121711721218}11731219···11391259 symmetric operations (AES, DES). It also checks that each table11401260 is of the modular block size11411261*/11421142-int sep_prepare_input_output_dma_table(unsigned long app_virt_in_addr,11431143- unsigned long app_virt_out_addr,11441144- unsigned long data_size,11451145- unsigned long block_size,11461146- unsigned long *lli_table_in_ptr,11471147- unsigned long *lli_table_out_ptr,11481148- unsigned long *in_num_entries_ptr,11491149- unsigned long *out_num_entries_ptr,11501150- unsigned long *table_data_size_ptr,11511151- bool isKernelVirtualAddress)11521152-12621262+int sep_prepare_input_output_dma_table(unsigned long app_virt_in_addr,12631263+ unsigned long app_virt_out_addr,12641264+ unsigned long data_size,12651265+ unsigned long block_size,12661266+ 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)11531267{11541154- /* array of pointers of page */11551155- struct sep_lli_entry_t *lli_in_array;12681268+ /* array of pointers of page */12691269+ struct sep_lli_entry_t *lli_in_array;1156127011571157- /* array of pointers of page */11581158- struct sep_lli_entry_t *lli_out_array;12711271+ /* array of pointers of page */12721272+ struct sep_lli_entry_t *lli_out_array;1159127311601160- /* result */11611161- int result;12741274+ /* result */12751275+ int result;116212761163127711641278 /*------------------------11651279 CODE11661280 --------------------------*/1167128111681168- dbg("SEP Driver:--------> sep_prepare_input_output_dma_table start\n");12821282+ dbg("SEP Driver:--------> sep_prepare_input_output_dma_table start\n");1169128311701170- result = 0;12841284+ result = 0;1171128511721172- /* initialize the pages pointers */11731173- sep_dev->in_page_array = 0;11741174- sep_dev->out_page_array = 0;12861286+ /* initialize the pages pointers */12871287+ sep_dev->in_page_array = 0;12881288+ sep_dev->out_page_array = 0;1175128911761176- /* check if the pages are in Kernel Virtual Address layout */11771177- if (isKernelVirtualAddress == true) {11781178- /* lock the pages of the kernel buffer and translate them to pages */11791179- result = sep_lock_kernel_pages(app_virt_in_addr,11801180- data_size,11811181- &sep_dev->in_num_pages,11821182- &lli_in_array,11831183- &sep_dev->in_page_array);11841184- if (result) {11851185- edbg(11861186- "SEP Driver: sep_lock_kernel_pages for input virtual buffer failed\n");11871187- goto end_function;12901290+ /* check if the pages are in Kernel Virtual Address layout */12911291+ if (isKernelVirtualAddress == true) {12921292+ /* lock the pages of the kernel buffer and translate them to pages */12931293+ result = sep_lock_kernel_pages(app_virt_in_addr, data_size, &sep_dev->in_num_pages, &lli_in_array, &sep_dev->in_page_array);12941294+ if (result) {12951295+ edbg("SEP Driver: sep_lock_kernel_pages for input virtual buffer failed\n");12961296+ goto end_function;12971297+ }12981298+ } else {12991299+ /* lock the pages of the user buffer and translate them to pages */13001300+ result = sep_lock_user_pages(app_virt_in_addr, data_size, &sep_dev->in_num_pages, &lli_in_array, &sep_dev->in_page_array);13011301+ if (result) {13021302+ edbg("SEP Driver: sep_lock_user_pages for input virtual buffer failed\n");13031303+ goto end_function;13041304+ }11881305 }11891189- } else {11901190- /* lock the pages of the user buffer and translate them to pages */11911191- result = sep_lock_user_pages(app_virt_in_addr,11921192- data_size,11931193- &sep_dev->in_num_pages,11941194- &lli_in_array,11951195- &sep_dev->in_page_array);11961196- if (result) {11971197- edbg(11981198- "SEP Driver: sep_lock_user_pages for input virtual buffer failed\n");11991199- goto end_function;13061306+13071307+ if (isKernelVirtualAddress == true) {13081308+ result = sep_lock_kernel_pages(app_virt_out_addr, data_size, &sep_dev->out_num_pages, &lli_out_array, &sep_dev->out_page_array);13091309+ if (result) {13101310+ edbg("SEP Driver: sep_lock_kernel_pages for output virtual buffer failed\n");13111311+ goto end_function_with_error1;13121312+ }13131313+ } else {13141314+ result = sep_lock_user_pages(app_virt_out_addr, data_size, &sep_dev->out_num_pages, &lli_out_array, &sep_dev->out_page_array);13151315+ if (result) {13161316+ edbg("SEP Driver: sep_lock_user_pages for output virtual buffer failed\n");13171317+ goto end_function_with_error1;13181318+ }12001319 }12011201- }1202132012031203- if (isKernelVirtualAddress == true) {12041204- result = sep_lock_kernel_pages(app_virt_out_addr,12051205- data_size,12061206- &sep_dev->out_num_pages,12071207- &lli_out_array,12081208- &sep_dev->out_page_array);13211321+13221322+ edbg("sep_dev->in_num_pages is %lu\n", sep_dev->in_num_pages);13231323+ edbg("sep_dev->out_num_pages is %lu\n", sep_dev->out_num_pages);13241324+ edbg("SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP is %x\n", SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP);13251325+13261326+13271327+ /* call the fucntion that creates table from the lli arrays */13281328+ 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);12091329 if (result) {12101210- edbg(12111211- "SEP Driver: sep_lock_kernel_pages for output virtual buffer failed\n");12121212- goto end_function_with_error1;13301330+ edbg("SEP Driver: sep_construct_dma_tables_from_lli failed\n");13311331+ goto end_function_with_error2;12131332 }12141214- } else {12151215- result = sep_lock_user_pages(app_virt_out_addr,12161216- data_size,12171217- &sep_dev->out_num_pages,12181218- &lli_out_array,12191219- &sep_dev->out_page_array);12201220- if (result) {12211221- edbg(12221222- "SEP Driver: sep_lock_user_pages for output virtual buffer failed\n");12231223- goto end_function_with_error1;12241224- }12251225- }13331333+13341334+ /* fall through - free the lli entry arrays */13351335+13361336+ dbg("in_num_entries_ptr is %08lx\n", *in_num_entries_ptr);13371337+ dbg("out_num_entries_ptr is %08lx\n", *out_num_entries_ptr);13381338+ dbg("table_data_size_ptr is %08lx\n", *table_data_size_ptr);122613391227134012281228- edbg(12291229- "sep_dev->in_num_pages is %lu\n", sep_dev->in_num_pages);12301230- edbg(12311231- "sep_dev->out_num_pages is %lu\n", sep_dev->out_num_pages);12321232- edbg(12331233- "SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP is %x\n",12341234- SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP);13411341+ end_function_with_error2:1235134213431343+ kfree(lli_out_array);1236134412371237- /* call the fucntion that creates table from the lli arrays */12381238- result = sep_construct_dma_tables_from_lli(lli_in_array,12391239- sep_dev->in_num_pages,12401240- lli_out_array,12411241- sep_dev->out_num_pages,12421242- block_size,12431243- lli_table_in_ptr,12441244- lli_table_out_ptr,12451245- in_num_entries_ptr,12461246- out_num_entries_ptr,12471247- table_data_size_ptr);12481248- if (result) {12491249- edbg(12501250- "SEP Driver: sep_construct_dma_tables_from_lli failed\n");12511251- goto end_function_with_error2;12521252- }13451345+ end_function_with_error1:1253134612541254- /* fall through - free the lli entry arrays */13471347+ kfree(lli_in_array);1255134812561256- dbg("in_num_entries_ptr is %08lx\n",12571257- *in_num_entries_ptr);12581258- dbg("out_num_entries_ptr is %08lx\n",12591259- *out_num_entries_ptr);12601260- dbg("table_data_size_ptr is %08lx\n",12611261- *table_data_size_ptr);13491349+ end_function:1262135013511351+ dbg("SEP Driver:<-------- sep_prepare_input_output_dma_table end result = %d\n", (int) result);1263135212641264-end_function_with_error2:12651265-12661266- kfree(lli_out_array);12671267-12681268-end_function_with_error1:12691269-12701270- kfree(lli_in_array);12711271-12721272-end_function:12731273-12741274- dbg("SEP Driver:<-------- sep_prepare_input_output_dma_table end result = %d\n", (int)result);12751275-12761276- return result;13531353+ return result;1277135412781355}12791356···12391402 This function creates the input and output dma tables for12401403 symmetric operations (AES/DES) according to the block size from LLI arays12411404*/12421242-int sep_construct_dma_tables_from_lli(struct sep_lli_entry_t *lli_in_array,12431243- unsigned long sep_in_lli_entries,12441244- struct sep_lli_entry_t *lli_out_array,12451245- unsigned long sep_out_lli_entries,12461246- unsigned long block_size,12471247- unsigned long *lli_table_in_ptr,12481248- unsigned long *lli_table_out_ptr,12491249- unsigned long *in_num_entries_ptr,12501250- unsigned long *out_num_entries_ptr,12511251- unsigned long *table_data_size_ptr)14051405+int sep_construct_dma_tables_from_lli(struct sep_lli_entry_t *lli_in_array,14061406+ unsigned long sep_in_lli_entries,14071407+ struct sep_lli_entry_t *lli_out_array,14081408+ unsigned long sep_out_lli_entries,14091409+ 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)12521410{12531253- /* points to the area where next lli table can be allocated */12541254- unsigned long lli_table_alloc_addr;14111411+ /* points to the area where next lli table can be allocated */14121412+ unsigned long lli_table_alloc_addr;1255141312561256- /* input lli table */12571257- struct sep_lli_entry_t *in_lli_table_ptr;14141414+ /* input lli table */14151415+ struct sep_lli_entry_t *in_lli_table_ptr;1258141612591259- /* output lli table */12601260- struct sep_lli_entry_t *out_lli_table_ptr;14171417+ /* output lli table */14181418+ struct sep_lli_entry_t *out_lli_table_ptr;1261141912621262- /* pointer to the info entry of the table - the last entry */12631263- struct sep_lli_entry_t *info_in_entry_ptr;14201420+ /* pointer to the info entry of the table - the last entry */14211421+ struct sep_lli_entry_t *info_in_entry_ptr;1264142212651265- /* pointer to the info entry of the table - the last entry */12661266- struct sep_lli_entry_t *info_out_entry_ptr;14231423+ /* pointer to the info entry of the table - the last entry */14241424+ struct sep_lli_entry_t *info_out_entry_ptr;1267142512681268- /* points to the first entry to be processed in the lli_in_array */12691269- unsigned long current_in_entry;14261426+ /* points to the first entry to be processed in the lli_in_array */14271427+ unsigned long current_in_entry;1270142812711271- /* points to the first entry to be processed in the lli_out_array */12721272- unsigned long current_out_entry;14291429+ /* points to the first entry to be processed in the lli_out_array */14301430+ unsigned long current_out_entry;1273143112741274- /* max size of the input table */12751275- unsigned long in_table_data_size;14321432+ /* max size of the input table */14331433+ unsigned long in_table_data_size;1276143412771277- /* max size of the output table */12781278- unsigned long out_table_data_size;14351435+ /* max size of the output table */14361436+ unsigned long out_table_data_size;1279143712801280- /* flag te signifies if this is the first tables build from the arrays */12811281- unsigned long first_table_flag;14381438+ /* flag te signifies if this is the first tables build from the arrays */14391439+ unsigned long first_table_flag;1282144012831283- /* the data size that should be in table */12841284- unsigned long table_data_size;14411441+ /* the data size that should be in table */14421442+ unsigned long table_data_size;1285144312861286- /* number of etnries in the input table */12871287- unsigned long num_entries_in_table;14441444+ /* number of etnries in the input table */14451445+ unsigned long num_entries_in_table;1288144612891289- /* number of etnries in the output table */12901290- unsigned long num_entries_out_table;14471447+ /* number of etnries in the output table */14481448+ unsigned long num_entries_out_table;1291144912921450 /*---------------------12931451 CODE12941452 ------------------------*/1295145312961296- dbg("SEP Driver:--------> sep_construct_dma_tables_from_lli start\n");14541454+ dbg("SEP Driver:--------> sep_construct_dma_tables_from_lli start\n");1297145512981298- /* initiate to pint after the message area */12991299- lli_table_alloc_addr = sep_dev->shared_area_addr +13001300- SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES;14561456+ /* initiate to pint after the message area */14571457+ lli_table_alloc_addr = sep_dev->shared_area_addr + SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES;1301145813021302- current_in_entry = 0;13031303- current_out_entry = 0;13041304- first_table_flag = 1;13051305- info_in_entry_ptr = 0;13061306- info_out_entry_ptr = 0;14591459+ current_in_entry = 0;14601460+ current_out_entry = 0;14611461+ first_table_flag = 1;14621462+ info_in_entry_ptr = 0;14631463+ info_out_entry_ptr = 0;1307146413081308- /* loop till all the entries in in array are not processed */13091309- while (current_in_entry < sep_in_lli_entries) {13101310- /* set the new input and output tables */13111311- in_lli_table_ptr = (struct sep_lli_entry_t *)lli_table_alloc_addr;14651465+ /* loop till all the entries in in array are not processed */14661466+ while (current_in_entry < sep_in_lli_entries) {14671467+ /* set the new input and output tables */14681468+ in_lli_table_ptr = (struct sep_lli_entry_t *) lli_table_alloc_addr;1312146913131313- lli_table_alloc_addr += sizeof(struct sep_lli_entry_t) *13141314- SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP;14701470+ lli_table_alloc_addr += sizeof(struct sep_lli_entry_t) * SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP;1315147113161316- /* set the first output tables */13171317- out_lli_table_ptr = (struct sep_lli_entry_t *)lli_table_alloc_addr;14721472+ /* set the first output tables */14731473+ out_lli_table_ptr = (struct sep_lli_entry_t *) lli_table_alloc_addr;1318147413191319- lli_table_alloc_addr += sizeof(struct sep_lli_entry_t) *13201320- SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP;14751475+ lli_table_alloc_addr += sizeof(struct sep_lli_entry_t) * SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP;1321147613221322- /* calculate the maximum size of data for input table */13231323- in_table_data_size =13241324- sep_calculate_lli_table_max_size(13251325- &lli_in_array[current_in_entry],13261326- (sep_in_lli_entries - current_in_entry));14771477+ /* calculate the maximum size of data for input table */14781478+ in_table_data_size = sep_calculate_lli_table_max_size(&lli_in_array[current_in_entry], (sep_in_lli_entries - current_in_entry));1327147913281328- /* calculate the maximum size of data for output table */13291329- out_table_data_size =13301330- sep_calculate_lli_table_max_size(13311331- &lli_out_array[current_out_entry],13321332- (sep_out_lli_entries - current_out_entry));14801480+ /* calculate the maximum size of data for output table */14811481+ out_table_data_size = sep_calculate_lli_table_max_size(&lli_out_array[current_out_entry], (sep_out_lli_entries - current_out_entry));1333148213341334- edbg(13351335- "SEP Driver:in_table_data_size is %lu\n", in_table_data_size);13361336- edbg(13371337- "SEP Driver:out_table_data_size is %lu\n", out_table_data_size);14831483+ edbg("SEP Driver:in_table_data_size is %lu\n", in_table_data_size);14841484+ edbg("SEP Driver:out_table_data_size is %lu\n", out_table_data_size);1338148513391339- /* check where the data is smallest */13401340- table_data_size = in_table_data_size;13411341- if (table_data_size > out_table_data_size)13421342- table_data_size = out_table_data_size;14861486+ /* check where the data is smallest */14871487+ table_data_size = in_table_data_size;14881488+ if (table_data_size > out_table_data_size)14891489+ table_data_size = out_table_data_size;1343149013441344- /* now calculate the table size so that it will be module block size */13451345- table_data_size = (table_data_size / block_size) * block_size;14911491+ /* now calculate the table size so that it will be module block size */14921492+ table_data_size = (table_data_size / block_size) * block_size;1346149313471347- dbg("SEP Driver:table_data_size is %lu\n", table_data_size);14941494+ dbg("SEP Driver:table_data_size is %lu\n", table_data_size);1348149513491349- /* construct input lli table */13501350- sep_build_lli_table(&lli_in_array[current_in_entry],13511351- in_lli_table_ptr,13521352- ¤t_in_entry,13531353- &num_entries_in_table,13541354- table_data_size);14961496+ /* construct input lli table */14971497+ sep_build_lli_table(&lli_in_array[current_in_entry], in_lli_table_ptr, ¤t_in_entry, &num_entries_in_table, table_data_size);1355149813561356- /* construct output lli table */13571357- sep_build_lli_table(&lli_out_array[current_out_entry],13581358- out_lli_table_ptr,13591359- ¤t_out_entry,13601360- &num_entries_out_table,13611361- table_data_size);14991499+ /* construct output lli table */15001500+ sep_build_lli_table(&lli_out_array[current_out_entry], out_lli_table_ptr, ¤t_out_entry, &num_entries_out_table, table_data_size);1362150113631363- /* if info entry is null - this is the first table built */13641364- if (info_in_entry_ptr == 0) {13651365- /* set the output parameters to physical addresses */13661366- *lli_table_in_ptr =13671367- sep_shared_area_virt_to_phys((unsigned long)in_lli_table_ptr);13681368- *in_num_entries_ptr = num_entries_in_table;13691369- *lli_table_out_ptr =13701370- sep_shared_area_virt_to_phys((unsigned long)out_lli_table_ptr);13711371- *out_num_entries_ptr = num_entries_out_table;13721372- *table_data_size_ptr = table_data_size;15021502+ /* if info entry is null - this is the first table built */15031503+ if (info_in_entry_ptr == 0) {15041504+ /* set the output parameters to physical addresses */15051505+ *lli_table_in_ptr = sep_shared_area_virt_to_phys((unsigned long) in_lli_table_ptr);15061506+ *in_num_entries_ptr = num_entries_in_table;15071507+ *lli_table_out_ptr = sep_shared_area_virt_to_phys((unsigned long) out_lli_table_ptr);15081508+ *out_num_entries_ptr = num_entries_out_table;15091509+ *table_data_size_ptr = table_data_size;1373151013741374- edbg(13751375- "SEP Driver:output lli_table_in_ptr is %08lx\n", *lli_table_in_ptr);13761376- edbg(13771377- "SEP Driver:output lli_table_out_ptr is %08lx\n", *lli_table_out_ptr);13781378- } else {13791379- /* update the info entry of the previous in table */13801380- info_in_entry_ptr->physical_address =13811381- sep_shared_area_virt_to_phys((unsigned long)in_lli_table_ptr);13821382- info_in_entry_ptr->block_size =13831383- ((num_entries_in_table) << 24) | (table_data_size);15111511+ edbg("SEP Driver:output lli_table_in_ptr is %08lx\n", *lli_table_in_ptr);15121512+ edbg("SEP Driver:output lli_table_out_ptr is %08lx\n", *lli_table_out_ptr);15131513+ } else {15141514+ /* update the info entry of the previous in table */15151515+ info_in_entry_ptr->physical_address = sep_shared_area_virt_to_phys((unsigned long) in_lli_table_ptr);15161516+ info_in_entry_ptr->block_size = ((num_entries_in_table) << 24) | (table_data_size);1384151713851385- /* update the info entry of the previous in table */13861386- info_out_entry_ptr->physical_address =13871387- sep_shared_area_virt_to_phys((unsigned long)out_lli_table_ptr);13881388- info_out_entry_ptr->block_size =13891389- ((num_entries_out_table) << 24) | (table_data_size);15181518+ /* update the info entry of the previous in table */15191519+ info_out_entry_ptr->physical_address = sep_shared_area_virt_to_phys((unsigned long) out_lli_table_ptr);15201520+ info_out_entry_ptr->block_size = ((num_entries_out_table) << 24) | (table_data_size);15211521+ }15221522+15231523+ /* save the pointer to the info entry of the current tables */15241524+ info_in_entry_ptr = in_lli_table_ptr + num_entries_in_table - 1;15251525+ info_out_entry_ptr = out_lli_table_ptr + num_entries_out_table - 1;15261526+15271527+ edbg("SEP Driver:output num_entries_out_table is %lu\n", (unsigned long) num_entries_out_table);15281528+ edbg("SEP Driver:output info_in_entry_ptr is %lu\n", (unsigned long) info_in_entry_ptr);15291529+ edbg("SEP Driver:output info_out_entry_ptr is %lu\n", (unsigned long) info_out_entry_ptr);13901530 }1391153113921392- /* save the pointer to the info entry of the current tables */13931393- info_in_entry_ptr = in_lli_table_ptr + num_entries_in_table - 1;13941394- info_out_entry_ptr = out_lli_table_ptr + num_entries_out_table - 1;15321532+ /* print input tables */15331533+ sep_debug_print_lli_tables((struct sep_lli_entry_t *)15341534+ sep_shared_area_phys_to_virt(*lli_table_in_ptr), *in_num_entries_ptr, *table_data_size_ptr);1395153513961396- edbg(13971397- "SEP Driver:output num_entries_out_table is %lu\n",13981398- (unsigned long)num_entries_out_table);13991399- edbg(14001400- "SEP Driver:output info_in_entry_ptr is %lu\n",14011401- (unsigned long)info_in_entry_ptr);14021402- edbg(14031403- "SEP Driver:output info_out_entry_ptr is %lu\n",14041404- (unsigned long)info_out_entry_ptr);14051405- }15361536+ /* print output tables */15371537+ sep_debug_print_lli_tables((struct sep_lli_entry_t *)15381538+ sep_shared_area_phys_to_virt(*lli_table_out_ptr), *out_num_entries_ptr, *table_data_size_ptr);1406153914071407- /* print input tables */14081408- sep_debug_print_lli_tables(14091409- (struct sep_lli_entry_t *)14101410- sep_shared_area_phys_to_virt(*lli_table_in_ptr),14111411- *in_num_entries_ptr,14121412- *table_data_size_ptr);15401540+ dbg("SEP Driver:<-------- sep_construct_dma_tables_from_lli end\n");1413154114141414- /* print output tables */14151415- sep_debug_print_lli_tables(14161416- (struct sep_lli_entry_t *)14171417- sep_shared_area_phys_to_virt(*lli_table_out_ptr),14181418- *out_num_entries_ptr,14191419- *table_data_size_ptr);14201420-14211421- dbg("SEP Driver:<-------- sep_construct_dma_tables_from_lli end\n");14221422-14231423- return 0;15421542+ return 0;14241543}1425154414261545/*···13841591 table from this array the condition is that either the table is full13851592 (all etnries are entered), or there are no more entries in the lli array13861593*/13871387-unsigned long sep_calculate_lli_table_max_size(13881388- struct sep_lli_entry_t *lli_in_array_ptr,13891389- unsigned long num_array_entries)15941594+unsigned long sep_calculate_lli_table_max_size(struct sep_lli_entry_t *lli_in_array_ptr, unsigned long num_array_entries)13901595{13911391- /* table data size */13921392- unsigned long table_data_size;15961596+ /* table data size */15971597+ unsigned long table_data_size;1393159813941394- /* counter */13951395- unsigned long counter;15991599+ /* counter */16001600+ unsigned long counter;1396160113971602 /*---------------------13981603 CODE13991604 ----------------------*/1400160514011401- table_data_size = 0;16061606+ table_data_size = 0;1402160714031403- /* calculate the data in the out lli table if till we fill the whole14041404- table or till the data has ended */14051405- for (counter = 0;14061406- (counter < (SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP - 1)) &&14071407- (counter < num_array_entries); counter++)14081408- table_data_size += lli_in_array_ptr[counter].block_size;16081608+ /* calculate the data in the out lli table if till we fill the whole16091609+ table or till the data has ended */16101610+ for (counter = 0; (counter < (SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP - 1)) && (counter < num_array_entries); counter++)16111611+ table_data_size += lli_in_array_ptr[counter].block_size;1409161214101410- return table_data_size;16131613+ return table_data_size;14111614}1412161514131616/*14141617 this functions builds ont lli table from the lli_array according to14151618 the given size of data14161619*/14171417-static void sep_build_lli_table(struct sep_lli_entry_t *lli_array_ptr,14181418- struct sep_lli_entry_t *lli_table_ptr,14191419- unsigned long *num_processed_entries_ptr,14201420- unsigned long *num_table_entries_ptr,14211421- unsigned long table_data_size)16201620+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)14221621{14231423- /* current table data size */14241424- unsigned long curr_table_data_size;16221622+ /* current table data size */16231623+ unsigned long curr_table_data_size;1425162414261426- /* counter of lli array entry */14271427- unsigned long array_counter;16251625+ /* counter of lli array entry */16261626+ unsigned long array_counter;1428162714291628 /*-----------------------14301629 CODE14311630 ---------------------------*/1432163114331433- dbg("SEP Driver:--------> sep_build_lli_table start\n");16321632+ dbg("SEP Driver:--------> sep_build_lli_table start\n");1434163314351435- /* init currrent table data size and lli array entry counter */14361436- curr_table_data_size = 0;14371437- array_counter = 0;14381438- *num_table_entries_ptr = 1;16341634+ /* init currrent table data size and lli array entry counter */16351635+ curr_table_data_size = 0;16361636+ array_counter = 0;16371637+ *num_table_entries_ptr = 1;1439163814401440- edbg(14411441- "SEP Driver:table_data_size is %lu\n",14421442- table_data_size);16391639+ edbg("SEP Driver:table_data_size is %lu\n", table_data_size);1443164014441444- /* fill the table till table size reaches the needed amount */14451445- while (curr_table_data_size < table_data_size) {14461446- /* update the number of entries in table */14471447- (*num_table_entries_ptr)++;16411641+ /* fill the table till table size reaches the needed amount */16421642+ while (curr_table_data_size < table_data_size) {16431643+ /* update the number of entries in table */16441644+ (*num_table_entries_ptr)++;1448164514491449- lli_table_ptr->physical_address =14501450- lli_array_ptr[array_counter].physical_address;14511451- lli_table_ptr->block_size = lli_array_ptr[array_counter].block_size;14521452- curr_table_data_size += lli_table_ptr->block_size;16461646+ lli_table_ptr->physical_address = lli_array_ptr[array_counter].physical_address;16471647+ lli_table_ptr->block_size = lli_array_ptr[array_counter].block_size;16481648+ curr_table_data_size += lli_table_ptr->block_size;1453164914541454- edbg(14551455- "SEP Driver:lli_table_ptr is %08lx\n",14561456- (unsigned long)lli_table_ptr);14571457- edbg(14581458- "SEP Driver:lli_table_ptr->physical_address is %08lx\n",14591459- lli_table_ptr->physical_address);14601460- edbg(14611461- "SEP Driver:lli_table_ptr->block_size is %lu\n",14621462- lli_table_ptr->block_size);16501650+ edbg("SEP Driver:lli_table_ptr is %08lx\n", (unsigned long) lli_table_ptr);16511651+ edbg("SEP Driver:lli_table_ptr->physical_address is %08lx\n", lli_table_ptr->physical_address);16521652+ edbg("SEP Driver:lli_table_ptr->block_size is %lu\n", lli_table_ptr->block_size);1463165314641464- /* check for overflow of the table data */14651465- if (curr_table_data_size > table_data_size) {14661466- edbg(14671467- "SEP Driver:curr_table_data_size > table_data_size\n");16541654+ /* check for overflow of the table data */16551655+ if (curr_table_data_size > table_data_size) {16561656+ edbg("SEP Driver:curr_table_data_size > table_data_size\n");1468165714691469- /* update the size of block in the table */14701470- lli_table_ptr->block_size -= (curr_table_data_size - table_data_size);16581658+ /* update the size of block in the table */16591659+ lli_table_ptr->block_size -= (curr_table_data_size - table_data_size);1471166014721472- /* update the physical address in the lli array */14731473- lli_array_ptr[array_counter].physical_address +=14741474- lli_table_ptr->block_size;16611661+ /* update the physical address in the lli array */16621662+ lli_array_ptr[array_counter].physical_address += lli_table_ptr->block_size;1475166314761476- /* update the block size left in the lli array */14771477- lli_array_ptr[array_counter].block_size =14781478- (curr_table_data_size - table_data_size);14791479- } else14801480- /* advance to the next entry in the lli_array */14811481- array_counter++;16641664+ /* update the block size left in the lli array */16651665+ lli_array_ptr[array_counter].block_size = (curr_table_data_size - table_data_size);16661666+ } else16671667+ /* advance to the next entry in the lli_array */16681668+ array_counter++;1482166914831483- edbg(14841484- "SEP Driver:lli_table_ptr->physical_address is %08lx\n",14851485- lli_table_ptr->physical_address);14861486- edbg(14871487- "SEP Driver:lli_table_ptr->block_size is %lu\n",14881488- lli_table_ptr->block_size);16701670+ edbg("SEP Driver:lli_table_ptr->physical_address is %08lx\n", lli_table_ptr->physical_address);16711671+ edbg("SEP Driver:lli_table_ptr->block_size is %lu\n", lli_table_ptr->block_size);1489167214901490- /* move to the next entry in table */14911491- lli_table_ptr++;14921492- }16731673+ /* move to the next entry in table */16741674+ lli_table_ptr++;16751675+ }1493167614941494- /* set the info entry to default */14951495- lli_table_ptr->physical_address = 0xffffffff;14961496- lli_table_ptr->block_size = 0;16771677+ /* set the info entry to default */16781678+ lli_table_ptr->physical_address = 0xffffffff;16791679+ lli_table_ptr->block_size = 0;1497168014981498- edbg(14991499- "SEP Driver:lli_table_ptr is %08lx\n",15001500- (unsigned long)lli_table_ptr);15011501- edbg(15021502- "SEP Driver:lli_table_ptr->physical_address is %08lx\n",15031503- lli_table_ptr->physical_address);15041504- edbg(15051505- "SEP Driver:lli_table_ptr->block_size is %lu\n",15061506- lli_table_ptr->block_size);16811681+ edbg("SEP Driver:lli_table_ptr is %08lx\n", (unsigned long) lli_table_ptr);16821682+ edbg("SEP Driver:lli_table_ptr->physical_address is %08lx\n", lli_table_ptr->physical_address);16831683+ edbg("SEP Driver:lli_table_ptr->block_size is %lu\n", lli_table_ptr->block_size);150716841508168515091509- /* set the output parameter */15101510- *num_processed_entries_ptr += array_counter;16861686+ /* set the output parameter */16871687+ *num_processed_entries_ptr += array_counter;1511168815121512- edbg(15131513- "SEP Driver:*num_processed_entries_ptr is %lu\n",15141514- *num_processed_entries_ptr);16891689+ edbg("SEP Driver:*num_processed_entries_ptr is %lu\n", *num_processed_entries_ptr);151516901516169115171517- dbg("SEP Driver:<-------- sep_build_lli_table end\n");16921692+ dbg("SEP Driver:<-------- sep_build_lli_table end\n");1518169315191519- return;16941694+ return;15201695}1521169615221697/*15231698 this function goes over the list of the print created tables and15241699 prints all the data15251700*/15261526-static void sep_debug_print_lli_tables(struct sep_lli_entry_t *lli_table_ptr,15271527- unsigned long num_table_entries,15281528- unsigned long table_data_size)17011701+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)15291702{15301530- unsigned long table_count;17031703+ unsigned long table_count;1531170415321532- unsigned long entries_count;17051705+ unsigned long entries_count;15331706 /*-----------------------------15341707 CODE15351708 -------------------------------*/1536170915371537- dbg("SEP Driver:--------> sep_debug_print_lli_tables start\n");17101710+ dbg("SEP Driver:--------> sep_debug_print_lli_tables start\n");1538171115391539- table_count = 1;15401540- while ((unsigned long)lli_table_ptr != 0xffffffff) {15411541- edbg("SEP Driver: lli table %08lx, table_data_size is %lu\n",15421542- table_count, table_data_size);15431543- edbg("SEP Driver: num_table_entries is %lu\n", num_table_entries);17121712+ table_count = 1;17131713+ while ((unsigned long) lli_table_ptr != 0xffffffff) {17141714+ edbg("SEP Driver: lli table %08lx, table_data_size is %lu\n", table_count, table_data_size);17151715+ edbg("SEP Driver: num_table_entries is %lu\n", num_table_entries);1544171615451545- /* print entries of the table (without info entry) */15461546- for (entries_count = 0;15471547- entries_count < num_table_entries;15481548- entries_count++, lli_table_ptr++) {15491549- edbg("SEP Driver:lli_table_ptr address is %08lx\n",15501550- (unsigned long)lli_table_ptr);15511551- edbg("SEP Driver:phys address is %08lx block size is %lu\n",15521552- lli_table_ptr->physical_address, lli_table_ptr->block_size);17171717+ /* print entries of the table (without info entry) */17181718+ for (entries_count = 0; entries_count < num_table_entries; entries_count++, lli_table_ptr++) {17191719+ edbg("SEP Driver:lli_table_ptr address is %08lx\n", (unsigned long) lli_table_ptr);17201720+ edbg("SEP Driver:phys address is %08lx block size is %lu\n", lli_table_ptr->physical_address, lli_table_ptr->block_size);17211721+ }17221722+17231723+ /* point to the info entry */17241724+ lli_table_ptr--;17251725+17261726+ edbg("SEP Driver:phys lli_table_ptr->block_size is %lu\n", lli_table_ptr->block_size);17271727+ edbg("SEP Driver:phys lli_table_ptr->physical_address is %08lx\n", lli_table_ptr->physical_address);17281728+17291729+17301730+ table_data_size = lli_table_ptr->block_size & 0xffffff;17311731+ num_table_entries = (lli_table_ptr->block_size >> 24) & 0xff;17321732+ lli_table_ptr = (struct sep_lli_entry_t *)17331733+ (lli_table_ptr->physical_address);17341734+17351735+ 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);17361736+17371737+ if ((unsigned long) lli_table_ptr != 0xffffffff)17381738+ lli_table_ptr = (struct sep_lli_entry_t *) sep_shared_area_phys_to_virt((unsigned long) lli_table_ptr);17391739+17401740+ table_count++;15531741 }1554174215551555- /* point to the info entry */15561556- lli_table_ptr--;15571557-15581558- edbg(15591559- "SEP Driver:phys lli_table_ptr->block_size is %lu\n",15601560- lli_table_ptr->block_size);15611561- edbg(15621562- "SEP Driver:phys lli_table_ptr->physical_address is %08lx\n",15631563- lli_table_ptr->physical_address);15641564-15651565-15661566- table_data_size = lli_table_ptr->block_size & 0xffffff;15671567- num_table_entries = (lli_table_ptr->block_size >> 24) & 0xff;15681568- lli_table_ptr = (struct sep_lli_entry_t *)15691569- (lli_table_ptr->physical_address);15701570-15711571- edbg("SEP Driver:phys table_data_size is %lu num_table_entries is %lu lli_table_ptr is%lu\n",15721572- table_data_size, num_table_entries, (unsigned long)lli_table_ptr);15731573-15741574- if ((unsigned long)lli_table_ptr != 0xffffffff)15751575- lli_table_ptr = (struct sep_lli_entry_t *)sep_shared_area_phys_to_virt(15761576- (unsigned long)lli_table_ptr);15771577-15781578- table_count++;15791579- }15801580-15811581- dbg("SEP Driver:<-------- sep_debug_print_lli_tables end\n");17431743+ dbg("SEP Driver:<-------- sep_debug_print_lli_tables end\n");15821744}1583174515841746···15421794 and construct a basic lli array, where each entry holds the physical page15431795 address and the size that application data holds in this physical pages15441796*/15451545-int sep_lock_user_pages(unsigned long app_virt_addr,15461546- unsigned long data_size,15471547- unsigned long *num_pages_ptr,15481548- struct sep_lli_entry_t **lli_array_ptr,15491549- struct page ***page_array_ptr)15501550-17971797+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)15511798{15521552- /* error */15531553- int error;17991799+ /* error */18001800+ int error;1554180115551555- /* the the page of the end address of the user space buffer */15561556- unsigned long end_page;18021802+ /* the the page of the end address of the user space buffer */18031803+ unsigned long end_page;1557180415581558- /* the page of the start address of the user space buffer */15591559- unsigned long start_page;18051805+ /* the page of the start address of the user space buffer */18061806+ unsigned long start_page;1560180715611561- /* the range in pages */15621562- unsigned long num_pages;18081808+ /* the range in pages */18091809+ unsigned long num_pages;1563181015641564- /* array of pointers ot page */15651565- struct page **page_array;18111811+ /* array of pointers ot page */18121812+ struct page **page_array;1566181315671567- /* array of lli */15681568- struct sep_lli_entry_t *lli_array;18141814+ /* array of lli */18151815+ struct sep_lli_entry_t *lli_array;1569181615701570- /* count */15711571- unsigned long count;18171817+ /* count */18181818+ unsigned long count;1572181915731573- /* result */15741574- int result;18201820+ /* result */18211821+ int result;1575182215761823 /*------------------------15771824 CODE15781825 --------------------------*/1579182615801580- dbg("SEP Driver:--------> sep_lock_user_pages start\n");18271827+ dbg("SEP Driver:--------> sep_lock_user_pages start\n");1581182815821582- error = 0;18291829+ error = 0;1583183015841584- /* set start and end pages and num pages */15851585- end_page = (app_virt_addr + data_size - 1) >> PAGE_SHIFT;15861586- start_page = app_virt_addr >> PAGE_SHIFT;15871587- num_pages = end_page - start_page + 1;18311831+ /* set start and end pages and num pages */18321832+ end_page = (app_virt_addr + data_size - 1) >> PAGE_SHIFT;18331833+ start_page = app_virt_addr >> PAGE_SHIFT;18341834+ num_pages = end_page - start_page + 1;1588183515891589- edbg(15901590- "SEP Driver: app_virt_addr is %08lx\n",15911591- app_virt_addr);15921592- edbg(15931593- "SEP Driver: data_size is %lu\n",15941594- data_size);15951595- edbg(15961596- "SEP Driver: start_page is %lu\n",15971597- start_page);15981598- edbg(15991599- "SEP Driver: end_page is %lu\n",16001600- end_page);16011601- edbg(16021602- "SEP Driver: num_pages is %lu\n",16031603- num_pages);18361836+ edbg("SEP Driver: app_virt_addr is %08lx\n", app_virt_addr);18371837+ edbg("SEP Driver: data_size is %lu\n", data_size);18381838+ edbg("SEP Driver: start_page is %lu\n", start_page);18391839+ edbg("SEP Driver: end_page is %lu\n", end_page);18401840+ edbg("SEP Driver: num_pages is %lu\n", num_pages);1604184116051605- /* allocate array of pages structure pointers */16061606- page_array = kmalloc(sizeof(struct page *) * num_pages, GFP_ATOMIC);16071607- if (!page_array) {16081608- edbg(16091609- "SEP Driver: kmalloc for page_array failed\n");18421842+ /* allocate array of pages structure pointers */18431843+ page_array = kmalloc(sizeof(struct page *) * num_pages, GFP_ATOMIC);18441844+ if (!page_array) {18451845+ edbg("SEP Driver: kmalloc for page_array failed\n");1610184616111611- error = -ENOMEM;16121612- goto end_function;16131613- }16141614-16151615- lli_array = kmalloc(sizeof(struct sep_lli_entry_t) * num_pages, GFP_ATOMIC);16161616- if (!lli_array) {16171617- edbg(16181618- "SEP Driver: kmalloc for lli_array failed\n");16191619-16201620- error = -ENOMEM;16211621- goto end_function_with_error1;16221622- }16231623-16241624- /* convert the application virtual address into a set of physical */16251625- down_read(¤t->mm->mmap_sem);16261626- result = get_user_pages(current, current->mm, app_virt_addr, num_pages, 1, 0,16271627- page_array,16281628- 0);16291629- up_read(¤t->mm->mmap_sem);16301630-16311631- /* check the number of pages locked - if not all then exit with error */16321632- if (result != num_pages) {16331633- dbg("SEP Driver: not all pages locked by get_user_pages\n");16341634-16351635- error = -ENOMEM;16361636- goto end_function_with_error2;16371637- }16381638-16391639- /* flush the cache */16401640- for (count = 0; count < num_pages; count++)16411641- flush_dcache_page(page_array[count]);16421642-16431643- /* set the start address of the first page - app data may start not at16441644- the beginning of the page */16451645- lli_array[0].physical_address = (16461646- (unsigned long)page_to_phys(page_array[0])) +16471647- (app_virt_addr & (~PAGE_MASK)) ;16481648-16491649- /* check that not all the data is in the first page only */16501650- if ((PAGE_SIZE - (app_virt_addr & (~PAGE_MASK))) >= data_size)16511651- lli_array[0].block_size = data_size;16521652- else16531653- lli_array[0].block_size = PAGE_SIZE - (app_virt_addr & (~PAGE_MASK));16541654-16551655- /* debug print */16561656- dbg("lli_array[0].physical_address is %08lx, lli_array[0].block_size is %lu\n",16571657- lli_array[0].physical_address,16581658- lli_array[0].block_size);16591659-16601660- /* go from the second page to the prev before last */16611661- for (count = 1; count < (num_pages - 1); count++) {16621662- lli_array[count].physical_address =16631663- (unsigned long)page_to_phys(page_array[count]);16641664- lli_array[count].block_size = PAGE_SIZE;16651665-16661666- edbg(16671667- "lli_array[%lu].physical_address is %08lx, \16681668- lli_array[%lu].block_size is %lu\n",16691669- count, lli_array[count].physical_address,16701670- count,16711671- lli_array[count].block_size);16721672- }16731673-16741674- /* if more then 1 pages locked - then update for the last page size needed */16751675- if (num_pages > 1) {16761676- /* update the address of the last page */16771677- lli_array[count].physical_address =16781678- (unsigned long)page_to_phys(page_array[count]);16791679-16801680- /* set the size of the last page */16811681- lli_array[count].block_size = (app_virt_addr + data_size) &16821682- (~PAGE_MASK);16831683-16841684- if (lli_array[count].block_size == 0) {16851685- dbg("app_virt_addr is %08lx\n", app_virt_addr);16861686- dbg("data_size is %lu\n", data_size);16871687- while (1);18471847+ error = -ENOMEM;18481848+ goto end_function;16881849 }16891689- edbg(16901690- "lli_array[%lu].physical_address is %08lx, \16911691- lli_array[%lu].block_size is %lu\n",16921692- count, lli_array[count].physical_address,16931693- count,16941694- lli_array[count].block_size);16951695- }1696185016971697- /* set output params */16981698- *lli_array_ptr = lli_array;16991699- *num_pages_ptr = num_pages;17001700- *page_array_ptr = page_array;18511851+ lli_array = kmalloc(sizeof(struct sep_lli_entry_t) * num_pages, GFP_ATOMIC);18521852+ if (!lli_array) {18531853+ edbg("SEP Driver: kmalloc for lli_array failed\n");1701185417021702- goto end_function;18551855+ error = -ENOMEM;18561856+ goto end_function_with_error1;18571857+ }1703185817041704-end_function_with_error2:18591859+ /* convert the application virtual address into a set of physical */18601860+ down_read(¤t->mm->mmap_sem);18611861+ result = get_user_pages(current, current->mm, app_virt_addr, num_pages, 1, 0, page_array, 0);18621862+ up_read(¤t->mm->mmap_sem);1705186317061706- /* release the cache */17071707- for (count = 0; count < num_pages; count++)17081708- page_cache_release(page_array[count]);18641864+ /* check the number of pages locked - if not all then exit with error */18651865+ if (result != num_pages) {18661866+ dbg("SEP Driver: not all pages locked by get_user_pages\n");1709186717101710- /* free lli array */17111711- kfree(lli_array);18681868+ error = -ENOMEM;18691869+ goto end_function_with_error2;18701870+ }1712187117131713-end_function_with_error1:18721872+ /* flush the cache */18731873+ for (count = 0; count < num_pages; count++)18741874+ flush_dcache_page(page_array[count]);1714187517151715- /* free page array */17161716- kfree(page_array);18761876+ /* set the start address of the first page - app data may start not at18771877+ the beginning of the page */18781878+ lli_array[0].physical_address = ((unsigned long) page_to_phys(page_array[0])) + (app_virt_addr & (~PAGE_MASK));1717187917181718-end_function:18801880+ /* check that not all the data is in the first page only */18811881+ if ((PAGE_SIZE - (app_virt_addr & (~PAGE_MASK))) >= data_size)18821882+ lli_array[0].block_size = data_size;18831883+ else18841884+ lli_array[0].block_size = PAGE_SIZE - (app_virt_addr & (~PAGE_MASK));1719188517201720- dbg("SEP Driver:<-------- sep_lock_user_pages end\n");18861886+ /* debug print */18871887+ 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);1721188817221722- return 0;18891889+ /* go from the second page to the prev before last */18901890+ for (count = 1; count < (num_pages - 1); count++) {18911891+ lli_array[count].physical_address = (unsigned long) page_to_phys(page_array[count]);18921892+ lli_array[count].block_size = PAGE_SIZE;18931893+18941894+ edbg("lli_array[%lu].physical_address is %08lx, \18951895+ lli_array[%lu].block_size is %lu\n", count, lli_array[count].physical_address, count, lli_array[count].block_size);18961896+ }18971897+18981898+ /* if more then 1 pages locked - then update for the last page size needed */18991899+ if (num_pages > 1) {19001900+ /* update the address of the last page */19011901+ lli_array[count].physical_address = (unsigned long) page_to_phys(page_array[count]);19021902+19031903+ /* set the size of the last page */19041904+ lli_array[count].block_size = (app_virt_addr + data_size) & (~PAGE_MASK);19051905+19061906+ if (lli_array[count].block_size == 0) {19071907+ dbg("app_virt_addr is %08lx\n", app_virt_addr);19081908+ dbg("data_size is %lu\n", data_size);19091909+ while (1);19101910+ }19111911+ edbg("lli_array[%lu].physical_address is %08lx, \19121912+ lli_array[%lu].block_size is %lu\n", count, lli_array[count].physical_address, count, lli_array[count].block_size);19131913+ }19141914+19151915+ /* set output params */19161916+ *lli_array_ptr = lli_array;19171917+ *num_pages_ptr = num_pages;19181918+ *page_array_ptr = page_array;19191919+19201920+ goto end_function;19211921+19221922+ end_function_with_error2:19231923+19241924+ /* release the cache */19251925+ for (count = 0; count < num_pages; count++)19261926+ page_cache_release(page_array[count]);19271927+19281928+ /* free lli array */19291929+ kfree(lli_array);19301930+19311931+ end_function_with_error1:19321932+19331933+ /* free page array */19341934+ kfree(page_array);19351935+19361936+ end_function:19371937+19381938+ dbg("SEP Driver:<-------- sep_lock_user_pages end\n");19391939+19401940+ return 0;17231941}1724194217251943/*···16931979 and construct a basic lli array, where each entry holds the physical16941980 page address and the size that application data holds in this physical pages16951981*/16961696-int sep_lock_kernel_pages(unsigned long kernel_virt_addr,16971697- unsigned long data_size,16981698- unsigned long *num_pages_ptr,16991699- struct sep_lli_entry_t **lli_array_ptr,17001700- struct page ***page_array_ptr)17011701-19821982+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)17021983{17031703- /* error */17041704- int error;19841984+ /* error */19851985+ int error;1705198617061706- /* the the page of the end address of the user space buffer */17071707- unsigned long end_page;19871987+ /* the the page of the end address of the user space buffer */19881988+ unsigned long end_page;1708198917091709- /* the page of the start address of the user space buffer */17101710- unsigned long start_page;19901990+ /* the page of the start address of the user space buffer */19911991+ unsigned long start_page;1711199217121712- /* the range in pages */17131713- unsigned long num_pages;19931993+ /* the range in pages */19941994+ unsigned long num_pages;1714199517151715- /* array of lli */17161716- struct sep_lli_entry_t *lli_array;19961996+ /* array of lli */19971997+ struct sep_lli_entry_t *lli_array;1717199817181718- /* next kernel address to map */17191719- unsigned long next_kernel_address;19991999+ /* next kernel address to map */20002000+ unsigned long next_kernel_address;1720200117211721- /* count */17221722- unsigned long count;20022002+ /* count */20032003+ unsigned long count;172320041724200517252006 /*------------------------17262007 CODE17272008 --------------------------*/1728200917291729- dbg("SEP Driver:--------> sep_lock_kernel_pages start\n");20102010+ dbg("SEP Driver:--------> sep_lock_kernel_pages start\n");1730201117311731- error = 0;20122012+ error = 0;1732201317331733- /* set start and end pages and num pages */17341734- end_page = (kernel_virt_addr + data_size - 1) >> PAGE_SHIFT;17351735- start_page = kernel_virt_addr >> PAGE_SHIFT;17361736- num_pages = end_page - start_page + 1;20142014+ /* set start and end pages and num pages */20152015+ end_page = (kernel_virt_addr + data_size - 1) >> PAGE_SHIFT;20162016+ start_page = kernel_virt_addr >> PAGE_SHIFT;20172017+ num_pages = end_page - start_page + 1;1737201817381738- edbg(17391739- "SEP Driver: kernel_virt_addr is %08lx\n",17401740- kernel_virt_addr);17411741- edbg(17421742- "SEP Driver: data_size is %lu\n",17431743- data_size);17441744- edbg(17451745- "SEP Driver: start_page is %lx\n",17461746- start_page);17471747- edbg(17481748- "SEP Driver: end_page is %lx\n",17491749- end_page);17501750- edbg(17511751- "SEP Driver: num_pages is %lu\n",17521752- num_pages);20192019+ edbg("SEP Driver: kernel_virt_addr is %08lx\n", kernel_virt_addr);20202020+ edbg("SEP Driver: data_size is %lu\n", data_size);20212021+ edbg("SEP Driver: start_page is %lx\n", start_page);20222022+ edbg("SEP Driver: end_page is %lx\n", end_page);20232023+ edbg("SEP Driver: num_pages is %lu\n", num_pages);1753202417541754- lli_array = kmalloc(sizeof(struct sep_lli_entry_t) * num_pages, GFP_ATOMIC);17551755- if (!lli_array) {17561756- edbg(17571757- "SEP Driver: kmalloc for lli_array failed\n");20252025+ lli_array = kmalloc(sizeof(struct sep_lli_entry_t) * num_pages, GFP_ATOMIC);20262026+ if (!lli_array) {20272027+ edbg("SEP Driver: kmalloc for lli_array failed\n");1758202817591759- error = -ENOMEM;17601760- goto end_function;17611761- }17621762-17631763- /* set the start address of the first page - app data may start not at17641764- the beginning of the page */17651765- lli_array[0].physical_address =17661766- (unsigned long)virt_to_phys((unsigned long *)kernel_virt_addr);17671767-17681768- /* check that not all the data is in the first page only */17691769- if ((PAGE_SIZE - (kernel_virt_addr & (~PAGE_MASK))) >= data_size)17701770- lli_array[0].block_size = data_size;17711771- else17721772- lli_array[0].block_size =17731773- PAGE_SIZE - (kernel_virt_addr & (~PAGE_MASK));17741774-17751775- /* debug print */17761776- dbg("lli_array[0].physical_address is %08lx, lli_array[0].block_size is %lu\n",17771777- lli_array[0].physical_address,17781778- lli_array[0].block_size);17791779-17801780- /* advance the address to the start of the next page */17811781- next_kernel_address = (kernel_virt_addr & PAGE_MASK) + PAGE_SIZE;17821782-17831783- /* go from the second page to the prev before last */17841784- for (count = 1; count < (num_pages - 1); count++) {17851785- lli_array[count].physical_address =17861786- (unsigned long)virt_to_phys((unsigned long *)next_kernel_address);17871787- lli_array[count].block_size = PAGE_SIZE;17881788-17891789- edbg(17901790- "lli_array[%lu].physical_address is %08lx, \17911791- lli_array[%lu].block_size is %lu\n",17921792- count, lli_array[count].physical_address, count,17931793- lli_array[count].block_size);17941794-17951795- next_kernel_address += PAGE_SIZE;17961796- }17971797-17981798- /* if more then 1 pages locked - then update for the last page size needed */17991799- if (num_pages > 1) {18001800- /* update the address of the last page */18011801- lli_array[count].physical_address =18021802- (unsigned long)virt_to_phys((unsigned long *)next_kernel_address);18031803-18041804- /* set the size of the last page */18051805- lli_array[count].block_size =18061806- (kernel_virt_addr + data_size) & (~PAGE_MASK);18071807-18081808- if (lli_array[count].block_size == 0) {18091809- dbg("app_virt_addr is %08lx\n",18101810- kernel_virt_addr);18111811- dbg("data_size is %lu\n", data_size);18121812- while (1);20292029+ error = -ENOMEM;20302030+ goto end_function;18132031 }1814203218151815- edbg(18161816- "lli_array[%lu].physical_address is %08lx, \18171817- lli_array[%lu].block_size is %lu\n",18181818- count, lli_array[count].physical_address,18191819- count,18201820- lli_array[count].block_size);18211821- }20332033+ /* set the start address of the first page - app data may start not at20342034+ the beginning of the page */20352035+ lli_array[0].physical_address = (unsigned long) virt_to_phys((unsigned long *) kernel_virt_addr);1822203618231823- /* set output params */18241824- *lli_array_ptr = lli_array;18251825- *num_pages_ptr = num_pages;18261826- *page_array_ptr = 0;20372037+ /* check that not all the data is in the first page only */20382038+ if ((PAGE_SIZE - (kernel_virt_addr & (~PAGE_MASK))) >= data_size)20392039+ lli_array[0].block_size = data_size;20402040+ else20412041+ lli_array[0].block_size = PAGE_SIZE - (kernel_virt_addr & (~PAGE_MASK));20422042+20432043+ /* debug print */20442044+ 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);20452045+20462046+ /* advance the address to the start of the next page */20472047+ next_kernel_address = (kernel_virt_addr & PAGE_MASK) + PAGE_SIZE;20482048+20492049+ /* go from the second page to the prev before last */20502050+ for (count = 1; count < (num_pages - 1); count++) {20512051+ lli_array[count].physical_address = (unsigned long) virt_to_phys((unsigned long *) next_kernel_address);20522052+ lli_array[count].block_size = PAGE_SIZE;20532053+20542054+ edbg("lli_array[%lu].physical_address is %08lx, \20552055+ lli_array[%lu].block_size is %lu\n", count, lli_array[count].physical_address, count, lli_array[count].block_size);20562056+20572057+ next_kernel_address += PAGE_SIZE;20582058+ }20592059+20602060+ /* if more then 1 pages locked - then update for the last page size needed */20612061+ if (num_pages > 1) {20622062+ /* update the address of the last page */20632063+ lli_array[count].physical_address = (unsigned long) virt_to_phys((unsigned long *) next_kernel_address);20642064+20652065+ /* set the size of the last page */20662066+ lli_array[count].block_size = (kernel_virt_addr + data_size) & (~PAGE_MASK);20672067+20682068+ if (lli_array[count].block_size == 0) {20692069+ dbg("app_virt_addr is %08lx\n", kernel_virt_addr);20702070+ dbg("data_size is %lu\n", data_size);20712071+ while (1);20722072+ }20732073+20742074+ edbg("lli_array[%lu].physical_address is %08lx, \20752075+ lli_array[%lu].block_size is %lu\n", count, lli_array[count].physical_address, count, lli_array[count].block_size);20762076+ }20772077+20782078+ /* set output params */20792079+ *lli_array_ptr = lli_array;20802080+ *num_pages_ptr = num_pages;20812081+ *page_array_ptr = 0;182720821828208318291829-end_function:20842084+ end_function:1830208518311831- dbg("SEP Driver:<-------- sep_lock_kernel_pages end\n");20862086+ dbg("SEP Driver:<-------- sep_lock_kernel_pages end\n");1832208718331833- return 0;20882088+ return 0;18342089}1835209018362091/*18372092 This function releases all the application virtual buffer physical pages,18382093 that were previously locked18392094*/18401840-int sep_free_dma_pages(struct page **page_array_ptr,18411841- unsigned long num_pages,18421842- unsigned long dirtyFlag)20952095+int sep_free_dma_pages(struct page **page_array_ptr, unsigned long num_pages, unsigned long dirtyFlag)18432096{18441844- /* count */18451845- unsigned long count;20972097+ /* count */20982098+ unsigned long count;1846209918472100 /*-------------------18482101 CODE18492102 ---------------------*/1850210318511851- if (dirtyFlag) {18521852- for (count = 0; count < num_pages; count++) {18531853- /* the out array was written, therefore the data was changed */18541854- if (!PageReserved(page_array_ptr[count]))18551855- SetPageDirty(page_array_ptr[count]);18561856- page_cache_release(page_array_ptr[count]);21042104+ if (dirtyFlag) {21052105+ for (count = 0; count < num_pages; count++) {21062106+ /* the out array was written, therefore the data was changed */21072107+ if (!PageReserved(page_array_ptr[count]))21082108+ SetPageDirty(page_array_ptr[count]);21092109+ page_cache_release(page_array_ptr[count]);21102110+ }21112111+ } else {21122112+ /* free in pages - the data was only read, therefore no update was done21132113+ on those pages */21142114+ for (count = 0; count < num_pages; count++)21152115+ page_cache_release(page_array_ptr[count]);18572116 }18581858- } else {18591859- /* free in pages - the data was only read, therefore no update was done18601860- on those pages */18611861- for (count = 0; count < num_pages; count++)18621862- page_cache_release(page_array_ptr[count]);18631863- }1864211718651865- if (page_array_ptr)18661866- /* free the array */18671867- kfree(page_array_ptr);21182118+ if (page_array_ptr)21192119+ /* free the array */21202120+ kfree(page_array_ptr);1868212118691869- return 0;21222122+ return 0;18702123}1871212418722125/*···18432162static void sep_send_command_handler()18442163{1845216418461846- unsigned long count;21652165+ unsigned long count;1847216618481848- dbg("SEP Driver:--------> sep_send_command_handler start\n");21672167+ dbg("SEP Driver:--------> sep_send_command_handler start\n");1849216818501850- sep_set_time(0, 0);21692169+ sep_set_time(0, 0);1851217018521852- /* flash cache */18531853- flush_cache_all();21712171+ /* flash cache */21722172+ flush_cache_all();1854217318551855- for (count = 0; count < 12 * 4; count += 4)18561856- edbg("Word %lu of the message is %lu\n", count,18571857- *((unsigned long *)(sep_dev->shared_area_addr + count)));21742174+ for (count = 0; count < 12 * 4; count += 4)21752175+ edbg("Word %lu of the message is %lu\n", count, *((unsigned long *) (sep_dev->shared_area_addr + count)));1858217618591859- /* update counter */18601860- sep_dev->host_to_sep_send_counter++;21772177+ /* update counter */21782178+ sep_dev->host_to_sep_send_counter++;1861217918621862- /* send interrupt to SEP */18631863- sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR0_REG_ADDR, 0x2);21802180+ /* send interrupt to SEP */21812181+ sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR0_REG_ADDR, 0x2);1864218218651865- dbg("SEP Driver:<-------- sep_send_command_handler end\n");21832183+ dbg("SEP Driver:<-------- sep_send_command_handler end\n");1866218418671867- return;21852185+ return;18682186}1869218718702188/*···18722192*/18732193static void sep_send_reply_command_handler()18742194{18751875- unsigned long count;21952195+ unsigned long count;1876219618771877- dbg("SEP Driver:--------> sep_send_reply_command_handler start\n");21972197+ dbg("SEP Driver:--------> sep_send_reply_command_handler start\n");1878219818791879- /* flash cache */18801880- flush_cache_all();21992199+ /* flash cache */22002200+ flush_cache_all();1881220118821882- for (count = 0; count < 12 * 4; count += 4)18831883- edbg("Word %lu of the message is %lu\n", count,18841884- *((unsigned long *)(sep_dev->shared_area_addr + count)));22022202+ for (count = 0; count < 12 * 4; count += 4)22032203+ edbg("Word %lu of the message is %lu\n", count, *((unsigned long *) (sep_dev->shared_area_addr + count)));188522041886220518871887- /* update counter */18881888- sep_dev->host_to_sep_send_counter++;22062206+ /* update counter */22072207+ sep_dev->host_to_sep_send_counter++;1889220818901890- /* send the interrupt to SEP */18911891- sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR2_REG_ADDR,18921892- sep_dev->host_to_sep_send_counter);22092209+ /* send the interrupt to SEP */22102210+ sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR2_REG_ADDR, sep_dev->host_to_sep_send_counter);1893221118941894- /* update both counters */18951895- sep_dev->host_to_sep_send_counter++;22122212+ /* update both counters */22132213+ sep_dev->host_to_sep_send_counter++;1896221418971897- sep_dev->sep_to_host_reply_counter++;22152215+ sep_dev->sep_to_host_reply_counter++;1898221618991899- dbg("SEP Driver:<-------- sep_send_reply_command_handler end\n");22172217+ dbg("SEP Driver:<-------- sep_send_reply_command_handler end\n");1900221819011901- return;22192219+ return;19022220}1903222119042222···19102232*/19112233static int sep_allocate_data_pool_memory_handler(unsigned long arg)19122234{19131913- /* error */19141914- int error;22352235+ /* error */22362236+ int error;1915223719161916- /* command paramaters */19171917- struct sep_driver_alloc_t command_args;22382238+ /* command paramaters */22392239+ struct sep_driver_alloc_t command_args;1918224019192241 /*-------------------------19202242 CODE19212243 ----------------------------*/1922224419231923- dbg("SEP Driver:--------> sep_allocate_data_pool_memory_handler start\n");22452245+ dbg("SEP Driver:--------> sep_allocate_data_pool_memory_handler start\n");192422461925224719261926- error = copy_from_user(&command_args,19271927- (void *)arg,19281928- sizeof(struct sep_driver_alloc_t));19291929- if (error)19301930- goto end_function;22482248+ error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_alloc_t));22492249+ if (error)22502250+ goto end_function;1931225119321932- /* allocate memory */19331933- if (19341934- (sep_dev->data_pool_bytes_allocated + command_args.num_bytes) >19351935- SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES) {19361936- error = -ENOTTY;19371937- goto end_function;19381938- }22522252+ /* allocate memory */22532253+ if ((sep_dev->data_pool_bytes_allocated + command_args.num_bytes) > SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES) {22542254+ error = -ENOTTY;22552255+ goto end_function;22562256+ }1939225719401940- /* set the virtual and physical address */19411941- command_args.offset = SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES +19421942- sep_dev->data_pool_bytes_allocated;19431943- command_args.phys_address = sep_dev->phys_shared_area_addr +19441944- SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES +19451945- sep_dev->data_pool_bytes_allocated;22582258+ /* set the virtual and physical address */22592259+ command_args.offset = SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES + sep_dev->data_pool_bytes_allocated;22602260+ command_args.phys_address = sep_dev->phys_shared_area_addr + SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES + sep_dev->data_pool_bytes_allocated;1946226119471947- /* write the memory back to the user space */19481948- error = copy_to_user((void *)arg,19491949- (void *)&command_args,19501950- sizeof(struct sep_driver_alloc_t));19511951- if (error)19521952- goto end_function;22622262+ /* write the memory back to the user space */22632263+ error = copy_to_user((void *) arg, (void *) &command_args, sizeof(struct sep_driver_alloc_t));22642264+ if (error)22652265+ goto end_function;1953226619541954- /* set the allocation */19551955- sep_dev->data_pool_bytes_allocated += command_args.num_bytes;22672267+ /* set the allocation */22682268+ sep_dev->data_pool_bytes_allocated += command_args.num_bytes;1956226919571957-end_function:22702270+ end_function:1958227119591959- dbg("SEP Driver:<-------- sep_allocate_data_pool_memory_handler end\n");22722272+ dbg("SEP Driver:<-------- sep_allocate_data_pool_memory_handler end\n");1960227319611961- return error;22742274+ return error;19622275}1963227619642277/*···19572288*/19582289static int sep_write_into_data_pool_handler(unsigned long arg)19592290{19601960- /* error */19611961- int error;22912291+ /* error */22922292+ int error;1962229319631963- /* virtual address */19641964- unsigned long virt_address;22942294+ /* virtual address */22952295+ unsigned long virt_address;1965229619661966- /* application in address */19671967- unsigned long app_in_address;22972297+ /* application in address */22982298+ unsigned long app_in_address;1968229919691969- /* number of bytes */19701970- unsigned long num_bytes;23002300+ /* number of bytes */23012301+ unsigned long num_bytes;1971230219721972- /* address of the data pool */19731973- unsigned long data_pool_area_addr;23032303+ /* address of the data pool */23042304+ unsigned long data_pool_area_addr;1974230519752306 /*--------------------------19762307 CODE19772308 -----------------------------*/1978230919791979- dbg("SEP Driver:--------> sep_write_into_data_pool_handler start\n");23102310+ dbg("SEP Driver:--------> sep_write_into_data_pool_handler start\n");1980231119811981- /* get the application address */19821982- error = get_user(app_in_address,19831983- &(((struct sep_driver_write_t *)arg)->app_address));19841984- if (error)19851985- goto end_function;23122312+ /* get the application address */23132313+ error = get_user(app_in_address, &(((struct sep_driver_write_t *) arg)->app_address));23142314+ if (error)23152315+ goto end_function;1986231619871987- /* get the virtual kernel address address */19881988- error = get_user(virt_address,19891989- &(((struct sep_driver_write_t *)arg)->datapool_address));19901990- if (error)19911991- goto end_function;23172317+ /* get the virtual kernel address address */23182318+ error = get_user(virt_address, &(((struct sep_driver_write_t *) arg)->datapool_address));23192319+ if (error)23202320+ goto end_function;1992232119931993- /* get the number of bytes */19941994- error = get_user(num_bytes, &(((struct sep_driver_write_t *)arg)->num_bytes));19951995- if (error)19961996- goto end_function;23222322+ /* get the number of bytes */23232323+ error = get_user(num_bytes, &(((struct sep_driver_write_t *) arg)->num_bytes));23242324+ if (error)23252325+ goto end_function;1997232619981998- /* calculate the start of the data pool */19991999- data_pool_area_addr = sep_dev->shared_area_addr +20002000- SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES;23272327+ /* calculate the start of the data pool */23282328+ data_pool_area_addr = sep_dev->shared_area_addr + SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES;200123292002233020032003- /* check that the range of the virtual kernel address is correct */20042004- if ((virt_address < data_pool_area_addr) ||20052005- (virt_address > (data_pool_area_addr +20062006- SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES))) {20072007- error = -ENOTTY;20082008- goto end_function;20092009- }23312331+ /* check that the range of the virtual kernel address is correct */23322332+ if ((virt_address < data_pool_area_addr) || (virt_address > (data_pool_area_addr + SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES))) {23332333+ error = -ENOTTY;23342334+ goto end_function;23352335+ }2010233620112011- /* copy the application data */20122012- error = copy_from_user((void *)virt_address,20132013- (void *)app_in_address,20142014- num_bytes);23372337+ /* copy the application data */23382338+ error = copy_from_user((void *) virt_address, (void *) app_in_address, num_bytes);2015233920162016-end_function:23402340+ end_function:2017234120182018- dbg("SEP Driver:<-------- sep_write_into_data_pool_handler end\n");23422342+ dbg("SEP Driver:<-------- sep_write_into_data_pool_handler end\n");2019234320202020- return error;23442344+ return error;20212345}2022234620232347/*···20182356*/20192357static int sep_read_from_data_pool_handler(unsigned long arg)20202358{20212021- /* error */20222022- int error;23592359+ /* error */23602360+ int error;2023236120242024- /* virtual address of dest application buffer */20252025- unsigned long app_out_address;23622362+ /* virtual address of dest application buffer */23632363+ unsigned long app_out_address;2026236420272027- /* virtual address of the data pool */20282028- unsigned long virt_address;23652365+ /* virtual address of the data pool */23662366+ unsigned long virt_address;2029236720302030- /* number bytes */20312031- unsigned long num_bytes;23682368+ /* number bytes */23692369+ unsigned long num_bytes;2032237020332033- /* address of the data pool */20342034- unsigned long data_pool_area_addr;23712371+ /* address of the data pool */23722372+ unsigned long data_pool_area_addr;2035237320362374 /*------------------------20372375 CODE20382376 -----------------------------*/2039237720402040- dbg("SEP Driver:--------> sep_read_from_data_pool_handler start\n");23782378+ dbg("SEP Driver:--------> sep_read_from_data_pool_handler start\n");2041237920422042- /* get the application address */20432043- error = get_user(app_out_address,20442044- &(((struct sep_driver_write_t *)arg)->app_address));20452045- if (error)20462046- goto end_function;23802380+ /* get the application address */23812381+ error = get_user(app_out_address, &(((struct sep_driver_write_t *) arg)->app_address));23822382+ if (error)23832383+ goto end_function;2047238420482048- /* get the virtual kernel address address */20492049- error = get_user(virt_address,20502050- &(((struct sep_driver_write_t *)arg)->datapool_address));20512051- if (error)20522052- goto end_function;23852385+ /* get the virtual kernel address address */23862386+ error = get_user(virt_address, &(((struct sep_driver_write_t *) arg)->datapool_address));23872387+ if (error)23882388+ goto end_function;2053238920542054- /* get the number of bytes */20552055- error = get_user(num_bytes, &(((struct sep_driver_write_t *)arg)->num_bytes));20562056- if (error)20572057- goto end_function;23902390+ /* get the number of bytes */23912391+ error = get_user(num_bytes, &(((struct sep_driver_write_t *) arg)->num_bytes));23922392+ if (error)23932393+ goto end_function;2058239420592059- /* calculate the start of the data pool */20602060- data_pool_area_addr = sep_dev->shared_area_addr +20612061- SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES;23952395+ /* calculate the start of the data pool */23962396+ data_pool_area_addr = sep_dev->shared_area_addr + SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES;2062239720632063- /* check that the range of the virtual kernel address is correct */20642064- if ((virt_address < data_pool_area_addr) ||20652065- (virt_address > (data_pool_area_addr +20662066- SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES))) {20672067- error = -ENOTTY;20682068- goto end_function;20692069- }23982398+ /* check that the range of the virtual kernel address is correct */23992399+ if ((virt_address < data_pool_area_addr) || (virt_address > (data_pool_area_addr + SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES))) {24002400+ error = -ENOTTY;24012401+ goto end_function;24022402+ }2070240320712071- /* copy the application data */20722072- error = copy_to_user((void *)app_out_address, (void *)virt_address,20732073- num_bytes);24042404+ /* copy the application data */24052405+ error = copy_to_user((void *) app_out_address, (void *) virt_address, num_bytes);2074240620752075-end_function:24072407+ end_function:2076240820772077- dbg("SEP Driver:<-------- sep_read_from_data_pool_handler end\n");24092409+ dbg("SEP Driver:<-------- sep_read_from_data_pool_handler end\n");2078241020792079- return error;24112411+ return error;20802412}2081241320822414···20802424*/20812425static int sep_create_sync_dma_tables_handler(unsigned long arg)20822426{20832083- /* error */20842084- int error;24272427+ /* error */24282428+ int error;2085242920862086- /* command arguments */20872087- struct sep_driver_build_sync_table_t command_args;24302430+ /* command arguments */24312431+ struct sep_driver_build_sync_table_t command_args;2088243220892433 /*------------------------20902434 CODE20912435 --------------------------*/2092243620932093- dbg("SEP Driver:--------> sep_create_sync_dma_tables_handler start\n");24372437+ dbg("SEP Driver:--------> sep_create_sync_dma_tables_handler start\n");2094243820952095- error = copy_from_user(&command_args,20962096- (void *)arg,20972097- sizeof(struct sep_driver_build_sync_table_t));20982098- if (error)20992099- goto end_function;24392439+ error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_build_sync_table_t));24402440+ if (error)24412441+ goto end_function;2100244221012101- edbg(21022102- "app_in_address is %08lx\n",21032103- command_args.app_in_address);21042104- edbg(21052105- "app_out_address is %08lx\n",21062106- command_args.app_out_address);21072107- edbg(21082108- "data_size is %lu\n",21092109- command_args.data_in_size);21102110- edbg(21112111- "block_size is %lu\n",21122112- command_args.block_size);24432443+ edbg("app_in_address is %08lx\n", command_args.app_in_address);24442444+ edbg("app_out_address is %08lx\n", command_args.app_out_address);24452445+ edbg("data_size is %lu\n", command_args.data_in_size);24462446+ edbg("block_size is %lu\n", command_args.block_size);211324472114244821152115- /* check if we need to build only input table or input/output */21162116- if (command_args.app_out_address)21172117- /* prepare input and output tables */21182118- error = sep_prepare_input_output_dma_table(command_args.app_in_address,21192119- command_args.app_out_address,21202120- command_args.data_in_size,21212121- command_args.block_size,21222122- &command_args.in_table_address,21232123- &command_args.out_table_address,21242124- &command_args.in_table_num_entries,21252125- &command_args.out_table_num_entries,21262126- &command_args.table_data_size,21272127- command_args.isKernelVirtualAddress);21282128- else21292129- /* prepare input tables */21302130- error = sep_prepare_input_dma_table(command_args.app_in_address,21312131- command_args.data_in_size,21322132- command_args.block_size,21332133- &command_args.in_table_address,21342134- &command_args.in_table_num_entries,21352135- &command_args.table_data_size,21362136- command_args.isKernelVirtualAddress);24492449+ /* check if we need to build only input table or input/output */24502450+ if (command_args.app_out_address)24512451+ /* prepare input and output tables */24522452+ error = sep_prepare_input_output_dma_table(command_args.app_in_address,24532453+ command_args.app_out_address,24542454+ command_args.data_in_size,24552455+ command_args.block_size,24562456+ &command_args.in_table_address,24572457+ &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);24582458+ else24592459+ /* prepare input tables */24602460+ error = sep_prepare_input_dma_table(command_args.app_in_address,24612461+ 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);2137246221382138- if (error)21392139- goto end_function;24632463+ if (error)24642464+ goto end_function;2140246521412141- /* copy to user */21422142- error = copy_to_user((void *)arg,21432143- (void *)&command_args,21442144- sizeof(struct sep_driver_build_sync_table_t));24662466+ /* copy to user */24672467+ error = copy_to_user((void *) arg, (void *) &command_args, sizeof(struct sep_driver_build_sync_table_t));2145246821462146-end_function:24692469+ end_function:2147247021482148- dbg("SEP Driver:<-------- sep_create_sync_dma_tables_handler end\n");24712471+ dbg("SEP Driver:<-------- sep_create_sync_dma_tables_handler end\n");2149247221502150- return error;24732473+ return error;21512474}2152247521532476/*···21382503 CODE21392504 -----------------------------*/2140250521412141- dbg("SEP Driver:--------> sep_free_dma_table_data_handler start\n");25062506+ dbg("SEP Driver:--------> sep_free_dma_table_data_handler start\n");2142250721432143- /* free input pages array */21442144- sep_free_dma_pages(sep_dev->in_page_array,21452145- sep_dev->in_num_pages,21462146- 0);25082508+ /* free input pages array */25092509+ sep_free_dma_pages(sep_dev->in_page_array, sep_dev->in_num_pages, 0);2147251021482148- /* free output pages array if needed */21492149- if (sep_dev->out_page_array)21502150- sep_free_dma_pages(sep_dev->out_page_array,21512151- sep_dev->out_num_pages,21522152- 1);25112511+ /* free output pages array if needed */25122512+ if (sep_dev->out_page_array)25132513+ sep_free_dma_pages(sep_dev->out_page_array, sep_dev->out_num_pages, 1);2153251421542154- /* reset all the values */21552155- sep_dev->in_page_array = 0;21562156- sep_dev->out_page_array = 0;21572157- sep_dev->in_num_pages = 0;21582158- sep_dev->out_num_pages = 0;25152515+ /* reset all the values */25162516+ sep_dev->in_page_array = 0;25172517+ sep_dev->out_page_array = 0;25182518+ sep_dev->in_num_pages = 0;25192519+ sep_dev->out_num_pages = 0;215925202160252121612161- dbg("SEP Driver:<-------- sep_free_dma_table_data_handler end\n");25222522+ dbg("SEP Driver:<-------- sep_free_dma_table_data_handler end\n");2162252321632163- return 0;25242524+ return 0;21642525}2165252621662527/*···21642533*/21652534static int sep_create_flow_dma_tables_handler(unsigned long arg)21662535{21672167- /* error */21682168- int error;25362536+ /* error */25372537+ int error;2169253821702170- /* command arguments */21712171- struct sep_driver_build_flow_table_t command_args;25392539+ /* command arguments */25402540+ struct sep_driver_build_flow_table_t command_args;2172254121732173- /* first table - output */21742174- struct sep_lli_entry_t first_table_data;25422542+ /* first table - output */25432543+ struct sep_lli_entry_t first_table_data;2175254421762176- /* dma table data */21772177- struct sep_lli_entry_t last_table_data;25452545+ /* dma table data */25462546+ struct sep_lli_entry_t last_table_data;2178254721792179- /* pointer to the info entry of the previuos DMA table */21802180- struct sep_lli_entry_t *prev_info_entry_ptr;25482548+ /* pointer to the info entry of the previuos DMA table */25492549+ struct sep_lli_entry_t *prev_info_entry_ptr;2181255021822182- /* pointer to the flow data strucutre */21832183- struct sep_flow_context_t *flow_context_ptr;25512551+ /* pointer to the flow data strucutre */25522552+ struct sep_flow_context_t *flow_context_ptr;2184255321852554 /*------------------------21862555 CODE21872556 --------------------------*/2188255721892189- dbg("SEP Driver:--------> sep_create_flow_dma_tables_handler start\n");25582558+ dbg("SEP Driver:--------> sep_create_flow_dma_tables_handler start\n");2190255921912191- /* init variables */21922192- prev_info_entry_ptr = 0;21932193- first_table_data.physical_address = 0xffffffff;25602560+ /* init variables */25612561+ prev_info_entry_ptr = 0;25622562+ first_table_data.physical_address = 0xffffffff;2194256321952195- /* find the free structure for flow data */21962196- error = sep_find_flow_context(SEP_FREE_FLOW_ID, &flow_context_ptr);21972197- if (error)25642564+ /* find the free structure for flow data */25652565+ error = sep_find_flow_context(SEP_FREE_FLOW_ID, &flow_context_ptr);25662566+ if (error)25672567+ goto end_function;25682568+25692569+ error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_build_flow_table_t));25702570+ if (error)25712571+ goto end_function;25722572+25732573+ /* create flow tables */25742574+ 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);25752575+ if (error)25762576+ goto end_function_with_error;25772577+25782578+ /* check if flow is static */25792579+ if (!command_args.flow_type)25802580+ /* point the info entry of the last to the info entry of the first */25812581+ last_table_data = first_table_data;25822582+25832583+ /* set output params */25842584+ command_args.first_table_addr = first_table_data.physical_address;25852585+ command_args.first_table_num_entries = ((first_table_data.block_size >> SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK);25862586+ command_args.first_table_data_size = (first_table_data.block_size & SEP_TABLE_DATA_SIZE_MASK);25872587+25882588+ /* send the parameters to user application */25892589+ error = copy_to_user((void *) arg, &command_args, sizeof(struct sep_driver_build_flow_table_t));25902590+ if (error)25912591+ goto end_function_with_error;25922592+25932593+ /* all the flow created - update the flow entry with temp id */25942594+ flow_context_ptr->flow_id = SEP_TEMP_FLOW_ID;25952595+25962596+ /* set the processing tables data in the context */25972597+ if (command_args.input_output_flag == SEP_DRIVER_IN_FLAG)25982598+ flow_context_ptr->input_tables_in_process = first_table_data;25992599+ else26002600+ flow_context_ptr->output_tables_in_process = first_table_data;26012601+21982602 goto end_function;2199260322002200- error = copy_from_user(&command_args,22012201- (void *)arg,22022202- sizeof(struct sep_driver_build_flow_table_t));22032203- if (error)22042204- goto end_function;26042604+ end_function_with_error:2205260522062206- /* create flow tables */22072207- error = sep_prepare_flow_dma_tables(command_args.num_virtual_buffers,22082208- command_args.virt_buff_data_addr,22092209- flow_context_ptr,22102210- &first_table_data,22112211- &last_table_data,22122212- command_args.isKernelVirtualAddress);22132213- if (error)22142214- goto end_function_with_error;26062606+ /* free the allocated tables */26072607+ sep_deallocated_flow_tables(&first_table_data);2215260822162216- /* check if flow is static */22172217- if (!command_args.flow_type)22182218- /* point the info entry of the last to the info entry of the first */22192219- last_table_data = first_table_data;26092609+ end_function:2220261022212221- /* set output params */22222222- command_args.first_table_addr = first_table_data.physical_address;22232223- command_args.first_table_num_entries =22242224- ((first_table_data.block_size >> SEP_NUM_ENTRIES_OFFSET_IN_BITS) &22252225- SEP_NUM_ENTRIES_MASK);22262226- command_args.first_table_data_size =22272227- (first_table_data.block_size & SEP_TABLE_DATA_SIZE_MASK);26112611+ dbg("SEP Driver:<-------- sep_create_flow_dma_tables_handler end\n");2228261222292229- /* send the parameters to user application */22302230- error = copy_to_user((void *)arg,22312231- &command_args,22322232- sizeof(struct sep_driver_build_flow_table_t));22332233- if (error)22342234- goto end_function_with_error;22352235-22362236- /* all the flow created - update the flow entry with temp id */22372237- flow_context_ptr->flow_id = SEP_TEMP_FLOW_ID;22382238-22392239- /* set the processing tables data in the context */22402240- if (command_args.input_output_flag == SEP_DRIVER_IN_FLAG)22412241- flow_context_ptr->input_tables_in_process = first_table_data;22422242- else22432243- flow_context_ptr->output_tables_in_process = first_table_data;22442244-22452245- goto end_function;22462246-22472247-end_function_with_error:22482248-22492249- /* free the allocated tables */22502250- sep_deallocated_flow_tables(&first_table_data);22512251-22522252-end_function:22532253-22542254- dbg("SEP Driver:<-------- sep_create_flow_dma_tables_handler end\n");22552255-22562256- return error;26132613+ return error;2257261422582615}22592616···22502631*/22512632static int sep_add_flow_tables_handler(unsigned long arg)22522633{22532253- /* error */22542254- int error;26342634+ /* error */26352635+ int error;2255263622562256- /* number of entries */22572257- unsigned long num_entries;26372637+ /* number of entries */26382638+ unsigned long num_entries;2258263922592259- /* command arguments */22602260- struct sep_driver_add_flow_table_t command_args;26402640+ /* command arguments */26412641+ struct sep_driver_add_flow_table_t command_args;2261264222622262- /* pointer to the flow data strucutre */22632263- struct sep_flow_context_t *flow_context_ptr;26432643+ /* pointer to the flow data strucutre */26442644+ struct sep_flow_context_t *flow_context_ptr;2264264522652265- /* first dma table data */22662266- struct sep_lli_entry_t first_table_data;26462646+ /* first dma table data */26472647+ struct sep_lli_entry_t first_table_data;2267264822682268- /* last dma table data */22692269- struct sep_lli_entry_t last_table_data;26492649+ /* last dma table data */26502650+ struct sep_lli_entry_t last_table_data;2270265122712271- /* pointer to the info entry of the current DMA table */22722272- struct sep_lli_entry_t *info_entry_ptr;26522652+ /* pointer to the info entry of the current DMA table */26532653+ struct sep_lli_entry_t *info_entry_ptr;2273265422742655 /*--------------------------22752656 CODE22762657 ----------------------------*/2277265822782278- dbg("SEP Driver:--------> sep_add_flow_tables_handler start\n");26592659+ dbg("SEP Driver:--------> sep_add_flow_tables_handler start\n");2279266022802280- /* get input parameters */22812281- error = copy_from_user(&command_args,22822282- (void *)arg,22832283- sizeof(struct sep_driver_add_flow_table_t));22842284- if (error)22852285- goto end_function;26612661+ /* get input parameters */26622662+ error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_add_flow_table_t));26632663+ if (error)26642664+ goto end_function;2286266522872287- /* find the flow structure for the flow id */22882288- error = sep_find_flow_context(command_args.flow_id, &flow_context_ptr);22892289- if (error)22902290- goto end_function;26662666+ /* find the flow structure for the flow id */26672667+ error = sep_find_flow_context(command_args.flow_id, &flow_context_ptr);26682668+ if (error)26692669+ goto end_function;2291267022922292- /* prepare the flow dma tables */22932293- error = sep_prepare_flow_dma_tables(command_args.num_virtual_buffers,22942294- command_args.virt_buff_data_addr,22952295- flow_context_ptr,22962296- &first_table_data,22972297- &last_table_data,22982298- command_args.isKernelVirtualAddress);22992299- if (error)23002300- goto end_function_with_error;26712671+ /* prepare the flow dma tables */26722672+ 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);26732673+ if (error)26742674+ goto end_function_with_error;2301267523022302- /* now check if there is already an existing add table for this flow */23032303- if (command_args.inputOutputFlag == SEP_DRIVER_IN_FLAG) {23042304- /* this buffer was for input buffers */23052305- if (flow_context_ptr->input_tables_flag) {23062306- /* add table already exists - add the new tables to the end23072307- of the previous */23082308- num_entries = (flow_context_ptr->last_input_table.block_size >>23092309- SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK;26762676+ /* now check if there is already an existing add table for this flow */26772677+ if (command_args.inputOutputFlag == SEP_DRIVER_IN_FLAG) {26782678+ /* this buffer was for input buffers */26792679+ if (flow_context_ptr->input_tables_flag) {26802680+ /* add table already exists - add the new tables to the end26812681+ of the previous */26822682+ num_entries = (flow_context_ptr->last_input_table.block_size >> SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK;2310268323112311- info_entry_ptr =23122312- (struct sep_lli_entry_t *)23132313- (flow_context_ptr->last_input_table.physical_address +23142314- (sizeof(struct sep_lli_entry_t) * (num_entries - 1)));26842684+ info_entry_ptr = (struct sep_lli_entry_t *)26852685+ (flow_context_ptr->last_input_table.physical_address + (sizeof(struct sep_lli_entry_t) * (num_entries - 1)));2315268623162316- /* connect to list of tables */23172317- *info_entry_ptr = first_table_data;26872687+ /* connect to list of tables */26882688+ *info_entry_ptr = first_table_data;2318268923192319- /* set the first table data */23202320- first_table_data = flow_context_ptr->first_input_table;23212321- } else {23222322- /* set the input flag */23232323- flow_context_ptr->input_tables_flag = 1;26902690+ /* set the first table data */26912691+ first_table_data = flow_context_ptr->first_input_table;26922692+ } else {26932693+ /* set the input flag */26942694+ flow_context_ptr->input_tables_flag = 1;2324269523252325- /* set the first table data */23262326- flow_context_ptr->first_input_table = first_table_data;26962696+ /* set the first table data */26972697+ flow_context_ptr->first_input_table = first_table_data;26982698+ }26992699+ /* set the last table data */27002700+ flow_context_ptr->last_input_table = last_table_data;27012701+ } else { /* this is output tables */27022702+27032703+ /* this buffer was for input buffers */27042704+ if (flow_context_ptr->output_tables_flag) {27052705+ /* add table already exists - add the new tables to27062706+ the end of the previous */27072707+ num_entries = (flow_context_ptr->last_output_table.block_size >> SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK;27082708+27092709+ info_entry_ptr = (struct sep_lli_entry_t *)27102710+ (flow_context_ptr->last_output_table.physical_address + (sizeof(struct sep_lli_entry_t) * (num_entries - 1)));27112711+27122712+ /* connect to list of tables */27132713+ *info_entry_ptr = first_table_data;27142714+27152715+ /* set the first table data */27162716+ first_table_data = flow_context_ptr->first_output_table;27172717+ } else {27182718+ /* set the input flag */27192719+ flow_context_ptr->output_tables_flag = 1;27202720+27212721+ /* set the first table data */27222722+ flow_context_ptr->first_output_table = first_table_data;27232723+ }27242724+ /* set the last table data */27252725+ flow_context_ptr->last_output_table = last_table_data;23272726 }23282328- /* set the last table data */23292329- flow_context_ptr->last_input_table = last_table_data;23302330- } else /* this is output tables */ {23312331- /* this buffer was for input buffers */23322332- if (flow_context_ptr->output_tables_flag) {23332333- /* add table already exists - add the new tables to23342334- the end of the previous */23352335- num_entries = (flow_context_ptr->last_output_table.block_size >>23362336- SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK;2337272723382338- info_entry_ptr =23392339- (struct sep_lli_entry_t *)23402340- (flow_context_ptr->last_output_table.physical_address +23412341- (sizeof(struct sep_lli_entry_t) * (num_entries - 1)));27282728+ /* set output params */27292729+ command_args.first_table_addr = first_table_data.physical_address;27302730+ command_args.first_table_num_entries = ((first_table_data.block_size >> SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK);27312731+ command_args.first_table_data_size = (first_table_data.block_size & SEP_TABLE_DATA_SIZE_MASK);2342273223432343- /* connect to list of tables */23442344- *info_entry_ptr = first_table_data;27332733+ /* send the parameters to user application */27342734+ error = copy_to_user((void *) arg, &command_args, sizeof(struct sep_driver_add_flow_table_t));27352735+ if (error)27362736+ goto end_function_with_error;2345273723462346- /* set the first table data */23472347- first_table_data = flow_context_ptr->first_output_table;23482348- } else {23492349- /* set the input flag */23502350- flow_context_ptr->output_tables_flag = 1;27382738+ end_function_with_error:2351273923522352- /* set the first table data */23532353- flow_context_ptr->first_output_table = first_table_data;23542354- }23552355- /* set the last table data */23562356- flow_context_ptr->last_output_table = last_table_data;23572357- }27402740+ /* free the allocated tables */27412741+ sep_deallocated_flow_tables(&first_table_data);2358274223592359- /* set output params */23602360- command_args.first_table_addr = first_table_data.physical_address;23612361- command_args.first_table_num_entries = ((first_table_data.block_size >>23622362- SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK);23632363- command_args.first_table_data_size =23642364- (first_table_data.block_size & SEP_TABLE_DATA_SIZE_MASK);27432743+ end_function:2365274423662366- /* send the parameters to user application */23672367- error = copy_to_user((void *)arg,23682368- &command_args,23692369- sizeof(struct sep_driver_add_flow_table_t));23702370- if (error)23712371- goto end_function_with_error;27452745+ dbg("SEP Driver:<-------- sep_add_flow_tables_handler end\n");2372274623732373-end_function_with_error:23742374-23752375- /* free the allocated tables */23762376- sep_deallocated_flow_tables(&first_table_data);23772377-23782378-end_function:23792379-23802380- dbg("SEP Driver:<-------- sep_add_flow_tables_handler end\n");23812381-23822382- return error;27472747+ return error;23832748}2384274923852750/*···23712768*/23722769static int sep_add_flow_tables_message_handler(unsigned long arg)23732770{23742374- /* error */23752375- int error;27712771+ /* error */27722772+ int error;2376277323772377- /* arguments */23782378- struct sep_driver_add_message_t command_args;27742774+ /* arguments */27752775+ struct sep_driver_add_message_t command_args;2379277623802380- /* flow context */23812381- struct sep_flow_context_t *flow_context_ptr;27772777+ /* flow context */27782778+ struct sep_flow_context_t *flow_context_ptr;2382277923832780 /*----------------------------23842781 CODE23852782 ------------------------------*/2386278323872387- dbg("SEP Driver:--------> sep_add_flow_tables_message_handler start\n");27842784+ dbg("SEP Driver:--------> sep_add_flow_tables_message_handler start\n");2388278523892389- error = copy_from_user(&command_args,23902390- (void *)arg,23912391- sizeof(struct sep_driver_add_message_t));23922392- if (error)23932393- goto end_function;27862786+ error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_add_message_t));27872787+ if (error)27882788+ goto end_function;2394278923952395- /* check input */23962396- if (command_args.message_size_in_bytes >23972397- SEP_MAX_ADD_MESSAGE_LENGTH_IN_BYTES) {23982398- error = -ENOMEM;23992399- goto end_function;24002400- }27902790+ /* check input */27912791+ if (command_args.message_size_in_bytes > SEP_MAX_ADD_MESSAGE_LENGTH_IN_BYTES) {27922792+ error = -ENOMEM;27932793+ goto end_function;27942794+ }2401279524022402- /* find the flow context */24032403- error = sep_find_flow_context(command_args.flow_id, &flow_context_ptr);24042404- if (error)24052405- goto end_function;27962796+ /* find the flow context */27972797+ error = sep_find_flow_context(command_args.flow_id, &flow_context_ptr);27982798+ if (error)27992799+ goto end_function;2406280024072407- /* copy the message into context */24082408- flow_context_ptr->message_size_in_bytes = command_args.message_size_in_bytes;28012801+ /* copy the message into context */28022802+ flow_context_ptr->message_size_in_bytes = command_args.message_size_in_bytes;2409280324102410- error = copy_from_user(flow_context_ptr->message,24112411- (void *)command_args.message_address,24122412- command_args.message_size_in_bytes);28042804+ error = copy_from_user(flow_context_ptr->message, (void *) command_args.message_address, command_args.message_size_in_bytes);241328052414280624152415-end_function:28072807+ end_function:2416280824172417- dbg("SEP Driver:<-------- sep_add_flow_tables_message_handler end\n");28092809+ dbg("SEP Driver:<-------- sep_add_flow_tables_message_handler end\n");2418281024192419- return error;28112811+ return error;24202812}2421281324222814···24202822*/24212823static int sep_get_static_pool_addr_handler(unsigned long arg)24222824{24232423- /* error */24242424- int error;28252825+ /* error */28262826+ int error;2425282724262426- /* command arguments */24272427- struct sep_driver_static_pool_addr_t command_args;28282828+ /* command arguments */28292829+ struct sep_driver_static_pool_addr_t command_args;2428283024292831 /*-----------------------------24302832 CODE24312833 ------------------------------*/2432283424332433- dbg("SEP Driver:--------> sep_get_static_pool_addr_handler start\n");28352835+ dbg("SEP Driver:--------> sep_get_static_pool_addr_handler start\n");2434283624352435- /*prepare the output parameters in the struct */24362436- command_args.physical_static_address = sep_dev->phys_shared_area_addr +24372437- SEP_DRIVER_STATIC_AREA_OFFSET_IN_BYTES;24382438- command_args.virtual_static_address = sep_dev->shared_area_addr +24392439- SEP_DRIVER_STATIC_AREA_OFFSET_IN_BYTES;28372837+ /*prepare the output parameters in the struct */28382838+ command_args.physical_static_address = sep_dev->phys_shared_area_addr + SEP_DRIVER_STATIC_AREA_OFFSET_IN_BYTES;28392839+ command_args.virtual_static_address = sep_dev->shared_area_addr + SEP_DRIVER_STATIC_AREA_OFFSET_IN_BYTES;2440284024412441- edbg("SEP Driver:physical_static_address is %08lx, virtual_static_address %08lx\n",24422442- command_args.physical_static_address,24432443- command_args.virtual_static_address);28412841+ edbg("SEP Driver:physical_static_address is %08lx, virtual_static_address %08lx\n", command_args.physical_static_address, command_args.virtual_static_address);2444284224452445- /* send the parameters to user application */24462446- error = copy_to_user((void *)arg,24472447- &command_args,24482448- sizeof(struct sep_driver_static_pool_addr_t));24492449- if (error)24502450- goto end_function;28432843+ /* send the parameters to user application */28442844+ error = copy_to_user((void *) arg, &command_args, sizeof(struct sep_driver_static_pool_addr_t));28452845+ if (error)28462846+ goto end_function;2451284724522452-end_function:28482848+ end_function:2453284924542454- dbg("SEP Driver:<-------- sep_get_static_pool_addr_handler end\n");28502850+ dbg("SEP Driver:<-------- sep_get_static_pool_addr_handler end\n");2455285124562456- return error;28522852+ return error;24572853}2458285424592855/*···24562864*/24572865static int sep_get_physical_mapped_offset_handler(unsigned long arg)24582866{24592459- /* error */24602460- int error;28672867+ /* error */28682868+ int error;2461286924622462- /* command arguments */24632463- struct sep_driver_get_mapped_offset_t command_args;28702870+ /* command arguments */28712871+ struct sep_driver_get_mapped_offset_t command_args;2464287224652873 /*-----------------------------24662874 CODE24672875 ------------------------------*/2468287624692469- dbg("SEP Driver:--------> sep_get_physical_mapped_offset_handler start\n");28772877+ dbg("SEP Driver:--------> sep_get_physical_mapped_offset_handler start\n");2470287824712471- error = copy_from_user(&command_args,24722472- (void *)arg,24732473- sizeof(struct sep_driver_get_mapped_offset_t));24742474- if (error)24752475- goto end_function;28792879+ error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_get_mapped_offset_t));28802880+ if (error)28812881+ goto end_function;2476288224772477- if (command_args.physical_address < sep_dev->phys_shared_area_addr) {24782478- error = -ENOTTY;24792479- goto end_function;24802480- }28832883+ if (command_args.physical_address < sep_dev->phys_shared_area_addr) {28842884+ error = -ENOTTY;28852885+ goto end_function;28862886+ }2481288724822482- /*prepare the output parameters in the struct */24832483- command_args.offset = command_args.physical_address -24842484- sep_dev->phys_shared_area_addr;28882888+ /*prepare the output parameters in the struct */28892889+ command_args.offset = command_args.physical_address - sep_dev->phys_shared_area_addr;2485289024862486- edbg("SEP Driver:physical_address is %08lx, offset is %lu\n",24872487- command_args.physical_address,24882488- command_args.offset);28912891+ edbg("SEP Driver:physical_address is %08lx, offset is %lu\n", command_args.physical_address, command_args.offset);2489289224902490- /* send the parameters to user application */24912491- error = copy_to_user((void *)arg,24922492- &command_args,24932493- sizeof(struct sep_driver_get_mapped_offset_t));24942494- if (error)24952495- goto end_function;28932893+ /* send the parameters to user application */28942894+ error = copy_to_user((void *) arg, &command_args, sizeof(struct sep_driver_get_mapped_offset_t));28952895+ if (error)28962896+ goto end_function;2496289724972497-end_function:28982898+ end_function:2498289924992499- dbg("SEP Driver:<-------- sep_get_physical_mapped_offset_handler end\n");29002900+ dbg("SEP Driver:<-------- sep_get_physical_mapped_offset_handler end\n");2500290125012501- return error;29022902+ return error;25022903}2503290425042905···25002915*/25012916static int sep_start_handler(void)25022917{25032503- /* reg val */25042504- unsigned long reg_val;29182918+ /* reg val */29192919+ unsigned long reg_val;2505292025062506- /* error */25072507- unsigned long error;29212921+ /* error */29222922+ unsigned long error;2508292325092924 /*-----------------------------25102925 CODE25112926 ------------------------------*/2512292725132513- dbg("SEP Driver:--------> sep_start_handler start\n");29282928+ dbg("SEP Driver:--------> sep_start_handler start\n");2514292925152515- error = 0;29302930+ error = 0;2516293125172517- /* wait in polling for message from SEP */25182518- do {25192519- reg_val = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR3_REG_ADDR);25202520- } while (!reg_val);29322932+ /* wait in polling for message from SEP */29332933+ do {29342934+ reg_val = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR3_REG_ADDR);29352935+ } while (!reg_val);2521293625222522- /* check the value */25232523- if (reg_val == 0x1) {25242524- /* fatal error - read erro status from GPRO */25252525- error = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR);25262526- goto end_function;25272527- }29372937+ /* check the value */29382938+ if (reg_val == 0x1) {29392939+ /* fatal error - read erro status from GPRO */29402940+ error = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR);29412941+ goto end_function;29422942+ }2528294325292529-end_function:29442944+ end_function:2530294525312531- dbg("SEP Driver:<-------- sep_start_handler end\n");29462946+ dbg("SEP Driver:<-------- sep_start_handler end\n");2532294725332533- return error;29482948+ return error;25342949}2535295025362951/*···25382953*/25392954static int sep_init_handler(unsigned long arg)25402955{25412541- /* word from message */25422542- unsigned long message_word;29562956+ /* word from message */29572957+ unsigned long message_word;2543295825442544- /* message ptr */25452545- unsigned long *message_ptr;29592959+ /* message ptr */29602960+ unsigned long *message_ptr;2546296125472547- /* command arguments */25482548- struct sep_driver_init_t command_args;29622962+ /* command arguments */29632963+ struct sep_driver_init_t command_args;2549296425502550- /* counter */25512551- unsigned long counter;29652965+ /* counter */29662966+ unsigned long counter;2552296725532553- /* error */25542554- unsigned long error;29682968+ /* error */29692969+ unsigned long error;2555297025562556- /* reg val */25572557- unsigned long reg_val;29712971+ /* reg val */29722972+ unsigned long reg_val;2558297325592974 /*-------------------25602975 CODE25612976 ---------------------*/2562297725632563- dbg("SEP Driver:--------> sep_init_handler start\n");29782978+ dbg("SEP Driver:--------> sep_init_handler start\n");2564297925652565- error = 0;29802980+ error = 0;2566298125672567- error = copy_from_user(&command_args, (void *)arg,25682568- sizeof(struct sep_driver_init_t));29822982+ error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_init_t));2569298325702570- dbg("SEP Driver:--------> sep_init_handler - finished copy_from_user \n");29842984+ dbg("SEP Driver:--------> sep_init_handler - finished copy_from_user \n");2571298525722572- if (error)25732573- goto end_function;29862986+ if (error)29872987+ goto end_function;2574298825752575- /* PATCH - configure the DMA to single -burst instead of multi-burst */25762576- /*sep_configure_dma_burst();*/29892989+ /* PATCH - configure the DMA to single -burst instead of multi-burst */29902990+ /*sep_configure_dma_burst(); */2577299125782578- dbg("SEP Driver:--------> sep_init_handler - finished sep_configure_dma_burst \n");29922992+ dbg("SEP Driver:--------> sep_init_handler - finished sep_configure_dma_burst \n");2579299325802580- message_ptr = (unsigned long *)command_args.message_addr;29942994+ message_ptr = (unsigned long *) command_args.message_addr;2581299525822582- /* set the base address of the SRAM */25832583- sep_write_reg(sep_dev, HW_SRAM_ADDR_REG_ADDR, HW_CC_SRAM_BASE_ADDRESS);29962996+ /* set the base address of the SRAM */29972997+ sep_write_reg(sep_dev, HW_SRAM_ADDR_REG_ADDR, HW_CC_SRAM_BASE_ADDRESS);2584299825852585- for (counter = 0 ;25862586- counter < command_args.message_size_in_words;25872587- counter++, message_ptr++) {25882588- get_user(message_word, message_ptr);29992999+ for (counter = 0; counter < command_args.message_size_in_words; counter++, message_ptr++) {30003000+ get_user(message_word, message_ptr);2589300125902590- /* write data to SRAM */25912591- sep_write_reg(sep_dev, HW_SRAM_DATA_REG_ADDR,25922592- message_word);30023002+ /* write data to SRAM */30033003+ sep_write_reg(sep_dev, HW_SRAM_DATA_REG_ADDR, message_word);2593300425942594- edbg(25952595- "SEP Driver:message_word is %lu\n",25962596- message_word);30053005+ edbg("SEP Driver:message_word is %lu\n", message_word);2597300625983007 /* wait for write complete */25992599- sep_wait_sram_write(sep_dev);26002600- }30083008+ sep_wait_sram_write(sep_dev);30093009+ }2601301026022602- dbg("SEP Driver:--------> sep_init_handler - finished getting messages from user space\n");30113011+ dbg("SEP Driver:--------> sep_init_handler - finished getting messages from user space\n");2603301226042604- /* signal SEP */26052605- sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR0_REG_ADDR,26062606- 0x1);30133013+ /* signal SEP */30143014+ sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR0_REG_ADDR, 0x1);2607301526082608- do {26092609- reg_val = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR3_REG_ADDR);26102610- } while (!(reg_val & 0xFFFFFFFD));30163016+ do {30173017+ reg_val = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR3_REG_ADDR);30183018+ } while (!(reg_val & 0xFFFFFFFD));2611301926122612- dbg("SEP Driver:--------> sep_init_handler - finished waiting for reg_val & 0xFFFFFFFD \n");30203020+ dbg("SEP Driver:--------> sep_init_handler - finished waiting for reg_val & 0xFFFFFFFD \n");2613302126142614- /* check the value */26152615- if (reg_val == 0x1) {26162616- edbg(26172617- "SEP Driver:init failed\n");30223022+ /* check the value */30233023+ if (reg_val == 0x1) {30243024+ edbg("SEP Driver:init failed\n");2618302526192619- error = sep_read_reg(sep_dev, 0x8060);26202620- edbg(26212621- "SEP Driver:sw monitor is %lu\n",26222622- error);30263026+ error = sep_read_reg(sep_dev, 0x8060);30273027+ edbg("SEP Driver:sw monitor is %lu\n", error);2623302826242624- /* fatal error - read erro status from GPRO */26252625- error = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR);26262626- edbg(26272627- "SEP Driver:error is %lu\n", error);26282628- goto end_function;26292629- }30293029+ /* fatal error - read erro status from GPRO */30303030+ error = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR);30313031+ edbg("SEP Driver:error is %lu\n", error);30323032+ goto end_function;30333033+ }2630303426312631-end_function:30353035+ end_function:2632303626332633- dbg("SEP Driver:<-------- sep_init_handler end\n");30373037+ dbg("SEP Driver:<-------- sep_init_handler end\n");2634303826352635- return error;30393039+ return error;2636304026373041}26383042···26303056*/26313057static int sep_realloc_cache_resident_handler(unsigned long arg)26323058{26332633- /* error */26342634- int error;30593059+ /* error */30603060+ int error;2635306126362636- /* physical cache addr */26372637- unsigned long phys_cache_address;30623062+ /* physical cache addr */30633063+ unsigned long phys_cache_address;2638306426392639- /* physical resident addr */26402640- unsigned long phys_resident_address;30653065+ /* physical resident addr */30663066+ unsigned long phys_resident_address;2641306726422642- /* command arguments */26432643- struct sep_driver_realloc_cache_resident_t command_args;30683068+ /* command arguments */30693069+ struct sep_driver_realloc_cache_resident_t command_args;2644307026453071 /*------------------26463072 CODE26473073 ---------------------*/2648307426492649- /* copy the data */26502650- error = copy_from_user(&command_args,26512651- (void *)arg,26522652- sizeof(struct sep_driver_realloc_cache_resident_t));26532653- if (error)26542654- goto end_function;30753075+ /* copy the data */30763076+ error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_realloc_cache_resident_t));30773077+ if (error)30783078+ goto end_function;2655307926562656- /* copy cache and resident to the their intended locations */26572657- error = sep_copy_cache_resident_to_area(command_args.cache_addr,26582658- command_args.cache_size_in_bytes,26592659- command_args.resident_addr,26602660- command_args.resident_size_in_bytes,26612661- &phys_cache_address,26622662- &phys_resident_address);26632663- if (error)26642664- goto end_function;30803080+ /* copy cache and resident to the their intended locations */30813081+ 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);30823082+ if (error)30833083+ goto end_function;2665308426662666- /* lock the area (if needed) */26672667- sep_lock_cache_resident_area();30853085+ /* lock the area (if needed) */30863086+ sep_lock_cache_resident_area();2668308726692669- command_args.new_base_addr = sep_dev->phys_shared_area_addr;30883088+ command_args.new_base_addr = sep_dev->phys_shared_area_addr;2670308926712671- /* find the new base address according to the lowest address between26722672- cache, resident and shared area */26732673- if (phys_resident_address < command_args.new_base_addr)26742674- command_args.new_base_addr = phys_resident_address;26752675- if (phys_cache_address < command_args.new_base_addr)26762676- command_args.new_base_addr = phys_cache_address;30903090+ /* find the new base address according to the lowest address between30913091+ cache, resident and shared area */30923092+ if (phys_resident_address < command_args.new_base_addr)30933093+ command_args.new_base_addr = phys_resident_address;30943094+ if (phys_cache_address < command_args.new_base_addr)30953095+ command_args.new_base_addr = phys_cache_address;2677309626782678- /* set the return parameters */26792679- command_args.new_cache_addr = phys_cache_address;26802680- command_args.new_resident_addr = phys_resident_address;30973097+ /* set the return parameters */30983098+ command_args.new_cache_addr = phys_cache_address;30993099+ command_args.new_resident_addr = phys_resident_address;268131002682310126832683- /* set the new shared area */26842684- command_args.new_shared_area_addr = sep_dev->phys_shared_area_addr;31023102+ /* set the new shared area */31033103+ command_args.new_shared_area_addr = sep_dev->phys_shared_area_addr;2685310426862686- edbg(26872687- "SEP Driver:command_args.new_shared_area_addr is %08lx\n",26882688- command_args.new_shared_area_addr);26892689- edbg(26902690- "SEP Driver:command_args.new_base_addr is %08lx\n",26912691- command_args.new_base_addr);26922692- edbg(26932693- "SEP Driver:command_args.new_resident_addr is %08lx\n",26942694- command_args.new_resident_addr);26952695- edbg(26962696- "SEP Driver:command_args.new_cache_addr is %08lx\n",26972697- command_args.new_cache_addr);31053105+ edbg("SEP Driver:command_args.new_shared_area_addr is %08lx\n", command_args.new_shared_area_addr);31063106+ edbg("SEP Driver:command_args.new_base_addr is %08lx\n", command_args.new_base_addr);31073107+ edbg("SEP Driver:command_args.new_resident_addr is %08lx\n", command_args.new_resident_addr);31083108+ edbg("SEP Driver:command_args.new_cache_addr is %08lx\n", command_args.new_cache_addr);2698310926992699- /* return to user */27002700- error = copy_to_user((void *)arg,27012701- (void *)&command_args,27022702- sizeof(struct sep_driver_realloc_cache_resident_t));31103110+ /* return to user */31113111+ error = copy_to_user((void *) arg, (void *) &command_args, sizeof(struct sep_driver_realloc_cache_resident_t));2703311227042704-end_function:31133113+ end_function:2705311427062706- return error;31153115+ return error;27073116}2708311727093118/*···26943137*/26953138static int sep_get_time_handler(unsigned long arg)26963139{26972697- /* error */26982698- int error;31403140+ /* error */31413141+ int error;2699314227002700- /* command arguments */27012701- struct sep_driver_get_time_t command_args;31433143+ /* command arguments */31443144+ struct sep_driver_get_time_t command_args;2702314527033146 /*------------------------27043147 CODE27053148 --------------------------*/2706314927072707- error = sep_set_time(&command_args.time_physical_address,27082708- &command_args.time_value);31503150+ error = sep_set_time(&command_args.time_physical_address, &command_args.time_value);2709315127102710- /* return to user */27112711- error = copy_to_user((void *)arg,27122712- (void *)&command_args,27132713- sizeof(struct sep_driver_get_time_t));31523152+ /* return to user */31533153+ error = copy_to_user((void *) arg, (void *) &command_args, sizeof(struct sep_driver_get_time_t));2714315427152715- return error;31553155+ return error;2716315627173157}27183158···27183164*/27193165static int sep_set_api_mode_handler(unsigned long arg)27203166{27212721- /* error */27222722- int error;31673167+ /* error */31683168+ int error;2723316927242724- /* flag */27252725- unsigned long mode_flag;31703170+ /* flag */31713171+ unsigned long mode_flag;2726317227273173 /*----------------------------27283174 CODE27293175 -----------------------------*/2730317627312731- dbg("SEP Driver:--------> sep_set_api_mode_handler start\n");31773177+ dbg("SEP Driver:--------> sep_set_api_mode_handler start\n");2732317827332733- error = get_user(27342734- mode_flag, &(((struct sep_driver_set_api_mode_t *)arg)->mode));27352735- if (error)27362736- goto end_function;31793179+ error = get_user(mode_flag, &(((struct sep_driver_set_api_mode_t *) arg)->mode));31803180+ if (error)31813181+ goto end_function;2737318227382738- /* set the global flag */27392739- sep_dev->block_mode_flag = mode_flag;31833183+ /* set the global flag */31843184+ sep_dev->block_mode_flag = mode_flag;274031852741318627422742-end_function:31873187+ end_function:2743318827442744- dbg("SEP Driver:<-------- sep_set_api_mode_handler end\n");31893189+ dbg("SEP Driver:<-------- sep_set_api_mode_handler end\n");2745319027462746- return error;31913191+ return error;27473192}2748319327493194/*···27543201 CODE27553202 -----------------------------*/2756320327572757- dbg("SEP Driver:--------> sep_end_transaction_handler start\n");32043204+ dbg("SEP Driver:--------> sep_end_transaction_handler start\n");2758320527592759-#if 0/*!SEP_DRIVER_POLLING_MODE*/27602760- /* close IMR */27612761- sep_write_reg(sep_dev, HW_HOST_IMR_REG_ADDR, 0x7FFF);32063206+#if 0 /*!SEP_DRIVER_POLLING_MODE */32073207+ /* close IMR */32083208+ sep_write_reg(sep_dev, HW_HOST_IMR_REG_ADDR, 0x7FFF);2762320927632763- /* release IRQ line */27642764- free_irq(SEP_DIRVER_IRQ_NUM, &sep_dev->reg_base_address);32103210+ /* release IRQ line */32113211+ free_irq(SEP_DIRVER_IRQ_NUM, &sep_dev->reg_base_address);2765321227662766- /* lock the sep mutex */27672767- mutex_unlock(&sep_mutex);32133213+ /* lock the sep mutex */32143214+ mutex_unlock(&sep_mutex);27683215#endif2769321627702770- dbg("SEP Driver:<-------- sep_end_transaction_handler end\n");32173217+ dbg("SEP Driver:<-------- sep_end_transaction_handler end\n");2771321827722772- return 0;32193219+ return 0;27733220}2774322127753222/* handler for flow done interrupt */27762776-static void sep_flow_done_handler(struct work_struct *work)32233223+static void sep_flow_done_handler(struct work_struct *work)27773224{27782778- /* flow context_ptr */27792779- struct sep_flow_context_t *flow_data_ptr;32253225+ /* flow context_ptr */32263226+ struct sep_flow_context_t *flow_data_ptr;27803227 /*-------------------------27813228 CODE27823229 ---------------------------*/2783323027842784- /* obtain the mutex */27852785- mutex_lock(&sep_mutex);32313231+ /* obtain the mutex */32323232+ mutex_lock(&sep_mutex);2786323327872787- /* get the pointer to context */27882788- flow_data_ptr = (struct sep_flow_context_t *)work;32343234+ /* get the pointer to context */32353235+ flow_data_ptr = (struct sep_flow_context_t *) work;2789323627902790- /* free all the current input tables in sep */27912791- sep_deallocated_flow_tables(&flow_data_ptr->input_tables_in_process);32373237+ /* free all the current input tables in sep */32383238+ sep_deallocated_flow_tables(&flow_data_ptr->input_tables_in_process);2792323927932793- /* free all the current tables output tables in SEP (if needed) */27942794- if (flow_data_ptr->output_tables_in_process.physical_address != 0xffffffff)27952795- sep_deallocated_flow_tables(&flow_data_ptr->output_tables_in_process);32403240+ /* free all the current tables output tables in SEP (if needed) */32413241+ if (flow_data_ptr->output_tables_in_process.physical_address != 0xffffffff)32423242+ sep_deallocated_flow_tables(&flow_data_ptr->output_tables_in_process);2796324327972797- /* check if we have additional tables to be sent to SEP only input27982798- flag may be checked */27992799- if (flow_data_ptr->input_tables_flag) {28002800- /* copy the message to the shared RAM and signal SEP */28012801- memcpy((void *)flow_data_ptr->message,28022802- (void *)sep_dev->shared_area_addr,28032803- flow_data_ptr->message_size_in_bytes);32443244+ /* check if we have additional tables to be sent to SEP only input32453245+ flag may be checked */32463246+ if (flow_data_ptr->input_tables_flag) {32473247+ /* copy the message to the shared RAM and signal SEP */32483248+ memcpy((void *) flow_data_ptr->message, (void *) sep_dev->shared_area_addr, flow_data_ptr->message_size_in_bytes);2804324928052805- sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR2_REG_ADDR, 0x2);28062806- }28072807- mutex_unlock(&sep_mutex);32503250+ sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR2_REG_ADDR, 0x2);32513251+ }32523252+ mutex_unlock(&sep_mutex);28083253}2809325428103255···28113260 the first and last tables of the list28123261*/28133262static int sep_prepare_flow_dma_tables(unsigned long num_virtual_buffers,28142814- unsigned long first_buff_addr,28152815- struct sep_flow_context_t *flow_data_ptr,28162816- struct sep_lli_entry_t *first_table_data_ptr,28172817- struct sep_lli_entry_t *last_table_data_ptr,28182818- bool isKernelVirtualAddress)32633263+ 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)28193264{28202820- /* error */28212821- int error;32653265+ /* error */32663266+ int error;2822326728232823- /* virtaul address of one buffer */28242824- unsigned long virt_buff_addr;32683268+ /* virtaul address of one buffer */32693269+ unsigned long virt_buff_addr;2825327028262826- /* virtual size of one buffer */28272827- unsigned long virt_buff_size;32713271+ /* virtual size of one buffer */32723272+ unsigned long virt_buff_size;2828327328292829- /* table data for each created table */28302830- struct sep_lli_entry_t table_data;32743274+ /* table data for each created table */32753275+ struct sep_lli_entry_t table_data;2831327628322832- /* info entry */28332833- struct sep_lli_entry_t *info_entry_ptr;32773277+ /* info entry */32783278+ struct sep_lli_entry_t *info_entry_ptr;2834327928352835- /* prevouis info entry */28362836- struct sep_lli_entry_t *prev_info_entry_ptr;32803280+ /* prevouis info entry */32813281+ struct sep_lli_entry_t *prev_info_entry_ptr;2837328228382838- /* counter */28392839- unsigned long i;32833283+ /* counter */32843284+ unsigned long i;2840328528413286 /*-------------------------------28423287 CODE28433288 ----------------------------------*/2844328928452845- /* init vars */28462846- error = 0;28472847- prev_info_entry_ptr = 0;32903290+ /* init vars */32913291+ error = 0;32923292+ prev_info_entry_ptr = 0;2848329328492849- /* init the first table to default */28502850- table_data.physical_address = 0xffffffff;28512851- first_table_data_ptr->physical_address = 0xffffffff;28522852- table_data.block_size = 0;32943294+ /* init the first table to default */32953295+ table_data.physical_address = 0xffffffff;32963296+ first_table_data_ptr->physical_address = 0xffffffff;32973297+ table_data.block_size = 0;2853329828542854- for (i = 0; i < num_virtual_buffers; i++) {28552855- /* get the virtual buffer address */28562856- error = get_user(virt_buff_addr, &first_buff_addr);28572857- if (error)28582858- goto end_function;32993299+ for (i = 0; i < num_virtual_buffers; i++) {33003300+ /* get the virtual buffer address */33013301+ error = get_user(virt_buff_addr, &first_buff_addr);33023302+ if (error)33033303+ goto end_function;2859330428602860- /* get the virtual buffer size */28612861- first_buff_addr++;28622862- error = get_user(virt_buff_size, &first_buff_addr);28632863- if (error)28642864- goto end_function;33053305+ /* get the virtual buffer size */33063306+ first_buff_addr++;33073307+ error = get_user(virt_buff_size, &first_buff_addr);33083308+ if (error)33093309+ goto end_function;2865331028662866- /* advance the address to point to the next pair of address|size */28672867- first_buff_addr++;33113311+ /* advance the address to point to the next pair of address|size */33123312+ first_buff_addr++;2868331328692869- /* now prepare the one flow LLI table from the data */28702870- error = sep_prepare_one_flow_dma_table(virt_buff_addr,28712871- virt_buff_size,28722872- &table_data,28732873- &info_entry_ptr,28742874- flow_data_ptr,28752875- isKernelVirtualAddress);28762876- if (error)28772877- goto end_function;33143314+ /* now prepare the one flow LLI table from the data */33153315+ error = sep_prepare_one_flow_dma_table(virt_buff_addr, virt_buff_size, &table_data, &info_entry_ptr, flow_data_ptr, isKernelVirtualAddress);33163316+ if (error)33173317+ goto end_function;2878331828792879- if (i == 0) {28802880- /* if this is the first table - save it to return to the user28812881- application */28822882- *first_table_data_ptr = table_data;33193319+ if (i == 0) {33203320+ /* if this is the first table - save it to return to the user33213321+ application */33223322+ *first_table_data_ptr = table_data;2883332328842884- /* set the pointer to info entry */28852885- prev_info_entry_ptr = info_entry_ptr;28862886- } else {28872887- /* not first table - the previous table info entry should28882888- be updated */28892889- prev_info_entry_ptr->block_size =28902890- (0x1 << SEP_INT_FLAG_OFFSET_IN_BITS) |28912891- (table_data.block_size);33243324+ /* set the pointer to info entry */33253325+ prev_info_entry_ptr = info_entry_ptr;33263326+ } else {33273327+ /* not first table - the previous table info entry should33283328+ be updated */33293329+ prev_info_entry_ptr->block_size = (0x1 << SEP_INT_FLAG_OFFSET_IN_BITS) | (table_data.block_size);2892333028932893- /* set the pointer to info entry */28942894- prev_info_entry_ptr = info_entry_ptr;33313331+ /* set the pointer to info entry */33323332+ prev_info_entry_ptr = info_entry_ptr;33333333+ }28953334 }28962896- }2897333528982898- /* set the last table data */28992899- *last_table_data_ptr = table_data;33363336+ /* set the last table data */33373337+ *last_table_data_ptr = table_data;2900333829012901-end_function:33393339+ end_function:2902334029032903- return error;33413341+ return error;29043342}2905334329063344···28973357 This function creates one DMA table for flow and returns its data,28983358 and pointer to its info entry28993359*/29002900-static int sep_prepare_one_flow_dma_table(29012901- unsigned long virt_buff_addr,29022902- unsigned long virt_buff_size,29032903- struct sep_lli_entry_t *table_data,29042904- struct sep_lli_entry_t **info_entry_ptr,29052905- struct sep_flow_context_t *flow_data_ptr,29062906- bool isKernelVirtualAddress)33603360+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)29073361{29082908- /* error */29092909- int error;33623362+ /* error */33633363+ int error;2910336429112911- /* the range in pages */29122912- unsigned long lli_array_size;33653365+ /* the range in pages */33663366+ unsigned long lli_array_size;2913336729142914- /* array of pointers ot page */29152915- struct sep_lli_entry_t *lli_array;33683368+ /* array of pointers ot page */33693369+ struct sep_lli_entry_t *lli_array;2916337029172917- /* pointer to the entry in the dma table */29182918- struct sep_lli_entry_t *flow_dma_table_entry_ptr;33713371+ /* pointer to the entry in the dma table */33723372+ struct sep_lli_entry_t *flow_dma_table_entry_ptr;2919337329202920- /* address of the dma table */29212921- unsigned long *start_dma_table_ptr;33743374+ /* address of the dma table */33753375+ unsigned long *start_dma_table_ptr;2922337629232923- /* total table data counter */29242924- unsigned long dma_table_data_count;33773377+ /* total table data counter */33783378+ unsigned long dma_table_data_count;2925337929262926- /* pointer that will keep the pointer t the pages of the virtual buffer */29272927- struct page **page_array_ptr;33803380+ /* pointer that will keep the pointer t the pages of the virtual buffer */33813381+ struct page **page_array_ptr;2928338229292929- /* counter */29302930- unsigned long entry_count;33833383+ /* counter */33843384+ unsigned long entry_count;2931338529323386 /*-------------------------------29333387 CODE29343388 ----------------------------------*/2935338929362936- /* find the space for the new table */29372937- error = sep_find_free_flow_dma_table_space(&start_dma_table_ptr);29382938- if (error)29392939- goto end_function;33903390+ /* find the space for the new table */33913391+ error = sep_find_free_flow_dma_table_space(&start_dma_table_ptr);33923392+ if (error)33933393+ goto end_function;2940339429412941- /* check if the pages are in Kernel Virtual Address layout */29422942- if (isKernelVirtualAddress == true)29432943- /* lock kernel buffer in the memory */29442944- error = sep_lock_kernel_pages(virt_buff_addr,29452945- virt_buff_size,29462946- &lli_array_size,29472947- &lli_array,29482948- &page_array_ptr);29492949- else29502950- /* lock user buffer in the memory */29512951- error = sep_lock_user_pages(virt_buff_addr,29522952- virt_buff_size,29532953- &lli_array_size,29542954- &lli_array,29552955- &page_array_ptr);33953395+ /* check if the pages are in Kernel Virtual Address layout */33963396+ if (isKernelVirtualAddress == true)33973397+ /* lock kernel buffer in the memory */33983398+ error = sep_lock_kernel_pages(virt_buff_addr, virt_buff_size, &lli_array_size, &lli_array, &page_array_ptr);33993399+ else34003400+ /* lock user buffer in the memory */34013401+ error = sep_lock_user_pages(virt_buff_addr, virt_buff_size, &lli_array_size, &lli_array, &page_array_ptr);2956340229572957- if (error)29582958- goto end_function;34033403+ if (error)34043404+ goto end_function;2959340529602960- /* set the pointer to page array at the beginning of table - this table is29612961- now considered taken */29622962- *start_dma_table_ptr = lli_array_size;34063406+ /* set the pointer to page array at the beginning of table - this table is34073407+ now considered taken */34083408+ *start_dma_table_ptr = lli_array_size;2963340929642964- /* point to the place of the pages pointers of the table */29652965- start_dma_table_ptr++;34103410+ /* point to the place of the pages pointers of the table */34113411+ start_dma_table_ptr++;2966341229672967- /* set the pages pointer */29682968- *start_dma_table_ptr = (unsigned long)page_array_ptr;34133413+ /* set the pages pointer */34143414+ *start_dma_table_ptr = (unsigned long) page_array_ptr;2969341529702970- /* set the pointer to the first entry */29712971- flow_dma_table_entry_ptr = (struct sep_lli_entry_t *)(++start_dma_table_ptr);34163416+ /* set the pointer to the first entry */34173417+ flow_dma_table_entry_ptr = (struct sep_lli_entry_t *) (++start_dma_table_ptr);2972341829732973- /* now create the entries for table */29742974- for (dma_table_data_count = entry_count = 0;29752975- entry_count < lli_array_size;29762976- entry_count++) {29772977- flow_dma_table_entry_ptr->physical_address =29782978- lli_array[entry_count].physical_address;34193419+ /* now create the entries for table */34203420+ for (dma_table_data_count = entry_count = 0; entry_count < lli_array_size; entry_count++) {34213421+ flow_dma_table_entry_ptr->physical_address = lli_array[entry_count].physical_address;2979342229802980- flow_dma_table_entry_ptr->block_size =29812981- lli_array[entry_count].block_size;34233423+ flow_dma_table_entry_ptr->block_size = lli_array[entry_count].block_size;2982342429832983- /* set the total data of a table */29842984- dma_table_data_count += lli_array[entry_count].block_size;34253425+ /* set the total data of a table */34263426+ dma_table_data_count += lli_array[entry_count].block_size;2985342729862986- flow_dma_table_entry_ptr++;29872987- }34283428+ flow_dma_table_entry_ptr++;34293429+ }2988343029892989- /* set the physical address */29902990- table_data->physical_address = virt_to_phys(start_dma_table_ptr);34313431+ /* set the physical address */34323432+ table_data->physical_address = virt_to_phys(start_dma_table_ptr);2991343329922992- /* set the num_entries and total data size */29932993- table_data->block_size = ((lli_array_size + 1) <<29942994- SEP_NUM_ENTRIES_OFFSET_IN_BITS) |29952995- (dma_table_data_count);34343434+ /* set the num_entries and total data size */34353435+ table_data->block_size = ((lli_array_size + 1) << SEP_NUM_ENTRIES_OFFSET_IN_BITS) | (dma_table_data_count);2996343629972997- /* set the info entry */29982998- flow_dma_table_entry_ptr->physical_address = 0xffffffff;29992999- flow_dma_table_entry_ptr->block_size = 0;34373437+ /* set the info entry */34383438+ flow_dma_table_entry_ptr->physical_address = 0xffffffff;34393439+ flow_dma_table_entry_ptr->block_size = 0;3000344030013001- /* set the pointer to info entry */30023002- *info_entry_ptr = flow_dma_table_entry_ptr;34413441+ /* set the pointer to info entry */34423442+ *info_entry_ptr = flow_dma_table_entry_ptr;3003344330043004- /* the array of the lli entries */30053005- kfree(lli_array);34443444+ /* the array of the lli entries */34453445+ kfree(lli_array);3006344630073007-end_function:34473447+ end_function:3008344830093009- return error;34493449+ return error;30103450}3011345130123452···29943474 This function returns pointer to the flow data structure29953475 that conatins the given id29963476*/29972997-static int sep_find_flow_context(29982998- unsigned long flow_id,29992999- struct sep_flow_context_t **flow_data_ptr)34773477+static int sep_find_flow_context(unsigned long flow_id, struct sep_flow_context_t **flow_data_ptr)30003478{30013001- /* count */30023002- unsigned long count;34793479+ /* count */34803480+ unsigned long count;3003348130043004- /* error */30053005- int error;34823482+ /* error */34833483+ int error;3006348430073485 /*-----------------------30083486 CODE30093487 ---------------------------*/3010348830113011- error = 0;34893489+ error = 0;3012349030133013- /*30143014- always search for flow with id default first - in case we30153015- already started working on the flow there can be no situation30163016- when 2 flows are with default flag30173017- */30183018- for (count = 0; count < SEP_DRIVER_NUM_FLOWS; count++) {30193019- if (sep_dev->flows_data_array[count].flow_id == flow_id) {30203020- *flow_data_ptr = &sep_dev->flows_data_array[count];30213021- break;34913491+ /*34923492+ always search for flow with id default first - in case we34933493+ already started working on the flow there can be no situation34943494+ when 2 flows are with default flag34953495+ */34963496+ for (count = 0; count < SEP_DRIVER_NUM_FLOWS; count++) {34973497+ if (sep_dev->flows_data_array[count].flow_id == flow_id) {34983498+ *flow_data_ptr = &sep_dev->flows_data_array[count];34993499+ break;35003500+ }30223501 }30233023- }3024350230253025- if (count == SEP_DRIVER_NUM_FLOWS)30263026- /* no flow found */30273027- error = -ENOMEM;35033503+ if (count == SEP_DRIVER_NUM_FLOWS)35043504+ /* no flow found */35053505+ error = -ENOMEM;3028350630293029- return error;35073507+ return error;30303508}3031350930323510/*30333511 this function find a space for the new flow dma table30343512*/30353035-static int sep_find_free_flow_dma_table_space(30363036- unsigned long **table_address_ptr)35133513+static int sep_find_free_flow_dma_table_space(unsigned long **table_address_ptr)30373514{30383038- /* error */30393039- int error;35153515+ /* error */35163516+ int error;3040351730413041- /* pointer to the id field of the flow dma table */30423042- unsigned long *start_table_ptr;35183518+ /* pointer to the id field of the flow dma table */35193519+ unsigned long *start_table_ptr;3043352030443044- /* start address of the flow dma area */30453045- unsigned long flow_dma_area_start_addr;35213521+ /* start address of the flow dma area */35223522+ unsigned long flow_dma_area_start_addr;3046352330473047- /* end address of the flow dma area */30483048- unsigned long flow_dma_area_end_addr;35243524+ /* end address of the flow dma area */35253525+ unsigned long flow_dma_area_end_addr;3049352630503050- /* maximum table size in words */30513051- unsigned long table_size_in_words;35273527+ /* maximum table size in words */35283528+ unsigned long table_size_in_words;3052352930533530 /*---------------------30543531 CODE30553532 -----------------------*/3056353330573057- error = 0;35343534+ error = 0;3058353530593059- /* find the start address of the flow DMA table area */30603060- flow_dma_area_start_addr = sep_dev->shared_area_addr +30613061- SEP_DRIVER_FLOW_DMA_TABLES_AREA_OFFSET_IN_BYTES;35363536+ /* find the start address of the flow DMA table area */35373537+ flow_dma_area_start_addr = sep_dev->shared_area_addr + SEP_DRIVER_FLOW_DMA_TABLES_AREA_OFFSET_IN_BYTES;3062353830633063- /* set end address of the flow table area */30643064- flow_dma_area_end_addr = flow_dma_area_start_addr +30653065- SEP_DRIVER_FLOW_DMA_TABLES_AREA_SIZE_IN_BYTES;35393539+ /* set end address of the flow table area */35403540+ flow_dma_area_end_addr = flow_dma_area_start_addr + SEP_DRIVER_FLOW_DMA_TABLES_AREA_SIZE_IN_BYTES;3066354130673067- /* set table size in words */30683068- table_size_in_words = SEP_DRIVER_MAX_FLOW_NUM_ENTRIES_IN_TABLE *30693069- (sizeof(struct sep_lli_entry_t) / sizeof(long)) + 2;35423542+ /* set table size in words */35433543+ table_size_in_words = SEP_DRIVER_MAX_FLOW_NUM_ENTRIES_IN_TABLE * (sizeof(struct sep_lli_entry_t) / sizeof(long)) + 2;3070354430713071- /* set the pointer to the start address of DMA area */30723072- start_table_ptr = (unsigned long *)flow_dma_area_start_addr;35453545+ /* set the pointer to the start address of DMA area */35463546+ start_table_ptr = (unsigned long *) flow_dma_area_start_addr;3073354730743074- /* find the space for the next table */30753075- while (((*start_table_ptr & 0x7FFFFFFF) != 0) &&30763076- ((unsigned long)start_table_ptr <30773077- flow_dma_area_end_addr))30783078- start_table_ptr += table_size_in_words;35483548+ /* find the space for the next table */35493549+ while (((*start_table_ptr & 0x7FFFFFFF) != 0) && ((unsigned long) start_table_ptr < flow_dma_area_end_addr))35503550+ start_table_ptr += table_size_in_words;3079355130803080- /* check if we reached the end of floa tables area */30813081- if ((unsigned long)start_table_ptr >= flow_dma_area_end_addr)30823082- error = -1;30833083- else30843084- *table_address_ptr = start_table_ptr;35523552+ /* check if we reached the end of floa tables area */35533553+ if ((unsigned long) start_table_ptr >= flow_dma_area_end_addr)35543554+ error = -1;35553555+ else35563556+ *table_address_ptr = start_table_ptr;3085355730863086- return error;35583558+ return error;30873559}3088356030893561/*···30843572*/30853573static void sep_deallocated_flow_tables(struct sep_lli_entry_t *first_table_ptr)30863574{30873087- /* id poiner */30883088- unsigned long *table_ptr;35753575+ /* id poiner */35763576+ unsigned long *table_ptr;3089357730903090- /* end address of the flow dma area */30913091- unsigned long num_entries;35783578+ /* end address of the flow dma area */35793579+ unsigned long num_entries;3092358030933093- unsigned long num_pages;35813581+ unsigned long num_pages;3094358230953095- /* pages ptr */30963096- struct page **pages_ptr;35833583+ /* pages ptr */35843584+ struct page **pages_ptr;3097358530983098- /* maximum table size in words */30993099- struct sep_lli_entry_t *info_entry_ptr;35863586+ /* maximum table size in words */35873587+ struct sep_lli_entry_t *info_entry_ptr;3100358831013589 /*-------------------------------31023590 CODE31033591 ---------------------------------*/3104359231053105- /* set the pointer to the first table */31063106- table_ptr = (unsigned long *)first_table_ptr->physical_address;35933593+ /* set the pointer to the first table */35943594+ table_ptr = (unsigned long *) first_table_ptr->physical_address;3107359531083108- /* set the num of entries */31093109- num_entries = (first_table_ptr->block_size >> SEP_NUM_ENTRIES_OFFSET_IN_BITS)31103110- & SEP_NUM_ENTRIES_MASK;35963596+ /* set the num of entries */35973597+ num_entries = (first_table_ptr->block_size >> SEP_NUM_ENTRIES_OFFSET_IN_BITS)35983598+ & SEP_NUM_ENTRIES_MASK;3111359931123112- /* go over all the connected tables */31133113- while (*table_ptr != 0xffffffff) {31143114- /* get number of pages */31153115- num_pages = *(table_ptr - 2);36003600+ /* go over all the connected tables */36013601+ while (*table_ptr != 0xffffffff) {36023602+ /* get number of pages */36033603+ num_pages = *(table_ptr - 2);3116360431173117- /* get the pointer to the pages */31183118- pages_ptr = (struct page **)(*(table_ptr - 1));36053605+ /* get the pointer to the pages */36063606+ pages_ptr = (struct page **) (*(table_ptr - 1));3119360731203120- /* free the pages */31213121- sep_free_dma_pages(pages_ptr, num_pages, 1);36083608+ /* free the pages */36093609+ sep_free_dma_pages(pages_ptr, num_pages, 1);3122361031233123- /* goto to the info entry */31243124- info_entry_ptr = ((struct sep_lli_entry_t *)table_ptr) +31253125- (num_entries - 1);36113611+ /* goto to the info entry */36123612+ info_entry_ptr = ((struct sep_lli_entry_t *) table_ptr) + (num_entries - 1);3126361331273127- table_ptr = (unsigned long *)info_entry_ptr->physical_address;31283128- num_entries = (info_entry_ptr->block_size >>31293129- SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK;31303130- }36143614+ table_ptr = (unsigned long *) info_entry_ptr->physical_address;36153615+ num_entries = (info_entry_ptr->block_size >> SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK;36163616+ }3131361731323132- return;36183618+ return;31333619}3134362031353621/*···31353625*/31363626static int sep_set_flow_id_handler(unsigned long arg)31373627{31383138- /* error */31393139- int error;36283628+ /* error */36293629+ int error;3140363031413141- /* flow _id */31423142- unsigned long flow_id;36313631+ /* flow _id */36323632+ unsigned long flow_id;3143363331443144- /* pointer to flow data structre */31453145- struct sep_flow_context_t *flow_data_ptr;36343634+ /* pointer to flow data structre */36353635+ struct sep_flow_context_t *flow_data_ptr;3146363631473637 /*----------------------31483638 CODE31493639 -----------------------*/3150364031513151- dbg("------------>SEP Driver: sep_set_flow_id_handler start\n");36413641+ dbg("------------>SEP Driver: sep_set_flow_id_handler start\n");3152364231533153- error = get_user(flow_id,31543154- &(((struct sep_driver_set_flow_id_t *)arg)->flow_id));31553155- if (error)31563156- goto end_function;36433643+ error = get_user(flow_id, &(((struct sep_driver_set_flow_id_t *) arg)->flow_id));36443644+ if (error)36453645+ goto end_function;3157364631583158- /* find the flow data structure that was just used for creating new flow31593159- - its id should be default */31603160- error = sep_find_flow_context(SEP_TEMP_FLOW_ID, &flow_data_ptr);31613161- if (error)31623162- goto end_function;36473647+ /* find the flow data structure that was just used for creating new flow36483648+ - its id should be default */36493649+ error = sep_find_flow_context(SEP_TEMP_FLOW_ID, &flow_data_ptr);36503650+ if (error)36513651+ goto end_function;3163365231643164- /* set flow id */31653165- flow_data_ptr->flow_id = flow_id;36533653+ /* set flow id */36543654+ flow_data_ptr->flow_id = flow_id;3166365531673167-end_function:36563656+ end_function:3168365731693169- dbg("SEP Driver:<-------- sep_set_flow_id_handler end\n");36583658+ dbg("SEP Driver:<-------- sep_set_flow_id_handler end\n");317036593171366031723172- return error;36613661+ return error;31733662}317436633175366431763665/*31773666 calculates time and sets it at the predefined address31783667*/31793179-static int sep_set_time(unsigned long *address_ptr,31803180- unsigned long *time_in_sec_ptr)36683668+static int sep_set_time(unsigned long *address_ptr, unsigned long *time_in_sec_ptr)31813669{31823182- /* time struct */31833183- struct timeval time;36703670+ /* time struct */36713671+ struct timeval time;3184367231853185- /* address of time in the kernel */31863186- unsigned long time_addr;36733673+ /* address of time in the kernel */36743674+ unsigned long time_addr;318736753188367631893677 /*------------------------31903678 CODE31913679 --------------------------*/3192368031933193- dbg("SEP Driver:--------> sep_set_time start\n");36813681+ dbg("SEP Driver:--------> sep_set_time start\n");319436823195368331963196- do_gettimeofday(&time);36843684+ do_gettimeofday(&time);3197368531983198- /* set value in the SYSTEM MEMORY offset */31993199- time_addr = sep_dev->message_shared_area_addr +32003200- SEP_DRIVER_SYSTEM_TIME_MEMORY_OFFSET_IN_BYTES;36863686+ /* set value in the SYSTEM MEMORY offset */36873687+ time_addr = sep_dev->message_shared_area_addr + SEP_DRIVER_SYSTEM_TIME_MEMORY_OFFSET_IN_BYTES;3201368832023202- *(unsigned long *)time_addr = SEP_TIME_VAL_TOKEN;32033203- *(unsigned long *)(time_addr + 4) = time.tv_sec;36893689+ *(unsigned long *) time_addr = SEP_TIME_VAL_TOKEN;36903690+ *(unsigned long *) (time_addr + 4) = time.tv_sec;3204369132053205- edbg(32063206- "SEP Driver:time.tv_sec is %lu\n",32073207- time.tv_sec);32083208- edbg(32093209- "SEP Driver:time_addr is %lu\n",32103210- time_addr);32113211- edbg(32123212- "SEP Driver:g_message_shared_area_addr is %lu\n",32133213- sep_dev->message_shared_area_addr);36923692+ edbg("SEP Driver:time.tv_sec is %lu\n", time.tv_sec);36933693+ edbg("SEP Driver:time_addr is %lu\n", time_addr);36943694+ edbg("SEP Driver:g_message_shared_area_addr is %lu\n", sep_dev->message_shared_area_addr);3214369532153215- /* set the output parameters if needed */32163216- if (address_ptr)32173217- *address_ptr = sep_shared_area_virt_to_phys(time_addr);36963696+ /* set the output parameters if needed */36973697+ if (address_ptr)36983698+ *address_ptr = sep_shared_area_virt_to_phys(time_addr);3218369932193219- if (time_in_sec_ptr)32203220- *time_in_sec_ptr = time.tv_sec;37003700+ if (time_in_sec_ptr)37013701+ *time_in_sec_ptr = time.tv_sec;3221370232223222- dbg("SEP Driver:<-------- sep_set_time end\n");37033703+ dbg("SEP Driver:<-------- sep_set_time end\n");3223370432243224- return 0;37053705+ return 0;32253706}3226370732273708static void sep_wait_busy(struct sep_device *dev)···3232373132333732#define HW_AHB_RD_WR_BURSTS_REG_ADDR 0x0E10UL3234373332353235- dbg("SEP Driver:<-------- sep_configure_dma_burst start \n");37343734+ dbg("SEP Driver:<-------- sep_configure_dma_burst start \n");3236373532373237- /* request access to registers from SEP */32383238- sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR0_REG_ADDR, 0x2);37363736+ /* request access to registers from SEP */37373737+ sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR0_REG_ADDR, 0x2);3239373832403240- dbg("SEP Driver:<-------- sep_configure_dma_burst finished request access to registers from SEP (write reg) \n");37393739+ dbg("SEP Driver:<-------- sep_configure_dma_burst finished request access to registers from SEP (write reg) \n");3241374032423242- sep_wait_busy(sep_dev);37413741+ sep_wait_busy(sep_dev);3243374232443244- dbg("SEP Driver:<-------- sep_configure_dma_burst finished request access to registers from SEP (while(revVal) wait loop) \n");37433743+ dbg("SEP Driver:<-------- sep_configure_dma_burst finished request access to registers from SEP (while(revVal) wait loop) \n");3245374432463246- /* set the DMA burst register to single burst*/32473247- sep_write_reg(sep_dev, HW_AHB_RD_WR_BURSTS_REG_ADDR, 0x0UL);37453745+ /* set the DMA burst register to single burst */37463746+ sep_write_reg(sep_dev, HW_AHB_RD_WR_BURSTS_REG_ADDR, 0x0UL);3248374732493249- /* release the sep busy */32503250- sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR0_REG_ADDR, 0x0UL);32513251- sep_wait_busy(sep_dev);37483748+ /* release the sep busy */37493749+ sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR0_REG_ADDR, 0x0UL);37503750+ sep_wait_busy(sep_dev);3252375132533253- dbg("SEP Driver:<-------- sep_configure_dma_burst done \n");37523752+ dbg("SEP Driver:<-------- sep_configure_dma_burst done \n");3254375332553754}32563755