@@ -18,12 +18,6 @@ static struct coresight_trace_id_map id_map_default = {
18
18
.cpu_map = & id_map_default_cpu_ids
19
19
};
20
20
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
-
27
21
/* lock to protect id_map and cpu data */
28
22
static DEFINE_SPINLOCK (id_map_lock );
29
23
@@ -35,7 +29,6 @@ static void coresight_trace_id_dump_table(struct coresight_trace_id_map *id_map,
35
29
{
36
30
pr_debug ("%s id_map::\n" , func_name );
37
31
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 );
39
32
}
40
33
#define DUMP_ID_MAP (map ) coresight_trace_id_dump_table(map, __func__)
41
34
#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
122
115
clear_bit (id , id_map -> used_ids );
123
116
}
124
117
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
-
132
118
/*
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.
137
120
*/
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 )
139
122
{
140
- struct coresight_trace_id_map * id_map = & id_map_default ;
141
123
unsigned long flags ;
142
- int cpu , bit ;
124
+ int cpu ;
143
125
144
126
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 );
153
130
spin_unlock_irqrestore (& id_map_lock , flags );
154
131
DUMP_ID_MAP (id_map );
155
132
}
@@ -164,7 +141,7 @@ static int _coresight_trace_id_get_cpu_id(int cpu, struct coresight_trace_id_map
164
141
/* check for existing allocation for this CPU */
165
142
id = _coresight_trace_id_read_cpu_id (cpu , id_map );
166
143
if (id )
167
- goto get_cpu_id_clr_pend ;
144
+ goto get_cpu_id_out_unlock ;
168
145
169
146
/*
170
147
* Find a new ID.
@@ -185,11 +162,6 @@ static int _coresight_trace_id_get_cpu_id(int cpu, struct coresight_trace_id_map
185
162
/* allocate the new id to the cpu */
186
163
atomic_set (per_cpu_ptr (id_map -> cpu_map , cpu ), id );
187
164
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
-
193
165
get_cpu_id_out_unlock :
194
166
spin_unlock_irqrestore (& id_map_lock , flags );
195
167
@@ -210,15 +182,8 @@ static void _coresight_trace_id_put_cpu_id(int cpu, struct coresight_trace_id_ma
210
182
211
183
spin_lock_irqsave (& id_map_lock , flags );
212
184
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 );
222
187
223
188
spin_unlock_irqrestore (& id_map_lock , flags );
224
189
DUMP_ID_CPU (cpu , id );
@@ -302,17 +267,17 @@ void coresight_trace_id_put_system_id(int id)
302
267
}
303
268
EXPORT_SYMBOL_GPL (coresight_trace_id_put_system_id );
304
269
305
- void coresight_trace_id_perf_start (void )
270
+ void coresight_trace_id_perf_start (struct coresight_trace_id_map * id_map )
306
271
{
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 ));
309
274
}
310
275
EXPORT_SYMBOL_GPL (coresight_trace_id_perf_start );
311
276
312
- void coresight_trace_id_perf_stop (void )
277
+ void coresight_trace_id_perf_stop (struct coresight_trace_id_map * id_map )
313
278
{
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 ));
317
282
}
318
283
EXPORT_SYMBOL_GPL (coresight_trace_id_perf_stop );
0 commit comments