From patchwork Mon Dec 3 22:54:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 152789 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp7389283ljp; Mon, 3 Dec 2018 14:55:28 -0800 (PST) X-Google-Smtp-Source: AFSGD/V99PBqMyvAKxIjp9xm9Qqsw7sEv3q1LeejyoGlIC9IQeS/M0lhcJVYS2+KBDIyeq+mxirf X-Received: by 2002:a17:902:ab92:: with SMTP id f18mr17004215plr.221.1543877728122; Mon, 03 Dec 2018 14:55:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543877728; cv=none; d=google.com; s=arc-20160816; b=gnQf02utXFeft0lIxWXhyV6zh5sUc2jdyh0l5H17eNvd2V9Hhb0mUWm5VJ4O9i994L UXkvad/PwCCu/I0jrHA4CeifPfOzV00SCNsdQHRSWAcA4DVEloYJJV0FHoHOqn2+4zrv gnsYHSf5yhZYj9iDiXP8VswyQPLANpl/Ms7K5bGqN5v/BahmMT65IhsNs5Q5xYboy1R8 aWXtCsrjKLhqIFNuomV3/h9uUVK8jX4MCDQjaATzljbwJ9rnbf6AyGqsoKDL5Mf7SK0u zNfKnT2ZbtUIotf/Sw93hmIauzb+CQpnAWdwzY5CmZgNl1mJBxVUphk7osi5SkOL+0IN +LOA== 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=FUfS1RaNWRXjmkdl2KAF9Nzafx1FSt3pPdNp4K92aQRCnRNagqHR5tp4MuHI+JJnYp da8m/52ODfHfDfbDN7lIIGzcHJmoettGyCYOvvVKt/U/TCYbKbWQLZmSYTkBIrOpl+Ww LOpeHKJKxrp7lY0odxX6L1Ln2rHQMDD+eBpFw9L8cGtC9PXDWQWirMAj1Dqgt0Kz3XIF Lr8nlb+30rBcV4dbnEw4PlV+oNQRGoCwctgnBR46EHvyoeJgMKSDf4SraneRmCOJ3BIq /a6UKrn65DzoG6J7c7cesgFGGolX3oPOyZVtqaYzhYy3lszICvIMd7iAbnhHexDFBpYX KTkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AyRvDK8q; 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 r18si14058877pgo.9.2018.12.03.14.55.27; Mon, 03 Dec 2018 14:55:28 -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=AyRvDK8q; 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 S1726186AbeLCWz1 (ORCPT + 32 others); Mon, 3 Dec 2018 17:55:27 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:40385 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726110AbeLCWzI (ORCPT ); Mon, 3 Dec 2018 17:55:08 -0500 Received: by mail-pg1-f195.google.com with SMTP id z10so6388763pgp.7 for ; Mon, 03 Dec 2018 14:55:07 -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=AyRvDK8qLksuCM5m5xpMuXurPSGg1u+IafeohsJhoxOT3eIogfCW4RPPjunRaMAGwA ad0IaHDWj2AA2p2wwYE60jkwPcCr9e70/BHSZiJ8R0M8uR68uXXN15McVkgGA9q+3a1N adTO7L8gepdaup8oxHXWsnOfnN8NrfqmKIdbE= 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=kkYt1TYVI3ZsejcNXiq3GpiYKTN3bf46nYLTnQ7WGd81UpcA/RaatHwjF3Neo8izjK NGSQncH5O9dIAPhksTotr6hIiLBS9qgGOsY0PUPZ8zxAra6zpPLDyBhsNFKra9yD++mA 3R6Q60Q/rnMDRei1rUy92W6Mj3LhV9bvdL+gKBD3haiYqsfx/wkZtLLu5x2uhUv5ex6w nmzvmrSscgYc5l1WBLSg9KJZFfbt0oucbQZG9EBEr+jUklsuYPweHm+r+hIIEOFa7BOd A83DSNrB+dXpOXOaleYzwnY7Q/Pibo80hC8t0Y3TmfkMeVX76M2zt56eoJFRESnLdhZ4 heMA== X-Gm-Message-State: AA+aEWYL9wDhYtsclZQenPDXdOsQ50cRl8oq1pxrmQtDn2pH2w0s1KlV NLI+qUVmze19eigRKQGdC0UhGg== X-Received: by 2002:a63:bc02:: with SMTP id q2mr14944296pge.116.1543877707458; Mon, 03 Dec 2018 14:55:07 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id v9sm20933057pfg.144.2018.12.03.14.55.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Dec 2018 14:55:06 -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: [PATCH v5 5/6] perf tools: Make perf_evsel accessible to PMU driver configuration code Date: Mon, 3 Dec 2018 15:54:55 -0700 Message-Id: <1543877696-17174-6-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543877696-17174-1-git-send-email-mathieu.poirier@linaro.org> References: <1543877696-17174-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 {