Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions drivers/hwtracing/Kconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# SPDX-License-Identifier: GPL-2.0-only
menu "HW tracing support"

source "drivers/hwtracing/coresight/Kconfig"

source "drivers/hwtracing/stm/Kconfig"

source "drivers/hwtracing/intel_th/Kconfig"
Expand Down
46 changes: 45 additions & 1 deletion drivers/hwtracing/coresight/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
menuconfig CORESIGHT
tristate "CoreSight Tracing Support"
depends on ARM || ARM64
depends on ARM || ARM64 || RISCV
depends on OF || ACPI
select ARM_AMBA
select PERF_EVENTS
Expand Down Expand Up @@ -280,4 +280,48 @@ config CORESIGHT_TNOC
To compile this driver as a module, choose M here: the module will be
called coresight-tnoc.

config RVTRACE
bool "RISC-V Trace Support"
help
This enables support for the RISC-V trace drivers. drivers
(including Trace Encoder, Trace Funnel and ATB Bridge) are
dynamically aggregated with CoreSight trace infrastructure
at run time to form a complete trace path.

config RVTRACE_ATBBRIDGE
tristate "RISCV Trace ATB Bridge driver"
depends on RVTRACE
help
This driver provides support for the ATB Bridge driver. The ATB
Bridge allows sending RISC-V trace to Arm CoreSight infrastructure
(instead of RISC-V compliant sink) as an ATB initiator.

To compile this driver as a module, choose M here: the module
will be called rvtrace-atbbridge.

config RVTRACE_FUNNEL
tristate "RISCV Trace Funnel driver"
depends on RVTRACE
help
his driver provides support for the Trace Funnel driver. The Funnel
aggregates the trace from each of its inputs and sends the combined
trace stream to its designated Trace Sink or ATB Bridge.

To compile this driver as a module, choose M here: the module
will be called rvtrace-funnel.

config RVTRACE_ENCODER
tristate "RISCV Trace Encoder driver"
depends on RVTRACE
select RVTRACE_FUNNEL
select RVTRACE_ATBBRIDGE
help
This driver provides support for the Trace Encoder module, tracing
the instructions that a processor is executing. This is primarily
useful for instruction level tracing. Depending on the implemented
version data tracing may also be available.

To compile this driver as a module, choose M here: the module
will be called rvtrace-encoder.

endif
6 changes: 6 additions & 0 deletions drivers/hwtracing/coresight/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,9 @@ obj-$(CONFIG_CORESIGHT_DUMMY) += coresight-dummy.o
obj-$(CONFIG_CORESIGHT_CTCU) += coresight-ctcu.o
coresight-ctcu-y := coresight-ctcu-core.o
obj-$(CONFIG_CORESIGHT_KUNIT_TESTS) += coresight-kunit-tests.o
obj-$(CONFIG_RVTRACE) += rvtrace.o
rvtrace-y := rvtrace-core.o rvtrace-timestamp.o
obj-$(CONFIG_RVTRACE_ATBBRIDGE) += rvtrace-atbbridge.o
obj-$(CONFIG_RVTRACE_FUNNEL) += rvtrace-funnel.o
obj-$(CONFIG_RVTRACE_ENCODER) += rvtrace-encoder.o
rvtrace-encoder-y := rvtrace-encoder-core.o rvtrace-encoder-sysfs.o
8 changes: 8 additions & 0 deletions drivers/hwtracing/coresight/coresight-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,11 @@ static void coresight_set_self_claim_tag_unlocked(struct coresight_device *csdev
{
csdev_access_relaxed_write32(&csdev->access, CORESIGHT_CLAIM_SELF_HOSTED,
CORESIGHT_CLAIMSET);
#if defined(__riscv)
local_flush_icache_all();
#else
isb();
#endif
}

void coresight_clear_self_claim_tag(struct csdev_access *csa)
Expand All @@ -158,7 +162,11 @@ void coresight_clear_self_claim_tag_unlocked(struct csdev_access *csa)
{
csdev_access_relaxed_write32(csa, CORESIGHT_CLAIM_SELF_HOSTED,
CORESIGHT_CLAIMCLR);
#if defined(__riscv)
local_flush_icache_all();
#else
isb();
#endif
}
EXPORT_SYMBOL_GPL(coresight_clear_self_claim_tag_unlocked);

Expand Down
1 change: 0 additions & 1 deletion drivers/hwtracing/coresight/coresight-etm-perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <linux/mm.h>
#include <linux/init.h>
#include <linux/perf_event.h>
#include <linux/perf/arm_pmu.h>
#include <linux/percpu-defs.h>
#include <linux/slab.h>
#include <linux/stringhash.h>
Expand Down
21 changes: 21 additions & 0 deletions drivers/hwtracing/coresight/coresight-etm-perf.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,27 @@ struct cscfg_config_desc;
#define ATTR_CFG_FLD_cc_threshold_LO 0
#define ATTR_CFG_FLD_cc_threshold_HI 11

#define __GEN_PMU_FORMAT_ATTR(cfg, lo, hi) \
(lo) == (hi) ? #cfg ":" #lo "\n" : #cfg ":" #lo "-" #hi

#define _GEN_PMU_FORMAT_ATTR(cfg, lo, hi) \
__GEN_PMU_FORMAT_ATTR(cfg, lo, hi)

#define GEN_PMU_FORMAT_ATTR(name) \
PMU_FORMAT_ATTR(name, \
_GEN_PMU_FORMAT_ATTR(ATTR_CFG_FLD_##name##_CFG, \
ATTR_CFG_FLD_##name##_LO, \
ATTR_CFG_FLD_##name##_HI))

#define _ATTR_CFG_GET_FLD(attr, cfg, lo, hi) \
((((attr)->cfg) >> lo) & GENMASK_ULL(hi - lo, 0))

#define ATTR_CFG_GET_FLD(attr, name) \
_ATTR_CFG_GET_FLD(attr, \
ATTR_CFG_FLD_##name##_CFG, \
ATTR_CFG_FLD_##name##_LO, \
ATTR_CFG_FLD_##name##_HI)

/**
* struct etm_filter - single instruction range or start/stop configuration.
* @start_addr: The address to start tracing on.
Expand Down
1 change: 0 additions & 1 deletion drivers/hwtracing/coresight/coresight-platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <linux/amba/bus.h>
#include <linux/coresight.h>
#include <linux/cpumask.h>
#include <asm/smp_plat.h>

#include "coresight-priv.h"

Expand Down
4 changes: 4 additions & 0 deletions drivers/hwtracing/coresight/coresight-tmc-etf.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,11 @@ static int tmc_panic_sync_etf(struct coresight_device *csdev)
* Make sure all previous writes are ordered,
* before we mark valid
*/
#if defined(__riscv)
__mb();
#else
dmb(sy);
#endif
mdata->valid = true;
/*
* Below order need to maintained, since crc of metadata
Expand Down
4 changes: 4 additions & 0 deletions drivers/hwtracing/coresight/coresight-tmc-etr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1883,7 +1883,11 @@ static int tmc_panic_sync_etr(struct coresight_device *csdev)
* Make sure all previous writes are ordered,
* before we mark valid
*/
#if defined(__riscv)
__mb();
#else
dmb(sy);
#endif
mdata->valid = true;
/*
* Below order need to maintained, since crc of metadata
Expand Down
Loading
Loading