linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: acme@kernel.org
Cc: peterz@infradead.org, mingo@redhat.com,
	alexander.shishkin@linux.intel.com, namhyung@kernel.org,
	adrian.hunter@intel.com, mike.leach@arm.com,
	suzuki.poulosi@arm.com, jolsa@redhat.com, kim.phillips@arm.com,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 06/10] perf tools: Add functionality to communicate with the openCSD decoder
Date: Wed, 17 Jan 2018 10:52:15 -0700	[thread overview]
Message-ID: <1516211539-5166-7-git-send-email-mathieu.poirier@linaro.org> (raw)
In-Reply-To: <1516211539-5166-1-git-send-email-mathieu.poirier@linaro.org>

This patch adds functions to communicate with the openCSD trace decoder,
more specifically to access program memory, fetch trace packets and
reset the decoder.

Co-authored-by: Tor Jeremiassen <tor@ti.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 60 +++++++++++++++++++++++++
 tools/perf/util/cs-etm-decoder/cs-etm-decoder.h |  9 ++++
 2 files changed, 69 insertions(+)

diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
index 57b020b0b36f..1fb01849f1c7 100644
--- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
+++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
@@ -45,6 +45,66 @@ struct cs_etm_decoder {
 	struct cs_etm_packet packet_buffer[MAX_BUFFER];
 };
 
