From patchwork Mon Jan 15 18:13:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 124553 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp752343lje; Mon, 15 Jan 2018 10:15:33 -0800 (PST) X-Google-Smtp-Source: ACJfBou1G7NOmy7LiOlOIT9ZECNy7VLhLPMhTZuKIyywB1HB6tFwM77KE3zISDIBgHmLsKy1w77t X-Received: by 10.98.91.193 with SMTP id p184mr31859360pfb.16.1516040132852; Mon, 15 Jan 2018 10:15:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516040132; cv=none; d=google.com; s=arc-20160816; b=WCXWdS/99XOOs89vhuu/1TDZY+iK6je2A/kcMkp11EihMwxeF1PKUUxOOVKBff7zhK anxAY27QIPklxxX+G5gO09Yuku/KIgP6UQ5iE1rg97bGXuaVH2DT8OmP6YvgBeFFYlZi hKLw40rO8NXRhdIuKKfJYiYdKfDc5ygdquN5N6JuZLARTv8QGTfjpmszeB+rj2VbYeHZ y/IukDLUJwSn8v3oD7ftelKOHZkjYGsabAPJ+nQBdnQWlm1gGEyWDadL9bGbH/Dr0f4I 9VBhEaVvwGqg88oE/YfxGHtJTxpzXmsnIVaEcpI4Td8ono8RlMHV1bYBkeejfxVQvkM1 EEQA== 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=kryfLUXrqkYFTkmRcT/OGcJCdeodwk6Ibq8PdPElmy/M+COPtSt3MOnEkzoIlnQyDu SEKCeTboaloDNBEsEBDRAfrnTVErFPCYYqaFH0eVGOb27ZXR6kGCKKkbENqLMi401F+U +SnGhs70NNaYKdGRjojuVuoE113xTrJ8XC0H+5vZGjBVJYdA4jeuAEJxstvJqAlXWnFZ g70Uw2hudAsjWOSvSKnjL88e+vdNelD8QjT0hIH/r0CJRaOBkhDwg8q7Q1SEpj9CQZbq jZSAWULJOLC7IZraPdTEDSKTM82RCbSLkZ517PzwNX8PisJVJklTPNlunkVE36i8K6zi 2kpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FSz6CiFY; 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 n6si158561pla.402.2018.01.15.10.15.32; Mon, 15 Jan 2018 10:15:32 -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=FSz6CiFY; 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 S1750997AbeAOSPb (ORCPT + 28 others); Mon, 15 Jan 2018 13:15:31 -0500 Received: from mail-it0-f66.google.com ([209.85.214.66]:44903 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751195AbeAOSNb (ORCPT ); Mon, 15 Jan 2018 13:13:31 -0500 Received: by mail-it0-f66.google.com with SMTP id b5so1849337itc.3 for ; Mon, 15 Jan 2018 10:13:31 -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=FSz6CiFYydxm7TccS1S2U0jrTx0oOcsw8OPm+Z8iRpIIY8yyUwsTQU52i5okUpbByR gAdNmAbFrpyxE0pcoeePhDZ0aagbk/slALx7+r/+PCO6UJk8RptJMch5C4vnz6l2rPcS CdwLkRFdKrpp9Wozm1KP5OxC3+QK3ASlVfHSE= 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=la73DZ1hxdEHJyfJcm3ayA0SrRNVkgfWExoKu+yGjLzWD/pXJj/xbWUd+MftJQ1xO0 A/zmo287cr2K+EVa+2/Rfctikbvo67UMhbQ3k42ataZamRbs/QpTxVfEvzZ3g5Qsgsk/ Q8A6W2MSmzye24IcsXr444v54jVoJ1N9mRBzLcNf0H4HZGzsb5Q9gjFbO1rQgCqMLDda l++9vzPEtOS81B3QIJhG5ZCglvSs4BEx5ODYDcxeYN4Br/nuJogSAcDjCpBOrs4C7Sks Ay8iSR2m0CFAYAYrTGTynsTKDndfgTaxpoaX3W9GX3oNWbu2IqQ/ViGAGHyr2EhMRgNU 5dLA== X-Gm-Message-State: AKwxytdpngLuvzD204U/2yHH2IeMTbypeFBIN0riQklvjDxkGtOR50S6 9YzPcetDXHBTN4KMoWTYjSUs5eJ9Ncw= X-Received: by 10.36.222.66 with SMTP id d63mr13794614itg.99.1516040010732; Mon, 15 Jan 2018 10:13:30 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id w142sm231480ita.25.2018.01.15.10.13.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Jan 2018 10:13:29 -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, jolsa@redhat.com, kim.phillips@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 06/10] perf tools: Add functionality to communicate with the openCSD decoder Date: Mon, 15 Jan 2018 11:13:10 -0700 Message-Id: <1516039994-314-7-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516039994-314-1-git-send-email-mathieu.poirier@linaro.org> References: <1516039994-314-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__ */