2021-09-14 18:26:32 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
|
|
/*
|
|
|
|
* Arm v8 Self-Hosted trace support.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2021 ARM Ltd.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __CORESIGHT_SELF_HOSTED_TRACE_H
|
|
|
|
#define __CORESIGHT_SELF_HOSTED_TRACE_H
|
|
|
|
|
|
|
|
#include <asm/sysreg.h>
|
|
|
|
|
|
|
|
static inline u64 read_trfcr(void)
|
|
|
|
{
|
|
|
|
return read_sysreg_s(SYS_TRFCR_EL1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void write_trfcr(u64 val)
|
|
|
|
{
|
|
|
|
write_sysreg_s(val, SYS_TRFCR_EL1);
|
|
|
|
isb();
|
|
|
|
}
|
|
|
|
|
coresight: trbe: Prohibit trace before disabling TRBE
When the TRBE generates an IRQ, we stop the TRBE, collect the trace
and then reprogram the TRBE with the updated buffer pointers, whenever
possible. We might also leave the TRBE disabled, if there is not
enough space left in the buffer. However, we do not touch the ETE at
all during all of this. This means the ETE is only disabled when
the event is disabled later (via irq_work). This is incorrect, as the
ETE trace is still ON without actually being captured and may be routed
to the ATB (even if it is for a short duration).
So, we move the CPU into trace prohibited state always before disabling
the TRBE, upon entering the IRQ handler. The state is restored if the
TRBE is enabled back. Otherwise the trace remains prohibited.
Since, the ETM/ETE driver now controls the TRFCR_EL1 per session, the
tracing can be restored/enabled back when the event is rescheduled
in.
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Leo Yan <leo.yan@linaro.org>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20210923143919.2944311-6-suzuki.poulose@arm.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
2021-09-23 22:39:19 +08:00
|
|
|
static inline u64 cpu_prohibit_trace(void)
|
2021-09-14 18:26:33 +08:00
|
|
|
{
|
|
|
|
u64 trfcr = read_trfcr();
|
|
|
|
|
|
|
|
/* Prohibit tracing at EL0 & the kernel EL */
|
|
|
|
write_trfcr(trfcr & ~(TRFCR_ELx_ExTRE | TRFCR_ELx_E0TRE));
|
coresight: trbe: Prohibit trace before disabling TRBE
When the TRBE generates an IRQ, we stop the TRBE, collect the trace
and then reprogram the TRBE with the updated buffer pointers, whenever
possible. We might also leave the TRBE disabled, if there is not
enough space left in the buffer. However, we do not touch the ETE at
all during all of this. This means the ETE is only disabled when
the event is disabled later (via irq_work). This is incorrect, as the
ETE trace is still ON without actually being captured and may be routed
to the ATB (even if it is for a short duration).
So, we move the CPU into trace prohibited state always before disabling
the TRBE, upon entering the IRQ handler. The state is restored if the
TRBE is enabled back. Otherwise the trace remains prohibited.
Since, the ETM/ETE driver now controls the TRFCR_EL1 per session, the
tracing can be restored/enabled back when the event is rescheduled
in.
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Leo Yan <leo.yan@linaro.org>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20210923143919.2944311-6-suzuki.poulose@arm.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
2021-09-23 22:39:19 +08:00
|
|
|
/* Return the original value of the TRFCR */
|
|
|
|
return trfcr;
|
2021-09-14 18:26:33 +08:00
|
|
|
}
|
2021-09-14 18:26:32 +08:00
|
|
|
#endif /* __CORESIGHT_SELF_HOSTED_TRACE_H */
|