+static u32
+cs_etm_decoder__mem_access(const void *context,
+			   const ocsd_vaddr_t address,
+			   const ocsd_mem_space_acc_t mem_space __maybe_unused,
+			   const u32 req_size,
+			   u8 *buffer)
+{
+	struct cs_etm_decoder *decoder = (struct cs_etm_decoder *) context;
+
+	return decoder->mem_access(decoder->data,
+				   address,
+				   req_size,
+				   buffer);
+}
+
+int cs_etm_decoder__add_mem_access_cb(struct cs_etm_decoder *decoder,
+				      u64 start, u64 end,
+				      cs_etm_mem_cb_type cb_func)
+{
+	decoder->mem_access = cb_func;
+
+	if (ocsd_dt_add_callback_mem_acc(decoder->dcd_tree, start, end,
+					 OCSD_MEM_SPACE_ANY,
+					 cs_etm_decoder__mem_access, decoder))
+		return -1;
+
+	return 0;
+}
+
+int cs_etm_decoder__reset(struct cs_etm_decoder *decoder)
+{
+	ocsd_datapath_resp_t dp_ret;
+
+	dp_ret = ocsd_dt_process_data(decoder->dcd_tree, OCSD_OP_RESET,
+				      0, 0, NULL, NULL);
+	if (OCSD_DATA_RESP_IS_FATAL(dp_ret))
+		return -1;
+
+	return 0;
+}
+
+int cs_etm_decoder__get_packet(struct cs_etm_decoder *decoder,
+			       struct cs_etm_packet *packet)
+{
+	if (!decoder || !packet)
+		return -EINVAL;
+
+	/* Nothing to do, might as well just return */
+	if (decoder->packet_count == 0)
+		return 0;
+
+	*packet = decoder->packet_buffer[decoder->head];
+
+	decoder->head = (decoder->head + 1) & (MAX_BUFFER - 1);
+
+	decoder->packet_count--;
+
+	return 1;
+}
+
 static void cs_etm_decoder__gen_etmv4_config(struct cs_etm_trace_params *params,
 					     ocsd_etmv4_cfg *config)
 {
diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h
index a1e9b0ac5965..3d2e6205d186 100644
--- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h
+++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h
@@ -93,4 +93,13 @@ cs_etm_decoder__new(int num_cpu,
 
 void cs_etm_decoder__free(struct cs_etm_decoder *decoder);
 
+int cs_etm_decoder__add_mem_access_cb(struct cs_etm_decoder *decoder,
+				      u64 start, u64 end,
+				      cs_etm_mem_cb_type cb_func);
+
+int cs_etm_decoder__get_packet(struct cs_etm_decoder *decoder,
+			       struct cs_etm_packet *packet);
+
+int cs_etm_decoder__reset(struct cs_etm_decoder *decoder);
+
 #endif /* INCLUDE__CS_ETM_DECODER_H__ */
-- 
2.7.4

  parent reply	other threads:[~2018-01-17 17:52 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-17 17:52 [PATCH v3 00/10] perf tools: Add support for CoreSight trace decoding Mathieu Poirier
2018-01-17 17:52 ` [PATCH v3 01/10] perf tools: Integrating the CoreSight decoding library Mathieu Poirier
2018-01-22 15:40   ` [PATCH] perf tools: Adding missing test file for libopencsd Mathieu Poirier
2018-01-22 16:34     ` Arnaldo Carvalho de Melo
2018-01-24 11:32     ` [tip:perf/core] perf tools: Integrating the CoreSight decoding library tip-bot for Mathieu Poirier
2018-01-28 21:16     ` tip-bot for Mathieu Poirier
2018-01-17 17:52 ` [PATCH v3 02/10] perf tools: Add initial entry point for decoder CoreSight traces Mathieu Poirier
2018-01-24 11:32   ` [tip:perf/core] " tip-bot for Mathieu Poirier
2018-01-28 21:16   ` tip-bot for Mathieu Poirier
2018-01-17 17:52 ` [PATCH v3 03/10] perf tools: Add processing of coresight metadata Mathieu Poirier
2018-01-24 11:33   ` [tip:perf/core] " tip-bot for Tor Jeremiassen
2018-01-28 21:17   ` tip-bot for Tor Jeremiassen
2018-01-17 17:52 ` [PATCH v3 04/10] perf tools: Add decoder mechanic to support dumping trace data Mathieu Poirier
2018-01-24 11:33   ` [tip:perf/core] " tip-bot for Mathieu Poirier
2018-01-28 21:17   ` tip-bot for Mathieu Poirier
2018-01-17 17:52 ` [PATCH v3 05/10] perf tools: Add support for decoding CoreSight " Mathieu Poirier
2018-01-24 11:34   ` [tip:perf/core] " tip-bot for Mathieu Poirier
2018-01-28 21:17   ` tip-bot for Mathieu Poirier
2018-01-17 17:52 ` Mathieu Poirier [this message]
2018-01-24 11:34   ` [tip:perf/core] perf tools: Add functionality to communicate with the openCSD decoder tip-bot for Mathieu Poirier
2018-01-28 21:18   ` tip-bot for Mathieu Poirier
2018-01-17 17:52 ` [PATCH v3 07/10] pert tools: Add queue management functionality Mathieu Poirier
2018-01-22 17:25   ` Robert Walker
2018-01-22 20:14     ` Mathieu Poirier
2018-01-24 11:34   ` [tip:perf/core] " tip-bot for Mathieu Poirier
2018-01-28 21:18   ` tip-bot for Mathieu Poirier
2018-01-17 17:52 ` [PATCH v3 08/10] perf tools: Add full support for CoreSight trace decoding Mathieu Poirier
2018-01-24 11:35   ` [tip:perf/core] " tip-bot for Mathieu Poirier
2018-01-28 21:19   ` tip-bot for Mathieu Poirier
2018-01-17 17:52 ` [PATCH v3 09/10] perf tools: Add mechanic to synthesise CoreSight trace packets Mathieu Poirier
2018-01-24 11:35   ` [tip:perf/core] " tip-bot for Mathieu Poirier
2018-01-28 21:19   ` tip-bot for Mathieu Poirier
2018-01-17 17:52 ` [PATCH v3 10/10] MAINTAINERS: Adding entry for CoreSight trace decoding Mathieu Poirier
2018-01-24 11:36   ` [tip:perf/core] " tip-bot for Tor Jeremiassen
2018-01-28 21:20   ` tip-bot for Tor Jeremiassen
2018-01-17 20:04 ` [PATCH v3 00/10] perf tools: Add support " Arnaldo Carvalho de Melo
2018-01-18 13:36   ` Arnaldo Carvalho de Melo
2018-01-19 15:01 ` Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1516211539-5166-7-git-send-email-mathieu.poirier@linaro.org \
    --to=mathieu.poirier@linaro.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@redhat.com \
    --cc=kim.phillips@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mike.leach@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=suzuki.poulosi@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).