From patchwork Wed Nov 28 22:01:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 152354 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1632832ljp; Wed, 28 Nov 2018 14:01:34 -0800 (PST) X-Google-Smtp-Source: AFSGD/U0SvsuFJ9ynu5Wsflg24nkON4p3rs6RoFHZuKArO7tOn2cUIJors9d7+GqEQAXnCJeV0n9 X-Received: by 2002:a17:902:4c85:: with SMTP id b5mr37324210ple.226.1543442493994; Wed, 28 Nov 2018 14:01:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543442493; cv=none; d=google.com; s=arc-20160816; b=lYYuAbzxlcbC6mxelufvquRv0xKqx+TpbhduZeIkcjfGZ1QSmfBMuusCHqVzrqQcUn jlesKXbwBeTVdtAqIDe07ULRHMMnh6CzX7Hlc4pljJjzrGXwyJddzXScf+Ol67QJuwjj UuMEmKC+AsA6nieHaGS1m3ACre5iOsjyQdTGl/fp8fH/Ex6y2CM+rxcRYcNUuMqZaMA1 OfxDHutAowSRpXYmNKHZlvqKhUIq7dzgZknX6nu+WiiWsJedUvWfxP4D9Oz8GmVOe32/ Gh0lGlGXCPZZRWV9adPwqzfN2OCdaBjj4USJJ17HHhgmGZJB2m6Tq7+eRPLiUjFdu/N0 AeJw== 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; bh=OR+Emv/hXsuIpqoetjY/PmsPRuVeBGeNKk4nTUUJUzU=; b=bqWWE8oDDsur3iw1IVu4lixcd5g9livs3xGkCvK8TEtMOWQgSvYqCahfA/gkMJ4F1Q 7qzsh8UifevclSi2hIIDRE5KY1L4P1sYgtq9oitewjx7p/1CgnAJTZOBzLafZsqmELXe oxFwhZ0oWyWEnnHwY7sZtn+WFWsKNfmajPfIteH1nHKT1xOs8T1j0cXoxZBrpE2jQn8k d/L8TmNvKG6mkJRccCVP4F8zc5CmT6Q7EE4Y8UF7SUeLNixQPZFeqGwOpATBF0dn3iEW mHf4Rs63FlGMbWbNEShwTAkWnaOLndRNRBRQ7ZgwBnF4JvMEHNuyDcedgBQ8ROErHQhZ wCwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="IRMnBk/E"; 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 s19si8230002plp.151.2018.11.28.14.01.33; Wed, 28 Nov 2018 14:01:33 -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="IRMnBk/E"; 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 S1726724AbeK2JEf (ORCPT + 32 others); Thu, 29 Nov 2018 04:04:35 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:40577 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726688AbeK2JEe (ORCPT ); Thu, 29 Nov 2018 04:04:34 -0500 Received: by mail-pg1-f196.google.com with SMTP id z10so10100027pgp.7 for ; Wed, 28 Nov 2018 14:01:29 -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=OR+Emv/hXsuIpqoetjY/PmsPRuVeBGeNKk4nTUUJUzU=; b=IRMnBk/ELZHfdyqOzNiXDXXMFOgGNE01jpNMzoQRU9t1CwXX4MYuBvx1k25n4uQhJA X2BQ0yYsLtqDrktboR0ehpnwY1vRhaMx5/wAJqhlBjE41V31tso4ZKrXf4usxYPzKFew CHIiyE9STum4m75W01TsFRx3UeDFazllDTYkk= 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=OR+Emv/hXsuIpqoetjY/PmsPRuVeBGeNKk4nTUUJUzU=; b=mxTWqRwwNIO9fW9j+lqK4Z7UT/OHQkjSE32i9/n2I5ucHVJx6AyGaXL4Jg5EClT3dz crIXwbhwyqsZs9CVWxTjJe7X8peMRk+7+9kUTxhLam859T8a6qHd7ytDflcg+F4XO/3p T98vTTv0aMDrhOEZpoRvnan4W/IxmZFRXpjn+HDB9rOMLqDqSa1U8Ai7OHs0u6RDZh8r pJH7FNHwu+kSq3JbrZPK92pXKKYxYdaA+SIz0ZhrTHfaaZgIU5nOp7LrJrtt+tCqDb+8 FGImnVXKafDEFQpbeWDIfyApz7sLgDKWgEzTBn6mzTZFYilbVuCQyMI0SXiDTExC44uZ dFSA== X-Gm-Message-State: AA+aEWb17AwJzW8+JPLFXuP/8KkHgQ1HVZPBV5WGxP2Y5qw1KIKPv+We xszWx7Xo5eHUpZfrpLrqNQY4jg== X-Received: by 2002:a63:de46:: with SMTP id y6mr34645335pgi.198.1543442488773; Wed, 28 Nov 2018 14:01:28 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id 12sm8698051pgd.35.2018.11.28.14.01.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Nov 2018 14:01:28 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org, peterz@infradead.org, mingo@redhat.com Cc: 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, suzuki.poulosi@arm.com, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 5/6] perf tools: Make perf_evsel accessible to PMU driver configuration code Date: Wed, 28 Nov 2018 15:01:17 -0700 Message-Id: <1543442478-31465-6-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543442478-31465-1-git-send-email-mathieu.poirier@linaro.org> References: <1543442478-31465-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 the perf_evsel available to the PMU driver configuration code. That way function perf_evsel__run_ioctl() can be used from there 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 {