mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-14 06:35:12 +00:00
338a588e9d
The existing mechanism to assign Trace ID values to sources is limited and does not scale for larger multicore / multi trace source systems. The API introduces functions that reserve IDs based on availabilty represented by a coresight_trace_id_map structure. This records the used and free IDs in a bitmap. CPU bound sources such as ETMs use the coresight_trace_id_get_cpu_id coresight_trace_id_put_cpu_id pair of functions. The API will record the ID associated with the CPU. This ensures that the same ID will be re-used while perf events are active on the CPU. The put_cpu_id function will pend release of the ID until all perf cs_etm sessions are complete. For backward compatibility the functions will attempt to use the same CPU IDs as the legacy system would have used if these are still available. Non-cpu sources, such as the STM can use coresight_trace_id_get_system_id / coresight_trace_id_put_system_id. Signed-off-by: Mike Leach <mike.leach@linaro.org> [ Fix checkpatch warning in drivers/hwtracing/coresight/coresight-trace-id.c ] Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://lore.kernel.org/r/20230116124928.5440-2-mike.leach@linaro.org
58 lines
1.8 KiB
C
58 lines
1.8 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* Copyright(C) 2015 Linaro Limited. All rights reserved.
|
|
* Author: Mathieu Poirier <mathieu.poirier@linaro.org>
|
|
*/
|
|
|
|
#ifndef _LINUX_CORESIGHT_PMU_H
|
|
#define _LINUX_CORESIGHT_PMU_H
|
|
|
|
#define CORESIGHT_ETM_PMU_NAME "cs_etm"
|
|
#define CORESIGHT_ETM_PMU_SEED 0x10
|
|
|
|
/*
|
|
* The legacy Trace ID system based on fixed calculation from the cpu
|
|
* number. This has been replaced by drivers using a dynamic allocation
|
|
* system - but need to retain the legacy algorithm for backward comparibility
|
|
* in certain situations:-
|
|
* a) new perf running on older systems that generate the legacy mapping
|
|
* b) older tools that may not update at the same time as the kernel.
|
|
*/
|
|
#define CORESIGHT_LEGACY_CPU_TRACE_ID(cpu) (0x10 + (cpu * 2))
|
|
|
|
/*
|
|
* Below are the definition of bit offsets for perf option, and works as
|
|
* arbitrary values for all ETM versions.
|
|
*
|
|
* Most of them are orignally from ETMv3.5/PTM's ETMCR config, therefore,
|
|
* ETMv3.5/PTM doesn't define ETMCR config bits with prefix "ETM3_" and
|
|
* directly use below macros as config bits.
|
|
*/
|
|
#define ETM_OPT_BRANCH_BROADCAST 8
|
|
#define ETM_OPT_CYCACC 12
|
|
#define ETM_OPT_CTXTID 14
|
|
#define ETM_OPT_CTXTID2 15
|
|
#define ETM_OPT_TS 28
|
|
#define ETM_OPT_RETSTK 29
|
|
|
|
/* ETMv4 CONFIGR programming bits for the ETM OPTs */
|
|
#define ETM4_CFG_BIT_BB 3
|
|
#define ETM4_CFG_BIT_CYCACC 4
|
|
#define ETM4_CFG_BIT_CTXTID 6
|
|
#define ETM4_CFG_BIT_VMID 7
|
|
#define ETM4_CFG_BIT_TS 11
|
|
#define ETM4_CFG_BIT_RETSTK 12
|
|
#define ETM4_CFG_BIT_VMID_OPT 15
|
|
|
|
static inline int coresight_get_trace_id(int cpu)
|
|
{
|
|
/*
|
|
* A trace ID of value 0 is invalid, so let's start at some
|
|
* random value that fits in 7 bits and go from there. Since
|
|
* the common convention is to have data trace IDs be I(N) + 1,
|
|
* set instruction trace IDs as a function of the CPU number.
|
|
*/
|
|
return (CORESIGHT_ETM_PMU_SEED + (cpu * 2));
|
|
}
|
|
|
|
#endif
|