Lines Matching full:id

13 #include "coresight-trace-id.h"
15 /* Default trace ID map. Used in sysfs mode and for system sources */
32 #define DUMP_ID_CPU(cpu, id) pr_debug("%s called; cpu=%d, id=%d\n", __func__, cpu, id) argument
33 #define DUMP_ID(id) pr_debug("%s called; id=%d\n", __func__, id) argument
37 #define DUMP_ID(id) argument
38 #define DUMP_ID_CPU(cpu, id) argument
42 /* unlocked read of current trace ID value for given CPU */
48 /* look for next available odd ID, return 0 if none found */
69 * Allocate new ID and set in use
71 * if @preferred_id is a valid id then try to use that value if available.
72 * if @preferred_id is not valid and @prefer_odd_id is true, try for odd id.
74 * Otherwise allocate next available ID.
79 int id = 0; in coresight_trace_id_alloc_new_id() local
84 id = preferred_id; in coresight_trace_id_alloc_new_id()
88 id = coresight_trace_id_find_odd_id(id_map); in coresight_trace_id_alloc_new_id()
89 if (id) in coresight_trace_id_alloc_new_id()
97 id = find_next_zero_bit(id_map->used_ids, CORESIGHT_TRACE_ID_RES_TOP, 1); in coresight_trace_id_alloc_new_id()
98 if (id >= CORESIGHT_TRACE_ID_RES_TOP) in coresight_trace_id_alloc_new_id()
103 set_bit(id, id_map->used_ids); in coresight_trace_id_alloc_new_id()
104 return id; in coresight_trace_id_alloc_new_id()
107 static void coresight_trace_id_free(int id, struct coresight_trace_id_map *id_map) in coresight_trace_id_free() argument
109 if (WARN(!IS_VALID_CS_TRACE_ID(id), "Invalid Trace ID %d\n", id)) in coresight_trace_id_free()
111 if (WARN(!test_bit(id, id_map->used_ids), "Freeing unused ID %d\n", id)) in coresight_trace_id_free()
113 clear_bit(id, id_map->used_ids); in coresight_trace_id_free()
135 int id; in _coresight_trace_id_get_cpu_id() local
140 id = _coresight_trace_id_read_cpu_id(cpu, id_map); in _coresight_trace_id_get_cpu_id()
141 if (id) in _coresight_trace_id_get_cpu_id()
145 * Find a new ID. in _coresight_trace_id_get_cpu_id()
147 * Use legacy values where possible in the dynamic trace ID allocator to in _coresight_trace_id_get_cpu_id()
151 * If the generated legacy ID is invalid, or not available then the next in _coresight_trace_id_get_cpu_id()
152 * available dynamic ID will be used. in _coresight_trace_id_get_cpu_id()
154 id = coresight_trace_id_alloc_new_id(id_map, in _coresight_trace_id_get_cpu_id()
157 if (!IS_VALID_CS_TRACE_ID(id)) in _coresight_trace_id_get_cpu_id()
160 /* allocate the new id to the cpu */ in _coresight_trace_id_get_cpu_id()
161 atomic_set(per_cpu_ptr(id_map->cpu_map, cpu), id); in _coresight_trace_id_get_cpu_id()
166 DUMP_ID_CPU(cpu, id); in _coresight_trace_id_get_cpu_id()
168 return id; in _coresight_trace_id_get_cpu_id()
174 int id; in _coresight_trace_id_put_cpu_id() local
177 id = _coresight_trace_id_read_cpu_id(cpu, id_map); in _coresight_trace_id_put_cpu_id()
178 if (!id) in _coresight_trace_id_put_cpu_id()
183 coresight_trace_id_free(id, id_map); in _coresight_trace_id_put_cpu_id()
187 DUMP_ID_CPU(cpu, id); in _coresight_trace_id_put_cpu_id()
194 int id; in coresight_trace_id_map_get_system_id() local
198 id = coresight_trace_id_alloc_new_id(id_map, 0, true); in coresight_trace_id_map_get_system_id()
201 DUMP_ID(id); in coresight_trace_id_map_get_system_id()
203 return id; in coresight_trace_id_map_get_system_id()
206 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
211 coresight_trace_id_free(id, id_map); in coresight_trace_id_map_put_system_id()
214 DUMP_ID(id); in coresight_trace_id_map_put_system_id()
262 void coresight_trace_id_put_system_id(int id) in coresight_trace_id_put_system_id() argument
264 coresight_trace_id_map_put_system_id(&id_map_default, id); in coresight_trace_id_put_system_id()