From patchwork Fri Feb 15 00:45:22 2019 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: 158458 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp103647jaa; Thu, 14 Feb 2019 16:47:49 -0800 (PST) X-Google-Smtp-Source: AHgI3IalH/MA5TXFkTFyD4r/y8cYZQDQkIrla0sYHmTK9Gndi0bipQ+4lzh6PNj3ndELO9IZ9fgn X-Received: by 2002:a63:fb15:: with SMTP id o21mr2672655pgh.211.1550191669892; Thu, 14 Feb 2019 16:47:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550191669; cv=none; d=google.com; s=arc-20160816; b=pgKVbd2dO0oIIbpXkj/BpqQ4LpbR6GYAbSGpGoKmTY9H7ozeYJ+WSFksh2XnoJrFYe 3YemGHnjcwXYd/wYtM+dOk1UmcGcNzs6LZniwALN0okpLNEb+Z3CD/hqIlXewyOqy0Wr 57hZyDM6m3rWjSEffpm3DCBHUsU5pd9cknJ3qTGisLtd59ZsB4tbVdy4LQUSR5BNv4WF wybhIzOQ3FqLqoOY41QKamkMx/w5etSlCcD+U/5YbMvFcSUC3o+1pfbjKXeRCNH2im4N a+UJdPtzRWNvw3fv6KrzANJR4Up09yzPKdDOQTeK4BZCtumPmdfWnrzIebxQn37L+qlO BPSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3KvJJb0HlwLfNNhTMsWwoN99m4vniUO50ipUCX9yPeY=; b=0JPkK6/Hzy6+ftF/jlw4fNtT0OBduXm80B0ovOjvh0gD2ODUW3UkTzRR6miRTbWliJ TQpQebA7i8+PWstEaNvG7wMNZRz/5+8jvEdN1Rww2gTrrCvaNOlwDRd/gHWZ0Nwmc2pZ SWFyRuFt8Ha2HyHvRPVfLFHHpEQPyOT7kmU+rtBYOps0LeGp9X81qLnmANJRWmPgt+GQ avtL9sUwhE6xsPKYLLhAHS1MGABXjrHzpaIy+1iYgtA54KsoM7ZiW49Dc77fsIOLfj7W eMuKynk5/Rm6lBYiMBlLD1cDZkWuLWA8C71hR5DbqShp1kaZMGMVaiTz+gO9DFB+6VHy +JZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=e8H1QGzG; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z9si4031375pgf.54.2019.02.14.16.47.49; Thu, 14 Feb 2019 16:47:49 -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=@kernel.org header.s=default header.b=e8H1QGzG; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389412AbfBOArr (ORCPT + 31 others); Thu, 14 Feb 2019 19:47:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:46518 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730479AbfBOArm (ORCPT ); Thu, 14 Feb 2019 19:47:42 -0500 Received: from quaco.ghostprotocols.net (unknown [189.40.103.31]) (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 8039F2229F; Fri, 15 Feb 2019 00:47:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550191661; bh=fbyBVb3RzYOoCKxaDHT5y2hX46bmgahi6LOZy34ChAI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e8H1QGzGRd25kFXby/MbzT65rJrqOkxLv4j3lJaJ6FkqtGWi+BicdKJogzrmHIs2F 6whSfFhd0YHSt2FJPU5LSX0664waxpwPAoPSehhyAxSDLB62Ld0uebSy97uJ6BPGsT 76uatpJge5ylizx7yRvdplFK7As6PVOXBXoQFtV0= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Mathieu Poirier , Jiri Olsa , Leo Yan , Peter Zijlstra , Suzuki K Poulouse , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 26/43] perf cs-etm: Introducing function cs_etm_decoder__init_dparams() Date: Thu, 14 Feb 2019 21:45:22 -0300 Message-Id: <20190215004539.23571-27-acme@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215004539.23571-1-acme@kernel.org> References: <20190215004539.23571-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Poirier Introducing function cs_etm_decoder__init_dparams() to avoid repeating code at two different places. Signed-off-by: Mathieu Poirier Cc: Jiri Olsa Cc: Leo Yan Cc: Peter Zijlstra Cc: Suzuki K Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/20190212171618.25355-5-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- .../perf/util/cs-etm-decoder/cs-etm-decoder.h | 3 +- tools/perf/util/cs-etm.c | 41 +++++++++++++------ 2 files changed, 30 insertions(+), 14 deletions(-) -- 2.19.1 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 7e6a8850be4a..663309486784 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h @@ -105,9 +105,10 @@ enum { CS_ETM_PROTO_PTM, }; -enum { +enum cs_etm_decoder_operation { CS_ETM_OPERATION_PRINT = 1, CS_ETM_OPERATION_DECODE, + CS_ETM_OPERATION_MAX, }; int cs_etm_decoder__process_data_block(struct cs_etm_decoder *decoder, diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index f396fee9bb95..3011c6cae531 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -136,6 +136,28 @@ static void cs_etm__packet_dump(const char *pkt_string) fflush(stdout); } +static int cs_etm__init_decoder_params(struct cs_etm_decoder_params *d_params, + struct cs_etm_queue *etmq, + enum cs_etm_decoder_operation mode) +{ + int ret = -EINVAL; + + if (!(mode < CS_ETM_OPERATION_MAX)) + goto out; + + d_params->packet_printer = cs_etm__packet_dump; + d_params->operation = mode; + d_params->data = etmq; + d_params->formatted = true; + d_params->fsyncs = false; + d_params->hsyncs = false; + d_params->frame_aligned = true; + + ret = 0; +out: + return ret; +} + static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, struct auxtrace_buffer *buffer) { @@ -182,12 +204,9 @@ static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, } /* Set decoder parameters to simply print the trace packets */ - d_params.packet_printer = cs_etm__packet_dump; - d_params.operation = CS_ETM_OPERATION_PRINT; - d_params.formatted = true; - d_params.fsyncs = false; - d_params.hsyncs = false; - d_params.frame_aligned = true; + if (cs_etm__init_decoder_params(&d_params, NULL, + CS_ETM_OPERATION_PRINT)) + return; decoder = cs_etm_decoder__new(etm->num_cpu, &d_params, t_params); @@ -436,13 +455,9 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, } /* Set decoder parameters to simply print the trace packets */ - d_params.packet_printer = cs_etm__packet_dump; - d_params.operation = CS_ETM_OPERATION_DECODE; - d_params.formatted = true; - d_params.fsyncs = false; - d_params.hsyncs = false; - d_params.frame_aligned = true; - d_params.data = etmq; + if (cs_etm__init_decoder_params(&d_params, etmq, + CS_ETM_OPERATION_DECODE)) + goto out_free; etmq->decoder = cs_etm_decoder__new(etm->num_cpu, &d_params, t_params);