From patchwork Mon Dec 17 17:21:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 154027 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2716238ljp; Mon, 17 Dec 2018 09:22:10 -0800 (PST) X-Google-Smtp-Source: AFSGD/XG10Nd5p6CgFD12R7GKCLdU8EFms1cafSoIGxyAkb16KOK9W6bGs5ai0hCSoKiczDuCFXA X-Received: by 2002:a63:82c6:: with SMTP id w189mr13058906pgd.344.1545067330847; Mon, 17 Dec 2018 09:22:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545067330; cv=none; d=google.com; s=arc-20160816; b=gb7hlVNhWfNfLCidxq1e/GDp55/5ZwdybL2yhcb0Sny1L/D28gMKLFPTFWPmVM9kTp H+G5AP2flmZSH0xur4NweAJWSAwsiAF4fFyLbLHt8yxNPl1Xv/Kz00dBJugEf9kBrF31 OcZZc02K/BQGxgdzzzHzRe/aFSE5oevtld3HZ67xIP6WU3+WEQubrsWQA0EoEc2OhY7o nmxRGiDVAuiPh3Hn1ZCDTUYLDFfIboK1s5hjL7vzg5WObYlM/q+8GH/0WUqbDKADZ7vK kWBl+sRYr02E+mRT4izJ6XBb8U/MXM+jHNqp7/c2QSQDa/5Ju5hDfQozpmlXY0ONmkpi Ixhw== 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=HWnBGa1x6rGGGm1/kS2g1IVVeTh1b3qx+fIttsoq8YroTyfuyz2xrDQZWcGyXRY+P+ Otu9shRfXF/kJPgAshX335+gZvvHqQ9/8M8HCGaRsPtefYWEu0jVl4dDinxciCW78Pw8 +FX5cmmtztQOlRpSyZGCB7sU/zHxpeZq4knX0jMX5d0aojsjmr7L69HN+5Vfxc0Q6rMr My7szUhwtl6gsO28+I+dB2v4dWimJ+6n7uYiVatW0QdolP6bBPIfhJCN5gbro7T5KiNQ HxASBPqQLkAzbRxXFOfI1VxMnDvaEGfQM7fsqkQ3q17mRi5YNWcxQuZlDGUg7BZAgKDU 3Lug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dPgpo2wa; 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 a28si11454942pgl.530.2018.12.17.09.22.10; Mon, 17 Dec 2018 09:22:10 -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=dPgpo2wa; 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 S2388398AbeLQRWJ (ORCPT + 31 others); Mon, 17 Dec 2018 12:22:09 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:36705 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388353AbeLQRV7 (ORCPT ); Mon, 17 Dec 2018 12:21:59 -0500 Received: by mail-pf1-f194.google.com with SMTP id b85so6696144pfc.3 for ; Mon, 17 Dec 2018 09:21:58 -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=dPgpo2waSyuc9a3TJA/V7dNAXshyYck6CqdnbQRgU5Z8zar4mMIWk+eTFg6ZmMowMJ N/bIULoBUbIuAso+anc3LL6Q/cNO7lU7KHqQv4YNR3XXy6mQ39XEDbAqytopUKvgrQ7B eIMoJAqVvSn1Ft50WIl077RWF3ZxDBIV6F5nc= 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=WfpuNIZOsHmNXSQ5131Tg2z2ZPtS2X8spQp6mCWFSGjNEEau0SxlqhiKfS61s8Yiy4 2A0nENvG+MA/Nr9UnU4vMnlGCYFG1bA0T7rnB31dAsX0GIXILYbvzJkHXZct8WDbKMig /vp6EwV6TAW05EYPvFhSbUnHay6jJbHqOT4gNrE0kW7O8xkej/PuIG6C+Zp7R3N6f1+t 33CzGcpgzCQpMD7cJKzVfYoJQIgnfuCzbQX4F9obknSftM+ArqzTh3bBqeEiPNy6mjr1 Xc19nBOH2TEBWLBjuBhSdgI09Y6WQUhzJJdDlh3AZaZorwcuQAgY3E4qL/hl0BZGggXs 64zg== X-Gm-Message-State: AA+aEWY6Ng5vvlKERKwXt3G9xuiJcWgbkqB50sELWgh/AhsUiTndNQcq O9+HKa2NKq88z1DBdSx2UiNDuA== X-Received: by 2002:a63:f901:: with SMTP id h1mr12824226pgi.154.1545067318085; Mon, 17 Dec 2018 09:21:58 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id j6sm20526648pfg.126.2018.12.17.09.21.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Dec 2018 09:21:57 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org, peterz@infradead.org, gregkh@linuxfoundation.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, hpa@zytor.com, suzuki.poulosi@arm.com, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RESEND PATCH v5 5/6] perf tools: Make perf_evsel accessible to PMU driver configuration code Date: Mon, 17 Dec 2018 10:21:45 -0700 Message-Id: <1545067306-31687-6-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545067306-31687-1-git-send-email-mathieu.poirier@linaro.org> References: <1545067306-31687-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 {