Lines Matching full:id

12 #include "coresight-trace-id.h"
14 /* Default trace ID map. Used on systems that don't require per sink mappings */
38 #define DUMP_ID_CPU(cpu, id) pr_debug("%s called; cpu=%d, id=%d\n", __func__, cpu, id) argument
39 #define DUMP_ID(id) pr_debug("%s called; id=%d\n", __func__, id) argument
43 #define DUMP_ID(id) argument
44 #define DUMP_ID_CPU(cpu, id) argument
48 /* unlocked read of current trace ID value for given CPU */
54 /* look for next available odd ID, return 0 if none found */
75 * Allocate new ID and set in use
77 * if @preferred_id is a valid id then try to use that value if available.
78 * if @preferred_id is not valid and @prefer_odd_id is true, try for odd id.
80 * Otherwise allocate next available ID.
85 int id = 0; in coresight_trace_id_alloc_new_id() local
90 id = preferred_id; in coresight_trace_id_alloc_new_id()
94 id = coresight_trace_id_find_odd_id(id_map); in coresight_trace_id_alloc_new_id()
95 if (id) in coresight_trace_id_alloc_new_id()
103 id = find_next_zero_bit(id_map->used_ids, CORESIGHT_TRACE_ID_RES_TOP, 1); in coresight_trace_id_alloc_new_id()
104 if (id >= CORESIGHT_TRACE_ID_RES_TOP) in coresight_trace_id_alloc_new_id()
109 set_bit(id, id_map->used_ids); in coresight_trace_id_alloc_new_id()
110 return id; in coresight_trace_id_alloc_new_id()
113 static void coresight_trace_id_free(int id, struct coresight_trace_id_map *id_map) in coresight_trace_id_free() argument
115 if (WARN(!IS_VALID_CS_TRACE_ID(id), "Invalid Trace ID %d\n", id)) in coresight_trace_id_free()
117 if (WARN(!test_bit(id, id_map->used_ids), "Freeing unused ID %d\n", id)) in coresight_trace_id_free()
119 clear_bit(id, id_map->used_ids); in coresight_trace_id_free()
122 static void coresight_trace_id_set_pend_rel(int id, struct coresight_trace_id_map *id_map) in coresight_trace_id_set_pend_rel() argument
124 if (WARN(!IS_VALID_CS_TRACE_ID(id), "Invalid Trace ID %d\n", id)) in coresight_trace_id_set_pend_rel()
126 set_bit(id, id_map->pend_rel_ids); in coresight_trace_id_set_pend_rel()
132 * This currently operates on the default id map, but may be extended to
133 * operate on all registered id maps if per sink id maps are used.
157 int id; in coresight_trace_id_map_get_cpu_id() local
162 id = _coresight_trace_id_read_cpu_id(cpu); in coresight_trace_id_map_get_cpu_id()
163 if (id) in coresight_trace_id_map_get_cpu_id()
167 * Find a new ID. in coresight_trace_id_map_get_cpu_id()
169 * Use legacy values where possible in the dynamic trace ID allocator to in coresight_trace_id_map_get_cpu_id()
173 * If the generated legacy ID is invalid, or not available then the next in coresight_trace_id_map_get_cpu_id()
174 * available dynamic ID will be used. in coresight_trace_id_map_get_cpu_id()
176 id = coresight_trace_id_alloc_new_id(id_map, in coresight_trace_id_map_get_cpu_id()
179 if (!IS_VALID_CS_TRACE_ID(id)) in coresight_trace_id_map_get_cpu_id()
182 /* allocate the new id to the cpu */ in coresight_trace_id_map_get_cpu_id()
183 atomic_set(&per_cpu(cpu_id, cpu), id); in coresight_trace_id_map_get_cpu_id()
186 /* we are (re)using this ID - so ensure it is not marked for release */ in coresight_trace_id_map_get_cpu_id()
188 clear_bit(id, id_map->pend_rel_ids); in coresight_trace_id_map_get_cpu_id()
193 DUMP_ID_CPU(cpu, id); in coresight_trace_id_map_get_cpu_id()
195 return id; in coresight_trace_id_map_get_cpu_id()
201 int id; in coresight_trace_id_map_put_cpu_id() local
204 id = _coresight_trace_id_read_cpu_id(cpu); in coresight_trace_id_map_put_cpu_id()
205 if (!id) in coresight_trace_id_map_put_cpu_id()
212 coresight_trace_id_set_pend_rel(id, id_map); in coresight_trace_id_map_put_cpu_id()
215 /* otherwise clear id */ in coresight_trace_id_map_put_cpu_id()
216 coresight_trace_id_free(id, id_map); in coresight_trace_id_map_put_cpu_id()
221 DUMP_ID_CPU(cpu, id); in coresight_trace_id_map_put_cpu_id()
228 int id; in coresight_trace_id_map_get_system_id() local
232 id = coresight_trace_id_alloc_new_id(id_map, 0, true); in coresight_trace_id_map_get_system_id()
235 DUMP_ID(id); in coresight_trace_id_map_get_system_id()
237 return id; in coresight_trace_id_map_get_system_id()
240 static void coresight_trace_id_map_put_system_id(struct coresight_trace_id_map *id_map, int id) in coresight_trace_id_map_put_system_id() argument
245 coresight_trace_id_free(id, id_map); in coresight_trace_id_map_put_system_id()
248 DUMP_ID(id); in coresight_trace_id_map_put_system_id()
278 void coresight_trace_id_put_system_id(int id) in coresight_trace_id_put_system_id() argument
280 coresight_trace_id_map_put_system_id(&id_map_default, id); in coresight_trace_id_put_system_id()