Received: by 10.223.176.5 with SMTP id f5csp2166446wra; Sun, 28 Jan 2018 14:00:37 -0800 (PST) X-Google-Smtp-Source: AH8x226N/vuM5sFyIAaJ4klZXB3Dab/TvlMK/oyY/8WGZKg00va1FyH33u93xtD7O19uyFqaZwmU X-Received: by 2002:a17:902:3363:: with SMTP id a90-v6mr19368997plc.159.1517176836918; Sun, 28 Jan 2018 14:00:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517176836; cv=none; d=google.com; s=arc-20160816; b=bGKvniSKGQNsCJpVDzO5ZnFClnqf7ND6nWmGRN0YWIJ/f8fpQ+t3eZJSOiHCNgAZ0/ uYxceXoSN4Tj0OWC5Qjdyho73H6cx3TjgsxAbERz//c35QjH3oCk3C8QAkBD8FuomHow fXCRIyulL4BawOGPAQ5Ig8qMwX2Vt+n3jG3Knf6NbUQxJ0WTF680BiVMliDBfmrOSbID 0e0uhKUxPhbItZ3TlAhUj+R5NIm0fy3P2ifHA+m/LIFGPDvVZIcglhrKWT2Y5vBN+5yW +qgM3kPaRsA1wKaT0DZ5zC8Xk5br4Xch/7yA0Nt6fKCx3iFtcfuC7pWcC7wgEP/17yOH 2+0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=S6Fb7iH9E24zwQw6WjXrV2d31NephltPyWa3LUxd+wY=; b=YCSKwhNhj9BcRLExwq2HT7GYv9xPLi8+YRdVsgpvfIDcwxGflPsBHadcnb2KZNbFBX fJKzHGiaM7eU558m3HYqlvM2MAkJiT0iUhxiiwPdZug1MCgAuMUz3AoXxYlCtP/AeBk/ YLXjYaeDDMWWK3nmru/o6/lg5km0G8K7JnXW9nkUtdm4a/eTWGGtbR5ghCXs/35kBTGE cGNHuP2BMqvzIuZQXaCMmNBA2Hz30q4JPBPp3xiF/3RLohnR+4D2UjD9vYfsm3aXqdRB QMtriJPrEjjO6WhGzFQ6nV7qAcXjSfQUv7uMTQUAg2WUA3EFcS1g3s/JgnJU6NqtNmyf oIYA== 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 v2-v6si7762271plo.525.2018.01.28.14.00.22; Sun, 28 Jan 2018 14:00:36 -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 S1753337AbeA1VWG (ORCPT + 99 others); Sun, 28 Jan 2018 16:22:06 -0500 Received: from terminus.zytor.com ([65.50.211.136]:57953 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752886AbeA1VWD (ORCPT ); Sun, 28 Jan 2018 16:22:03 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w0SLIOAa008007; Sun, 28 Jan 2018 13:18:24 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w0SLIOCv007997; Sun, 28 Jan 2018 13:18:24 -0800 Date: Sun, 28 Jan 2018 13:18:24 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Mathieu Poirier Message-ID: Cc: tglx@linutronix.de, mike.leach@arm.com, adrian.hunter@intel.com, mathieu.poirier@linaro.org, kim.phillips@arm.com, tor@ti.com, acme@redhat.com, suzuki.poulose@arm.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, peterz@infradead.org, hpa@zytor.com, mingo@kernel.org, namhyung@kernel.org, linux-kernel@vger.kernel.org Reply-To: jolsa@redhat.com, alexander.shishkin@linux.intel.com, acme@redhat.com, suzuki.poulose@arm.com, tor@ti.com, hpa@zytor.com, peterz@infradead.org, namhyung@kernel.org, mingo@kernel.org, linux-kernel@vger.kernel.org, mike.leach@arm.com, tglx@linutronix.de, adrian.hunter@intel.com, mathieu.poirier@linaro.org, kim.phillips@arm.com In-Reply-To: <1516211539-5166-7-git-send-email-mathieu.poirier@linaro.org> References: <1516211539-5166-7-git-send-email-mathieu.poirier@linaro.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Add functionality to communicate with the openCSD decoder Git-Commit-ID: 290598be0e84badee2ce93b32e4146184720b2f4 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 290598be0e84badee2ce93b32e4146184720b2f4 Gitweb: https://git.kernel.org/tip/290598be0e84badee2ce93b32e4146184720b2f4 Author: Mathieu Poirier AuthorDate: Wed, 17 Jan 2018 10:52:15 -0700 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 25 Jan 2018 06:37:26 -0300 perf tools: Add functionality to communicate with the openCSD decoder 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(+) 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 57b020b..1fb0184 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 a1e9b0a..3d2e620 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__ */