From patchwork Fri Dec 15 16:44:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 122125 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp707006qgn; Fri, 15 Dec 2017 08:45:55 -0800 (PST) X-Google-Smtp-Source: ACJfBosJfcszdvT56HiEXvbRJAHS8r1afu5wEBs6qFuG7wRWW2aEskdMdM1WynL02wi9lWCk2nMO X-Received: by 10.84.135.101 with SMTP id 92mr14445830pli.172.1513356355002; Fri, 15 Dec 2017 08:45:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513356354; cv=none; d=google.com; s=arc-20160816; b=u7y6U8DQ26xgh5wx67dx5GfXbWs3PGVRGB4OmDNqwMAp7ZpzbuxvJoO4+sNvXx/TJE C9ZDI48VbuhckUSu6XCARIZUXM2qlM0Li8iV3IAed8RC3AsCizZU5tv/0Sz1TzoP05Nb Dl7e6C+6/CWGaaWvOo82igijiMtfpeQoew4d95XZ1UI4waFHGhDpWj9zZDxIEKq9ZC1j ZddDC5ScgZLVEMh5J0JoE1d3rQgkrOwHYhcBT0Q473Z9NUTfSV56vNKqMFtaUfE0+hM8 B4IBUB3mI72N66WC3fwW7KTup18MOBZAlKv5tHNdtG/l+lL6G9VA8+2c11i9270B6Ad7 TmnA== 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:dkim-signature:arc-authentication-results; bh=/ZMSClb7LNeJt9fnv4WSWglgut3CZtYd6v/jP/IUU9w=; b=qHxfyCLSEQgFCQj6HbHRjbjwHYzZi5gTd4+CfDUYqUsCCjJU9VUQPCeM3lJOEBXZKq gWXEFox1RUr3Q8v4viTIxbCq8KQB6Czrjo9VVPD7e+kXEE8abkWIHUv70mPlkfuPluk7 xy3vsU3Ser7mQlOTidUTk6a+0iqK8BLYsoseWUluhXqWeVMT3Sx524Y2cnJRjmd+/yET 54g1ZXSJKMNr5Xh+cK4qUEWnpAQ/sNj1giGvWIFN8qy5LFHvkKc/uTNwrKxwGhFt2ZnU rN5cRcqQz7vX2mGuIB5SxcRv3cecrMZLJPMNyk0anCVggFTtc0QmeeDXaFnz0rREiWzN uYZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CKU+myty; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z6si4837219pgz.111.2017.12.15.08.45.54; Fri, 15 Dec 2017 08:45:54 -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; dkim=pass header.i=@linaro.org header.s=google header.b=CKU+myty; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756923AbdLOQpZ (ORCPT + 24 others); Fri, 15 Dec 2017 11:45:25 -0500 Received: from mail-it0-f67.google.com ([209.85.214.67]:44937 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756894AbdLOQpS (ORCPT ); Fri, 15 Dec 2017 11:45:18 -0500 Received: by mail-it0-f67.google.com with SMTP id b5so20960361itc.3 for ; Fri, 15 Dec 2017 08:45:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/ZMSClb7LNeJt9fnv4WSWglgut3CZtYd6v/jP/IUU9w=; b=CKU+myty+SHoNSlkzpOCci7tySJZqeHbVXefD3FD/lsu235ohSHl2FOl289Qxg/apI bFWSHHc1a2zV1ZMWRRdfwjOXEIlCBdQZTVk/aSOyPqrI6chLkYQmXxyc+504YaLiOP0m k3Xzg1RoFZue5584pbxLTBowQhm3tKnndLy5w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/ZMSClb7LNeJt9fnv4WSWglgut3CZtYd6v/jP/IUU9w=; b=NOgUxyW1llWWY/1SGej8oSujaWAE8LaFGP0xZ18YOd2Sc8ikOfmpmfePY80bszk1/q JSxQMKSYG5sbcJP9pYjfJPi0u4KpP+KZE2frjSiFZGjbdjx9tHa9TzWo7+cA7eaBtMsZ sS0g7NB0qH+kTq6Vvkv4ol12s/xniGmBvONsmG2K+NlKm1U4LBX7/+o8WLuH4JxMV8Jg a0gqEekf/fWF7BQ+oXneCoK9x8eqZdtbNyTKdVqAw2tNHiqSWr5PilzBA1yOaCpW4sI1 9CxkotGCmXjDRjKpl0+I0QBk79j5/k+82DuHZnQnZWshTy0O3cykVjHYbL2bVfpoDIeZ SpZg== X-Gm-Message-State: AKGB3mKne92670iXUhpnScmg4sztJ8h2Byi/KMMPLQxrUahHtvkAYVjd 8KH2oZV2TWhxf1DlGMtNXPwkbw== X-Received: by 10.107.137.228 with SMTP id t97mr13528514ioi.18.1513356317418; Fri, 15 Dec 2017 08:45:17 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id q132sm3631732iod.26.2017.12.15.08.45.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Dec 2017 08:45:16 -0800 (PST) From: Mathieu Poirier 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, tor@ti.com, jolsa@redhat.com, mathieu.poirier@linaro.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 06/10] perf tools: Add functionality to communicate with the openCSD decoder Date: Fri, 15 Dec 2017 09:44:55 -0700 Message-Id: <1513356299-26274-7-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513356299-26274-1-git-send-email-mathieu.poirier@linaro.org> References: <1513356299-26274-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 Signed-off-by: Mathieu Poirier --- 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.7.4 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__ */