DSPBRIDGE: replace sync_enter/leave_cs with mutexts or spinlocks
PATCH 1/4 DSPBRIDGE: replace sync_enter/leave_cs with mutexts or spinlocks
Quoted 1 line
From
0691223bb8e78186a1651c810f0e5c4e966c38bfMon Sep 17 00:00:00 2001
From: Fernando Guzman Lugo <[email protected]>
Date: Fri, 19 Mar 2010 13:42:19 -0600
Subject: [PATCH] DSPBRIDGE: replace sync_enter/leave_cs with mutexts or spinlocks
This patch replaces sync_enter/leave_cs functions used before as mutext with mutex_lock/unlock functions or with spin_lock/unlock in case of small CS or removes them in case of they are not needed.
Signed-off-by Fernando Guzman Lugo <[email protected]>
--- drivers/dsp/bridge/pmgr/cmm.c | 30 ++-- drivers/dsp/bridge/pmgr/dmm.c | 47 +++---- drivers/dsp/bridge/rmgr/node.c | 269 +++++++++++++++-------------------- drivers/dsp/bridge/rmgr/proc.c | 16 +-- drivers/dsp/bridge/rmgr/strm.c | 10 +-- drivers/dsp/bridge/wmd/io_sm.c | 4 - drivers/dsp/bridge/wmd/tiomap3430.c | 22 +-- 7 files changed, 160 insertions(+), 238 deletions(-)
drivers/dsp/bridge/pmgr/cmm.c +15 -15
@@ -108,7 +108,7 @@ struct cmm_object {/* * Cmm Lock is used to serialize access mem manager for multi-threads. */ -struct sync_csobject *cmm_lock;/* Lock to access cmm mgr */ +struct mutex cmm_lock;/* Lock to access cmm mgr */ struct lst_list *node_free_list_head;/* Free list of memory nodes */ u32 ul_min_block_size;/* Min SM block; default 16 bytes */ u32 dw_page_size;/* Memory Page size (1k/4k) */
@@ -202,7 +202,7 @@ void *cmm_calloc_buf(struct cmm_object *hcmm_mgr, u32 usize, ((usize -1 ) & ~(cmm_mgr_obj->ul_min_block_size -1 )) + cmm_mgr_obj->ul_min_block_size; -sync_enter_cs (cmm_mgr_obj->cmm_lock); +mutex_lock (&cmm_mgr_obj->cmm_lock); pnode =get_free_block (allocator, usize); }if (pnode) {
@@ -240,7 +240,7 @@ void *cmm_calloc_buf(struct cmm_object *hcmm_mgr, u32 usize, *pp_buf_va = (void *)pnode->dw_va; } } -sync_leave_cs (cmm_mgr_obj->cmm_lock); +mutex_unlock (&cmm_mgr_obj->cmm_lock); }return buf_pa; }
@@ -296,7 +296,7 @@ dsp_status cmm_create(OUT struct cmm_object **ph_cmm_mgr, node_free_list_head->head); }if (DSP_SUCCEEDED (status)) - status =sync_initialize_cs (&cmm_obj->cmm_lock); +mutex_init (&cmm_obj->cmm_lock);if (DSP_SUCCEEDED (status)) *ph_cmm_mgr = cmm_obj;
@@ -327,7 +327,7 @@ dsp_status cmm_destroy(struct cmm_object *hcmm_mgr, bool bForce) status =DSP_EHANDLE ;return status; } -sync_enter_cs (cmm_mgr_obj->cmm_lock); +mutex_lock (&cmm_mgr_obj->cmm_lock);/* If not force then fail if outstanding allocations exist */ if (!bForce) {/* Check for outstanding memory allocations */
@@ -360,10 +360,10 @@ dsp_status cmm_destroy(struct cmm_object *hcmm_mgr, bool bForce)/* delete NodeFreeList list */ kfree (cmm_mgr_obj->node_free_list_head); } -sync_leave_cs (cmm_mgr_obj->cmm_lock); +mutex_unlock (&cmm_mgr_obj->cmm_lock);if (DSP_SUCCEEDED (status)) {/* delete CS & cmm mgr object */ -sync_delete_cs (cmm_mgr_obj->cmm_lock); +mutex_destroy (&cmm_mgr_obj->cmm_lock);MEM_FREE_OBJECT (cmm_mgr_obj); }return status;
@@ -411,7 +411,7 @@ dsp_status cmm_free_buf(struct cmm_object *hcmm_mgr, void *buf_pa,/* get the allocator for this segment id */ allocator =get_allocator (cmm_mgr_obj, ul_seg_id);if (allocator !=NULL ) { -sync_enter_cs (cmm_mgr_obj->cmm_lock); +mutex_lock (&cmm_mgr_obj->cmm_lock); mnode_obj = (struct cmm_mnode *)lst_first (allocator->in_use_list_head);while (mnode_obj) {
@@ -429,7 +429,7 @@ dsp_status cmm_free_buf(struct cmm_object *hcmm_mgr, void *buf_pa,lst_next (allocator->in_use_list_head, (struct list_head *)mnode_obj); } -sync_leave_cs (cmm_mgr_obj->cmm_lock); +mutex_unlock (&cmm_mgr_obj->cmm_lock); }return status; }
@@ -478,7 +478,7 @@ dsp_status cmm_get_info(struct cmm_object *hcmm_mgr, status =DSP_EHANDLE ;return status; } -sync_enter_cs (cmm_mgr_obj->cmm_lock); +mutex_lock (&cmm_mgr_obj->cmm_lock); cmm_info_obj->ul_num_gppsm_segs =0 ;/* # of SM segments */ /* Total # of outstanding alloc */ cmm_info_obj->ul_total_in_use_cnt =0 ;
@@ -519,7 +519,7 @@ dsp_status cmm_get_info(struct cmm_object *hcmm_mgr, } } }/* end for */ -sync_leave_cs (cmm_mgr_obj->cmm_lock); +mutex_unlock (&cmm_mgr_obj->cmm_lock);return status; }
@@ -574,7 +574,7 @@ dsp_status cmm_register_gppsm_seg(struct cmm_object *hcmm_mgr,return status; }/* make sure we have room for another allocator */ -sync_enter_cs (cmm_mgr_obj->cmm_lock); +mutex_lock (&cmm_mgr_obj->cmm_lock); slot_seg =get_slot (cmm_mgr_obj);if (slot_seg <0 ) {/* get a slot number */
@@ -655,7 +655,7 @@ dsp_status cmm_register_gppsm_seg(struct cmm_object *hcmm_mgr, cmm_mgr_obj->pa_gppsm_seg_tab[slot_seg] = psma; func_end: -sync_leave_cs (cmm_mgr_obj->cmm_lock); +mutex_unlock (&cmm_mgr_obj->cmm_lock);return status; }
@@ -679,7 +679,7 @@ dsp_status cmm_un_register_gppsm_seg(struct cmm_object *hcmm_mgr,if ((ul_id >0 ) && (ul_id <=CMM_MAXGPPSEGS )) {while (ul_id <=CMM_MAXGPPSEGS ) { -sync_enter_cs (cmm_mgr_obj->cmm_lock); +mutex_lock (&cmm_mgr_obj->cmm_lock);/* slot = seg_id-1 */ psma = cmm_mgr_obj->pa_gppsm_seg_tab[ul_id -1 ];if (psma !=NULL ) {
@@ -691,7 +691,7 @@ dsp_status cmm_un_register_gppsm_seg(struct cmm_object *hcmm_mgr, }else if (ul_seg_id !=CMM_ALLSEGMENTS ) { status =DSP_EFAIL ; } -sync_leave_cs (cmm_mgr_obj->cmm_lock); +mutex_unlock (&cmm_mgr_obj->cmm_lock);if (ul_seg_id !=CMM_ALLSEGMENTS )break ;
drivers/dsp/bridge/pmgr/dmm.c +17 -30
154 lines not on this page · raw message
drivers/dsp/bridge/rmgr/node.c +115 -154
449 lines not on this page · raw message
drivers/dsp/bridge/rmgr/proc.c +5 -11
@@ -97,7 +97,7 @@ struct proc_object {static u32 refs; -struct sync_csobject *proc_lock;/* For critical sections */ +DEFINE_MUTEX (proc_lock);/* For critical sections */ /* ----------------------------------- Function Prototypes */ static dsp_status proc_monitor (struct proc_object *hprocessor);
@@ -655,9 +655,6 @@ void proc_exit(void) {DBC_REQUIRE (refs >0 ); -if (proc_lock) - (void )sync_delete_cs (proc_lock); - refs--;DBC_ENSURE (refs >=0 );
@@ -780,9 +777,6 @@ bool proc_init(void)DBC_REQUIRE (refs >=0 ); -if (refs ==0 ) - (void )sync_initialize_cs (&proc_lock); -if (ret) refs++;
@@ -1078,7 +1072,7 @@ dsp_status proc_map(void *hprocessor, void *pmpu_addr, u32 ul_size, goto func_end; }/* Critical section */ - (void )sync_enter_cs (proc_lock); +mutex_lock (&proc_lock); status =dmm_get_handle (p_proc_object, &dmm_mgr);if (DSP_SUCCEEDED (status)) status =dmm_map_memory (dmm_mgr, va_align, size_align);
@@ -1097,7 +1091,7 @@ dsp_status proc_map(void *hprocessor, void *pmpu_addr, u32 ul_size, }else {dmm_un_map_memory (dmm_mgr, va_align, &size_align); } - (void )sync_leave_cs (proc_lock); +mutex_unlock (&proc_lock);if (DSP_FAILED (status)) goto func_end;
@@ -1414,7 +1408,7 @@ dsp_status proc_un_map(void *hprocessor, void *map_addr, goto func_end;/* Critical section */ - (void )sync_enter_cs (proc_lock); +mutex_lock (&proc_lock);/* * Update DMM structures. Get the size to unmap. * This function returns error if the VA is not mapped
@@ -1425,7 +1419,7 @@ dsp_status proc_un_map(void *hprocessor, void *map_addr, status = (*p_proc_object->intf_fxns->pfn_brd_mem_un_map) (p_proc_object->hwmd_context, va_align, size_align); } - (void )sync_leave_cs (proc_lock); +mutex_unlock (&proc_lock);if (DSP_FAILED (status)) goto func_end;
drivers/dsp/bridge/rmgr/strm.c +1 -9
@@ -63,7 +63,6 @@ struct strm_mgr {struct dev_object *dev_obj;/* Device for this processor */ struct chnl_mgr *hchnl_mgr;/* Channel manager */ struct bridge_drv_interface *intf_fxns;/* Function interface to WMD */ -struct sync_csobject *sync_obj;/* For critical sections */ };/*
@@ -233,8 +232,6 @@ dsp_status strm_create(OUT struct strm_mgr **phStrmMgr,DBC_ASSERT (strm_mgr_obj->intf_fxns !=NULL ); } } -if (DSP_SUCCEEDED (status)) - status =sync_initialize_cs (&strm_mgr_obj->sync_obj);if (DSP_SUCCEEDED (status)) *phStrmMgr = strm_mgr_obj;
@@ -870,11 +867,6 @@ static dsp_status delete_strm(struct strm_object *hStrm)*/ static void delete_strm_mgr (struct strm_mgr *strm_mgr_obj) { -if (MEM_IS_VALID_HANDLE (strm_mgr_obj,STRMMGR_SIGNATURE )) { - -if (strm_mgr_obj->sync_obj) -sync_delete_cs (strm_mgr_obj->sync_obj); - +if (MEM_IS_VALID_HANDLE (strm_mgr_obj,STRMMGR_SIGNATURE ))MEM_FREE_OBJECT (strm_mgr_obj); - } }
drivers/dsp/bridge/wmd/io_sm.c +0 -4
@@ -102,7 +102,6 @@ struct io_mgr {u8 *msg_output;/* Address of output messages */ u32 usm_buf_size;/* Size of a shared memory I/O channel */ bool shared_irq;/* Is this IRQ shared? */ -struct sync_csobject *hcs_obj;/* Critical section object handle */ u32 word_size;/* Size in bytes of DSP word */ u16 intr_val;/* Interrupt value */ /* Private extnd proc info; mmu setup */
@@ -223,8 +222,6 @@ dsp_status bridge_io_create(OUT struct io_mgr **phIOMgr, pio_mgr->hchnl_mgr = hchnl_mgr; pio_mgr->word_size = pMgrAttrs->word_size; pio_mgr->shared_mem = shared_mem; -if (DSP_SUCCEEDED (status)) - status =sync_initialize_cs (&pio_mgr->hcs_obj);if (dev_type ==DSP_UNIT ) {/* Create an IO DPC */
@@ -282,7 +279,6 @@ dsp_status bridge_io_destroy(struct io_mgr *hio_mgr)#ifndef DSP_TRACEBUF_DISABLED kfree (hio_mgr->pmsg);#endif -sync_delete_cs (hio_mgr->hcs_obj);/* Leak Fix. */ /* Free this IO manager object */ MEM_FREE_OBJECT (hio_mgr); }else {
drivers/dsp/bridge/wmd/tiomap3430.c +7 -15
@@ -168,7 +168,7 @@ struct page_info {/* Attributes used to manage the DSP MMU page tables */ struct pg_table_attrs { -struct sync_csobject *hcs_obj;/* Critical section object handle */ +spinlock_t pg_lock;/* Critical section object handle */ u32 l1_base_pa;/* Physical address of the L1 PT */ u32 l1_base_va;/* Virtual address of the L1 PT */
@@ -1058,10 +1058,8 @@ static dsp_status bridge_dev_create(OUT struct wmd_dev_context **ppDevContext,else status =DSP_EMEMORY ; -if (DSP_SUCCEEDED (status)) - status =sync_initialize_cs (&pt_attrs->hcs_obj); -if (DSP_SUCCEEDED (status)) { +spin_lock_init (&pt_attrs->pg_lock);/* Set the Endianism Register *//* Need to set this */ /* Retrieve the TC u16 SWAP Option */ status = reg_get_value(TCWORDSWAP, (u8 *) &tc_word_swap,
@@ -1083,9 +1081,6 @@ static dsp_status bridge_dev_create(OUT struct wmd_dev_context **ppDevContext, *ppDevContext = dev_context; }else {if (pt_attrs !=NULL ) { -if (pt_attrs->hcs_obj) -sync_delete_cs (pt_attrs->hcs_obj); -kfree (pt_attrs->pg_info);if (pt_attrs->l2_tbl_alloc_va) {
@@ -1181,9 +1176,6 @@ static dsp_status bridge_dev_destroy(struct wmd_dev_context *hDevContext)wmd_brd_delete (dev_context);if (dev_context->pt_attrs) { pt_attrs = dev_context->pt_attrs; -if (pt_attrs->hcs_obj) -sync_delete_cs (pt_attrs->hcs_obj); -kfree (pt_attrs->pg_info);if (pt_attrs->l2_tbl_alloc_va) {
@@ -1618,7 +1610,7 @@ static dsp_status bridge_brd_mem_un_map(struct wmd_dev_context *hDevContext, va_curr += pte_size; pte_addr_l2 += (pte_size >>12 ) *sizeof (u32); } -sync_enter_cs (pt->hcs_obj); +spin_lock (&pt->pg_lock);if (rem_bytes_l2 ==0 ) { pt->pg_info[l2_page_num].num_entries -= pte_count;if (pt->pg_info[l2_page_num].num_entries ==0 ) {
@@ -1631,7 +1623,7 @@ static dsp_status bridge_brd_mem_un_map(struct wmd_dev_context *hDevContext, status =DSP_SOK ; else { status =DSP_EFAIL ; -sync_leave_cs (pt->hcs_obj); +spin_unlock (&pt->pg_lock); goto EXIT_LOOP; } }
@@ -1639,7 +1631,7 @@ static dsp_status bridge_brd_mem_un_map(struct wmd_dev_context *hDevContext, }else status =DSP_EFAIL ; -sync_leave_cs (pt->hcs_obj); +spin_unlock (&pt->pg_lock);continue ; skip_coarse_page:/* va_curr aligned to pte_size? */
@@ -1802,7 +1794,7 @@ static dsp_status pte_set(struct pg_table_attrs *pt, u32 pa, u32 va, }else {return DSP_EFAIL ; } -sync_enter_cs (pt->hcs_obj); +spin_lock (&pt->pg_lock);if (pte_size ==HW_MMU_COARSE_PAGE_SIZE ) {/* Get the L2 PA from the L1 PTE, and find * corresponding L2 VA */
@@ -1850,7 +1842,7 @@ static dsp_status pte_set(struct pg_table_attrs *pt, u32 pa, u32 va, l2_base_pa, l2_page_num, pt->pg_info[l2_page_num].num_entries); } -sync_leave_cs (pt->hcs_obj); +spin_unlock (&pt->pg_lock); }if (DSP_SUCCEEDED (status)) { dev_dbg(bridge, "PTE: pg_tbl_va %x, pa %x, va %x, size %x\n",
--
1.6.0.4