/* unlocked read of current trace ID value for given CPU */ staticint _coresight_trace_id_read_cpu_id(int cpu, struct coresight_trace_id_map *id_map)
{ return atomic_read(per_cpu_ptr(id_map->cpu_map, cpu));
}
/* look for next available odd ID, return 0 if none found */ staticint coresight_trace_id_find_odd_id(struct coresight_trace_id_map *id_map)
{ int found_id = 0, bit = 1, next_id;
/* *AllocatenewIDandsetinuse * *if@preferred_idisavalididthentrytousethatvalueifavailable. *if@preferred_idisnotvalidand@prefer_odd_idistrue,tryforoddid. * *OtherwiseallocatenextavailableID.
*/ staticint coresight_trace_id_alloc_new_id(struct coresight_trace_id_map *id_map, int preferred_id, unsignedint flags)
{ int id = 0;
/* for backwards compatibility, cpu IDs may use preferred value */ if (IS_VALID_CS_TRACE_ID(preferred_id)) { if (!test_bit(preferred_id, id_map->used_ids)) {
id = preferred_id; goto trace_id_allocated;
} elseif (flags & TRACE_ID_REQ_STATIC) return -EBUSY;
} elseif (flags & TRACE_ID_PREFER_ODD) { /* may use odd ids to avoid preferred legacy cpu IDs */
id = coresight_trace_id_find_odd_id(id_map); if (id) goto trace_id_allocated;
} elseif (!IS_VALID_CS_TRACE_ID(preferred_id) &&
(flags & TRACE_ID_REQ_STATIC)) return -EINVAL;
/* *skipreservedbit0,lookatbitmaplengthof *CORESIGHT_TRACE_ID_RES_TOPfromoffsetofbit1.
*/
id = find_next_zero_bit(id_map->used_ids, CORESIGHT_TRACE_ID_RES_TOP, 1); if (id >= CORESIGHT_TRACE_ID_RES_TOP) return -EINVAL;
/* mark as used */
trace_id_allocated:
set_bit(id, id_map->used_ids); return id;
}
staticvoid coresight_trace_id_free(int id, struct coresight_trace_id_map *id_map)
{ if (WARN(!IS_VALID_CS_TRACE_ID(id), "Invalid Trace ID %d\n", id)) return; if (WARN(!test_bit(id, id_map->used_ids), "Freeing unused ID %d\n", id)) return;
clear_bit(id, id_map->used_ids);
}
int coresight_trace_id_get_system_id(void)
{ /* prefer odd IDs for system components to avoid legacy CPU IDS */ return coresight_trace_id_map_get_system_id(&id_map_default, 0,
TRACE_ID_PREFER_ODD);
}
EXPORT_SYMBOL_GPL(coresight_trace_id_get_system_id);
int coresight_trace_id_get_static_system_id(int trace_id)
{ return coresight_trace_id_map_get_system_id(&id_map_default,
trace_id, TRACE_ID_REQ_STATIC);
}
EXPORT_SYMBOL_GPL(coresight_trace_id_get_static_system_id);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.