From patchwork Mon Jul 2 22:33:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 140852 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp464671ljj; Mon, 2 Jul 2018 15:33:44 -0700 (PDT) X-Google-Smtp-Source: AAOMgpejKIymlX0wNKd6kuETMQq8o07L5I9SpSRM27CS8FNe5A2fbKsFa8e9a8XS06G6OhZrPewH X-Received: by 2002:a17:902:24a5:: with SMTP id w34-v6mr14890146pla.52.1530570824366; Mon, 02 Jul 2018 15:33:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530570824; cv=none; d=google.com; s=arc-20160816; b=M/eQXJ5vNo4hO+FCmLxuWFlNRLrKTQBIX45mGTMaKdbCKhaEeVQFyubsuhovFnl5wy 9tlJ1nqc4RvMMje2lYE7UPAKBBSS5ddTi7QZzqmvArIDwx1u5u1OnueDhu/72zEd+C1E V/iyS9AJuMkyAQXe2r9UKxseGvl3wWZEOhx+MOabf8c74wiEw9BAQVM0VKGZuudCdy6q kw1nMJZhjt4xSHM+uVHst1fa+IRs1dQuuu1ukjA0BeDVXIGwaxpMY/d73w4otRo6xa5P qvT18XuWUc8Z9BP6HPFtdeiKICmjmzl5irX8bJPUdsmKCcOE/crz7CVKqh6FtQyZs0Df aavg== 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=DQAmyMFajI++8HwoDa2U9XFg2UmDhXlRNwslkHRjsDM=; b=rqBKn9o8ErkB6iQflk6MN7fnK27Zfb5J/Qxmivu6Pvg4LxeNDUhOgJ0AN51gyLktRa KudceodmDrkyfeeWm79i5rkvyhi1Wg3jQ2tn1aKTkrJ5+7AjDPxYAn87egzjH1WD083m gfNgpV08FLPg0rdXUXs7upgY75DVIpZXHGYTCLh1UTvMTvVY+bgarT6peQUIY9lsMYRF p57LUfMRwCK9A+G5KvR0ZlB+JZObd8PqTiOsDeJMfMxSoq+wamNwSq5N7+PjQ6dpDZ9A Stot+SEgVObDUHHZR5MU4Ent7ri+W+drnL9YUb5iJwvs0p00Ufyjn65G2eDyU+cxG3vM Utyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B9iJPEF9; 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 s25-v6si15325273pgd.188.2018.07.02.15.33.44; Mon, 02 Jul 2018 15:33:44 -0700 (PDT) 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=B9iJPEF9; 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 S932323AbeGBWdl (ORCPT + 31 others); Mon, 2 Jul 2018 18:33:41 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:35392 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932100AbeGBWdi (ORCPT ); Mon, 2 Jul 2018 18:33:38 -0400 Received: by mail-pf0-f196.google.com with SMTP id z9-v6so2053pfh.2 for ; Mon, 02 Jul 2018 15:33:38 -0700 (PDT) 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=DQAmyMFajI++8HwoDa2U9XFg2UmDhXlRNwslkHRjsDM=; b=B9iJPEF9XQXHuelfEi4/d9Hq5rjgt9W7TwvbSTapRurTpsFC9dODOqp3eqL2VsHqPD YeEfFT//XlDlhY9sFRnUAAOa99xyIo5rveYJsEnsXiAdFjSQa/JEHbg415PgRYx/QbV+ 6AsuDVTXjYwc+aC8Nz+eyVNvCGprL0Fi0HNWo= 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=DQAmyMFajI++8HwoDa2U9XFg2UmDhXlRNwslkHRjsDM=; b=SBc8C9It2OHc5H6YZgfFqsNfsk4dfw2uZgnYm/WxtPF5sgcw0u/yfL2FjSjUQVS+uf 5k9LZeJGajFHcnKI8BnevXHccHCJWrq7fqZlTBLZ4yH1M7MJgJJTOuzynjxTQ2/BI8N1 wwmXEeq7JOjLqtHHaj0NsluoGOzWQ2CdddaFA/0OlXD5QF3mPZGIMCe0F9K/e8rDM5JI bdxr7OKZ5U3ZkPU+sb8r5Rug0FxS6RgXQhdx5sdPhHaNrd95D71G4FFutgwbFr6RZa6Q VRzHJ+v8Rm4GSBIe9NDuQ8lsW/HNb0vp0iE19XKPX6s23nrv+tLao24WB0PiuChdxGn9 LlFA== X-Gm-Message-State: APt69E1PXa12MHEkKvg4Ph33t58QvktxS8J6ftIVzNbwqjs2WcyZNJx0 clv60ZKX0vpce6KD7jUFieunUQ== X-Received: by 2002:a62:df82:: with SMTP id d2-v6mr26302759pfl.189.1530570818156; Mon, 02 Jul 2018 15:33:38 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id p11-v6sm21764132pgu.16.2018.07.02.15.33.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Jul 2018 15:33:37 -0700 (PDT) From: Mathieu Poirier To: peterz@infradead.org, acme@kernel.org Cc: mingo@redhat.com, tglx@linutronix.de, alexander.shishkin@linux.intel.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, will.deacon@arm.com, mark.rutland@arm.com, jolsa@redhat.com, namhyung@kernel.org, adrian.hunter@intel.com, ast@kernel.org, gregkh@linuxfoundation.org, hpa@zytor.com, mathieu.poirier@linaro.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/6] perf tools: Make perf_evsel accessible to PMU driver configuration code Date: Mon, 2 Jul 2018 16:33:26 -0600 Message-Id: <1530570810-28929-3-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530570810-28929-1-git-send-email-mathieu.poirier@linaro.org> References: <1530570810-28929-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 Make structure perf_evsel available to the PMU driver configuration code. That way function perf_evsel__apply_drv_config() can be used from within that code and information pertaining to the 'perf_evsel_config_term' is still available. Signed-off-by: Mathieu Poirier --- tools/perf/arch/arm/util/cs-etm.c | 22 +++++++++++++++++++++- tools/perf/arch/arm/util/cs-etm.h | 3 ++- tools/perf/util/drv_configs.c | 30 +++++++----------------------- tools/perf/util/pmu.h | 3 ++- 4 files changed, 32 insertions(+), 26 deletions(-) -- 2.7.4 diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index 2f595cd73da6..d8081c2e6d44 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -635,7 +635,7 @@ static int __printf(2, 3) cs_device__print_file(const char *name, const char *fm return ret; } -int cs_etm_set_drv_config(struct perf_evsel_config_term *term) +static int cs_etm_set_drv_config_term(struct perf_evsel_config_term *term) { int ret; char enable_sink[ENABLE_SINK_MAX]; @@ -649,3 +649,23 @@ int cs_etm_set_drv_config(struct perf_evsel_config_term *term) return 0; } + +int cs_etm_set_drv_config(struct perf_evsel *evsel, + struct perf_evsel_config_term **err_term) +{ + int err = 0; + struct perf_evsel_config_term *term; + + list_for_each_entry(term, &evsel->config_terms, list) { + if (term->type != PERF_EVSEL__CONFIG_TERM_DRV_CFG) + continue; + + err = cs_etm_set_drv_config_term(term); + if (err) { + *err_term = term; + break; + } + } + + return err; +} diff --git a/tools/perf/arch/arm/util/cs-etm.h b/tools/perf/arch/arm/util/cs-etm.h index 1a12e64f5127..a3f8dde6ccef 100644 --- a/tools/perf/arch/arm/util/cs-etm.h +++ b/tools/perf/arch/arm/util/cs-etm.h @@ -10,6 +10,7 @@ #include "../../util/evsel.h" struct auxtrace_record *cs_etm_record_init(int *err); -int cs_etm_set_drv_config(struct perf_evsel_config_term *term); +int cs_etm_set_drv_config(struct perf_evsel *evsel, + struct perf_evsel_config_term **err_term); #endif diff --git a/tools/perf/util/drv_configs.c b/tools/perf/util/drv_configs.c index eec754243f4d..f7c1bcf08549 100644 --- a/tools/perf/util/drv_configs.c +++ b/tools/perf/util/drv_configs.c @@ -25,7 +25,6 @@ perf_evsel__apply_drv_configs(struct perf_evsel *evsel, { bool found = false; int err = 0; - struct perf_evsel_config_term *term; struct perf_pmu *pmu = NULL; while ((pmu = perf_pmu__scan(pmu)) != NULL) @@ -34,29 +33,14 @@ perf_evsel__apply_drv_configs(struct perf_evsel *evsel, break; } - list_for_each_entry(term, &evsel->config_terms, list) { - if (term->type != PERF_EVSEL__CONFIG_TERM_DRV_CFG) - continue; + /* + * No need to continue if we didn't get a match or if there is no + * driver configuration function for this PMU. + */ + if (!found || !pmu->set_drv_config) + return err; - /* - * We have a configuration term, report an error if we - * can't find the PMU or if the PMU driver doesn't support - * cmd line driver configuration. - */ - if (!found || !pmu->set_drv_config) { - err = -EINVAL; - *err_term = term; - break; - } - - err = pmu->set_drv_config(term); - if (err) { - *err_term = term; - break; - } - } - - return err; + return pmu->set_drv_config(evsel, err_term); } int perf_evlist__apply_drv_configs(struct perf_evlist *evlist, diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index 76fecec7b3f9..47f44394042b 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h @@ -29,7 +29,8 @@ struct perf_pmu { struct list_head format; /* HEAD struct perf_pmu_format -> list */ struct list_head aliases; /* HEAD struct perf_pmu_alias -> list */ struct list_head list; /* ELEM */ - int (*set_drv_config) (struct perf_evsel_config_term *term); + int (*set_drv_config) (struct perf_evsel *evsel, + struct perf_evsel_config_term **err_term); }; struct perf_pmu_info {