From patchwork Tue Jan 23 13:12:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 125518 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp1751125ljf; Tue, 23 Jan 2018 05:18:06 -0800 (PST) X-Google-Smtp-Source: AH8x224BfqhM6E+b2bDwve8Nv0h8XifPuH54XliojPB6QeXQwGksugzfJRvw5pz889uP3Fj4XviN X-Received: by 2002:a17:902:60c7:: with SMTP id k7-v6mr5735638pln.316.1516713486200; Tue, 23 Jan 2018 05:18:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516713486; cv=none; d=google.com; s=arc-20160816; b=shv5OGZyVeeudaCr+OvJQbw+7+2SIFaax28Y6NnqUY1VXtfd4hNGv280A2ReEFQq0O zG3EoA9imlvABn+kovQQS9I3EvTfHC9E0PXxHtTPUguvctYzdCnm+cAUmhj/ydRzmINq PpnrdMlYyRzabKPxQXcmCmLhDEptuJ1LV/mUXRR25BPdYoKtjzFbgdbn0k8X7sUz1fOd WH1HeaNgaemdhogmgJMCCoVAYhNI7Q6JORrCBkfe1GAuR7EtOgUEn3coBe4OC4NZMYCE ubdF6sv2q3jIdw2DYW7WCnjVzkFqQlkjrDL+R94itzK/Uuo+1xz3lPtMcEWtGMkmKNje obBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:arc-authentication-results; bh=tlkbt5DBAqdaYoN/4XMbNoL9jhTk0GDgTHr1ClvN6PE=; b=MnvuaJefSEtupjY+Jtll89TXvMS2uVmjXa71xS3el4veTvKsbQ9R4eTo5p7fLevLxT MWuNDqHDVmDtM3rXCf6HqDnjYdBdOKQMGMREm3M9NoOran7tJQkkK6NPS6TaVx+9gpVJ hWJRe+3yv2GUc+bgDrsoJJXlYKdiPdAZZpI982TipCd1WRM7N8bj8cvwFQLP2EbG/C6q z0ztQ9ZWw5Ygf4R3muZ/q/rpbr+y6+uzmasthtEB1+1gEwgjbdHST0q5nXzAfIjAQxbA FldK/X5yVAbyCo84OR8NVWq01GVWUTrFSoLlWA7AkDI7yWWjmTqKVWY1uu2gq1+oAt+E ZLGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s124si4979015pgc.386.2018.01.23.05.18.05; Tue, 23 Jan 2018 05:18:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752487AbeAWNRT (ORCPT + 28 others); Tue, 23 Jan 2018 08:17:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:47318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751868AbeAWNOV (ORCPT ); Tue, 23 Jan 2018 08:14:21 -0500 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 45F002178D; Tue, 23 Jan 2018 13:14:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 45F002178D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=acme@kernel.org From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Mathieu Poirier , Adrian Hunter , Alexander Shishkin , Kim Phillips , Mike Leach , Namhyung Kim , Peter Zijlstra , Suzuki Poulouse , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 33/43] perf tools: Add functionality to communicate with the openCSD decoder Date: Tue, 23 Jan 2018 10:12:41 -0300 Message-Id: <20180123131251.28197-34-acme@kernel.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180123131251.28197-1-acme@kernel.org> References: <20180123131251.28197-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Poirier 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 Signed-off-by: Mathieu Poirier Acked-by: Jiri Olsa Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Kim Phillips Cc: Mike Leach Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Suzuki Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/1516211539-5166-7-git-send-email-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- 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(+) -- 2.14.3 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__ */