@@ -18,12 +18,6 @@ static struct coresight_trace_id_map id_map_default = {
1818 .cpu_map = & id_map_default_cpu_ids
1919};
2020
21- /* maintain a record of the pending releases per cpu */
22- static cpumask_t cpu_id_release_pending ;
23-
24- /* perf session active counter */
25- static atomic_t perf_cs_etm_session_active = ATOMIC_INIT (0 );
26-
2721/* lock to protect id_map and cpu data */
2822static DEFINE_SPINLOCK (id_map_lock );
2923
@@ -35,7 +29,6 @@ static void coresight_trace_id_dump_table(struct coresight_trace_id_map *id_map,
3529{
3630 pr_debug ("%s id_map::\n" , func_name );
3731 pr_debug ("Used = %*pb\n" , CORESIGHT_TRACE_IDS_MAX , id_map -> used_ids );
38- pr_debug ("Pend = %*pb\n" , CORESIGHT_TRACE_IDS_MAX , id_map -> pend_rel_ids );
3932}
4033#define DUMP_ID_MAP (map ) coresight_trace_id_dump_table(map, __func__)
4134#define DUMP_ID_CPU (cpu , id ) pr_debug("%s called; cpu=%d, id=%d\n", __func__, cpu, id)
@@ -122,34 +115,18 @@ static void coresight_trace_id_free(int id, struct coresight_trace_id_map *id_ma
122115 clear_bit (id , id_map -> used_ids );
123116}
124117
125- static void coresight_trace_id_set_pend_rel (int id , struct coresight_trace_id_map * id_map )
126- {
127- if (WARN (!IS_VALID_CS_TRACE_ID (id ), "Invalid Trace ID %d\n" , id ))
128- return ;
129- set_bit (id , id_map -> pend_rel_ids );
130- }
131-
132118/*
133- * release all pending IDs for all current maps & clear CPU associations
134- *
135- * This currently operates on the default id map, but may be extended to
136- * operate on all registered id maps if per sink id maps are used.
119+ * Release all IDs and clear CPU associations.
137120 */
138- static void coresight_trace_id_release_all_pending ( void )
121+ static void coresight_trace_id_release_all ( struct coresight_trace_id_map * id_map )
139122{
140- struct coresight_trace_id_map * id_map = & id_map_default ;
141123 unsigned long flags ;
142- int cpu , bit ;
124+ int cpu ;
143125
144126 spin_lock_irqsave (& id_map_lock , flags );
145- for_each_set_bit (bit , id_map -> pend_rel_ids , CORESIGHT_TRACE_ID_RES_TOP ) {
146- clear_bit (bit , id_map -> used_ids );
147- clear_bit (bit , id_map -> pend_rel_ids );
148- }
149- for_each_cpu (cpu , & cpu_id_release_pending ) {
150- atomic_set (per_cpu_ptr (id_map_default .cpu_map , cpu ), 0 );
151- cpumask_clear_cpu (cpu , & cpu_id_release_pending );
152- }
127+ bitmap_zero (id_map -> used_ids , CORESIGHT_TRACE_IDS_MAX );
128+ for_each_possible_cpu (cpu )
129+ atomic_set (per_cpu_ptr (id_map -> cpu_map , cpu ), 0 );
153130 spin_unlock_irqrestore (& id_map_lock , flags );
154131 DUMP_ID_MAP (id_map );
155132}
@@ -164,7 +141,7 @@ static int _coresight_trace_id_get_cpu_id(int cpu, struct coresight_trace_id_map
164141 /* check for existing allocation for this CPU */
165142 id = _coresight_trace_id_read_cpu_id (cpu , id_map );
166143 if (id )
167- goto get_cpu_id_clr_pend ;
144+ goto get_cpu_id_out_unlock ;
168145
169146 /*
170147 * Find a new ID.
@@ -185,11 +162,6 @@ static int _coresight_trace_id_get_cpu_id(int cpu, struct coresight_trace_id_map
185162 /* allocate the new id to the cpu */
186163 atomic_set (per_cpu_ptr (id_map -> cpu_map , cpu ), id );
187164
188- get_cpu_id_clr_pend :
189- /* we are (re)using this ID - so ensure it is not marked for release */
190- cpumask_clear_cpu (cpu , & cpu_id_release_pending );
191- clear_bit (id , id_map -> pend_rel_ids );
192-
193165get_cpu_id_out_unlock :
194166 spin_unlock_irqrestore (& id_map_lock , flags );
195167
@@ -210,15 +182,8 @@ static void _coresight_trace_id_put_cpu_id(int cpu, struct coresight_trace_id_ma
210182
211183 spin_lock_irqsave (& id_map_lock , flags );
212184
213- if (atomic_read (& perf_cs_etm_session_active )) {
214- /* set release at pending if perf still active */
215- coresight_trace_id_set_pend_rel (id , id_map );
216- cpumask_set_cpu (cpu , & cpu_id_release_pending );
217- } else {
218- /* otherwise clear id */
219- coresight_trace_id_free (id , id_map );
220- atomic_set (per_cpu_ptr (id_map -> cpu_map , cpu ), 0 );
221- }
185+ coresight_trace_id_free (id , id_map );
186+ atomic_set (per_cpu_ptr (id_map -> cpu_map , cpu ), 0 );
222187
223188 spin_unlock_irqrestore (& id_map_lock , flags );
224189 DUMP_ID_CPU (cpu , id );
@@ -302,17 +267,17 @@ void coresight_trace_id_put_system_id(int id)
302267}
303268EXPORT_SYMBOL_GPL (coresight_trace_id_put_system_id );
304269
305- void coresight_trace_id_perf_start (void )
270+ void coresight_trace_id_perf_start (struct coresight_trace_id_map * id_map )
306271{
307- atomic_inc (& perf_cs_etm_session_active );
308- PERF_SESSION (atomic_read (& perf_cs_etm_session_active ));
272+ atomic_inc (& id_map -> perf_cs_etm_session_active );
273+ PERF_SESSION (atomic_read (& id_map -> perf_cs_etm_session_active ));
309274}
310275EXPORT_SYMBOL_GPL (coresight_trace_id_perf_start );
311276
312- void coresight_trace_id_perf_stop (void )
277+ void coresight_trace_id_perf_stop (struct coresight_trace_id_map * id_map )
313278{
314- if (!atomic_dec_return (& perf_cs_etm_session_active ))
315- coresight_trace_id_release_all_pending ( );
316- PERF_SESSION (atomic_read (& perf_cs_etm_session_active ));
279+ if (!atomic_dec_return (& id_map -> perf_cs_etm_session_active ))
280+ coresight_trace_id_release_all ( id_map );
281+ PERF_SESSION (atomic_read (& id_map -> perf_cs_etm_session_active ));
317282}
318283EXPORT_SYMBOL_GPL (coresight_trace_id_perf_stop );
0 commit comments